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