| 1 |
/*- |
| 2 |
* SPDX-License-Identifier: BSD-3-Clause |
| 3 |
* |
| 4 |
* Copyright (c) 2001-2008, by Cisco Systems, Inc. All rights reserved. |
| 5 |
* Copyright (c) 2008-2012, by Randall Stewart. All rights reserved. |
| 6 |
* Copyright (c) 2008-2012, by Michael Tuexen. All rights reserved. |
| 7 |
* |
| 8 |
* Redistribution and use in source and binary forms, with or without |
| 9 |
* modification, are permitted provided that the following conditions are met: |
| 10 |
* |
| 11 |
* a) Redistributions of source code must retain the above copyright notice, |
| 12 |
* this list of conditions and the following disclaimer. |
| 13 |
* |
| 14 |
* b) Redistributions in binary form must reproduce the above copyright |
| 15 |
* notice, this list of conditions and the following disclaimer in |
| 16 |
* the documentation and/or other materials provided with the distribution. |
| 17 |
* |
| 18 |
* c) Neither the name of Cisco Systems, Inc. nor the names of its |
| 19 |
* contributors may be used to endorse or promote products derived |
| 20 |
* from this software without specific prior written permission. |
| 21 |
* |
| 22 |
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 23 |
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, |
| 24 |
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 25 |
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE |
| 26 |
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 27 |
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 28 |
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
| 29 |
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
| 30 |
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 31 |
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
| 32 |
* THE POSSIBILITY OF SUCH DAMAGE. |
| 33 |
*/ |
| 34 |
|
| 35 |
#if defined(__FreeBSD__) && !defined(__Userspace__) |
| 36 |
#include <sys/cdefs.h> |
| 37 |
__FBSDID("$FreeBSD: head/sys/netinet/sctp_structs.h 362106 2020-06-12 16:31:13Z tuexen $"); |
| 38 |
#endif |
| 39 |
|
| 40 |
#ifndef _NETINET_SCTP_STRUCTS_H_ |
| 41 |
#define _NETINET_SCTP_STRUCTS_H_ |
| 42 |
|
| 43 |
#include <netinet/sctp_os.h> |
| 44 |
#include <netinet/sctp_header.h> |
| 45 |
#include <netinet/sctp_auth.h> |
| 46 |
|
| 47 |
struct sctp_timer { |
| 48 |
sctp_os_timer_t timer; |
| 49 |
|
| 50 |
int type; |
| 51 |
/* |
| 52 |
* Depending on the timer type these will be setup and cast with the |
| 53 |
* appropriate entity. |
| 54 |
*/ |
| 55 |
void *ep; |
| 56 |
void *tcb; |
| 57 |
void *net; |
| 58 |
#if defined(__FreeBSD__) && !defined(__Userspace__) |
| 59 |
void *vnet; |
| 60 |
#endif |
| 61 |
|
| 62 |
/* for sanity checking */ |
| 63 |
void *self; |
| 64 |
uint32_t ticks; |
| 65 |
uint32_t stopped_from; |
| 66 |
}; |
| 67 |
|
| 68 |
|
| 69 |
struct sctp_foo_stuff { |
| 70 |
struct sctp_inpcb *inp; |
| 71 |
uint32_t lineno; |
| 72 |
uint32_t ticks; |
| 73 |
int updown; |
| 74 |
}; |
| 75 |
|
| 76 |
|
| 77 |
/* |
| 78 |
* This is the information we track on each interface that we know about from |
| 79 |
* the distant end. |
| 80 |
*/ |
| 81 |
TAILQ_HEAD(sctpnetlisthead, sctp_nets); |
| 82 |
|
| 83 |
struct sctp_stream_reset_list { |
| 84 |
TAILQ_ENTRY(sctp_stream_reset_list) next_resp; |
| 85 |
uint32_t seq; |
| 86 |
uint32_t tsn; |
| 87 |
uint32_t number_entries; |
| 88 |
uint16_t list_of_streams[]; |
| 89 |
}; |
| 90 |
|
| 91 |
TAILQ_HEAD(sctp_resethead, sctp_stream_reset_list); |
| 92 |
|
| 93 |
/* |
| 94 |
* Users of the iterator need to malloc a iterator with a call to |
| 95 |
* sctp_initiate_iterator(inp_func, assoc_func, inp_func, pcb_flags, pcb_features, |
| 96 |
* asoc_state, void-ptr-arg, uint32-arg, end_func, inp); |
| 97 |
* |
| 98 |
* Use the following two defines if you don't care what pcb flags are on the EP |
| 99 |
* and/or you don't care what state the association is in. |
| 100 |
* |
| 101 |
* Note that if you specify an INP as the last argument then ONLY each |
| 102 |
* association of that single INP will be executed upon. Note that the pcb |
| 103 |
* flags STILL apply so if the inp you specify has different pcb_flags then |
| 104 |
* what you put in pcb_flags nothing will happen. use SCTP_PCB_ANY_FLAGS to |
| 105 |
* assure the inp you specify gets treated. |
| 106 |
*/ |
| 107 |
#define SCTP_PCB_ANY_FLAGS 0x00000000 |
| 108 |
#define SCTP_PCB_ANY_FEATURES 0x00000000 |
| 109 |
#define SCTP_ASOC_ANY_STATE 0x00000000 |
| 110 |
|
| 111 |
typedef void (*asoc_func) (struct sctp_inpcb *, struct sctp_tcb *, void *ptr, |
| 112 |
uint32_t val); |
| 113 |
typedef int (*inp_func) (struct sctp_inpcb *, void *ptr, uint32_t val); |
| 114 |
typedef void (*end_func) (void *ptr, uint32_t val); |
| 115 |
|
| 116 |
#if defined(__FreeBSD__) && !defined(__Userspace__) |
| 117 |
#if defined(SCTP_MCORE_INPUT) && defined(SMP) |
| 118 |
/* whats on the mcore control struct */ |
| 119 |
struct sctp_mcore_queue { |
| 120 |
TAILQ_ENTRY(sctp_mcore_queue) next; |
| 121 |
struct vnet *vn; |
| 122 |
struct mbuf *m; |
| 123 |
int off; |
| 124 |
int v6; |
| 125 |
}; |
| 126 |
|
| 127 |
TAILQ_HEAD(sctp_mcore_qhead, sctp_mcore_queue); |
| 128 |
|
| 129 |
struct sctp_mcore_ctrl { |
| 130 |
SCTP_PROCESS_STRUCT thread_proc; |
| 131 |
struct sctp_mcore_qhead que; |
| 132 |
struct mtx core_mtx; |
| 133 |
struct mtx que_mtx; |
| 134 |
int running; |
| 135 |
int cpuid; |
| 136 |
}; |
| 137 |
#endif |
| 138 |
#endif |
| 139 |
|
| 140 |
struct sctp_iterator { |
| 141 |
TAILQ_ENTRY(sctp_iterator) sctp_nxt_itr; |
| 142 |
#if defined(__FreeBSD__) && !defined(__Userspace__) |
| 143 |
struct vnet *vn; |
| 144 |
#endif |
| 145 |
struct sctp_timer tmr; |
| 146 |
struct sctp_inpcb *inp; /* current endpoint */ |
| 147 |
struct sctp_tcb *stcb; /* current* assoc */ |
| 148 |
struct sctp_inpcb *next_inp; /* special hook to skip to */ |
| 149 |
asoc_func function_assoc; /* per assoc function */ |
| 150 |
inp_func function_inp; /* per endpoint function */ |
| 151 |
inp_func function_inp_end; /* end INP function */ |
| 152 |
end_func function_atend; /* iterator completion function */ |
| 153 |
void *pointer; /* pointer for apply func to use */ |
| 154 |
uint32_t val; /* value for apply func to use */ |
| 155 |
uint32_t pcb_flags; /* endpoint flags being checked */ |
| 156 |
uint32_t pcb_features; /* endpoint features being checked */ |
| 157 |
uint32_t asoc_state; /* assoc state being checked */ |
| 158 |
uint32_t iterator_flags; |
| 159 |
uint8_t no_chunk_output; |
| 160 |
uint8_t done_current_ep; |
| 161 |
}; |
| 162 |
/* iterator_flags values */ |
| 163 |
#define SCTP_ITERATOR_DO_ALL_INP 0x00000001 |
| 164 |
#define SCTP_ITERATOR_DO_SINGLE_INP 0x00000002 |
| 165 |
|
| 166 |
|
| 167 |
TAILQ_HEAD(sctpiterators, sctp_iterator); |
| 168 |
|
| 169 |
struct sctp_copy_all { |
| 170 |
struct sctp_inpcb *inp; /* ep */ |
| 171 |
struct mbuf *m; |
| 172 |
struct sctp_sndrcvinfo sndrcv; |
| 173 |
ssize_t sndlen; |
| 174 |
int cnt_sent; |
| 175 |
int cnt_failed; |
| 176 |
}; |
| 177 |
|
| 178 |
struct sctp_asconf_iterator { |
| 179 |
struct sctpladdr list_of_work; |
| 180 |
int cnt; |
| 181 |
}; |
| 182 |
|
| 183 |
struct iterator_control { |
| 184 |
#if defined(__FreeBSD__) && !defined(__Userspace__) |
| 185 |
struct mtx ipi_iterator_wq_mtx; |
| 186 |
struct mtx it_mtx; |
| 187 |
#elif defined(__APPLE__) && !defined(__Userspace__) |
| 188 |
lck_mtx_t *ipi_iterator_wq_mtx; |
| 189 |
lck_mtx_t *it_mtx; |
| 190 |
#elif defined(SCTP_PROCESS_LEVEL_LOCKS) |
| 191 |
#if defined(__Userspace__) |
| 192 |
userland_mutex_t ipi_iterator_wq_mtx; |
| 193 |
userland_mutex_t it_mtx; |
| 194 |
userland_cond_t iterator_wakeup; |
| 195 |
#else |
| 196 |
pthread_mutex_t ipi_iterator_wq_mtx; |
| 197 |
pthread_mutex_t it_mtx; |
| 198 |
pthread_cond_t iterator_wakeup; |
| 199 |
#endif |
| 200 |
#elif defined(_WIN32) && !defined(__Userspace__) |
| 201 |
struct spinlock it_lock; |
| 202 |
struct spinlock ipi_iterator_wq_lock; |
| 203 |
KEVENT iterator_wakeup[2]; |
| 204 |
PFILE_OBJECT iterator_thread_obj; |
| 205 |
#else |
| 206 |
void *it_mtx; |
| 207 |
#endif |
| 208 |
#if !(defined(_WIN32) && !defined(__Userspace__)) |
| 209 |
#if !defined(__Userspace__) |
| 210 |
SCTP_PROCESS_STRUCT thread_proc; |
| 211 |
#else |
| 212 |
userland_thread_t thread_proc; |
| 213 |
#endif |
| 214 |
#endif |
| 215 |
struct sctpiterators iteratorhead; |
| 216 |
struct sctp_iterator *cur_it; |
| 217 |
uint32_t iterator_running; |
| 218 |
uint32_t iterator_flags; |
| 219 |
}; |
| 220 |
#if !(defined(__FreeBSD__) && !defined(__Userspace__)) |
| 221 |
#define SCTP_ITERATOR_MUST_EXIT 0x00000001 |
| 222 |
#define SCTP_ITERATOR_EXITED 0x00000002 |
| 223 |
#endif |
| 224 |
#define SCTP_ITERATOR_STOP_CUR_IT 0x00000004 |
| 225 |
#define SCTP_ITERATOR_STOP_CUR_INP 0x00000008 |
| 226 |
|
| 227 |
struct sctp_net_route { |
| 228 |
#if defined(__FreeBSD__) && !defined(__Userspace__) |
| 229 |
struct nhop_object *ro_nh; |
| 230 |
struct llentry *ro_lle; |
| 231 |
char *ro_prepend; |
| 232 |
uint16_t ro_plen; |
| 233 |
uint16_t ro_flags; |
| 234 |
uint16_t ro_mtu; |
| 235 |
uint16_t spare; |
| 236 |
#else |
| 237 |
sctp_rtentry_t *ro_rt; |
| 238 |
#endif |
| 239 |
#if defined(__APPLE__) && !defined(__Userspace__) |
| 240 |
#if !defined(APPLE_LEOPARD) && !defined(APPLE_SNOWLEOPARD) && !defined(APPLE_LION) && !defined(APPLE_MOUNTAINLION) && !defined(APPLE_ELCAPITAN) |
| 241 |
struct llentry *ro_lle; |
| 242 |
#endif |
| 243 |
#if !defined(APPLE_LEOPARD) && !defined(APPLE_SNOWLEOPARD) && !defined(APPLE_LION) && !defined(APPLE_MOUNTAINLION) |
| 244 |
struct ifaddr *ro_srcia; |
| 245 |
#endif |
| 246 |
#if !defined(APPLE_LEOPARD) |
| 247 |
uint32_t ro_flags; |
| 248 |
#endif |
| 249 |
#endif |
| 250 |
union sctp_sockstore _l_addr; /* remote peer addr */ |
| 251 |
struct sctp_ifa *_s_addr; /* our selected src addr */ |
| 252 |
}; |
| 253 |
|
| 254 |
struct htcp { |
| 255 |
uint16_t alpha; /* Fixed point arith, << 7 */ |
| 256 |
uint8_t beta; /* Fixed point arith, << 7 */ |
| 257 |
uint8_t modeswitch; /* Delay modeswitch until we had at least one congestion event */ |
| 258 |
uint32_t last_cong; /* Time since last congestion event end */ |
| 259 |
uint32_t undo_last_cong; |
| 260 |
uint16_t bytes_acked; |
| 261 |
uint32_t bytecount; |
| 262 |
uint32_t minRTT; |
| 263 |
uint32_t maxRTT; |
| 264 |
|
| 265 |
uint32_t undo_maxRTT; |
| 266 |
uint32_t undo_old_maxB; |
| 267 |
|
| 268 |
/* Bandwidth estimation */ |
| 269 |
uint32_t minB; |
| 270 |
uint32_t maxB; |
| 271 |
uint32_t old_maxB; |
| 272 |
uint32_t Bi; |
| 273 |
uint32_t lasttime; |
| 274 |
}; |
| 275 |
|
| 276 |
struct rtcc_cc { |
| 277 |
struct timeval tls; /* The time we started the sending */ |
| 278 |
uint64_t lbw; /* Our last estimated bw */ |
| 279 |
uint64_t lbw_rtt; /* RTT at bw estimate */ |
| 280 |
uint64_t bw_bytes; /* The total bytes since this sending began */ |
| 281 |
uint64_t bw_tot_time; /* The total time since sending began */ |
| 282 |
uint64_t new_tot_time; /* temp holding the new value */ |
| 283 |
uint64_t bw_bytes_at_last_rttc; /* What bw_bytes was at last rtt calc */ |
| 284 |
uint32_t cwnd_at_bw_set; /* Cwnd at last bw saved - lbw */ |
| 285 |
uint32_t vol_reduce; /* cnt of voluntary reductions */ |
| 286 |
uint16_t steady_step; /* The number required to be in steady state*/ |
| 287 |
uint16_t step_cnt; /* The current number */ |
| 288 |
uint8_t ret_from_eq; /* When all things are equal what do I return 0/1 - 1 no cc advance */ |
| 289 |
uint8_t use_dccc_ecn; /* Flag to enable DCCC ECN */ |
| 290 |
uint8_t tls_needs_set; /* Flag to indicate we need to set tls 0 or 1 means set at send 2 not */ |
| 291 |
uint8_t last_step_state; /* Last state if steady state stepdown is on */ |
| 292 |
uint8_t rtt_set_this_sack; /* Flag saying this sack had RTT calc on it */ |
| 293 |
uint8_t last_inst_ind; /* Last saved inst indication */ |
| 294 |
}; |
| 295 |
|
| 296 |
|
| 297 |
struct sctp_nets { |
| 298 |
TAILQ_ENTRY(sctp_nets) sctp_next; /* next link */ |
| 299 |
|
| 300 |
/* |
| 301 |
* Things on the top half may be able to be split into a common |
| 302 |
* structure shared by all. |
| 303 |
*/ |
| 304 |
struct sctp_timer pmtu_timer; |
| 305 |
struct sctp_timer hb_timer; |
| 306 |
|
| 307 |
/* |
| 308 |
* The following two in combination equate to a route entry for v6 |
| 309 |
* or v4. |
| 310 |
*/ |
| 311 |
struct sctp_net_route ro; |
| 312 |
|
| 313 |
/* mtu discovered so far */ |
| 314 |
uint32_t mtu; |
| 315 |
uint32_t ssthresh; /* not sure about this one for split */ |
| 316 |
uint32_t last_cwr_tsn; |
| 317 |
uint32_t cwr_window_tsn; |
| 318 |
uint32_t ecn_ce_pkt_cnt; |
| 319 |
uint32_t lost_cnt; |
| 320 |
/* smoothed average things for RTT and RTO itself */ |
| 321 |
int lastsa; |
| 322 |
int lastsv; |
| 323 |
uint64_t rtt; /* last measured rtt value in us */ |
| 324 |
uint32_t RTO; |
| 325 |
|
| 326 |
/* This is used for SHUTDOWN/SHUTDOWN-ACK/SEND or INIT timers */ |
| 327 |
struct sctp_timer rxt_timer; |
| 328 |
|
| 329 |
/* last time in seconds I sent to it */ |
| 330 |
struct timeval last_sent_time; |
| 331 |
union cc_control_data { |
| 332 |
struct htcp htcp_ca; /* JRS - struct used in HTCP algorithm */ |
| 333 |
struct rtcc_cc rtcc; /* rtcc module cc stuff */ |
| 334 |
} cc_mod; |
| 335 |
int ref_count; |
| 336 |
|
| 337 |
/* Congestion stats per destination */ |
| 338 |
/* |
| 339 |
* flight size variables and such, sorry Vern, I could not avoid |
| 340 |
* this if I wanted performance :> |
| 341 |
*/ |
| 342 |
uint32_t flight_size; |
| 343 |
uint32_t cwnd; /* actual cwnd */ |
| 344 |
uint32_t prev_cwnd; /* cwnd before any processing */ |
| 345 |
uint32_t ecn_prev_cwnd; /* ECN prev cwnd at first ecn_echo seen in new window */ |
| 346 |
uint32_t partial_bytes_acked; /* in CA tracks when to incr a MTU */ |
| 347 |
/* tracking variables to avoid the aloc/free in sack processing */ |
| 348 |
unsigned int net_ack; |
| 349 |
unsigned int net_ack2; |
| 350 |
|
| 351 |
/* |
| 352 |
* JRS - 5/8/07 - Variable to track last time |
| 353 |
* a destination was active for CMT PF |
| 354 |
*/ |
| 355 |
uint32_t last_active; |
| 356 |
|
| 357 |
/* |
| 358 |
* CMT variables ([email protected]) |
| 359 |
*/ |
| 360 |
uint32_t this_sack_highest_newack; /* tracks highest TSN newly |
| 361 |
* acked for a given dest in |
| 362 |
* the current SACK. Used in |
| 363 |
* SFR and HTNA algos */ |
| 364 |
uint32_t pseudo_cumack; /* CMT CUC algorithm. Maintains next expected |
| 365 |
* pseudo-cumack for this destination */ |
| 366 |
uint32_t rtx_pseudo_cumack; /* CMT CUC algorithm. Maintains next |
| 367 |
* expected pseudo-cumack for this |
| 368 |
* destination */ |
| 369 |
|
| 370 |
/* CMT fast recovery variables */ |
| 371 |
uint32_t fast_recovery_tsn; |
| 372 |
uint32_t heartbeat_random1; |
| 373 |
uint32_t heartbeat_random2; |
| 374 |
#ifdef INET6 |
| 375 |
uint32_t flowlabel; |
| 376 |
#endif |
| 377 |
uint8_t dscp; |
| 378 |
|
| 379 |
struct timeval start_time; /* time when this net was created */ |
| 380 |
uint32_t marked_retrans; /* number or DATA chunks marked for |
| 381 |
timer based retransmissions */ |
| 382 |
uint32_t marked_fastretrans; |
| 383 |
uint32_t heart_beat_delay; /* Heart Beat delay in ms */ |
| 384 |
|
| 385 |
/* if this guy is ok or not ... status */ |
| 386 |
uint16_t dest_state; |
| 387 |
/* number of timeouts to consider the destination unreachable */ |
| 388 |
uint16_t failure_threshold; |
| 389 |
/* number of timeouts to consider the destination potentially failed */ |
| 390 |
uint16_t pf_threshold; |
| 391 |
/* error stats on the destination */ |
| 392 |
uint16_t error_count; |
| 393 |
/* UDP port number in case of UDP tunneling */ |
| 394 |
uint16_t port; |
| 395 |
|
| 396 |
uint8_t fast_retran_loss_recovery; |
| 397 |
uint8_t will_exit_fast_recovery; |
| 398 |
/* Flags that probably can be combined into dest_state */ |
| 399 |
uint8_t fast_retran_ip; /* fast retransmit in progress */ |
| 400 |
uint8_t hb_responded; |
| 401 |
uint8_t saw_newack; /* CMT's SFR algorithm flag */ |
| 402 |
uint8_t src_addr_selected; /* if we split we move */ |
| 403 |
uint8_t indx_of_eligible_next_to_use; |
| 404 |
uint8_t addr_is_local; /* its a local address (if known) could move |
| 405 |
* in split */ |
| 406 |
|
| 407 |
/* |
| 408 |
* CMT variables ([email protected]) |
| 409 |
*/ |
| 410 |
uint8_t find_pseudo_cumack; /* CMT CUC algorithm. Flag used to |
| 411 |
* find a new pseudocumack. This flag |
| 412 |
* is set after a new pseudo-cumack |
| 413 |
* has been received and indicates |
| 414 |
* that the sender should find the |
| 415 |
* next pseudo-cumack expected for |
| 416 |
* this destination */ |
| 417 |
uint8_t find_rtx_pseudo_cumack; /* CMT CUCv2 algorithm. Flag used to |
| 418 |
* find a new rtx-pseudocumack. This |
| 419 |
* flag is set after a new |
| 420 |
* rtx-pseudo-cumack has been received |
| 421 |
* and indicates that the sender |
| 422 |
* should find the next |
| 423 |
* rtx-pseudo-cumack expected for this |
| 424 |
* destination */ |
| 425 |
uint8_t new_pseudo_cumack; /* CMT CUC algorithm. Flag used to |
| 426 |
* indicate if a new pseudo-cumack or |
| 427 |
* rtx-pseudo-cumack has been received */ |
| 428 |
uint8_t window_probe; /* Doing a window probe? */ |
| 429 |
uint8_t RTO_measured; /* Have we done the first measure */ |
| 430 |
uint8_t last_hs_used; /* index into the last HS table entry we used */ |
| 431 |
uint8_t lan_type; |
| 432 |
uint8_t rto_needed; |
| 433 |
#if defined(__FreeBSD__) && !defined(__Userspace__) |
| 434 |
uint32_t flowid; |
| 435 |
uint8_t flowtype; |
| 436 |
#endif |
| 437 |
}; |
| 438 |
|
| 439 |
|
| 440 |
struct sctp_data_chunkrec { |
| 441 |
uint32_t tsn; /* the TSN of this transmit */ |
| 442 |
uint32_t mid; /* the message identifier of this transmit */ |
| 443 |
uint16_t sid; /* the stream number of this guy */ |
| 444 |
uint32_t ppid; |
| 445 |
uint32_t context; /* from send */ |
| 446 |
uint32_t cwnd_at_send; |
| 447 |
/* |
| 448 |
* part of the Highest sacked algorithm to be able to stroke counts |
| 449 |
* on ones that are FR'd. |
| 450 |
*/ |
| 451 |
uint32_t fast_retran_tsn; /* sending_seq at the time of FR */ |
| 452 |
struct timeval timetodrop; /* time we drop it from queue */ |
| 453 |
uint32_t fsn; /* Fragment Sequence Number */ |
| 454 |
uint8_t doing_fast_retransmit; |
| 455 |
uint8_t rcv_flags; /* flags pulled from data chunk on inbound for |
| 456 |
* outbound holds sending flags for PR-SCTP. |
| 457 |
*/ |
| 458 |
uint8_t state_flags; |
| 459 |
uint8_t chunk_was_revoked; |
| 460 |
uint8_t fwd_tsn_cnt; |
| 461 |
}; |
| 462 |
|
| 463 |
TAILQ_HEAD(sctpchunk_listhead, sctp_tmit_chunk); |
| 464 |
|
| 465 |
/* The lower byte is used to enumerate PR_SCTP policies */ |
| 466 |
#define CHUNK_FLAGS_PR_SCTP_TTL SCTP_PR_SCTP_TTL |
| 467 |
#define CHUNK_FLAGS_PR_SCTP_BUF SCTP_PR_SCTP_BUF |
| 468 |
#define CHUNK_FLAGS_PR_SCTP_RTX SCTP_PR_SCTP_RTX |
| 469 |
|
| 470 |
/* The upper byte is used as a bit mask */ |
| 471 |
#define CHUNK_FLAGS_FRAGMENT_OK 0x0100 |
| 472 |
|
| 473 |
struct chk_id { |
| 474 |
uint8_t id; |
| 475 |
uint8_t can_take_data; |
| 476 |
}; |
| 477 |
|
| 478 |
|
| 479 |
struct sctp_tmit_chunk { |
| 480 |
union { |
| 481 |
struct sctp_data_chunkrec data; |
| 482 |
struct chk_id chunk_id; |
| 483 |
} rec; |
| 484 |
struct sctp_association *asoc; /* bp to asoc this belongs to */ |
| 485 |
struct timeval sent_rcv_time; /* filled in if RTT being calculated */ |
| 486 |
struct mbuf *data; /* pointer to mbuf chain of data */ |
| 487 |
struct mbuf *last_mbuf; /* pointer to last mbuf in chain */ |
| 488 |
struct sctp_nets *whoTo; |
| 489 |
TAILQ_ENTRY(sctp_tmit_chunk) sctp_next; /* next link */ |
| 490 |
int32_t sent; /* the send status */ |
| 491 |
uint16_t snd_count; /* number of times I sent */ |
| 492 |
uint16_t flags; /* flags, such as FRAGMENT_OK */ |
| 493 |
uint16_t send_size; |
| 494 |
uint16_t book_size; |
| 495 |
uint16_t mbcnt; |
| 496 |
uint16_t auth_keyid; |
| 497 |
uint8_t holds_key_ref; /* flag if auth keyid refcount is held */ |
| 498 |
uint8_t pad_inplace; |
| 499 |
uint8_t do_rtt; |
| 500 |
uint8_t book_size_scale; |
| 501 |
uint8_t no_fr_allowed; |
| 502 |
uint8_t copy_by_ref; |
| 503 |
uint8_t window_probe; |
| 504 |
}; |
| 505 |
|
| 506 |
struct sctp_queued_to_read { /* sinfo structure Pluse more */ |
| 507 |
uint16_t sinfo_stream; /* off the wire */ |
| 508 |
uint16_t sinfo_flags; /* SCTP_UNORDERED from wire use SCTP_EOF for |
| 509 |
* EOR */ |
| 510 |
uint32_t sinfo_ppid; /* off the wire */ |
| 511 |
uint32_t sinfo_context; /* pick this up from assoc def context? */ |
| 512 |
uint32_t sinfo_timetolive; /* not used by kernel */ |
| 513 |
uint32_t sinfo_tsn; /* Use this in reassembly as first TSN */ |
| 514 |
uint32_t sinfo_cumtsn; /* Use this in reassembly as last TSN */ |
| 515 |
sctp_assoc_t sinfo_assoc_id; /* our assoc id */ |
| 516 |
/* Non sinfo stuff */ |
| 517 |
uint32_t mid; /* Fragment Index */ |
| 518 |
uint32_t length; /* length of data */ |
| 519 |
uint32_t held_length; /* length held in sb */ |
| 520 |
uint32_t top_fsn; /* Highest FSN in queue */ |
| 521 |
uint32_t fsn_included; /* Highest FSN in *data portion */ |
| 522 |
struct sctp_nets *whoFrom; /* where it came from */ |
| 523 |
struct mbuf *data; /* front of the mbuf chain of data with |
| 524 |
* PKT_HDR */ |
| 525 |
struct mbuf *tail_mbuf; /* used for multi-part data */ |
| 526 |
struct mbuf *aux_data; /* used to hold/cache control if o/s does not take it from us */ |
| 527 |
struct sctp_tcb *stcb; /* assoc, used for window update */ |
| 528 |
TAILQ_ENTRY(sctp_queued_to_read) next; |
| 529 |
TAILQ_ENTRY(sctp_queued_to_read) next_instrm; |
| 530 |
struct sctpchunk_listhead reasm; |
| 531 |
uint16_t port_from; |
| 532 |
uint16_t spec_flags; /* Flags to hold the notification field */ |
| 533 |
uint8_t do_not_ref_stcb; |
| 534 |
uint8_t end_added; |
| 535 |
uint8_t pdapi_aborted; |
| 536 |
uint8_t pdapi_started; |
| 537 |
uint8_t some_taken; |
| 538 |
uint8_t last_frag_seen; |
| 539 |
uint8_t first_frag_seen; |
| 540 |
uint8_t on_read_q; |
| 541 |
uint8_t on_strm_q; |
| 542 |
}; |
| 543 |
|
| 544 |
#define SCTP_ON_ORDERED 1 |
| 545 |
#define SCTP_ON_UNORDERED 2 |
| 546 |
|
| 547 |
/* This data structure will be on the outbound |
| 548 |
* stream queues. Data will be pulled off from |
| 549 |
* the front of the mbuf data and chunk-ified |
| 550 |
* by the output routines. We will custom |
| 551 |
* fit every chunk we pull to the send/sent |
| 552 |
* queue to make up the next full packet |
| 553 |
* if we can. An entry cannot be removed |
| 554 |
* from the stream_out queue until |
| 555 |
* the msg_is_complete flag is set. This |
| 556 |
* means at times data/tail_mbuf MIGHT |
| 557 |
* be NULL.. If that occurs it happens |
| 558 |
* for one of two reasons. Either the user |
| 559 |
* is blocked on a send() call and has not |
| 560 |
* awoken to copy more data down... OR |
| 561 |
* the user is in the explict MSG_EOR mode |
| 562 |
* and wrote some data, but has not completed |
| 563 |
* sending. |
| 564 |
*/ |
| 565 |
struct sctp_stream_queue_pending { |
| 566 |
struct mbuf *data; |
| 567 |
struct mbuf *tail_mbuf; |
| 568 |
struct timeval ts; |
| 569 |
struct sctp_nets *net; |
| 570 |
TAILQ_ENTRY (sctp_stream_queue_pending) next; |
| 571 |
TAILQ_ENTRY (sctp_stream_queue_pending) ss_next; |
| 572 |
uint32_t fsn; |
| 573 |
uint32_t length; |
| 574 |
uint32_t timetolive; |
| 575 |
uint32_t ppid; |
| 576 |
uint32_t context; |
| 577 |
uint16_t sinfo_flags; |
| 578 |
uint16_t sid; |
| 579 |
uint16_t act_flags; |
| 580 |
uint16_t auth_keyid; |
| 581 |
uint8_t holds_key_ref; |
| 582 |
uint8_t msg_is_complete; |
| 583 |
uint8_t some_taken; |
| 584 |
uint8_t sender_all_done; |
| 585 |
uint8_t put_last_out; |
| 586 |
uint8_t discard_rest; |
| 587 |
}; |
| 588 |
|
| 589 |
/* |
| 590 |
* this struct contains info that is used to track inbound stream data and |
| 591 |
* help with ordering. |
| 592 |
*/ |
| 593 |
TAILQ_HEAD(sctpwheelunrel_listhead, sctp_stream_in); |
| 594 |
struct sctp_stream_in { |
| 595 |
struct sctp_readhead inqueue; |
| 596 |
struct sctp_readhead uno_inqueue; |
| 597 |
uint32_t last_mid_delivered; /* used for re-order */ |
| 598 |
uint16_t sid; |
| 599 |
uint8_t delivery_started; |
| 600 |
uint8_t pd_api_started; |
| 601 |
}; |
| 602 |
|
| 603 |
TAILQ_HEAD(sctpwheel_listhead, sctp_stream_out); |
| 604 |
TAILQ_HEAD(sctplist_listhead, sctp_stream_queue_pending); |
| 605 |
|
| 606 |
|
| 607 |
/* Round-robin schedulers */ |
| 608 |
struct ss_rr { |
| 609 |
/* next link in wheel */ |
| 610 |
TAILQ_ENTRY(sctp_stream_out) next_spoke; |
| 611 |
}; |
| 612 |
|
| 613 |
/* Priority scheduler */ |
| 614 |
struct ss_prio { |
| 615 |
/* next link in wheel */ |
| 616 |
TAILQ_ENTRY(sctp_stream_out) next_spoke; |
| 617 |
/* priority id */ |
| 618 |
uint16_t priority; |
| 619 |
}; |
| 620 |
|
| 621 |
/* Fair Bandwidth scheduler */ |
| 622 |
struct ss_fb { |
| 623 |
/* next link in wheel */ |
| 624 |
TAILQ_ENTRY(sctp_stream_out) next_spoke; |
| 625 |
/* stores message size */ |
| 626 |
int32_t rounds; |
| 627 |
}; |
| 628 |
|
| 629 |
/* |
| 630 |
* This union holds all data necessary for |
| 631 |
* different stream schedulers. |
| 632 |
*/ |
| 633 |
struct scheduling_data { |
| 634 |
struct sctp_stream_out *locked_on_sending; |
| 635 |
/* circular looking for output selection */ |
| 636 |
struct sctp_stream_out *last_out_stream; |
| 637 |
union { |
| 638 |
struct sctpwheel_listhead wheel; |
| 639 |
struct sctplist_listhead list; |
| 640 |
} out; |
| 641 |
}; |
| 642 |
|
| 643 |
/* |
| 644 |
* This union holds all parameters per stream |
| 645 |
* necessary for different stream schedulers. |
| 646 |
*/ |
| 647 |
union scheduling_parameters { |
| 648 |
struct ss_rr rr; |
| 649 |
struct ss_prio prio; |
| 650 |
struct ss_fb fb; |
| 651 |
}; |
| 652 |
|
| 653 |
/* States for outgoing streams */ |
| 654 |
#define SCTP_STREAM_CLOSED 0x00 |
| 655 |
#define SCTP_STREAM_OPENING 0x01 |
| 656 |
#define SCTP_STREAM_OPEN 0x02 |
| 657 |
#define SCTP_STREAM_RESET_PENDING 0x03 |
| 658 |
#define SCTP_STREAM_RESET_IN_FLIGHT 0x04 |
| 659 |
|
| 660 |
#define SCTP_MAX_STREAMS_AT_ONCE_RESET 200 |
| 661 |
|
| 662 |
/* This struct is used to track the traffic on outbound streams */ |
| 663 |
struct sctp_stream_out { |
| 664 |
struct sctp_streamhead outqueue; |
| 665 |
union scheduling_parameters ss_params; |
| 666 |
uint32_t chunks_on_queues; /* send queue and sent queue */ |
| 667 |
#if defined(SCTP_DETAILED_STR_STATS) |
| 668 |
uint32_t abandoned_unsent[SCTP_PR_SCTP_MAX + 1]; |
| 669 |
uint32_t abandoned_sent[SCTP_PR_SCTP_MAX + 1]; |
| 670 |
#else |
| 671 |
/* Only the aggregation */ |
| 672 |
uint32_t abandoned_unsent[1]; |
| 673 |
uint32_t abandoned_sent[1]; |
| 674 |
#endif |
| 675 |
/* For associations using DATA chunks, the lower 16-bit of |
| 676 |
* next_mid_ordered are used as the next SSN. |
| 677 |
*/ |
| 678 |
uint32_t next_mid_ordered; |
| 679 |
uint32_t next_mid_unordered; |
| 680 |
uint16_t sid; |
| 681 |
uint8_t last_msg_incomplete; |
| 682 |
uint8_t state; |
| 683 |
}; |
| 684 |
|
| 685 |
/* used to keep track of the addresses yet to try to add/delete */ |
| 686 |
TAILQ_HEAD(sctp_asconf_addrhead, sctp_asconf_addr); |
| 687 |
struct sctp_asconf_addr { |
| 688 |
TAILQ_ENTRY(sctp_asconf_addr) next; |
| 689 |
struct sctp_asconf_addr_param ap; |
| 690 |
struct sctp_ifa *ifa; /* save the ifa for add/del ip */ |
| 691 |
uint8_t sent; /* has this been sent yet? */ |
| 692 |
uint8_t special_del; /* not to be used in lookup */ |
| 693 |
}; |
| 694 |
|
| 695 |
struct sctp_scoping { |
| 696 |
uint8_t ipv4_addr_legal; |
| 697 |
uint8_t ipv6_addr_legal; |
| 698 |
#if defined(__Userspace__) |
| 699 |
uint8_t conn_addr_legal; |
| 700 |
#endif |
| 701 |
uint8_t loopback_scope; |
| 702 |
uint8_t ipv4_local_scope; |
| 703 |
uint8_t local_scope; |
| 704 |
uint8_t site_scope; |
| 705 |
}; |
| 706 |
|
| 707 |
#define SCTP_TSN_LOG_SIZE 40 |
| 708 |
|
| 709 |
struct sctp_tsn_log { |
| 710 |
void *stcb; |
| 711 |
uint32_t tsn; |
| 712 |
uint32_t seq; |
| 713 |
uint16_t strm; |
| 714 |
uint16_t sz; |
| 715 |
uint16_t flgs; |
| 716 |
uint16_t in_pos; |
| 717 |
uint16_t in_out; |
| 718 |
uint16_t resv; |
| 719 |
}; |
| 720 |
|
| 721 |
#define SCTP_FS_SPEC_LOG_SIZE 200 |
| 722 |
struct sctp_fs_spec_log { |
| 723 |
uint32_t sent; |
| 724 |
uint32_t total_flight; |
| 725 |
uint32_t tsn; |
| 726 |
uint16_t book; |
| 727 |
uint8_t incr; |
| 728 |
uint8_t decr; |
| 729 |
}; |
| 730 |
|
| 731 |
/* This struct is here to cut out the compatiabilty |
| 732 |
* pad that bulks up both the inp and stcb. The non |
| 733 |
* pad portion MUST stay in complete sync with |
| 734 |
* sctp_sndrcvinfo... i.e. if sinfo_xxxx is added |
| 735 |
* this must be done here too. |
| 736 |
*/ |
| 737 |
struct sctp_nonpad_sndrcvinfo { |
| 738 |
uint16_t sinfo_stream; |
| 739 |
uint16_t sinfo_ssn; |
| 740 |
uint16_t sinfo_flags; |
| 741 |
uint32_t sinfo_ppid; |
| 742 |
uint32_t sinfo_context; |
| 743 |
uint32_t sinfo_timetolive; |
| 744 |
uint32_t sinfo_tsn; |
| 745 |
uint32_t sinfo_cumtsn; |
| 746 |
sctp_assoc_t sinfo_assoc_id; |
| 747 |
uint16_t sinfo_keynumber; |
| 748 |
uint16_t sinfo_keynumber_valid; |
| 749 |
}; |
| 750 |
|
| 751 |
/* |
| 752 |
* JRS - Structure to hold function pointers to the functions responsible |
| 753 |
* for congestion control. |
| 754 |
*/ |
| 755 |
|
| 756 |
struct sctp_cc_functions { |
| 757 |
void (*sctp_set_initial_cc_param)(struct sctp_tcb *stcb, struct sctp_nets *net); |
| 758 |
void (*sctp_cwnd_update_after_sack)(struct sctp_tcb *stcb, |
| 759 |
struct sctp_association *asoc, |
| 760 |
int accum_moved ,int reneged_all, int will_exit); |
| 761 |
void (*sctp_cwnd_update_exit_pf)(struct sctp_tcb *stcb, struct sctp_nets *net); |
| 762 |
void (*sctp_cwnd_update_after_fr)(struct sctp_tcb *stcb, |
| 763 |
struct sctp_association *asoc); |
| 764 |
void (*sctp_cwnd_update_after_timeout)(struct sctp_tcb *stcb, |
| 765 |
struct sctp_nets *net); |
| 766 |
void (*sctp_cwnd_update_after_ecn_echo)(struct sctp_tcb *stcb, |
| 767 |
struct sctp_nets *net, int in_window, int num_pkt_lost); |
| 768 |
void (*sctp_cwnd_update_after_packet_dropped)(struct sctp_tcb *stcb, |
| 769 |
struct sctp_nets *net, struct sctp_pktdrop_chunk *cp, |
| 770 |
uint32_t *bottle_bw, uint32_t *on_queue); |
| 771 |
void (*sctp_cwnd_update_after_output)(struct sctp_tcb *stcb, |
| 772 |
struct sctp_nets *net, int burst_limit); |
| 773 |
void (*sctp_cwnd_update_packet_transmitted)(struct sctp_tcb *stcb, |
| 774 |
struct sctp_nets *net); |
| 775 |
void (*sctp_cwnd_update_tsn_acknowledged)(struct sctp_nets *net, |
| 776 |
struct sctp_tmit_chunk *); |
| 777 |
void (*sctp_cwnd_new_transmission_begins)(struct sctp_tcb *stcb, |
| 778 |
struct sctp_nets *net); |
| 779 |
void (*sctp_cwnd_prepare_net_for_sack)(struct sctp_tcb *stcb, |
| 780 |
struct sctp_nets *net); |
| 781 |
int (*sctp_cwnd_socket_option)(struct sctp_tcb *stcb, int set, struct sctp_cc_option *); |
| 782 |
void (*sctp_rtt_calculated)(struct sctp_tcb *, struct sctp_nets *, struct timeval *); |
| 783 |
}; |
| 784 |
|
| 785 |
/* |
| 786 |
* RS - Structure to hold function pointers to the functions responsible |
| 787 |
* for stream scheduling. |
| 788 |
*/ |
| 789 |
struct sctp_ss_functions { |
| 790 |
void (*sctp_ss_init)(struct sctp_tcb *stcb, struct sctp_association *asoc, |
| 791 |
int holds_lock); |
| 792 |
void (*sctp_ss_clear)(struct sctp_tcb *stcb, struct sctp_association *asoc, |
| 793 |
int clear_values, int holds_lock); |
| 794 |
void (*sctp_ss_init_stream)(struct sctp_tcb *stcb, struct sctp_stream_out *strq, struct sctp_stream_out *with_strq); |
| 795 |
void (*sctp_ss_add_to_stream)(struct sctp_tcb *stcb, struct sctp_association *asoc, |
| 796 |
struct sctp_stream_out *strq, struct sctp_stream_queue_pending *sp, int holds_lock); |
| 797 |
int (*sctp_ss_is_empty)(struct sctp_tcb *stcb, struct sctp_association *asoc); |
| 798 |
void (*sctp_ss_remove_from_stream)(struct sctp_tcb *stcb, struct sctp_association *asoc, |
| 799 |
struct sctp_stream_out *strq, struct sctp_stream_queue_pending *sp, int holds_lock); |
| 800 |
struct sctp_stream_out* (*sctp_ss_select_stream)(struct sctp_tcb *stcb, |
| 801 |
struct sctp_nets *net, struct sctp_association *asoc); |
| 802 |
void (*sctp_ss_scheduled)(struct sctp_tcb *stcb, struct sctp_nets *net, |
| 803 |
struct sctp_association *asoc, struct sctp_stream_out *strq, int moved_how_much); |
| 804 |
void (*sctp_ss_packet_done)(struct sctp_tcb *stcb, struct sctp_nets *net, |
| 805 |
struct sctp_association *asoc); |
| 806 |
int (*sctp_ss_get_value)(struct sctp_tcb *stcb, struct sctp_association *asoc, |
| 807 |
struct sctp_stream_out *strq, uint16_t *value); |
| 808 |
int (*sctp_ss_set_value)(struct sctp_tcb *stcb, struct sctp_association *asoc, |
| 809 |
struct sctp_stream_out *strq, uint16_t value); |
| 810 |
int (*sctp_ss_is_user_msgs_incomplete)(struct sctp_tcb *stcb, struct sctp_association *asoc); |
| 811 |
}; |
| 812 |
|
| 813 |
/* used to save ASCONF chunks for retransmission */ |
| 814 |
TAILQ_HEAD(sctp_asconf_head, sctp_asconf); |
| 815 |
struct sctp_asconf { |
| 816 |
TAILQ_ENTRY(sctp_asconf) next; |
| 817 |
uint32_t serial_number; |
| 818 |
uint16_t snd_count; |
| 819 |
struct mbuf *data; |
| 820 |
uint16_t len; |
| 821 |
}; |
| 822 |
|
| 823 |
/* used to save ASCONF-ACK chunks for retransmission */ |
| 824 |
TAILQ_HEAD(sctp_asconf_ackhead, sctp_asconf_ack); |
| 825 |
struct sctp_asconf_ack { |
| 826 |
TAILQ_ENTRY(sctp_asconf_ack) next; |
| 827 |
uint32_t serial_number; |
| 828 |
struct sctp_nets *last_sent_to; |
| 829 |
struct mbuf *data; |
| 830 |
uint16_t len; |
| 831 |
}; |
| 832 |
|
| 833 |
/* |
| 834 |
* Here we have information about each individual association that we track. |
| 835 |
* We probably in production would be more dynamic. But for ease of |
| 836 |
* implementation we will have a fixed array that we hunt for in a linear |
| 837 |
* fashion. |
| 838 |
*/ |
| 839 |
struct sctp_association { |
| 840 |
/* association state */ |
| 841 |
int state; |
| 842 |
|
| 843 |
/* queue of pending addrs to add/delete */ |
| 844 |
struct sctp_asconf_addrhead asconf_queue; |
| 845 |
|
| 846 |
struct timeval time_entered; /* time we entered state */ |
| 847 |
struct timeval time_last_rcvd; |
| 848 |
struct timeval time_last_sent; |
| 849 |
struct timeval time_last_sat_advance; |
| 850 |
struct sctp_nonpad_sndrcvinfo def_send; |
| 851 |
|
| 852 |
/* timers and such */ |
| 853 |
struct sctp_timer dack_timer; /* Delayed ack timer */ |
| 854 |
struct sctp_timer asconf_timer; /* asconf */ |
| 855 |
struct sctp_timer strreset_timer; /* stream reset */ |
| 856 |
struct sctp_timer shut_guard_timer; /* shutdown guard */ |
| 857 |
struct sctp_timer autoclose_timer; /* automatic close timer */ |
| 858 |
struct sctp_timer delete_prim_timer; /* deleting primary dst */ |
| 859 |
|
| 860 |
/* list of restricted local addresses */ |
| 861 |
struct sctpladdr sctp_restricted_addrs; |
| 862 |
|
| 863 |
/* last local address pending deletion (waiting for an address add) */ |
| 864 |
struct sctp_ifa *asconf_addr_del_pending; |
| 865 |
/* Deleted primary destination (used to stop timer) */ |
| 866 |
struct sctp_nets *deleted_primary; |
| 867 |
|
| 868 |
struct sctpnetlisthead nets; /* remote address list */ |
| 869 |
|
| 870 |
/* Free chunk list */ |
| 871 |
struct sctpchunk_listhead free_chunks; |
| 872 |
|
| 873 |
/* Control chunk queue */ |
| 874 |
struct sctpchunk_listhead control_send_queue; |
| 875 |
|
| 876 |
/* ASCONF chunk queue */ |
| 877 |
struct sctpchunk_listhead asconf_send_queue; |
| 878 |
|
| 879 |
/* |
| 880 |
* Once a TSN hits the wire it is moved to the sent_queue. We |
| 881 |
* maintain two counts here (don't know if any but retran_cnt is |
| 882 |
* needed). The idea is that the sent_queue_retran_cnt reflects how |
| 883 |
* many chunks have been marked for retranmission by either T3-rxt |
| 884 |
* or FR. |
| 885 |
*/ |
| 886 |
struct sctpchunk_listhead sent_queue; |
| 887 |
struct sctpchunk_listhead send_queue; |
| 888 |
|
| 889 |
/* Scheduling queues */ |
| 890 |
struct scheduling_data ss_data; |
| 891 |
|
| 892 |
/* If an iterator is looking at me, this is it */ |
| 893 |
struct sctp_iterator *stcb_starting_point_for_iterator; |
| 894 |
|
| 895 |
/* ASCONF save the last ASCONF-ACK so we can resend it if necessary */ |
| 896 |
struct sctp_asconf_ackhead asconf_ack_sent; |
| 897 |
|
| 898 |
/* |
| 899 |
* pointer to last stream reset queued to control queue by us with |
| 900 |
* requests. |
| 901 |
*/ |
| 902 |
struct sctp_tmit_chunk *str_reset; |
| 903 |
/* |
| 904 |
* if Source Address Selection happening, this will rotate through |
| 905 |
* the link list. |
| 906 |
*/ |
| 907 |
struct sctp_laddr *last_used_address; |
| 908 |
|
| 909 |
/* stream arrays */ |
| 910 |
struct sctp_stream_in *strmin; |
| 911 |
struct sctp_stream_out *strmout; |
| 912 |
uint8_t *mapping_array; |
| 913 |
/* primary destination to use */ |
| 914 |
struct sctp_nets *primary_destination; |
| 915 |
struct sctp_nets *alternate; /* If primary is down or PF */ |
| 916 |
/* For CMT */ |
| 917 |
struct sctp_nets *last_net_cmt_send_started; |
| 918 |
/* last place I got a data chunk from */ |
| 919 |
struct sctp_nets *last_data_chunk_from; |
| 920 |
/* last place I got a control from */ |
| 921 |
struct sctp_nets *last_control_chunk_from; |
| 922 |
|
| 923 |
|
| 924 |
/* |
| 925 |
* wait to the point the cum-ack passes req->send_reset_at_tsn for |
| 926 |
* any req on the list. |
| 927 |
*/ |
| 928 |
struct sctp_resethead resetHead; |
| 929 |
|
| 930 |
/* queue of chunks waiting to be sent into the local stack */ |
| 931 |
struct sctp_readhead pending_reply_queue; |
| 932 |
|
| 933 |
/* JRS - the congestion control functions are in this struct */ |
| 934 |
struct sctp_cc_functions cc_functions; |
| 935 |
/* JRS - value to store the currently loaded congestion control module */ |
| 936 |
uint32_t congestion_control_module; |
| 937 |
/* RS - the stream scheduling functions are in this struct */ |
| 938 |
struct sctp_ss_functions ss_functions; |
| 939 |
/* RS - value to store the currently loaded stream scheduling module */ |
| 940 |
uint32_t stream_scheduling_module; |
| 941 |
|
| 942 |
uint32_t vrf_id; |
| 943 |
uint32_t cookie_preserve_req; |
| 944 |
/* ASCONF next seq I am sending out, inits at init-tsn */ |
| 945 |
uint32_t asconf_seq_out; |
| 946 |
uint32_t asconf_seq_out_acked; |
| 947 |
/* ASCONF last received ASCONF from peer, starts at peer's TSN-1 */ |
| 948 |
uint32_t asconf_seq_in; |
| 949 |
|
| 950 |
/* next seq I am sending in str reset messages */ |
| 951 |
uint32_t str_reset_seq_out; |
| 952 |
/* next seq I am expecting in str reset messages */ |
| 953 |
uint32_t str_reset_seq_in; |
| 954 |
|
| 955 |
/* various verification tag information */ |
| 956 |
uint32_t my_vtag; /* The tag to be used. if assoc is re-initited |
| 957 |
* by remote end, and I have unlocked this |
| 958 |
* will be regenerated to a new random value. */ |
| 959 |
uint32_t peer_vtag; /* The peers last tag */ |
| 960 |
|
| 961 |
uint32_t my_vtag_nonce; |
| 962 |
uint32_t peer_vtag_nonce; |
| 963 |
|
| 964 |
uint32_t assoc_id; |
| 965 |
|
| 966 |
/* This is the SCTP fragmentation threshold */ |
| 967 |
uint32_t smallest_mtu; |
| 968 |
|
| 969 |
/* |
| 970 |
* Special hook for Fast retransmit, allows us to track the highest |
| 971 |
* TSN that is NEW in this SACK if gap ack blocks are present. |
| 972 |
*/ |
| 973 |
uint32_t this_sack_highest_gap; |
| 974 |
|
| 975 |
/* |
| 976 |
* The highest consecutive TSN that has been acked by peer on my |
| 977 |
* sends |
| 978 |
*/ |
| 979 |
uint32_t last_acked_seq; |
| 980 |
|
| 981 |
/* The next TSN that I will use in sending. */ |
| 982 |
uint32_t sending_seq; |
| 983 |
|
| 984 |
/* Original seq number I used ??questionable to keep?? */ |
| 985 |
uint32_t init_seq_number; |
| 986 |
|
| 987 |
|
| 988 |
/* The Advanced Peer Ack Point, as required by the PR-SCTP */ |
| 989 |
/* (A1 in Section 4.2) */ |
| 990 |
uint32_t advanced_peer_ack_point; |
| 991 |
|
| 992 |
/* |
| 993 |
* The highest consequetive TSN at the bottom of the mapping array |
| 994 |
* (for his sends). |
| 995 |
*/ |
| 996 |
uint32_t cumulative_tsn; |
| 997 |
/* |
| 998 |
* Used to track the mapping array and its offset bits. This MAY be |
| 999 |
* lower then cumulative_tsn. |
| 1000 |
*/ |
| 1001 |
uint32_t mapping_array_base_tsn; |
| 1002 |
/* |
| 1003 |
* used to track highest TSN we have received and is listed in the |
| 1004 |
* mapping array. |
| 1005 |
*/ |
| 1006 |
uint32_t highest_tsn_inside_map; |
| 1007 |
|
| 1008 |
/* EY - new NR variables used for nr_sack based on mapping_array*/ |
| 1009 |
uint8_t *nr_mapping_array; |
| 1010 |
uint32_t highest_tsn_inside_nr_map; |
| 1011 |
|
| 1012 |
uint32_t fast_recovery_tsn; |
| 1013 |
uint32_t sat_t3_recovery_tsn; |
| 1014 |
uint32_t tsn_last_delivered; |
| 1015 |
/* |
| 1016 |
* For the pd-api we should re-write this a bit more efficient. We |
| 1017 |
* could have multiple sctp_queued_to_read's that we are building at |
| 1018 |
* once. Now we only do this when we get ready to deliver to the |
| 1019 |
* socket buffer. Note that we depend on the fact that the struct is |
| 1020 |
* "stuck" on the read queue until we finish all the pd-api. |
| 1021 |
*/ |
| 1022 |
struct sctp_queued_to_read *control_pdapi; |
| 1023 |
|
| 1024 |
uint32_t tsn_of_pdapi_last_delivered; |
| 1025 |
uint32_t pdapi_ppid; |
| 1026 |
uint32_t context; |
| 1027 |
uint32_t last_reset_action[SCTP_MAX_RESET_PARAMS]; |
| 1028 |
uint32_t last_sending_seq[SCTP_MAX_RESET_PARAMS]; |
| 1029 |
uint32_t last_base_tsnsent[SCTP_MAX_RESET_PARAMS]; |
| 1030 |
#ifdef SCTP_ASOCLOG_OF_TSNS |
| 1031 |
/* |
| 1032 |
* special log - This adds considerable size |
| 1033 |
* to the asoc, but provides a log that you |
| 1034 |
* can use to detect problems via kgdb. |
| 1035 |
*/ |
| 1036 |
struct sctp_tsn_log in_tsnlog[SCTP_TSN_LOG_SIZE]; |
| 1037 |
struct sctp_tsn_log out_tsnlog[SCTP_TSN_LOG_SIZE]; |
| 1038 |
uint32_t cumack_log[SCTP_TSN_LOG_SIZE]; |
| 1039 |
uint32_t cumack_logsnt[SCTP_TSN_LOG_SIZE]; |
| 1040 |
uint16_t tsn_in_at; |
| 1041 |
uint16_t tsn_out_at; |
| 1042 |
uint16_t tsn_in_wrapped; |
| 1043 |
uint16_t tsn_out_wrapped; |
| 1044 |
uint16_t cumack_log_at; |
| 1045 |
uint16_t cumack_log_atsnt; |
| 1046 |
#endif /* SCTP_ASOCLOG_OF_TSNS */ |
| 1047 |
#ifdef SCTP_FS_SPEC_LOG |
| 1048 |
struct sctp_fs_spec_log fslog[SCTP_FS_SPEC_LOG_SIZE]; |
| 1049 |
uint16_t fs_index; |
| 1050 |
#endif |
| 1051 |
|
| 1052 |
/* |
| 1053 |
* window state information and smallest MTU that I use to bound |
| 1054 |
* segmentation |
| 1055 |
*/ |
| 1056 |
uint32_t peers_rwnd; |
| 1057 |
uint32_t my_rwnd; |
| 1058 |
uint32_t my_last_reported_rwnd; |
| 1059 |
uint32_t sctp_frag_point; |
| 1060 |
|
| 1061 |
uint32_t total_output_queue_size; |
| 1062 |
|
| 1063 |
uint32_t sb_cc; /* shadow of sb_cc */ |
| 1064 |
uint32_t sb_send_resv; /* amount reserved on a send */ |
| 1065 |
uint32_t my_rwnd_control_len; /* shadow of sb_mbcnt used for rwnd control */ |
| 1066 |
#ifdef INET6 |
| 1067 |
uint32_t default_flowlabel; |
| 1068 |
#endif |
| 1069 |
uint32_t pr_sctp_cnt; |
| 1070 |
int ctrl_queue_cnt; /* could be removed REM - NO IT CAN'T!! RRS */ |
| 1071 |
/* |
| 1072 |
* All outbound datagrams queue into this list from the individual |
| 1073 |
* stream queue. Here they get assigned a TSN and then await |
| 1074 |
* sending. The stream seq comes when it is first put in the |
| 1075 |
* individual str queue |
| 1076 |
*/ |
| 1077 |
unsigned int stream_queue_cnt; |
| 1078 |
unsigned int send_queue_cnt; |
| 1079 |
unsigned int sent_queue_cnt; |
| 1080 |
unsigned int sent_queue_cnt_removeable; |
| 1081 |
/* |
| 1082 |
* Number on sent queue that are marked for retran until this value |
| 1083 |
* is 0 we only send one packet of retran'ed data. |
| 1084 |
*/ |
| 1085 |
unsigned int sent_queue_retran_cnt; |
| 1086 |
|
| 1087 |
unsigned int size_on_reasm_queue; |
| 1088 |
unsigned int cnt_on_reasm_queue; |
| 1089 |
unsigned int fwd_tsn_cnt; |
| 1090 |
/* amount of data (bytes) currently in flight (on all destinations) */ |
| 1091 |
unsigned int total_flight; |
| 1092 |
/* Total book size in flight */ |
| 1093 |
unsigned int total_flight_count; /* count of chunks used with |
| 1094 |
* book total */ |
| 1095 |
/* count of destinaton nets and list of destination nets */ |
| 1096 |
unsigned int numnets; |
| 1097 |
|
| 1098 |
/* Total error count on this association */ |
| 1099 |
unsigned int overall_error_count; |
| 1100 |
|
| 1101 |
unsigned int cnt_msg_on_sb; |
| 1102 |
|
| 1103 |
/* All stream count of chunks for delivery */ |
| 1104 |
unsigned int size_on_all_streams; |
| 1105 |
unsigned int cnt_on_all_streams; |
| 1106 |
|
| 1107 |
/* Heart Beat delay in ms */ |
| 1108 |
uint32_t heart_beat_delay; |
| 1109 |
|
| 1110 |
/* autoclose */ |
| 1111 |
uint32_t sctp_autoclose_ticks; |
| 1112 |
|
| 1113 |
/* how many preopen streams we have */ |
| 1114 |
unsigned int pre_open_streams; |
| 1115 |
|
| 1116 |
/* How many streams I support coming into me */ |
| 1117 |
unsigned int max_inbound_streams; |
| 1118 |
|
| 1119 |
/* the cookie life I award for any cookie, in seconds */ |
| 1120 |
uint32_t cookie_life; |
| 1121 |
/* time to delay acks for */ |
| 1122 |
unsigned int delayed_ack; |
| 1123 |
unsigned int old_delayed_ack; |
| 1124 |
unsigned int sack_freq; |
| 1125 |
unsigned int data_pkts_seen; |
| 1126 |
|
| 1127 |
unsigned int numduptsns; |
| 1128 |
int dup_tsns[SCTP_MAX_DUP_TSNS]; |
| 1129 |
uint32_t initial_init_rto_max; /* initial RTO for INIT's */ |
| 1130 |
uint32_t initial_rto; /* initial send RTO */ |
| 1131 |
uint32_t minrto; /* per assoc RTO-MIN */ |
| 1132 |
uint32_t maxrto; /* per assoc RTO-MAX */ |
| 1133 |
|
| 1134 |
/* authentication fields */ |
| 1135 |
sctp_auth_chklist_t *local_auth_chunks; |
| 1136 |
sctp_auth_chklist_t *peer_auth_chunks; |
| 1137 |
sctp_hmaclist_t *local_hmacs; /* local HMACs supported */ |
| 1138 |
sctp_hmaclist_t *peer_hmacs; /* peer HMACs supported */ |
| 1139 |
struct sctp_keyhead shared_keys; /* assoc's shared keys */ |
| 1140 |
sctp_authinfo_t authinfo; /* randoms, cached keys */ |
| 1141 |
/* |
| 1142 |
* refcnt to block freeing when a sender or receiver is off coping |
| 1143 |
* user data in. |
| 1144 |
*/ |
| 1145 |
uint32_t refcnt; |
| 1146 |
uint32_t chunks_on_out_queue; /* total chunks floating around, |
| 1147 |
* locked by send socket buffer */ |
| 1148 |
uint32_t peers_adaptation; |
| 1149 |
uint32_t default_mtu; |
| 1150 |
uint16_t peer_hmac_id; /* peer HMAC id to send */ |
| 1151 |
|
| 1152 |
/* |
| 1153 |
* Being that we have no bag to collect stale cookies, and that we |
| 1154 |
* really would not want to anyway.. we will count them in this |
| 1155 |
* counter. We of course feed them to the pigeons right away (I have |
| 1156 |
* always thought of pigeons as flying rats). |
| 1157 |
*/ |
| 1158 |
uint16_t stale_cookie_count; |
| 1159 |
|
| 1160 |
/* |
| 1161 |
* For the partial delivery API, if up, invoked this is what last |
| 1162 |
* TSN I delivered |
| 1163 |
*/ |
| 1164 |
uint16_t str_of_pdapi; |
| 1165 |
uint16_t ssn_of_pdapi; |
| 1166 |
|
| 1167 |
/* counts of actual built streams. Allocation may be more however */ |
| 1168 |
/* could re-arrange to optimize space here. */ |
| 1169 |
uint16_t streamincnt; |
| 1170 |
uint16_t streamoutcnt; |
| 1171 |
uint16_t strm_realoutsize; |
| 1172 |
uint16_t strm_pending_add_size; |
| 1173 |
/* my maximum number of retrans of INIT and SEND */ |
| 1174 |
/* copied from SCTP but should be individually setable */ |
| 1175 |
uint16_t max_init_times; |
| 1176 |
uint16_t max_send_times; |
| 1177 |
|
| 1178 |
uint16_t def_net_failure; |
| 1179 |
|
| 1180 |
uint16_t def_net_pf_threshold; |
| 1181 |
|
| 1182 |
/* |
| 1183 |
* lock flag: 0 is ok to send, 1+ (duals as a retran count) is |
| 1184 |
* awaiting ACK |
| 1185 |
*/ |
| 1186 |
uint16_t mapping_array_size; |
| 1187 |
|
| 1188 |
uint16_t last_strm_seq_delivered; |
| 1189 |
uint16_t last_strm_no_delivered; |
| 1190 |
|
| 1191 |
uint16_t last_revoke_count; |
| 1192 |
int16_t num_send_timers_up; |
| 1193 |
|
| 1194 |
uint16_t stream_locked_on; |
| 1195 |
uint16_t ecn_echo_cnt_onq; |
| 1196 |
|
| 1197 |
uint16_t free_chunk_cnt; |
| 1198 |
uint8_t stream_locked; |
| 1199 |
uint8_t authenticated; /* packet authenticated ok */ |
| 1200 |
/* |
| 1201 |
* This flag indicates that a SACK need to be sent. |
| 1202 |
* Initially this is 1 to send the first sACK immediately. |
| 1203 |
*/ |
| 1204 |
uint8_t send_sack; |
| 1205 |
|
| 1206 |
/* max burst of new packets into the network */ |
| 1207 |
uint32_t max_burst; |
| 1208 |
/* max burst of fast retransmit packets */ |
| 1209 |
uint32_t fr_max_burst; |
| 1210 |
|
| 1211 |
uint8_t sat_network; /* RTT is in range of sat net or greater */ |
| 1212 |
uint8_t sat_network_lockout; /* lockout code */ |
| 1213 |
uint8_t burst_limit_applied; /* Burst limit in effect at last send? */ |
| 1214 |
/* flag goes on when we are doing a partial delivery api */ |
| 1215 |
uint8_t hb_random_values[4]; |
| 1216 |
uint8_t fragmented_delivery_inprogress; |
| 1217 |
uint8_t fragment_flags; |
| 1218 |
uint8_t last_flags_delivered; |
| 1219 |
uint8_t hb_ect_randombit; |
| 1220 |
uint8_t hb_random_idx; |
| 1221 |
uint8_t default_dscp; |
| 1222 |
uint8_t asconf_del_pending; /* asconf delete last addr pending */ |
| 1223 |
uint8_t trigger_reset; |
| 1224 |
/* |
| 1225 |
* This value, plus all other ack'd but above cum-ack is added |
| 1226 |
* together to cross check against the bit that we have yet to |
| 1227 |
* define (probably in the SACK). When the cum-ack is updated, this |
| 1228 |
* sum is updated as well. |
| 1229 |
*/ |
| 1230 |
|
| 1231 |
/* Flags whether an extension is supported or not */ |
| 1232 |
uint8_t ecn_supported; |
| 1233 |
uint8_t prsctp_supported; |
| 1234 |
uint8_t auth_supported; |
| 1235 |
uint8_t asconf_supported; |
| 1236 |
uint8_t reconfig_supported; |
| 1237 |
uint8_t nrsack_supported; |
| 1238 |
uint8_t pktdrop_supported; |
| 1239 |
uint8_t idata_supported; |
| 1240 |
|
| 1241 |
/* Did the peer make the stream config (add out) request */ |
| 1242 |
uint8_t peer_req_out; |
| 1243 |
|
| 1244 |
uint8_t local_strreset_support; |
| 1245 |
uint8_t peer_supports_nat; |
| 1246 |
|
| 1247 |
struct sctp_scoping scope; |
| 1248 |
/* flags to handle send alternate net tracking */ |
| 1249 |
uint8_t used_alt_asconfack; |
| 1250 |
uint8_t fast_retran_loss_recovery; |
| 1251 |
uint8_t sat_t3_loss_recovery; |
| 1252 |
uint8_t dropped_special_cnt; |
| 1253 |
uint8_t seen_a_sack_this_pkt; |
| 1254 |
uint8_t stream_reset_outstanding; |
| 1255 |
uint8_t stream_reset_out_is_outstanding; |
| 1256 |
uint8_t delayed_connection; |
| 1257 |
uint8_t ifp_had_enobuf; |
| 1258 |
uint8_t saw_sack_with_frags; |
| 1259 |
uint8_t saw_sack_with_nr_frags; |
| 1260 |
uint8_t in_asocid_hash; |
| 1261 |
uint8_t assoc_up_sent; |
| 1262 |
uint8_t adaptation_needed; |
| 1263 |
uint8_t adaptation_sent; |
| 1264 |
/* CMT variables */ |
| 1265 |
uint8_t cmt_dac_pkts_rcvd; |
| 1266 |
uint8_t sctp_cmt_on_off; |
| 1267 |
uint8_t iam_blocking; |
| 1268 |
uint8_t cookie_how[8]; |
| 1269 |
/* JRS 5/21/07 - CMT PF variable */ |
| 1270 |
uint8_t sctp_cmt_pf; |
| 1271 |
uint8_t use_precise_time; |
| 1272 |
uint64_t sctp_features; |
| 1273 |
uint32_t max_cwnd; |
| 1274 |
uint16_t port; /* remote UDP encapsulation port */ |
| 1275 |
/* |
| 1276 |
* The mapping array is used to track out of order sequences above |
| 1277 |
* last_acked_seq. 0 indicates packet missing 1 indicates packet |
| 1278 |
* rec'd. We slide it up every time we raise last_acked_seq and 0 |
| 1279 |
* trailing locactions out. If I get a TSN above the array |
| 1280 |
* mappingArraySz, I discard the datagram and let retransmit happen. |
| 1281 |
*/ |
| 1282 |
uint32_t marked_retrans; |
| 1283 |
uint32_t timoinit; |
| 1284 |
uint32_t timodata; |
| 1285 |
uint32_t timosack; |
| 1286 |
uint32_t timoshutdown; |
| 1287 |
uint32_t timoheartbeat; |
| 1288 |
uint32_t timocookie; |
| 1289 |
uint32_t timoshutdownack; |
| 1290 |
struct timeval start_time; |
| 1291 |
struct timeval discontinuity_time; |
| 1292 |
uint64_t abandoned_unsent[SCTP_PR_SCTP_MAX + 1]; |
| 1293 |
uint64_t abandoned_sent[SCTP_PR_SCTP_MAX + 1]; |
| 1294 |
}; |
| 1295 |
|
| 1296 |
#endif |