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