home *** CD-ROM | disk | FTP | other *** search
/ The Pier Shareware 6 / The_Pier_Shareware_Number_6_(The_Pier_Exchange)_(1995).iso / 024 / psi110g.zip / RSPF.H < prev    next >
C/C++ Source or Header  |  1994-04-17  |  6KB  |  152 lines

  1. #ifndef RSPFPKTLEN
  2. struct rspfpacketh {
  3.     char version;
  4.     char type;
  5.     unsigned char fragn;
  6.     unsigned char fragtot;
  7.     int16 csum;
  8.     unsigned char sync;
  9.     unsigned char nodes;
  10.     int16 envid;
  11. };
  12. #define RSPFPKTLEN  10
  13. struct rspfnodeh {
  14.     int32 addr;
  15.     short seq;          /* 16 bit signed int */
  16.     unsigned char subseq;
  17.     unsigned char links;
  18. };
  19. #define RSPFNODELEN 8
  20. struct rspflinkh {
  21.     unsigned char horizon;
  22.     unsigned char erp;
  23.     unsigned char cost;
  24.     unsigned char adjn;
  25. };
  26. #define RSPFLINKLEN 4
  27. struct rspfrouter {
  28.     struct rspfrouter *next;
  29.     char sent;          /* True if the data has already been sent */
  30.     char subseq;        /* Sub-sequence number of latest update */
  31.     int32 time;         /* Time when data was last received */
  32.     struct mbuf *data;      /* Latest data, starting with node header */
  33. };
  34. #define NULLRROUTER (struct rspfrouter *)0
  35. struct rspfreasm {
  36.     struct rspfreasm *next;
  37.     int32 addr;         /* Address of originating station */
  38.     int32 time;         /* Time when a fragment was last received */
  39.     struct mbuf *data;      /* A queue of fragments */
  40. };
  41. #define NULLRREASM  (struct rspfreasm *)0
  42.   
  43. #define RSPF_RTIME  30      /* Reassembly timeout in seconds */
  44.   
  45. /* RRH header, host format */
  46. struct rrh {
  47.     char version;
  48.     char type;
  49.     int16 csum;
  50.     int32 addr;
  51.     int16 seq;
  52.     char flags;
  53. #define RSPFMODE    1   /* Tells whether we want a VC link or not */
  54. };
  55. #define RRHLEN      11
  56. union rspf {
  57.     struct {
  58.         char version;
  59. #define RSPF_VERSION    21      /* Current version */
  60.         char type;
  61. #define RSPF_FULLPKT    1       /* Routing update */
  62. #define RSPF_RRH    3       /* Router-Router Hello */
  63.     } hdr;
  64.     struct rspfpacketh pkthdr;
  65.     struct rrh rrh;
  66. };
  67.   
  68. #define RSPF_PROCMAX    5       /* Maximum number of processes handling
  69.                        suspect adjacencies */
  70.   
  71. struct rspfadj {
  72.     struct rspfadj *next;
  73.     int32 addr;
  74.     unsigned char cost;     /* Cost to reach this adjacency */
  75.     int16 seq;          /* Number of AX.25 frames it has sent */
  76.     int32 heard;        /* Number of heard AX.25 frames */
  77.     struct timer timer;     /* Adjacency turns suspect if timer expires */
  78.     char tos;           /* Preferred type of service */
  79.     char added;         /* Used by the SPF algorithm */
  80.     void *scratch;      /* also used by SPF (contains the interface) */
  81.     struct proc *pinger;    /* Pointer to rspfping process */
  82.     char state;
  83. #define RSPF_TENTATIVE  0
  84. #define RSPF_OK     1
  85. #define RSPF_SUSPECT    2
  86. #define RSPF_BAD    3
  87.     int okcnt;          /* Times adjacency has entered OK state */
  88. };
  89. #define NULLADJ (struct rspfadj *)0
  90.   
  91. struct rspfiface {
  92.     struct rspfiface *next;
  93.     struct iface *iface;
  94.     unsigned char quality;  /* Default quality for this interface */
  95.     unsigned char horizon;  /* Default horizon value */
  96.     unsigned char erp;      /* Default ERP factor */
  97. };
  98. #define NULLRIFACE (struct rspfiface *)0
  99.   
  100. struct rspf_stat {
  101.     unsigned rrhin;        /* RRH's received */
  102.     unsigned rrhout;       /* RRH's sent */
  103.     unsigned updatein;     /* Updates received */
  104.     unsigned updateout;    /* Updates sent */
  105.     unsigned badcsum;      /* Bad checksums */
  106.     unsigned badvers;      /* Bad versions */
  107.     unsigned norspfiface;  /* RSPF packets from non RSPF interfaces */
  108.     unsigned oldreport;    /* Node headers with old sequence numbers */
  109.     unsigned outpolls;     /* Poll packets sent */
  110.     unsigned noadjupdate;  /* Updates received from non-adjacencies */
  111. };
  112.   
  113. /* Event types in main loop */
  114. #define RSPFE_RRH   1   /* It is time to send a new RRH */
  115. #define RSPFE_CHECK 2   /* An adjacency has becomed suspect */
  116. #define RSPFE_UPDATE    3   /* Time to send a new routing updates */
  117. #define RSPFE_ARP   4   /* An ARP reply was received */
  118. #define RSPFE_PACKET    5   /* A packet was received (RRH or Update) */
  119.   
  120. extern struct rspf_stat Rspf_stat;
  121. extern struct rspfreasm *Rspfreasmq;
  122. extern struct rspfiface *Rspfifaces;
  123. extern struct rspfadj *Adjs;
  124. extern struct rspfrouter *Rspfrouters;
  125. extern struct mbuf *Rspfinq;
  126. extern struct timer Rspfreasmt, Susptimer;
  127. extern char *Rrh_message;
  128. extern int Rspfownmode;
  129. extern unsigned short Rspfpingmax;
  130.   
  131. #ifdef __GNUC__
  132. struct ip;            /* forward declarations */
  133. struct pseudo_header;
  134. #endif
  135.   
  136. void rspfmain __ARGS((int v,void *v1,void *v2));
  137. void rspf_input __ARGS((struct iface *iface,struct ip *ip,struct mbuf *bp,int rxbroadcast));
  138. void rspfarpupcall __ARGS((int32 addr,int16 hardware,struct iface *iface));
  139. void rspfrouteupcall __ARGS((int32 addr,unsigned bits,int32 gateway));
  140. void rspfevent __ARGS((void *t));
  141. void rspfsuspect __ARGS((void *t));
  142. struct mbuf *makeownupdate __ARGS((int32 dest,int new));
  143. int ntohrspf __ARGS((union rspf *rspf,struct mbuf **bpp));
  144. int ntohrspfnode __ARGS((struct rspfnodeh *nodeh,struct mbuf **bpp));
  145. int ntohrspflink __ARGS((struct rspflinkh *linkh,struct mbuf **bpp));
  146. struct mbuf *htonrrh __ARGS((struct rrh *rrh,struct mbuf *data,struct pseudo_header *ph));
  147. struct mbuf *htonrspf __ARGS((struct rspfpacketh *pkth,struct mbuf *data));
  148. struct mbuf *htonrspfnode __ARGS((struct rspfnodeh *nodeh,struct mbuf *data));
  149. struct mbuf *htonrspflink __ARGS((struct rspflinkh *linkh,struct mbuf *data));
  150. void rspfnodedump __ARGS((FILE *fp,struct mbuf **bpp,int adjcnt));
  151. #endif
  152.