home *** CD-ROM | disk | FTP | other *** search
/ Super Net 1 / SUPERNET_1.iso / PC / OTROS / SUN / PPP / SUNOS_OL / DDP_PPP.TAR / fsm.h < prev    next >
Encoding:
C/C++ Source or Header  |  1991-01-03  |  3.9 KB  |  116 lines

  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 retransmits;        /* Number of retransmissions */
  71.     int maxtermtransmits;    /* Maximum Terminate-Request transmissions */
  72.     int nakloops;        /* Number of nak loops since last timeout */
  73.     int maxnakloops;        /* Maximum number of nak loops tolerated */
  74.     fsm_callbacks *callbacks;    /* Callback routines */
  75. } fsm;
  76.  
  77.  
  78. /*
  79.  * Link states.
  80.  */
  81. #define CLOSED        1    /* Connection closed */
  82. #define LISTEN        2    /* Listening for a Config Request */
  83. #define REQSENT        3    /* We've sent a Config Request */
  84. #define ACKSENT        4    /* We've sent a Config Ack */
  85. #define ACKRCVD        5    /* We've received a Config Ack */
  86. #define OPEN        6    /* Connection open */
  87. #define TERMSENT    7    /* We've sent a Terminate Request */
  88.  
  89.  
  90. /*
  91.  * Flags.
  92.  */
  93. #define LOWERUP        1    /* The lower level is UP */
  94. #define AOPENDING    2    /* Active Open pending timeout of request */
  95. #define POPENDING    4    /* Passive Open pending timeout of request */
  96.  
  97.  
  98. /*
  99.  * Timeouts.
  100.  */
  101. #define DEFTIMEOUT    3    /* Timeout time in seconds */
  102. #define DEFMAXTERMTRANSMITS 10    /* Maximum Terminate-Request transmissions */
  103.  
  104.  
  105. #define DEFMAXNAKLOOPS    10    /* Maximum number of nak loops */
  106.  
  107.  
  108. void fsm_init();
  109. void fsm_activeopen();
  110. void fsm_passiveopen();
  111. void fsm_close();
  112. void fsm_lowerup();
  113. void fsm_lowerdown();
  114. void fsm_protreject();
  115. void fsm_input();
  116.