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