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

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