summaryrefslogtreecommitdiffstats
path: root/usr.sbin/ppp/fsm.h
diff options
context:
space:
mode:
authorbrian <brian@FreeBSD.org>2002-04-16 23:57:09 +0000
committerbrian <brian@FreeBSD.org>2002-04-16 23:57:09 +0000
commitb86a2d03f8a98e438b3c78ca9fb2a04a1565f133 (patch)
tree5b0847031a0b3f8cbd6098a3ecd67ce4673d2eca /usr.sbin/ppp/fsm.h
parenta9db9e22216eec27a36b64873a2eeb434586b0dd (diff)
downloadFreeBSD-src-b86a2d03f8a98e438b3c78ca9fb2a04a1565f133.zip
FreeBSD-src-b86a2d03f8a98e438b3c78ca9fb2a04a1565f133.tar.gz
Make the way FSM options are processed easier to read by using structures
instead of u_char *. The changes are cosmetic except: RecvConfigAck() now displays the options that are being ACK'd Huge (bogus) options sent from the peer won't cause an infinite loop SendIdent and ReceiveIdent are displayed consistenlty with other FSM data LCP AUTHPROTO options that aren't understood are NAK'd, not REJ'd
Diffstat (limited to 'usr.sbin/ppp/fsm.h')
-rw-r--r--usr.sbin/ppp/fsm.h58
1 files changed, 39 insertions, 19 deletions
diff --git a/usr.sbin/ppp/fsm.h b/usr.sbin/ppp/fsm.h
index 126c9b7..2e57775 100644
--- a/usr.sbin/ppp/fsm.h
+++ b/usr.sbin/ppp/fsm.h
@@ -56,6 +56,8 @@
#define FSM_REQ_TIMER 1
#define FSM_TRM_TIMER 2
+#define FSM_OPTLEN 100
+
struct fsm;
struct fsm_retry {
@@ -65,24 +67,24 @@ struct fsm_retry {
};
struct fsm_decode {
- u_char ack[100], *ackend;
- u_char nak[100], *nakend;
- u_char rej[100], *rejend;
+ u_char ack[FSM_OPTLEN], *ackend;
+ u_char nak[FSM_OPTLEN], *nakend;
+ u_char rej[FSM_OPTLEN], *rejend;
};
struct fsm_callbacks {
- int (*LayerUp) (struct fsm *); /* Layer is now up (tlu) */
- void (*LayerDown) (struct fsm *); /* About to come down (tld) */
- void (*LayerStart) (struct fsm *); /* Layer about to start up (tls) */
- void (*LayerFinish) (struct fsm *); /* Layer now down (tlf) */
- void (*InitRestartCounter) (struct fsm *, int); /* Set fsm timer load */
- void (*SendConfigReq) (struct fsm *); /* Send REQ please */
- void (*SentTerminateReq) (struct fsm *); /* Term REQ just sent */
- void (*SendTerminateAck) (struct fsm *, u_char); /* Send Term ACK please */
- void (*DecodeConfig) (struct fsm *, u_char *, int, int, struct fsm_decode *);
- /* Deal with incoming data */
- int (*RecvResetReq) (struct fsm *fp); /* Reset output */
- void (*RecvResetAck) (struct fsm *fp, u_char); /* Reset input */
+ int (*LayerUp)(struct fsm *); /* Layer is now up (tlu) */
+ void (*LayerDown)(struct fsm *); /* About to come down (tld) */
+ void (*LayerStart)(struct fsm *); /* Layer about to start (tls) */
+ void (*LayerFinish)(struct fsm *); /* Layer now down (tlf) */
+ void (*InitRestartCounter)(struct fsm *, int);/* Set fsm timer load */
+ void (*SendConfigReq)(struct fsm *); /* Send REQ please */
+ void (*SentTerminateReq)(struct fsm *); /* Term REQ just sent */
+ void (*SendTerminateAck)(struct fsm *, u_char); /* Send Term ACK please */
+ void (*DecodeConfig)(struct fsm *, u_char *, u_char *, int,
+ struct fsm_decode *); /* Deal with incoming data */
+ int (*RecvResetReq)(struct fsm *fp); /* Reset output */
+ void (*RecvResetAck)(struct fsm *fp, u_char); /* Reset input */
};
struct fsm_parent {
@@ -159,12 +161,25 @@ struct fsmheader {
#define CODE_RESETREQ 14 /* Used in CCP */
#define CODE_RESETACK 15 /* Used in CCP */
-/* Minimum config req size. This struct is *only* used for it's size */
-struct fsmconfig {
- u_char type;
- u_char length;
+struct fsm_opt_hdr {
+ u_char id;
+ u_char len;
+};
+
+#define MAX_FSM_OPT_LEN 20
+struct fsm_opt {
+ struct fsm_opt_hdr hdr;
+ u_char data[MAX_FSM_OPT_LEN-2];
};
+#define INC_FSM_OPT(ty, length, o) \
+ do { \
+ (o)->hdr.id = (ty); \
+ (o)->hdr.len = (length); \
+ (o) = (struct fsm_opt *)((u_char *)(o) + (length)); \
+ } while (0)
+
+
extern void fsm_Init(struct fsm *, const char *, u_short, int, int, int,
struct bundle *, struct link *, const struct fsm_parent *,
struct fsm_callbacks *, const char * const [3]);
@@ -179,3 +194,8 @@ extern void fsm_NullRecvResetAck(struct fsm *, u_char);
extern void fsm_Reopen(struct fsm *);
extern void fsm2initial(struct fsm *);
extern const char *State2Nam(u_int);
+extern struct fsm_opt *fsm_readopt(u_char **);
+extern void fsm_rej(struct fsm_decode *, const struct fsm_opt *);
+extern void fsm_ack(struct fsm_decode *, const struct fsm_opt *);
+extern void fsm_nak(struct fsm_decode *, const struct fsm_opt *);
+extern void fsm_opt_normalise(struct fsm_decode *);
OpenPOWER on IntegriCloud