root/net/socket/sock.h

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

INCLUDED FROM


   1 /*
   2  *              Definitions for the socket handler
   3  *
   4  * Version:     @(#)sock.h      1.28    26/12/93
   5  *
   6  * Authors:     Ross Biro, <bir7@leland.Stanford.Edu>
   7  *              Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
   8  *              Corey Minyard <wf-rch!minyard@relay.EU.net>
   9  *              Florian La Roche <flla@stud.uni-sb.de>
  10  *
  11  * Fixes:
  12  *              Alan Cox        :       Volatiles in skbuff pointers. See
  13  *                                      skbuff comments. May be overdone,
  14  *                                      better to prove they can be removed
  15  *                                      than the reverse.
  16  *              Alan Cox        :       Added a zapped field for tcp to note
  17  *                                      a socket is reset and must stay shut up
  18  *              Alan Cox        :       New fields for options
  19  *      Pauline Middelink       :       identd support
  20  *              Alan Cox        :       Split into sock.h and sockinet.h
  21  *
  22  *              This program is free software; you can redistribute it and/or
  23  *              modify it under the terms of the GNU General Public License
  24  *              as published by the Free Software Foundation; either version
  25  *              2 of the License, or (at your option) any later version.
  26  */
  27 #ifndef _SOCK_H
  28 #define _SOCK_H
  29 
  30 #include <linux/timer.h>
  31 #include <linux/ip.h>           /* struct options */
  32 #include <linux/tcp.h>          /* struct tcphdr */
  33 
  34 #include "skbuff.h"             /* struct sk_buff */
  35 #ifdef CONFIG_AX25
  36 #include "ax25/ax25.h"
  37 #endif
  38 #ifdef CONFIG_IPX
  39 #include "ipx/ipx.h"
  40 #endif
  41 
  42 #define SOCK_ARRAY_SIZE 64
  43 
  44 
  45 /*
  46  * This structure really needs to be cleaned up.
  47  * Most of it is for TCP, and not used by any of
  48  * the other protocols.
  49  */
  50 struct sock {
  51   struct options                *opt;
  52   struct options                *rcv_opt;
  53   volatile unsigned long        wmem_alloc;
  54   volatile unsigned long        rmem_alloc;
  55   unsigned long                 send_seq;
  56   unsigned long                 acked_seq;
  57   unsigned long                 copied_seq;
  58   unsigned long                 rcv_ack_seq;
  59   unsigned long                 window_seq;
  60   unsigned long                 fin_seq;
  61 
  62   /*
  63    * Not all are volatile, but some are, so we
  64    * might as well say they all are.
  65    */
  66   volatile char                 inuse,
  67                                 dead,
  68                                 urginline,
  69                                 intr,
  70                                 blog,
  71                                 done,
  72                                 reuse,
  73                                 keepopen,
  74                                 linger,
  75                                 delay_acks,
  76                                 destroy,
  77                                 ack_timed,
  78                                 no_check,
  79                                 exp_growth,
  80                                 zapped, /* In ax25 & ipx means not linked */
  81                                 broadcast;
  82   unsigned long                 lingertime;
  83   int                           proc;
  84   struct sock                   *next;
  85   struct sock                   *pair;
  86   struct sk_buff                *volatile send_tail;
  87   struct sk_buff                *volatile send_head;
  88   struct sk_buff                *volatile back_log;
  89   struct sk_buff                *send_tmp;
  90   long                          retransmits;
  91   struct sk_buff                *volatile wback,
  92                                 *volatile wfront,
  93                                 *volatile rqueue;
  94   struct proto                  *prot;
  95   struct wait_queue             **sleep;
  96   unsigned long                 daddr;
  97   unsigned long                 saddr;
  98   unsigned short                max_unacked;
  99   unsigned short                window;
 100   unsigned short                bytes_rcv;
 101   unsigned short                mtu;
 102   unsigned short                num;
 103   volatile unsigned short       cong_window;
 104   volatile unsigned short       packets_out;
 105   volatile unsigned short       urg;
 106   volatile unsigned short       shutdown;
 107   unsigned short                mss;
 108   volatile unsigned long        rtt;
 109   volatile unsigned long        mdev;
 110   volatile unsigned short       backoff;
 111   volatile short                err;
 112   unsigned char                 protocol;
 113   volatile unsigned char        state;
 114   volatile unsigned char        ack_backlog;
 115   unsigned char                 max_ack_backlog;
 116   unsigned char                 priority;
 117   unsigned char                 debug;
 118   unsigned short                rcvbuf;
 119   unsigned short                sndbuf;
 120   unsigned short                type;
 121 #ifdef CONFIG_IPX
 122   ipx_address                   ipx_source_addr,ipx_dest_addr;
 123   unsigned short                ipx_type;
 124 #endif
 125 #ifdef CONFIG_AX25
 126 /* Really we want to add a per protocol private area */
 127   ax25_address                  ax25_source_addr,ax25_dest_addr;
 128   struct sk_buff *volatile      ax25_retxq[8];
 129   char                          ax25_state,ax25_vs,ax25_vr,ax25_lastrxnr,ax25_lasttxnr;
 130   char                          ax25_condition;
 131   char                          ax25_retxcnt;
 132   char                          ax25_xx;
 133   char                          ax25_retxqi;
 134   char                          ax25_rrtimer;
 135   char                          ax25_timer;
 136 #endif  
 137 /* IP 'private area' or will be eventually */
 138   int                           ip_ttl;         /* TTL setting */
 139   int                           ip_tos;         /* TOS */
 140   
 141   struct tcphdr                 dummy_th;
 142 
 143   /* This part is used for the timeout functions (timer.c). */
 144   int                           timeout;        /* What are we waiting for? */
 145   struct timer_list             timer;
 146 
 147   /* identd */
 148   struct socket                 *socket;
 149   
 150   /* Event callbacks */
 151   
 152   void                          (*state_change)(struct sock *sk);
 153   void                          (*data_ready)(struct sock *sk,int bytes);
 154   void                          (*write_space)(struct sock *sk);
 155   void                          (*error_report)(struct sock *sk);
 156 };
 157 
 158 
 159 #define TIME_WRITE      1
 160 #define TIME_CLOSE      2
 161 #define TIME_KEEPOPEN   3
 162 #define TIME_DESTROY    4
 163 #define TIME_DONE       5       /* used to absorb those last few packets */
 164 #define SOCK_DESTROY_TIME 1000  /* about 10 seconds                     */
 165 
 166 #define PROT_SOCK       1024    /* Sockets 0-1023 can't be bound too unless you are superuser */
 167 
 168 #define SHUTDOWN_MASK   3
 169 #define RCV_SHUTDOWN    1
 170 #define SEND_SHUTDOWN   2
 171 
 172 extern void                     print_sk(struct sock *);
 173 extern void                     *sock_wmalloc(struct sock *sk,
 174                                               unsigned long size, int force,
 175                                               int priority);
 176 extern void                     *sock_rmalloc(struct sock *sk,
 177                                               unsigned long size, int force,
 178                                               int priority);
 179 extern void                     sock_wfree(struct sock *sk, void *mem,
 180                                            unsigned long size);
 181 extern void                     sock_rfree(struct sock *sk, void *mem,
 182                                            unsigned long size);
 183 extern unsigned long            sock_rspace(struct sock *sk);
 184 extern unsigned long            sock_wspace(struct sock *sk);
 185 
 186 extern int                      sock_setsockopt(struct sock *sk, int level, int optname, char *optval,
 187                                                 int optlen);
 188 extern int                      sock_getsockopt(struct sock *sk, int level, int optname, char *optval,
 189                                                 int *optlen);                                           
 190 
 191 #endif  /* _SOCK_H */

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