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
40 #define SOCK_ARRAY_SIZE 64
41
42
43
44
45
46
47
48 struct sock {
49 struct options *opt;
50 volatile unsigned long wmem_alloc;
51 volatile unsigned long rmem_alloc;
52 unsigned long send_seq;
53 unsigned long acked_seq;
54 unsigned long copied_seq;
55 unsigned long rcv_ack_seq;
56 unsigned long window_seq;
57 unsigned long fin_seq;
58
59
60
61
62
63 volatile char inuse,
64 dead,
65 urginline,
66 intr,
67 blog,
68 done,
69 reuse,
70 keepopen,
71 linger,
72 delay_acks,
73 destroy,
74 ack_timed,
75 no_check,
76 exp_growth,
77 zapped,
78 broadcast;
79 unsigned long lingertime;
80 int proc;
81 struct sock *next;
82 struct sock *pair;
83 struct sk_buff *volatile send_tail;
84 struct sk_buff *volatile send_head;
85 struct sk_buff *volatile back_log;
86 struct sk_buff *send_tmp;
87 long retransmits;
88 struct sk_buff *volatile wback,
89 *volatile wfront,
90 *volatile rqueue;
91 struct proto *prot;
92 struct wait_queue **sleep;
93 unsigned long daddr;
94 unsigned long saddr;
95 unsigned short max_unacked;
96 unsigned short window;
97 unsigned short bytes_rcv;
98 unsigned short mtu;
99 unsigned short num;
100 volatile unsigned short cong_window;
101 volatile unsigned short packets_out;
102 volatile unsigned short urg;
103 volatile unsigned short shutdown;
104 unsigned short mss;
105 volatile unsigned long rtt;
106 volatile unsigned long mdev;
107 volatile unsigned short backoff;
108 volatile short err;
109 unsigned char protocol;
110 volatile unsigned char state;
111 volatile unsigned char ack_backlog;
112 unsigned char max_ack_backlog;
113 unsigned char priority;
114 unsigned char debug;
115 unsigned short rcvbuf;
116 unsigned short sndbuf;
117 unsigned short type;
118 struct tcphdr dummy_th;
119
120
121 int timeout;
122 struct timer_list timer;
123
124
125 struct socket *socket;
126 };
127
128 struct proto {
129 void *(*wmalloc)(struct sock *sk,
130 unsigned long size, int force,
131 int priority);
132 void *(*rmalloc)(struct sock *sk,
133 unsigned long size, int force,
134 int priority);
135 void (*wfree)(struct sock *sk, void *mem,
136 unsigned long size);
137 void (*rfree)(struct sock *sk, void *mem,
138 unsigned long size);
139 unsigned long (*rspace)(struct sock *sk);
140 unsigned long (*wspace)(struct sock *sk);
141 void (*close)(struct sock *sk, int timeout);
142 int (*read)(struct sock *sk, unsigned char *to,
143 int len, int nonblock, unsigned flags);
144 int (*write)(struct sock *sk, unsigned char *to,
145 int len, int nonblock, unsigned flags);
146 int (*sendto)(struct sock *sk,
147 unsigned char *from, int len, int noblock,
148 unsigned flags, struct sockaddr_in *usin,
149 int addr_len);
150 int (*recvfrom)(struct sock *sk,
151 unsigned char *from, int len, int noblock,
152 unsigned flags, struct sockaddr_in *usin,
153 int *addr_len);
154 int (*build_header)(struct sk_buff *skb,
155 unsigned long saddr,
156 unsigned long daddr,
157 struct device **dev, int type,
158 struct options *opt, int len);
159 int (*connect)(struct sock *sk,
160 struct sockaddr_in *usin, int addr_len);
161 struct sock *(*accept) (struct sock *sk, int flags);
162 void (*queue_xmit)(struct sock *sk,
163 struct device *dev, struct sk_buff *skb,
164 int free);
165 void (*retransmit)(struct sock *sk, int all);
166 void (*write_wakeup)(struct sock *sk);
167 void (*read_wakeup)(struct sock *sk);
168 int (*rcv)(struct sk_buff *buff, struct device *dev,
169 struct options *opt, unsigned long daddr,
170 unsigned short len, unsigned long saddr,
171 int redo, struct inet_protocol *protocol);
172 int (*select)(struct sock *sk, int which,
173 select_table *wait);
174 int (*ioctl)(struct sock *sk, int cmd,
175 unsigned long arg);
176 int (*init)(struct sock *sk);
177 void (*shutdown)(struct sock *sk, int how);
178 unsigned short max_header;
179 unsigned long retransmits;
180 struct sock *sock_array[SOCK_ARRAY_SIZE];
181 char name[80];
182 };
183
184 #define TIME_WRITE 1
185 #define TIME_CLOSE 2
186 #define TIME_KEEPOPEN 3
187 #define TIME_DESTROY 4
188 #define TIME_DONE 5
189 #define SOCK_DESTROY_TIME 1000
190
191 #define PROT_SOCK 1024
192
193 #define SHUTDOWN_MASK 3
194 #define RCV_SHUTDOWN 1
195 #define SEND_SHUTDOWN 2
196
197
198 extern void destroy_sock(struct sock *sk);
199 extern unsigned short get_new_socknum(struct proto *, unsigned short);
200 extern void put_sock(unsigned short, struct sock *);
201 extern void release_sock(struct sock *sk);
202 extern struct sock *get_sock(struct proto *, unsigned short,
203 unsigned long, unsigned short,
204 unsigned long);
205 extern void print_sk(struct sock *);
206 extern void *sock_wmalloc(struct sock *sk,
207 unsigned long size, int force,
208 int priority);
209 extern void *sock_rmalloc(struct sock *sk,
210 unsigned long size, int force,
211 int priority);
212 extern void sock_wfree(struct sock *sk, void *mem,
213 unsigned long size);
214 extern void sock_rfree(struct sock *sk, void *mem,
215 unsigned long size);
216 extern unsigned long sock_rspace(struct sock *sk);
217 extern unsigned long sock_wspace(struct sock *sk);
218
219
220
221 extern struct sock *timer_base;
222
223 void delete_timer (struct sock *);
224 void reset_timer (struct sock *, int, unsigned long);
225 void net_timer (unsigned long);
226
227
228 #endif