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/tcp.h>
36 #include <linux/config.h>
37
38 #include <linux/skbuff.h>
39 #include "protocol.h"
40 #ifdef CONFIG_AX25
41 #include "ax25.h"
42 #endif
43 #ifdef CONFIG_IPX
44 #include "ipx.h"
45 #endif
46 #ifdef CONFIG_ATALK
47 #include <linux/atalk.h>
48 #endif
49
50 #include <linux/igmp.h>
51
52 #define SOCK_ARRAY_SIZE 256
53
54
55
56
57
58
59
60 struct sock {
61 struct options *opt;
62 volatile unsigned long wmem_alloc;
63 volatile unsigned long rmem_alloc;
64 unsigned long write_seq;
65 unsigned long sent_seq;
66 unsigned long acked_seq;
67 unsigned long copied_seq;
68 unsigned long rcv_ack_seq;
69 unsigned long window_seq;
70 unsigned long fin_seq;
71 unsigned long urg_seq;
72 unsigned long urg_data;
73
74
75
76
77
78 volatile char inuse,
79 dead,
80 urginline,
81 intr,
82 blog,
83 done,
84 reuse,
85 keepopen,
86 linger,
87 delay_acks,
88 destroy,
89 ack_timed,
90 no_check,
91 zapped,
92 broadcast,
93 nonagle;
94 unsigned long lingertime;
95 int proc;
96 struct sock *next;
97 struct sock *prev;
98 struct sock *pair;
99 struct sk_buff * volatile send_head;
100 struct sk_buff * volatile send_tail;
101 struct sk_buff_head back_log;
102 struct sk_buff *partial;
103 struct timer_list partial_timer;
104 long retransmits;
105 struct sk_buff_head write_queue,
106 receive_queue;
107 struct proto *prot;
108 struct wait_queue **sleep;
109 unsigned long daddr;
110 unsigned long saddr;
111 unsigned short max_unacked;
112 unsigned short window;
113 unsigned short bytes_rcv;
114
115 unsigned short mtu;
116 volatile unsigned short mss;
117 volatile unsigned short user_mss;
118 volatile unsigned short max_window;
119 unsigned long window_clamp;
120 unsigned short num;
121 volatile unsigned short cong_window;
122 volatile unsigned short cong_count;
123 volatile unsigned short ssthresh;
124 volatile unsigned short packets_out;
125 volatile unsigned short shutdown;
126 volatile unsigned long rtt;
127 volatile unsigned long mdev;
128 volatile unsigned long rto;
129
130
131
132 volatile unsigned short backoff;
133 volatile short err;
134 unsigned char protocol;
135 volatile unsigned char state;
136 volatile unsigned char ack_backlog;
137 unsigned char max_ack_backlog;
138 unsigned char priority;
139 unsigned char debug;
140 unsigned short rcvbuf;
141 unsigned short sndbuf;
142 unsigned short type;
143 unsigned char localroute;
144 #ifdef CONFIG_IPX
145 ipx_address ipx_dest_addr;
146 ipx_interface *ipx_intrfc;
147 unsigned short ipx_port;
148 unsigned short ipx_type;
149 #endif
150 #ifdef CONFIG_AX25
151
152 ax25_address ax25_source_addr,ax25_dest_addr;
153 struct sk_buff *volatile ax25_retxq[8];
154 char ax25_state,ax25_vs,ax25_vr,ax25_lastrxnr,ax25_lasttxnr;
155 char ax25_condition;
156 char ax25_retxcnt;
157 char ax25_xx;
158 char ax25_retxqi;
159 char ax25_rrtimer;
160 char ax25_timer;
161 unsigned char ax25_n2;
162 unsigned short ax25_t1,ax25_t2,ax25_t3;
163 ax25_digi *ax25_digipeat;
164 #endif
165 #ifdef CONFIG_ATALK
166 struct atalk_sock at;
167 #endif
168
169
170 int ip_ttl;
171 int ip_tos;
172 struct tcphdr dummy_th;
173 struct timer_list keepalive_timer;
174 struct timer_list retransmit_timer;
175 struct timer_list ack_timer;
176 int ip_xmit_timeout;
177 #ifdef CONFIG_IP_MULTICAST
178 int ip_mc_ttl;
179 int ip_mc_loop;
180 char ip_mc_name[MAX_ADDR_LEN];
181 struct ip_mc_socklist *ip_mc_list;
182 #endif
183
184
185 int timeout;
186 struct timer_list timer;
187 struct timeval stamp;
188
189
190 struct socket *socket;
191
192
193 void (*state_change)(struct sock *sk);
194 void (*data_ready)(struct sock *sk,int bytes);
195 void (*write_space)(struct sock *sk);
196 void (*error_report)(struct sock *sk);
197
198 };
199
200 struct proto {
201 struct sk_buff * (*wmalloc)(struct sock *sk,
202 unsigned long size, int force,
203 int priority);
204 struct sk_buff * (*rmalloc)(struct sock *sk,
205 unsigned long size, int force,
206 int priority);
207 void (*wfree)(struct sock *sk, struct sk_buff *skb,
208 unsigned long size);
209 void (*rfree)(struct sock *sk, struct sk_buff *skb,
210 unsigned long size);
211 unsigned long (*rspace)(struct sock *sk);
212 unsigned long (*wspace)(struct sock *sk);
213 void (*close)(struct sock *sk, int timeout);
214 int (*read)(struct sock *sk, unsigned char *to,
215 int len, int nonblock, unsigned flags);
216 int (*write)(struct sock *sk, unsigned char *to,
217 int len, int nonblock, unsigned flags);
218 int (*sendto)(struct sock *sk,
219 unsigned char *from, int len, int noblock,
220 unsigned flags, struct sockaddr_in *usin,
221 int addr_len);
222 int (*recvfrom)(struct sock *sk,
223 unsigned char *from, int len, int noblock,
224 unsigned flags, struct sockaddr_in *usin,
225 int *addr_len);
226 int (*build_header)(struct sk_buff *skb,
227 unsigned long saddr,
228 unsigned long daddr,
229 struct device **dev, int type,
230 struct options *opt, int len, int tos, int ttl);
231 int (*connect)(struct sock *sk,
232 struct sockaddr_in *usin, int addr_len);
233 struct sock * (*accept) (struct sock *sk, int flags);
234 void (*queue_xmit)(struct sock *sk,
235 struct device *dev, struct sk_buff *skb,
236 int free);
237 void (*retransmit)(struct sock *sk, int all);
238 void (*write_wakeup)(struct sock *sk);
239 void (*read_wakeup)(struct sock *sk);
240 int (*rcv)(struct sk_buff *buff, struct device *dev,
241 struct options *opt, unsigned long daddr,
242 unsigned short len, unsigned long saddr,
243 int redo, struct inet_protocol *protocol);
244 int (*select)(struct sock *sk, int which,
245 select_table *wait);
246 int (*ioctl)(struct sock *sk, int cmd,
247 unsigned long arg);
248 int (*init)(struct sock *sk);
249 void (*shutdown)(struct sock *sk, int how);
250 int (*setsockopt)(struct sock *sk, int level, int optname,
251 char *optval, int optlen);
252 int (*getsockopt)(struct sock *sk, int level, int optname,
253 char *optval, int *option);
254 unsigned short max_header;
255 unsigned long retransmits;
256 struct sock * sock_array[SOCK_ARRAY_SIZE];
257 char name[80];
258 int inuse, highestinuse;
259 };
260
261 #define TIME_WRITE 1
262 #define TIME_CLOSE 2
263 #define TIME_KEEPOPEN 3
264 #define TIME_DESTROY 4
265 #define TIME_DONE 5
266 #define TIME_PROBE0 6
267 #define SOCK_DESTROY_TIME 1000
268
269 #define PROT_SOCK 1024
270
271 #define SHUTDOWN_MASK 3
272 #define RCV_SHUTDOWN 1
273 #define SEND_SHUTDOWN 2
274
275
276 extern void destroy_sock(struct sock *sk);
277 extern unsigned short get_new_socknum(struct proto *, unsigned short);
278 extern void put_sock(unsigned short, struct sock *);
279 extern void release_sock(struct sock *sk);
280 extern struct sock *get_sock(struct proto *, unsigned short,
281 unsigned long, unsigned short,
282 unsigned long);
283 extern struct sock *get_sock_mcast(struct sock *, unsigned short,
284 unsigned long, unsigned short,
285 unsigned long);
286 extern struct sock *get_sock_raw(struct sock *, unsigned short,
287 unsigned long, unsigned long);
288
289 extern struct sk_buff *sock_wmalloc(struct sock *sk,
290 unsigned long size, int force,
291 int priority);
292 extern struct sk_buff *sock_rmalloc(struct sock *sk,
293 unsigned long size, int force,
294 int priority);
295 extern void sock_wfree(struct sock *sk, struct sk_buff *skb,
296 unsigned long size);
297 extern void sock_rfree(struct sock *sk, struct sk_buff *skb,
298 unsigned long size);
299 extern unsigned long sock_rspace(struct sock *sk);
300 extern unsigned long sock_wspace(struct sock *sk);
301
302 extern int sock_setsockopt(struct sock *sk,int level,int op,char *optval,int optlen);
303
304 extern int sock_getsockopt(struct sock *sk,int level,int op,char *optval,int *optlen);
305 extern struct sk_buff *sock_alloc_send_skb(struct sock *skb, unsigned long size, int noblock, int *errcode);
306 extern int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb);
307
308
309 extern struct sock *timer_base;
310
311 void delete_timer (struct sock *);
312 void reset_timer (struct sock *, int, unsigned long);
313 void net_timer (unsigned long);
314
315
316 #endif