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