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

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