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