2 * SPDX-License-Identifier: BSD-3-Clause
4 * Copyright (c) 2001-2007, 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.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions are met:
11 * a) Redistributions of source code must retain the above copyright notice,
12 * this list of conditions and the following disclaimer.
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.
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.
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.
35 #if defined(__FreeBSD__) && !defined(__Userspace__)
36 #include <sys/cdefs.h>
37 __FBSDID("$FreeBSD: head/sys/netinet/sctp_pcb.h 362106 2020-06-12 16:31:13Z tuexen $");
40 #ifndef _NETINET_SCTP_PCB_H_
41 #define _NETINET_SCTP_PCB_H_
43 #include <netinet/sctp_os.h>
44 #include <netinet/sctp.h>
45 #include <netinet/sctp_constants.h>
46 #include <netinet/sctp_sysctl.h>
48 LIST_HEAD(sctppcbhead, sctp_inpcb);
49 LIST_HEAD(sctpasochead, sctp_tcb);
50 LIST_HEAD(sctpladdr, sctp_laddr);
51 LIST_HEAD(sctpvtaghead, sctp_tagblock);
52 LIST_HEAD(sctp_vrflist, sctp_vrf);
53 LIST_HEAD(sctp_ifnlist, sctp_ifn);
54 LIST_HEAD(sctp_ifalist, sctp_ifa);
55 TAILQ_HEAD(sctp_readhead, sctp_queued_to_read);
56 TAILQ_HEAD(sctp_streamhead, sctp_stream_queue_pending);
58 #include <netinet/sctp_structs.h>
59 #include <netinet/sctp_auth.h>
61 #define SCTP_PCBHASH_ALLADDR(port, mask) (port & mask)
62 #define SCTP_PCBHASH_ASOC(tag, mask) (tag & mask)
65 LIST_ENTRY (sctp_vrf) next_vrf;
66 struct sctp_ifalist *vrf_addr_hash;
67 struct sctp_ifnlist ifnlist;
69 uint32_t tbl_id_v4; /* default v4 table id */
70 uint32_t tbl_id_v6; /* default v6 table id */
71 uint32_t total_ifa_count;
72 u_long vrf_addr_hashmark;
77 struct sctp_ifalist ifalist;
79 LIST_ENTRY(sctp_ifn) next_ifn;
80 LIST_ENTRY(sctp_ifn) next_bucket;
81 void *ifn_p; /* never access without appropriate lock */
84 uint32_t ifn_index; /* shorthand way to look at ifn for reference */
85 uint32_t refcount; /* number of reference held should be >= ifa_count */
86 uint32_t ifa_count; /* IFA's we hold (in our list - ifalist)*/
87 uint32_t num_v6; /* number of v6 addresses */
88 uint32_t num_v4; /* number of v4 addresses */
89 uint32_t registered_af; /* registered address family for i/f events */
90 char ifn_name[SCTP_IFNAMSIZ];
93 /* SCTP local IFA flags */
94 #define SCTP_ADDR_VALID 0x00000001 /* its up and active */
95 #define SCTP_BEING_DELETED 0x00000002 /* being deleted,
96 * when refcount = 0. Note
97 * that it is pulled from the ifn list
98 * and ifa_p is nulled right away but
99 * it cannot be freed until the last *net
100 * pointing to it is deleted.
102 #define SCTP_ADDR_DEFER_USE 0x00000004 /* Hold off using this one */
103 #define SCTP_ADDR_IFA_UNUSEABLE 0x00000008
106 LIST_ENTRY(sctp_ifa) next_ifa;
107 LIST_ENTRY(sctp_ifa) next_bucket;
108 struct sctp_ifn *ifn_p; /* back pointer to parent ifn */
109 void *ifa; /* pointer to ifa, needed for flag
110 * update for that we MUST lock
111 * appropriate locks. This is for V6.
113 union sctp_sockstore address;
114 uint32_t refcount; /* number of folks referring to this */
116 uint32_t localifa_flags;
117 uint32_t vrf_id; /* vrf_id of this addr (for deleting) */
125 LIST_ENTRY(sctp_laddr) sctp_nxt_addr; /* next in list */
126 struct sctp_ifa *ifa;
127 uint32_t action; /* Used during asconf and adding
128 * if no-zero src-addr selection will
129 * not consider this address.
131 struct timeval start_time; /* time when this address was created */
134 struct sctp_block_entry {
138 struct sctp_timewait {
139 uint32_t tv_sec_at_expire; /* the seconds from boot to expire */
140 uint32_t v_tag; /* the vtag that can not be reused */
141 uint16_t lport; /* the local port used in vtag */
142 uint16_t rport; /* the remote port used in vtag */
145 struct sctp_tagblock {
146 LIST_ENTRY(sctp_tagblock) sctp_nxt_tagblock;
147 struct sctp_timewait vtag_block[SCTP_NUMBER_IN_VTAG_BLOCK];
152 #if defined(__FreeBSD__) && !defined(__Userspace__)
154 struct socket *udp4_tun_socket;
157 struct socket *udp6_tun_socket;
160 struct sctpasochead *sctp_asochash;
163 struct sctppcbhead *sctp_ephash;
167 * The TCP model represents a substantial overhead in that we get an
168 * additional hash table to keep explicit connections in. The
169 * listening TCP endpoint will exist in the usual ephash above and
170 * accept only INIT's. It will be incapable of sending off an INIT.
171 * When a dg arrives we must look in the normal ephash. If we find a
172 * TCP endpoint that will tell us to go to the specific endpoint
173 * hash and re-hash to find the right assoc/socket. If we find a UDP
174 * model socket we then must complete the lookup. If this fails,
175 * i.e. no association can be found then we must continue to see if
176 * a sctp_peeloff()'d socket is in the tcpephash (a spun off socket
177 * acts like a TCP model connected socket).
179 struct sctppcbhead *sctp_tcpephash;
181 uint32_t hashtblsize;
183 struct sctp_vrflist *sctp_vrfhash;
186 struct sctp_ifnlist *vrf_ifn_hash;
187 u_long vrf_ifn_hashmark;
189 struct sctppcbhead listhead;
190 struct sctpladdr addr_wq;
192 #if defined(__APPLE__) && !defined(__Userspace__)
193 struct inpcbhead inplisthead;
194 struct inpcbinfo sctbinfo;
197 sctp_zone_t ipi_zone_ep;
198 sctp_zone_t ipi_zone_asoc;
199 sctp_zone_t ipi_zone_laddr;
200 sctp_zone_t ipi_zone_net;
201 sctp_zone_t ipi_zone_chunk;
202 sctp_zone_t ipi_zone_readq;
203 sctp_zone_t ipi_zone_strmoq;
204 sctp_zone_t ipi_zone_asconf;
205 sctp_zone_t ipi_zone_asconf_ack;
207 #if defined(__FreeBSD__) && !defined(__Userspace__)
208 struct rwlock ipi_ep_mtx;
209 struct mtx ipi_iterator_wq_mtx;
210 struct rwlock ipi_addr_mtx;
211 struct mtx ipi_pktlog_mtx;
212 struct mtx wq_addr_mtx;
213 #elif defined(SCTP_PROCESS_LEVEL_LOCKS)
214 userland_mutex_t ipi_ep_mtx;
215 userland_mutex_t ipi_addr_mtx;
216 userland_mutex_t ipi_count_mtx;
217 userland_mutex_t ipi_pktlog_mtx;
218 userland_mutex_t wq_addr_mtx;
219 #elif defined(__APPLE__) && !defined(__Userspace__)
220 #ifdef _KERN_LOCKS_H_
221 lck_mtx_t *ipi_addr_mtx;
222 lck_mtx_t *ipi_count_mtx;
223 lck_mtx_t *ipi_pktlog_mtx;
224 lck_mtx_t *logging_mtx;
225 lck_mtx_t *wq_addr_mtx;
229 #endif /* _KERN_LOCKS_H_ */
230 #elif defined(_WIN32) && !defined(__Userspace__)
231 struct rwlock ipi_ep_lock;
232 struct rwlock ipi_addr_lock;
233 struct spinlock ipi_pktlog_mtx;
234 struct rwlock wq_addr_mtx;
235 #elif defined(__Userspace__)
237 uint32_t ipi_count_ep;
239 /* assoc/tcb zone info */
240 uint32_t ipi_count_asoc;
242 /* local addrlist zone info */
243 uint32_t ipi_count_laddr;
245 /* remote addrlist zone info */
246 uint32_t ipi_count_raddr;
248 /* chunk structure list for output */
249 uint32_t ipi_count_chunk;
251 /* socket queue zone info */
252 uint32_t ipi_count_readq;
254 /* socket queue zone info */
255 uint32_t ipi_count_strmoq;
258 uint32_t ipi_count_vrfs;
261 uint32_t ipi_count_ifns;
264 uint32_t ipi_count_ifas;
266 /* system wide number of free chunks hanging around */
267 uint32_t ipi_free_chunks;
268 uint32_t ipi_free_strmoq;
270 struct sctpvtaghead vtag_timewait[SCTP_STACK_VTAG_HASH_SIZE];
272 /* address work queue handling */
273 struct sctp_timer addr_wq_timer;
275 #if defined(_SCTP_NEEDS_CALLOUT_) || defined(_USER_SCTP_NEEDS_CALLOUT_)
276 struct calloutlist callqueue;
281 struct sctp_base_info {
282 /* All static structures that
283 * anchor the system must be here.
285 struct sctp_epinfo sctppcbinfo;
286 #if defined(__FreeBSD__) && !defined(__Userspace__)
287 #if defined(SMP) && defined(SCTP_USE_PERCPU_STAT)
288 struct sctpstat *sctpstat;
290 struct sctpstat sctpstat;
293 struct sctpstat sctpstat;
295 struct sctp_sysctl sctpsysctl;
297 char sctp_pcb_initialized;
298 #if defined(SCTP_PACKET_LOGGING)
299 int packet_log_writers;
301 uint8_t packet_log_buffer[SCTP_PACKET_LOG_SIZE];
303 #if defined(__FreeBSD__) && !defined(__Userspace__)
304 eventhandler_tag eh_tag;
306 #if defined(__APPLE__) && !defined(__Userspace__)
307 int sctp_main_timer_ticks;
309 #if defined(__Userspace__)
310 userland_mutex_t timer_mtx;
311 userland_thread_t timer_thread;
312 int timer_thread_should_exit;
313 int iterator_thread_started;
314 int timer_thread_started;
316 pthread_mutexattr_t mtx_attr;
317 #if defined(INET) || defined(INET6)
319 userland_thread_t recvthreadroute;
323 #if defined(_WIN32) && !defined(__MINGW32__)
324 SOCKET userspace_rawsctp;
325 SOCKET userspace_udpsctp;
327 int userspace_rawsctp;
328 int userspace_udpsctp;
330 userland_thread_t recvthreadraw;
331 userland_thread_t recvthreadudp;
334 #if defined(_WIN32) && !defined(__MINGW32__)
335 SOCKET userspace_rawsctp6;
336 SOCKET userspace_udpsctp6;
338 int userspace_rawsctp6;
339 int userspace_udpsctp6;
341 userland_thread_t recvthreadraw6;
342 userland_thread_t recvthreadudp6;
344 int (*conn_output)(void *addr, void *buffer, size_t length, uint8_t tos, uint8_t set_df);
345 void (*debug_printf)(const char *format, ...);
346 int crc32c_offloaded;
351 * Here we have all the relevant information for each SCTP entity created. We
352 * will need to modify this as approprate. We also need to figure out how to
353 * access /dev/random.
356 unsigned int time_of_secret_change; /* number of seconds from
358 uint32_t secret_key[SCTP_HOW_MANY_SECRETS][SCTP_NUMBER_OF_SECRETS];
359 unsigned int size_of_a_cookie;
361 uint32_t sctp_timeoutticks[SCTP_NUM_TMRS];
362 uint32_t sctp_minrto;
363 uint32_t sctp_maxrto;
364 uint32_t initial_rto;
365 uint32_t initial_init_rto_max;
367 unsigned int sctp_sack_freq;
368 uint32_t sctp_sws_sender;
369 uint32_t sctp_sws_receiver;
371 uint32_t sctp_default_cc_module;
372 uint32_t sctp_default_ss_module;
373 /* authentication related fields */
374 struct sctp_keyhead shared_keys;
375 sctp_auth_chklist_t *local_auth_chunks;
376 sctp_hmaclist_t *local_hmacs;
377 uint16_t default_keyid;
378 uint32_t default_mtu;
380 /* various thresholds */
381 /* Max times I will init at a guy */
382 uint16_t max_init_times;
384 /* Max times I will send before we consider someone dead */
385 uint16_t max_send_times;
387 uint16_t def_net_failure;
389 uint16_t def_net_pf_threshold;
391 /* number of streams to pre-open on a association */
392 uint16_t pre_open_stream_count;
393 uint16_t max_open_streams_intome;
395 /* random number generator */
396 uint32_t random_counter;
397 uint8_t random_numbers[SCTP_SIGNATURE_ALOC_SIZE];
398 uint8_t random_store[SCTP_SIGNATURE_ALOC_SIZE];
401 * This timer is kept running per endpoint. When it fires it will
402 * change the secret key. The default is once a hour
404 struct sctp_timer signature_change;
406 uint32_t def_cookie_life;
408 uint32_t auto_close_time;
409 uint32_t initial_sequence_debug;
410 uint32_t adaptation_layer_indicator;
411 uint8_t adaptation_layer_indicator_provided;
414 uint32_t fr_max_burst;
416 uint32_t default_flowlabel;
418 uint8_t default_dscp;
419 char current_secret_number;
420 char last_secret_number;
421 uint16_t port; /* remote UDP encapsulation port */
424 #ifndef SCTP_ALIGNMENT
425 #define SCTP_ALIGNMENT 32
429 #define SCTP_ALIGNM1 (SCTP_ALIGNMENT-1)
432 #define sctp_lport ip_inp.inp.inp_lport
434 struct sctp_pcbtsn_rlog {
441 #define SCTP_READ_LOG_SIZE 135 /* we choose the number to make a pcb a page */
446 * put an inpcb in front of it all, kind of a waste but we need to
447 * for compatibility with all the other stuff.
451 char align[(sizeof(struct inpcb) + SCTP_ALIGNM1) &
455 #if defined(__APPLE__) && !defined(__Userspace__)
456 /* leave some space in case i386 inpcb is bigger than ppc */
457 uint8_t padding[128];
460 /* Socket buffer lock protects read_queue and of course sb_cc */
461 struct sctp_readhead read_queue;
463 LIST_ENTRY(sctp_inpcb) sctp_list; /* lists all endpoints */
464 /* hash of all endpoints for model */
465 LIST_ENTRY(sctp_inpcb) sctp_hash;
466 /* count of local addresses bound, 0 if bound all */
469 /* list of addrs in use by the EP, NULL if bound-all */
470 struct sctpladdr sctp_addr_list;
471 /* used for source address selection rotation when we are subset bound */
472 struct sctp_laddr *next_addr_touse;
474 /* back pointer to our socket */
475 struct socket *sctp_socket;
476 uint64_t sctp_features; /* Feature flags */
477 uint32_t sctp_flags; /* INP state flag set */
478 uint32_t sctp_mobility_features; /* Mobility Feature flags */
479 struct sctp_pcb sctp_ep;/* SCTP ep data */
480 /* head of the hash of all associations */
481 struct sctpasochead *sctp_tcbhash;
482 u_long sctp_hashmark;
483 /* head of the list of all associations */
484 struct sctpasochead sctp_asoc_list;
485 #ifdef SCTP_TRACK_FREED_ASOCS
486 struct sctpasochead sctp_asoc_free_list;
488 struct sctp_iterator *inp_starting_point_for_iterator;
489 uint32_t sctp_frag_point;
490 uint32_t partial_delivery_point;
491 uint32_t sctp_context;
493 uint8_t local_strreset_support;
494 uint32_t sctp_cmt_on_off;
495 uint8_t ecn_supported;
496 uint8_t prsctp_supported;
497 uint8_t auth_supported;
498 uint8_t idata_supported;
499 uint8_t asconf_supported;
500 uint8_t reconfig_supported;
501 uint8_t nrsack_supported;
502 uint8_t pktdrop_supported;
503 struct sctp_nonpad_sndrcvinfo def_send;
505 * These three are here for the sosend_dgram
506 * (pkt, pkt_last and control).
507 * routine. However, I don't think anyone in
508 * the current FreeBSD kernel calls this. So
509 * they are candidates with sctp_sendm for
512 struct mbuf *pkt, *pkt_last;
513 struct mbuf *control;
514 #if defined(__FreeBSD__) && !defined(__Userspace__)
516 struct mtx inp_create_mtx;
517 struct mtx inp_rdata_mtx;
519 #elif defined(SCTP_PROCESS_LEVEL_LOCKS)
520 userland_mutex_t inp_mtx;
521 userland_mutex_t inp_create_mtx;
522 userland_mutex_t inp_rdata_mtx;
524 #elif defined(__APPLE__) && !defined(__Userspace__)
525 #if defined(SCTP_APPLE_RWLOCK)
530 lck_mtx_t *inp_create_mtx;
531 lck_mtx_t *inp_rdata_mtx;
532 #elif defined(_WIN32) && !defined(__Userspace__)
533 struct rwlock inp_lock;
534 struct spinlock inp_create_lock;
535 struct spinlock inp_rdata_lock;
537 #elif defined(__Userspace__)
540 #if defined(__APPLE__) && !defined(__Userspace__)
543 uint32_t lock_caller1;
544 uint32_t lock_caller2;
545 uint32_t lock_caller3;
546 uint32_t unlock_caller1;
547 uint32_t unlock_caller2;
548 uint32_t unlock_caller3;
549 uint32_t getlock_caller1;
550 uint32_t getlock_caller2;
551 uint32_t getlock_caller3;
553 uint32_t lock_gen_count;
554 uint32_t unlock_gen_count;
555 uint32_t getlock_gen_count;
557 uint32_t i_am_here_file;
558 uint32_t i_am_here_line;
567 uint32_t total_sends;
568 uint32_t total_recvs;
569 uint32_t last_abort_code;
570 uint32_t total_nospaces;
571 struct sctpasochead *sctp_asocidhash;
572 u_long hashasocidmark;
573 uint32_t sctp_associd_counter;
575 #ifdef SCTP_ASOCLOG_OF_TSNS
576 struct sctp_pcbtsn_rlog readlog[SCTP_READ_LOG_SIZE];
577 uint32_t readlog_index;
579 #if defined(__Userspace__)
581 int (*recv_callback)(struct socket *, union sctp_sockstore, void *, size_t,
582 struct sctp_rcvinfo, int, void *);
583 uint32_t send_sb_threshold;
584 int (*send_callback)(struct socket *, uint32_t);
588 #if defined(__Userspace__)
589 int register_recv_cb (struct socket *,
590 int (*)(struct socket *, union sctp_sockstore, void *, size_t,
591 struct sctp_rcvinfo, int, void *));
592 int register_send_cb (struct socket *, uint32_t, int (*)(struct socket *, uint32_t));
593 int register_ulp_info (struct socket *, void *);
594 int retrieve_ulp_info (struct socket *, void **);
598 struct socket *sctp_socket; /* back pointer to socket */
599 struct sctp_inpcb *sctp_ep; /* back pointer to ep */
600 LIST_ENTRY(sctp_tcb) sctp_tcbhash; /* next link in hash
602 LIST_ENTRY(sctp_tcb) sctp_tcblist; /* list of all of the
604 LIST_ENTRY(sctp_tcb) sctp_tcbasocidhash; /* next link in asocid
607 LIST_ENTRY(sctp_tcb) sctp_asocs; /* vtag hash list */
608 struct sctp_block_entry *block_entry; /* pointer locked by socket
610 struct sctp_association asoc;
612 * freed_by_sorcv_sincelast is protected by the sockbuf_lock NOT the
613 * tcb_lock. Its special in this way to help avoid extra mutex calls
614 * in the reading of data.
616 uint32_t freed_by_sorcv_sincelast;
617 uint32_t total_sends;
618 uint32_t total_recvs;
619 int freed_from_where;
620 uint16_t rport; /* remote port in network format */
622 #if defined(__FreeBSD__) && !defined(__Userspace__)
624 struct mtx tcb_send_mtx;
625 #elif defined(SCTP_PROCESS_LEVEL_LOCKS)
626 userland_mutex_t tcb_mtx;
627 userland_mutex_t tcb_send_mtx;
628 #elif defined(__APPLE__) && !defined(__Userspace__)
630 lck_mtx_t* tcb_send_mtx;
631 #elif defined(_WIN32) && !defined(__Userspace__)
632 struct spinlock tcb_lock;
633 struct spinlock tcb_send_lock;
634 #elif defined(__Userspace__)
636 #if defined(__APPLE__) && !defined(__Userspace__)
644 #if defined(__FreeBSD__) && !defined(__Userspace__)
646 #include <netinet/sctp_lock_bsd.h>
648 #elif defined(__APPLE__) && !defined(__Userspace__)
650 * Apple MacOS X 10.4 "Tiger"
653 #include <netinet/sctp_lock_apple_fg.h>
655 #elif defined(SCTP_PROCESS_LEVEL_LOCKS)
657 #include <netinet/sctp_process_lock.h>
659 #elif defined(_WIN32) && !defined(__Userspace__)
661 #include <netinet/sctp_lock_windows.h>
663 #elif defined(__Userspace__)
665 #include <netinet/sctp_lock_userspace.h>
669 * Pre-5.x FreeBSD, and others.
671 #include <netinet/sctp_lock_empty.h>
674 #if defined(_KERNEL) || defined(__Userspace__)
676 /* Attention Julian, this is the extern that
677 * goes with the base info. sctp_pcb.c has
678 * the real definition.
680 #if defined(__FreeBSD__) && !defined(__Userspace__)
681 VNET_DECLARE(struct sctp_base_info, system_base_info) ;
683 extern struct sctp_base_info system_base_info;
687 int SCTP6_ARE_ADDR_EQUAL(struct sockaddr_in6 *a, struct sockaddr_in6 *b);
690 void sctp_fill_pcbinfo(struct sctp_pcbinfo *);
693 sctp_find_ifn(void *ifn, uint32_t ifn_index);
695 struct sctp_vrf *sctp_allocate_vrf(int vrfid);
696 struct sctp_vrf *sctp_find_vrf(uint32_t vrfid);
697 void sctp_free_vrf(struct sctp_vrf *vrf);
700 * Change address state, can be used if
701 * O/S supports telling transports about
702 * changes to IFA/IFN's (link layer triggers).
703 * If a ifn goes down, we will do src-addr-selection
704 * and NOT use that, as a source address. This does
705 * not stop the routing system from routing out
706 * that interface, but we won't put it as a source.
708 void sctp_mark_ifa_addr_down(uint32_t vrf_id, struct sockaddr *addr, const char *if_name, uint32_t ifn_index);
709 void sctp_mark_ifa_addr_up(uint32_t vrf_id, struct sockaddr *addr, const char *if_name, uint32_t ifn_index);
712 sctp_add_addr_to_vrf(uint32_t vrfid,
713 void *ifn, uint32_t ifn_index, uint32_t ifn_type,
715 void *ifa, struct sockaddr *addr, uint32_t ifa_flags,
718 void sctp_update_ifn_mtu(uint32_t ifn_index, uint32_t mtu);
720 void sctp_free_ifn(struct sctp_ifn *sctp_ifnp);
721 void sctp_free_ifa(struct sctp_ifa *sctp_ifap);
724 void sctp_del_addr_from_vrf(uint32_t vrfid, struct sockaddr *addr,
725 uint32_t ifn_index, const char *if_name);
729 struct sctp_nets *sctp_findnet(struct sctp_tcb *, struct sockaddr *);
731 struct sctp_inpcb *sctp_pcb_findep(struct sockaddr *, int, int, uint32_t);
733 #if defined(__FreeBSD__) && !defined(__Userspace__)
734 int sctp_inpcb_bind(struct socket *, struct sockaddr *,
735 struct sctp_ifa *,struct thread *);
736 #elif defined(_WIN32) && !defined(__Userspace__)
737 int sctp_inpcb_bind(struct socket *, struct sockaddr *,
738 struct sctp_ifa *,PKTHREAD);
740 /* struct proc is a dummy for __Userspace__ */
741 int sctp_inpcb_bind(struct socket *, struct sockaddr *,
742 struct sctp_ifa *, struct proc *);
746 sctp_findassociation_addr(struct mbuf *, int,
747 struct sockaddr *, struct sockaddr *,
748 struct sctphdr *, struct sctp_chunkhdr *, struct sctp_inpcb **,
749 struct sctp_nets **, uint32_t vrf_id);
752 sctp_findassociation_addr_sa(struct sockaddr *,
753 struct sockaddr *, struct sctp_inpcb **, struct sctp_nets **, int, uint32_t);
756 sctp_move_pcb_and_assoc(struct sctp_inpcb *, struct sctp_inpcb *,
760 * For this call ep_addr, the to is the destination endpoint address of the
761 * peer (relative to outbound). The from field is only used if the TCP model
762 * is enabled and helps distingush amongst the subset bound (non-boundall).
763 * The TCP model MAY change the actual ep field, this is why it is passed.
766 sctp_findassociation_ep_addr(struct sctp_inpcb **,
767 struct sockaddr *, struct sctp_nets **, struct sockaddr *,
771 sctp_findasoc_ep_asocid_locked(struct sctp_inpcb *inp, sctp_assoc_t asoc_id, int want_lock);
774 sctp_findassociation_ep_asocid(struct sctp_inpcb *,
778 sctp_findassociation_ep_asconf(struct mbuf *, int, struct sockaddr *,
779 struct sctphdr *, struct sctp_inpcb **, struct sctp_nets **, uint32_t vrf_id);
781 int sctp_inpcb_alloc(struct socket *so, uint32_t vrf_id);
783 int sctp_is_address_on_local_host(struct sockaddr *addr, uint32_t vrf_id);
785 void sctp_inpcb_free(struct sctp_inpcb *, int, int);
787 #define SCTP_DONT_INITIALIZE_AUTH_PARAMS 0
788 #define SCTP_INITIALIZE_AUTH_PARAMS 1
790 #if defined(__FreeBSD__) && !defined(__Userspace__)
792 sctp_aloc_assoc(struct sctp_inpcb *, struct sockaddr *,
793 int *, uint32_t, uint32_t, uint16_t, uint16_t, struct thread *,
795 #elif defined(_WIN32) && !defined(__Userspace__)
797 sctp_aloc_assoc(struct sctp_inpcb *, struct sockaddr *,
798 int *, uint32_t, uint32_t, uint16_t, uint16_t, PKTHREAD, int);
800 /* proc will be NULL for __Userspace__ */
802 sctp_aloc_assoc(struct sctp_inpcb *, struct sockaddr *,
803 int *, uint32_t, uint32_t, uint16_t, uint16_t, struct proc *,
807 int sctp_free_assoc(struct sctp_inpcb *, struct sctp_tcb *, int, int);
810 void sctp_delete_from_timewait(uint32_t, uint16_t, uint16_t);
812 int sctp_is_in_timewait(uint32_t tag, uint16_t lport, uint16_t rport);
815 sctp_add_vtag_to_timewait(uint32_t tag, uint32_t time, uint16_t lport, uint16_t rport);
817 void sctp_add_local_addr_ep(struct sctp_inpcb *, struct sctp_ifa *, uint32_t);
819 void sctp_del_local_addr_ep(struct sctp_inpcb *, struct sctp_ifa *);
821 int sctp_add_remote_addr(struct sctp_tcb *, struct sockaddr *, struct sctp_nets **, uint16_t, int, int);
823 void sctp_remove_net(struct sctp_tcb *, struct sctp_nets *);
825 int sctp_del_remote_addr(struct sctp_tcb *, struct sockaddr *);
827 #if defined(__Userspace__)
828 void sctp_pcb_init(int);
830 void sctp_pcb_init(void);
833 void sctp_pcb_finish(void);
835 void sctp_add_local_addr_restricted(struct sctp_tcb *, struct sctp_ifa *);
836 void sctp_del_local_addr_restricted(struct sctp_tcb *, struct sctp_ifa *);
839 sctp_load_addresses_from_init(struct sctp_tcb *, struct mbuf *, int, int,
840 struct sockaddr *, struct sockaddr *, struct sockaddr *, uint16_t);
843 sctp_set_primary_addr(struct sctp_tcb *, struct sockaddr *,
846 int sctp_is_vtag_good(uint32_t, uint16_t lport, uint16_t rport, struct timeval *);
848 /* void sctp_drain(void); */
850 int sctp_destination_is_reachable(struct sctp_tcb *, struct sockaddr *);
852 int sctp_swap_inpcb_for_listen(struct sctp_inpcb *inp);
854 void sctp_clean_up_stream(struct sctp_tcb *stcb, struct sctp_readhead *rh);
857 * Null in last arg inpcb indicate run on ALL ep's. Specific inp in last arg
858 * indicates run on ONLY assoc's of the specified endpoint.
861 sctp_initiate_iterator(inp_func inpf,
870 #if defined(__FreeBSD__) && !defined(__Userspace__)
871 #if defined(SCTP_MCORE_INPUT) && defined(SMP)
873 sctp_queue_to_mcore(struct mbuf *m, int off, int cpu_to_use);
879 #endif /* !__sctp_pcb_h__ */