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