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