home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 3 / PDCD_3.iso / internet / tcpipsrc / h / if / NETROM < prev    next >
Text File  |  1992-04-05  |  7KB  |  180 lines

  1. /* net/rom support definitions
  2.  * Copyright 1989 by Daniel M. Frank, W9NK.  Permission granted for
  3.  * non-commercial distribution only.
  4.  */
  5.  
  6. #define NR3HLEN         15      /* length of a net/rom level 3 hdr, */
  7. #define NR3DLEN         241     /* max data size in net/rom l3 packet */
  8. #define NR3NODESIG      0xff    /* signature for nodes broadcast */
  9. #define NR3NODEHL       7       /* nodes bc header length */
  10.  
  11. #define NRNUMIFACE      10      /* number of interfaces associated */
  12.                                 /* with net/rom network layer      */
  13. #define NRNUMCHAINS     17      /* number of chains in the */
  14.                                 /* neighbor and route hash tables */
  15. #define NRRTDESTLEN     21      /* length of destination entry in */
  16.                                 /* nodes broadcast */
  17. #define NRDESTPERPACK   11      /* maximum number of destinations per */
  18.                                 /* nodes packet */
  19.  
  20. #define NRPROTO_IP      0x0c
  21.  
  22. /* Internal representation of net/rom network layer header */
  23. struct nr3hdr {
  24.         struct ax25_addr source ;       /* callsign of origin node */
  25.         struct ax25_addr dest ;         /* callsign of destination node */
  26.         unsigned char ttl ;                     /* time-to-live */
  27. } ;
  28.  
  29. /* Internal representation of net/rom routing broadcast destination */
  30. /* entry */
  31. struct nr3dest {
  32.         struct ax25_addr dest ;         /* destination callsign */
  33.         char alias[7] ;                 /* ident, upper case ASCII, blank-filled */
  34.         struct ax25_addr neighbor ;     /* best-quality neighbor */
  35.         unsigned quality ;              /* quality of route for this neighbor */
  36. } ;
  37.  
  38.  
  39. /* net/rom interface table entry */
  40. struct nriface {
  41.         struct interface *interface ;   /* pointer to ax.25 interface */
  42.         char alias[7] ;                 /* alias for this interface's node */
  43.                                         /* broadcasts */
  44.         unsigned quality ;              /* net/rom link quality estimate */
  45. } ;
  46.  
  47. /* net/rom neighbor table structure */
  48. struct nrnbr_tab {
  49.         struct nrnbr_tab *next ;        /* doubly linked list pointers */
  50.         struct nrnbr_tab *prev ;
  51.         char call[AXALEN*3] ;           /* call of neighbor + 2 digis max */
  52.         unsigned interface ;            /* offset of neighbor's port in */
  53.                                         /* interface table */
  54.         unsigned refcnt ;               /* how many routes for this neighbor? */
  55. } ;
  56.  
  57. #define NULLNTAB        (struct nrnbr_tab *)0
  58.  
  59.  
  60. /* A list of these structures is provided for each route table */
  61. /* entry.  They bind a destination to a neighbor node.  If the */
  62. /* list of bindings becomes empty, the route table entry is    */
  63. /* automatically deleted.                                                                          */
  64.  
  65. struct nr_bind {
  66.         struct nr_bind *next ;          /* doubly linked list */
  67.         struct nr_bind *prev ;
  68.         unsigned quality ;              /* quality estimate */
  69.         unsigned obsocnt ;              /* obsolescence count */
  70.         unsigned flags ;
  71. #define NRB_PERMANENT   0x01            /* entry never times out */
  72. #define NRB_RECORDED    0x02            /* a "record route" entry */
  73.         struct nrnbr_tab *via ;         /* route goes via this neighbor */
  74. } ;
  75.  
  76. #define NULLNRBIND      (struct nr_bind *)0
  77.  
  78.  
  79. /* net/rom routing table entry */
  80.  
  81. struct nrroute_tab {
  82.         struct nrroute_tab *next ;      /* doubly linked list pointers */
  83.         struct nrroute_tab *prev ;
  84.         char alias[7] ;                 /* alias of node */
  85.         struct ax25_addr call ;         /* callsign of node */
  86.         unsigned num_routes ;           /* how many routes in bindings list? */
  87.         struct nr_bind *routes ;        /* list of neighbors */
  88.  
  89. } ;
  90.  
  91. #define NULLNRRTAB      (struct nrroute_tab *)0
  92.  
  93.  
  94. /* The net/rom nodes broadcast filter structure */
  95. struct nrnf_tab {
  96.         struct nrnf_tab *next ;         /* doubly linked list */
  97.         struct nrnf_tab *prev ;
  98.         struct ax25_addr neighbor ;     /* call of neighbor to filter */
  99.         unsigned interface ;            /* filter on this interface */
  100. } ;
  101.  
  102. #define NULLNRNFTAB     (struct nrnf_tab *)0
  103.  
  104.  
  105. /* The interface table */
  106. extern struct nriface nrifaces[NRNUMIFACE] ;
  107.  
  108. /* How many interfaces are in use */
  109. extern unsigned nr_numiface ;
  110.  
  111. /* The neighbor hash table (hashed on neighbor callsign) */
  112. extern struct nrnbr_tab *nrnbr_tab[NRNUMCHAINS] ;
  113.  
  114. /* The routes hash table (hashed on destination callsign) */
  115. extern struct nrroute_tab *nrroute_tab[NRNUMCHAINS] ;
  116.  
  117. /* The nodes broadcast filter table */
  118. extern struct nrnf_tab *nrnf_tab[NRNUMCHAINS] ;
  119.  
  120. /* filter modes: */
  121. #define NRNF_NOFILTER   0       /* don't filter */
  122. #define NRNF_ACCEPT     1       /* accept broadcasts from stations in list */
  123. #define NRNF_REJECT     2       /* reject broadcasts from stations in list */
  124.  
  125. /* The filter mode */
  126. extern unsigned nr_nfmode ;
  127.  
  128. /* The time-to-live for net/rom network layer packets */
  129. extern unsigned char nr_ttl ;
  130.  
  131. /* The obsolescence count initializer */
  132. extern unsigned obso_init ;
  133.  
  134. /* The threshhold at which routes becoming obsolete are not broadcast */
  135. extern unsigned obso_minbc ;
  136.  
  137. /* The quality threshhold below which routes in a broadcast will */
  138. /* be ignored */
  139. extern unsigned nr_autofloor ;
  140.  
  141. /* The maximum number of routes maintained for a destination. */
  142. /* If the list fills up, only the highest quality routes are  */
  143. /* kept.  This limiting is done to avoid possible over-use of */
  144. /* memory for routing tables in closely spaced net/rom networks. */
  145. extern unsigned nr_maxroutes ;
  146.  
  147. /* Whether we want to broadcast the contents of our routing
  148.  * table, or just our own callsign and alias:
  149.  */
  150. extern unsigned nr_verbose ;
  151.  
  152. /* The netrom pseudo-interface */
  153. extern struct interface *nr_interface ;
  154.  
  155. /* In NR3 */
  156. void nr3output(struct ax25_addr *, struct mbuf *);
  157. int  nr_send(struct mbuf *, struct interface *, int32, char, char, char, char);
  158. void nr_route(struct mbuf *, struct ax25_cb *);
  159. void nr_bcnodes(unsigned int);
  160. void nr3arp(void);
  161. int  nr_attach(int, char **);
  162. void nr_nodercv(struct interface *, struct ax25_addr *, struct mbuf *);
  163. int16 nrhash(struct ax25_addr *);
  164. struct nrnbr_tab *find_nrnbr(struct ax25_addr *, unsigned int);
  165. struct nrroute_tab *find_nrroute(struct ax25_addr *);
  166. struct ax25_addr *find_nralias(char *);
  167. struct nr_bind *find_binding(struct nr_bind *, struct nrnbr_tab *);
  168. int nr_routeadd(char *, struct ax25_addr *, unsigned int,                                    unsigned int, char *, unsigned int, unsigned int) ;
  169. int nr_routedrop(struct ax25_addr *, struct ax25_addr *, unsigned int);
  170. char *nr_getroute(struct ax25_addr *);
  171. struct nrnf_tab *find_nrnf(struct ax25_addr *, unsigned int);
  172. int nr_nfadd(struct ax25_addr *, unsigned int);
  173. int nr_nfdrop(struct ax25_addr *, unsigned int);
  174.  
  175. /* In NRSUBR */
  176. int ntohnr3(struct nr3hdr *,struct mbuf **);
  177. struct mbuf *htonnr3(struct nr3hdr *);
  178. int ntohnrdest(struct nr3dest *,struct mbuf **);
  179. struct mbuf *htonnrdest(struct nr3dest *);
  180.