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