]> CyberLeo.Net >> Repos - FreeBSD/releng/8.0.git/blob - sys/netinet/sctp_structs.h
Adjust to reflect 8.0-RELEASE.
[FreeBSD/releng/8.0.git] / sys / netinet / sctp_structs.h
1 /*-
2  * Copyright (c) 2001-2008, by Cisco Systems, Inc. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions are met:
6  *
7  * a) Redistributions of source code must retain the above copyright notice,
8  *   this list of conditions and the following disclaimer.
9  *
10  * b) Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in
12  *   the documentation and/or other materials provided with the distribution.
13  *
14  * c) Neither the name of Cisco Systems, Inc. nor the names of its
15  *    contributors may be used to endorse or promote products derived
16  *    from this software without specific prior written permission.
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
20  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
22  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
28  * THE POSSIBILITY OF SUCH DAMAGE.
29  */
30
31 /* $KAME: sctp_structs.h,v 1.13 2005/03/06 16:04:18 itojun Exp $         */
32
33 #include <sys/cdefs.h>
34 __FBSDID("$FreeBSD$");
35
36 #ifndef __sctp_structs_h__
37 #define __sctp_structs_h__
38
39 #include <netinet/sctp_os.h>
40 #include <netinet/sctp_header.h>
41 #include <netinet/sctp_auth.h>
42
43 struct sctp_timer {
44         sctp_os_timer_t timer;
45
46         int type;
47         /*
48          * Depending on the timer type these will be setup and cast with the
49          * appropriate entity.
50          */
51         void *ep;
52         void *tcb;
53         void *net;
54
55         /* for sanity checking */
56         void *self;
57         uint32_t ticks;
58         uint32_t stopped_from;
59 };
60
61
62 struct sctp_foo_stuff {
63         struct sctp_inpcb *inp;
64         uint32_t lineno;
65         uint32_t ticks;
66         int updown;
67 };
68
69
70 /*
71  * This is the information we track on each interface that we know about from
72  * the distant end.
73  */
74 TAILQ_HEAD(sctpnetlisthead, sctp_nets);
75
76 struct sctp_stream_reset_list {
77         TAILQ_ENTRY(sctp_stream_reset_list) next_resp;
78         uint32_t tsn;
79         int number_entries;
80         struct sctp_stream_reset_out_request req;
81 };
82
83 TAILQ_HEAD(sctp_resethead, sctp_stream_reset_list);
84
85 /*
86  * Users of the iterator need to malloc a iterator with a call to
87  * sctp_initiate_iterator(inp_func, assoc_func, inp_func,  pcb_flags, pcb_features,
88  *     asoc_state, void-ptr-arg, uint32-arg, end_func, inp);
89  *
90  * Use the following two defines if you don't care what pcb flags are on the EP
91  * and/or you don't care what state the association is in.
92  *
93  * Note that if you specify an INP as the last argument then ONLY each
94  * association of that single INP will be executed upon. Note that the pcb
95  * flags STILL apply so if the inp you specify has different pcb_flags then
96  * what you put in pcb_flags nothing will happen. use SCTP_PCB_ANY_FLAGS to
97  * assure the inp you specify gets treated.
98  */
99 #define SCTP_PCB_ANY_FLAGS      0x00000000
100 #define SCTP_PCB_ANY_FEATURES   0x00000000
101 #define SCTP_ASOC_ANY_STATE     0x00000000
102
103 typedef void (*asoc_func) (struct sctp_inpcb *, struct sctp_tcb *, void *ptr,
104          uint32_t val);
105 typedef int (*inp_func) (struct sctp_inpcb *, void *ptr, uint32_t val);
106 typedef void (*end_func) (void *ptr, uint32_t val);
107
108 struct sctp_iterator {
109         TAILQ_ENTRY(sctp_iterator) sctp_nxt_itr;
110         struct sctp_timer tmr;
111         struct sctp_inpcb *inp; /* current endpoint */
112         struct sctp_tcb *stcb;  /* current* assoc */
113         asoc_func function_assoc;       /* per assoc function */
114         inp_func function_inp;  /* per endpoint function */
115         inp_func function_inp_end;      /* end INP function */
116         end_func function_atend;/* iterator completion function */
117         void *pointer;          /* pointer for apply func to use */
118         uint32_t val;           /* value for apply func to use */
119         uint32_t pcb_flags;     /* endpoint flags being checked */
120         uint32_t pcb_features;  /* endpoint features being checked */
121         uint32_t asoc_state;    /* assoc state being checked */
122         uint32_t iterator_flags;
123         uint8_t no_chunk_output;
124         uint8_t done_current_ep;
125 };
126
127 /* iterator_flags values */
128 #define SCTP_ITERATOR_DO_ALL_INP        0x00000001
129 #define SCTP_ITERATOR_DO_SINGLE_INP     0x00000002
130
131 TAILQ_HEAD(sctpiterators, sctp_iterator);
132
133 struct sctp_copy_all {
134         struct sctp_inpcb *inp; /* ep */
135         struct mbuf *m;
136         struct sctp_sndrcvinfo sndrcv;
137         int sndlen;
138         int cnt_sent;
139         int cnt_failed;
140 };
141
142 struct sctp_asconf_iterator {
143         struct sctpladdr list_of_work;
144         int cnt;
145 };
146
147 struct sctp_net_route {
148         sctp_rtentry_t *ro_rt;
149         void *ro_lle;
150         union sctp_sockstore _l_addr;   /* remote peer addr */
151         struct sctp_ifa *_s_addr;       /* our selected src addr */
152 };
153
154 struct htcp {
155         uint16_t alpha;         /* Fixed point arith, << 7 */
156         uint8_t beta;           /* Fixed point arith, << 7 */
157         uint8_t modeswitch;     /* Delay modeswitch until we had at least one
158                                  * congestion event */
159         uint32_t last_cong;     /* Time since last congestion event end */
160         uint32_t undo_last_cong;
161         uint16_t bytes_acked;
162         uint32_t bytecount;
163         uint32_t minRTT;
164         uint32_t maxRTT;
165
166         uint32_t undo_maxRTT;
167         uint32_t undo_old_maxB;
168
169         /* Bandwidth estimation */
170         uint32_t minB;
171         uint32_t maxB;
172         uint32_t old_maxB;
173         uint32_t Bi;
174         uint32_t lasttime;
175 };
176
177
178 struct sctp_nets {
179         TAILQ_ENTRY(sctp_nets) sctp_next;       /* next link */
180
181         /*
182          * Things on the top half may be able to be split into a common
183          * structure shared by all.
184          */
185         struct sctp_timer pmtu_timer;
186
187         /*
188          * The following two in combination equate to a route entry for v6
189          * or v4.
190          */
191         struct sctp_net_route ro;
192
193         /* mtu discovered so far */
194         uint32_t mtu;
195         uint32_t ssthresh;      /* not sure about this one for split */
196
197         /* smoothed average things for RTT and RTO itself */
198         int lastsa;
199         int lastsv;
200         int rtt;                /* last measured rtt value in ms */
201         unsigned int RTO;
202
203         /* This is used for SHUTDOWN/SHUTDOWN-ACK/SEND or INIT timers */
204         struct sctp_timer rxt_timer;
205         struct sctp_timer fr_timer;     /* for early fr */
206
207         /* last time in seconds I sent to it */
208         struct timeval last_sent_time;
209         int ref_count;
210
211         /* Congestion stats per destination */
212         /*
213          * flight size variables and such, sorry Vern, I could not avoid
214          * this if I wanted performance :>
215          */
216         uint32_t flight_size;
217         uint32_t cwnd;          /* actual cwnd */
218         uint32_t prev_cwnd;     /* cwnd before any processing */
219         uint32_t partial_bytes_acked;   /* in CA tracks when to incr a MTU */
220         uint32_t prev_rtt;
221         /* tracking variables to avoid the aloc/free in sack processing */
222         unsigned int net_ack;
223         unsigned int net_ack2;
224
225         /*
226          * JRS - 5/8/07 - Variable to track last time a destination was
227          * active for CMT PF
228          */
229         uint32_t last_active;
230
231         /*
232          * CMT variables (iyengar@cis.udel.edu)
233          */
234         uint32_t this_sack_highest_newack;      /* tracks highest TSN newly
235                                                  * acked for a given dest in
236                                                  * the current SACK. Used in
237                                                  * SFR and HTNA algos */
238         uint32_t pseudo_cumack; /* CMT CUC algorithm. Maintains next expected
239                                  * pseudo-cumack for this destination */
240         uint32_t rtx_pseudo_cumack;     /* CMT CUC algorithm. Maintains next
241                                          * expected pseudo-cumack for this
242                                          * destination */
243
244         /* CMT fast recovery variables */
245         uint32_t fast_recovery_tsn;
246         uint32_t heartbeat_random1;
247         uint32_t heartbeat_random2;
248         uint32_t tos_flowlabel;
249
250         struct timeval start_time;      /* time when this net was created */
251
252         uint32_t marked_retrans;/* number or DATA chunks marked for timer
253                                  * based retransmissions */
254         uint32_t marked_fastretrans;
255
256         /* if this guy is ok or not ... status */
257         uint16_t dest_state;
258         /* number of transmit failures to down this guy */
259         uint16_t failure_threshold;
260         /* error stats on destination */
261         uint16_t error_count;
262         /* UDP port number in case of UDP tunneling */
263         uint16_t port;
264
265         uint8_t fast_retran_loss_recovery;
266         uint8_t will_exit_fast_recovery;
267         /* Flags that probably can be combined into dest_state */
268         uint8_t fast_retran_ip; /* fast retransmit in progress */
269         uint8_t hb_responded;
270         uint8_t saw_newack;     /* CMT's SFR algorithm flag */
271         uint8_t src_addr_selected;      /* if we split we move */
272         uint8_t indx_of_eligible_next_to_use;
273         uint8_t addr_is_local;  /* its a local address (if known) could move
274                                  * in split */
275
276         /*
277          * CMT variables (iyengar@cis.udel.edu)
278          */
279         uint8_t find_pseudo_cumack;     /* CMT CUC algorithm. Flag used to
280                                          * find a new pseudocumack. This flag
281                                          * is set after a new pseudo-cumack
282                                          * has been received and indicates
283                                          * that the sender should find the
284                                          * next pseudo-cumack expected for
285                                          * this destination */
286         uint8_t find_rtx_pseudo_cumack; /* CMT CUCv2 algorithm. Flag used to
287                                          * find a new rtx-pseudocumack. This
288                                          * flag is set after a new
289                                          * rtx-pseudo-cumack has been received
290                                          * and indicates that the sender
291                                          * should find the next
292                                          * rtx-pseudo-cumack expected for this
293                                          * destination */
294         uint8_t new_pseudo_cumack;      /* CMT CUC algorithm. Flag used to
295                                          * indicate if a new pseudo-cumack or
296                                          * rtx-pseudo-cumack has been received */
297         uint8_t window_probe;   /* Doing a window probe? */
298         uint8_t RTO_measured;   /* Have we done the first measure */
299         uint8_t last_hs_used;   /* index into the last HS table entry we used */
300         /* JRS - struct used in HTCP algorithm */
301         struct htcp htcp_ca;
302 };
303
304
305 struct sctp_data_chunkrec {
306         uint32_t TSN_seq;       /* the TSN of this transmit */
307         uint16_t stream_seq;    /* the stream sequence number of this transmit */
308         uint16_t stream_number; /* the stream number of this guy */
309         uint32_t payloadtype;
310         uint32_t context;       /* from send */
311
312         /* ECN Nonce: Nonce Value for this chunk */
313         uint8_t ect_nonce;
314         uint8_t fwd_tsn_cnt;
315         /*
316          * part of the Highest sacked algorithm to be able to stroke counts
317          * on ones that are FR'd.
318          */
319         uint32_t fast_retran_tsn;       /* sending_seq at the time of FR */
320         struct timeval timetodrop;      /* time we drop it from queue */
321         uint8_t doing_fast_retransmit;
322         uint8_t rcv_flags;      /* flags pulled from data chunk on inbound for
323                                  * outbound holds sending flags for PR-SCTP. */
324         uint8_t state_flags;
325         uint8_t chunk_was_revoked;
326 };
327
328 TAILQ_HEAD(sctpchunk_listhead, sctp_tmit_chunk);
329
330 /* The lower byte is used to enumerate PR_SCTP policies */
331 #define CHUNK_FLAGS_PR_SCTP_TTL         SCTP_PR_SCTP_TTL
332 #define CHUNK_FLAGS_PR_SCTP_BUF         SCTP_PR_SCTP_BUF
333 #define CHUNK_FLAGS_PR_SCTP_RTX         SCTP_PR_SCTP_RTX
334
335 /* The upper byte is used a a bit mask */
336 #define CHUNK_FLAGS_FRAGMENT_OK         0x0100
337
338 struct chk_id {
339         uint16_t id;
340         uint16_t can_take_data;
341 };
342
343
344 struct sctp_tmit_chunk {
345         union {
346                 struct sctp_data_chunkrec data;
347                 struct chk_id chunk_id;
348         }     rec;
349         struct sctp_association *asoc;  /* bp to asoc this belongs to */
350         struct timeval sent_rcv_time;   /* filled in if RTT being calculated */
351         struct mbuf *data;      /* pointer to mbuf chain of data */
352         struct mbuf *last_mbuf; /* pointer to last mbuf in chain */
353         struct sctp_nets *whoTo;
354                   TAILQ_ENTRY(sctp_tmit_chunk) sctp_next;       /* next link */
355         int32_t sent;           /* the send status */
356         uint16_t snd_count;     /* number of times I sent */
357         uint16_t flags;         /* flags, such as FRAGMENT_OK */
358         uint16_t send_size;
359         uint16_t book_size;
360         uint16_t mbcnt;
361         uint16_t auth_keyid;
362         uint8_t holds_key_ref;  /* flag if auth keyid refcount is held */
363         uint8_t pad_inplace;
364         uint8_t do_rtt;
365         uint8_t book_size_scale;
366         uint8_t addr_over;      /* flag which is set if the dest address for
367                                  * this chunk is overridden by user. Used for
368                                  * CMT (iyengar@cis.udel.edu, 2005/06/21) */
369         uint8_t no_fr_allowed;
370         uint8_t pr_sctp_on;
371         uint8_t copy_by_ref;
372         uint8_t window_probe;
373 };
374
375 /*
376  * The first part of this structure MUST be the entire sinfo structure. Maybe
377  * I should have made it a sub structure... we can circle back later and do
378  * that if we want.
379  */
380 struct sctp_queued_to_read {    /* sinfo structure Pluse more */
381         uint16_t sinfo_stream;  /* off the wire */
382         uint16_t sinfo_ssn;     /* off the wire */
383         uint16_t sinfo_flags;   /* SCTP_UNORDERED from wire use SCTP_EOF for
384                                  * EOR */
385         uint32_t sinfo_ppid;    /* off the wire */
386         uint32_t sinfo_context; /* pick this up from assoc def context? */
387         uint32_t sinfo_timetolive;      /* not used by kernel */
388         uint32_t sinfo_tsn;     /* Use this in reassembly as first TSN */
389         uint32_t sinfo_cumtsn;  /* Use this in reassembly as last TSN */
390         sctp_assoc_t sinfo_assoc_id;    /* our assoc id */
391         /* Non sinfo stuff */
392         uint32_t length;        /* length of data */
393         uint32_t held_length;   /* length held in sb */
394         struct sctp_nets *whoFrom;      /* where it came from */
395         struct mbuf *data;      /* front of the mbuf chain of data with
396                                  * PKT_HDR */
397         struct mbuf *tail_mbuf; /* used for multi-part data */
398         struct mbuf *aux_data;  /* used to hold/cache  control if o/s does not
399                                  * take it from us */
400         struct sctp_tcb *stcb;  /* assoc, used for window update */
401                  TAILQ_ENTRY(sctp_queued_to_read) next;
402         uint16_t port_from;
403         uint16_t spec_flags;    /* Flags to hold the notification field */
404         uint8_t do_not_ref_stcb;
405         uint8_t end_added;
406         uint8_t pdapi_aborted;
407         uint8_t some_taken;
408 };
409
410 /* This data structure will be on the outbound
411  * stream queues. Data will be pulled off from
412  * the front of the mbuf data and chunk-ified
413  * by the output routines. We will custom
414  * fit every chunk we pull to the send/sent
415  * queue to make up the next full packet
416  * if we can. An entry cannot be removed
417  * from the stream_out queue until
418  * the msg_is_complete flag is set. This
419  * means at times data/tail_mbuf MIGHT
420  * be NULL.. If that occurs it happens
421  * for one of two reasons. Either the user
422  * is blocked on a send() call and has not
423  * awoken to copy more data down... OR
424  * the user is in the explict MSG_EOR mode
425  * and wrote some data, but has not completed
426  * sending.
427  */
428 struct sctp_stream_queue_pending {
429         struct mbuf *data;
430         struct mbuf *tail_mbuf;
431         struct timeval ts;
432         struct sctp_nets *net;
433                   TAILQ_ENTRY(sctp_stream_queue_pending) next;
434         uint32_t length;
435         uint32_t timetolive;
436         uint32_t ppid;
437         uint32_t context;
438         uint16_t sinfo_flags;
439         uint16_t stream;
440         uint16_t strseq;
441         uint16_t act_flags;
442         uint16_t auth_keyid;
443         uint8_t holds_key_ref;
444         uint8_t msg_is_complete;
445         uint8_t some_taken;
446         uint8_t addr_over;
447         uint8_t pr_sctp_on;
448         uint8_t sender_all_done;
449         uint8_t put_last_out;
450         uint8_t discard_rest;
451 };
452
453 /*
454  * this struct contains info that is used to track inbound stream data and
455  * help with ordering.
456  */
457 TAILQ_HEAD(sctpwheelunrel_listhead, sctp_stream_in);
458 struct sctp_stream_in {
459         struct sctp_readhead inqueue;
460         uint16_t stream_no;
461         uint16_t last_sequence_delivered;       /* used for re-order */
462         uint8_t delivery_started;
463 };
464
465 /* This struct is used to track the traffic on outbound streams */
466 TAILQ_HEAD(sctpwheel_listhead, sctp_stream_out);
467 struct sctp_stream_out {
468         struct sctp_streamhead outqueue;
469                         TAILQ_ENTRY(sctp_stream_out) next_spoke;        /* next link in wheel */
470         uint16_t stream_no;
471         uint16_t next_sequence_sent;    /* next one I expect to send out */
472         uint8_t last_msg_incomplete;
473 };
474
475 /* used to keep track of the addresses yet to try to add/delete */
476 TAILQ_HEAD(sctp_asconf_addrhead, sctp_asconf_addr);
477 struct sctp_asconf_addr {
478         TAILQ_ENTRY(sctp_asconf_addr) next;
479         struct sctp_asconf_addr_param ap;
480         struct sctp_ifa *ifa;   /* save the ifa for add/del ip */
481         uint8_t sent;           /* has this been sent yet? */
482         uint8_t special_del;    /* not to be used in lookup */
483
484 };
485
486 struct sctp_scoping {
487         uint8_t ipv4_addr_legal;
488         uint8_t ipv6_addr_legal;
489         uint8_t loopback_scope;
490         uint8_t ipv4_local_scope;
491         uint8_t local_scope;
492         uint8_t site_scope;
493 };
494
495 #define SCTP_TSN_LOG_SIZE 40
496
497 struct sctp_tsn_log {
498         void *stcb;
499         uint32_t tsn;
500         uint16_t strm;
501         uint16_t seq;
502         uint16_t sz;
503         uint16_t flgs;
504         uint16_t in_pos;
505         uint16_t in_out;
506 };
507
508 #define SCTP_FS_SPEC_LOG_SIZE 200
509 struct sctp_fs_spec_log {
510         uint32_t sent;
511         uint32_t total_flight;
512         uint32_t tsn;
513         uint16_t book;
514         uint8_t incr;
515         uint8_t decr;
516 };
517
518 /* This struct is here to cut out the compatiabilty
519  * pad that bulks up both the inp and stcb. The non
520  * pad portion MUST stay in complete sync with
521  * sctp_sndrcvinfo... i.e. if sinfo_xxxx is added
522  * this must be done here too.
523  */
524 struct sctp_nonpad_sndrcvinfo {
525         uint16_t sinfo_stream;
526         uint16_t sinfo_ssn;
527         uint16_t sinfo_flags;
528         uint32_t sinfo_ppid;
529         uint32_t sinfo_context;
530         uint32_t sinfo_timetolive;
531         uint32_t sinfo_tsn;
532         uint32_t sinfo_cumtsn;
533         sctp_assoc_t sinfo_assoc_id;
534 };
535
536 /*
537  * JRS - Structure to hold function pointers to the functions responsible
538  * for congestion control.
539  */
540
541 struct sctp_cc_functions {
542         void (*sctp_set_initial_cc_param) (struct sctp_tcb *stcb, struct sctp_nets *net);
543         void (*sctp_cwnd_update_after_sack) (struct sctp_tcb *stcb,
544                  struct sctp_association *asoc,
545                  int accum_moved, int reneged_all, int will_exit);
546         void (*sctp_cwnd_update_after_fr) (struct sctp_tcb *stcb,
547                  struct sctp_association *asoc);
548         void (*sctp_cwnd_update_after_timeout) (struct sctp_tcb *stcb,
549                  struct sctp_nets *net);
550         void (*sctp_cwnd_update_after_ecn_echo) (struct sctp_tcb *stcb,
551                  struct sctp_nets *net);
552         void (*sctp_cwnd_update_after_packet_dropped) (struct sctp_tcb *stcb,
553                  struct sctp_nets *net, struct sctp_pktdrop_chunk *cp,
554                  uint32_t * bottle_bw, uint32_t * on_queue);
555         void (*sctp_cwnd_update_after_output) (struct sctp_tcb *stcb,
556                  struct sctp_nets *net, int burst_limit);
557         void (*sctp_cwnd_update_after_fr_timer) (struct sctp_inpcb *inp,
558                  struct sctp_tcb *stcb, struct sctp_nets *net);
559 };
560
561 /* used to save ASCONF chunks for retransmission */
562 TAILQ_HEAD(sctp_asconf_head, sctp_asconf);
563 struct sctp_asconf {
564         TAILQ_ENTRY(sctp_asconf) next;
565         uint32_t serial_number;
566         uint16_t snd_count;
567         struct mbuf *data;
568         uint16_t len;
569 };
570
571 /* used to save ASCONF-ACK chunks for retransmission */
572 TAILQ_HEAD(sctp_asconf_ackhead, sctp_asconf_ack);
573 struct sctp_asconf_ack {
574         TAILQ_ENTRY(sctp_asconf_ack) next;
575         uint32_t serial_number;
576         struct sctp_nets *last_sent_to;
577         struct mbuf *data;
578         uint16_t len;
579 };
580
581 /*
582  * Here we have information about each individual association that we track.
583  * We probably in production would be more dynamic. But for ease of
584  * implementation we will have a fixed array that we hunt for in a linear
585  * fashion.
586  */
587 struct sctp_association {
588         /* association state */
589         int state;
590
591         /* queue of pending addrs to add/delete */
592         struct sctp_asconf_addrhead asconf_queue;
593
594         struct timeval time_entered;    /* time we entered state */
595         struct timeval time_last_rcvd;
596         struct timeval time_last_sent;
597         struct timeval time_last_sat_advance;
598         struct sctp_nonpad_sndrcvinfo def_send;
599
600         /* timers and such */
601         struct sctp_timer hb_timer;     /* hb timer */
602         struct sctp_timer dack_timer;   /* Delayed ack timer */
603         struct sctp_timer asconf_timer; /* asconf */
604         struct sctp_timer strreset_timer;       /* stream reset */
605         struct sctp_timer shut_guard_timer;     /* shutdown guard */
606         struct sctp_timer autoclose_timer;      /* automatic close timer */
607         struct sctp_timer delayed_event_timer;  /* timer for delayed events */
608         struct sctp_timer delete_prim_timer;    /* deleting primary dst */
609
610         /* list of restricted local addresses */
611         struct sctpladdr sctp_restricted_addrs;
612
613         /* last local address pending deletion (waiting for an address add) */
614         struct sctp_ifa *asconf_addr_del_pending;
615         /* Deleted primary destination (used to stop timer) */
616         struct sctp_nets *deleted_primary;
617
618         struct sctpnetlisthead nets;    /* remote address list */
619
620         /* Free chunk list */
621         struct sctpchunk_listhead free_chunks;
622
623         /* Control chunk queue */
624         struct sctpchunk_listhead control_send_queue;
625
626         /* ASCONF chunk queue */
627         struct sctpchunk_listhead asconf_send_queue;
628
629         /*
630          * Once a TSN hits the wire it is moved to the sent_queue. We
631          * maintain two counts here (don't know if any but retran_cnt is
632          * needed). The idea is that the sent_queue_retran_cnt reflects how
633          * many chunks have been marked for retranmission by either T3-rxt
634          * or FR.
635          */
636         struct sctpchunk_listhead sent_queue;
637         struct sctpchunk_listhead send_queue;
638
639         /* re-assembly queue for fragmented chunks on the inbound path */
640         struct sctpchunk_listhead reasmqueue;
641
642         /*
643          * this queue is used when we reach a condition that we can NOT put
644          * data into the socket buffer. We track the size of this queue and
645          * set our rwnd to the space in the socket minus also the
646          * size_on_delivery_queue.
647          */
648         struct sctpwheel_listhead out_wheel;
649
650         /*
651          * This pointer will be set to NULL most of the time. But when we
652          * have a fragmented message, where we could not get out all of the
653          * message at the last send then this will point to the stream to go
654          * get data from.
655          */
656         struct sctp_stream_out *locked_on_sending;
657
658         /* If an iterator is looking at me, this is it */
659         struct sctp_iterator *stcb_starting_point_for_iterator;
660
661         /* ASCONF save the last ASCONF-ACK so we can resend it if necessary */
662         struct sctp_asconf_ackhead asconf_ack_sent;
663
664         /*
665          * pointer to last stream reset queued to control queue by us with
666          * requests.
667          */
668         struct sctp_tmit_chunk *str_reset;
669         /*
670          * if Source Address Selection happening, this will rotate through
671          * the link list.
672          */
673         struct sctp_laddr *last_used_address;
674
675         /* stream arrays */
676         struct sctp_stream_in *strmin;
677         struct sctp_stream_out *strmout;
678         uint8_t *mapping_array;
679         /* primary destination to use */
680         struct sctp_nets *primary_destination;
681         /* For CMT */
682         struct sctp_nets *last_net_cmt_send_started;
683         /* last place I got a data chunk from */
684         struct sctp_nets *last_data_chunk_from;
685         /* last place I got a control from */
686         struct sctp_nets *last_control_chunk_from;
687
688         /* circular looking for output selection */
689         struct sctp_stream_out *last_out_stream;
690
691         /*
692          * wait to the point the cum-ack passes req->send_reset_at_tsn for
693          * any req on the list.
694          */
695         struct sctp_resethead resetHead;
696
697         /* queue of chunks waiting to be sent into the local stack */
698         struct sctp_readhead pending_reply_queue;
699
700         /* JRS - the congestion control functions are in this struct */
701         struct sctp_cc_functions cc_functions;
702         /*
703          * JRS - value to store the currently loaded congestion control
704          * module
705          */
706         uint32_t congestion_control_module;
707
708         uint32_t vrf_id;
709
710         uint32_t cookie_preserve_req;
711         /* ASCONF next seq I am sending out, inits at init-tsn */
712         uint32_t asconf_seq_out;
713         uint32_t asconf_seq_out_acked;
714         /* ASCONF last received ASCONF from peer, starts at peer's TSN-1 */
715         uint32_t asconf_seq_in;
716
717         /* next seq I am sending in str reset messages */
718         uint32_t str_reset_seq_out;
719         /* next seq I am expecting in str reset messages */
720         uint32_t str_reset_seq_in;
721
722         /* various verification tag information */
723         uint32_t my_vtag;       /* The tag to be used. if assoc is re-initited
724                                  * by remote end, and I have unlocked this
725                                  * will be regenerated to a new random value. */
726         uint32_t peer_vtag;     /* The peers last tag */
727
728         uint32_t my_vtag_nonce;
729         uint32_t peer_vtag_nonce;
730
731         uint32_t assoc_id;
732
733         /* This is the SCTP fragmentation threshold */
734         uint32_t smallest_mtu;
735
736         /*
737          * Special hook for Fast retransmit, allows us to track the highest
738          * TSN that is NEW in this SACK if gap ack blocks are present.
739          */
740         uint32_t this_sack_highest_gap;
741
742         /*
743          * The highest consecutive TSN that has been acked by peer on my
744          * sends
745          */
746         uint32_t last_acked_seq;
747
748         /* The next TSN that I will use in sending. */
749         uint32_t sending_seq;
750
751         /* Original seq number I used ??questionable to keep?? */
752         uint32_t init_seq_number;
753
754
755         /* The Advanced Peer Ack Point, as required by the PR-SCTP */
756         /* (A1 in Section 4.2) */
757         uint32_t advanced_peer_ack_point;
758
759         /*
760          * The highest consequetive TSN at the bottom of the mapping array
761          * (for his sends).
762          */
763         uint32_t cumulative_tsn;
764         /*
765          * Used to track the mapping array and its offset bits. This MAY be
766          * lower then cumulative_tsn.
767          */
768         uint32_t mapping_array_base_tsn;
769         /*
770          * used to track highest TSN we have received and is listed in the
771          * mapping array.
772          */
773         uint32_t highest_tsn_inside_map;
774
775         /* EY - new NR variables used for nr_sack based on mapping_array */
776         uint8_t *nr_mapping_array;
777         uint32_t nr_mapping_array_base_tsn;
778         uint32_t highest_tsn_inside_nr_map;
779         uint16_t nr_mapping_array_size;
780
781         uint32_t last_echo_tsn;
782         uint32_t last_cwr_tsn;
783         uint32_t fast_recovery_tsn;
784         uint32_t sat_t3_recovery_tsn;
785         uint32_t tsn_last_delivered;
786         /*
787          * For the pd-api we should re-write this a bit more efficent. We
788          * could have multiple sctp_queued_to_read's that we are building at
789          * once. Now we only do this when we get ready to deliver to the
790          * socket buffer. Note that we depend on the fact that the struct is
791          * "stuck" on the read queue until we finish all the pd-api.
792          */
793         struct sctp_queued_to_read *control_pdapi;
794
795         uint32_t tsn_of_pdapi_last_delivered;
796         uint32_t pdapi_ppid;
797         uint32_t context;
798         uint32_t last_reset_action[SCTP_MAX_RESET_PARAMS];
799         uint32_t last_sending_seq[SCTP_MAX_RESET_PARAMS];
800         uint32_t last_base_tsnsent[SCTP_MAX_RESET_PARAMS];
801 #ifdef SCTP_ASOCLOG_OF_TSNS
802         /*
803          * special log  - This adds considerable size to the asoc, but
804          * provides a log that you can use to detect problems via kgdb.
805          */
806         struct sctp_tsn_log in_tsnlog[SCTP_TSN_LOG_SIZE];
807         struct sctp_tsn_log out_tsnlog[SCTP_TSN_LOG_SIZE];
808         uint32_t cumack_log[SCTP_TSN_LOG_SIZE];
809         uint32_t cumack_logsnt[SCTP_TSN_LOG_SIZE];
810         uint16_t tsn_in_at;
811         uint16_t tsn_out_at;
812         uint16_t tsn_in_wrapped;
813         uint16_t tsn_out_wrapped;
814         uint16_t cumack_log_at;
815         uint16_t cumack_log_atsnt;
816 #endif                          /* SCTP_ASOCLOG_OF_TSNS */
817 #ifdef SCTP_FS_SPEC_LOG
818         struct sctp_fs_spec_log fslog[SCTP_FS_SPEC_LOG_SIZE];
819         uint16_t fs_index;
820 #endif
821
822         /*
823          * window state information and smallest MTU that I use to bound
824          * segmentation
825          */
826         uint32_t peers_rwnd;
827         uint32_t my_rwnd;
828         uint32_t my_last_reported_rwnd;
829         uint32_t sctp_frag_point;
830
831         uint32_t total_output_queue_size;
832
833         uint32_t sb_cc;         /* shadow of sb_cc */
834         uint32_t sb_send_resv;  /* amount reserved on a send */
835         uint32_t my_rwnd_control_len;   /* shadow of sb_mbcnt used for rwnd
836                                          * control */
837         /* 32 bit nonce stuff */
838         uint32_t nonce_resync_tsn;
839         uint32_t nonce_wait_tsn;
840         uint32_t default_flowlabel;
841         uint32_t pr_sctp_cnt;
842         int ctrl_queue_cnt;     /* could be removed  REM */
843         /*
844          * All outbound datagrams queue into this list from the individual
845          * stream queue. Here they get assigned a TSN and then await
846          * sending. The stream seq comes when it is first put in the
847          * individual str queue
848          */
849         unsigned int stream_queue_cnt;
850         unsigned int send_queue_cnt;
851         unsigned int sent_queue_cnt;
852         unsigned int sent_queue_cnt_removeable;
853         /*
854          * Number on sent queue that are marked for retran until this value
855          * is 0 we only send one packet of retran'ed data.
856          */
857         unsigned int sent_queue_retran_cnt;
858
859         unsigned int size_on_reasm_queue;
860         unsigned int cnt_on_reasm_queue;
861         /* amount of data (bytes) currently in flight (on all destinations) */
862         unsigned int total_flight;
863         /* Total book size in flight */
864         unsigned int total_flight_count;        /* count of chunks used with
865                                                  * book total */
866         /* count of destinaton nets and list of destination nets */
867         unsigned int numnets;
868
869         /* Total error count on this association */
870         unsigned int overall_error_count;
871
872         unsigned int cnt_msg_on_sb;
873
874         /* All stream count of chunks for delivery */
875         unsigned int size_on_all_streams;
876         unsigned int cnt_on_all_streams;
877
878         /* Heart Beat delay in ticks */
879         unsigned int heart_beat_delay;
880
881         /* autoclose */
882         unsigned int sctp_autoclose_ticks;
883
884         /* how many preopen streams we have */
885         unsigned int pre_open_streams;
886
887         /* How many streams I support coming into me */
888         unsigned int max_inbound_streams;
889
890         /* the cookie life I award for any cookie, in seconds */
891         unsigned int cookie_life;
892         /* time to delay acks for */
893         unsigned int delayed_ack;
894         unsigned int old_delayed_ack;
895         unsigned int sack_freq;
896         unsigned int data_pkts_seen;
897
898         unsigned int numduptsns;
899         int dup_tsns[SCTP_MAX_DUP_TSNS];
900         unsigned int initial_init_rto_max;      /* initial RTO for INIT's */
901         unsigned int initial_rto;       /* initial send RTO */
902         unsigned int minrto;    /* per assoc RTO-MIN */
903         unsigned int maxrto;    /* per assoc RTO-MAX */
904
905         /* authentication fields */
906         sctp_auth_chklist_t *local_auth_chunks;
907         sctp_auth_chklist_t *peer_auth_chunks;
908         sctp_hmaclist_t *local_hmacs;   /* local HMACs supported */
909         sctp_hmaclist_t *peer_hmacs;    /* peer HMACs supported */
910         struct sctp_keyhead shared_keys;        /* assoc's shared keys */
911         sctp_authinfo_t authinfo;       /* randoms, cached keys */
912         /*
913          * refcnt to block freeing when a sender or receiver is off coping
914          * user data in.
915          */
916         uint32_t refcnt;
917         uint32_t chunks_on_out_queue;   /* total chunks floating around,
918                                          * locked by send socket buffer */
919         uint32_t peers_adaptation;
920         uint16_t peer_hmac_id;  /* peer HMAC id to send */
921
922         /*
923          * Being that we have no bag to collect stale cookies, and that we
924          * really would not want to anyway.. we will count them in this
925          * counter. We of course feed them to the pigeons right away (I have
926          * always thought of pigeons as flying rats).
927          */
928         uint16_t stale_cookie_count;
929
930         /*
931          * For the partial delivery API, if up, invoked this is what last
932          * TSN I delivered
933          */
934         uint16_t str_of_pdapi;
935         uint16_t ssn_of_pdapi;
936
937         /* counts of actual built streams. Allocation may be more however */
938         /* could re-arrange to optimize space here. */
939         uint16_t streamincnt;
940         uint16_t streamoutcnt;
941         uint16_t strm_realoutsize;
942         /* my maximum number of retrans of INIT and SEND */
943         /* copied from SCTP but should be individually setable */
944         uint16_t max_init_times;
945         uint16_t max_send_times;
946
947         uint16_t def_net_failure;
948
949         /*
950          * lock flag: 0 is ok to send, 1+ (duals as a retran count) is
951          * awaiting ACK
952          */
953         uint16_t mapping_array_size;
954
955         uint16_t last_strm_seq_delivered;
956         uint16_t last_strm_no_delivered;
957
958         uint16_t last_revoke_count;
959         int16_t num_send_timers_up;
960
961         uint16_t stream_locked_on;
962         uint16_t ecn_echo_cnt_onq;
963
964         uint16_t free_chunk_cnt;
965
966         uint8_t stream_locked;
967         uint8_t authenticated;  /* packet authenticated ok */
968         /*
969          * This flag indicates that a SACK need to be sent. Initially this
970          * is 1 to send the first sACK immediately.
971          */
972         uint8_t send_sack;
973
974         /* max burst after fast retransmit completes */
975         uint8_t max_burst;
976
977         uint8_t sat_network;    /* RTT is in range of sat net or greater */
978         uint8_t sat_network_lockout;    /* lockout code */
979         uint8_t burst_limit_applied;    /* Burst limit in effect at last send? */
980         /* flag goes on when we are doing a partial delivery api */
981         uint8_t hb_random_values[4];
982         uint8_t fragmented_delivery_inprogress;
983         uint8_t fragment_flags;
984         uint8_t last_flags_delivered;
985         uint8_t hb_ect_randombit;
986         uint8_t hb_random_idx;
987         uint8_t hb_is_disabled; /* is the hb disabled? */
988         uint8_t default_tos;
989         uint8_t asconf_del_pending;     /* asconf delete last addr pending */
990
991         /* ECN Nonce stuff */
992         uint8_t receiver_nonce_sum;     /* nonce I sum and put in my sack */
993         uint8_t ecn_nonce_allowed;      /* Tells us if ECN nonce is on */
994         uint8_t nonce_sum_check;/* On off switch used during re-sync */
995         uint8_t nonce_wait_for_ecne;    /* flag when we expect a ECN */
996         uint8_t peer_supports_ecn_nonce;
997
998         /*
999          * This value, plus all other ack'd but above cum-ack is added
1000          * together to cross check against the bit that we have yet to
1001          * define (probably in the SACK). When the cum-ack is updated, this
1002          * sum is updated as well.
1003          */
1004         uint8_t nonce_sum_expect_base;
1005         /* Flag to tell if ECN is allowed */
1006         uint8_t ecn_allowed;
1007
1008         /* flag to indicate if peer can do asconf */
1009         uint8_t peer_supports_asconf;
1010         /* EY - flag to indicate if peer can do nr_sack */
1011         uint8_t peer_supports_nr_sack;
1012         /* pr-sctp support flag */
1013         uint8_t peer_supports_prsctp;
1014         /* peer authentication support flag */
1015         uint8_t peer_supports_auth;
1016         /* stream resets are supported by the peer */
1017         uint8_t peer_supports_strreset;
1018
1019         uint8_t peer_supports_nat;
1020         /*
1021          * packet drop's are supported by the peer, we don't really care
1022          * about this but we bookkeep it anyway.
1023          */
1024         uint8_t peer_supports_pktdrop;
1025
1026         /* Do we allow V6/V4? */
1027         uint8_t ipv4_addr_legal;
1028         uint8_t ipv6_addr_legal;
1029         /* Address scoping flags */
1030         /* scope value for IPv4 */
1031         uint8_t ipv4_local_scope;
1032         /* scope values for IPv6 */
1033         uint8_t local_scope;
1034         uint8_t site_scope;
1035         /* loopback scope */
1036         uint8_t loopback_scope;
1037         /* flags to handle send alternate net tracking */
1038         uint8_t used_alt_onsack;
1039         uint8_t used_alt_asconfack;
1040         uint8_t fast_retran_loss_recovery;
1041         uint8_t sat_t3_loss_recovery;
1042         uint8_t dropped_special_cnt;
1043         uint8_t seen_a_sack_this_pkt;
1044         uint8_t stream_reset_outstanding;
1045         uint8_t stream_reset_out_is_outstanding;
1046         uint8_t delayed_connection;
1047         uint8_t ifp_had_enobuf;
1048         uint8_t saw_sack_with_frags;
1049         /* EY */
1050         uint8_t saw_sack_with_nr_frags;
1051         uint8_t in_asocid_hash;
1052         uint8_t assoc_up_sent;
1053         uint8_t adaptation_needed;
1054         uint8_t adaptation_sent;
1055         /* CMT variables */
1056         uint8_t cmt_dac_pkts_rcvd;
1057         uint8_t sctp_cmt_on_off;
1058         uint8_t iam_blocking;
1059         uint8_t cookie_how[8];
1060         /* EY 05/05/08 - NR_SACK variable */
1061         uint8_t sctp_nr_sack_on_off;
1062         /* JRS 5/21/07 - CMT PF variable */
1063         uint8_t sctp_cmt_pf;
1064         /*
1065          * The mapping array is used to track out of order sequences above
1066          * last_acked_seq. 0 indicates packet missing 1 indicates packet
1067          * rec'd. We slide it up every time we raise last_acked_seq and 0
1068          * trailing locactions out.  If I get a TSN above the array
1069          * mappingArraySz, I discard the datagram and let retransmit happen.
1070          */
1071         uint32_t marked_retrans;
1072         uint32_t timoinit;
1073         uint32_t timodata;
1074         uint32_t timosack;
1075         uint32_t timoshutdown;
1076         uint32_t timoheartbeat;
1077         uint32_t timocookie;
1078         uint32_t timoshutdownack;
1079         struct timeval start_time;
1080         struct timeval discontinuity_time;
1081 };
1082
1083 #endif