home *** CD-ROM | disk | FTP | other *** search
/ The Pier Shareware 6 / The_Pier_Shareware_Number_6_(The_Pier_Exchange)_(1995).iso / 024 / psi110g.zip / UDP.H < prev    next >
C/C++ Source or Header  |  1994-04-17  |  3KB  |  93 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.   
  38. /* Structure of a UDP protocol header */
  39. struct udp {
  40.     int16 source;   /* Source port */
  41.     int16 dest; /* Destination port */
  42.     int16 length;   /* Length of header and data */
  43.     int16 checksum; /* Checksum over pseudo-header, header and data */
  44. };
  45. #define UDPHDR  8   /* Length of UDP header */
  46.   
  47. /* User Datagram Protocol control block
  48.  * Each entry on the receive queue consists of the
  49.  * remote socket structure, followed by any data
  50.  */
  51. struct udp_cb {
  52.     struct udp_cb *next;
  53.     struct socket socket;   /* Local port accepting datagrams */
  54.     void (*r_upcall) __ARGS((struct iface *iface,struct udp_cb *,int));
  55.                 /* Function to call when one arrives */
  56.     struct mbuf *rcvq;  /* Queue of pending datagrams */
  57.     int rcvcnt;     /* Count of pending datagrams */
  58.     int user;       /* User link */
  59. };
  60. extern struct udp_cb *Udps; /* Hash table for UDP structures */
  61. #define NULLUDP (struct udp_cb *)0
  62.   
  63. /* UDP primitives */
  64.   
  65. /* In udp.c: */
  66. int del_udp __ARGS((struct udp_cb *up));
  67. struct udp_cb *open_udp __ARGS((struct socket *lsocket,
  68. void (*r_upcall) __ARGS((struct iface *iface,struct udp_cb *,int))));
  69. int recv_udp __ARGS((struct udp_cb *up,struct socket *fsocket,struct mbuf **bp));
  70. int send_udp __ARGS((struct socket *lsocket,struct socket *fsocket,char tos,
  71. char ttl,struct mbuf *data,int16 length,int16 id,char df));
  72. void udp_input __ARGS((struct iface *iface,struct ip *ip,struct mbuf *bp,
  73. int rxbroadcast));
  74. void udp_garbage __ARGS((int drastic));
  75.   
  76. #ifdef HOPCHECK
  77. void udp_icmp __ARGS((int32 icsource, int32 ipsource,int32 ipdest,
  78. char ictype,char iccode,struct mbuf **bpp));
  79. /* In hop.c: */
  80. void hop_icmp __ARGS((struct udp_cb *ucb, int32 icsource, int32 ipdest,
  81. int16 udpdest, char ictype, char iccode));
  82. #endif
  83.   
  84. /* In udpcmd.c: */
  85. int st_udp __ARGS((struct udp_cb *udp,int n));
  86.   
  87. /* In udphdr.c: */
  88. struct mbuf *htonudp __ARGS((struct udp *udp,struct mbuf *data,struct pseudo_header *ph));
  89. int ntohudp __ARGS((struct udp *udp,struct mbuf **bpp));
  90. int16 udpcksum __ARGS((struct mbuf *bp));
  91.   
  92. #endif  /* _UDP_H */
  93.