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

  1. #ifndef    _UDP_H
  2. #define    _UDP_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    _INTERNET_H
  17. #include "internet.h"
  18. #endif
  19.  
  20. #ifndef _IP_H
  21. #include "ip.h"
  22. #endif
  23.  
  24. #ifndef    _NETUSER_H
  25. #include "netuser.h"
  26. #endif
  27.  
  28. /* SNMP MIB variables, used for statistics and control. See RFC 1066 */
  29. extern struct mib_entry Udp_mib[];
  30. #define    udpInDatagrams    Udp_mib[1].value.integer
  31. #define    udpNoPorts    Udp_mib[2].value.integer
  32. #define    udpInErrors    Udp_mib[3].value.integer
  33. #define    udpOutDatagrams    Udp_mib[4].value.integer
  34. #define    NUMUDPMIB    4
  35.  
  36. /* User Datagram Protocol definitions */
  37. #define    NUDP    20
  38.  
  39. /* Structure of a UDP protocol header */
  40. struct udp {
  41.     int16 source;    /* Source port */
  42.     int16 dest;    /* Destination port */
  43.     int16 length;    /* Length of header and data */
  44.     int16 checksum;    /* Checksum over pseudo-header, header and data */
  45. };
  46. #define    UDPHDR    8    /* Length of UDP header */
  47.  
  48. /* User Datagram Protocol control block
  49.  * Each entry on the receive queue consists of the
  50.  * remote socket structure, followed by any data
  51.  */
  52. struct udp_cb {
  53.     struct udp_cb *prev;    /* Linked list pointers */
  54.     struct udp_cb *next;
  55.     struct socket socket;    /* Local port accepting datagrams */
  56.     void (*r_upcall) __ARGS((struct iface *iface,struct udp_cb *,int));
  57.                 /* Function to call when one arrives */
  58.     struct mbuf *rcvq;    /* Queue of pending datagrams */
  59.     int rcvcnt;        /* Count of pending datagrams */
  60.     int user;        /* User link */
  61. };
  62. extern struct udp_cb *Udps[];    /* Hash table for UDP structures */
  63. #define    NULLUDP    (struct udp_cb *)0
  64.  
  65. /* UDP primitives */
  66.  
  67. /* In udp.c: */
  68. int del_udp __ARGS((struct udp_cb *up));
  69. struct udp_cb *open_udp __ARGS((struct socket *lsocket,
  70.     void (*r_upcall) __ARGS((struct iface *iface,struct udp_cb *,int))));
  71. int recv_udp __ARGS((struct udp_cb *up,struct socket *fsocket,struct mbuf **bp));
  72. int send_udp __ARGS((struct socket *lsocket,struct socket *fsocket,char tos,
  73.     char ttl,struct mbuf *data,int16 length,int16 id,char df));
  74. void udp_input __ARGS((struct iface *iface,struct ip *ip,struct mbuf *bp,
  75.     int rxbroadcast));
  76. void udp_garbage __ARGS((int drastic));
  77.  
  78. #ifdef HOPCHECK
  79. void udp_icmp __ARGS((int32 icsource, int32 ipsource,int32 ipdest,
  80.     char ictype,char iccode,struct mbuf **bpp));
  81. /* In hop.c: */
  82. void hop_icmp __ARGS((struct udp_cb *ucb, int32 icsource, int32 ipdest,
  83.     int16 udpdest, char ictype, char iccode));
  84. #endif
  85.  
  86. /* In udpcmd.c: */
  87. int st_udp __ARGS((struct udp_cb *udp,int n));
  88.  
  89. /* In udphdr.c: */
  90. struct mbuf *htonudp __ARGS((struct udp *udp,struct mbuf *data,struct pseudo_header *ph));
  91. int ntohudp __ARGS((struct udp *udp,struct mbuf **bpp));
  92.  
  93. #endif    /* _UDP_H */
  94.