This source file includes following definitions.
- sock_queue_rcv_skb
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 #ifndef _SOCK_H
31 #define _SOCK_H
32
33 #include <linux/timer.h>
34 #include <linux/ip.h>
35 #include <linux/in.h>
36 #include <linux/tcp.h>
37 #include <linux/config.h>
38
39 #include <linux/skbuff.h>
40 #include <net/protocol.h>
41 #ifdef CONFIG_AX25
42 #include <net/ax25.h>
43 #ifdef CONFIG_NETROM
44 #include <net/netrom.h>
45 #endif
46 #endif
47 #ifdef CONFIG_IPX
48 #include <net/ipx.h>
49 #endif
50 #ifdef CONFIG_ATALK
51 #include <linux/atalk.h>
52 #endif
53
54 #include <linux/igmp.h>
55
56
57 #define SOCK_ARRAY_SIZE 256
58
59
60
61
62
63
64 struct unix_opt
65 {
66 int family;
67 char * name;
68 int locks;
69 struct inode * inode;
70 struct semaphore readsem;
71 struct sock * other;
72 };
73
74
75
76
77
78
79
80 struct sock
81 {
82 struct options *opt;
83 volatile unsigned long wmem_alloc;
84 volatile unsigned long rmem_alloc;
85 unsigned long allocation;
86 __u32 write_seq;
87 __u32 sent_seq;
88 __u32 acked_seq;
89 __u32 copied_seq;
90 __u32 rcv_ack_seq;
91 __u32 window_seq;
92 __u32 fin_seq;
93 __u32 urg_seq;
94 __u32 urg_data;
95
96
97
98
99
100 volatile char inuse,
101 dead,
102 urginline,
103 intr,
104 blog,
105 done,
106 reuse,
107 keepopen,
108 linger,
109 delay_acks,
110 destroy,
111 ack_timed,
112 no_check,
113 zapped,
114 broadcast,
115 nonagle;
116 unsigned long lingertime;
117 int proc;
118 struct sock *next;
119 struct sock *prev;
120 struct sock *pair;
121 struct sk_buff * volatile send_head;
122 struct sk_buff * volatile send_tail;
123 struct sk_buff_head back_log;
124 struct sk_buff *partial;
125 struct timer_list partial_timer;
126 long retransmits;
127 struct sk_buff_head write_queue,
128 receive_queue;
129 struct proto *prot;
130 struct wait_queue **sleep;
131 __u32 daddr;
132 __u32 saddr;
133 __u32 rcv_saddr;
134 unsigned short max_unacked;
135 unsigned short window;
136 unsigned short bytes_rcv;
137
138
139
140 unsigned short mtu;
141 volatile unsigned short mss;
142 volatile unsigned short user_mss;
143 volatile unsigned short max_window;
144 unsigned long window_clamp;
145 unsigned short num;
146 volatile unsigned short cong_window;
147 volatile unsigned short cong_count;
148 volatile unsigned short ssthresh;
149 volatile unsigned short packets_out;
150 volatile unsigned short shutdown;
151 volatile unsigned long rtt;
152 volatile unsigned long mdev;
153 volatile unsigned long rto;
154
155
156
157
158
159
160 volatile unsigned short backoff;
161 volatile short err;
162 unsigned char protocol;
163 volatile unsigned char state;
164 volatile unsigned char ack_backlog;
165 unsigned char max_ack_backlog;
166 unsigned char priority;
167 unsigned char debug;
168 unsigned short rcvbuf;
169 unsigned short sndbuf;
170 unsigned short type;
171 unsigned char localroute;
172 #ifdef CONFIG_IPX
173
174
175
176 ipx_address ipx_dest_addr;
177 ipx_interface *ipx_intrfc;
178 unsigned short ipx_port;
179 unsigned short ipx_type;
180 #endif
181 #ifdef CONFIG_AX25
182 ax25_cb *ax25;
183 #ifdef CONFIG_NETROM
184 nr_cb *nr;
185 #endif
186 #endif
187
188
189
190
191
192
193 union
194 {
195 struct unix_opt af_unix;
196 #ifdef CONFIG_ATALK
197 struct atalk_sock af_at;
198 #endif
199 } protinfo;
200
201
202
203
204 int ip_ttl;
205 int ip_tos;
206 struct tcphdr dummy_th;
207 struct timer_list keepalive_timer;
208 struct timer_list retransmit_timer;
209 struct timer_list ack_timer;
210 int ip_xmit_timeout;
211 struct rtable *ip_route_cache;
212 unsigned long ip_route_stamp;
213 unsigned long ip_route_daddr;
214 unsigned long ip_route_saddr;
215 int ip_route_local;
216 unsigned long ip_hcache_stamp;
217 unsigned long *ip_hcache_ver;
218 char ip_hcache_data[16];
219 int ip_hcache_state;
220 unsigned char ip_option_len;
221 unsigned char ip_option_flen;
222 unsigned char ip_opt_next_strict;
223 unsigned long ip_opt_next_hop;
224 unsigned char *ip_opt_ptr[2];
225 unsigned char ip_hdrincl;
226 #ifdef CONFIG_IP_MULTICAST
227 int ip_mc_ttl;
228 int ip_mc_loop;
229 char ip_mc_name[MAX_ADDR_LEN];
230 struct ip_mc_socklist *ip_mc_list;
231 #endif
232
233
234
235
236
237 int timeout;
238 struct timer_list timer;
239
240
241 struct timeval stamp;
242
243
244
245
246
247 struct socket *socket;
248
249
250
251
252
253 void (*state_change)(struct sock *sk);
254 void (*data_ready)(struct sock *sk,int bytes);
255 void (*write_space)(struct sock *sk);
256 void (*error_report)(struct sock *sk);
257
258 };
259
260
261
262
263
264 struct proto
265 {
266 void (*close)(struct sock *sk, int timeout);
267 int (*read)(struct sock *sk, unsigned char *to,
268 int len, int nonblock, unsigned flags);
269 int (*write)(struct sock *sk, const unsigned char *to,
270 int len, int nonblock, unsigned flags);
271 int (*sendto)(struct sock *sk,
272 const unsigned char *from, int len,
273 int noblock, unsigned flags,
274 struct sockaddr_in *usin, int addr_len);
275 int (*recvfrom)(struct sock *sk,
276 unsigned char *from, int len, int noblock,
277 unsigned flags, struct sockaddr_in *usin,
278 int *addr_len);
279 int (*build_header)(struct sk_buff *skb,
280 __u32 saddr,
281 __u32 daddr,
282 struct device **dev, int type,
283 struct options *opt, int len,
284 int tos, int ttl);
285 int (*connect)(struct sock *sk,
286 struct sockaddr_in *usin, int addr_len);
287 struct sock * (*accept) (struct sock *sk, int flags);
288 void (*queue_xmit)(struct sock *sk,
289 struct device *dev, struct sk_buff *skb,
290 int free);
291 void (*retransmit)(struct sock *sk, int all);
292 void (*write_wakeup)(struct sock *sk);
293 void (*read_wakeup)(struct sock *sk);
294 int (*rcv)(struct sk_buff *buff, struct device *dev,
295 struct options *opt, __u32 daddr,
296 unsigned short len, __u32 saddr,
297 int redo, struct inet_protocol *protocol);
298 int (*select)(struct sock *sk, int which,
299 select_table *wait);
300 int (*ioctl)(struct sock *sk, int cmd,
301 unsigned long arg);
302 int (*init)(struct sock *sk);
303 void (*shutdown)(struct sock *sk, int how);
304 int (*setsockopt)(struct sock *sk, int level, int optname,
305 char *optval, int optlen);
306 int (*getsockopt)(struct sock *sk, int level, int optname,
307 char *optval, int *option);
308 int (*sendmsg)(struct sock *sk, struct msghdr *msg, int len,
309 int noblock, int flags);
310 int (*recvmsg)(struct sock *sk, struct msghdr *msg, int len,
311 int noblock, int flags, int *addr_len);
312 unsigned short max_header;
313 unsigned long retransmits;
314 char name[32];
315 int inuse, highestinuse;
316 struct sock * sock_array[SOCK_ARRAY_SIZE];
317 };
318
319 #define TIME_WRITE 1
320 #define TIME_CLOSE 2
321 #define TIME_KEEPOPEN 3
322 #define TIME_DESTROY 4
323 #define TIME_DONE 5
324 #define TIME_PROBE0 6
325
326
327
328 #define SOCK_DESTROY_TIME (10*HZ)
329
330
331
332
333
334
335 #define PROT_SOCK 1024
336
337
338 #define SHUTDOWN_MASK 3
339 #define RCV_SHUTDOWN 1
340 #define SEND_SHUTDOWN 2
341
342
343 extern void destroy_sock(struct sock *sk);
344 extern unsigned short get_new_socknum(struct proto *,
345 unsigned short);
346 extern void put_sock(unsigned short, struct sock *);
347 extern void release_sock(struct sock *sk);
348 extern struct sock *get_sock(struct proto *, unsigned short,
349 unsigned long, unsigned short,
350 unsigned long);
351 extern struct sock *get_sock_mcast(struct sock *, unsigned short,
352 unsigned long, unsigned short,
353 unsigned long);
354 extern struct sock *get_sock_raw(struct sock *, unsigned short,
355 unsigned long, unsigned long);
356
357 extern struct sk_buff *sock_wmalloc(struct sock *sk,
358 unsigned long size, int force,
359 int priority);
360 extern struct sk_buff *sock_rmalloc(struct sock *sk,
361 unsigned long size, int force,
362 int priority);
363 extern void sock_wfree(struct sock *sk,
364 struct sk_buff *skb);
365 extern void sock_rfree(struct sock *sk,
366 struct sk_buff *skb);
367 extern unsigned long sock_rspace(struct sock *sk);
368 extern unsigned long sock_wspace(struct sock *sk);
369
370 extern int sock_setsockopt(struct sock *sk, int level,
371 int op, char *optval,
372 int optlen);
373
374 extern int sock_getsockopt(struct sock *sk, int level,
375 int op, char *optval,
376 int *optlen);
377 extern struct sk_buff *sock_alloc_send_skb(struct sock *skb,
378 unsigned long size,
379 unsigned long fallback,
380 int noblock,
381 int *errcode);
382
383
384
385
386
387
388
389
390
391
392 extern __inline__ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
393 {
394 unsigned long flags;
395 if(sk->rmem_alloc + skb->truesize >= sk->rcvbuf)
396 return -ENOMEM;
397 save_flags(flags);
398 cli();
399 sk->rmem_alloc+=skb->truesize;
400 skb->sk=sk;
401 restore_flags(flags);
402 skb_queue_tail(&sk->receive_queue,skb);
403 if(!sk->dead)
404 sk->data_ready(sk,skb->len);
405 return 0;
406 }
407
408
409
410
411
412 extern struct sock *timer_base;
413
414 extern void delete_timer (struct sock *);
415 extern void reset_timer (struct sock *, int, unsigned long);
416 extern void net_timer (unsigned long);
417
418
419
420
421
422
423 #define NETDEBUG(x) x
424
425 #endif