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