home *** CD-ROM | disk | FTP | other *** search
/ HAM Radio 1 / HamRadio.cdr / misc / tcpipsrc / ax25.h < prev    next >
Text File  |  1990-11-10  |  7KB  |  213 lines

  1. #ifndef    _AX25_H
  2. #define    _AX25_H
  3.  
  4. #ifndef    _GLOBAL_H
  5. #include "global.h"
  6. #endif
  7.  
  8. #ifndef    _MBUF_H
  9. #include "mbuf.h"
  10. #endif
  11.  
  12. #ifndef    _IFACE_H
  13. #include "iface.h"
  14. #endif
  15.  
  16. /* AX.25 datagram (address) sub-layer definitions */
  17.  
  18. #define    NHASH        17    /* Number of hash chains in AX.25 routing
  19.                  * tables, LAPB control blocks and link
  20.                  * status tables
  21.                  */
  22. #define    MAXDIGIS    7    /* Maximum number of digipeaters */
  23. #define    ALEN        6    /* Number of chars in callsign field */
  24. #define    AXALEN        7    /* Total AX.25 address length, including SSID */
  25. #define    AXBUF        10    /* Buffer size for maximum-length ascii call */
  26.  
  27. #ifndef _LAPB_H
  28. #include "lapb.h"
  29. #endif
  30.  
  31. /* Bits within SSID field of AX.25 address */
  32. #define    SSID        0x1e    /* Sub station ID */
  33. #define    REPEATED    0x80    /* Has-been-repeated bit in repeater field */
  34. #define    E        0x01    /* Address extension bit */
  35. #define    C        0x80    /* Command/response designation */
  36. /* Our AX.25 address */
  37. extern char Mycall[AXALEN];
  38.  
  39. /* AX.25 broadcast address: "QST   -0" in shifted ASCII */
  40. extern char Ax25_bdcst[AXALEN];
  41.  
  42. extern int Digipeat;
  43. extern int Ax25mbox;
  44.  
  45. /* Internal representation of an AX.25 header */
  46. struct ax25 {
  47.     char dest[AXALEN];        /* Destination address */
  48.     char source[AXALEN];        /* Source address */
  49.     char digis[MAXDIGIS][AXALEN];    /* Digi string */
  50.     int ndigis;            /* Number of digipeaters */
  51.     int nextdigi;            /* Index to next digi in chain */
  52.     int cmdrsp;            /* Command/response */
  53. };
  54.  
  55. /* C-bit stuff */
  56. #define    LAPB_UNKNOWN        0
  57. #define    LAPB_COMMAND        1
  58. #define    LAPB_RESPONSE        2
  59.  
  60. /* AX.25 routing table entry */
  61. struct ax_route {
  62.     struct ax_route *prev;        /* Linked list pointers */
  63.     struct ax_route *next;
  64.     char target[AXALEN];
  65.     char digis[MAXDIGIS][AXALEN];
  66.     int ndigis;
  67.     char type;
  68. #define    AX_LOCAL    1        /* Set by local ax25 route command */
  69. #define    AX_AUTO        2        /* Set by incoming packet */
  70. };
  71. #define NULLAXR    ((struct ax_route *)0)
  72.  
  73. extern struct ax_route *Ax_routes[NHASH];
  74. extern struct ax_route Ax_default;
  75.  
  76. /* AX.25 Level 3 Protocol IDs (PIDs) */
  77. #define PID_X25        0x01    /* CCITT X.25 PLP */
  78. #define    PID_SEGMENT    0x08    /* Segmentation fragment */
  79. #define PID_TEXNET    0xc3    /* TEXNET datagram protocol */
  80. #define    PID_LQ        0xc4    /* Link quality protocol */
  81. #define    PID_APPLETALK    0xca    /* Appletalk */
  82. #define    PID_APPLEARP    0xcb    /* Appletalk ARP */
  83. #define    PID_IP        0xcc    /* ARPA Internet Protocol */
  84. #define    PID_ARP        0xcd    /* ARPA Address Resolution Protocol */
  85. #define    PID_NETROM    0xcf    /* NET/ROM */
  86. #define    PID_NO_L3    0xf0    /* No level 3 protocol */
  87.  
  88. #define    SEG_FIRST    0x80    /* First segment of a sequence */
  89. #define    SEG_REM        0x7f    /* Mask for # segments remaining */
  90.  
  91. #define    AX_EOL        "\r"    /* AX.25 end-of-line convention */
  92.  
  93. /* Link quality report packet header, internal format */
  94. struct lqhdr {
  95.     int16 version;        /* Version number of protocol */
  96. #define    LINKVERS    1
  97.     int32    ip_addr;    /* Sending station's IP address */
  98. };
  99. #define    LQHDR    6
  100. /* Link quality entry, internal format */
  101. struct lqentry {
  102.     char addr[AXALEN];    /* Address of heard station */
  103.     int32 count;        /* Count of packets heard from that station */
  104. };
  105. #define    LQENTRY    11
  106.  
  107. /* Link quality database record format
  108.  * Currently used only by AX.25 interfaces
  109.  */
  110. struct lq {
  111.     struct lq *prev;    /* Linked list pointers */
  112.     struct lq *next;
  113.  
  114.     struct iface *iface;    /* Interface address was heard on */
  115.  
  116.     /* Time station was last heard */
  117.     int32 time;
  118.  
  119.     /* # of packets heard from this station as of his last update */
  120.     int32 lastrxcnt;
  121.  
  122.     /* Current # of packets heard from this station */
  123.     int32 currxcnt;
  124.  
  125.     /* # packets reported as transmitted by station as of his last update */
  126.     int32 lasttxcnt;
  127.  
  128.     int16 hisqual;    /* Fraction (0-1000) of station's packets heard
  129.              * as of last update
  130.              */
  131.     int16 myqual;    /* Fraction (0-1000) of our packets heard by station
  132.              * as of last update
  133.              */
  134.     char *addr;    /* Hardware address of station heard */
  135. };
  136. #define    NULLLQ    (struct lq *)0
  137.  
  138. extern struct lq *Lq[NHASH];    /* Link quality record headers */
  139.  
  140. /* Linkage to network protocols atop ax25 */
  141. struct axlink {
  142.     int pid;
  143.     void (*funct) __ARGS((struct iface *,struct ax25_cb *,char *, char *,
  144.      struct mbuf *,int));
  145. };
  146. extern struct axlink Axlink[];
  147.  
  148. /* List of AX.25 multicast addresses */
  149. extern char *Axmulti[];
  150.  
  151. /* Codes for the open_ax25 call */
  152. #define    AX_PASSIVE    0
  153. #define    AX_ACTIVE    1
  154. #define    AX_SERVER    2    /* Passive, clone on opening */
  155.  
  156. /* In ax25.c: */
  157. struct ax_route *ax_add __ARGS((char *,int,char digis[][AXALEN],int));
  158. int ax_drop __ARGS((char *));
  159. struct ax_route *ax_lookup __ARGS((char *));
  160. void ax_recv __ARGS((struct iface *,struct mbuf *));
  161. int ax_send __ARGS((struct mbuf *bp,struct iface *iface,int32 gateway,int prec,
  162.     int del,int tput,int rel));
  163. int ax_output __ARGS((struct iface *iface,char *dest,char *source,int16 pid,
  164.     struct mbuf *data));
  165. int sendframe __ARGS((struct ax25_cb *axp,int cmdrsp,int ctl,struct mbuf *data));
  166. void axnl3 __ARGS((struct iface *iface,struct ax25_cb *axp,char *src,
  167.     char *dest,struct mbuf *bp,int mcast));
  168.  
  169. /* In ax25cmd.c: */
  170. void st_ax25 __ARGS((struct ax25_cb *axp));
  171.  
  172. /* In axhdr.c: */
  173. struct mbuf *htonax25 __ARGS((struct ax25 *hdr,struct mbuf *data));
  174. int ntohax25 __ARGS((struct ax25 *hdr,struct mbuf **bpp));
  175.  
  176. /* In axlink.c: */
  177. void getlqentry __ARGS((struct lqentry *ep,struct mbuf **bpp));
  178. void getlqhdr __ARGS((struct lqhdr *hp,struct mbuf **bpp));
  179. void logaddr __ARGS((struct iface *iface,char *addr));
  180. char *putlqentry __ARGS((char *cp,char *addr,int32 count));
  181. char *putlqhdr __ARGS((char *cp,int16 version,int32 ip_addr));
  182.  
  183. /* In ax25user.c: */
  184. int ax25val __ARGS((struct ax25_cb *axp));
  185. int disc_ax25 __ARGS((struct ax25_cb *axp));
  186. int kick_ax25 __ARGS((struct ax25_cb *axp));
  187. struct ax25_cb *open_ax25 __ARGS((struct iface *,char *,char *,
  188.     int,int16,
  189.     void (*) __ARGS((struct ax25_cb *,int)),
  190.     void (*) __ARGS((struct ax25_cb *,int)),
  191.     void (*) __ARGS((struct ax25_cb *,int,int)),
  192.     int user));
  193. struct mbuf *recv_ax25 __ARGS((struct ax25_cb *axp,int16 cnt));
  194. int reset_ax25 __ARGS((struct ax25_cb *axp));
  195. int send_ax25 __ARGS((struct ax25_cb *axp,struct mbuf *bp,int pid));
  196.  
  197. /* In ax25subr.c: */
  198. int addreq __ARGS((char *a,char *b));
  199. int16 ax25hash __ARGS((char *s));
  200. struct ax25_cb *cr_ax25 __ARGS((char *addr));
  201. void del_ax25 __ARGS((struct ax25_cb *axp));
  202. struct ax25_cb *find_ax25 __ARGS((char *));
  203. char *pax25 __ARGS((char *e,char *addr));
  204. int setcall __ARGS((char *out,char *call));
  205.  
  206. /* In socket.c: */
  207. void beac_input __ARGS((struct iface *iface,char *src,struct mbuf *bp));
  208. void s_arcall __ARGS((struct ax25_cb *axp,int cnt));
  209. void s_ascall __ARGS((struct ax25_cb *axp,int old,int new));
  210. void s_atcall __ARGS((struct ax25_cb *axp,int cnt));
  211.  
  212. #endif    /* _AX25_H */
  213.