root/net/tcp/sock.h

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

INCLUDED FROM


   1 /* sock.h */
   2 /*
   3     Copyright (C) 1992  Ross Biro
   4 
   5     This program is free software; you can redistribute it and/or modify
   6     it under the terms of the GNU General Public License as published by
   7     the Free Software Foundation; either version 2, or (at your option)
   8     any later version.
   9 
  10     This program is distributed in the hope that it will be useful,
  11     but WITHOUT ANY WARRANTY; without even the implied warranty of
  12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13     GNU General Public License for more details.
  14 
  15     You should have received a copy of the GNU General Public License
  16     along with this program; if not, write to the Free Software
  17     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 
  18 
  19     The Author may be reached as bir7@leland.stanford.edu or
  20     C/O Department of Mathematics; Stanford University; Stanford, CA 94305
  21 */
  22 /* $Id: sock.h,v 0.8.4.7 1993/01/26 22:04:00 bir7 Exp $ */
  23 /* $Log: sock.h,v $
  24  * Revision 0.8.4.7  1993/01/26  22:04:00  bir7
  25  * Added support for proc fs.
  26  *
  27  * Revision 0.8.4.6  1993/01/23  18:00:11  bir7
  28  * Added volatile keyword
  29  *
  30  * Revision 0.8.4.5  1992/12/12  01:50:49  bir7
  31  * Fixed support for half duplex connections.
  32  *
  33  * Revision 0.8.4.4  1992/12/06  23:29:59  bir7
  34  * Added mss and support for half completed packets.
  35  *
  36  * Revision 0.8.4.3  1992/12/03  19:54:12  bir7
  37  * Added paranoid queue checking.
  38  *
  39  * Revision 0.8.4.2  1992/11/10  10:38:48  bir7
  40  * Change free_s to kfree_s and accidently changed free_skb to kfree_skb.
  41  *
  42  * Revision 0.8.4.1  1992/11/10  00:17:18  bir7
  43  * version change only.
  44  *
  45  * Revision 0.8.3.4  1992/11/10  00:14:47  bir7
  46  * Changed malloc to kmalloc and added Id and Log
  47  *
  48  */
  49 #ifndef _TCP_SOCK_H
  50 #define _TCP_SOCK_H
  51 
  52 #define SOCK_ARRAY_SIZE 64
  53 
  54 /* This structure really needs to be cleaned up.  Most of it is
  55    for tcp, and not used by any of the other protocols. */
  56 
  57 struct sock 
  58 {
  59   struct options *opt;
  60   volatile unsigned long wmem_alloc;
  61   volatile unsigned long rmem_alloc;
  62   unsigned long send_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   /* not all are volatile, but some are, so we might as
  69      well say they all are. */
  70   volatile unsigned long  inuse:1, dead:1, urginline:1,
  71                 intr:1, blog:1, done:1, reuse:1, keepopen:1, linger:1,
  72                 delay_acks:1, timeout:3, destroy:1, ack_timed:1, no_check:1,
  73                 exp_growth:1;
  74   int proc;
  75   volatile struct sock *next;
  76   volatile struct sock *pair;
  77   struct sk_buff *send_tail;
  78   struct sk_buff *send_head;
  79   volatile struct sk_buff * volatile back_log;
  80   struct sk_buff *send_tmp;
  81   long retransmits;
  82   struct sk_buff *wback, *wfront, *rqueue;
  83   struct proto *prot;
  84   struct wait_queue **sleep;
  85   unsigned long daddr;
  86   unsigned long saddr;
  87   unsigned short max_unacked;
  88   unsigned short window;
  89   unsigned short bytes_rcv;
  90   unsigned short mtu;
  91   unsigned short num;
  92   volatile unsigned short cong_window;
  93   volatile unsigned short packets_out;
  94   volatile unsigned short urg;
  95   volatile unsigned short shutdown;
  96   unsigned short mss;
  97   volatile short rtt;
  98   volatile short err;
  99   unsigned char protocol;
 100   volatile unsigned char state;
 101   volatile unsigned char ack_backlog;
 102   unsigned char max_ack_backlog;
 103   unsigned char priority;
 104   struct tcp_header dummy_th; /* I may be able to get rid of this. */
 105   volatile struct timer time_wait;
 106 };
 107 
 108 struct proto 
 109 {
 110   void *(*wmalloc)(volatile struct sock *sk, unsigned long size, int force,
 111                    int priority);
 112   void *(*rmalloc)(volatile struct sock *sk, unsigned long size, int force,
 113                    int priority);
 114   void (*wfree)(volatile struct sock *sk, void *mem, unsigned long size);
 115   void (*rfree)(volatile struct sock *sk, void *mem, unsigned long size);
 116   unsigned long (*rspace)(volatile struct sock *sk);
 117   unsigned long (*wspace)(volatile struct sock *sk);
 118   void (*close)(volatile struct sock *sk, int timeout);
 119   int (*read)(volatile struct sock *sk, unsigned char *to, int len,
 120               int nonblock, unsigned flags);
 121   int (*write)(volatile struct sock *sk, unsigned char *to, int len,
 122                int nonblock, unsigned flags);
 123   int (*sendto) (volatile struct sock *sk, unsigned char *from, int len,
 124                  int noblock, unsigned flags, struct sockaddr_in *usin,
 125                  int addr_len);
 126   int (*recvfrom) (volatile struct sock *sk, unsigned char *from, int len,
 127                    int noblock, unsigned flags, struct sockaddr_in *usin,
 128                    int *addr_len);
 129   int (*build_header) (struct sk_buff *skb, unsigned long saddr,
 130                        unsigned long daddr, struct device **dev, int type,
 131                        struct options *opt, int len);
 132   int (*connect) (volatile struct sock *sk, struct sockaddr_in *usin,
 133                   int addr_len);
 134   volatile struct sock *(*accept) (volatile struct sock *sk, int flags);
 135   void  (*queue_xmit) (volatile struct sock *sk, struct device *dev, 
 136                        struct sk_buff *skb, int free);
 137   void (*retransmit) (volatile struct sock *sk, int all);
 138   void (*write_wakeup) (volatile struct sock *sk);
 139   void (*read_wakeup) (volatile struct sock *sk);
 140   int (*rcv)(struct sk_buff *buff, struct device *dev, struct options *opt,
 141              unsigned long daddr, unsigned short len,
 142              unsigned long saddr, int redo, struct ip_protocol *protocol);
 143   int (*select)(volatile struct sock *sk, int which, select_table *wait);
 144   int (*ioctl) (volatile struct sock *sk, int cmd, unsigned long arg);
 145   int (*init) (volatile struct sock *sk);
 146   void (*shutdown) (volatile struct sock *sk, int how);
 147   unsigned short max_header;
 148   unsigned long retransmits;
 149   volatile struct sock *sock_array[SOCK_ARRAY_SIZE];
 150   char name[80];
 151 };
 152 
 153 #define TIME_WRITE 1
 154 #define TIME_CLOSE 2
 155 #define TIME_KEEPOPEN 3
 156 #define TIME_DESTROY 4
 157 #define TIME_DONE 5 /* used to absorb those last few packets. */
 158 #define SOCK_DESTROY_TIME 1000 /* about 10 seconds. */
 159 
 160 /* used with free skb */
 161 #define FREE_READ 1
 162 #define FREE_WRITE 0
 163 
 164 struct sk_buff
 165 {
 166   volatile struct sk_buff *next;
 167   volatile struct sk_buff *prev;
 168   volatile struct sk_buff *link3;
 169   volatile struct sock *sk;
 170   volatile unsigned long when; /* used to compute rtt's. */
 171   struct device *dev;
 172   void *mem_addr;
 173   union
 174     {
 175        struct tcp_header *th;
 176        struct enet_header *eth;
 177        struct ip_header *iph;
 178        struct udp_header *uh;
 179        struct arp *arp;
 180        unsigned char *raw;
 181        unsigned long seq;
 182     } h;
 183   unsigned long mem_len;
 184   unsigned long len;
 185   unsigned long saddr;
 186   unsigned long daddr;
 187   int magic;
 188   volatile unsigned long acked:1,used:1,free:1,arp:1, urg_used:1, lock:1;
 189 };
 190 
 191 #define PROT_SOCK 1024
 192 #define SK_WMEM_MAX 8192
 193 #define SK_RMEM_MAX 32767
 194 #define SHUTDOWN_MASK 3
 195 #define RCV_SHUTDOWN 1
 196 #define SEND_SHUTDOWN 2
 197 
 198 void destroy_sock (volatile struct sock *sk);
 199 unsigned short get_new_socknum (struct proto *, unsigned short);
 200 void put_sock (unsigned short, volatile struct sock *); 
 201 void release_sock (volatile struct sock *sk);
 202 volatile struct sock *get_sock(struct proto *, unsigned short, unsigned long,
 203                                unsigned short, unsigned long);
 204 void print_sk (volatile struct sock *);
 205 void print_skb (struct sk_buff *);
 206 void *sock_wmalloc(volatile struct sock *sk, unsigned long size, int force,
 207                    int priority);
 208 void *sock_rmalloc(volatile struct sock *sk, unsigned long size, int force,
 209                    int priority);
 210 void sock_wfree(volatile struct sock *sk, void *mem, unsigned long size);
 211 void sock_rfree(volatile struct sock *sk, void *mem, unsigned long size);
 212 unsigned long sock_rspace(volatile struct sock *sk);
 213 unsigned long sock_wspace(volatile struct sock *sk);
 214 void kfree_skb (struct sk_buff *skb, int rw);
 215 void lock_skb (struct sk_buff *skb);
 216 void unlock_skb (struct sk_buff *skb, int rw);
 217 
 218 void dummy_routine(void *, ... );
 219 
 220 #endif

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