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.5 1992/12/12 01:50:49 bir7 Exp $ */
  23 /* $Log: sock.h,v $
  24  * Revision 0.8.4.5  1992/12/12  01:50:49  bir7
  25  * Fixed support for half duplex connections.
  26  *
  27  * Revision 0.8.4.4  1992/12/06  23:29:59  bir7
  28  * Added mss and support for half completed packets.
  29  *
  30  * Revision 0.8.4.3  1992/12/03  19:54:12  bir7
  31  * Added paranoid queue checking.
  32  *
  33  * Revision 0.8.4.2  1992/11/10  10:38:48  bir7
  34  * Change free_s to kfree_s and accidently changed free_skb to kfree_skb.
  35  *
  36  * Revision 0.8.4.1  1992/11/10  00:17:18  bir7
  37  * version change only.
  38  *
  39  * Revision 0.8.3.4  1992/11/10  00:14:47  bir7
  40  * Changed malloc to kmalloc and added Id and Log
  41  *
  42  */
  43 #ifndef _TCP_SOCK_H
  44 #define _TCP_SOCK_H
  45 
  46 #define SOCK_ARRAY_SIZE 64
  47 
  48 /* This structure really needs to be cleaned up.  Most of it is
  49    for tcp, and not used by any of the other protocols. */
  50 
  51 struct sock 
  52 {
  53   struct options *opt;
  54   unsigned long wmem_alloc;
  55   unsigned long rmem_alloc;
  56   unsigned long send_seq;
  57   unsigned long acked_seq;
  58   unsigned long copied_seq;
  59   unsigned long rcv_ack_seq;
  60   unsigned long window_seq;
  61   unsigned long fin_seq;
  62   unsigned long inuse:1, dead:1, urginline:1,
  63                 intr:1, blog:1, done:1, reuse:1, keepopen:1, linger:1,
  64                 delay_acks:1, timeout:3, destroy:1, ack_timed:1, no_check:1,
  65                 exp_growth:1;
  66   int proc;
  67   volatile struct sock *next;
  68   volatile struct sock *pair;
  69   struct sk_buff *send_tail;
  70   struct sk_buff *send_head;
  71   struct sk_buff *back_log;
  72   struct sk_buff *send_tmp;
  73   long retransmits;
  74   struct sk_buff *wback, *wfront, *rqueue;
  75   struct proto *prot;
  76   struct wait_queue **sleep;
  77   unsigned long daddr;
  78   unsigned long saddr;
  79   unsigned short max_unacked;
  80   unsigned short window;
  81   unsigned short bytes_rcv;
  82   unsigned short mtu;
  83   unsigned short num;
  84   unsigned short cong_window;
  85   unsigned short packets_out;
  86   unsigned short urg;
  87   unsigned short shutdown;
  88   unsigned short mss;
  89   short rtt;
  90   short err;
  91   unsigned char protocol;
  92   unsigned char state;
  93   unsigned char ack_backlog;
  94   unsigned char max_ack_backlog;
  95   unsigned char priority;
  96   struct tcp_header dummy_th; /* I may be able to get rid of this. */
  97   struct timer time_wait;
  98 };
  99 
 100 struct proto 
 101 {
 102   void *(*wmalloc)(volatile struct sock *sk, unsigned long size, int force,
 103                    int priority);
 104   void *(*rmalloc)(volatile struct sock *sk, unsigned long size, int force,
 105                    int priority);
 106   void (*wfree)(volatile struct sock *sk, void *mem, unsigned long size);
 107   void (*rfree)(volatile struct sock *sk, void *mem, unsigned long size);
 108   unsigned long (*rspace)(volatile struct sock *sk);
 109   unsigned long (*wspace)(volatile struct sock *sk);
 110   void (*close)(volatile struct sock *sk, int timeout);
 111   int (*read)(volatile struct sock *sk, unsigned char *to, int len,
 112               int nonblock, unsigned flags);
 113   int (*write)(volatile struct sock *sk, unsigned char *to, int len,
 114                int nonblock, unsigned flags);
 115   int (*sendto) (volatile struct sock *sk, unsigned char *from, int len,
 116                  int noblock, unsigned flags, struct sockaddr_in *usin,
 117                  int addr_len);
 118   int (*recvfrom) (volatile struct sock *sk, unsigned char *from, int len,
 119                    int noblock, unsigned flags, struct sockaddr_in *usin,
 120                    int *addr_len);
 121   int (*build_header) (struct sk_buff *skb, unsigned long saddr,
 122                        unsigned long daddr, struct device **dev, int type,
 123                        struct options *opt, int len);
 124   int (*connect) (volatile struct sock *sk, struct sockaddr_in *usin,
 125                   int addr_len);
 126   volatile struct sock *(*accept) (volatile struct sock *sk, int flags);
 127   void  (*queue_xmit) (volatile struct sock *sk, struct device *dev, 
 128                        struct sk_buff *skb, int free);
 129   void (*retransmit) (volatile struct sock *sk, int all);
 130   void (*write_wakeup) (volatile struct sock *sk);
 131   void (*read_wakeup) (volatile struct sock *sk);
 132   int (*rcv)(struct sk_buff *buff, struct device *dev, struct options *opt,
 133              unsigned long daddr, unsigned short len,
 134              unsigned long saddr, int redo, struct ip_protocol *protocol);
 135   int (*select)(volatile struct sock *sk, int which, select_table *wait);
 136   int (*ioctl) (volatile struct sock *sk, int cmd, unsigned long arg);
 137   int (*init) (volatile struct sock *sk);
 138   void (*shutdown) (volatile struct sock *sk, int how);
 139   unsigned short max_header;
 140   unsigned long retransmits;
 141   volatile struct sock *sock_array[SOCK_ARRAY_SIZE];
 142 };
 143 
 144 #define TIME_WRITE 1
 145 #define TIME_CLOSE 2
 146 #define TIME_KEEPOPEN 3
 147 #define TIME_DESTROY 4
 148 #define TIME_DONE 5 /* used to absorb those last few packets. */
 149 #define SOCK_DESTROY_TIME 1000 /* about 10 seconds. */
 150 
 151 /* used with free skb */
 152 #define FREE_READ 1
 153 #define FREE_WRITE 0
 154 
 155 struct sk_buff
 156 {
 157   struct sk_buff *next;
 158   struct sk_buff *prev;
 159   struct sk_buff *link3;
 160   volatile struct sock *sk;
 161   unsigned long when; /* used to compute rtt's. */
 162   struct device *dev;
 163   void *mem_addr;
 164   union
 165     {
 166        struct tcp_header *th;
 167        struct enet_header *eth;
 168        struct ip_header *iph;
 169        struct udp_header *uh;
 170        struct arp *arp;
 171        unsigned char *raw;
 172        unsigned long seq;
 173     } h;
 174   unsigned long mem_len;
 175   unsigned long len;
 176   unsigned long saddr;
 177   unsigned long daddr;
 178   int magic;
 179   unsigned long acked:1,used:1,free:1,arp:1, urg_used:1, lock:1;
 180 };
 181 
 182 #define PROT_SOCK 1024
 183 #define SK_WMEM_MAX 8192
 184 #define SK_RMEM_MAX 32767
 185 #define SHUTDOWN_MASK 3
 186 #define RCV_SHUTDOWN 1
 187 #define SEND_SHUTDOWN 2
 188 
 189 void destroy_sock (volatile struct sock *sk);
 190 unsigned short get_new_socknum (struct proto *, unsigned short);
 191 void put_sock (unsigned short, volatile struct sock *); 
 192 void release_sock (volatile struct sock *sk);
 193 volatile struct sock *get_sock(struct proto *, unsigned short, unsigned long,
 194                                unsigned short, unsigned long);
 195 void print_sk (volatile struct sock *);
 196 void print_skb (struct sk_buff *);
 197 void *sock_wmalloc(volatile struct sock *sk, unsigned long size, int force,
 198                    int priority);
 199 void *sock_rmalloc(volatile struct sock *sk, unsigned long size, int force,
 200                    int priority);
 201 void sock_wfree(volatile struct sock *sk, void *mem, unsigned long size);
 202 void sock_rfree(volatile struct sock *sk, void *mem, unsigned long size);
 203 unsigned long sock_rspace(volatile struct sock *sk);
 204 unsigned long sock_wspace(volatile struct sock *sk);
 205 void kfree_skb (struct sk_buff *skb, int rw);
 206 void lock_skb (struct sk_buff *skb);
 207 void unlock_skb (struct sk_buff *skb, int rw);
 208 
 209 void dummy_routine(void *, ... );
 210 
 211 #endif

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