Commit | Line | Data |
---|---|---|
1da177e4 LT |
1 | /* SCTP kernel reference Implementation |
2 | * (C) Copyright IBM Corp. 2001, 2004 | |
3 | * Copyright (c) 1999-2000 Cisco, Inc. | |
4 | * Copyright (c) 1999-2001 Motorola, Inc. | |
5 | * Copyright (c) 2001 Intel Corp. | |
6 | * | |
7 | * This file is part of the SCTP kernel reference Implementation | |
8 | * | |
9 | * The SCTP reference implementation is free software; | |
10 | * you can redistribute it and/or modify it under the terms of | |
11 | * the GNU General Public License as published by | |
12 | * the Free Software Foundation; either version 2, or (at your option) | |
13 | * any later version. | |
14 | * | |
15 | * The SCTP reference implementation is distributed in the hope that it | |
16 | * will be useful, but WITHOUT ANY WARRANTY; without even the implied | |
17 | * ************************ | |
18 | * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | |
19 | * See the GNU General Public License for more details. | |
20 | * | |
21 | * You should have received a copy of the GNU General Public License | |
22 | * along with GNU CC; see the file COPYING. If not, write to | |
23 | * the Free Software Foundation, 59 Temple Place - Suite 330, | |
24 | * Boston, MA 02111-1307, USA. | |
25 | * | |
26 | * Please send any bug reports or fixes you make to the | |
27 | * email addresses: | |
28 | * lksctp developers <lksctp-developers@lists.sourceforge.net> | |
29 | * | |
30 | * Or submit a bug report through the following website: | |
31 | * http://www.sf.net/projects/lksctp | |
32 | * | |
33 | * Written or modified by: | |
34 | * Randall Stewart <randall@sctp.chicago.il.us> | |
35 | * Ken Morneau <kmorneau@cisco.com> | |
36 | * Qiaobing Xie <qxie1@email.mot.com> | |
37 | * La Monte H.P. Yarroll <piggy@acm.org> | |
38 | * Karl Knutson <karl@athena.chicago.il.us> | |
39 | * Jon Grimm <jgrimm@us.ibm.com> | |
40 | * Xingang Guo <xingang.guo@intel.com> | |
41 | * Hui Huang <hui.huang@nokia.com> | |
42 | * Sridhar Samudrala <sri@us.ibm.com> | |
43 | * Daisy Chang <daisyc@us.ibm.com> | |
44 | * Dajiang Zhang <dajiang.zhang@nokia.com> | |
45 | * Ardelle Fan <ardelle.fan@intel.com> | |
46 | * Ryan Layer <rmlayer@us.ibm.com> | |
47 | * Anup Pemmaiah <pemmaiah@cc.usu.edu> | |
48 | * Kevin Gao <kevin.gao@intel.com> | |
49 | * | |
50 | * Any bugs reported given to us we will try to fix... any fixes shared will | |
51 | * be incorporated into the next SCTP release. | |
52 | */ | |
53 | ||
54 | #ifndef __sctp_structs_h__ | |
55 | #define __sctp_structs_h__ | |
56 | ||
57 | #include <linux/time.h> /* We get struct timespec. */ | |
58 | #include <linux/socket.h> /* linux/in.h needs this!! */ | |
59 | #include <linux/in.h> /* We get struct sockaddr_in. */ | |
60 | #include <linux/in6.h> /* We get struct in6_addr */ | |
61 | #include <linux/ipv6.h> | |
62 | #include <asm/param.h> /* We get MAXHOSTNAMELEN. */ | |
63 | #include <asm/atomic.h> /* This gets us atomic counters. */ | |
64 | #include <linux/skbuff.h> /* We need sk_buff_head. */ | |
65 | #include <linux/workqueue.h> /* We need tq_struct. */ | |
66 | #include <linux/sctp.h> /* We need sctp* header structs. */ | |
67 | ||
68 | /* A convenience structure for handling sockaddr structures. | |
69 | * We should wean ourselves off this. | |
70 | */ | |
71 | union sctp_addr { | |
72 | struct sockaddr_in v4; | |
73 | struct sockaddr_in6 v6; | |
74 | struct sockaddr sa; | |
75 | }; | |
76 | ||
77 | /* Forward declarations for data structures. */ | |
78 | struct sctp_globals; | |
79 | struct sctp_endpoint; | |
80 | struct sctp_association; | |
81 | struct sctp_transport; | |
82 | struct sctp_packet; | |
83 | struct sctp_chunk; | |
84 | struct sctp_inq; | |
85 | struct sctp_outq; | |
86 | struct sctp_bind_addr; | |
87 | struct sctp_ulpq; | |
88 | struct sctp_ep_common; | |
89 | struct sctp_ssnmap; | |
90 | ||
91 | ||
92 | #include <net/sctp/tsnmap.h> | |
93 | #include <net/sctp/ulpevent.h> | |
94 | #include <net/sctp/ulpqueue.h> | |
95 | ||
96 | /* Structures useful for managing bind/connect. */ | |
97 | ||
98 | struct sctp_bind_bucket { | |
99 | unsigned short port; | |
100 | unsigned short fastreuse; | |
101 | struct sctp_bind_bucket *next; | |
102 | struct sctp_bind_bucket **pprev; | |
103 | struct hlist_head owner; | |
104 | }; | |
105 | ||
106 | struct sctp_bind_hashbucket { | |
107 | spinlock_t lock; | |
108 | struct sctp_bind_bucket *chain; | |
109 | }; | |
110 | ||
111 | /* Used for hashing all associations. */ | |
112 | struct sctp_hashbucket { | |
113 | rwlock_t lock; | |
114 | struct sctp_ep_common *chain; | |
115 | } __attribute__((__aligned__(8))); | |
116 | ||
117 | ||
118 | /* The SCTP globals structure. */ | |
119 | extern struct sctp_globals { | |
120 | /* RFC2960 Section 14. Suggested SCTP Protocol Parameter Values | |
121 | * | |
122 | * The following protocol parameters are RECOMMENDED: | |
123 | * | |
124 | * RTO.Initial - 3 seconds | |
125 | * RTO.Min - 1 second | |
126 | * RTO.Max - 60 seconds | |
127 | * RTO.Alpha - 1/8 (3 when converted to right shifts.) | |
128 | * RTO.Beta - 1/4 (2 when converted to right shifts.) | |
129 | */ | |
130 | __u32 rto_initial; | |
131 | __u32 rto_min; | |
132 | __u32 rto_max; | |
133 | ||
134 | /* Note: rto_alpha and rto_beta are really defined as inverse | |
135 | * powers of two to facilitate integer operations. | |
136 | */ | |
137 | int rto_alpha; | |
138 | int rto_beta; | |
139 | ||
140 | /* Max.Burst - 4 */ | |
141 | int max_burst; | |
142 | ||
143 | /* Valid.Cookie.Life - 60 seconds */ | |
144 | int valid_cookie_life; | |
145 | ||
146 | /* Whether Cookie Preservative is enabled(1) or not(0) */ | |
147 | int cookie_preserve_enable; | |
148 | ||
149 | /* Association.Max.Retrans - 10 attempts | |
150 | * Path.Max.Retrans - 5 attempts (per destination address) | |
151 | * Max.Init.Retransmits - 8 attempts | |
152 | */ | |
153 | int max_retrans_association; | |
154 | int max_retrans_path; | |
155 | int max_retrans_init; | |
156 | ||
157 | /* HB.interval - 30 seconds */ | |
158 | int hb_interval; | |
159 | ||
160 | /* The following variables are implementation specific. */ | |
161 | ||
162 | /* Default initialization values to be applied to new associations. */ | |
163 | __u16 max_instreams; | |
164 | __u16 max_outstreams; | |
165 | ||
166 | /* This is a list of groups of functions for each address | |
167 | * family that we support. | |
168 | */ | |
169 | struct list_head address_families; | |
170 | ||
171 | /* This is the hash of all endpoints. */ | |
172 | int ep_hashsize; | |
173 | struct sctp_hashbucket *ep_hashtable; | |
174 | ||
175 | /* This is the hash of all associations. */ | |
176 | int assoc_hashsize; | |
177 | struct sctp_hashbucket *assoc_hashtable; | |
178 | ||
179 | /* This is the sctp port control hash. */ | |
180 | int port_hashsize; | |
181 | int port_rover; | |
182 | spinlock_t port_alloc_lock; /* Protects port_rover. */ | |
183 | struct sctp_bind_hashbucket *port_hashtable; | |
184 | ||
185 | /* This is the global local address list. | |
186 | * We actively maintain this complete list of interfaces on | |
187 | * the system by catching routing events. | |
188 | * | |
189 | * It is a list of sctp_sockaddr_entry. | |
190 | */ | |
191 | struct list_head local_addr_list; | |
192 | spinlock_t local_addr_lock; | |
193 | ||
194 | /* Flag to indicate if addip is enabled. */ | |
195 | int addip_enable; | |
196 | ||
197 | /* Flag to indicate if PR-SCTP is enabled. */ | |
198 | int prsctp_enable; | |
199 | } sctp_globals; | |
200 | ||
201 | #define sctp_rto_initial (sctp_globals.rto_initial) | |
202 | #define sctp_rto_min (sctp_globals.rto_min) | |
203 | #define sctp_rto_max (sctp_globals.rto_max) | |
204 | #define sctp_rto_alpha (sctp_globals.rto_alpha) | |
205 | #define sctp_rto_beta (sctp_globals.rto_beta) | |
206 | #define sctp_max_burst (sctp_globals.max_burst) | |
207 | #define sctp_valid_cookie_life (sctp_globals.valid_cookie_life) | |
208 | #define sctp_cookie_preserve_enable (sctp_globals.cookie_preserve_enable) | |
209 | #define sctp_max_retrans_association (sctp_globals.max_retrans_association) | |
210 | #define sctp_max_retrans_path (sctp_globals.max_retrans_path) | |
211 | #define sctp_max_retrans_init (sctp_globals.max_retrans_init) | |
212 | #define sctp_hb_interval (sctp_globals.hb_interval) | |
213 | #define sctp_max_instreams (sctp_globals.max_instreams) | |
214 | #define sctp_max_outstreams (sctp_globals.max_outstreams) | |
215 | #define sctp_address_families (sctp_globals.address_families) | |
216 | #define sctp_ep_hashsize (sctp_globals.ep_hashsize) | |
217 | #define sctp_ep_hashtable (sctp_globals.ep_hashtable) | |
218 | #define sctp_assoc_hashsize (sctp_globals.assoc_hashsize) | |
219 | #define sctp_assoc_hashtable (sctp_globals.assoc_hashtable) | |
220 | #define sctp_port_hashsize (sctp_globals.port_hashsize) | |
221 | #define sctp_port_rover (sctp_globals.port_rover) | |
222 | #define sctp_port_alloc_lock (sctp_globals.port_alloc_lock) | |
223 | #define sctp_port_hashtable (sctp_globals.port_hashtable) | |
224 | #define sctp_local_addr_list (sctp_globals.local_addr_list) | |
225 | #define sctp_local_addr_lock (sctp_globals.local_addr_lock) | |
226 | #define sctp_addip_enable (sctp_globals.addip_enable) | |
227 | #define sctp_prsctp_enable (sctp_globals.prsctp_enable) | |
228 | ||
229 | /* SCTP Socket type: UDP or TCP style. */ | |
230 | typedef enum { | |
231 | SCTP_SOCKET_UDP = 0, | |
232 | SCTP_SOCKET_UDP_HIGH_BANDWIDTH, | |
233 | SCTP_SOCKET_TCP | |
234 | } sctp_socket_type_t; | |
235 | ||
236 | /* Per socket SCTP information. */ | |
237 | struct sctp_sock { | |
238 | /* inet_sock has to be the first member of sctp_sock */ | |
239 | struct inet_sock inet; | |
240 | /* What kind of a socket is this? */ | |
241 | sctp_socket_type_t type; | |
242 | ||
243 | /* PF_ family specific functions. */ | |
244 | struct sctp_pf *pf; | |
245 | ||
246 | /* Access to HMAC transform. */ | |
247 | struct crypto_tfm *hmac; | |
248 | ||
249 | /* What is our base endpointer? */ | |
250 | struct sctp_endpoint *ep; | |
251 | ||
252 | struct sctp_bind_bucket *bind_hash; | |
253 | /* Various Socket Options. */ | |
254 | __u16 default_stream; | |
255 | __u32 default_ppid; | |
256 | __u16 default_flags; | |
257 | __u32 default_context; | |
258 | __u32 default_timetolive; | |
259 | ||
260 | struct sctp_initmsg initmsg; | |
261 | struct sctp_rtoinfo rtoinfo; | |
262 | struct sctp_paddrparams paddrparam; | |
263 | struct sctp_event_subscribe subscribe; | |
264 | struct sctp_assocparams assocparams; | |
265 | int user_frag; | |
266 | __u32 autoclose; | |
267 | __u8 nodelay; | |
268 | __u8 disable_fragments; | |
269 | __u8 pd_mode; | |
270 | __u8 v4mapped; | |
271 | __u32 adaption_ind; | |
272 | ||
273 | /* Receive to here while partial delivery is in effect. */ | |
274 | struct sk_buff_head pd_lobby; | |
275 | }; | |
276 | ||
277 | static inline struct sctp_sock *sctp_sk(const struct sock *sk) | |
278 | { | |
279 | return (struct sctp_sock *)sk; | |
280 | } | |
281 | ||
282 | static inline struct sock *sctp_opt2sk(const struct sctp_sock *sp) | |
283 | { | |
284 | return (struct sock *)sp; | |
285 | } | |
286 | ||
287 | #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) | |
288 | struct sctp6_sock { | |
289 | struct sctp_sock sctp; | |
290 | struct ipv6_pinfo inet6; | |
291 | }; | |
292 | #endif /* CONFIG_IPV6 */ | |
293 | ||
294 | ||
295 | /* This is our APPLICATION-SPECIFIC state cookie. | |
296 | * THIS IS NOT DICTATED BY THE SPECIFICATION. | |
297 | */ | |
298 | /* These are the parts of an association which we send in the cookie. | |
299 | * Most of these are straight out of: | |
300 | * RFC2960 12.2 Parameters necessary per association (i.e. the TCB) | |
301 | * | |
302 | */ | |
303 | ||
304 | struct sctp_cookie { | |
305 | ||
306 | /* My : Tag expected in every inbound packet and sent | |
307 | * Verification: in the INIT or INIT ACK chunk. | |
308 | * Tag : | |
309 | */ | |
310 | __u32 my_vtag; | |
311 | ||
312 | /* Peer's : Tag expected in every outbound packet except | |
313 | * Verification: in the INIT chunk. | |
314 | * Tag : | |
315 | */ | |
316 | __u32 peer_vtag; | |
317 | ||
318 | /* The rest of these are not from the spec, but really need to | |
319 | * be in the cookie. | |
320 | */ | |
321 | ||
322 | /* My Tie Tag : Assist in discovering a restarting association. */ | |
323 | __u32 my_ttag; | |
324 | ||
325 | /* Peer's Tie Tag: Assist in discovering a restarting association. */ | |
326 | __u32 peer_ttag; | |
327 | ||
328 | /* When does this cookie expire? */ | |
329 | struct timeval expiration; | |
330 | ||
331 | /* Number of inbound/outbound streams which are set | |
332 | * and negotiated during the INIT process. | |
333 | */ | |
334 | __u16 sinit_num_ostreams; | |
335 | __u16 sinit_max_instreams; | |
336 | ||
337 | /* This is the first sequence number I used. */ | |
338 | __u32 initial_tsn; | |
339 | ||
340 | /* This holds the originating address of the INIT packet. */ | |
341 | union sctp_addr peer_addr; | |
342 | ||
343 | /* IG Section 2.35.3 | |
344 | * Include the source port of the INIT-ACK | |
345 | */ | |
346 | __u16 my_port; | |
347 | ||
348 | __u8 prsctp_capable; | |
349 | ||
350 | /* Padding for future use */ | |
351 | __u8 padding; | |
352 | ||
353 | __u32 adaption_ind; | |
354 | ||
355 | ||
356 | /* This is a shim for my peer's INIT packet, followed by | |
357 | * a copy of the raw address list of the association. | |
358 | * The length of the raw address list is saved in the | |
359 | * raw_addr_list_len field, which will be used at the time when | |
360 | * the association TCB is re-constructed from the cookie. | |
361 | */ | |
362 | __u32 raw_addr_list_len; | |
363 | struct sctp_init_chunk peer_init[0]; | |
364 | }; | |
365 | ||
366 | ||
367 | /* The format of our cookie that we send to our peer. */ | |
368 | struct sctp_signed_cookie { | |
369 | __u8 signature[SCTP_SECRET_SIZE]; | |
370 | struct sctp_cookie c; | |
371 | }; | |
372 | ||
373 | /* This is another convenience type to allocate memory for address | |
374 | * params for the maximum size and pass such structures around | |
375 | * internally. | |
376 | */ | |
377 | union sctp_addr_param { | |
378 | struct sctp_ipv4addr_param v4; | |
379 | struct sctp_ipv6addr_param v6; | |
380 | }; | |
381 | ||
382 | /* A convenience type to allow walking through the various | |
383 | * parameters and avoid casting all over the place. | |
384 | */ | |
385 | union sctp_params { | |
386 | void *v; | |
387 | struct sctp_paramhdr *p; | |
388 | struct sctp_cookie_preserve_param *life; | |
389 | struct sctp_hostname_param *dns; | |
390 | struct sctp_cookie_param *cookie; | |
391 | struct sctp_supported_addrs_param *sat; | |
392 | struct sctp_ipv4addr_param *v4; | |
393 | struct sctp_ipv6addr_param *v6; | |
394 | union sctp_addr_param *addr; | |
395 | struct sctp_adaption_ind_param *aind; | |
396 | }; | |
397 | ||
398 | /* RFC 2960. Section 3.3.5 Heartbeat. | |
399 | * Heartbeat Information: variable length | |
400 | * The Sender-specific Heartbeat Info field should normally include | |
401 | * information about the sender's current time when this HEARTBEAT | |
402 | * chunk is sent and the destination transport address to which this | |
403 | * HEARTBEAT is sent (see Section 8.3). | |
404 | */ | |
405 | typedef struct sctp_sender_hb_info { | |
406 | struct sctp_paramhdr param_hdr; | |
407 | union sctp_addr daddr; | |
408 | unsigned long sent_at; | |
409 | } __attribute__((packed)) sctp_sender_hb_info_t; | |
410 | ||
411 | /* | |
412 | * RFC 2960 1.3.2 Sequenced Delivery within Streams | |
413 | * | |
414 | * The term "stream" is used in SCTP to refer to a sequence of user | |
415 | * messages that are to be delivered to the upper-layer protocol in | |
416 | * order with respect to other messages within the same stream. This is | |
417 | * in contrast to its usage in TCP, where it refers to a sequence of | |
418 | * bytes (in this document a byte is assumed to be eight bits). | |
419 | * ... | |
420 | * | |
421 | * This is the structure we use to track both our outbound and inbound | |
422 | * SSN, or Stream Sequence Numbers. | |
423 | */ | |
424 | ||
425 | struct sctp_stream { | |
426 | __u16 *ssn; | |
427 | unsigned int len; | |
428 | }; | |
429 | ||
430 | struct sctp_ssnmap { | |
431 | struct sctp_stream in; | |
432 | struct sctp_stream out; | |
433 | int malloced; | |
434 | }; | |
435 | ||
436 | struct sctp_ssnmap *sctp_ssnmap_new(__u16 in, __u16 out, int gfp); | |
437 | void sctp_ssnmap_free(struct sctp_ssnmap *map); | |
438 | void sctp_ssnmap_clear(struct sctp_ssnmap *map); | |
439 | ||
440 | /* What is the current SSN number for this stream? */ | |
441 | static inline __u16 sctp_ssn_peek(struct sctp_stream *stream, __u16 id) | |
442 | { | |
443 | return stream->ssn[id]; | |
444 | } | |
445 | ||
446 | /* Return the next SSN number for this stream. */ | |
447 | static inline __u16 sctp_ssn_next(struct sctp_stream *stream, __u16 id) | |
448 | { | |
449 | return stream->ssn[id]++; | |
450 | } | |
451 | ||
452 | /* Skip over this ssn and all below. */ | |
453 | static inline void sctp_ssn_skip(struct sctp_stream *stream, __u16 id, | |
454 | __u16 ssn) | |
455 | { | |
456 | stream->ssn[id] = ssn+1; | |
457 | } | |
458 | ||
459 | /* | |
460 | * Pointers to address related SCTP functions. | |
461 | * (i.e. things that depend on the address family.) | |
462 | */ | |
463 | struct sctp_af { | |
464 | int (*sctp_xmit) (struct sk_buff *skb, | |
465 | struct sctp_transport *, | |
466 | int ipfragok); | |
467 | int (*setsockopt) (struct sock *sk, | |
468 | int level, | |
469 | int optname, | |
470 | char __user *optval, | |
471 | int optlen); | |
472 | int (*getsockopt) (struct sock *sk, | |
473 | int level, | |
474 | int optname, | |
475 | char __user *optval, | |
476 | int __user *optlen); | |
477 | struct dst_entry *(*get_dst) (struct sctp_association *asoc, | |
478 | union sctp_addr *daddr, | |
479 | union sctp_addr *saddr); | |
480 | void (*get_saddr) (struct sctp_association *asoc, | |
481 | struct dst_entry *dst, | |
482 | union sctp_addr *daddr, | |
483 | union sctp_addr *saddr); | |
484 | void (*copy_addrlist) (struct list_head *, | |
485 | struct net_device *); | |
486 | void (*dst_saddr) (union sctp_addr *saddr, | |
487 | struct dst_entry *dst, | |
488 | unsigned short port); | |
489 | int (*cmp_addr) (const union sctp_addr *addr1, | |
490 | const union sctp_addr *addr2); | |
491 | void (*addr_copy) (union sctp_addr *dst, | |
492 | union sctp_addr *src); | |
493 | void (*from_skb) (union sctp_addr *, | |
494 | struct sk_buff *skb, | |
495 | int saddr); | |
496 | void (*from_sk) (union sctp_addr *, | |
497 | struct sock *sk); | |
498 | void (*to_sk_saddr) (union sctp_addr *, | |
499 | struct sock *sk); | |
500 | void (*to_sk_daddr) (union sctp_addr *, | |
501 | struct sock *sk); | |
502 | void (*from_addr_param) (union sctp_addr *, | |
503 | union sctp_addr_param *, | |
504 | __u16 port, int iif); | |
505 | int (*to_addr_param) (const union sctp_addr *, | |
506 | union sctp_addr_param *); | |
507 | int (*addr_valid) (union sctp_addr *, | |
508 | struct sctp_sock *); | |
509 | sctp_scope_t (*scope) (union sctp_addr *); | |
510 | void (*inaddr_any) (union sctp_addr *, unsigned short); | |
511 | int (*is_any) (const union sctp_addr *); | |
512 | int (*available) (union sctp_addr *, | |
513 | struct sctp_sock *); | |
514 | int (*skb_iif) (const struct sk_buff *sk); | |
515 | int (*is_ce) (const struct sk_buff *sk); | |
516 | void (*seq_dump_addr)(struct seq_file *seq, | |
517 | union sctp_addr *addr); | |
518 | __u16 net_header_len; | |
519 | int sockaddr_len; | |
520 | sa_family_t sa_family; | |
521 | struct list_head list; | |
522 | }; | |
523 | ||
524 | struct sctp_af *sctp_get_af_specific(sa_family_t); | |
525 | int sctp_register_af(struct sctp_af *); | |
526 | ||
527 | /* Protocol family functions. */ | |
528 | struct sctp_pf { | |
529 | void (*event_msgname)(struct sctp_ulpevent *, char *, int *); | |
530 | void (*skb_msgname) (struct sk_buff *, char *, int *); | |
531 | int (*af_supported) (sa_family_t, struct sctp_sock *); | |
532 | int (*cmp_addr) (const union sctp_addr *, | |
533 | const union sctp_addr *, | |
534 | struct sctp_sock *); | |
535 | int (*bind_verify) (struct sctp_sock *, union sctp_addr *); | |
536 | int (*send_verify) (struct sctp_sock *, union sctp_addr *); | |
537 | int (*supported_addrs)(const struct sctp_sock *, __u16 *); | |
538 | struct sock *(*create_accept_sk) (struct sock *sk, | |
539 | struct sctp_association *asoc); | |
540 | void (*addr_v4map) (struct sctp_sock *, union sctp_addr *); | |
541 | struct sctp_af *af; | |
542 | }; | |
543 | ||
544 | ||
545 | /* Structure to track chunk fragments that have been acked, but peer | |
546 | * fragments of the same message have not. | |
547 | */ | |
548 | struct sctp_datamsg { | |
549 | /* Chunks waiting to be submitted to lower layer. */ | |
550 | struct list_head chunks; | |
551 | /* Chunks that have been transmitted. */ | |
552 | struct list_head track; | |
553 | /* Reference counting. */ | |
554 | atomic_t refcnt; | |
555 | /* When is this message no longer interesting to the peer? */ | |
556 | unsigned long expires_at; | |
557 | /* Did the messenge fail to send? */ | |
558 | int send_error; | |
559 | char send_failed; | |
560 | /* Control whether chunks from this message can be abandoned. */ | |
561 | char can_abandon; | |
562 | }; | |
563 | ||
564 | struct sctp_datamsg *sctp_datamsg_from_user(struct sctp_association *, | |
565 | struct sctp_sndrcvinfo *, | |
566 | struct msghdr *, int len); | |
567 | void sctp_datamsg_put(struct sctp_datamsg *); | |
568 | void sctp_datamsg_free(struct sctp_datamsg *); | |
569 | void sctp_datamsg_track(struct sctp_chunk *); | |
570 | void sctp_chunk_fail(struct sctp_chunk *, int error); | |
571 | int sctp_chunk_abandoned(struct sctp_chunk *); | |
572 | ||
573 | ||
574 | /* RFC2960 1.4 Key Terms | |
575 | * | |
576 | * o Chunk: A unit of information within an SCTP packet, consisting of | |
577 | * a chunk header and chunk-specific content. | |
578 | * | |
579 | * As a matter of convenience, we remember the SCTP common header for | |
580 | * each chunk as well as a few other header pointers... | |
581 | */ | |
582 | struct sctp_chunk { | |
583 | /* These first three elements MUST PRECISELY match the first | |
584 | * three elements of struct sk_buff. This allows us to reuse | |
585 | * all the skb_* queue management functions. | |
586 | */ | |
587 | struct sctp_chunk *next; | |
588 | struct sctp_chunk *prev; | |
589 | struct sk_buff_head *list; | |
590 | atomic_t refcnt; | |
591 | ||
592 | /* This is our link to the per-transport transmitted list. */ | |
593 | struct list_head transmitted_list; | |
594 | ||
595 | /* This field is used by chunks that hold fragmented data. | |
596 | * For the first fragment this is the list that holds the rest of | |
597 | * fragments. For the remaining fragments, this is the link to the | |
598 | * frag_list maintained in the first fragment. | |
599 | */ | |
600 | struct list_head frag_list; | |
601 | ||
602 | /* This points to the sk_buff containing the actual data. */ | |
603 | struct sk_buff *skb; | |
604 | ||
605 | /* These are the SCTP headers by reverse order in a packet. | |
606 | * Note that some of these may happen more than once. In that | |
607 | * case, we point at the "current" one, whatever that means | |
608 | * for that level of header. | |
609 | */ | |
610 | ||
611 | /* We point this at the FIRST TLV parameter to chunk_hdr. */ | |
612 | union sctp_params param_hdr; | |
613 | union { | |
614 | __u8 *v; | |
615 | struct sctp_datahdr *data_hdr; | |
616 | struct sctp_inithdr *init_hdr; | |
617 | struct sctp_sackhdr *sack_hdr; | |
618 | struct sctp_heartbeathdr *hb_hdr; | |
619 | struct sctp_sender_hb_info *hbs_hdr; | |
620 | struct sctp_shutdownhdr *shutdown_hdr; | |
621 | struct sctp_signed_cookie *cookie_hdr; | |
622 | struct sctp_ecnehdr *ecne_hdr; | |
623 | struct sctp_cwrhdr *ecn_cwr_hdr; | |
624 | struct sctp_errhdr *err_hdr; | |
625 | struct sctp_addiphdr *addip_hdr; | |
626 | struct sctp_fwdtsn_hdr *fwdtsn_hdr; | |
627 | } subh; | |
628 | ||
629 | __u8 *chunk_end; | |
630 | ||
631 | struct sctp_chunkhdr *chunk_hdr; | |
632 | struct sctphdr *sctp_hdr; | |
633 | ||
634 | /* This needs to be recoverable for SCTP_SEND_FAILED events. */ | |
635 | struct sctp_sndrcvinfo sinfo; | |
636 | ||
637 | /* Which association does this belong to? */ | |
638 | struct sctp_association *asoc; | |
639 | ||
640 | /* What endpoint received this chunk? */ | |
641 | struct sctp_ep_common *rcvr; | |
642 | ||
643 | /* We fill this in if we are calculating RTT. */ | |
644 | unsigned long sent_at; | |
645 | ||
646 | /* What is the origin IP address for this chunk? */ | |
647 | union sctp_addr source; | |
648 | /* Destination address for this chunk. */ | |
649 | union sctp_addr dest; | |
650 | ||
651 | /* For outbound message, track all fragments for SEND_FAILED. */ | |
652 | struct sctp_datamsg *msg; | |
653 | ||
654 | /* For an inbound chunk, this tells us where it came from. | |
655 | * For an outbound chunk, it tells us where we'd like it to | |
656 | * go. It is NULL if we have no preference. | |
657 | */ | |
658 | struct sctp_transport *transport; | |
659 | ||
660 | __u8 rtt_in_progress; /* Is this chunk used for RTT calculation? */ | |
661 | __u8 resent; /* Has this chunk ever been retransmitted. */ | |
662 | __u8 has_tsn; /* Does this chunk have a TSN yet? */ | |
663 | __u8 has_ssn; /* Does this chunk have a SSN yet? */ | |
664 | __u8 singleton; /* Was this the only chunk in the packet? */ | |
665 | __u8 end_of_packet; /* Was this the last chunk in the packet? */ | |
666 | __u8 ecn_ce_done; /* Have we processed the ECN CE bit? */ | |
667 | __u8 pdiscard; /* Discard the whole packet now? */ | |
668 | __u8 tsn_gap_acked; /* Is this chunk acked by a GAP ACK? */ | |
669 | __u8 fast_retransmit; /* Is this chunk fast retransmitted? */ | |
670 | __u8 tsn_missing_report; /* Data chunk missing counter. */ | |
671 | }; | |
672 | ||
673 | void sctp_chunk_hold(struct sctp_chunk *); | |
674 | void sctp_chunk_put(struct sctp_chunk *); | |
675 | int sctp_user_addto_chunk(struct sctp_chunk *chunk, int off, int len, | |
676 | struct iovec *data); | |
677 | void sctp_chunk_free(struct sctp_chunk *); | |
678 | void *sctp_addto_chunk(struct sctp_chunk *, int len, const void *data); | |
679 | struct sctp_chunk *sctp_chunkify(struct sk_buff *, | |
680 | const struct sctp_association *, | |
681 | struct sock *); | |
682 | void sctp_init_addrs(struct sctp_chunk *, union sctp_addr *, | |
683 | union sctp_addr *); | |
684 | const union sctp_addr *sctp_source(const struct sctp_chunk *chunk); | |
685 | ||
686 | /* This is a structure for holding either an IPv6 or an IPv4 address. */ | |
687 | /* sin_family -- AF_INET or AF_INET6 | |
688 | * sin_port -- ordinary port number | |
689 | * sin_addr -- cast to either (struct in_addr) or (struct in6_addr) | |
690 | */ | |
691 | struct sctp_sockaddr_entry { | |
692 | struct list_head list; | |
693 | union sctp_addr a; | |
694 | }; | |
695 | ||
696 | typedef struct sctp_chunk *(sctp_packet_phandler_t)(struct sctp_association *); | |
697 | ||
698 | /* This structure holds lists of chunks as we are assembling for | |
699 | * transmission. | |
700 | */ | |
701 | struct sctp_packet { | |
702 | /* These are the SCTP header values (host order) for the packet. */ | |
703 | __u16 source_port; | |
704 | __u16 destination_port; | |
705 | __u32 vtag; | |
706 | ||
707 | /* This contains the payload chunks. */ | |
708 | struct sk_buff_head chunks; | |
709 | ||
710 | /* This is the overhead of the sctp and ip headers. */ | |
711 | size_t overhead; | |
712 | /* This is the total size of all chunks INCLUDING padding. */ | |
713 | size_t size; | |
714 | ||
715 | /* The packet is destined for this transport address. | |
716 | * The function we finally use to pass down to the next lower | |
717 | * layer lives in the transport structure. | |
718 | */ | |
719 | struct sctp_transport *transport; | |
720 | ||
721 | /* This packet contains a COOKIE-ECHO chunk. */ | |
722 | char has_cookie_echo; | |
723 | ||
724 | /* This packet containsa SACK chunk. */ | |
725 | char has_sack; | |
726 | ||
727 | /* SCTP cannot fragment this packet. So let ip fragment it. */ | |
728 | char ipfragok; | |
729 | ||
730 | int malloced; | |
731 | }; | |
732 | ||
733 | struct sctp_packet *sctp_packet_init(struct sctp_packet *, | |
734 | struct sctp_transport *, | |
735 | __u16 sport, __u16 dport); | |
736 | struct sctp_packet *sctp_packet_config(struct sctp_packet *, __u32 vtag, int); | |
737 | sctp_xmit_t sctp_packet_transmit_chunk(struct sctp_packet *, | |
738 | struct sctp_chunk *); | |
739 | sctp_xmit_t sctp_packet_append_chunk(struct sctp_packet *, | |
740 | struct sctp_chunk *); | |
741 | int sctp_packet_transmit(struct sctp_packet *); | |
742 | void sctp_packet_free(struct sctp_packet *); | |
743 | ||
744 | static inline int sctp_packet_empty(struct sctp_packet *packet) | |
745 | { | |
746 | return (packet->size == packet->overhead); | |
747 | } | |
748 | ||
749 | /* This represents a remote transport address. | |
750 | * For local transport addresses, we just use union sctp_addr. | |
751 | * | |
752 | * RFC2960 Section 1.4 Key Terms | |
753 | * | |
754 | * o Transport address: A Transport Address is traditionally defined | |
755 | * by Network Layer address, Transport Layer protocol and Transport | |
756 | * Layer port number. In the case of SCTP running over IP, a | |
757 | * transport address is defined by the combination of an IP address | |
758 | * and an SCTP port number (where SCTP is the Transport protocol). | |
759 | * | |
760 | * RFC2960 Section 7.1 SCTP Differences from TCP Congestion control | |
761 | * | |
762 | * o The sender keeps a separate congestion control parameter set for | |
763 | * each of the destination addresses it can send to (not each | |
764 | * source-destination pair but for each destination). The parameters | |
765 | * should decay if the address is not used for a long enough time | |
766 | * period. | |
767 | * | |
768 | */ | |
769 | struct sctp_transport { | |
770 | /* A list of transports. */ | |
771 | struct list_head transports; | |
772 | ||
773 | /* Reference counting. */ | |
774 | atomic_t refcnt; | |
775 | int dead; | |
776 | ||
777 | /* This is the peer's IP address and port. */ | |
778 | union sctp_addr ipaddr; | |
779 | ||
780 | /* These are the functions we call to handle LLP stuff. */ | |
781 | struct sctp_af *af_specific; | |
782 | ||
783 | /* Which association do we belong to? */ | |
784 | struct sctp_association *asoc; | |
785 | ||
786 | /* RFC2960 | |
787 | * | |
788 | * 12.3 Per Transport Address Data | |
789 | * | |
790 | * For each destination transport address in the peer's | |
791 | * address list derived from the INIT or INIT ACK chunk, a | |
792 | * number of data elements needs to be maintained including: | |
793 | */ | |
794 | __u32 rtt; /* This is the most recent RTT. */ | |
795 | ||
796 | /* RTO : The current retransmission timeout value. */ | |
797 | __u32 rto; | |
798 | ||
799 | /* RTTVAR : The current RTT variation. */ | |
800 | __u32 rttvar; | |
801 | ||
802 | /* SRTT : The current smoothed round trip time. */ | |
803 | __u32 srtt; | |
804 | ||
805 | /* RTO-Pending : A flag used to track if one of the DATA | |
806 | * chunks sent to this address is currently being | |
807 | * used to compute a RTT. If this flag is 0, | |
808 | * the next DATA chunk sent to this destination | |
809 | * should be used to compute a RTT and this flag | |
810 | * should be set. Every time the RTT | |
811 | * calculation completes (i.e. the DATA chunk | |
812 | * is SACK'd) clear this flag. | |
813 | */ | |
814 | int rto_pending; | |
815 | ||
816 | /* | |
817 | * These are the congestion stats. | |
818 | */ | |
819 | /* cwnd : The current congestion window. */ | |
820 | __u32 cwnd; /* This is the actual cwnd. */ | |
821 | ||
822 | /* ssthresh : The current slow start threshold value. */ | |
823 | __u32 ssthresh; | |
824 | ||
825 | /* partial : The tracking method for increase of cwnd when in | |
826 | * bytes acked : congestion avoidance mode (see Section 6.2.2) | |
827 | */ | |
828 | __u32 partial_bytes_acked; | |
829 | ||
830 | /* Data that has been sent, but not acknowledged. */ | |
831 | __u32 flight_size; | |
832 | ||
833 | /* PMTU : The current known path MTU. */ | |
834 | __u32 pmtu; | |
835 | ||
836 | /* Destination */ | |
837 | struct dst_entry *dst; | |
838 | /* Source address. */ | |
839 | union sctp_addr saddr; | |
840 | ||
841 | /* When was the last time(in jiffies) that a data packet was sent on | |
842 | * this transport? This is used to adjust the cwnd when the transport | |
843 | * becomes inactive. | |
844 | */ | |
845 | unsigned long last_time_used; | |
846 | ||
847 | /* Heartbeat interval: The endpoint sends out a Heartbeat chunk to | |
848 | * the destination address every heartbeat interval. | |
849 | */ | |
850 | int hb_interval; | |
851 | ||
852 | /* When was the last time (in jiffies) that we heard from this | |
853 | * transport? We use this to pick new active and retran paths. | |
854 | */ | |
855 | unsigned long last_time_heard; | |
856 | ||
857 | /* Last time(in jiffies) when cwnd is reduced due to the congestion | |
858 | * indication based on ECNE chunk. | |
859 | */ | |
860 | unsigned long last_time_ecne_reduced; | |
861 | ||
862 | /* active : The current active state of this destination, | |
863 | * : i.e. DOWN, UP, etc. | |
864 | */ | |
865 | int active; | |
866 | ||
867 | /* hb_allowed : The current heartbeat state of this destination, | |
868 | * : i.e. ALLOW-HB, NO-HEARTBEAT, etc. | |
869 | */ | |
870 | int hb_allowed; | |
871 | ||
872 | /* These are the error stats for this destination. */ | |
873 | ||
874 | /* Error count : The current error count for this destination. */ | |
875 | unsigned short error_count; | |
876 | ||
877 | /* This is the max_retrans value for the transport and will | |
878 | * be initialized to proto.max_retrans.path. This can be changed | |
879 | * using SCTP_SET_PEER_ADDR_PARAMS socket option. | |
880 | */ | |
881 | int max_retrans; | |
882 | ||
883 | /* Per : A timer used by each destination. | |
884 | * Destination : | |
885 | * Timer : | |
886 | * | |
887 | * [Everywhere else in the text this is called T3-rtx. -ed] | |
888 | */ | |
889 | struct timer_list T3_rtx_timer; | |
890 | ||
891 | /* Heartbeat timer is per destination. */ | |
892 | struct timer_list hb_timer; | |
893 | ||
894 | /* Since we're using per-destination retransmission timers | |
895 | * (see above), we're also using per-destination "transmitted" | |
896 | * queues. This probably ought to be a private struct | |
897 | * accessible only within the outqueue, but it's not, yet. | |
898 | */ | |
899 | struct list_head transmitted; | |
900 | ||
901 | /* We build bundle-able packets for this transport here. */ | |
902 | struct sctp_packet packet; | |
903 | ||
904 | /* This is the list of transports that have chunks to send. */ | |
905 | struct list_head send_ready; | |
906 | ||
907 | int malloced; /* Is this structure kfree()able? */ | |
908 | ||
909 | /* State information saved for SFR_CACC algorithm. The key | |
910 | * idea in SFR_CACC is to maintain state at the sender on a | |
911 | * per-destination basis when a changeover happens. | |
912 | * char changeover_active; | |
913 | * char cycling_changeover; | |
914 | * __u32 next_tsn_at_change; | |
915 | * char cacc_saw_newack; | |
916 | */ | |
917 | struct { | |
918 | /* An unsigned integer, which stores the next TSN to be | |
919 | * used by the sender, at the moment of changeover. | |
920 | */ | |
921 | __u32 next_tsn_at_change; | |
922 | ||
923 | /* A flag which indicates the occurrence of a changeover */ | |
924 | char changeover_active; | |
925 | ||
926 | /* A flag which indicates whether the change of primary is | |
927 | * the first switch to this destination address during an | |
928 | * active switch. | |
929 | */ | |
930 | char cycling_changeover; | |
931 | ||
932 | /* A temporary flag, which is used during the processing of | |
933 | * a SACK to estimate the causative TSN(s)'s group. | |
934 | */ | |
935 | char cacc_saw_newack; | |
936 | } cacc; | |
937 | }; | |
938 | ||
939 | struct sctp_transport *sctp_transport_new(const union sctp_addr *, int); | |
940 | void sctp_transport_set_owner(struct sctp_transport *, | |
941 | struct sctp_association *); | |
942 | void sctp_transport_route(struct sctp_transport *, union sctp_addr *, | |
943 | struct sctp_sock *); | |
944 | void sctp_transport_pmtu(struct sctp_transport *); | |
945 | void sctp_transport_free(struct sctp_transport *); | |
946 | void sctp_transport_reset_timers(struct sctp_transport *); | |
947 | void sctp_transport_hold(struct sctp_transport *); | |
948 | void sctp_transport_put(struct sctp_transport *); | |
949 | void sctp_transport_update_rto(struct sctp_transport *, __u32); | |
950 | void sctp_transport_raise_cwnd(struct sctp_transport *, __u32, __u32); | |
951 | void sctp_transport_lower_cwnd(struct sctp_transport *, sctp_lower_cwnd_t); | |
952 | unsigned long sctp_transport_timeout(struct sctp_transport *); | |
953 | ||
954 | ||
955 | /* This is the structure we use to queue packets as they come into | |
956 | * SCTP. We write packets to it and read chunks from it. | |
957 | */ | |
958 | struct sctp_inq { | |
959 | /* This is actually a queue of sctp_chunk each | |
960 | * containing a partially decoded packet. | |
961 | */ | |
962 | struct sk_buff_head in; | |
963 | /* This is the packet which is currently off the in queue and is | |
964 | * being worked on through the inbound chunk processing. | |
965 | */ | |
966 | struct sctp_chunk *in_progress; | |
967 | ||
968 | /* This is the delayed task to finish delivering inbound | |
969 | * messages. | |
970 | */ | |
971 | struct work_struct immediate; | |
972 | ||
973 | int malloced; /* Is this structure kfree()able? */ | |
974 | }; | |
975 | ||
976 | void sctp_inq_init(struct sctp_inq *); | |
977 | void sctp_inq_free(struct sctp_inq *); | |
978 | void sctp_inq_push(struct sctp_inq *, struct sctp_chunk *packet); | |
979 | struct sctp_chunk *sctp_inq_pop(struct sctp_inq *); | |
980 | void sctp_inq_set_th_handler(struct sctp_inq *, void (*)(void *), void *); | |
981 | ||
982 | /* This is the structure we use to hold outbound chunks. You push | |
983 | * chunks in and they automatically pop out the other end as bundled | |
984 | * packets (it calls (*output_handler)()). | |
985 | * | |
986 | * This structure covers sections 6.3, 6.4, 6.7, 6.8, 6.10, 7., 8.1, | |
987 | * and 8.2 of the v13 draft. | |
988 | * | |
989 | * It handles retransmissions. The connection to the timeout portion | |
990 | * of the state machine is through sctp_..._timeout() and timeout_handler. | |
991 | * | |
992 | * If you feed it SACKs, it will eat them. | |
993 | * | |
994 | * If you give it big chunks, it will fragment them. | |
995 | * | |
996 | * It assigns TSN's to data chunks. This happens at the last possible | |
997 | * instant before transmission. | |
998 | * | |
999 | * When free()'d, it empties itself out via output_handler(). | |
1000 | */ | |
1001 | struct sctp_outq { | |
1002 | struct sctp_association *asoc; | |
1003 | ||
1004 | /* Data pending that has never been transmitted. */ | |
1005 | struct sk_buff_head out; | |
1006 | ||
1007 | unsigned out_qlen; /* Total length of queued data chunks. */ | |
1008 | ||
1009 | /* Error of send failed, may used in SCTP_SEND_FAILED event. */ | |
1010 | unsigned error; | |
1011 | ||
1012 | /* These are control chunks we want to send. */ | |
1013 | struct sk_buff_head control; | |
1014 | ||
1015 | /* These are chunks that have been sacked but are above the | |
1016 | * CTSN, or cumulative tsn ack point. | |
1017 | */ | |
1018 | struct list_head sacked; | |
1019 | ||
1020 | /* Put chunks on this list to schedule them for | |
1021 | * retransmission. | |
1022 | */ | |
1023 | struct list_head retransmit; | |
1024 | ||
1025 | /* Put chunks on this list to save them for FWD TSN processing as | |
1026 | * they were abandoned. | |
1027 | */ | |
1028 | struct list_head abandoned; | |
1029 | ||
1030 | /* How many unackd bytes do we have in-flight? */ | |
1031 | __u32 outstanding_bytes; | |
1032 | ||
1033 | /* Corked? */ | |
1034 | char cork; | |
1035 | ||
1036 | /* Is this structure empty? */ | |
1037 | char empty; | |
1038 | ||
1039 | /* Are we kfree()able? */ | |
1040 | char malloced; | |
1041 | }; | |
1042 | ||
1043 | void sctp_outq_init(struct sctp_association *, struct sctp_outq *); | |
1044 | void sctp_outq_teardown(struct sctp_outq *); | |
1045 | void sctp_outq_free(struct sctp_outq*); | |
1046 | int sctp_outq_tail(struct sctp_outq *, struct sctp_chunk *chunk); | |
1047 | int sctp_outq_flush(struct sctp_outq *, int); | |
1048 | int sctp_outq_sack(struct sctp_outq *, struct sctp_sackhdr *); | |
1049 | int sctp_outq_is_empty(const struct sctp_outq *); | |
1050 | void sctp_outq_restart(struct sctp_outq *); | |
1051 | ||
1052 | void sctp_retransmit(struct sctp_outq *, struct sctp_transport *, | |
1053 | sctp_retransmit_reason_t); | |
1054 | void sctp_retransmit_mark(struct sctp_outq *, struct sctp_transport *, __u8); | |
1055 | int sctp_outq_uncork(struct sctp_outq *); | |
1056 | /* Uncork and flush an outqueue. */ | |
1057 | static inline void sctp_outq_cork(struct sctp_outq *q) | |
1058 | { | |
1059 | q->cork = 1; | |
1060 | } | |
1061 | ||
1062 | /* These bind address data fields common between endpoints and associations */ | |
1063 | struct sctp_bind_addr { | |
1064 | ||
1065 | /* RFC 2960 12.1 Parameters necessary for the SCTP instance | |
1066 | * | |
1067 | * SCTP Port: The local SCTP port number the endpoint is | |
1068 | * bound to. | |
1069 | */ | |
1070 | __u16 port; | |
1071 | ||
1072 | /* RFC 2960 12.1 Parameters necessary for the SCTP instance | |
1073 | * | |
1074 | * Address List: The list of IP addresses that this instance | |
1075 | * has bound. This information is passed to one's | |
1076 | * peer(s) in INIT and INIT ACK chunks. | |
1077 | */ | |
1078 | struct list_head address_list; | |
1079 | ||
1080 | int malloced; /* Are we kfree()able? */ | |
1081 | }; | |
1082 | ||
1083 | void sctp_bind_addr_init(struct sctp_bind_addr *, __u16 port); | |
1084 | void sctp_bind_addr_free(struct sctp_bind_addr *); | |
1085 | int sctp_bind_addr_copy(struct sctp_bind_addr *dest, | |
1086 | const struct sctp_bind_addr *src, | |
1087 | sctp_scope_t scope, int gfp,int flags); | |
1088 | int sctp_add_bind_addr(struct sctp_bind_addr *, union sctp_addr *, | |
1089 | int gfp); | |
1090 | int sctp_del_bind_addr(struct sctp_bind_addr *, union sctp_addr *); | |
1091 | int sctp_bind_addr_match(struct sctp_bind_addr *, const union sctp_addr *, | |
1092 | struct sctp_sock *); | |
1093 | union sctp_addr *sctp_find_unmatch_addr(struct sctp_bind_addr *bp, | |
1094 | const union sctp_addr *addrs, | |
1095 | int addrcnt, | |
1096 | struct sctp_sock *opt); | |
1097 | union sctp_params sctp_bind_addrs_to_raw(const struct sctp_bind_addr *bp, | |
1098 | int *addrs_len, int gfp); | |
1099 | int sctp_raw_to_bind_addrs(struct sctp_bind_addr *bp, __u8 *raw, int len, | |
1100 | __u16 port, int gfp); | |
1101 | ||
1102 | sctp_scope_t sctp_scope(const union sctp_addr *); | |
1103 | int sctp_in_scope(const union sctp_addr *addr, const sctp_scope_t scope); | |
1104 | int sctp_is_any(const union sctp_addr *addr); | |
1105 | int sctp_addr_is_valid(const union sctp_addr *addr); | |
1106 | ||
1107 | ||
1108 | /* What type of endpoint? */ | |
1109 | typedef enum { | |
1110 | SCTP_EP_TYPE_SOCKET, | |
1111 | SCTP_EP_TYPE_ASSOCIATION, | |
1112 | } sctp_endpoint_type_t; | |
1113 | ||
1114 | /* | |
1115 | * A common base class to bridge the implmentation view of a | |
1116 | * socket (usually listening) endpoint versus an association's | |
1117 | * local endpoint. | |
1118 | * This common structure is useful for several purposes: | |
1119 | * 1) Common interface for lookup routines. | |
1120 | * a) Subfunctions work for either endpoint or association | |
1121 | * b) Single interface to lookup allows hiding the lookup lock rather | |
1122 | * than acquiring it externally. | |
1123 | * 2) Common interface for the inbound chunk handling/state machine. | |
1124 | * 3) Common object handling routines for reference counting, etc. | |
1125 | * 4) Disentangle association lookup from endpoint lookup, where we | |
1126 | * do not have to find our endpoint to find our association. | |
1127 | * | |
1128 | */ | |
1129 | ||
1130 | struct sctp_ep_common { | |
1131 | /* Fields to help us manage our entries in the hash tables. */ | |
1132 | struct sctp_ep_common *next; | |
1133 | struct sctp_ep_common **pprev; | |
1134 | int hashent; | |
1135 | ||
1136 | /* Runtime type information. What kind of endpoint is this? */ | |
1137 | sctp_endpoint_type_t type; | |
1138 | ||
1139 | /* Some fields to help us manage this object. | |
1140 | * refcnt - Reference count access to this object. | |
1141 | * dead - Do not attempt to use this object. | |
1142 | * malloced - Do we need to kfree this object? | |
1143 | */ | |
1144 | atomic_t refcnt; | |
1145 | char dead; | |
1146 | char malloced; | |
1147 | ||
1148 | /* What socket does this endpoint belong to? */ | |
1149 | struct sock *sk; | |
1150 | ||
1151 | /* This is where we receive inbound chunks. */ | |
1152 | struct sctp_inq inqueue; | |
1153 | ||
1154 | /* This substructure includes the defining parameters of the | |
1155 | * endpoint: | |
1156 | * bind_addr.port is our shared port number. | |
1157 | * bind_addr.address_list is our set of local IP addresses. | |
1158 | */ | |
1159 | struct sctp_bind_addr bind_addr; | |
1160 | ||
1161 | /* Protection during address list comparisons. */ | |
1162 | rwlock_t addr_lock; | |
1163 | }; | |
1164 | ||
1165 | ||
1166 | /* RFC Section 1.4 Key Terms | |
1167 | * | |
1168 | * o SCTP endpoint: The logical sender/receiver of SCTP packets. On a | |
1169 | * multi-homed host, an SCTP endpoint is represented to its peers as a | |
1170 | * combination of a set of eligible destination transport addresses to | |
1171 | * which SCTP packets can be sent and a set of eligible source | |
1172 | * transport addresses from which SCTP packets can be received. | |
1173 | * All transport addresses used by an SCTP endpoint must use the | |
1174 | * same port number, but can use multiple IP addresses. A transport | |
1175 | * address used by an SCTP endpoint must not be used by another | |
1176 | * SCTP endpoint. In other words, a transport address is unique | |
1177 | * to an SCTP endpoint. | |
1178 | * | |
1179 | * From an implementation perspective, each socket has one of these. | |
1180 | * A TCP-style socket will have exactly one association on one of | |
1181 | * these. An UDP-style socket will have multiple associations hanging | |
1182 | * off one of these. | |
1183 | */ | |
1184 | ||
1185 | struct sctp_endpoint { | |
1186 | /* Common substructure for endpoint and association. */ | |
1187 | struct sctp_ep_common base; | |
1188 | ||
1189 | /* Associations: A list of current associations and mappings | |
1190 | * to the data consumers for each association. This | |
1191 | * may be in the form of a hash table or other | |
1192 | * implementation dependent structure. The data | |
1193 | * consumers may be process identification | |
1194 | * information such as file descriptors, named pipe | |
1195 | * pointer, or table pointers dependent on how SCTP | |
1196 | * is implemented. | |
1197 | */ | |
1198 | /* This is really a list of struct sctp_association entries. */ | |
1199 | struct list_head asocs; | |
1200 | ||
1201 | /* Secret Key: A secret key used by this endpoint to compute | |
1202 | * the MAC. This SHOULD be a cryptographic quality | |
1203 | * random number with a sufficient length. | |
1204 | * Discussion in [RFC1750] can be helpful in | |
1205 | * selection of the key. | |
1206 | */ | |
1207 | __u8 secret_key[SCTP_HOW_MANY_SECRETS][SCTP_SECRET_SIZE]; | |
1208 | int current_key; | |
1209 | int last_key; | |
1210 | int key_changed_at; | |
1211 | ||
1212 | /* Default timeouts. */ | |
1213 | int timeouts[SCTP_NUM_TIMEOUT_TYPES]; | |
1214 | ||
1215 | /* Various thresholds. */ | |
1216 | ||
1217 | /* Name for debugging output... */ | |
1218 | char *debug_name; | |
1219 | }; | |
1220 | ||
1221 | /* Recover the outter endpoint structure. */ | |
1222 | static inline struct sctp_endpoint *sctp_ep(struct sctp_ep_common *base) | |
1223 | { | |
1224 | struct sctp_endpoint *ep; | |
1225 | ||
1226 | ep = container_of(base, struct sctp_endpoint, base); | |
1227 | return ep; | |
1228 | } | |
1229 | ||
1230 | /* These are function signatures for manipulating endpoints. */ | |
1231 | struct sctp_endpoint *sctp_endpoint_new(struct sock *, int); | |
1232 | void sctp_endpoint_free(struct sctp_endpoint *); | |
1233 | void sctp_endpoint_put(struct sctp_endpoint *); | |
1234 | void sctp_endpoint_hold(struct sctp_endpoint *); | |
1235 | void sctp_endpoint_add_asoc(struct sctp_endpoint *, struct sctp_association *); | |
1236 | struct sctp_association *sctp_endpoint_lookup_assoc( | |
1237 | const struct sctp_endpoint *ep, | |
1238 | const union sctp_addr *paddr, | |
1239 | struct sctp_transport **); | |
1240 | int sctp_endpoint_is_peeled_off(struct sctp_endpoint *, | |
1241 | const union sctp_addr *); | |
1242 | struct sctp_endpoint *sctp_endpoint_is_match(struct sctp_endpoint *, | |
1243 | const union sctp_addr *); | |
1244 | int sctp_has_association(const union sctp_addr *laddr, | |
1245 | const union sctp_addr *paddr); | |
1246 | ||
1247 | int sctp_verify_init(const struct sctp_association *asoc, sctp_cid_t, | |
1248 | sctp_init_chunk_t *peer_init, struct sctp_chunk *chunk, | |
1249 | struct sctp_chunk **err_chunk); | |
1250 | int sctp_process_init(struct sctp_association *, sctp_cid_t cid, | |
1251 | const union sctp_addr *peer, | |
1252 | sctp_init_chunk_t *init, int gfp); | |
1253 | __u32 sctp_generate_tag(const struct sctp_endpoint *); | |
1254 | __u32 sctp_generate_tsn(const struct sctp_endpoint *); | |
1255 | ||
1256 | ||
1257 | /* RFC2960 | |
1258 | * | |
1259 | * 12. Recommended Transmission Control Block (TCB) Parameters | |
1260 | * | |
1261 | * This section details a recommended set of parameters that should | |
1262 | * be contained within the TCB for an implementation. This section is | |
1263 | * for illustrative purposes and should not be deemed as requirements | |
1264 | * on an implementation or as an exhaustive list of all parameters | |
1265 | * inside an SCTP TCB. Each implementation may need its own additional | |
1266 | * parameters for optimization. | |
1267 | */ | |
1268 | ||
1269 | ||
1270 | /* Here we have information about each individual association. */ | |
1271 | struct sctp_association { | |
1272 | ||
1273 | /* A base structure common to endpoint and association. | |
1274 | * In this context, it represents the associations's view | |
1275 | * of the local endpoint of the association. | |
1276 | */ | |
1277 | struct sctp_ep_common base; | |
1278 | ||
1279 | /* Associations on the same socket. */ | |
1280 | struct list_head asocs; | |
1281 | ||
1282 | /* association id. */ | |
1283 | sctp_assoc_t assoc_id; | |
1284 | ||
1285 | /* This is our parent endpoint. */ | |
1286 | struct sctp_endpoint *ep; | |
1287 | ||
1288 | /* These are those association elements needed in the cookie. */ | |
1289 | struct sctp_cookie c; | |
1290 | ||
1291 | /* This is all information about our peer. */ | |
1292 | struct { | |
1293 | /* rwnd | |
1294 | * | |
1295 | * Peer Rwnd : Current calculated value of the peer's rwnd. | |
1296 | */ | |
1297 | __u32 rwnd; | |
1298 | ||
1299 | /* transport_addr_list | |
1300 | * | |
1301 | * Peer : A list of SCTP transport addresses that the | |
1302 | * Transport : peer is bound to. This information is derived | |
1303 | * Address : from the INIT or INIT ACK and is used to | |
1304 | * List : associate an inbound packet with a given | |
1305 | * : association. Normally this information is | |
1306 | * : hashed or keyed for quick lookup and access | |
1307 | * : of the TCB. | |
1308 | * | |
1309 | * It is a list of SCTP_transport's. | |
1310 | */ | |
1311 | struct list_head transport_addr_list; | |
1312 | ||
1313 | /* port | |
1314 | * The transport layer port number. | |
1315 | */ | |
1316 | __u16 port; | |
1317 | ||
1318 | /* primary_path | |
1319 | * | |
1320 | * Primary : This is the current primary destination | |
1321 | * Path : transport address of the peer endpoint. It | |
1322 | * : may also specify a source transport address | |
1323 | * : on this endpoint. | |
1324 | * | |
1325 | * All of these paths live on transport_addr_list. | |
1326 | * | |
1327 | * At the bakeoffs, we discovered that the intent of | |
1328 | * primaryPath is that it only changes when the ULP | |
1329 | * asks to have it changed. We add the activePath to | |
1330 | * designate the connection we are currently using to | |
1331 | * transmit new data and most control chunks. | |
1332 | */ | |
1333 | struct sctp_transport *primary_path; | |
1334 | ||
1335 | /* Cache the primary path address here, when we | |
1336 | * need a an address for msg_name. | |
1337 | */ | |
1338 | union sctp_addr primary_addr; | |
1339 | ||
1340 | /* active_path | |
1341 | * The path that we are currently using to | |
1342 | * transmit new data and most control chunks. | |
1343 | */ | |
1344 | struct sctp_transport *active_path; | |
1345 | ||
1346 | /* retran_path | |
1347 | * | |
1348 | * RFC2960 6.4 Multi-homed SCTP Endpoints | |
1349 | * ... | |
1350 | * Furthermore, when its peer is multi-homed, an | |
1351 | * endpoint SHOULD try to retransmit a chunk to an | |
1352 | * active destination transport address that is | |
1353 | * different from the last destination address to | |
1354 | * which the DATA chunk was sent. | |
1355 | */ | |
1356 | struct sctp_transport *retran_path; | |
1357 | ||
1358 | /* Pointer to last transport I have sent on. */ | |
1359 | struct sctp_transport *last_sent_to; | |
1360 | ||
1361 | /* This is the last transport I have received DATA on. */ | |
1362 | struct sctp_transport *last_data_from; | |
1363 | ||
1364 | /* | |
1365 | * Mapping An array of bits or bytes indicating which out of | |
1366 | * Array order TSN's have been received (relative to the | |
1367 | * Last Rcvd TSN). If no gaps exist, i.e. no out of | |
1368 | * order packets have been received, this array | |
1369 | * will be set to all zero. This structure may be | |
1370 | * in the form of a circular buffer or bit array. | |
1371 | * | |
1372 | * Last Rcvd : This is the last TSN received in | |
1373 | * TSN : sequence. This value is set initially by | |
1374 | * : taking the peer's Initial TSN, received in | |
1375 | * : the INIT or INIT ACK chunk, and subtracting | |
1376 | * : one from it. | |
1377 | * | |
1378 | * Throughout most of the specification this is called the | |
1379 | * "Cumulative TSN ACK Point". In this case, we | |
1380 | * ignore the advice in 12.2 in favour of the term | |
1381 | * used in the bulk of the text. This value is hidden | |
1382 | * in tsn_map--we get it by calling sctp_tsnmap_get_ctsn(). | |
1383 | */ | |
1384 | struct sctp_tsnmap tsn_map; | |
1385 | __u8 _map[sctp_tsnmap_storage_size(SCTP_TSN_MAP_SIZE)]; | |
1386 | ||
1387 | /* Ack State : This flag indicates if the next received | |
1388 | * : packet is to be responded to with a | |
1389 | * : SACK. This is initializedto 0. When a packet | |
1390 | * : is received it is incremented. If this value | |
1391 | * : reaches 2 or more, a SACK is sent and the | |
1392 | * : value is reset to 0. Note: This is used only | |
1393 | * : when no DATA chunks are received out of | |
1394 | * : order. When DATA chunks are out of order, | |
1395 | * : SACK's are not delayed (see Section 6). | |
1396 | */ | |
1397 | __u8 sack_needed; /* Do we need to sack the peer? */ | |
1398 | ||
1399 | /* These are capabilities which our peer advertised. */ | |
1400 | __u8 ecn_capable; /* Can peer do ECN? */ | |
1401 | __u8 ipv4_address; /* Peer understands IPv4 addresses? */ | |
1402 | __u8 ipv6_address; /* Peer understands IPv6 addresses? */ | |
1403 | __u8 hostname_address;/* Peer understands DNS addresses? */ | |
1404 | __u8 asconf_capable; /* Does peer support ADDIP? */ | |
1405 | __u8 prsctp_capable; /* Can peer do PR-SCTP? */ | |
1406 | ||
1407 | __u32 adaption_ind; /* Adaption Code point. */ | |
1408 | ||
1409 | /* This mask is used to disable sending the ASCONF chunk | |
1410 | * with specified parameter to peer. | |
1411 | */ | |
1412 | __u16 addip_disabled_mask; | |
1413 | ||
1414 | struct sctp_inithdr i; | |
1415 | int cookie_len; | |
1416 | void *cookie; | |
1417 | ||
1418 | /* ADDIP Section 4.2 Upon reception of an ASCONF Chunk. | |
1419 | * C1) ... "Peer-Serial-Number'. This value MUST be initialized to the | |
1420 | * Initial TSN Value minus 1 | |
1421 | */ | |
1422 | __u32 addip_serial; | |
1423 | } peer; | |
1424 | ||
1425 | /* State : A state variable indicating what state the | |
1426 | * : association is in, i.e. COOKIE-WAIT, | |
1427 | * : COOKIE-ECHOED, ESTABLISHED, SHUTDOWN-PENDING, | |
1428 | * : SHUTDOWN-SENT, SHUTDOWN-RECEIVED, SHUTDOWN-ACK-SENT. | |
1429 | * | |
1430 | * Note: No "CLOSED" state is illustrated since if a | |
1431 | * association is "CLOSED" its TCB SHOULD be removed. | |
1432 | * | |
1433 | * In this implementation we DO have a CLOSED | |
1434 | * state which is used during initiation and shutdown. | |
1435 | * | |
1436 | * State takes values from SCTP_STATE_*. | |
1437 | */ | |
1438 | sctp_state_t state; | |
1439 | ||
1440 | /* The cookie life I award for any cookie. */ | |
1441 | struct timeval cookie_life; | |
1442 | ||
1443 | /* Overall : The overall association error count. | |
1444 | * Error Count : [Clear this any time I get something.] | |
1445 | */ | |
1446 | int overall_error_count; | |
1447 | ||
1448 | /* These are the association's initial, max, and min RTO values. | |
1449 | * These values will be initialized by system defaults, but can | |
1450 | * be modified via the SCTP_RTOINFO socket option. | |
1451 | */ | |
1452 | __u32 rto_initial; | |
1453 | __u32 rto_max; | |
1454 | __u32 rto_min; | |
1455 | ||
1456 | /* Maximum number of new data packets that can be sent in a burst. */ | |
1457 | int max_burst; | |
1458 | ||
1459 | /* This is the max_retrans value for the association. This value will | |
1460 | * be initialized initialized from system defaults, but can be | |
1461 | * modified by the SCTP_ASSOCINFO socket option. | |
1462 | */ | |
1463 | int max_retrans; | |
1464 | ||
1465 | /* Maximum number of times the endpoint will retransmit INIT */ | |
1466 | __u16 max_init_attempts; | |
1467 | ||
1468 | /* How many times have we resent an INIT? */ | |
1469 | __u16 init_retries; | |
1470 | ||
1471 | /* The largest timeout or RTO value to use in attempting an INIT */ | |
1472 | __u16 max_init_timeo; | |
1473 | ||
1474 | int timeouts[SCTP_NUM_TIMEOUT_TYPES]; | |
1475 | struct timer_list timers[SCTP_NUM_TIMEOUT_TYPES]; | |
1476 | ||
1477 | /* Transport to which SHUTDOWN chunk was last sent. */ | |
1478 | struct sctp_transport *shutdown_last_sent_to; | |
1479 | ||
1480 | /* Next TSN : The next TSN number to be assigned to a new | |
1481 | * : DATA chunk. This is sent in the INIT or INIT | |
1482 | * : ACK chunk to the peer and incremented each | |
1483 | * : time a DATA chunk is assigned a TSN | |
1484 | * : (normally just prior to transmit or during | |
1485 | * : fragmentation). | |
1486 | */ | |
1487 | __u32 next_tsn; | |
1488 | ||
1489 | /* | |
1490 | * Last Rcvd : This is the last TSN received in sequence. This value | |
1491 | * TSN : is set initially by taking the peer's Initial TSN, | |
1492 | * : received in the INIT or INIT ACK chunk, and | |
1493 | * : subtracting one from it. | |
1494 | * | |
1495 | * Most of RFC 2960 refers to this as the Cumulative TSN Ack Point. | |
1496 | */ | |
1497 | ||
1498 | __u32 ctsn_ack_point; | |
1499 | ||
1500 | /* PR-SCTP Advanced.Peer.Ack.Point */ | |
1501 | __u32 adv_peer_ack_point; | |
1502 | ||
1503 | /* Highest TSN that is acknowledged by incoming SACKs. */ | |
1504 | __u32 highest_sacked; | |
1505 | ||
1506 | /* The number of unacknowledged data chunks. Reported through | |
1507 | * the SCTP_STATUS sockopt. | |
1508 | */ | |
1509 | __u16 unack_data; | |
1510 | ||
1511 | /* This is the association's receive buffer space. This value is used | |
1512 | * to set a_rwnd field in an INIT or a SACK chunk. | |
1513 | */ | |
1514 | __u32 rwnd; | |
1515 | ||
1516 | /* This is the last advertised value of rwnd over a SACK chunk. */ | |
1517 | __u32 a_rwnd; | |
1518 | ||
1519 | /* Number of bytes by which the rwnd has slopped. The rwnd is allowed | |
1520 | * to slop over a maximum of the association's frag_point. | |
1521 | */ | |
1522 | __u32 rwnd_over; | |
1523 | ||
1524 | /* This is the sndbuf size in use for the association. | |
1525 | * This corresponds to the sndbuf size for the association, | |
1526 | * as specified in the sk->sndbuf. | |
1527 | */ | |
1528 | int sndbuf_used; | |
1529 | ||
1530 | /* This is the wait queue head for send requests waiting on | |
1531 | * the association sndbuf space. | |
1532 | */ | |
1533 | wait_queue_head_t wait; | |
1534 | ||
1535 | /* Association : The smallest PMTU discovered for all of the | |
1536 | * PMTU : peer's transport addresses. | |
1537 | */ | |
1538 | __u32 pmtu; | |
1539 | ||
1540 | /* The message size at which SCTP fragmentation will occur. */ | |
1541 | __u32 frag_point; | |
1542 | ||
1543 | /* Currently only one counter is used to count INIT errors. */ | |
1544 | int counters[SCTP_NUMBER_COUNTERS]; | |
1545 | ||
1546 | /* Default send parameters. */ | |
1547 | __u16 default_stream; | |
1548 | __u16 default_flags; | |
1549 | __u32 default_ppid; | |
1550 | __u32 default_context; | |
1551 | __u32 default_timetolive; | |
1552 | ||
1553 | /* This tracks outbound ssn for a given stream. */ | |
1554 | struct sctp_ssnmap *ssnmap; | |
1555 | ||
1556 | /* All outbound chunks go through this structure. */ | |
1557 | struct sctp_outq outqueue; | |
1558 | ||
1559 | /* A smart pipe that will handle reordering and fragmentation, | |
1560 | * as well as handle passing events up to the ULP. | |
1561 | */ | |
1562 | struct sctp_ulpq ulpq; | |
1563 | ||
1564 | /* Last TSN that caused an ECNE Chunk to be sent. */ | |
1565 | __u32 last_ecne_tsn; | |
1566 | ||
1567 | /* Last TSN that caused a CWR Chunk to be sent. */ | |
1568 | __u32 last_cwr_tsn; | |
1569 | ||
1570 | /* How many duplicated TSNs have we seen? */ | |
1571 | int numduptsns; | |
1572 | ||
1573 | /* Number of seconds of idle time before an association is closed. */ | |
1574 | __u32 autoclose; | |
1575 | ||
1576 | /* These are to support | |
1577 | * "SCTP Extensions for Dynamic Reconfiguration of IP Addresses | |
1578 | * and Enforcement of Flow and Message Limits" | |
1579 | * <draft-ietf-tsvwg-addip-sctp-02.txt> | |
1580 | * or "ADDIP" for short. | |
1581 | */ | |
1582 | ||
1583 | ||
1584 | ||
1585 | /* ADDIP Section 4.1.1 Congestion Control of ASCONF Chunks | |
1586 | * | |
1587 | * R1) One and only one ASCONF Chunk MAY be in transit and | |
1588 | * unacknowledged at any one time. If a sender, after sending | |
1589 | * an ASCONF chunk, decides it needs to transfer another | |
1590 | * ASCONF Chunk, it MUST wait until the ASCONF-ACK Chunk | |
1591 | * returns from the previous ASCONF Chunk before sending a | |
1592 | * subsequent ASCONF. Note this restriction binds each side, | |
1593 | * so at any time two ASCONF may be in-transit on any given | |
1594 | * association (one sent from each endpoint). | |
1595 | * | |
1596 | * [This is our one-and-only-one ASCONF in flight. If we do | |
1597 | * not have an ASCONF in flight, this is NULL.] | |
1598 | */ | |
1599 | struct sctp_chunk *addip_last_asconf; | |
1600 | ||
1601 | /* ADDIP Section 4.2 Upon reception of an ASCONF Chunk. | |
1602 | * | |
1603 | * IMPLEMENTATION NOTE: As an optimization a receiver may wish | |
1604 | * to save the last ASCONF-ACK for some predetermined period | |
1605 | * of time and instead of re-processing the ASCONF (with the | |
1606 | * same serial number) it may just re-transmit the | |
1607 | * ASCONF-ACK. It may wish to use the arrival of a new serial | |
1608 | * number to discard the previously saved ASCONF-ACK or any | |
1609 | * other means it may choose to expire the saved ASCONF-ACK. | |
1610 | * | |
1611 | * [This is our saved ASCONF-ACK. We invalidate it when a new | |
1612 | * ASCONF serial number arrives.] | |
1613 | */ | |
1614 | struct sctp_chunk *addip_last_asconf_ack; | |
1615 | ||
1616 | /* These ASCONF chunks are waiting to be sent. | |
1617 | * | |
1618 | * These chunaks can't be pushed to outqueue until receiving | |
1619 | * ASCONF_ACK for the previous ASCONF indicated by | |
1620 | * addip_last_asconf, so as to guarantee that only one ASCONF | |
1621 | * is in flight at any time. | |
1622 | * | |
1623 | * ADDIP Section 4.1.1 Congestion Control of ASCONF Chunks | |
1624 | * | |
1625 | * In defining the ASCONF Chunk transfer procedures, it is | |
1626 | * essential that these transfers MUST NOT cause congestion | |
1627 | * within the network. To achieve this, we place these | |
1628 | * restrictions on the transfer of ASCONF Chunks: | |
1629 | * | |
1630 | * R1) One and only one ASCONF Chunk MAY be in transit and | |
1631 | * unacknowledged at any one time. If a sender, after sending | |
1632 | * an ASCONF chunk, decides it needs to transfer another | |
1633 | * ASCONF Chunk, it MUST wait until the ASCONF-ACK Chunk | |
1634 | * returns from the previous ASCONF Chunk before sending a | |
1635 | * subsequent ASCONF. Note this restriction binds each side, | |
1636 | * so at any time two ASCONF may be in-transit on any given | |
1637 | * association (one sent from each endpoint). | |
1638 | * | |
1639 | * | |
1640 | * [I really think this is EXACTLY the sort of intelligence | |
1641 | * which already resides in sctp_outq. Please move this | |
1642 | * queue and its supporting logic down there. --piggy] | |
1643 | */ | |
1644 | struct sk_buff_head addip_chunks; | |
1645 | ||
1646 | /* ADDIP Section 4.1 ASCONF Chunk Procedures | |
1647 | * | |
1648 | * A2) A serial number should be assigned to the Chunk. The | |
1649 | * serial number SHOULD be a monotonically increasing | |
1650 | * number. The serial number SHOULD be initialized at | |
1651 | * the start of the association to the same value as the | |
1652 | * Initial TSN and every time a new ASCONF chunk is created | |
1653 | * it is incremented by one after assigning the serial number | |
1654 | * to the newly created chunk. | |
1655 | * | |
1656 | * ADDIP | |
1657 | * 3.1.1 Address/Stream Configuration Change Chunk (ASCONF) | |
1658 | * | |
1659 | * Serial Number : 32 bits (unsigned integer) | |
1660 | * | |
1661 | * This value represents a Serial Number for the ASCONF | |
1662 | * Chunk. The valid range of Serial Number is from 0 to | |
1663 | * 4294967295 (2^32 - 1). Serial Numbers wrap back to 0 | |
1664 | * after reaching 4294967295. | |
1665 | */ | |
1666 | __u32 addip_serial; | |
1667 | ||
1668 | /* Need to send an ECNE Chunk? */ | |
1669 | char need_ecne; | |
1670 | ||
1671 | /* Is it a temporary association? */ | |
1672 | char temp; | |
1673 | }; | |
1674 | ||
1675 | ||
1676 | /* An eyecatcher for determining if we are really looking at an | |
1677 | * association data structure. | |
1678 | */ | |
1679 | enum { | |
1680 | SCTP_ASSOC_EYECATCHER = 0xa550c123, | |
1681 | }; | |
1682 | ||
1683 | /* Recover the outter association structure. */ | |
1684 | static inline struct sctp_association *sctp_assoc(struct sctp_ep_common *base) | |
1685 | { | |
1686 | struct sctp_association *asoc; | |
1687 | ||
1688 | asoc = container_of(base, struct sctp_association, base); | |
1689 | return asoc; | |
1690 | } | |
1691 | ||
1692 | /* These are function signatures for manipulating associations. */ | |
1693 | ||
1694 | ||
1695 | struct sctp_association * | |
1696 | sctp_association_new(const struct sctp_endpoint *, const struct sock *, | |
1697 | sctp_scope_t scope, int gfp); | |
1698 | void sctp_association_free(struct sctp_association *); | |
1699 | void sctp_association_put(struct sctp_association *); | |
1700 | void sctp_association_hold(struct sctp_association *); | |
1701 | ||
1702 | struct sctp_transport *sctp_assoc_choose_shutdown_transport( | |
1703 | struct sctp_association *); | |
1704 | void sctp_assoc_update_retran_path(struct sctp_association *); | |
1705 | struct sctp_transport *sctp_assoc_lookup_paddr(const struct sctp_association *, | |
1706 | const union sctp_addr *); | |
1707 | int sctp_assoc_lookup_laddr(struct sctp_association *asoc, | |
1708 | const union sctp_addr *laddr); | |
1709 | struct sctp_transport *sctp_assoc_add_peer(struct sctp_association *, | |
1710 | const union sctp_addr *address, | |
1711 | const int gfp); | |
1712 | void sctp_assoc_del_peer(struct sctp_association *asoc, | |
1713 | const union sctp_addr *addr); | |
1714 | void sctp_assoc_control_transport(struct sctp_association *, | |
1715 | struct sctp_transport *, | |
1716 | sctp_transport_cmd_t, sctp_sn_error_t); | |
1717 | struct sctp_transport *sctp_assoc_lookup_tsn(struct sctp_association *, __u32); | |
1718 | struct sctp_transport *sctp_assoc_is_match(struct sctp_association *, | |
1719 | const union sctp_addr *, | |
1720 | const union sctp_addr *); | |
1721 | void sctp_assoc_migrate(struct sctp_association *, struct sock *); | |
1722 | void sctp_assoc_update(struct sctp_association *old, | |
1723 | struct sctp_association *new); | |
1724 | ||
1725 | __u32 sctp_association_get_next_tsn(struct sctp_association *); | |
1726 | ||
1727 | void sctp_assoc_sync_pmtu(struct sctp_association *); | |
1728 | void sctp_assoc_rwnd_increase(struct sctp_association *, unsigned); | |
1729 | void sctp_assoc_rwnd_decrease(struct sctp_association *, unsigned); | |
1730 | void sctp_assoc_set_primary(struct sctp_association *, | |
1731 | struct sctp_transport *); | |
1732 | int sctp_assoc_set_bind_addr_from_ep(struct sctp_association *, int); | |
1733 | int sctp_assoc_set_bind_addr_from_cookie(struct sctp_association *, | |
1734 | struct sctp_cookie*, int gfp); | |
1735 | ||
1736 | int sctp_cmp_addr_exact(const union sctp_addr *ss1, | |
1737 | const union sctp_addr *ss2); | |
1738 | struct sctp_chunk *sctp_get_ecne_prepend(struct sctp_association *asoc); | |
1739 | ||
1740 | /* A convenience structure to parse out SCTP specific CMSGs. */ | |
1741 | typedef struct sctp_cmsgs { | |
1742 | struct sctp_initmsg *init; | |
1743 | struct sctp_sndrcvinfo *info; | |
1744 | } sctp_cmsgs_t; | |
1745 | ||
1746 | /* Structure for tracking memory objects */ | |
1747 | typedef struct { | |
1748 | char *label; | |
1749 | atomic_t *counter; | |
1750 | } sctp_dbg_objcnt_entry_t; | |
1751 | ||
1752 | #endif /* __sctp_structs_h__ */ |