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