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