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

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