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

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