sctp_structs.h 40 KB

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