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