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