xref: /freebsd/sys/netinet/sctp_pcb.h (revision f677a9e2672665f4eb3dd4111c07ee8f1f954262)
1 /*-
2  * Copyright (c) 2001-2007, by Cisco Systems, Inc. All rights reserved.
3  * Copyright (c) 2008-2012, by Randall Stewart. All rights reserved.
4  * Copyright (c) 2008-2012, by Michael Tuexen. All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions are met:
8  *
9  * a) Redistributions of source code must retain the above copyright notice,
10  *    this list of conditions and the following disclaimer.
11  *
12  * b) Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in
14  *    the documentation and/or other materials provided with the distribution.
15  *
16  * c) Neither the name of Cisco Systems, Inc. nor the names of its
17  *    contributors may be used to endorse or promote products derived
18  *    from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
24  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
30  * THE POSSIBILITY OF SUCH DAMAGE.
31  */
32 
33 #include <sys/cdefs.h>
34 __FBSDID("$FreeBSD$");
35 
36 #ifndef _NETINET_SCTP_PCB_H_
37 #define _NETINET_SCTP_PCB_H_
38 
39 #include <netinet/sctp_os.h>
40 #include <netinet/sctp.h>
41 #include <netinet/sctp_constants.h>
42 #include <netinet/sctp_sysctl.h>
43 
44 LIST_HEAD(sctppcbhead, sctp_inpcb);
45 LIST_HEAD(sctpasochead, sctp_tcb);
46 LIST_HEAD(sctpladdr, sctp_laddr);
47 LIST_HEAD(sctpvtaghead, sctp_tagblock);
48 LIST_HEAD(sctp_vrflist, sctp_vrf);
49 LIST_HEAD(sctp_ifnlist, sctp_ifn);
50 LIST_HEAD(sctp_ifalist, sctp_ifa);
51 TAILQ_HEAD(sctp_readhead, sctp_queued_to_read);
52 TAILQ_HEAD(sctp_streamhead, sctp_stream_queue_pending);
53 
54 #include <netinet/sctp_structs.h>
55 #include <netinet/sctp_auth.h>
56 
57 #define SCTP_PCBHASH_ALLADDR(port, mask) (port & mask)
58 #define SCTP_PCBHASH_ASOC(tag, mask) (tag & mask)
59 
60 struct sctp_vrf {
61 	LIST_ENTRY(sctp_vrf) next_vrf;
62 	struct sctp_ifalist *vrf_addr_hash;
63 	struct sctp_ifnlist ifnlist;
64 	uint32_t vrf_id;
65 	uint32_t tbl_id_v4;	/* default v4 table id */
66 	uint32_t tbl_id_v6;	/* default v6 table id */
67 	uint32_t total_ifa_count;
68 	u_long vrf_addr_hashmark;
69 	uint32_t refcount;
70 };
71 
72 struct sctp_ifn {
73 	struct sctp_ifalist ifalist;
74 	struct sctp_vrf *vrf;
75 	         LIST_ENTRY(sctp_ifn) next_ifn;
76 	         LIST_ENTRY(sctp_ifn) next_bucket;
77 	void *ifn_p;		/* never access without appropriate lock */
78 	uint32_t ifn_mtu;
79 	uint32_t ifn_type;
80 	uint32_t ifn_index;	/* shorthand way to look at ifn for reference */
81 	uint32_t refcount;	/* number of reference held should be >=
82 				 * ifa_count */
83 	uint32_t ifa_count;	/* IFA's we hold (in our list - ifalist) */
84 	uint32_t num_v6;	/* number of v6 addresses */
85 	uint32_t num_v4;	/* number of v4 addresses */
86 	uint32_t registered_af;	/* registered address family for i/f events */
87 	char ifn_name[SCTP_IFNAMSIZ];
88 };
89 
90 /* SCTP local IFA flags */
91 #define SCTP_ADDR_VALID         0x00000001	/* its up and active */
92 #define SCTP_BEING_DELETED      0x00000002	/* being deleted, when
93 						 * refcount = 0. Note that it
94 						 * is pulled from the ifn list
95 						 * and ifa_p is nulled right
96 						 * away but it cannot be freed
97 						 * until the last *net
98 						 * pointing to it is deleted. */
99 #define SCTP_ADDR_DEFER_USE     0x00000004	/* Hold off using this one */
100 #define SCTP_ADDR_IFA_UNUSEABLE 0x00000008
101 
102 struct sctp_ifa {
103 	LIST_ENTRY(sctp_ifa) next_ifa;
104 	LIST_ENTRY(sctp_ifa) next_bucket;
105 	struct sctp_ifn *ifn_p;	/* back pointer to parent ifn */
106 	void *ifa;		/* pointer to ifa, needed for flag update for
107 				 * that we MUST lock appropriate locks. This
108 				 * is for V6. */
109 	union sctp_sockstore address;
110 	uint32_t refcount;	/* number of folks refering to this */
111 	uint32_t flags;
112 	uint32_t localifa_flags;
113 	uint32_t vrf_id;	/* vrf_id of this addr (for deleting) */
114 	uint8_t src_is_loop;
115 	uint8_t src_is_priv;
116 	uint8_t src_is_glob;
117 	uint8_t resv;
118 };
119 
120 struct sctp_laddr {
121 	LIST_ENTRY(sctp_laddr) sctp_nxt_addr;	/* next in list */
122 	struct sctp_ifa *ifa;
123 	uint32_t action;	/* Used during asconf and adding if no-zero
124 				 * src-addr selection will not consider this
125 				 * address. */
126 	struct timeval start_time;	/* time when this address was created */
127 };
128 
129 struct sctp_block_entry {
130 	int error;
131 };
132 
133 struct sctp_timewait {
134 	uint32_t tv_sec_at_expire;	/* the seconds from boot to expire */
135 	uint32_t v_tag;		/* the vtag that can not be reused */
136 	uint16_t lport;		/* the local port used in vtag */
137 	uint16_t rport;		/* the remote port used in vtag */
138 };
139 
140 struct sctp_tagblock {
141 	LIST_ENTRY(sctp_tagblock) sctp_nxt_tagblock;
142 	struct sctp_timewait vtag_block[SCTP_NUMBER_IN_VTAG_BLOCK];
143 };
144 
145 
146 struct sctp_epinfo {
147 #ifdef INET
148 	struct socket *udp4_tun_socket;
149 #endif
150 #ifdef INET6
151 	struct socket *udp6_tun_socket;
152 #endif
153 	struct sctpasochead *sctp_asochash;
154 	u_long hashasocmark;
155 
156 	struct sctppcbhead *sctp_ephash;
157 	u_long hashmark;
158 
159 	/*-
160 	 * The TCP model represents a substantial overhead in that we get an
161 	 * additional hash table to keep explicit connections in. The
162 	 * listening TCP endpoint will exist in the usual ephash above and
163 	 * accept only INIT's. It will be incapable of sending off an INIT.
164 	 * When a dg arrives we must look in the normal ephash. If we find a
165 	 * TCP endpoint that will tell us to go to the specific endpoint
166 	 * hash and re-hash to find the right assoc/socket. If we find a UDP
167 	 * model socket we then must complete the lookup. If this fails,
168 	 * i.e. no association can be found then we must continue to see if
169 	 * a sctp_peeloff()'d socket is in the tcpephash (a spun off socket
170 	 * acts like a TCP model connected socket).
171 	 */
172 	struct sctppcbhead *sctp_tcpephash;
173 	u_long hashtcpmark;
174 	uint32_t hashtblsize;
175 
176 	struct sctp_vrflist *sctp_vrfhash;
177 	u_long hashvrfmark;
178 
179 	struct sctp_ifnlist *vrf_ifn_hash;
180 	u_long vrf_ifn_hashmark;
181 
182 	struct sctppcbhead listhead;
183 	struct sctpladdr addr_wq;
184 
185 	/* ep zone info */
186 	sctp_zone_t ipi_zone_ep;
187 	sctp_zone_t ipi_zone_asoc;
188 	sctp_zone_t ipi_zone_laddr;
189 	sctp_zone_t ipi_zone_net;
190 	sctp_zone_t ipi_zone_chunk;
191 	sctp_zone_t ipi_zone_readq;
192 	sctp_zone_t ipi_zone_strmoq;
193 	sctp_zone_t ipi_zone_asconf;
194 	sctp_zone_t ipi_zone_asconf_ack;
195 
196 	struct rwlock ipi_ep_mtx;
197 	struct mtx ipi_iterator_wq_mtx;
198 	struct rwlock ipi_addr_mtx;
199 	struct mtx ipi_pktlog_mtx;
200 	struct mtx wq_addr_mtx;
201 	uint32_t ipi_count_ep;
202 
203 	/* assoc/tcb zone info */
204 	uint32_t ipi_count_asoc;
205 
206 	/* local addrlist zone info */
207 	uint32_t ipi_count_laddr;
208 
209 	/* remote addrlist zone info */
210 	uint32_t ipi_count_raddr;
211 
212 	/* chunk structure list for output */
213 	uint32_t ipi_count_chunk;
214 
215 	/* socket queue zone info */
216 	uint32_t ipi_count_readq;
217 
218 	/* socket queue zone info */
219 	uint32_t ipi_count_strmoq;
220 
221 	/* Number of vrfs */
222 	uint32_t ipi_count_vrfs;
223 
224 	/* Number of ifns */
225 	uint32_t ipi_count_ifns;
226 
227 	/* Number of ifas */
228 	uint32_t ipi_count_ifas;
229 
230 	/* system wide number of free chunks hanging around */
231 	uint32_t ipi_free_chunks;
232 	uint32_t ipi_free_strmoq;
233 
234 	struct sctpvtaghead vtag_timewait[SCTP_STACK_VTAG_HASH_SIZE];
235 
236 	/* address work queue handling */
237 	struct sctp_timer addr_wq_timer;
238 
239 };
240 
241 
242 struct sctp_base_info {
243 	/*
244 	 * All static structures that anchor the system must be here.
245 	 */
246 	struct sctp_epinfo sctppcbinfo;
247 #if defined(__FreeBSD__) && defined(SMP) && defined(SCTP_USE_PERCPU_STAT)
248 	struct sctpstat *sctpstat;
249 #else
250 	struct sctpstat sctpstat;
251 #endif
252 	struct sctp_sysctl sctpsysctl;
253 	uint8_t first_time;
254 	char sctp_pcb_initialized;
255 #if defined(SCTP_PACKET_LOGGING)
256 	int packet_log_writers;
257 	int packet_log_end;
258 	uint8_t packet_log_buffer[SCTP_PACKET_LOG_SIZE];
259 #endif
260 };
261 
262 /*-
263  * Here we have all the relevant information for each SCTP entity created. We
264  * will need to modify this as approprate. We also need to figure out how to
265  * access /dev/random.
266  */
267 struct sctp_pcb {
268 	unsigned int time_of_secret_change;	/* number of seconds from
269 						 * timeval.tv_sec */
270 	uint32_t secret_key[SCTP_HOW_MANY_SECRETS][SCTP_NUMBER_OF_SECRETS];
271 	unsigned int size_of_a_cookie;
272 
273 	unsigned int sctp_timeoutticks[SCTP_NUM_TMRS];
274 	unsigned int sctp_minrto;
275 	unsigned int sctp_maxrto;
276 	unsigned int initial_rto;
277 	int initial_init_rto_max;
278 
279 	unsigned int sctp_sack_freq;
280 	uint32_t sctp_sws_sender;
281 	uint32_t sctp_sws_receiver;
282 
283 	uint32_t sctp_default_cc_module;
284 	uint32_t sctp_default_ss_module;
285 	/* authentication related fields */
286 	struct sctp_keyhead shared_keys;
287 	sctp_auth_chklist_t *local_auth_chunks;
288 	sctp_hmaclist_t *local_hmacs;
289 	uint16_t default_keyid;
290 
291 	/* various thresholds */
292 	/* Max times I will init at a guy */
293 	uint16_t max_init_times;
294 
295 	/* Max times I will send before we consider someone dead */
296 	uint16_t max_send_times;
297 
298 	uint16_t def_net_failure;
299 
300 	uint16_t def_net_pf_threshold;
301 
302 	/* number of streams to pre-open on a association */
303 	uint16_t pre_open_stream_count;
304 	uint16_t max_open_streams_intome;
305 
306 	/* random number generator */
307 	uint32_t random_counter;
308 	uint8_t random_numbers[SCTP_SIGNATURE_ALOC_SIZE];
309 	uint8_t random_store[SCTP_SIGNATURE_ALOC_SIZE];
310 
311 	/*
312 	 * This timer is kept running per endpoint.  When it fires it will
313 	 * change the secret key.  The default is once a hour
314 	 */
315 	struct sctp_timer signature_change;
316 
317 	/* Zero copy full buffer timer */
318 	struct sctp_timer zero_copy_timer;
319 	/* Zero copy app to transport (sendq) read repulse timer */
320 	struct sctp_timer zero_copy_sendq_timer;
321 	uint32_t def_cookie_life;
322 	/* defaults to 0 */
323 	int auto_close_time;
324 	uint32_t initial_sequence_debug;
325 	uint32_t adaptation_layer_indicator;
326 	uint8_t adaptation_layer_indicator_provided;
327 	uint32_t store_at;
328 	uint32_t max_burst;
329 	uint32_t fr_max_burst;
330 #ifdef INET6
331 	uint32_t default_flowlabel;
332 #endif
333 	uint8_t default_dscp;
334 	char current_secret_number;
335 	char last_secret_number;
336 	uint16_t port;		/* remote UDP encapsulation port */
337 };
338 
339 #ifndef SCTP_ALIGNMENT
340 #define SCTP_ALIGNMENT 32
341 #endif
342 
343 #ifndef SCTP_ALIGNM1
344 #define SCTP_ALIGNM1 (SCTP_ALIGNMENT-1)
345 #endif
346 
347 #define sctp_lport ip_inp.inp.inp_lport
348 
349 struct sctp_pcbtsn_rlog {
350 	uint32_t vtag;
351 	uint16_t strm;
352 	uint16_t seq;
353 	uint16_t sz;
354 	uint16_t flgs;
355 };
356 
357 #define SCTP_READ_LOG_SIZE 135	/* we choose the number to make a pcb a page */
358 
359 
360 struct sctp_inpcb {
361 	/*-
362 	 * put an inpcb in front of it all, kind of a waste but we need to
363 	 * for compatability with all the other stuff.
364 	 */
365 	union {
366 		struct inpcb inp;
367 		char align[(sizeof(struct in6pcb) + SCTP_ALIGNM1) &
368 		        ~SCTP_ALIGNM1];
369 	}     ip_inp;
370 
371 
372 	/* Socket buffer lock protects read_queue and of course sb_cc */
373 	struct sctp_readhead read_queue;
374 
375 	              LIST_ENTRY(sctp_inpcb) sctp_list;	/* lists all endpoints */
376 	/* hash of all endpoints for model */
377 	              LIST_ENTRY(sctp_inpcb) sctp_hash;
378 	/* count of local addresses bound, 0 if bound all */
379 	int laddr_count;
380 
381 	/* list of addrs in use by the EP, NULL if bound-all */
382 	struct sctpladdr sctp_addr_list;
383 	/*
384 	 * used for source address selection rotation when we are subset
385 	 * bound
386 	 */
387 	struct sctp_laddr *next_addr_touse;
388 
389 	/* back pointer to our socket */
390 	struct socket *sctp_socket;
391 	uint64_t sctp_features;	/* Feature flags */
392 	uint32_t sctp_flags;	/* INP state flag set */
393 	uint32_t sctp_mobility_features;	/* Mobility  Feature flags */
394 	struct sctp_pcb sctp_ep;/* SCTP ep data */
395 	/* head of the hash of all associations */
396 	struct sctpasochead *sctp_tcbhash;
397 	u_long sctp_hashmark;
398 	/* head of the list of all associations */
399 	struct sctpasochead sctp_asoc_list;
400 #ifdef SCTP_TRACK_FREED_ASOCS
401 	struct sctpasochead sctp_asoc_free_list;
402 #endif
403 	struct sctp_iterator *inp_starting_point_for_iterator;
404 	uint32_t sctp_frag_point;
405 	uint32_t partial_delivery_point;
406 	uint32_t sctp_context;
407 	uint8_t local_strreset_support;
408 	uint32_t sctp_cmt_on_off;
409 	uint32_t sctp_ecn_enable;
410 	struct sctp_nonpad_sndrcvinfo def_send;
411 	/*-
412 	 * These three are here for the sosend_dgram
413 	 * (pkt, pkt_last and control).
414 	 * routine. However, I don't think anyone in
415 	 * the current FreeBSD kernel calls this. So
416 	 * they are candidates with sctp_sendm for
417 	 * de-supporting.
418 	 */
419 	struct mbuf *pkt, *pkt_last;
420 	struct mbuf *control;
421 	struct mtx inp_mtx;
422 	struct mtx inp_create_mtx;
423 	struct mtx inp_rdata_mtx;
424 	int32_t refcount;
425 	uint32_t def_vrf_id;
426 	uint32_t total_sends;
427 	uint32_t total_recvs;
428 	uint32_t last_abort_code;
429 	uint32_t total_nospaces;
430 	struct sctpasochead *sctp_asocidhash;
431 	u_long hashasocidmark;
432 	uint32_t sctp_associd_counter;
433 
434 #ifdef SCTP_ASOCLOG_OF_TSNS
435 	struct sctp_pcbtsn_rlog readlog[SCTP_READ_LOG_SIZE];
436 	uint32_t readlog_index;
437 #endif
438 };
439 
440 struct sctp_tcb {
441 	struct socket *sctp_socket;	/* back pointer to socket */
442 	struct sctp_inpcb *sctp_ep;	/* back pointer to ep */
443 	           LIST_ENTRY(sctp_tcb) sctp_tcbhash;	/* next link in hash
444 							 * table */
445 	           LIST_ENTRY(sctp_tcb) sctp_tcblist;	/* list of all of the
446 							 * TCB's */
447 	           LIST_ENTRY(sctp_tcb) sctp_tcbasocidhash;	/* next link in asocid
448 								 * hash table */
449 	           LIST_ENTRY(sctp_tcb) sctp_asocs;	/* vtag hash list */
450 	struct sctp_block_entry *block_entry;	/* pointer locked by  socket
451 						 * send buffer */
452 	struct sctp_association asoc;
453 	/*-
454 	 * freed_by_sorcv_sincelast is protected by the sockbuf_lock NOT the
455 	 * tcb_lock. Its special in this way to help avoid extra mutex calls
456 	 * in the reading of data.
457 	 */
458 	uint32_t freed_by_sorcv_sincelast;
459 	uint32_t total_sends;
460 	uint32_t total_recvs;
461 	int freed_from_where;
462 	uint16_t rport;		/* remote port in network format */
463 	uint16_t resv;
464 	struct mtx tcb_mtx;
465 	struct mtx tcb_send_mtx;
466 };
467 
468 
469 
470 #include <netinet/sctp_lock_bsd.h>
471 
472 
473 /* TODO where to put non-_KERNEL things for __Userspace__? */
474 #if defined(_KERNEL) || defined(__Userspace__)
475 
476 /* Attention Julian, this is the extern that
477  * goes with the base info. sctp_pcb.c has
478  * the real definition.
479  */
480 VNET_DECLARE(struct sctp_base_info, system_base_info);
481 
482 #ifdef INET6
483 int SCTP6_ARE_ADDR_EQUAL(struct sockaddr_in6 *a, struct sockaddr_in6 *b);
484 
485 #endif
486 
487 void sctp_fill_pcbinfo(struct sctp_pcbinfo *);
488 
489 struct sctp_ifn *
490          sctp_find_ifn(void *ifn, uint32_t ifn_index);
491 
492 struct sctp_vrf *sctp_allocate_vrf(int vrfid);
493 struct sctp_vrf *sctp_find_vrf(uint32_t vrfid);
494 void sctp_free_vrf(struct sctp_vrf *vrf);
495 
496 /*-
497  * Change address state, can be used if
498  * O/S supports telling transports about
499  * changes to IFA/IFN's (link layer triggers).
500  * If a ifn goes down, we will do src-addr-selection
501  * and NOT use that, as a source address. This does
502  * not stop the routing system from routing out
503  * that interface, but we won't put it as a source.
504  */
505 void sctp_mark_ifa_addr_down(uint32_t vrf_id, struct sockaddr *addr, const char *if_name, uint32_t ifn_index);
506 void sctp_mark_ifa_addr_up(uint32_t vrf_id, struct sockaddr *addr, const char *if_name, uint32_t ifn_index);
507 
508 struct sctp_ifa *
509 sctp_add_addr_to_vrf(uint32_t vrfid,
510     void *ifn, uint32_t ifn_index, uint32_t ifn_type,
511     const char *if_name,
512     void *ifa, struct sockaddr *addr, uint32_t ifa_flags,
513     int dynamic_add);
514 
515 void sctp_update_ifn_mtu(uint32_t ifn_index, uint32_t mtu);
516 
517 void sctp_free_ifn(struct sctp_ifn *sctp_ifnp);
518 void sctp_free_ifa(struct sctp_ifa *sctp_ifap);
519 
520 
521 void
522 sctp_del_addr_from_vrf(uint32_t vrfid, struct sockaddr *addr,
523     uint32_t ifn_index, const char *if_name);
524 
525 
526 
527 struct sctp_nets *sctp_findnet(struct sctp_tcb *, struct sockaddr *);
528 
529 struct sctp_inpcb *sctp_pcb_findep(struct sockaddr *, int, int, uint32_t);
530 
531 int
532 sctp_inpcb_bind(struct socket *, struct sockaddr *,
533     struct sctp_ifa *, struct thread *);
534 
535 struct sctp_tcb *
536 sctp_findassociation_addr(struct mbuf *, int,
537     struct sockaddr *, struct sockaddr *,
538     struct sctphdr *, struct sctp_chunkhdr *, struct sctp_inpcb **,
539     struct sctp_nets **, uint32_t vrf_id);
540 
541 struct sctp_tcb *
542 sctp_findassociation_addr_sa(struct sockaddr *,
543     struct sockaddr *, struct sctp_inpcb **, struct sctp_nets **, int, uint32_t);
544 
545 void
546 sctp_move_pcb_and_assoc(struct sctp_inpcb *, struct sctp_inpcb *,
547     struct sctp_tcb *);
548 
549 /*-
550  * For this call ep_addr, the to is the destination endpoint address of the
551  * peer (relative to outbound). The from field is only used if the TCP model
552  * is enabled and helps distingush amongst the subset bound (non-boundall).
553  * The TCP model MAY change the actual ep field, this is why it is passed.
554  */
555 struct sctp_tcb *
556 sctp_findassociation_ep_addr(struct sctp_inpcb **,
557     struct sockaddr *, struct sctp_nets **, struct sockaddr *,
558     struct sctp_tcb *);
559 
560 struct sctp_tcb *
561          sctp_findasoc_ep_asocid_locked(struct sctp_inpcb *inp, sctp_assoc_t asoc_id, int want_lock);
562 
563 struct sctp_tcb *
564 sctp_findassociation_ep_asocid(struct sctp_inpcb *,
565     sctp_assoc_t, int);
566 
567 struct sctp_tcb *
568 sctp_findassociation_ep_asconf(struct mbuf *, int, struct sockaddr *,
569     struct sctphdr *, struct sctp_inpcb **, struct sctp_nets **, uint32_t vrf_id);
570 
571 int sctp_inpcb_alloc(struct socket *so, uint32_t vrf_id);
572 
573 int sctp_is_address_on_local_host(struct sockaddr *addr, uint32_t vrf_id);
574 
575 void sctp_inpcb_free(struct sctp_inpcb *, int, int);
576 
577 struct sctp_tcb *
578 sctp_aloc_assoc(struct sctp_inpcb *, struct sockaddr *,
579     int *, uint32_t, uint32_t, struct thread *);
580 
581 int sctp_free_assoc(struct sctp_inpcb *, struct sctp_tcb *, int, int);
582 
583 
584 void sctp_delete_from_timewait(uint32_t, uint16_t, uint16_t);
585 
586 int sctp_is_in_timewait(uint32_t tag, uint16_t lport, uint16_t rport);
587 
588 void
589      sctp_add_vtag_to_timewait(uint32_t tag, uint32_t time, uint16_t lport, uint16_t rport);
590 
591 void sctp_add_local_addr_ep(struct sctp_inpcb *, struct sctp_ifa *, uint32_t);
592 
593 int sctp_insert_laddr(struct sctpladdr *, struct sctp_ifa *, uint32_t);
594 
595 void sctp_remove_laddr(struct sctp_laddr *);
596 
597 void sctp_del_local_addr_ep(struct sctp_inpcb *, struct sctp_ifa *);
598 
599 int sctp_add_remote_addr(struct sctp_tcb *, struct sockaddr *, struct sctp_nets **, int, int);
600 
601 void sctp_remove_net(struct sctp_tcb *, struct sctp_nets *);
602 
603 int sctp_del_remote_addr(struct sctp_tcb *, struct sockaddr *);
604 
605 void sctp_pcb_init(void);
606 
607 void sctp_pcb_finish(void);
608 
609 void sctp_add_local_addr_restricted(struct sctp_tcb *, struct sctp_ifa *);
610 void sctp_del_local_addr_restricted(struct sctp_tcb *, struct sctp_ifa *);
611 
612 int
613 sctp_load_addresses_from_init(struct sctp_tcb *, struct mbuf *, int, int,
614     struct sockaddr *, struct sockaddr *, struct sockaddr *);
615 
616 int
617 sctp_set_primary_addr(struct sctp_tcb *, struct sockaddr *,
618     struct sctp_nets *);
619 
620 int sctp_is_vtag_good(uint32_t, uint16_t lport, uint16_t rport, struct timeval *);
621 
622 /* void sctp_drain(void); */
623 
624 int sctp_destination_is_reachable(struct sctp_tcb *, struct sockaddr *);
625 
626 int sctp_swap_inpcb_for_listen(struct sctp_inpcb *inp);
627 
628 /*-
629  * Null in last arg inpcb indicate run on ALL ep's. Specific inp in last arg
630  * indicates run on ONLY assoc's of the specified endpoint.
631  */
632 int
633 sctp_initiate_iterator(inp_func inpf,
634     asoc_func af,
635     inp_func inpe,
636     uint32_t, uint32_t,
637     uint32_t, void *,
638     uint32_t,
639     end_func ef,
640     struct sctp_inpcb *,
641     uint8_t co_off);
642 
643 #if defined(__FreeBSD__) && defined(SCTP_MCORE_INPUT) && defined(SMP)
644 void
645      sctp_queue_to_mcore(struct mbuf *m, int off, int cpu_to_use);
646 
647 #endif
648 
649 #ifdef INVARIANTS
650 void
651      sctp_validate_no_locks(struct sctp_inpcb *inp);
652 
653 #endif
654 
655 #endif				/* _KERNEL */
656 #endif				/* !__sctp_pcb_h__ */
657