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