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

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