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 #ifdef CONFIG_AX25
  40 #include "ax25.h"
  41 #endif
  42 #ifdef CONFIG_IPX
  43 #include "ipx.h"
  44 #endif
  45 
  46 #define SOCK_ARRAY_SIZE 64
  47 
  48 
  49 /*
  50  * This structure really needs to be cleaned up.
  51  * Most of it is for TCP, and not used by any of
  52  * the other protocols.
  53  */
  54 struct sock {
  55   struct options                *opt;
  56   volatile unsigned long        wmem_alloc;
  57   volatile unsigned long        rmem_alloc;
  58   unsigned long                 send_seq;
  59   unsigned long                 acked_seq;
  60   unsigned long                 copied_seq;
  61   unsigned long                 rcv_ack_seq;
  62   unsigned long                 window_seq;
  63   unsigned long                 fin_seq;
  64 
  65   /*
  66    * Not all are volatile, but some are, so we
  67    * might as well say they all are.
  68    */
  69   volatile char                 inuse,
  70                                 dead,
  71                                 urginline,
  72                                 intr,
  73                                 blog,
  74                                 done,
  75                                 reuse,
  76                                 keepopen,
  77                                 linger,
  78                                 delay_acks,
  79                                 destroy,
  80                                 ack_timed,
  81                                 no_check,
  82                                 exp_growth,
  83                                 zapped, /* In ax25 & ipx means not linked */
  84                                 broadcast,
  85                                 nonagle;
  86   unsigned long                 lingertime;
  87   int                           proc;
  88   struct sock                   *next;
  89   struct sock                   *pair;
  90   struct sk_buff                *volatile send_tail;
  91   struct sk_buff                *volatile send_head;
  92   struct sk_buff                *volatile back_log;
  93   struct sk_buff                *send_tmp;
  94   long                          retransmits;
  95   struct sk_buff                *volatile wback,
  96                                 *volatile wfront,
  97                                 *volatile rqueue;
  98   struct proto                  *prot;
  99   struct wait_queue             **sleep;
 100   unsigned long                 daddr;
 101   unsigned long                 saddr;
 102   unsigned short                max_unacked;
 103   unsigned short                window;
 104   unsigned short                bytes_rcv;
 105   unsigned short                mtu;
 106   unsigned short                num;
 107   volatile unsigned short       cong_window;
 108   volatile unsigned short       packets_out;
 109   volatile unsigned short       urg;
 110   volatile unsigned short       shutdown;
 111   unsigned short                mss;
 112   volatile unsigned long        rtt;
 113   volatile unsigned long        mdev;
 114   volatile unsigned short       backoff;
 115   volatile short                err;
 116   unsigned char                 protocol;
 117   volatile unsigned char        state;
 118   volatile unsigned char        ack_backlog;
 119   unsigned char                 max_ack_backlog;
 120   unsigned char                 priority;
 121   unsigned char                 debug;
 122   unsigned short                rcvbuf;
 123   unsigned short                sndbuf;
 124   unsigned short                type;
 125 #ifdef CONFIG_IPX
 126   ipx_address                   ipx_source_addr,ipx_dest_addr;
 127   unsigned short                ipx_type;
 128 #endif
 129 #ifdef CONFIG_AX25
 130 /* Really we want to add a per protocol private area */
 131   ax25_address                  ax25_source_addr,ax25_dest_addr;
 132   struct sk_buff *volatile      ax25_retxq[8];
 133   char                          ax25_state,ax25_vs,ax25_vr,ax25_lastrxnr,ax25_lasttxnr;
 134   char                          ax25_condition;
 135   char                          ax25_retxcnt;
 136   char                          ax25_xx;
 137   char                          ax25_retxqi;
 138   char                          ax25_rrtimer;
 139   char                          ax25_timer;
 140   ax25_digi                     *ax25_digipeat;
 141 #endif  
 142 /* IP 'private area' or will be eventually */
 143   int                           ip_ttl;         /* TTL setting */
 144   int                           ip_tos;         /* TOS */
 145   struct tcphdr                 dummy_th;
 146 
 147   /* This part is used for the timeout functions (timer.c). */
 148   int                           timeout;        /* What are we waiting for? */
 149   struct timer_list             timer;
 150 
 151   /* identd */
 152   struct socket                 *socket;
 153   
 154   /* Callbacks */
 155   void                          (*state_change)(struct sock *sk);
 156   void                          (*data_ready)(struct sock *sk,int bytes);
 157   void                          (*write_space)(struct sock *sk);
 158   void                          (*error_report)(struct sock *sk);
 159   
 160 };
 161 
 162 struct proto {
 163   struct sk_buff *      (*wmalloc)(struct sock *sk,
 164                                     unsigned long size, int force,
 165                                     int priority);
 166   struct sk_buff *      (*rmalloc)(struct sock *sk,
 167                                     unsigned long size, int force,
 168                                     int priority);
 169   void                  (*wfree)(struct sock *sk, void *mem,
 170                                  unsigned long size);
 171   void                  (*rfree)(struct sock *sk, void *mem,
 172                                  unsigned long size);
 173   unsigned long         (*rspace)(struct sock *sk);
 174   unsigned long         (*wspace)(struct sock *sk);
 175   void                  (*close)(struct sock *sk, int timeout);
 176   int                   (*read)(struct sock *sk, unsigned char *to,
 177                                 int len, int nonblock, unsigned flags);
 178   int                   (*write)(struct sock *sk, unsigned char *to,
 179                                  int len, int nonblock, unsigned flags);
 180   int                   (*sendto)(struct sock *sk,
 181                                   unsigned char *from, int len, int noblock,
 182                                   unsigned flags, struct sockaddr_in *usin,
 183                                   int addr_len);
 184   int                   (*recvfrom)(struct sock *sk,
 185                                     unsigned char *from, int len, int noblock,
 186                                     unsigned flags, struct sockaddr_in *usin,
 187                                     int *addr_len);
 188   int                   (*build_header)(struct sk_buff *skb,
 189                                         unsigned long saddr,
 190                                         unsigned long daddr,
 191                                         struct device **dev, int type,
 192                                         struct options *opt, int len, int tos, int ttl);
 193   int                   (*connect)(struct sock *sk,
 194                                   struct sockaddr_in *usin, int addr_len);
 195   struct sock *         (*accept) (struct sock *sk, int flags);
 196   void                  (*queue_xmit)(struct sock *sk,
 197                                       struct device *dev, struct sk_buff *skb,
 198                                       int free);
 199   void                  (*retransmit)(struct sock *sk, int all);
 200   void                  (*write_wakeup)(struct sock *sk);
 201   void                  (*read_wakeup)(struct sock *sk);
 202   int                   (*rcv)(struct sk_buff *buff, struct device *dev,
 203                                struct options *opt, unsigned long daddr,
 204                                unsigned short len, unsigned long saddr,
 205                                int redo, struct inet_protocol *protocol);
 206   int                   (*select)(struct sock *sk, int which,
 207                                   select_table *wait);
 208   int                   (*ioctl)(struct sock *sk, int cmd,
 209                                  unsigned long arg);
 210   int                   (*init)(struct sock *sk);
 211   void                  (*shutdown)(struct sock *sk, int how);
 212   int                   (*setsockopt)(struct sock *sk, int level, int optname,
 213                                  char *optval, int optlen);
 214   int                   (*getsockopt)(struct sock *sk, int level, int optname,
 215                                 char *optval, int *option);      
 216   unsigned short        max_header;
 217   unsigned long         retransmits;
 218   struct sock *         sock_array[SOCK_ARRAY_SIZE];
 219   char                  name[80];
 220 };
 221 
 222 #define TIME_WRITE      1
 223 #define TIME_CLOSE      2
 224 #define TIME_KEEPOPEN   3
 225 #define TIME_DESTROY    4
 226 #define TIME_DONE       5       /* used to absorb those last few packets */
 227 #define TIME_PROBE0     6
 228 #define SOCK_DESTROY_TIME 1000  /* about 10 seconds                     */
 229 
 230 #define PROT_SOCK       1024    /* Sockets 0-1023 can't be bound too unless you are superuser */
 231 
 232 #define SHUTDOWN_MASK   3
 233 #define RCV_SHUTDOWN    1
 234 #define SEND_SHUTDOWN   2
 235 
 236 
 237 extern void                     destroy_sock(struct sock *sk);
 238 extern unsigned short           get_new_socknum(struct proto *, unsigned short);
 239 extern void                     put_sock(unsigned short, struct sock *); 
 240 extern void                     release_sock(struct sock *sk);
 241 extern struct sock              *get_sock(struct proto *, unsigned short,
 242                                           unsigned long, unsigned short,
 243                                           unsigned long);
 244 extern void                     print_sk(struct sock *);
 245 extern struct sk_buff           *sock_wmalloc(struct sock *sk,
 246                                               unsigned long size, int force,
 247                                               int priority);
 248 extern struct sk_buff           *sock_rmalloc(struct sock *sk,
 249                                               unsigned long size, int force,
 250                                               int priority);
 251 extern void                     sock_wfree(struct sock *sk, void *mem,
 252                                            unsigned long size);
 253 extern void                     sock_rfree(struct sock *sk, void *mem,
 254                                            unsigned long size);
 255 extern unsigned long            sock_rspace(struct sock *sk);
 256 extern unsigned long            sock_wspace(struct sock *sk);
 257 
 258 extern int                      sock_setsockopt(struct sock *sk,int level,int op,char *optval,int optlen);
 259 extern int                      sock_getsockopt(struct sock *sk,int level,int op,char *optval,int *optlen);
 260 
 261 /* declarations from timer.c */
 262 extern struct sock *timer_base;
 263 
 264 void delete_timer (struct sock *);
 265 void reset_timer (struct sock *, int, unsigned long);
 266 void net_timer (unsigned long);
 267 
 268 
 269 #endif  /* _SOCK_H */

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