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