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 unsigned short bytes_rcv;
153
154
155
156 unsigned short mtu;
157 volatile unsigned short mss;
158 volatile unsigned short user_mss;
159 volatile unsigned short max_window;
160 unsigned long window_clamp;
161 unsigned short num;
162 volatile unsigned short cong_window;
163 volatile unsigned short cong_count;
164 volatile unsigned short ssthresh;
165 volatile unsigned short packets_out;
166 volatile unsigned short shutdown;
167 volatile unsigned long rtt;
168 volatile unsigned long mdev;
169 volatile unsigned long rto;
170
171
172
173
174
175
176 volatile unsigned short backoff;
177 volatile int err, err_soft;
178
179
180
181 unsigned char protocol;
182 volatile unsigned char state;
183 volatile unsigned char ack_backlog;
184 unsigned char max_ack_backlog;
185 unsigned char priority;
186 unsigned char debug;
187 unsigned short rcvbuf;
188 unsigned short sndbuf;
189 unsigned short type;
190 unsigned char localroute;
191 #ifdef CONFIG_IPX
192
193
194
195 ipx_address ipx_dest_addr;
196 ipx_interface *ipx_intrfc;
197 unsigned short ipx_port;
198 unsigned short ipx_type;
199 #endif
200 #ifdef CONFIG_AX25
201 ax25_cb *ax25;
202 #ifdef CONFIG_NETROM
203 nr_cb *nr;
204 #endif
205 #endif
206
207
208
209
210
211
212 union
213 {
214 struct unix_opt af_unix;
215 #ifdef CONFIG_ATALK
216 struct atalk_sock af_at;
217 #endif
218 #ifdef CONFIG_INET
219 struct inet_packet_opt af_packet;
220 #endif
221 } protinfo;
222
223
224
225
226 int ip_ttl;
227 int ip_tos;
228 struct tcphdr dummy_th;
229 struct timer_list keepalive_timer;
230 struct timer_list retransmit_timer;
231 struct timer_list ack_timer;
232 int ip_xmit_timeout;
233 struct rtable *ip_route_cache;
234 unsigned char ip_hdrincl;
235 #ifdef CONFIG_IP_MULTICAST
236 int ip_mc_ttl;
237 int ip_mc_loop;
238 char ip_mc_name[MAX_ADDR_LEN];
239 struct ip_mc_socklist *ip_mc_list;
240 #endif
241
242
243
244
245
246 int timeout;
247 struct timer_list timer;
248
249
250 struct timeval stamp;
251
252
253
254
255
256 struct socket *socket;
257
258
259
260
261
262 void (*state_change)(struct sock *sk);
263 void (*data_ready)(struct sock *sk,int bytes);
264 void (*write_space)(struct sock *sk);
265 void (*error_report)(struct sock *sk);
266
267 };
268
269
270
271
272
273 struct proto
274 {
275 void (*close)(struct sock *sk, int timeout);
276 int (*build_header)(struct sk_buff *skb,
277 __u32 saddr,
278 __u32 daddr,
279 struct device **dev, int type,
280 struct options *opt, int len,
281 int tos, int ttl, struct rtable ** rp);
282 int (*connect)(struct sock *sk,
283 struct sockaddr_in *usin, int addr_len);
284 struct sock * (*accept) (struct sock *sk, int flags);
285 void (*queue_xmit)(struct sock *sk,
286 struct device *dev, struct sk_buff *skb,
287 int free);
288 void (*retransmit)(struct sock *sk, int all);
289 void (*write_wakeup)(struct sock *sk);
290 void (*read_wakeup)(struct sock *sk);
291 int (*rcv)(struct sk_buff *buff, struct device *dev,
292 struct options *opt, __u32 daddr,
293 unsigned short len, __u32 saddr,
294 int redo, struct inet_protocol *protocol);
295 int (*select)(struct sock *sk, int which,
296 select_table *wait);
297 int (*ioctl)(struct sock *sk, int cmd,
298 unsigned long arg);
299 int (*init)(struct sock *sk);
300 void (*shutdown)(struct sock *sk, int how);
301 int (*setsockopt)(struct sock *sk, int level, int optname,
302 char *optval, int optlen);
303 int (*getsockopt)(struct sock *sk, int level, int optname,
304 char *optval, int *option);
305 int (*sendmsg)(struct sock *sk, struct msghdr *msg, int len,
306 int noblock, int flags);
307 int (*recvmsg)(struct sock *sk, struct msghdr *msg, int len,
308 int noblock, int flags, int *addr_len);
309 int (*bind)(struct sock *sk, struct sockaddr *uaddr, int addr_len);
310 unsigned short max_header;
311 unsigned long retransmits;
312 char name[32];
313 int inuse, highestinuse;
314 struct sock * sock_array[SOCK_ARRAY_SIZE];
315 };
316
317 #define TIME_WRITE 1
318 #define TIME_CLOSE 2
319 #define TIME_KEEPOPEN 3
320 #define TIME_DESTROY 4
321 #define TIME_DONE 5
322 #define TIME_PROBE0 6
323
324
325
326 #define SOCK_DESTROY_TIME (10*HZ)
327
328
329
330
331
332
333 #define PROT_SOCK 1024
334
335
336 #define SHUTDOWN_MASK 3
337 #define RCV_SHUTDOWN 1
338 #define SEND_SHUTDOWN 2
339
340
341 extern void destroy_sock(struct sock *sk);
342 extern unsigned short get_new_socknum(struct proto *,
343 unsigned short);
344 extern void put_sock(unsigned short, struct sock *);
345 extern void release_sock(struct sock *sk);
346 extern struct sock *get_sock(struct proto *, unsigned short,
347 unsigned long, unsigned short,
348 unsigned long);
349 extern struct sock *get_sock_mcast(struct sock *, unsigned short,
350 unsigned long, unsigned short,
351 unsigned long);
352 extern struct sock *get_sock_raw(struct sock *, unsigned short,
353 unsigned long, unsigned long);
354
355 extern struct sk_buff *sock_wmalloc(struct sock *sk,
356 unsigned long size, int force,
357 int priority);
358 extern struct sk_buff *sock_rmalloc(struct sock *sk,
359 unsigned long size, int force,
360 int priority);
361 extern void sock_wfree(struct sock *sk,
362 struct sk_buff *skb);
363 extern void sock_rfree(struct sock *sk,
364 struct sk_buff *skb);
365 extern unsigned long sock_rspace(struct sock *sk);
366 extern unsigned long sock_wspace(struct sock *sk);
367
368 extern int sock_setsockopt(struct sock *sk, int level,
369 int op, char *optval,
370 int optlen);
371
372 extern int sock_getsockopt(struct sock *sk, int level,
373 int op, char *optval,
374 int *optlen);
375 extern struct sk_buff *sock_alloc_send_skb(struct sock *skb,
376 unsigned long size,
377 unsigned long fallback,
378 int noblock,
379 int *errcode);
380
381
382
383
384
385
386
387
388
389
390 extern __inline__ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
391 {
392 unsigned long flags;
393 if(sk->rmem_alloc + skb->truesize >= sk->rcvbuf)
394 return -ENOMEM;
395 save_flags(flags);
396 cli();
397 sk->rmem_alloc+=skb->truesize;
398 skb->sk=sk;
399 restore_flags(flags);
400 skb_queue_tail(&sk->receive_queue,skb);
401 if(!sk->dead)
402 sk->data_ready(sk,skb->len);
403 return 0;
404 }
405
406
407
408
409
410 extern __inline__ int sock_error(struct sock *sk)
411 {
412 int err=xchg(&sk->err,0);
413 return -err;
414 }
415
416
417
418
419
420 extern struct sock *timer_base;
421
422 extern void delete_timer (struct sock *);
423 extern void reset_timer (struct sock *, int, unsigned long);
424 extern void net_timer (unsigned long);
425
426
427
428
429
430
431 #define NETDEBUG(x) x
432
433 #endif