while (phase != PHASE_DEAD) { handle_events(); get_input(); if (kill_link) { lcp_close(0, "User request"); } if (asked_to_quit) { bundle_terminating = 1; if (phase == PHASE_MASTER) mp_bundle_terminated(); } if (open_ccp_flag) { if (phase == PHASE_NETWORK || phase == PHASE_RUNNING) { ccp_fsm[0].flags = OPT_RESTART; /* clears OPT_SILENT */ (*ccp_protent.open)(0); } } } struct channel { /* set of options for this channel */ option_t *options; /* find and process a per-channel options file */ void (*process_extra_options) __P((void)); /* check all the options that have been given */ void (*check_options) __P((void)); /* get the channel ready to do PPP, return a file descriptor */ int (*connect) __P((void)); /* we're finished with the channel */ void (*disconnect) __P((void)); /* put the channel into PPP `mode' */ int (*establish_ppp) __P((int)); /* take the channel out of PPP `mode', restore loopback if demand */ void (*disestablish_ppp) __P((int)); /* set the transmit-side PPP parameters of the channel */ void (*send_config) __P((int, u_int32_t, int, int)); /* set the receive-side PPP parameters of the channel */ void (*recv_config) __P((int, u_int32_t, int, int)); /* cleanup on error or normal exit */ void (*cleanup) __P((void)); /* close the device, called in children after fork */ void (*close) __P((void)); int *retry_times; int *time_out; int *relflag; }; struct protent { u_short protocol; /* PPP protocol number */ /* Initialization procedure */ void (*init) __P((int unit)); /* Process a received packet */ void (*input) __P((int unit, u_char *pkt, int len)); /* Process a received protocol-reject */ void (*protrej) __P((int unit)); /* Lower layer has come up */ void (*lowerup) __P((int unit)); /* Lower layer has gone down */ void (*lowerdown) __P((int unit)); /* Open the protocol */ void (*open) __P((int unit)); /* Close the protocol */ void (*close) __P((int unit, char *reason)); /* Print a packet in readable form */ int (*printpkt) __P((u_char *pkt, int len, void (*printer) __P((void *, char *, ...)), void *arg)); /* Process a received data packet */ void (*datainput) __P((int unit, u_char *pkt, int len)); bool enabled_flag; /* 0 iff protocol is disabled */ char *name; /* Text name of protocol */ char *data_name; /* Text name of corresponding data protocol */ option_t *options; /* List of command-line options */ /* Check requested options, assign defaults */ void (*check_options) __P((void)); /* Configure interface for demand-dial */ int (*demand_conf) __P((int unit)); /* Say whether to bring up link for this pkt */ int (*active_pkt) __P((u_char *pkt, int len)); };typedef struct fsm { int unit; /* Interface unit number */ int protocol; /* Data Link Layer Protocol field value */ int state; /* State */ int flags; /* Contains option bits */ u_char id; /* Current id */ u_char reqid; /* Current request id */ u_char seen_ack; /* Have received valid Ack/Nak/Rej to Req */ int timeouttime; /* Timeout time in milliseconds */ int maxconfreqtransmits; /* Maximum Configure-Request transmissions */ int retransmits; /* Number of retransmissions left */ int maxtermtransmits; /* Maximum Terminate-Request transmissions */ int nakloops; /* Number of nak loops since last ack */ int rnakloops; /* Number of naks received */ int maxnakloops; /* Maximum number of nak loops tolerated */ struct fsm_callbacks *callbacks; /* Callback routines */ char *term_reason; /* Reason for closing protocol */ int term_reason_len; /* Length of term_reason */ } fsm; typedef struct fsm_callbacks { void (*resetci) /* Reset our Configuration Information */ __P((fsm *)); int (*cilen) /* Length of our Configuration Information */ __P((fsm *)); void (*addci) /* Add our Configuration Information */ __P((fsm *, u_char *, int *)); int (*ackci) /* ACK our Configuration Information */ __P((fsm *, u_char *, int)); int (*nakci) /* NAK our Configuration Information */ __P((fsm *, u_char *, int, int)); int (*rejci) /* Reject our Configuration Information */ __P((fsm *, u_char *, int)); int (*reqci) /* Request peer's Configuration Information */ __P((fsm *, u_char *, int *, int)); void (*up) /* Called when fsm reaches OPENED state */ __P((fsm *)); void (*down) /* Called when fsm leaves OPENED state */ __P((fsm *)); void (*starting) /* Called when we want the lower layer */ __P((fsm *)); void (*finished) /* Called when we don't want the lower layer */ __P((fsm *)); void (*protreject) /* Called when Protocol-Reject received */ __P((int)); void (*retransmit) /* Retransmission is necessary */ __P((fsm *)); int (*extcode) /* Called when unknown code received */ __P((fsm *, int, int, u_char *, int)); char *proto_name; /* String name for protocol (for messages) */ } fsm_callbacks;