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