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
40
41
42
43
44
45
46
47
48
49 #ifndef _TCP_SOCK_H
50 #define _TCP_SOCK_H
51
52 #define SOCK_ARRAY_SIZE 64
53
54
55
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
69
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;
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
158 #define SOCK_DESTROY_TIME 1000
159
160
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;
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