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