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  *              Florian La Roche <flla@stud.uni-sb.de>
  14  *
  15  * Fixes:
  16  *              Alan Cox        :       Volatiles in skbuff pointers. See
  17  *                                      skbuff comments. May be overdone,
  18  *                                      better to prove they can be removed
  19  *                                      than the reverse.
  20  *              Alan Cox        :       Added a zapped field for tcp to note
  21  *                                      a socket is reset and must stay shut up
  22  *              Alan Cox        :       New fields for options
  23  *      Pauline Middelink       :       identd support
  24  *
  25  *              This program is free software; you can redistribute it and/or
  26  *              modify it under the terms of the GNU General Public License
  27  *              as published by the Free Software Foundation; either version
  28  *              2 of the License, or (at your option) any later version.
  29  */
  30 #ifndef _SOCK_H
  31 #define _SOCK_H
  32 
  33 #include <linux/timer.h>
  34 #include <linux/ip.h>           /* struct options */
  35 #include <linux/tcp.h>          /* struct tcphdr */
  36 
  37 #include "skbuff.h"             /* struct sk_buff */
  38 #include "protocol.h"           /* struct inet_protocol */
  39 
  40 #define SOCK_ARRAY_SIZE 64
  41 
  42 
  43 /*
  44  * This structure really needs to be cleaned up.
  45  * Most of it is for TCP, and not used by any of
  46  * the other protocols.
  47  */
  48 struct sock {
  49   struct options                *opt;
  50   volatile unsigned long        wmem_alloc;
  51   volatile unsigned long        rmem_alloc;
  52   unsigned long                 send_seq;
  53   unsigned long                 acked_seq;
  54   unsigned long                 copied_seq;
  55   unsigned long                 rcv_ack_seq;
  56   unsigned long                 window_seq;
  57   unsigned long                 fin_seq;
  58 
  59   /*
  60    * Not all are volatile, but some are, so we
  61    * might as well say they all are.
  62    */
  63   volatile char                 inuse,
  64                                 dead,
  65                                 urginline,
  66                                 intr,
  67                                 blog,
  68                                 done,
  69                                 reuse,
  70                                 keepopen,
  71                                 linger,
  72                                 delay_acks,
  73                                 destroy,
  74                                 ack_timed,
  75                                 no_check,
  76                                 exp_growth,
  77                                 zapped, /* In ipx means not linked */
  78                                 broadcast;
  79   unsigned long                 lingertime;
  80   int                           proc;
  81   struct sock                   *next;
  82   struct sock                   *pair;
  83   struct sk_buff                *volatile send_tail;
  84   struct sk_buff                *volatile send_head;
  85   struct sk_buff                *volatile back_log;
  86   struct sk_buff                *send_tmp;
  87   long                          retransmits;
  88   struct sk_buff                *volatile wback,
  89                                 *volatile wfront,
  90                                 *volatile rqueue;
  91   struct proto                  *prot;
  92   struct wait_queue             **sleep;
  93   unsigned long                 daddr;
  94   unsigned long                 saddr;
  95   unsigned short                max_unacked;
  96   unsigned short                window;
  97   unsigned short                bytes_rcv;
  98   unsigned short                mtu;
  99   unsigned short                num;
 100   volatile unsigned short       cong_window;
 101   volatile unsigned short       packets_out;
 102   volatile unsigned short       urg;
 103   volatile unsigned short       shutdown;
 104   unsigned short                mss;
 105   volatile unsigned long        rtt;
 106   volatile unsigned long        mdev;
 107   volatile unsigned short       backoff;
 108   volatile short                err;
 109   unsigned char                 protocol;
 110   volatile unsigned char        state;
 111   volatile unsigned char        ack_backlog;
 112   unsigned char                 max_ack_backlog;
 113   unsigned char                 priority;
 114   unsigned char                 debug;
 115   unsigned short                rcvbuf;
 116   unsigned short                sndbuf;
 117   unsigned short                type;   /* IPX type field */
 118   struct tcphdr                 dummy_th;
 119 
 120   /* This part is used for the timeout functions (timer.c). */
 121   int                           timeout;        /* What are we waiting for? */
 122   struct timer_list             timer;
 123 
 124   /* identd */
 125   struct socket                 *socket;
 126 };
 127 
 128 struct proto {
 129   void                  *(*wmalloc)(struct sock *sk,
 130                                     unsigned long size, int force,
 131                                     int priority);
 132   void                  *(*rmalloc)(struct sock *sk,
 133                                     unsigned long size, int force,
 134                                     int priority);
 135   void                  (*wfree)(struct sock *sk, void *mem,
 136                                  unsigned long size);
 137   void                  (*rfree)(struct sock *sk, void *mem,
 138                                  unsigned long size);
 139   unsigned long         (*rspace)(struct sock *sk);
 140   unsigned long         (*wspace)(struct sock *sk);
 141   void                  (*close)(struct sock *sk, int timeout);
 142   int                   (*read)(struct sock *sk, unsigned char *to,
 143                                 int len, int nonblock, unsigned flags);
 144   int                   (*write)(struct sock *sk, unsigned char *to,
 145                                  int len, int nonblock, unsigned flags);
 146   int                   (*sendto)(struct sock *sk,
 147                                   unsigned char *from, int len, int noblock,
 148                                   unsigned flags, struct sockaddr_in *usin,
 149                                   int addr_len);
 150   int                   (*recvfrom)(struct sock *sk,
 151                                     unsigned char *from, int len, int noblock,
 152                                     unsigned flags, struct sockaddr_in *usin,
 153                                     int *addr_len);
 154   int                   (*build_header)(struct sk_buff *skb,
 155                                         unsigned long saddr,
 156                                         unsigned long daddr,
 157                                         struct device **dev, int type,
 158                                         struct options *opt, int len);
 159   int                   (*connect)(struct sock *sk,
 160                                   struct sockaddr_in *usin, int addr_len);
 161   struct sock           *(*accept) (struct sock *sk, int flags);
 162   void                  (*queue_xmit)(struct sock *sk,
 163                                       struct device *dev, struct sk_buff *skb,
 164                                       int free);
 165   void                  (*retransmit)(struct sock *sk, int all);
 166   void                  (*write_wakeup)(struct sock *sk);
 167   void                  (*read_wakeup)(struct sock *sk);
 168   int                   (*rcv)(struct sk_buff *buff, struct device *dev,
 169                                struct options *opt, unsigned long daddr,
 170                                unsigned short len, unsigned long saddr,
 171                                int redo, struct inet_protocol *protocol);
 172   int                   (*select)(struct sock *sk, int which,
 173                                   select_table *wait);
 174   int                   (*ioctl)(struct sock *sk, int cmd,
 175                                  unsigned long arg);
 176   int                   (*init)(struct sock *sk);
 177   void                  (*shutdown)(struct sock *sk, int how);
 178   unsigned short        max_header;
 179   unsigned long         retransmits;
 180   struct sock           *sock_array[SOCK_ARRAY_SIZE];
 181   char                  name[80];
 182 };
 183 
 184 #define TIME_WRITE      1
 185 #define TIME_CLOSE      2
 186 #define TIME_KEEPOPEN   3
 187 #define TIME_DESTROY    4
 188 #define TIME_DONE       5       /* used to absorb those last few packets */
 189 #define SOCK_DESTROY_TIME 1000  /* about 10 seconds                     */
 190 
 191 #define PROT_SOCK       1024    /* Sockets 0-1023 can't be bound too unless you are superuser */
 192 
 193 #define SHUTDOWN_MASK   3
 194 #define RCV_SHUTDOWN    1
 195 #define SEND_SHUTDOWN   2
 196 
 197 
 198 extern void                     destroy_sock(struct sock *sk);
 199 extern unsigned short           get_new_socknum(struct proto *, unsigned short);
 200 extern void                     put_sock(unsigned short, struct sock *); 
 201 extern void                     release_sock(struct sock *sk);
 202 extern struct sock              *get_sock(struct proto *, unsigned short,
 203                                           unsigned long, unsigned short,
 204                                           unsigned long);
 205 extern void                     print_sk(struct sock *);
 206 extern void                     *sock_wmalloc(struct sock *sk,
 207                                               unsigned long size, int force,
 208                                               int priority);
 209 extern void                     *sock_rmalloc(struct sock *sk,
 210                                               unsigned long size, int force,
 211                                               int priority);
 212 extern void                     sock_wfree(struct sock *sk, void *mem,
 213                                            unsigned long size);
 214 extern void                     sock_rfree(struct sock *sk, void *mem,
 215                                            unsigned long size);
 216 extern unsigned long            sock_rspace(struct sock *sk);
 217 extern unsigned long            sock_wspace(struct sock *sk);
 218 
 219 
 220 /* declarations from timer.c */
 221 extern struct sock *timer_base;
 222 
 223 void delete_timer (struct sock *);
 224 void reset_timer (struct sock *, int, unsigned long);
 225 void net_timer (unsigned long);
 226 
 227 
 228 #endif  /* _SOCK_H */

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