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