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 #include <linux/config.h>
  37 
  38 #include <linux/skbuff.h>       /* struct sk_buff */
  39 #include "protocol.h"           /* struct inet_protocol */
  40 #ifdef CONFIG_AX25
  41 #include "ax25.h"
  42 #endif
  43 #ifdef CONFIG_IPX
  44 #include "ipx.h"
  45 #endif
  46 #ifdef CONFIG_ATALK
  47 #include <linux/atalk.h>
  48 #endif
  49 
  50 #include <linux/igmp.h>
  51 
  52 #define SOCK_ARRAY_SIZE 256             /* Think big (also on some systems a byte is faster */
  53 
  54 
  55 /*
  56  * This structure really needs to be cleaned up.
  57  * Most of it is for TCP, and not used by any of
  58  * the other protocols.
  59  */
  60 struct sock {
  61   struct options                *opt;
  62   volatile unsigned long        wmem_alloc;
  63   volatile unsigned long        rmem_alloc;
  64   unsigned long                 write_seq;
  65   unsigned long                 sent_seq;
  66   unsigned long                 acked_seq;
  67   unsigned long                 copied_seq;
  68   unsigned long                 rcv_ack_seq;
  69   unsigned long                 window_seq;
  70   unsigned long                 fin_seq;
  71   unsigned long                 urg_seq;
  72   unsigned long                 urg_data;
  73 
  74   /*
  75    * Not all are volatile, but some are, so we
  76    * might as well say they all are.
  77    */
  78   volatile char                 inuse,
  79                                 dead,
  80                                 urginline,
  81                                 intr,
  82                                 blog,
  83                                 done,
  84                                 reuse,
  85                                 keepopen,
  86                                 linger,
  87                                 delay_acks,
  88                                 destroy,
  89                                 ack_timed,
  90                                 no_check,
  91                                 zapped, /* In ax25 & ipx means not linked */
  92                                 broadcast,
  93                                 nonagle;
  94   unsigned long                 lingertime;
  95   int                           proc;
  96   struct sock                   *next;
  97   struct sock                   *prev; /* Doubly linked chain.. */
  98   struct sock                   *pair;
  99   struct sk_buff                * volatile send_head;
 100   struct sk_buff                * volatile send_tail;
 101   struct sk_buff_head           back_log;
 102   struct sk_buff                *partial;
 103   struct timer_list             partial_timer;
 104   long                          retransmits;
 105   struct sk_buff_head           write_queue,
 106                                 receive_queue;
 107   struct proto                  *prot;
 108   struct wait_queue             **sleep;
 109   unsigned long                 daddr;
 110   unsigned long                 saddr;
 111   unsigned short                max_unacked;
 112   unsigned short                window;
 113   unsigned short                bytes_rcv;
 114 /* mss is min(mtu, max_window) */
 115   unsigned short                mtu;       /* mss negotiated in the syn's */
 116   volatile unsigned short       mss;       /* current eff. mss - can change */
 117   volatile unsigned short       user_mss;  /* mss requested by user in ioctl */
 118   volatile unsigned short       max_window;
 119   unsigned long                 window_clamp;
 120   unsigned short                num;
 121   volatile unsigned short       cong_window;
 122   volatile unsigned short       cong_count;
 123   volatile unsigned short       ssthresh;
 124   volatile unsigned short       packets_out;
 125   volatile unsigned short       shutdown;
 126   volatile unsigned long        rtt;
 127   volatile unsigned long        mdev;
 128   volatile unsigned long        rto;
 129 /* currently backoff isn't used, but I'm maintaining it in case
 130  * we want to go back to a backoff formula that needs it
 131  */
 132   volatile unsigned short       backoff;
 133   volatile short                err;
 134   unsigned char                 protocol;
 135   volatile unsigned char        state;
 136   volatile unsigned char        ack_backlog;
 137   unsigned char                 max_ack_backlog;
 138   unsigned char                 priority;
 139   unsigned char                 debug;
 140   unsigned short                rcvbuf;
 141   unsigned short                sndbuf;
 142   unsigned short                type;
 143   unsigned char                 localroute;     /* Route locally only */
 144 #ifdef CONFIG_IPX
 145   ipx_address                   ipx_dest_addr;
 146   ipx_interface                 *ipx_intrfc;
 147   unsigned short                ipx_port;
 148   unsigned short                ipx_type;
 149 #endif
 150 #ifdef CONFIG_AX25
 151 /* Really we want to add a per protocol private area */
 152   ax25_address                  ax25_source_addr,ax25_dest_addr;
 153   struct sk_buff *volatile      ax25_retxq[8];
 154   char                          ax25_state,ax25_vs,ax25_vr,ax25_lastrxnr,ax25_lasttxnr;
 155   char                          ax25_condition;
 156   char                          ax25_retxcnt;
 157   char                          ax25_xx;
 158   char                          ax25_retxqi;
 159   char                          ax25_rrtimer;
 160   char                          ax25_timer;
 161   unsigned char                 ax25_n2;
 162   unsigned short                ax25_t1,ax25_t2,ax25_t3;
 163   ax25_digi                     *ax25_digipeat;
 164 #endif  
 165 #ifdef CONFIG_ATALK
 166   struct atalk_sock             at;
 167 #endif
 168 
 169 /* IP 'private area' or will be eventually */
 170   int                           ip_ttl;         /* TTL setting */
 171   int                           ip_tos;         /* TOS */
 172   struct tcphdr                 dummy_th;
 173   struct timer_list             keepalive_timer;        /* TCP keepalive hack */
 174   struct timer_list             retransmit_timer;       /* TCP retransmit timer */
 175   struct timer_list             ack_timer;              /* TCP delayed ack timer */
 176   int                           ip_xmit_timeout;        /* Why the timeout is running */
 177 #ifdef CONFIG_IP_MULTICAST  
 178   int                           ip_mc_ttl;                      /* Multicasting TTL */
 179   int                           ip_mc_loop;                     /* Loopback (not implemented yet) */
 180   char                          ip_mc_name[MAX_ADDR_LEN];       /* Multicast device name */
 181   struct ip_mc_socklist         *ip_mc_list;                    /* Group array */
 182 #endif  
 183 
 184   /* This part is used for the timeout functions (timer.c). */
 185   int                           timeout;        /* What are we waiting for? */
 186   struct timer_list             timer;          /* This is the TIME_WAIT/receive timer when we are doing IP */
 187   struct timeval                stamp;
 188 
 189   /* identd */
 190   struct socket                 *socket;
 191   
 192   /* Callbacks */
 193   void                          (*state_change)(struct sock *sk);
 194   void                          (*data_ready)(struct sock *sk,int bytes);
 195   void                          (*write_space)(struct sock *sk);
 196   void                          (*error_report)(struct sock *sk);
 197   
 198 };
 199 
 200 struct proto {
 201   struct sk_buff *      (*wmalloc)(struct sock *sk,
 202                                     unsigned long size, int force,
 203                                     int priority);
 204   struct sk_buff *      (*rmalloc)(struct sock *sk,
 205                                     unsigned long size, int force,
 206                                     int priority);
 207   void                  (*wfree)(struct sock *sk, struct sk_buff *skb,
 208                                  unsigned long size);
 209   void                  (*rfree)(struct sock *sk, struct sk_buff *skb,
 210                                  unsigned long size);
 211   unsigned long         (*rspace)(struct sock *sk);
 212   unsigned long         (*wspace)(struct sock *sk);
 213   void                  (*close)(struct sock *sk, int timeout);
 214   int                   (*read)(struct sock *sk, unsigned char *to,
 215                                 int len, int nonblock, unsigned flags);
 216   int                   (*write)(struct sock *sk, unsigned char *to,
 217                                  int len, int nonblock, unsigned flags);
 218   int                   (*sendto)(struct sock *sk,
 219                                   unsigned char *from, int len, int noblock,
 220                                   unsigned flags, struct sockaddr_in *usin,
 221                                   int addr_len);
 222   int                   (*recvfrom)(struct sock *sk,
 223                                     unsigned char *from, int len, int noblock,
 224                                     unsigned flags, struct sockaddr_in *usin,
 225                                     int *addr_len);
 226   int                   (*build_header)(struct sk_buff *skb,
 227                                         unsigned long saddr,
 228                                         unsigned long daddr,
 229                                         struct device **dev, int type,
 230                                         struct options *opt, int len, int tos, int ttl);
 231   int                   (*connect)(struct sock *sk,
 232                                   struct sockaddr_in *usin, int addr_len);
 233   struct sock *         (*accept) (struct sock *sk, int flags);
 234   void                  (*queue_xmit)(struct sock *sk,
 235                                       struct device *dev, struct sk_buff *skb,
 236                                       int free);
 237   void                  (*retransmit)(struct sock *sk, int all);
 238   void                  (*write_wakeup)(struct sock *sk);
 239   void                  (*read_wakeup)(struct sock *sk);
 240   int                   (*rcv)(struct sk_buff *buff, struct device *dev,
 241                                struct options *opt, unsigned long daddr,
 242                                unsigned short len, unsigned long saddr,
 243                                int redo, struct inet_protocol *protocol);
 244   int                   (*select)(struct sock *sk, int which,
 245                                   select_table *wait);
 246   int                   (*ioctl)(struct sock *sk, int cmd,
 247                                  unsigned long arg);
 248   int                   (*init)(struct sock *sk);
 249   void                  (*shutdown)(struct sock *sk, int how);
 250   int                   (*setsockopt)(struct sock *sk, int level, int optname,
 251                                  char *optval, int optlen);
 252   int                   (*getsockopt)(struct sock *sk, int level, int optname,
 253                                 char *optval, int *option);      
 254   unsigned short        max_header;
 255   unsigned long         retransmits;
 256   struct sock *         sock_array[SOCK_ARRAY_SIZE];
 257   char                  name[80];
 258   int                   inuse, highestinuse;
 259 };
 260 
 261 #define TIME_WRITE      1
 262 #define TIME_CLOSE      2
 263 #define TIME_KEEPOPEN   3
 264 #define TIME_DESTROY    4
 265 #define TIME_DONE       5       /* used to absorb those last few packets */
 266 #define TIME_PROBE0     6
 267 #define SOCK_DESTROY_TIME 1000  /* about 10 seconds                     */
 268 
 269 #define PROT_SOCK       1024    /* Sockets 0-1023 can't be bound too unless you are superuser */
 270 
 271 #define SHUTDOWN_MASK   3
 272 #define RCV_SHUTDOWN    1
 273 #define SEND_SHUTDOWN   2
 274 
 275 
 276 extern void                     destroy_sock(struct sock *sk);
 277 extern unsigned short           get_new_socknum(struct proto *, unsigned short);
 278 extern void                     put_sock(unsigned short, struct sock *); 
 279 extern void                     release_sock(struct sock *sk);
 280 extern struct sock              *get_sock(struct proto *, unsigned short,
 281                                           unsigned long, unsigned short,
 282                                           unsigned long);
 283 extern struct sock              *get_sock_mcast(struct sock *, unsigned short,
 284                                           unsigned long, unsigned short,
 285                                           unsigned long);
 286 extern struct sock              *get_sock_raw(struct sock *, unsigned short,
 287                                           unsigned long, unsigned long);
 288 
 289 extern struct sk_buff           *sock_wmalloc(struct sock *sk,
 290                                               unsigned long size, int force,
 291                                               int priority);
 292 extern struct sk_buff           *sock_rmalloc(struct sock *sk,
 293                                               unsigned long size, int force,
 294                                               int priority);
 295 extern void                     sock_wfree(struct sock *sk, struct sk_buff *skb,
 296                                            unsigned long size);
 297 extern void                     sock_rfree(struct sock *sk, struct sk_buff *skb,
 298                                            unsigned long size);
 299 extern unsigned long            sock_rspace(struct sock *sk);
 300 extern unsigned long            sock_wspace(struct sock *sk);
 301 
 302 extern int                      sock_setsockopt(struct sock *sk,int level,int op,char *optval,int optlen);
 303 
 304 extern int                      sock_getsockopt(struct sock *sk,int level,int op,char *optval,int *optlen);
 305 extern struct sk_buff           *sock_alloc_send_skb(struct sock *skb, unsigned long size, int noblock, int *errcode);
 306 extern int                      sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb);
 307 
 308 /* declarations from timer.c */
 309 extern struct sock *timer_base;
 310 
 311 void delete_timer (struct sock *);
 312 void reset_timer (struct sock *, int, unsigned long);
 313 void net_timer (unsigned long);
 314 
 315 
 316 #endif  /* _SOCK_H */

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