home *** CD-ROM | disk | FTP | other *** search
/ Media Share 9 / MEDIASHARE_09.ISO / network / src_1218.zip / NETROM.H < prev    next >
Text File  |  1990-11-10  |  7KB  |  221 lines

  1. #ifndef    _NETROM_H
  2. #define    _NETROM_H
  3.  
  4. #ifndef    _MBUF_H
  5. #include "mbuf.h"
  6. #endif
  7.  
  8. #ifndef    _IFACE_H
  9. #include "iface.h"
  10. #endif
  11.  
  12. #ifndef    _AX25_H
  13. #include "ax25.h"
  14. #endif
  15.  
  16. #ifndef _NR4_H
  17. #include "nr4.h"
  18. #endif
  19.  
  20. /* net/rom support definitions
  21.  * Copyright 1989 by Daniel M. Frank, W9NK.  Permission granted for
  22.  * non-commercial distribution only.
  23.  */
  24.  
  25. #define NR3HLEN        15    /* length of a net/rom level 3 hdr, */
  26. #define NR3DLEN        241    /* max data size in net/rom l3 packet */
  27. #define NR3NODESIG    0xff    /* signature for nodes broadcast */
  28. #define NR3NODEHL    7    /* nodes bc header length */
  29.  
  30. #define NRNUMIFACE    10    /* number of interfaces associated */
  31.                 /* with net/rom network layer      */
  32. #define NRNUMCHAINS    17    /* number of chains in the */
  33.                 /* neighbor and route hash tables */
  34. #define NRRTDESTLEN    21    /* length of destination entry in */
  35.                 /* nodes broadcast */
  36. #define NRDESTPERPACK    11    /* maximum number of destinations per */
  37.                 /* nodes packet */
  38.  
  39. /* NET/ROM protocol numbers */
  40. #define NRPROTO_IP    0x0c
  41.  
  42. /* Internal representation of net/rom network layer header */
  43. struct nr3hdr {
  44.     char source[AXALEN] ;    /* callsign of origin node */
  45.     char dest[AXALEN] ;        /* callsign of destination node */
  46.     unsigned ttl ;                /* time-to-live */
  47. } ;
  48.  
  49. /* Internal representation of net/rom routing broadcast destination */
  50. /* entry */
  51. struct nr3dest {
  52.     char dest[AXALEN] ;        /* destination callsign */
  53.     char alias[AXALEN] ;            /* ident, upper case ASCII, blank-filled */
  54.     char neighbor[AXALEN] ;    /* best-quality neighbor */
  55.     unsigned quality ;        /* quality of route for this neighbor */
  56. } ;
  57.  
  58.  
  59. /* net/rom interface table entry */
  60. struct nriface {
  61.     struct iface *iface ;        /* pointer to ax.25 interface */
  62.     char alias[AXALEN] ;        /* alias for this interface's node */
  63.                     /* broadcasts */
  64.     unsigned quality ;        /* net/rom link quality estimate */
  65. } ;
  66.  
  67. /* net/rom neighbor table structure */
  68. struct nrnbr_tab {
  69.     struct nrnbr_tab *next ;    /* doubly linked list pointers */
  70.     struct nrnbr_tab *prev ;
  71.     char call[AXALEN] ;        /* call of neighbor + 2 digis max */
  72.     unsigned iface ;        /* offset of neighbor's port in */
  73.                     /* interface table */
  74.     unsigned refcnt ;        /* how many routes for this neighbor? */
  75. } ;
  76.  
  77. #define    NULLNTAB    (struct nrnbr_tab *)0
  78.  
  79.  
  80. /* A list of these structures is provided for each route table */
  81. /* entry.  They bind a destination to a neighbor node.  If the */
  82. /* list of bindings becomes empty, the route table entry is    */
  83. /* automatically deleted.                                       */
  84.  
  85. struct nr_bind {
  86.     struct nr_bind *next ;        /* doubly linked list */
  87.     struct nr_bind *prev ;
  88.     unsigned quality ;        /* quality estimate */
  89.     unsigned obsocnt ;        /* obsolescence count */
  90.     unsigned flags ;
  91. #define    NRB_PERMANENT    0x01        /* entry never times out */
  92. #define NRB_RECORDED    0x02        /* a "record route" entry */
  93.     struct nrnbr_tab *via ;        /* route goes via this neighbor */
  94. } ;
  95.  
  96. #define    NULLNRBIND    (struct nr_bind *)0
  97.  
  98.  
  99. /* net/rom routing table entry */
  100.  
  101. struct nrroute_tab {
  102.     struct nrroute_tab *next ;    /* doubly linked list pointers */
  103.     struct nrroute_tab *prev ;
  104.     char alias[AXALEN] ;            /* alias of node */
  105.     char call[AXALEN] ;        /* callsign of node */
  106.     unsigned num_routes ;        /* how many routes in bindings list? */
  107.     struct nr_bind *routes ;    /* list of neighbors */
  108.  
  109. } ;
  110.  
  111. #define    NULLNRRTAB    (struct nrroute_tab *)0
  112.  
  113.  
  114. /* The net/rom nodes broadcast filter structure */
  115. struct nrnf_tab {
  116.     struct nrnf_tab *next ;        /* doubly linked list */
  117.     struct nrnf_tab *prev ;
  118.     char neighbor[AXALEN] ;    /* call of neighbor to filter */
  119.     unsigned iface ;        /* filter on this interface */
  120. } ;
  121.  
  122. #define    NULLNRNFTAB    (struct nrnf_tab *)0
  123.  
  124. /* Structure for handling raw NET/ROM user sockets */
  125. struct raw_nr {
  126.     struct raw_nr *prev;
  127.     struct raw_nr *next;
  128.  
  129.     struct mbuf *rcvq;    /* receive queue */
  130.     char protocol;        /* Protocol */
  131. };
  132. #define    NULLRNR    ((struct raw_nr *)0)
  133.  
  134. /* The interface table */
  135. extern struct nriface Nrifaces[NRNUMIFACE] ;
  136.  
  137. /* How many interfaces are in use */
  138. extern unsigned Nr_numiface ;
  139.  
  140. /* The neighbor hash table (hashed on neighbor callsign) */
  141. extern struct nrnbr_tab *Nrnbr_tab[NRNUMCHAINS] ;
  142.  
  143. /* The routes hash table (hashed on destination callsign) */
  144. extern struct nrroute_tab *Nrroute_tab[NRNUMCHAINS] ;
  145.  
  146. /* The nodes broadcast filter table */
  147. extern struct nrnf_tab *Nrnf_tab[NRNUMCHAINS] ;
  148.  
  149. extern char Nr_nodebc[AXALEN];
  150.  
  151. /* filter modes: */
  152. #define    NRNF_NOFILTER    0    /* don't filter */
  153. #define    NRNF_ACCEPT    1    /* accept broadcasts from stations in list */
  154. #define    NRNF_REJECT    2    /* reject broadcasts from stations in list */
  155.  
  156. /* The filter mode */
  157. extern unsigned Nr_nfmode ;
  158.  
  159. /* The time-to-live for net/rom network layer packets */
  160. extern unsigned short Nr_ttl ;
  161.  
  162. /* The obsolescence count initializer */
  163. extern unsigned Obso_init ;
  164.  
  165. /* The threshhold at which routes becoming obsolete are not broadcast */
  166. extern unsigned Obso_minbc ;
  167.  
  168. /* The quality threshhold below which routes in a broadcast will */
  169. /* be ignored */
  170. extern unsigned Nr_autofloor ;
  171.  
  172. /* Whether we want to broadcast the contents of our routing
  173.  * table, or just our own callsign and alias:
  174.  */
  175. extern int Nr_verbose ;
  176.  
  177. /* The maximum number of routes maintained for a destination. */
  178. /* If the list fills up, only the highest quality routes are  */
  179. /* kept.  This limiting is done to avoid possible over-use of */
  180. /* memory for routing tables in closely spaced net/rom networks. */
  181. extern unsigned Nr_maxroutes ;
  182.  
  183. /* The netrom pseudo-interface */
  184. extern struct iface *Nr_iface ;
  185.  
  186. /* Functions */
  187.  
  188. /* In nr3.c: */
  189. void del_rnr __ARGS((struct raw_nr *rpp));
  190. char *find_nralias __ARGS((char *));
  191. struct nrroute_tab *find_nrroute __ARGS((char *));
  192. void nr_bcnodes __ARGS((unsigned ifno));
  193. void nr_nodercv __ARGS((struct iface *iface,char *source,struct mbuf *bp));
  194. int nr_nfadd __ARGS((char *, unsigned));
  195. int nr_nfdrop __ARGS((char *, unsigned));
  196. void nr_route __ARGS((struct mbuf *bp,struct ax25_cb *iaxp));
  197. int nr_routeadd __ARGS((char *, char *, unsigned,
  198.     unsigned, char *, unsigned, unsigned));
  199. int nr_routedrop __ARGS((char *, char *, unsigned));
  200. int nr_send __ARGS((struct mbuf *bp,struct iface *iface,int32 gateway,int prec,
  201.     int del,int tput,int rel));
  202. void nr_sendraw __ARGS((char *dest,unsigned family,unsigned proto,
  203.     struct mbuf *data));
  204. void nr3output __ARGS((char *dest,struct mbuf *data));
  205. int16 nrhash __ARGS((char *s));
  206. struct raw_nr *raw_nr __ARGS((char));
  207.  
  208. /* In nrcmd.c: */
  209. void donrdump __ARGS((struct nr4cb *cb));
  210. int doroutedump __ARGS((void));
  211. int dorouteinfo __ARGS((int argc,char *argv[],void *p));
  212. int putalias __ARGS((char *to, char *from,int complain));
  213.  
  214. /* In nrhdr.c: */
  215. struct mbuf *htonnr3 __ARGS((struct nr3hdr *));
  216. struct mbuf *htonnrdest __ARGS((struct nr3dest *));
  217. int ntohnr3 __ARGS((struct nr3hdr *, struct mbuf **));
  218. int ntohnrdest __ARGS((struct nr3dest *ds,struct mbuf **bpp));
  219.  
  220. #endif    /* _NETROM_H */
  221.