home *** CD-ROM | disk | FTP | other *** search
/ Media Share 9 / MEDIASHARE_09.ISO / hamradio / s920603.zip / USOCK.H < prev    next >
C/C++ Source or Header  |  1992-05-30  |  3KB  |  140 lines

  1. #ifndef    _USOCK_H
  2. #define    _USOCK_H
  3.  
  4. #ifndef    _MBUF_H
  5. #include "mbuf.h"
  6. #endif
  7.  
  8. #ifndef    _LZW_H
  9. #include "lzw.h"
  10. #endif
  11.  
  12. #ifndef _PROC_H
  13. #include "proc.h"
  14. #endif
  15.  
  16. #ifndef _TCP_H
  17. #include "tcp.h"
  18. #endif
  19.  
  20. #ifndef _UDP_H
  21. #include "udp.h"
  22. #endif
  23.  
  24. #ifndef _IP_H
  25. #include "ip.h"
  26. #endif
  27.  
  28. #ifndef _NETROM_H
  29. #include "netrom.h"
  30. #endif
  31.  
  32. #ifndef _SOCKADDR_H
  33. #include "sockaddr.h"
  34. #endif
  35.  
  36. struct loc {
  37.     struct usock *peer;
  38.     struct mbuf *q;
  39.     int hiwat;        /* Flow control point */
  40.     int flags;
  41. #define    LOC_SHUTDOWN    1
  42. };
  43. #define    NULLLOC    (struct loc *)0
  44. #define    LOCDFLOW    5    /* dgram socket flow-control point, packets */
  45. #define    LOCSFLOW    2048    /* stream socket flow control point, bytes */
  46. #define    SOCKBASE    128    /* Start of socket indexes */
  47.  
  48. union sp {
  49.         struct sockaddr *sa;
  50.         struct sockaddr_in *in;
  51.         struct sockaddr_ax *ax;
  52.         struct sockaddr_nr *nr;
  53.         char *p;
  54. };
  55. struct socklink {
  56.     int type;        /* Socket type */
  57.     int (*socket) __ARGS((struct usock *,int));
  58.     int (*bind) __ARGS((struct usock *));
  59.     int (*listen) __ARGS((struct usock *,int));
  60.     int (*connect) __ARGS((struct usock *));
  61.     int accept;
  62.     int (*recv) __ARGS((struct usock *,struct mbuf **,char *,int *));
  63.     int (*send) __ARGS((struct usock *,struct mbuf *,char *to));
  64.     int (*qlen) __ARGS((struct usock *,int));
  65.     int (*kick) __ARGS((struct usock *));
  66.     int (*shut) __ARGS((struct usock *,int));
  67.     int (*close) __ARGS((struct usock *));
  68.     int (*check) __ARGS((char *,int));
  69.     char **error;
  70.     char *(*state) __ARGS((struct usock *));
  71.     int (*status) __ARGS((struct usock *));
  72.     char *eol;
  73. };
  74. extern struct socklink Socklink[];
  75. union cb {
  76.     struct tcb *tcb;
  77.     struct ax25_cb *ax25;
  78.     struct udp_cb *udp;
  79.     struct raw_ip *rip;
  80.     struct raw_nr *rnr;
  81.     struct nr4cb *nr4;
  82.     struct loc *local;
  83.     char *p;
  84. };
  85. /* User sockets */
  86. struct usock {
  87.     unsigned index;
  88.     struct proc *owner;
  89.     int refcnt;
  90.     char noblock;
  91.     char type;
  92. #define    NOTUSED            0
  93. #define    TYPE_TCP        1
  94. #define    TYPE_UDP        2
  95. #define    TYPE_AX25I        3
  96. #define    TYPE_AX25UI        4
  97. #define TYPE_RAW        5
  98. #define TYPE_NETROML3        6
  99. #define TYPE_NETROML4        7
  100. #define    TYPE_LOCAL_STREAM    8
  101. #define    TYPE_LOCAL_DGRAM    9
  102.     struct socklink *sp;
  103.     int rdysock;
  104.     union cb cb;
  105.     char *name;
  106.     int namelen;
  107.     char *peername;
  108.     int peernamelen;
  109.     char errcodes[4];    /* Protocol-specific error codes */
  110.     char tos;        /* Internet type-of-service */
  111.     int flag;        /* Mode flags, defined in socket.h */
  112. };
  113. #define    NULLUSOCK    ((struct usock *)0)
  114.  
  115. extern char *(*Psock[]) __ARGS((struct sockaddr *));
  116. extern char Badsocket[];
  117. extern char *Socktypes[];
  118. extern struct usock **Usock;
  119. extern unsigned Nsock;
  120. extern int16 Lport;
  121.  
  122. struct usock *itop __ARGS((int s));
  123. void st_garbage __ARGS((int red));
  124.  
  125. /* In locsocket.c: */
  126. int so_los __ARGS((struct usock *up,int protocol));
  127. int so_lod __ARGS((struct usock *up,int protocol));
  128. int so_lo_recv __ARGS((struct usock *up,struct mbuf **bpp,char *from,
  129.     int *fromlen));
  130. int so_los_send __ARGS((struct usock *up,struct mbuf *bp,char *to));
  131. int so_lod_send __ARGS((struct usock *up,struct mbuf *bp,char *to));
  132. int so_lod_qlen __ARGS((struct usock *up,int rtx));
  133. int so_los_qlen __ARGS((struct usock *up,int rtx));
  134. int so_loc_shut __ARGS((struct usock *up,int how));
  135. int so_loc_close __ARGS((struct usock *up));
  136. char *lopsocket __ARGS((struct sockaddr *p));
  137. int so_loc_stat __ARGS((struct usock *up));
  138.  
  139. #endif /* _USOCK_H */
  140.