home *** CD-ROM | disk | FTP | other *** search
/ Media Share 9 / MEDIASHARE_09.ISO / hamradio / s920603.zip / AX25.H < prev    next >
C/C++ Source or Header  |  1992-05-01  |  9KB  |  257 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. #ifndef _SOCKADDR_H
  17. #include "sockaddr.h"
  18. #endif
  19.  
  20. extern char Ax25_eol[];
  21.  
  22. /* AX.25 datagram (address) sub-layer definitions */
  23.  
  24. #define    MAXDIGIS    7    /* Maximum number of digipeaters */
  25. #define    ALEN        6    /* Number of chars in callsign field */
  26. #define    AXALEN        7    /* Total AX.25 address length, including SSID */
  27. #define    AXBUF        10    /* Buffer size for maximum-length ascii call */
  28.  
  29. #ifndef _LAPB_H
  30. #include "lapb.h"
  31. #endif
  32.  
  33. /* Bits within SSID field of AX.25 address */
  34. #define    SSID        0x1e    /* Sub station ID */
  35. #define    REPEATED    0x80    /* Has-been-repeated bit in repeater field */
  36. #define    E        0x01    /* Address extension bit */
  37. #define    C        0x80    /* Command/response designation */
  38.  
  39. /* Our AX.25 address */
  40. extern char Mycall[AXALEN];
  41.  
  42. /* List of AX.25 multicast addresses, e.g., "QST   -0" in shifted ASCII */
  43. extern char Ax25multi[][AXALEN];
  44.  
  45. extern int Digipeat;
  46. extern int Ax25mbox;
  47.  
  48. /* Number of chars in interface field. The involved definition takes possible
  49.  * alignment requirements into account, since ax25_addr is of an odd size.
  50.  */
  51. #define    ILEN    (sizeof(struct sockaddr) - sizeof(short) - AXALEN)
  52.  
  53. /* Socket address, AX.25 style */
  54. struct sockaddr_ax {
  55.     short sax_family;        /* 2 bytes */
  56.     char ax25_addr[AXALEN];
  57.     char iface[ILEN];        /* Interface name */
  58. };
  59.  
  60. /* Internal representation of an AX.25 header */
  61. struct ax25 {
  62.     char dest[AXALEN];        /* Destination address */
  63.     char source[AXALEN];        /* Source address */
  64.     char digis[MAXDIGIS][AXALEN];    /* Digi string */
  65.     int ndigis;            /* Number of digipeaters */
  66.     int nextdigi;            /* Index to next digi in chain */
  67.     int cmdrsp;            /* Command/response */
  68. };
  69.  
  70. /* C-bit stuff */
  71. #define    LAPB_UNKNOWN        0
  72. #define    LAPB_COMMAND        1
  73. #define    LAPB_RESPONSE        2
  74.  
  75. /* AX.25 routing table entry */
  76. struct ax_route {
  77.     struct ax_route *next;        /* Linked list pointer */
  78.     char target[AXALEN];
  79.     char digis[MAXDIGIS][AXALEN];
  80.     int ndigis;
  81.     char type;
  82. #define    AX_LOCAL    1        /* Set by local ax25 route command */
  83. #define    AX_AUTO        2        /* Set by incoming packet */
  84. };
  85. #define NULLAXR    ((struct ax_route *)0)
  86.  
  87. extern struct ax_route *Ax_routes;
  88. extern struct ax_route Ax_default;
  89.  
  90. /* AX.25 Level 3 Protocol IDs (PIDs) */
  91. #define PID_X25        0x01    /* CCITT X.25 PLP */
  92. #define    PID_SEGMENT    0x08    /* Segmentation fragment */
  93. #define PID_TEXNET    0xc3    /* TEXNET datagram protocol */
  94. #define    PID_LQ        0xc4    /* Link quality protocol */
  95. #define    PID_APPLETALK    0xca    /* Appletalk */
  96. #define    PID_APPLEARP    0xcb    /* Appletalk ARP */
  97. #define    PID_IP        0xcc    /* ARPA Internet Protocol */
  98. #define    PID_ARP        0xcd    /* ARPA Address Resolution Protocol */
  99. #define    PID_NETROM    0xcf    /* NET/ROM */
  100. #define    PID_NO_L3    0xf0    /* No level 3 protocol */
  101.  
  102. #define    SEG_FIRST    0x80    /* First segment of a sequence */
  103. #define    SEG_REM        0x7f    /* Mask for # segments remaining */
  104.  
  105. /* Link quality report packet header, internal format */
  106. struct lqhdr {
  107.     int16 version;        /* Version number of protocol */
  108. #define    LINKVERS    1
  109.     int32    ip_addr;    /* Sending station's IP address */
  110. };
  111. #define    LQHDR    6
  112. /* Link quality entry, internal format */
  113. struct lqentry {
  114.     char addr[AXALEN];    /* Address of heard station */
  115.     int32 count;        /* Count of packets heard from that station */
  116. };
  117. #define    LQENTRY    11
  118.  
  119. /* Link quality database record format
  120.  * Currently used only by AX.25 interfaces
  121.  */
  122. struct lq {
  123.     struct lq *next;
  124.     char addr[AXALEN];    /* Hardware address of station heard */
  125.     struct iface *iface;    /* Interface address was heard on */
  126.     int32 time;        /* Time station was last heard */
  127.     int32 currxcnt;    /* Current # of packets heard from this station */
  128.  
  129. #ifdef    notdef        /* Not yet implemented */
  130.     /* # of packets heard from this station as of his last update */
  131.     int32 lastrxcnt;
  132.  
  133.     /* # packets reported as transmitted by station as of his last update */
  134.     int32 lasttxcnt;
  135.  
  136.     int16 hisqual;    /* Fraction (0-1000) of station's packets heard
  137.              * as of last update
  138.              */
  139.     int16 myqual;    /* Fraction (0-1000) of our packets heard by station
  140.              * as of last update
  141.              */
  142. #endif
  143. };
  144. #define    NULLLQ    (struct lq *)0
  145.  
  146. extern struct lq *Lq;    /* Link quality record headers */
  147.  
  148. /* Structure used to keep track of monitored destination addresses */
  149. struct ld {
  150.     struct ld *next;    /* Linked list pointers */
  151.     char addr[AXALEN];/* Hardware address of destination overheard */
  152.     struct iface *iface;    /* Interface address was heard on */
  153.     int32 time;        /* Time station was last mentioned */
  154.     int32 currxcnt;    /* Current # of packets destined to this station */
  155. };
  156. #define    NULLLD    (struct ld *)0
  157.  
  158. extern struct ld *Ld;    /* Destination address record headers */
  159.  
  160. /* Linkage to network protocols atop ax25 */
  161. struct axlink {
  162.     int pid;
  163.     void (*funct) __ARGS((struct iface *,struct ax25_cb *,char *, char *,
  164.      struct mbuf *,int));
  165. };
  166. extern struct axlink Axlink[];
  167.  
  168. /* Codes for the open_ax25 call */
  169. #define    AX_PASSIVE    0
  170. #define    AX_ACTIVE    1
  171. #define    AX_SERVER    2    /* Passive, clone on opening */
  172.  
  173. /* In ax25.c: */
  174. struct ax_route *ax_add __ARGS((char *,int,char digis[][AXALEN],int));
  175. int ax_drop __ARGS((char *));
  176. struct ax_route *ax_lookup __ARGS((char *));
  177. void ax_recv __ARGS((struct iface *,struct mbuf *));
  178. int ax_send __ARGS((struct mbuf *bp,struct iface *iface,int32 gateway,int tos));
  179. int ax_output __ARGS((struct iface *iface,char *dest,char *source,int16 pid,
  180.     struct mbuf *data));
  181. int sendframe __ARGS((struct ax25_cb *axp,int cmdrsp,int ctl,struct mbuf *data));
  182. void axnl3 __ARGS((struct iface *iface,struct ax25_cb *axp,char *src,
  183.     char *dest,struct mbuf *bp,int mcast));
  184.  
  185. /* In ax25cmd.c: */
  186. void st_ax25 __ARGS((struct ax25_cb *axp));
  187.  
  188. /* In axhdr.c: */
  189. struct mbuf *htonax25 __ARGS((struct ax25 *hdr,struct mbuf *data));
  190. int ntohax25 __ARGS((struct ax25 *hdr,struct mbuf **bpp));
  191.  
  192. /* In axlink.c: */
  193. void getlqentry __ARGS((struct lqentry *ep,struct mbuf **bpp));
  194. void getlqhdr __ARGS((struct lqhdr *hp,struct mbuf **bpp));
  195. void logsrc __ARGS((struct iface *iface,char *addr));
  196. void logdest __ARGS((struct iface *iface,char *addr));
  197. char *putlqentry __ARGS((char *cp,char *addr,int32 count));
  198. char *putlqhdr __ARGS((char *cp,int16 version,int32 ip_addr));
  199. struct lq *al_lookup __ARGS((struct iface *ifp,char *addr,int sort));
  200.  
  201. /* In ax25user.c: */
  202. int ax25val __ARGS((struct ax25_cb *axp));
  203. int disc_ax25 __ARGS((struct ax25_cb *axp));
  204. int kick_ax25 __ARGS((struct ax25_cb *axp));
  205. struct ax25_cb *open_ax25 __ARGS((struct iface *,char *,char *,
  206.     int,int16,
  207.     void (*) __ARGS((struct ax25_cb *,int)),
  208.     void (*) __ARGS((struct ax25_cb *,int)),
  209.     void (*) __ARGS((struct ax25_cb *,int,int)),
  210.     int user));
  211. struct mbuf *recv_ax25 __ARGS((struct ax25_cb *axp,int16 cnt));
  212. int reset_ax25 __ARGS((struct ax25_cb *axp));
  213. int send_ax25 __ARGS((struct ax25_cb *axp,struct mbuf *bp,int pid));
  214.  
  215. /* In ax25subr.c: */
  216. int addreq __ARGS((char *a,char *b));
  217. struct ax25_cb *cr_ax25 __ARGS((char *addr));
  218. void del_ax25 __ARGS((struct ax25_cb *axp));
  219. struct ax25_cb *find_ax25 __ARGS((char *));
  220. char *pax25 __ARGS((char *e,char *addr));
  221. int setcall __ARGS((char *out,char *call));
  222.  
  223. /* In axsocket.c: */
  224. int so_ax_sock __ARGS((struct usock *up,int protocol));
  225. int so_ax_bind __ARGS((struct usock *up));
  226. int so_ax_listen __ARGS((struct usock *up,int backlog));
  227. int so_ax_conn __ARGS((struct usock *up));
  228. int so_ax_recv __ARGS((struct usock *up,struct mbuf **bpp,char *from,
  229.     int *fromlen));
  230. int so_ax_send __ARGS((struct usock *up,struct mbuf *bp,char *to));
  231. int so_ax_qlen __ARGS((struct usock *up,int rtx));
  232. int so_ax_kick __ARGS((struct usock *up));
  233. int so_ax_shut __ARGS((struct usock *up,int how));
  234. int so_ax_close __ARGS((struct usock *up));
  235. int checkaxaddr __ARGS((char *name,int namelen));
  236.  
  237. int so_axui_sock __ARGS((struct usock *up,int protocol));
  238. int so_axui_bind __ARGS((struct usock *up));
  239. int so_axui_conn __ARGS((struct usock *up));
  240. int so_axui_recv __ARGS((struct usock *up,struct mbuf **bpp,char *from,
  241.     int *fromlen));
  242. int so_axui_send __ARGS((struct usock *up,struct mbuf *bp,char *to));
  243. int so_axui_qlen __ARGS((struct usock *up,int rtx));
  244. int so_axui_shut __ARGS((struct usock *up,int how));
  245. int so_axui_close __ARGS((struct usock *up));
  246. char *axpsocket __ARGS((struct sockaddr *p));
  247. char *axstate __ARGS((struct usock *up));
  248. int so_ax_stat __ARGS((struct usock *up));
  249.  
  250. void beac_input __ARGS((struct iface *iface,char *src,struct mbuf *bp));
  251.  
  252. void s_arcall __ARGS((struct ax25_cb *axp,int cnt));
  253. void s_ascall __ARGS((struct ax25_cb *axp,int old,int new));
  254. void s_atcall __ARGS((struct ax25_cb *axp,int cnt));
  255.  
  256. #endif  /* _AX25_H */
  257.