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