1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39 #ifndef _TCP_SOCK_H
40 #define _TCP_SOCK_H
41
42 #define SOCK_ARRAY_SIZE 64
43
44
45
46
47 struct sock
48 {
49 struct options *opt;
50 unsigned long wmem_alloc;
51 unsigned long rmem_alloc;
52 unsigned long send_seq;
53 unsigned long acked_seq;
54 unsigned long copied_seq;
55 unsigned long rcv_ack_seq;
56 unsigned long window_seq;
57 unsigned long fin_seq;
58 unsigned long inuse:1, dead:1, urginline:1,
59 intr:1, blog:1, done:1, reuse:1, keepopen:1, linger:1,
60 delay_acks:1, timeout:3, destroy:1, ack_timed:1, no_check:1,
61 exp_growth:1;
62 int proc;
63 volatile struct sock *next;
64 volatile struct sock *pair;
65 struct sk_buff *send_tail;
66 struct sk_buff *send_head;
67 struct sk_buff *back_log;
68 long retransmits;
69 struct sk_buff *wback, *wfront, *rqueue;
70 struct proto *prot;
71 struct wait_queue **sleep;
72 unsigned long daddr;
73 unsigned long saddr;
74 unsigned short max_unacked;
75 unsigned short window;
76 unsigned short bytes_rcv;
77 unsigned short mtu;
78 unsigned short num;
79 unsigned short cong_window;
80 unsigned short packets_out;
81 unsigned short urg;
82 unsigned short shutdown;
83 short rtt;
84 short err;
85 unsigned char protocol;
86 unsigned char state;
87 unsigned char ack_backlog;
88 unsigned char max_ack_backlog;
89 unsigned char priority;
90 struct tcp_header dummy_th;
91 struct timer time_wait;
92 };
93
94 struct proto
95 {
96 void *(*wmalloc)(volatile struct sock *sk, unsigned long size, int force,
97 int priority);
98 void *(*rmalloc)(volatile struct sock *sk, unsigned long size, int force,
99 int priority);
100 void (*wfree)(volatile struct sock *sk, void *mem, unsigned long size);
101 void (*rfree)(volatile struct sock *sk, void *mem, unsigned long size);
102 unsigned long (*rspace)(volatile struct sock *sk);
103 unsigned long (*wspace)(volatile struct sock *sk);
104 void (*close)(volatile struct sock *sk, int timeout);
105 int (*read)(volatile struct sock *sk, unsigned char *to, int len,
106 int nonblock, unsigned flags);
107 int (*write)(volatile struct sock *sk, unsigned char *to, int len,
108 int nonblock, unsigned flags);
109 int (*sendto) (volatile struct sock *sk, unsigned char *from, int len,
110 int noblock, unsigned flags, struct sockaddr_in *usin,
111 int addr_len);
112 int (*recvfrom) (volatile struct sock *sk, unsigned char *from, int len,
113 int noblock, unsigned flags, struct sockaddr_in *usin,
114 int *addr_len);
115 int (*build_header) (struct sk_buff *skb, unsigned long saddr,
116 unsigned long daddr, struct device **dev, int type,
117 struct options *opt, int len);
118 int (*connect) (volatile struct sock *sk, struct sockaddr_in *usin,
119 int addr_len);
120 volatile struct sock *(*accept) (volatile struct sock *sk, int flags);
121 void (*queue_xmit) (volatile struct sock *sk, struct device *dev,
122 struct sk_buff *skb, int free);
123 void (*retransmit) (volatile struct sock *sk, int all);
124 void (*write_wakeup) (volatile struct sock *sk);
125 void (*read_wakeup) (volatile struct sock *sk);
126 int (*rcv)(struct sk_buff *buff, struct device *dev, struct options *opt,
127 unsigned long daddr, unsigned short len,
128 unsigned long saddr, int redo, struct ip_protocol *protocol);
129 int (*select)(volatile struct sock *sk, int which, select_table *wait);
130 int (*ioctl) (volatile struct sock *sk, int cmd, unsigned long arg);
131 int (*init) (volatile struct sock *sk);
132 unsigned short max_header;
133 unsigned long retransmits;
134 volatile struct sock *sock_array[SOCK_ARRAY_SIZE];
135 };
136
137 #define TIME_WRITE 1
138 #define TIME_CLOSE 2
139 #define TIME_KEEPOPEN 3
140 #define TIME_DESTROY 4
141 #define TIME_DONE 5
142 #define SOCK_DESTROY_TIME 1000
143
144
145 #define FREE_READ 1
146 #define FREE_WRITE 0
147
148 struct sk_buff
149 {
150 struct sk_buff *next;
151 struct sk_buff *prev;
152 struct sk_buff *link3;
153 volatile struct sock *sk;
154 unsigned long when;
155 struct device *dev;
156 void *mem_addr;
157 union
158 {
159 struct tcp_header *th;
160 struct enet_header *eth;
161 struct ip_header *iph;
162 struct udp_header *uh;
163 struct arp *arp;
164 unsigned char *raw;
165 unsigned long seq;
166 } h;
167 unsigned long mem_len;
168 unsigned long len;
169 unsigned long saddr;
170 unsigned long daddr;
171 unsigned long acked:1,used:1,free:1,arp:1, urg_used:1, lock:1;
172 };
173
174 #define PROT_SOCK 1024
175 #define SK_WMEM_MAX 8192
176 #define SK_RMEM_MAX 32767
177 #define SHUTDOWN_MASK 3
178 #define RCV_SHUTDOWN 1
179 #define SEND_SHUTDOWN 2
180
181 void destroy_sock (volatile struct sock *sk);
182 unsigned short get_new_socknum (struct proto *, unsigned short);
183 void put_sock (unsigned short, volatile struct sock *);
184 void release_sock (volatile struct sock *sk);
185 volatile struct sock *get_sock(struct proto *, unsigned short, unsigned long,
186 unsigned short, unsigned long);
187 void print_sk (volatile struct sock *);
188 void print_skb (struct sk_buff *);
189 void *sock_wmalloc(volatile struct sock *sk, unsigned long size, int force,
190 int priority);
191 void *sock_rmalloc(volatile struct sock *sk, unsigned long size, int force,
192 int priority);
193 void sock_wfree(volatile struct sock *sk, void *mem, unsigned long size);
194 void sock_rfree(volatile struct sock *sk, void *mem, unsigned long size);
195 unsigned long sock_rspace(volatile struct sock *sk);
196 unsigned long sock_wspace(volatile struct sock *sk);
197 void kfree_skb (struct sk_buff *skb, int rw);
198 void lock_skb (struct sk_buff *skb);
199 void unlock_skb (struct sk_buff *skb, int rw);
200
201 void dummy_routine(void *, ... );
202
203 #endif