Watt-32 tcp/ip  2.2 dev-rel.10
ppp.h
Go to the documentation of this file.
1 
3 #ifndef _w32_PPP_H
4 #define _w32_PPP_H
5 
6 #include <time.h>
7 #include <sys/socket.h> /* <sys/wtypes.h> */
8 #include <net/ppp_defs.h> /* PPP_MRU etc. */
9 
10 void ppp_start (int debug);
11 void ppp_input (const BYTE *inbuf, WORD len);
12 
13 
14 /* Standard link phases
15  */
16 enum ppp_phase {
17  phDead, phEstablish, phAuthenticate,
18  phNetwork, phTerminate
19  };
20 
21 /* Standard set of events
22  */
23 enum ppp_event {
24  evUp, evDown, evOpen, evClose, evTOp,
25  evTOm, evRCRp, evRCRm, evRCA, evRCN,
26  evRTR, evRTA, evRUC, evRXJp, evRXJm, evRXR
27  };
28 
29 /* Standard negotiation states
30  */
31 enum xcp_state {
32  stInitial, stStarting, stClosed, stStopped,
33  stClosing, stStopping, stReqSent, stAckRcvd,
34  stAckSent, stOpened, stNoChange
35  };
36 
37 /* Standard set of actions
38  */
39 enum xcp_action {
40  acNull, acIrc, acScr, acTls, acTlf, acStr, acSta,
41  acSca, acScn, acScj, acTld, acTlu, acZrc, acSer
42  };
43 
44 /* Standard message code numbers
45  */
46 #define CODE_CONF_REQ 1
47 #define CODE_CONF_ACK 2
48 #define CODE_CONF_NAK 3
49 #define CODE_CONF_REJ 4
50 #define CODE_TERM_REQ 5
51 #define CODE_TERM_ACK 6
52 #define CODE_CODE_REJ 7
53 #define CODE_PROTO_REJ 8
54 #define CODE_ECHO_REQ 9
55 #define CODE_ECHO_REP 10
56 #define CODE_DISCARD_REQ 11
57 
58 
59 struct ppp_xcp;
60 struct ppp_state;
61 struct xcp_type;
62 
63 typedef void (*xcp_func) (struct ppp_state *state,
64  struct ppp_xcp *xcp,
65  const struct xcp_type *tp,
66  const BYTE *buf, int len);
67 
68 typedef void (*ppp_func) (struct ppp_state *state,
69  struct ppp_xcp *xcp);
70 
71 /* Basic information about an option.
72  */
73 struct xcp_type {
74  char *name; /* Printable name */
75  short type; /* option number (-1 to end) */
76  short flag; /* set to ignore default value */
77  BYTE minlen; /* minimum overall length */
78  BYTE maxlen; /* maximum overall length */
79  DWORD default_value; /* default */
80  xcp_func validate_req;
81  xcp_func validate_nak;
82  xcp_func show;
83  };
84 
85 enum os_state {
86  osUsable,
87  osUnusable
88  };
89 
90 struct option_state {
91  DWORD my_value; /* sent in Configure-Request */
92  DWORD peer_value; /* last received */
93  enum os_state state; /* flag for rejects */
94  };
95 
96 struct ppp_xcp {
97  const char *name; /* name of control protocol */
98  enum xcp_state state; /* state machine */
99  int restart; /* standard restart count */
100  time_t timeout; /* standard restart timer */
101  int naks_sent;/* consecutive naks sent */
102  ppp_func deliver; /* handler */
103  struct xcp_type *types; /* option types supported here */
104  struct option_state *opts; /* current negotiation state */
105  WORD proto; /* PPP protocol ID */
106  BYTE ident; /* current ID number */
107  };
108 
109 enum parse_state {
110  psOK, psNak,
111  psRej, psBad
112  };
113 
114 struct ppp_state {
115  enum ppp_phase phase; /* link phase */
116  enum parse_state parse_state; /* request parsing state */
117  struct ppp_xcp xcps[2]; /* installed XCPs */
118 #define XCP_LCP 0
119 #define XCP_IPCP 1
120  int timeout_period; /* value for restart timer */
121  int mlen; /* packet length */
122  DWORD mymagic, hismagic; /* magic numbers (for echo) */
123  BYTE *bp, *up; /* pointers to packet buffers */
124  BYTE *inbuffer;
125  BYTE outbuffer [PPP_MRU];
126  };
127 
128 #endif /* _w32_PPP_H */
Definition: ppp.h:96
Definition: ppp.h:114
Definition: ppp.h:73
void ppp_input(const BYTE *inbuf, WORD len)
The PPP input handler.
Definition: ppp.c:845