sctp_pcb.h revision 225549
1199044Sgabor/*-
2199044Sgabor * Copyright (c) 2001-2007, by Cisco Systems, Inc. All rights reserved.
3199044Sgabor * Copyright (c) 2008-2011, by Randall Stewart. All rights reserved.
4199044Sgabor * Copyright (c) 2008-2011, by Michael Tuexen. All rights reserved.
5199044Sgabor * Redistribution and use in source and binary forms, with or without
6199044Sgabor * modification, are permitted provided that the following conditions are met:
7199044Sgabor *
8199044Sgabor * a) Redistributions of source code must retain the above copyright notice,
9199044Sgabor *   this list of conditions and the following disclaimer.
10199044Sgabor *
11199044Sgabor * b) Redistributions in binary form must reproduce the above copyright
12199044Sgabor *    notice, this list of conditions and the following disclaimer in
13199044Sgabor *   the documentation and/or other materials provided with the distribution.
14199044Sgabor *
15199044Sgabor * c) Neither the name of Cisco Systems, Inc. nor the names of its
16199044Sgabor *    contributors may be used to endorse or promote products derived
17199044Sgabor *    from this software without specific prior written permission.
18199044Sgabor *
19199044Sgabor * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20199044Sgabor * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
21199044Sgabor * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22199044Sgabor * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
23199044Sgabor * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24199044Sgabor * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25199044Sgabor * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26199044Sgabor * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27199044Sgabor * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28199044Sgabor * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
29199044Sgabor * THE POSSIBILITY OF SUCH DAMAGE.
30199044Sgabor */
31199044Sgabor
32199044Sgabor/* $KAME: sctp_pcb.h,v 1.21 2005/07/16 01:18:47 suz Exp $	 */
33199044Sgabor
34199044Sgabor#include <sys/cdefs.h>
35199044Sgabor__FBSDID("$FreeBSD: head/sys/netinet/sctp_pcb.h 225549 2011-09-14 08:15:21Z tuexen $");
36199044Sgabor
37199044Sgabor#ifndef __sctp_pcb_h__
38199044Sgabor#define __sctp_pcb_h__
39199044Sgabor
40199044Sgabor#include <netinet/sctp_os.h>
41199044Sgabor#include <netinet/sctp.h>
42199044Sgabor#include <netinet/sctp_constants.h>
43199044Sgabor#include <netinet/sctp_sysctl.h>
44199044Sgabor
45199044SgaborLIST_HEAD(sctppcbhead, sctp_inpcb);
46199044SgaborLIST_HEAD(sctpasochead, sctp_tcb);
47199044SgaborLIST_HEAD(sctpladdr, sctp_laddr);
48199044SgaborLIST_HEAD(sctpvtaghead, sctp_tagblock);
49199044SgaborLIST_HEAD(sctp_vrflist, sctp_vrf);
50199044SgaborLIST_HEAD(sctp_ifnlist, sctp_ifn);
51199044SgaborLIST_HEAD(sctp_ifalist, sctp_ifa);
52199044SgaborTAILQ_HEAD(sctp_readhead, sctp_queued_to_read);
53199044SgaborTAILQ_HEAD(sctp_streamhead, sctp_stream_queue_pending);
54199044Sgabor
55199044Sgabor#include <netinet/sctp_structs.h>
56199044Sgabor#include <netinet/sctp_auth.h>
57199044Sgabor
58199044Sgabor#define SCTP_PCBHASH_ALLADDR(port, mask) (port & mask)
59199044Sgabor#define SCTP_PCBHASH_ASOC(tag, mask) (tag & mask)
60199044Sgabor
61199044Sgaborstruct sctp_vrf {
62199044Sgabor	LIST_ENTRY(sctp_vrf) next_vrf;
63199044Sgabor	struct sctp_ifalist *vrf_addr_hash;
64199044Sgabor	struct sctp_ifnlist ifnlist;
65199044Sgabor	uint32_t vrf_id;
66199044Sgabor	uint32_t tbl_id_v4;	/* default v4 table id */
67199044Sgabor	uint32_t tbl_id_v6;	/* default v6 table id */
68199044Sgabor	uint32_t total_ifa_count;
69199044Sgabor	u_long vrf_addr_hashmark;
70199044Sgabor	uint32_t refcount;
71199044Sgabor};
72199044Sgabor
73199044Sgaborstruct sctp_ifn {
74199044Sgabor	struct sctp_ifalist ifalist;
75199044Sgabor	struct sctp_vrf *vrf;
76199044Sgabor	         LIST_ENTRY(sctp_ifn) next_ifn;
77199044Sgabor	         LIST_ENTRY(sctp_ifn) next_bucket;
78199044Sgabor	void *ifn_p;		/* never access without appropriate lock */
79199044Sgabor	uint32_t ifn_mtu;
80199044Sgabor	uint32_t ifn_type;
81199044Sgabor	uint32_t ifn_index;	/* shorthand way to look at ifn for reference */
82199044Sgabor	uint32_t refcount;	/* number of reference held should be >=
83199044Sgabor				 * ifa_count */
84199044Sgabor	uint32_t ifa_count;	/* IFA's we hold (in our list - ifalist) */
85199044Sgabor	uint32_t num_v6;	/* number of v6 addresses */
86199044Sgabor	uint32_t num_v4;	/* number of v4 addresses */
87199044Sgabor	uint32_t registered_af;	/* registered address family for i/f events */
88199044Sgabor	char ifn_name[SCTP_IFNAMSIZ];
89199044Sgabor};
90199044Sgabor
91199044Sgabor/* SCTP local IFA flags */
92199044Sgabor#define SCTP_ADDR_VALID         0x00000001	/* its up and active */
93199044Sgabor#define SCTP_BEING_DELETED      0x00000002	/* being deleted, when
94199044Sgabor						 * refcount = 0. Note that it
95199044Sgabor						 * is pulled from the ifn list
96199044Sgabor						 * and ifa_p is nulled right
97199044Sgabor						 * away but it cannot be freed
98199044Sgabor						 * until the last *net
99199044Sgabor						 * pointing to it is deleted. */
100199044Sgabor#define SCTP_ADDR_DEFER_USE     0x00000004	/* Hold off using this one */
101199044Sgabor#define SCTP_ADDR_IFA_UNUSEABLE 0x00000008
102199044Sgabor
103199044Sgaborstruct sctp_ifa {
104199044Sgabor	LIST_ENTRY(sctp_ifa) next_ifa;
105199044Sgabor	LIST_ENTRY(sctp_ifa) next_bucket;
106199044Sgabor	struct sctp_ifn *ifn_p;	/* back pointer to parent ifn */
107199044Sgabor	void *ifa;		/* pointer to ifa, needed for flag update for
108199044Sgabor				 * that we MUST lock appropriate locks. This
109199044Sgabor				 * is for V6. */
110199044Sgabor	union sctp_sockstore address;
111199044Sgabor	uint32_t refcount;	/* number of folks refering to this */
112199044Sgabor	uint32_t flags;
113199044Sgabor	uint32_t localifa_flags;
114199044Sgabor	uint32_t vrf_id;	/* vrf_id of this addr (for deleting) */
115199044Sgabor	uint8_t src_is_loop;
116199044Sgabor	uint8_t src_is_priv;
117199044Sgabor	uint8_t src_is_glob;
118199044Sgabor	uint8_t resv;
119199044Sgabor};
120199044Sgabor
121199044Sgaborstruct sctp_laddr {
122199044Sgabor	LIST_ENTRY(sctp_laddr) sctp_nxt_addr;	/* next in list */
123199044Sgabor	struct sctp_ifa *ifa;
124199044Sgabor	uint32_t action;	/* Used during asconf and adding if no-zero
125199044Sgabor				 * src-addr selection will not consider this
126199044Sgabor				 * address. */
127199044Sgabor	struct timeval start_time;	/* time when this address was created */
128199044Sgabor};
129199044Sgabor
130199044Sgaborstruct sctp_block_entry {
131199044Sgabor	int error;
132199044Sgabor};
133199044Sgabor
134199044Sgaborstruct sctp_timewait {
135199044Sgabor	uint32_t tv_sec_at_expire;	/* the seconds from boot to expire */
136199044Sgabor	uint32_t v_tag;		/* the vtag that can not be reused */
137199044Sgabor	uint16_t lport;		/* the local port used in vtag */
138199044Sgabor	uint16_t rport;		/* the remote port used in vtag */
139199044Sgabor};
140199044Sgabor
141199044Sgaborstruct sctp_tagblock {
142199044Sgabor	LIST_ENTRY(sctp_tagblock) sctp_nxt_tagblock;
143199044Sgabor	struct sctp_timewait vtag_block[SCTP_NUMBER_IN_VTAG_BLOCK];
144199044Sgabor};
145199044Sgabor
146199044Sgabor
147199044Sgaborstruct sctp_epinfo {
148199044Sgabor	struct socket *udp_tun_socket;
149199044Sgabor	struct sctpasochead *sctp_asochash;
150199044Sgabor	u_long hashasocmark;
151199044Sgabor
152199044Sgabor	struct sctppcbhead *sctp_ephash;
153199044Sgabor	u_long hashmark;
154199044Sgabor
155199044Sgabor	/*-
156199044Sgabor	 * The TCP model represents a substantial overhead in that we get an
157199044Sgabor	 * additional hash table to keep explicit connections in. The
158199044Sgabor	 * listening TCP endpoint will exist in the usual ephash above and
159199044Sgabor	 * accept only INIT's. It will be incapable of sending off an INIT.
160199044Sgabor	 * When a dg arrives we must look in the normal ephash. If we find a
161199044Sgabor	 * TCP endpoint that will tell us to go to the specific endpoint
162199044Sgabor	 * hash and re-hash to find the right assoc/socket. If we find a UDP
163199044Sgabor	 * model socket we then must complete the lookup. If this fails,
164199044Sgabor	 * i.e. no association can be found then we must continue to see if
165199044Sgabor	 * a sctp_peeloff()'d socket is in the tcpephash (a spun off socket
166199044Sgabor	 * acts like a TCP model connected socket).
167199044Sgabor	 */
168199044Sgabor	struct sctppcbhead *sctp_tcpephash;
169199044Sgabor	u_long hashtcpmark;
170199044Sgabor	uint32_t hashtblsize;
171199044Sgabor
172199044Sgabor	struct sctp_vrflist *sctp_vrfhash;
173199044Sgabor	u_long hashvrfmark;
174199044Sgabor
175199044Sgabor	struct sctp_ifnlist *vrf_ifn_hash;
176199044Sgabor	u_long vrf_ifn_hashmark;
177199044Sgabor
178199044Sgabor	struct sctppcbhead listhead;
179199044Sgabor	struct sctpladdr addr_wq;
180199044Sgabor
181199044Sgabor	/* ep zone info */
182199044Sgabor	sctp_zone_t ipi_zone_ep;
183199044Sgabor	sctp_zone_t ipi_zone_asoc;
184199044Sgabor	sctp_zone_t ipi_zone_laddr;
185199044Sgabor	sctp_zone_t ipi_zone_net;
186199044Sgabor	sctp_zone_t ipi_zone_chunk;
187199044Sgabor	sctp_zone_t ipi_zone_readq;
188199044Sgabor	sctp_zone_t ipi_zone_strmoq;
189199044Sgabor	sctp_zone_t ipi_zone_asconf;
190199044Sgabor	sctp_zone_t ipi_zone_asconf_ack;
191199044Sgabor
192199044Sgabor	struct rwlock ipi_ep_mtx;
193199044Sgabor	struct mtx ipi_iterator_wq_mtx;
194199044Sgabor	struct rwlock ipi_addr_mtx;
195199044Sgabor	struct mtx ipi_pktlog_mtx;
196199044Sgabor	struct mtx wq_addr_mtx;
197199044Sgabor	uint32_t ipi_count_ep;
198199044Sgabor
199199044Sgabor	/* assoc/tcb zone info */
200199044Sgabor	uint32_t ipi_count_asoc;
201199044Sgabor
202199044Sgabor	/* local addrlist zone info */
203199044Sgabor	uint32_t ipi_count_laddr;
204199044Sgabor
205199044Sgabor	/* remote addrlist zone info */
206199044Sgabor	uint32_t ipi_count_raddr;
207199044Sgabor
208199044Sgabor	/* chunk structure list for output */
209199044Sgabor	uint32_t ipi_count_chunk;
210199044Sgabor
211199044Sgabor	/* socket queue zone info */
212199044Sgabor	uint32_t ipi_count_readq;
213199044Sgabor
214199044Sgabor	/* socket queue zone info */
215199044Sgabor	uint32_t ipi_count_strmoq;
216199044Sgabor
217199044Sgabor	/* Number of vrfs */
218199044Sgabor	uint32_t ipi_count_vrfs;
219199044Sgabor
220199044Sgabor	/* Number of ifns */
221199044Sgabor	uint32_t ipi_count_ifns;
222199044Sgabor
223199044Sgabor	/* Number of ifas */
224199044Sgabor	uint32_t ipi_count_ifas;
225199044Sgabor
226199044Sgabor	/* system wide number of free chunks hanging around */
227199044Sgabor	uint32_t ipi_free_chunks;
228199044Sgabor	uint32_t ipi_free_strmoq;
229199044Sgabor
230199044Sgabor	struct sctpvtaghead vtag_timewait[SCTP_STACK_VTAG_HASH_SIZE];
231199044Sgabor
232199044Sgabor	/* address work queue handling */
233199044Sgabor	struct sctp_timer addr_wq_timer;
234199044Sgabor
235199044Sgabor};
236199044Sgabor
237199044Sgabor
238199044Sgaborstruct sctp_base_info {
239199044Sgabor	/*
240199044Sgabor	 * All static structures that anchor the system must be here.
241199044Sgabor	 */
242199044Sgabor	struct sctp_epinfo sctppcbinfo;
243199044Sgabor#if defined(__FreeBSD__) && defined(SMP) && defined(SCTP_USE_PERCPU_STAT)
244199044Sgabor	struct sctpstat *sctpstat;
245199044Sgabor#else
246199044Sgabor	struct sctpstat sctpstat;
247199044Sgabor#endif
248199044Sgabor	struct sctp_sysctl sctpsysctl;
249199044Sgabor	uint8_t first_time;
250199044Sgabor	char sctp_pcb_initialized;
251199044Sgabor#if defined(SCTP_PACKET_LOGGING)
252199044Sgabor	int packet_log_writers;
253199044Sgabor	int packet_log_end;
254199044Sgabor	uint8_t packet_log_buffer[SCTP_PACKET_LOG_SIZE];
255199044Sgabor#endif
256199044Sgabor};
257199044Sgabor
258199044Sgabor/*-
259199044Sgabor * Here we have all the relevant information for each SCTP entity created. We
260 * will need to modify this as approprate. We also need to figure out how to
261 * access /dev/random.
262 */
263struct sctp_pcb {
264	unsigned int time_of_secret_change;	/* number of seconds from
265						 * timeval.tv_sec */
266	uint32_t secret_key[SCTP_HOW_MANY_SECRETS][SCTP_NUMBER_OF_SECRETS];
267	unsigned int size_of_a_cookie;
268
269	unsigned int sctp_timeoutticks[SCTP_NUM_TMRS];
270	unsigned int sctp_minrto;
271	unsigned int sctp_maxrto;
272	unsigned int initial_rto;
273	int initial_init_rto_max;
274
275	unsigned int sctp_sack_freq;
276	uint32_t sctp_sws_sender;
277	uint32_t sctp_sws_receiver;
278
279	uint32_t sctp_default_cc_module;
280	uint32_t sctp_default_ss_module;
281	/* authentication related fields */
282	struct sctp_keyhead shared_keys;
283	sctp_auth_chklist_t *local_auth_chunks;
284	sctp_hmaclist_t *local_hmacs;
285	uint16_t default_keyid;
286
287	/* various thresholds */
288	/* Max times I will init at a guy */
289	uint16_t max_init_times;
290
291	/* Max times I will send before we consider someone dead */
292	uint16_t max_send_times;
293
294	uint16_t def_net_failure;
295
296	uint16_t def_net_pf_threshold;
297
298	/* number of streams to pre-open on a association */
299	uint16_t pre_open_stream_count;
300	uint16_t max_open_streams_intome;
301
302	/* random number generator */
303	uint32_t random_counter;
304	uint8_t random_numbers[SCTP_SIGNATURE_ALOC_SIZE];
305	uint8_t random_store[SCTP_SIGNATURE_ALOC_SIZE];
306
307	/*
308	 * This timer is kept running per endpoint.  When it fires it will
309	 * change the secret key.  The default is once a hour
310	 */
311	struct sctp_timer signature_change;
312
313	/* Zero copy full buffer timer */
314	struct sctp_timer zero_copy_timer;
315	/* Zero copy app to transport (sendq) read repulse timer */
316	struct sctp_timer zero_copy_sendq_timer;
317	uint32_t def_cookie_life;
318	/* defaults to 0 */
319	int auto_close_time;
320	uint32_t initial_sequence_debug;
321	uint32_t adaptation_layer_indicator;
322	uint32_t store_at;
323	uint32_t max_burst;
324	uint32_t fr_max_burst;
325#ifdef INET6
326	uint32_t default_flowlabel;
327#endif
328	uint8_t default_dscp;
329	char current_secret_number;
330	char last_secret_number;
331};
332
333#ifndef SCTP_ALIGNMENT
334#define SCTP_ALIGNMENT 32
335#endif
336
337#ifndef SCTP_ALIGNM1
338#define SCTP_ALIGNM1 (SCTP_ALIGNMENT-1)
339#endif
340
341#define sctp_lport ip_inp.inp.inp_lport
342
343struct sctp_pcbtsn_rlog {
344	uint32_t vtag;
345	uint16_t strm;
346	uint16_t seq;
347	uint16_t sz;
348	uint16_t flgs;
349};
350
351#define SCTP_READ_LOG_SIZE 135	/* we choose the number to make a pcb a page */
352
353
354struct sctp_inpcb {
355	/*-
356	 * put an inpcb in front of it all, kind of a waste but we need to
357	 * for compatability with all the other stuff.
358	 */
359	union {
360		struct inpcb inp;
361		char align[(sizeof(struct in6pcb) + SCTP_ALIGNM1) &
362		        ~SCTP_ALIGNM1];
363	}     ip_inp;
364
365
366	/* Socket buffer lock protects read_queue and of course sb_cc */
367	struct sctp_readhead read_queue;
368
369	              LIST_ENTRY(sctp_inpcb) sctp_list;	/* lists all endpoints */
370	/* hash of all endpoints for model */
371	              LIST_ENTRY(sctp_inpcb) sctp_hash;
372	/* count of local addresses bound, 0 if bound all */
373	int laddr_count;
374
375	/* list of addrs in use by the EP, NULL if bound-all */
376	struct sctpladdr sctp_addr_list;
377	/*
378	 * used for source address selection rotation when we are subset
379	 * bound
380	 */
381	struct sctp_laddr *next_addr_touse;
382
383	/* back pointer to our socket */
384	struct socket *sctp_socket;
385	uint32_t sctp_flags;	/* INP state flag set */
386	uint32_t sctp_features;	/* Feature flags */
387	uint32_t sctp_mobility_features;	/* Mobility  Feature flags */
388	struct sctp_pcb sctp_ep;/* SCTP ep data */
389	/* head of the hash of all associations */
390	struct sctpasochead *sctp_tcbhash;
391	u_long sctp_hashmark;
392	/* head of the list of all associations */
393	struct sctpasochead sctp_asoc_list;
394#ifdef SCTP_TRACK_FREED_ASOCS
395	struct sctpasochead sctp_asoc_free_list;
396#endif
397	struct sctp_iterator *inp_starting_point_for_iterator;
398	uint32_t sctp_frag_point;
399	uint32_t partial_delivery_point;
400	uint32_t sctp_context;
401	uint32_t sctp_cmt_on_off;
402	uint32_t sctp_ecn_enable;
403	struct sctp_nonpad_sndrcvinfo def_send;
404	/*-
405	 * These three are here for the sosend_dgram
406	 * (pkt, pkt_last and control).
407	 * routine. However, I don't think anyone in
408	 * the current FreeBSD kernel calls this. So
409	 * they are candidates with sctp_sendm for
410	 * de-supporting.
411	 */
412	struct mbuf *pkt, *pkt_last;
413	struct mbuf *control;
414	struct mtx inp_mtx;
415	struct mtx inp_create_mtx;
416	struct mtx inp_rdata_mtx;
417	int32_t refcount;
418	uint32_t def_vrf_id;
419	uint32_t total_sends;
420	uint32_t total_recvs;
421	uint32_t last_abort_code;
422	uint32_t total_nospaces;
423	struct sctpasochead *sctp_asocidhash;
424	u_long hashasocidmark;
425	uint32_t sctp_associd_counter;
426
427#ifdef SCTP_ASOCLOG_OF_TSNS
428	struct sctp_pcbtsn_rlog readlog[SCTP_READ_LOG_SIZE];
429	uint32_t readlog_index;
430#endif
431};
432
433struct sctp_tcb {
434	struct socket *sctp_socket;	/* back pointer to socket */
435	struct sctp_inpcb *sctp_ep;	/* back pointer to ep */
436	           LIST_ENTRY(sctp_tcb) sctp_tcbhash;	/* next link in hash
437							 * table */
438	           LIST_ENTRY(sctp_tcb) sctp_tcblist;	/* list of all of the
439							 * TCB's */
440	           LIST_ENTRY(sctp_tcb) sctp_tcbasocidhash;	/* next link in asocid
441								 * hash table */
442	           LIST_ENTRY(sctp_tcb) sctp_asocs;	/* vtag hash list */
443	struct sctp_block_entry *block_entry;	/* pointer locked by  socket
444						 * send buffer */
445	struct sctp_association asoc;
446	/*-
447	 * freed_by_sorcv_sincelast is protected by the sockbuf_lock NOT the
448	 * tcb_lock. Its special in this way to help avoid extra mutex calls
449	 * in the reading of data.
450	 */
451	uint32_t freed_by_sorcv_sincelast;
452	uint32_t total_sends;
453	uint32_t total_recvs;
454	int freed_from_where;
455	uint16_t rport;		/* remote port in network format */
456	uint16_t resv;
457	struct mtx tcb_mtx;
458	struct mtx tcb_send_mtx;
459};
460
461
462
463#include <netinet/sctp_lock_bsd.h>
464
465
466/* TODO where to put non-_KERNEL things for __Userspace__? */
467#if defined(_KERNEL) || defined(__Userspace__)
468
469/* Attention Julian, this is the extern that
470 * goes with the base info. sctp_pcb.c has
471 * the real definition.
472 */
473VNET_DECLARE(struct sctp_base_info, system_base_info);
474
475#ifdef INET6
476int SCTP6_ARE_ADDR_EQUAL(struct sockaddr_in6 *a, struct sockaddr_in6 *b);
477
478#endif
479
480void sctp_fill_pcbinfo(struct sctp_pcbinfo *);
481
482struct sctp_ifn *
483         sctp_find_ifn(void *ifn, uint32_t ifn_index);
484
485struct sctp_vrf *sctp_allocate_vrf(int vrfid);
486struct sctp_vrf *sctp_find_vrf(uint32_t vrfid);
487void sctp_free_vrf(struct sctp_vrf *vrf);
488
489/*-
490 * Change address state, can be used if
491 * O/S supports telling transports about
492 * changes to IFA/IFN's (link layer triggers).
493 * If a ifn goes down, we will do src-addr-selection
494 * and NOT use that, as a source address. This does
495 * not stop the routing system from routing out
496 * that interface, but we won't put it as a source.
497 */
498void sctp_mark_ifa_addr_down(uint32_t vrf_id, struct sockaddr *addr, const char *if_name, uint32_t ifn_index);
499void sctp_mark_ifa_addr_up(uint32_t vrf_id, struct sockaddr *addr, const char *if_name, uint32_t ifn_index);
500
501struct sctp_ifa *
502sctp_add_addr_to_vrf(uint32_t vrfid,
503    void *ifn, uint32_t ifn_index, uint32_t ifn_type,
504    const char *if_name,
505    void *ifa, struct sockaddr *addr, uint32_t ifa_flags,
506    int dynamic_add);
507
508void sctp_update_ifn_mtu(uint32_t ifn_index, uint32_t mtu);
509
510void sctp_free_ifn(struct sctp_ifn *sctp_ifnp);
511void sctp_free_ifa(struct sctp_ifa *sctp_ifap);
512
513
514void
515sctp_del_addr_from_vrf(uint32_t vrfid, struct sockaddr *addr,
516    uint32_t ifn_index, const char *if_name);
517
518
519
520struct sctp_nets *sctp_findnet(struct sctp_tcb *, struct sockaddr *);
521
522struct sctp_inpcb *sctp_pcb_findep(struct sockaddr *, int, int, uint32_t);
523
524int
525sctp_inpcb_bind(struct socket *, struct sockaddr *,
526    struct sctp_ifa *, struct thread *);
527
528struct sctp_tcb *
529sctp_findassociation_addr(struct mbuf *, int, int,
530    struct sctphdr *, struct sctp_chunkhdr *, struct sctp_inpcb **,
531    struct sctp_nets **, uint32_t vrf_id);
532
533struct sctp_tcb *
534sctp_findassociation_addr_sa(struct sockaddr *,
535    struct sockaddr *, struct sctp_inpcb **, struct sctp_nets **, int, uint32_t);
536
537void
538sctp_move_pcb_and_assoc(struct sctp_inpcb *, struct sctp_inpcb *,
539    struct sctp_tcb *);
540
541/*-
542 * For this call ep_addr, the to is the destination endpoint address of the
543 * peer (relative to outbound). The from field is only used if the TCP model
544 * is enabled and helps distingush amongst the subset bound (non-boundall).
545 * The TCP model MAY change the actual ep field, this is why it is passed.
546 */
547struct sctp_tcb *
548sctp_findassociation_ep_addr(struct sctp_inpcb **,
549    struct sockaddr *, struct sctp_nets **, struct sockaddr *,
550    struct sctp_tcb *);
551
552struct sctp_tcb *
553         sctp_findasoc_ep_asocid_locked(struct sctp_inpcb *inp, sctp_assoc_t asoc_id, int want_lock);
554
555struct sctp_tcb *
556sctp_findassociation_ep_asocid(struct sctp_inpcb *,
557    sctp_assoc_t, int);
558
559struct sctp_tcb *
560sctp_findassociation_ep_asconf(struct mbuf *, int, int,
561    struct sctphdr *, struct sctp_inpcb **, struct sctp_nets **, uint32_t vrf_id);
562
563int sctp_inpcb_alloc(struct socket *so, uint32_t vrf_id);
564
565int sctp_is_address_on_local_host(struct sockaddr *addr, uint32_t vrf_id);
566
567void sctp_inpcb_free(struct sctp_inpcb *, int, int);
568
569struct sctp_tcb *
570sctp_aloc_assoc(struct sctp_inpcb *, struct sockaddr *,
571    int *, uint32_t, uint32_t, struct thread *);
572
573int sctp_free_assoc(struct sctp_inpcb *, struct sctp_tcb *, int, int);
574
575
576void sctp_delete_from_timewait(uint32_t, uint16_t, uint16_t);
577
578int sctp_is_in_timewait(uint32_t tag, uint16_t lport, uint16_t rport);
579
580void
581     sctp_add_vtag_to_timewait(uint32_t tag, uint32_t time, uint16_t lport, uint16_t rport);
582
583void sctp_add_local_addr_ep(struct sctp_inpcb *, struct sctp_ifa *, uint32_t);
584
585int sctp_insert_laddr(struct sctpladdr *, struct sctp_ifa *, uint32_t);
586
587void sctp_remove_laddr(struct sctp_laddr *);
588
589void sctp_del_local_addr_ep(struct sctp_inpcb *, struct sctp_ifa *);
590
591int sctp_add_remote_addr(struct sctp_tcb *, struct sockaddr *, struct sctp_nets **, int, int);
592
593void sctp_remove_net(struct sctp_tcb *, struct sctp_nets *);
594
595int sctp_del_remote_addr(struct sctp_tcb *, struct sockaddr *);
596
597void sctp_pcb_init(void);
598
599void sctp_pcb_finish(void);
600
601void sctp_add_local_addr_restricted(struct sctp_tcb *, struct sctp_ifa *);
602void sctp_del_local_addr_restricted(struct sctp_tcb *, struct sctp_ifa *);
603
604int
605sctp_load_addresses_from_init(struct sctp_tcb *, struct mbuf *, int, int,
606    int, struct sctphdr *, struct sockaddr *);
607
608int
609sctp_set_primary_addr(struct sctp_tcb *, struct sockaddr *,
610    struct sctp_nets *);
611
612int sctp_is_vtag_good(struct sctp_inpcb *, uint32_t, uint16_t lport, uint16_t rport, struct timeval *, int);
613
614/* void sctp_drain(void); */
615
616int sctp_destination_is_reachable(struct sctp_tcb *, struct sockaddr *);
617
618int sctp_swap_inpcb_for_listen(struct sctp_inpcb *inp);
619
620/*-
621 * Null in last arg inpcb indicate run on ALL ep's. Specific inp in last arg
622 * indicates run on ONLY assoc's of the specified endpoint.
623 */
624int
625sctp_initiate_iterator(inp_func inpf,
626    asoc_func af,
627    inp_func inpe,
628    uint32_t, uint32_t,
629    uint32_t, void *,
630    uint32_t,
631    end_func ef,
632    struct sctp_inpcb *,
633    uint8_t co_off);
634
635#if defined(__FreeBSD__) && defined(SCTP_MCORE_INPUT) && defined(SMP)
636void
637     sctp_queue_to_mcore(struct mbuf *m, int off, int cpu_to_use);
638
639#endif
640
641#ifdef INVARIANTS
642void
643     sctp_validate_no_locks(struct sctp_inpcb *inp);
644
645#endif
646
647#endif				/* _KERNEL */
648#endif				/* !__sctp_pcb_h__ */
649