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 #ifndef _TCP_SOCK_H
44 #define _TCP_SOCK_H
45
46 #define SOCK_ARRAY_SIZE 64
47
48
49
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;
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
149 #define SOCK_DESTROY_TIME 1000
150
151
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;
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