root/net/inet/sock.h

/* [previous][next][first][last][top][bottom][index][help] */

INCLUDED FROM


   1 /*
   2  * INET         An implementation of the TCP/IP protocol suite for the LINUX
   3  *              operating system.  INET is implemented using the  BSD Socket
   4  *              interface as the means of communication with the user level.
   5  *
   6  *              Definitions for the AF_INET socket handler.
   7  *
   8  * Version:     @(#)sock.h      1.0.4   05/13/93
   9  *
  10  * Authors:     Ross Biro, <bir7@leland.Stanford.Edu>
  11  *              Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
  12  *              Corey Minyard <wf-rch!minyard@relay.EU.net>
  13  *
  14  *              This program is free software; you can redistribute it and/or
  15  *              modify it under the terms of the GNU General Public License
  16  *              as published by the Free Software Foundation; either version
  17  *              2 of the License, or (at your option) any later version.
  18  */
  19 #ifndef _SOCK_H
  20 #define _SOCK_H
  21 
  22 
  23 #define SOCK_ARRAY_SIZE 64
  24 
  25 
  26 /*
  27  * This structure really needs to be cleaned up.
  28  * Most of it is for TCP, and not used by any of
  29  * the other protocols.
  30  */
  31 struct sock {
  32   struct options                *opt;
  33   volatile unsigned long        wmem_alloc;
  34   volatile unsigned long        rmem_alloc;
  35   unsigned long                 send_seq;
  36   unsigned long                 acked_seq;
  37   unsigned long                 copied_seq;
  38   unsigned long                 rcv_ack_seq;
  39   unsigned long                 window_seq;
  40   unsigned long                 fin_seq;
  41 
  42   /*
  43    * Not all are volatile, but some are, so we
  44    * might as well say they all are.
  45    */
  46   volatile char                 inuse,
  47                                 dead,
  48                                 urginline,
  49                                 intr,
  50                                 blog,
  51                                 done,
  52                                 reuse,
  53                                 keepopen,
  54                                 linger,
  55                                 delay_acks,
  56                                 timeout,
  57                                 destroy,
  58                                 ack_timed,
  59                                 no_check,
  60                                 exp_growth;
  61   int                           proc;
  62   struct sock                   *next;
  63   struct sock                   *pair;
  64   struct sk_buff                *send_tail;
  65   struct sk_buff                *send_head;
  66   struct sk_buff                *volatile back_log;
  67   struct sk_buff                *send_tmp;
  68   long                          retransmits;
  69   struct sk_buff                *wback,
  70                                 *wfront,
  71                                 *rqueue;
  72   struct proto                  *prot;
  73   struct wait_queue             **sleep;
  74   unsigned long                 daddr;
  75   unsigned long                 saddr;
  76   unsigned short                max_unacked;
  77   unsigned short                window;
  78   unsigned short                bytes_rcv;
  79   unsigned short                mtu;
  80   unsigned short                num;
  81   volatile unsigned short       cong_window;
  82   volatile unsigned short       packets_out;
  83   volatile unsigned short       urg;
  84   volatile unsigned short       shutdown;
  85   unsigned short                mss;
  86   volatile short                rtt;
  87   volatile short                err;
  88   unsigned char                 protocol;
  89   volatile unsigned char        state;
  90   volatile unsigned char        ack_backlog;
  91   unsigned char                 max_ack_backlog;
  92   unsigned char                 priority;
  93   struct tcphdr                 dummy_th;
  94   struct timer                  time_wait;
  95 };
  96 
  97 struct proto {
  98   void                  *(*wmalloc)(struct sock *sk,
  99                                     unsigned long size, int force,
 100                                     int priority);
 101   void                  *(*rmalloc)(struct sock *sk,
 102                                     unsigned long size, int force,
 103                                     int priority);
 104   void                  (*wfree)(struct sock *sk, void *mem,
 105                                  unsigned long size);
 106   void                  (*rfree)(struct sock *sk, void *mem,
 107                                  unsigned long size);
 108   unsigned long         (*rspace)(struct sock *sk);
 109   unsigned long         (*wspace)(struct sock *sk);
 110   void                  (*close)(struct sock *sk, int timeout);
 111   int                   (*read)(struct sock *sk, unsigned char *to,
 112                                 int len, int nonblock, unsigned flags);
 113   int                   (*write)(struct sock *sk, unsigned char *to,
 114                                  int len, int nonblock, unsigned flags);
 115   int                   (*sendto)(struct sock *sk,
 116                                   unsigned char *from, int len, int noblock,
 117                                   unsigned flags, struct sockaddr_in *usin,
 118                                   int addr_len);
 119   int                   (*recvfrom)(struct sock *sk,
 120                                     unsigned char *from, int len, int noblock,
 121                                     unsigned flags, struct sockaddr_in *usin,
 122                                     int *addr_len);
 123   int                   (*build_header)(struct sk_buff *skb,
 124                                         unsigned long saddr,
 125                                         unsigned long daddr,
 126                                         struct device **dev, int type,
 127                                         struct options *opt, int len);
 128   int                   (*connect)(struct sock *sk,
 129                                   struct sockaddr_in *usin, int addr_len);
 130   struct sock           *(*accept) (struct sock *sk, int flags);
 131   void                  (*queue_xmit)(struct sock *sk,
 132                                       struct device *dev, struct sk_buff *skb,
 133                                       int free);
 134   void                  (*retransmit)(struct sock *sk, int all);
 135   void                  (*write_wakeup)(struct sock *sk);
 136   void                  (*read_wakeup)(struct sock *sk);
 137   int                   (*rcv)(struct sk_buff *buff, struct device *dev,
 138                                struct options *opt, unsigned long daddr,
 139                                unsigned short len, unsigned long saddr,
 140                                int redo, struct inet_protocol *protocol);
 141   int                   (*select)(struct sock *sk, int which,
 142                                   select_table *wait);
 143   int                   (*ioctl)(struct sock *sk, int cmd,
 144                                  unsigned long arg);
 145   int                   (*init)(struct sock *sk);
 146   void                  (*shutdown)(struct sock *sk, int how);
 147   unsigned short        max_header;
 148   unsigned long         retransmits;
 149   struct sock           *sock_array[SOCK_ARRAY_SIZE];
 150   char                  name[80];
 151 };
 152 
 153 #define TIME_WRITE      1
 154 #define TIME_CLOSE      2
 155 #define TIME_KEEPOPEN   3
 156 #define TIME_DESTROY    4
 157 #define TIME_DONE       5       /* used to absorb those last few packets */
 158 #define SOCK_DESTROY_TIME 1000  /* about 10 seconds                     */
 159 
 160 
 161 #define PROT_SOCK       1024
 162 #define SHUTDOWN_MASK   3
 163 #define RCV_SHUTDOWN    1
 164 #define SEND_SHUTDOWN   2
 165 
 166 
 167 extern void                     destroy_sock(struct sock *sk);
 168 extern unsigned short           get_new_socknum(struct proto *, unsigned short);
 169 extern void                     put_sock(unsigned short, struct sock *); 
 170 extern void                     release_sock(struct sock *sk);
 171 extern struct sock              *get_sock(struct proto *, unsigned short,
 172                                           unsigned long, unsigned short,
 173                                           unsigned long);
 174 extern void                     print_sk(struct sock *);
 175 extern void                     *sock_wmalloc(struct sock *sk,
 176                                               unsigned long size, int force,
 177                                               int priority);
 178 extern void                     *sock_rmalloc(struct sock *sk,
 179                                               unsigned long size, int force,
 180                                               int priority);
 181 extern void                     sock_wfree(struct sock *sk, void *mem,
 182                                            unsigned long size);
 183 extern void                     sock_rfree(struct sock *sk, void *mem,
 184                                            unsigned long size);
 185 extern unsigned long            sock_rspace(struct sock *sk);
 186 extern unsigned long            sock_wspace(struct sock *sk);
 187 
 188 #endif  /* _SOCK_H */

/* [previous][next][first][last][top][bottom][index][help] */