NetBSD/usr.sbin/pppd/fsm.h

133 lines
4.8 KiB
C
Raw Normal View History

1993-08-14 10:29:28 +04:00
/*
* fsm.h - {Link, IP} Control Protocol Finite State Machine definitions.
*
* Copyright (c) 1989 Carnegie Mellon University.
* All rights reserved.
*
* Redistribution and use in source and binary forms are permitted
* provided that the above copyright notice and this paragraph are
* duplicated in all such forms and that any documentation,
* advertising materials, and other materials related to such
* distribution and use acknowledge that the software was developed
* by Carnegie Mellon University. The name of the
* University may not be used to endorse or promote products derived
* from this software without specific prior written permission.
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: fsm.h,v 1.3 1993/11/10 01:34:07 paulus Exp $
1993-08-14 10:29:28 +04:00
*/
/*
* Packet header = Code, id, length.
*/
#define HEADERLEN (sizeof (u_char) + sizeof (u_char) + sizeof (u_short))
/*
* CP (LCP, IPCP, etc.) codes.
*/
#define CONFREQ 1 /* Configuration Request */
#define CONFACK 2 /* Configuration Ack */
#define CONFNAK 3 /* Configuration Nak */
#define CONFREJ 4 /* Configuration Reject */
#define TERMREQ 5 /* Termination Request */
#define TERMACK 6 /* Termination Ack */
#define CODEREJ 7 /* Code Reject */
#define PROTREJ 8 /* Protocol Reject */
#define ECHOREQ 9 /* Echo Request */
#define ECHOREP 10 /* Echo Reply */
#define DISCREQ 11 /* Discard Request */
#define KEEPALIVE 12 /* Keepalive */
/*
* Each FSM is described by a fsm_callbacks and a fsm structure.
*/
typedef struct fsm_callbacks {
void (*resetci)(); /* Reset our Configuration Information */
int (*cilen)(); /* Length of our Configuration Information */
1993-08-14 10:29:28 +04:00
void (*addci)(); /* Add our Configuration Information */
int (*ackci)(); /* ACK our Configuration Information */
int (*nakci)(); /* NAK our Configuration Information */
int (*rejci)(); /* Reject our Configuration Information */
int (*reqci)(); /* Request peer's Configuration Information */
void (*up)(); /* Called when fsm reaches OPENED state */
void (*down)(); /* Called when fsm leaves OPENED state */
void (*starting)(); /* Called when we want the lower layer */
void (*finished)(); /* Called when we don't want the lower layer */
1993-08-14 10:29:28 +04:00
void (*protreject)(); /* Called when Protocol-Reject received */
void (*retransmit)(); /* Retransmission is necessary */
int (*extcode)(); /* Called when unknown code received */
char *proto_name; /* String name for protocol (for messages) */
1993-08-14 10:29:28 +04:00
} fsm_callbacks;
typedef struct fsm {
int unit; /* Interface unit number */
int protocol; /* Data Link Layer Protocol field value */
1993-08-14 10:29:28 +04:00
int state; /* State */
int flags; /* Contains option bits */
1993-08-14 10:29:28 +04:00
u_char id; /* Current id */
u_char reqid; /* Current request id */
int timeouttime; /* Timeout time in milliseconds */
int maxconfreqtransmits; /* Maximum Configure-Request transmissions */
int retransmits; /* Number of retransmissions left */
1993-08-14 10:29:28 +04:00
int maxtermtransmits; /* Maximum Terminate-Request transmissions */
int nakloops; /* Number of nak loops since last ack */
1993-08-14 10:29:28 +04:00
int maxnakloops; /* Maximum number of nak loops tolerated */
fsm_callbacks *callbacks; /* Callback routines */
} fsm;
/*
* Link states.
*/
#define INITIAL 0 /* Down, hasn't been opened */
#define STARTING 1 /* Down, been opened */
#define CLOSED 2 /* Up, hasn't been opened */
#define STOPPED 3 /* Open, waiting for down event */
#define CLOSING 4 /* Terminating the connection, not open */
#define STOPPING 5 /* Terminating, but open */
#define REQSENT 6 /* We've sent a Config Request */
#define ACKRCVD 7 /* We've received a Config Ack */
#define ACKSENT 8 /* We've sent a Config Ack */
#define OPENED 9 /* Connection available */
1993-08-14 10:29:28 +04:00
/*
* Flags - indicate options controlling FSM operation
1993-08-14 10:29:28 +04:00
*/
#define OPT_PASSIVE 1 /* Don't die if we don't get a response */
#define OPT_RESTART 2 /* Treat 2nd OPEN as DOWN, UP */
#define OPT_SILENT 4 /* Wait for peer to speak first */
1993-08-14 10:29:28 +04:00
/*
* Timeouts.
*/
#define DEFTIMEOUT 3 /* Timeout time in seconds */
#define DEFMAXTERMREQS 2 /* Maximum Terminate-Request transmissions */
#define DEFMAXCONFREQS 10 /* Maximum Configure-Request transmissions */
1993-08-14 10:29:28 +04:00
#define DEFMAXNAKLOOPS 10 /* Maximum number of nak loops */
/*
* Prototypes
*/
1993-08-14 10:29:28 +04:00
void fsm_init __ARGS((fsm *));
void fsm_lowerup __ARGS((fsm *));
void fsm_lowerdown __ARGS((fsm *));
void fsm_open __ARGS((fsm *));
void fsm_close __ARGS((fsm *));
1993-08-14 10:29:28 +04:00
void fsm_input __ARGS((fsm *, u_char *, int));
void fsm_protreject __ARGS((fsm *));
1993-08-14 10:29:28 +04:00
void fsm_sdata __ARGS((fsm *, int, int, u_char *, int));
/*
* Variables
*/
extern int peer_mru[]; /* currently negotiated peer MRU (per unit) */