Commit | Line | Data |
---|---|---|
2a905848 RG |
1 | /* |
2 | * fsm.h - {Link, IP} Control Protocol Finite State Machine definitions. | |
3 | * | |
4 | * Copyright (c) 1989 Carnegie Mellon University. | |
5 | * All rights reserved. | |
6 | * | |
7 | * Redistribution and use in source and binary forms are permitted | |
8 | * provided that the above copyright notice and this paragraph are | |
9 | * duplicated in all such forms and that any documentation, | |
10 | * advertising materials, and other materials related to such | |
11 | * distribution and use acknowledge that the software was developed | |
12 | * by Carnegie Mellon University. The name of the | |
13 | * University may not be used to endorse or promote products derived | |
14 | * from this software without specific prior written permission. | |
15 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR | |
16 | * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED | |
17 | * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. | |
18 | */ | |
19 | ||
20 | /* | |
21 | * Packet header = Code, id, length. | |
22 | */ | |
23 | #define HEADERLEN (sizeof (u_char) + sizeof (u_char) + sizeof (u_short)) | |
24 | ||
25 | ||
26 | /* | |
27 | * CP (LCP, IPCP, etc.) codes. | |
28 | */ | |
29 | #define CONFREQ 1 /* Configuration Request */ | |
30 | #define CONFACK 2 /* Configuration Ack */ | |
31 | #define CONFNAK 3 /* Configuration Nak */ | |
32 | #define CONFREJ 4 /* Configuration Reject */ | |
33 | #define TERMREQ 5 /* Termination Request */ | |
34 | #define TERMACK 6 /* Termination Ack */ | |
35 | #define CODEREJ 7 /* Code Reject */ | |
36 | #define PROTREJ 8 /* Protocol Reject */ | |
37 | #define ECHOREQ 9 /* Echo Request */ | |
38 | #define ECHOREP 10 /* Echo Reply */ | |
39 | #define DISCREQ 11 /* Discard Request */ | |
40 | #define KEEPALIVE 12 /* Keepalive */ | |
41 | ||
42 | ||
43 | /* | |
44 | * Each FSM is described by a fsm_callbacks and a fsm structure. | |
45 | */ | |
46 | typedef struct fsm_callbacks { | |
47 | void (*resetci)(); /* Reset our Configuration Information */ | |
48 | int (*cilen)(); /* Length of our Configuration Information */ | |
49 | void (*addci)(); /* Add our Configuration Information */ | |
50 | int (*ackci)(); /* ACK our Configuration Information */ | |
51 | void (*nakci)(); /* NAK our Configuration Information */ | |
52 | void (*rejci)(); /* Reject our Configuration Information */ | |
53 | u_char (*reqci)(); /* Request peer's Configuration Information */ | |
54 | void (*up)(); /* Called when fsm reaches OPEN state */ | |
55 | void (*down)(); /* Called when fsm leaves OPEN state */ | |
56 | void (*closed)(); /* Called when fsm reaches CLOSED state */ | |
57 | void (*protreject)(); /* Called when Protocol-Reject received */ | |
58 | void (*retransmit)(); /* Retransmission is necessary */ | |
59 | } fsm_callbacks; | |
60 | ||
61 | ||
62 | typedef struct fsm { | |
63 | int unit; /* Interface unit number */ | |
64 | u_short protocol; /* Data Link Layer Protocol field value */ | |
65 | int state; /* State */ | |
66 | int flags; /* Flags */ | |
67 | u_char id; /* Current id */ | |
68 | u_char reqid; /* Current request id */ | |
69 | int timeouttime; /* Timeout time in milliseconds */ | |
70 | int maxconfreqtransmits; /* Maximum Configure-Request transmissions */ | |
71 | int retransmits; /* Number of retransmissions */ | |
72 | int maxtermtransmits; /* Maximum Terminate-Request transmissions */ | |
73 | int nakloops; /* Number of nak loops since last timeout */ | |
74 | int maxnakloops; /* Maximum number of nak loops tolerated */ | |
75 | fsm_callbacks *callbacks; /* Callback routines */ | |
76 | } fsm; | |
77 | ||
78 | ||
79 | /* | |
80 | * Link states. | |
81 | */ | |
82 | #define CLOSED 1 /* Connection closed */ | |
83 | #define LISTEN 2 /* Listening for a Config Request */ | |
84 | #define REQSENT 3 /* We've sent a Config Request */ | |
85 | #define ACKSENT 4 /* We've sent a Config Ack */ | |
86 | #define ACKRCVD 5 /* We've received a Config Ack */ | |
87 | #define OPEN 6 /* Connection open */ | |
88 | #define TERMSENT 7 /* We've sent a Terminate Request */ | |
89 | ||
90 | ||
91 | /* | |
92 | * Flags. | |
93 | */ | |
94 | #define LOWERUP 1 /* The lower level is UP */ | |
95 | #define AOPENDING 2 /* Active Open pending timeout of request */ | |
96 | #define POPENDING 4 /* Passive Open pending timeout of request */ | |
97 | ||
98 | ||
99 | /* | |
100 | * Timeouts. | |
101 | */ | |
102 | #define DEFTIMEOUT 3 /* Timeout time in seconds */ | |
103 | #define DEFMAXTERMTRANSMITS 10 /* Maximum Terminate-Request transmissions */ | |
104 | #define DEFMAXCONFIGREQS 10 /* Maximum Configure-Request transmissions */ | |
105 | ||
106 | ||
107 | #define DEFMAXNAKLOOPS 10 /* Maximum number of nak loops */ | |
108 | ||
109 | ||
110 | void fsm_init __ARGS((fsm *)); | |
111 | void fsm_activeopen __ARGS((fsm *)); | |
112 | void fsm_passiveopen __ARGS((fsm *)); | |
113 | void fsm_close __ARGS((fsm *)); | |
114 | void fsm_lowerup __ARGS((fsm *)); | |
115 | void fsm_lowerdown __ARGS((fsm *)); | |
116 | void fsm_protreject __ARGS((fsm *)); | |
117 | void fsm_input __ARGS((fsm *, u_char *, int)); | |
118 | void fsm_sdata __ARGS((fsm *, int, int, u_char *, int)); |