Home | History | Annotate | Line # | Download | only in netinet
sctp_pcb.h revision 1.1.22.1
      1       1.1       rjs /*	$KAME: sctp_pcb.h,v 1.21 2005/07/16 01:18:47 suz Exp $	*/
      2  1.1.22.1  christos /*	$NetBSD: sctp_pcb.h,v 1.1.22.1 2019/06/10 22:09:47 christos Exp $ */
      3       1.1       rjs 
      4       1.1       rjs #ifndef __SCTP_PCB_H__
      5       1.1       rjs #define __SCTP_PCB_H__
      6       1.1       rjs 
      7       1.1       rjs /*
      8       1.1       rjs  * Copyright (c) 2001, 2002, 2003, 2004 Cisco Systems, Inc.
      9       1.1       rjs  * All rights reserved.
     10       1.1       rjs  *
     11       1.1       rjs  * Redistribution and use in source and binary forms, with or without
     12       1.1       rjs  * modification, are permitted provided that the following conditions
     13       1.1       rjs  * are met:
     14       1.1       rjs  * 1. Redistributions of source code must retain the above copyright
     15       1.1       rjs  *    notice, this list of conditions and the following disclaimer.
     16       1.1       rjs  * 2. Redistributions in binary form must reproduce the above copyright
     17       1.1       rjs  *    notice, this list of conditions and the following disclaimer in the
     18       1.1       rjs  *    documentation and/or other materials provided with the distribution.
     19       1.1       rjs  * 3. All advertising materials mentioning features or use of this software
     20       1.1       rjs  *    must display the following acknowledgement:
     21       1.1       rjs  *      This product includes software developed by Cisco Systems, Inc.
     22       1.1       rjs  * 4. Neither the name of the project nor the names of its contributors
     23       1.1       rjs  *    may be used to endorse or promote products derived from this software
     24       1.1       rjs  *    without specific prior written permission.
     25       1.1       rjs  *
     26       1.1       rjs  * THIS SOFTWARE IS PROVIDED BY CISCO SYSTEMS AND CONTRIBUTORS ``AS IS'' AND
     27       1.1       rjs  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     28       1.1       rjs  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     29       1.1       rjs  * ARE DISCLAIMED.  IN NO EVENT SHALL CISCO SYSTEMS OR CONTRIBUTORS BE LIABLE
     30       1.1       rjs  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     31       1.1       rjs  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     32       1.1       rjs  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     33       1.1       rjs  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     34       1.1       rjs  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     35       1.1       rjs  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     36       1.1       rjs  * SUCH DAMAGE.
     37       1.1       rjs  */
     38       1.1       rjs 
     39       1.1       rjs /*
     40       1.1       rjs  * We must have V6 so the size of the proto can be calculated. Otherwise
     41       1.1       rjs  * we would not allocate enough for Net/Open BSD :-<
     42       1.1       rjs  */
     43       1.1       rjs #include <net/if.h>
     44       1.1       rjs #include <netinet/ip6.h>
     45       1.1       rjs #include <netinet6/ip6_var.h>
     46       1.1       rjs #include <netinet6/ip6protosw.h>
     47       1.1       rjs #include <netinet6/in6_var.h>
     48       1.1       rjs #include <netinet6/in6_pcb.h>
     49       1.1       rjs 
     50       1.1       rjs #include <netinet/sctp.h>
     51       1.1       rjs #include <netinet/sctp_constants.h>
     52       1.1       rjs 
     53       1.1       rjs LIST_HEAD(sctppcbhead, sctp_inpcb);
     54       1.1       rjs LIST_HEAD(sctpasochead, sctp_tcb);
     55       1.1       rjs TAILQ_HEAD(sctpsocketq, sctp_socket_q_list);
     56       1.1       rjs LIST_HEAD(sctpladdr, sctp_laddr);
     57       1.1       rjs LIST_HEAD(sctpvtaghead, sctp_tagblock);
     58       1.1       rjs 
     59       1.1       rjs #include <netinet/sctp_structs.h>
     60       1.1       rjs #include <netinet/sctp_uio.h>
     61       1.1       rjs 
     62       1.1       rjs /*
     63       1.1       rjs  * PCB flags
     64       1.1       rjs  */
     65       1.1       rjs #define SCTP_PCB_FLAGS_UDPTYPE		0x00000001
     66       1.1       rjs #define SCTP_PCB_FLAGS_TCPTYPE		0x00000002
     67       1.1       rjs #define SCTP_PCB_FLAGS_BOUNDALL		0x00000004
     68       1.1       rjs #define SCTP_PCB_FLAGS_ACCEPTING	0x00000008
     69       1.1       rjs #define SCTP_PCB_FLAGS_UNBOUND		0x00000010
     70       1.1       rjs #define SCTP_PCB_FLAGS_DO_ASCONF	0x00000020
     71       1.1       rjs #define SCTP_PCB_FLAGS_AUTO_ASCONF	0x00000040
     72       1.1       rjs /* socket options */
     73       1.1       rjs #define SCTP_PCB_FLAGS_NODELAY		0x00000100
     74       1.1       rjs #define SCTP_PCB_FLAGS_AUTOCLOSE	0x00000200
     75       1.1       rjs #define SCTP_PCB_FLAGS_RECVDATAIOEVNT	0x00000400
     76       1.1       rjs #define SCTP_PCB_FLAGS_RECVASSOCEVNT	0x00000800
     77       1.1       rjs #define SCTP_PCB_FLAGS_RECVPADDREVNT	0x00001000
     78       1.1       rjs #define SCTP_PCB_FLAGS_RECVPEERERR	0x00002000
     79       1.1       rjs #define SCTP_PCB_FLAGS_RECVSENDFAILEVNT	0x00004000
     80       1.1       rjs #define SCTP_PCB_FLAGS_RECVSHUTDOWNEVNT	0x00008000
     81       1.1       rjs #define SCTP_PCB_FLAGS_ADAPTIONEVNT	0x00010000
     82       1.1       rjs #define SCTP_PCB_FLAGS_PDAPIEVNT	0x00020000
     83       1.1       rjs #define SCTP_PCB_FLAGS_STREAM_RESETEVNT 0x00040000
     84       1.1       rjs #define SCTP_PCB_FLAGS_NO_FRAGMENT	0x00080000
     85       1.1       rjs /* TCP model support */
     86       1.1       rjs #define SCTP_PCB_FLAGS_CONNECTED	0x00100000
     87       1.1       rjs #define SCTP_PCB_FLAGS_IN_TCPPOOL	0x00200000
     88       1.1       rjs #define SCTP_PCB_FLAGS_DONT_WAKE	0x00400000
     89       1.1       rjs #define SCTP_PCB_FLAGS_WAKEOUTPUT	0x00800000
     90       1.1       rjs #define SCTP_PCB_FLAGS_WAKEINPUT	0x01000000
     91       1.1       rjs #define SCTP_PCB_FLAGS_BOUND_V6		0x02000000
     92       1.1       rjs #define SCTP_PCB_FLAGS_NEEDS_MAPPED_V4	0x04000000
     93       1.1       rjs #define SCTP_PCB_FLAGS_BLOCKING_IO	0x08000000
     94       1.1       rjs #define SCTP_PCB_FLAGS_SOCKET_GONE	0x10000000
     95       1.1       rjs #define SCTP_PCB_FLAGS_SOCKET_ALLGONE	0x20000000
     96       1.1       rjs 
     97       1.1       rjs /* flags to copy to new PCB */
     98       1.1       rjs #define SCTP_PCB_COPY_FLAGS		0x0707ff64
     99       1.1       rjs 
    100       1.1       rjs #define SCTP_PCBHASH_ALLADDR(port, mask) (port & mask)
    101       1.1       rjs #define SCTP_PCBHASH_ASOC(tag, mask) (tag & mask)
    102       1.1       rjs 
    103       1.1       rjs struct sctp_laddr {
    104       1.1       rjs 	LIST_ENTRY(sctp_laddr) sctp_nxt_addr;	/* next in list */
    105       1.1       rjs 	struct ifaddr *ifa;
    106       1.1       rjs };
    107       1.1       rjs 
    108       1.1       rjs struct sctp_timewait {
    109       1.1       rjs 	uint32_t tv_sec_at_expire;	/* the seconds from boot to expire */
    110       1.1       rjs 	uint32_t v_tag;		/* the vtag that can not be reused */
    111       1.1       rjs };
    112       1.1       rjs 
    113       1.1       rjs struct sctp_tagblock {
    114       1.1       rjs         LIST_ENTRY(sctp_tagblock) sctp_nxt_tagblock;
    115       1.1       rjs 	struct sctp_timewait vtag_block[SCTP_NUMBER_IN_VTAG_BLOCK];
    116       1.1       rjs };
    117       1.1       rjs 
    118       1.1       rjs struct sctp_epinfo {
    119       1.1       rjs 	struct sctpasochead *sctp_asochash;
    120       1.1       rjs 	u_long hashasocmark;
    121       1.1       rjs 
    122       1.1       rjs 	struct sctppcbhead *sctp_ephash;
    123       1.1       rjs 	u_long hashmark;
    124       1.1       rjs 
    125       1.1       rjs 	/*
    126       1.1       rjs 	 * The TCP model represents a substantial overhead in that we get
    127       1.1       rjs 	 * an additional hash table to keep explicit connections in. The
    128       1.1       rjs 	 * listening TCP endpoint will exist in the usual ephash above and
    129       1.1       rjs 	 * accept only INIT's. It will be incapable of sending off an INIT.
    130       1.1       rjs 	 * When a dg arrives we must look in the normal ephash. If we find
    131       1.1       rjs 	 * a TCP endpoint that will tell us to go to the specific endpoint
    132       1.1       rjs 	 * hash and re-hash to find the right assoc/socket. If we find a
    133       1.1       rjs 	 * UDP model socket we then must complete the lookup. If this fails,
    134       1.1       rjs 	 * i.e. no association can be found then we must continue to see if
    135       1.1       rjs 	 * a sctp_peeloff()'d socket is in the tcpephash (a spun off socket
    136       1.1       rjs 	 * acts like a TCP model connected socket).
    137       1.1       rjs 	 */
    138       1.1       rjs 	struct sctppcbhead *sctp_tcpephash;
    139       1.1       rjs 	u_long hashtcpmark;
    140       1.1       rjs 	uint32_t hashtblsize;
    141       1.1       rjs 
    142       1.1       rjs 	struct sctppcbhead listhead;
    143       1.1       rjs 
    144       1.1       rjs 	struct sctpiterators iteratorhead;
    145       1.1       rjs 
    146       1.1       rjs 	/* ep zone info */
    147       1.1       rjs #if defined(__FreeBSD__) || defined(__APPLE__)
    148       1.1       rjs #if __FreeBSD_version >= 500000
    149       1.1       rjs 	struct uma_zone *ipi_zone_ep;
    150       1.1       rjs 	struct uma_zone *ipi_zone_asoc;
    151       1.1       rjs 	struct uma_zone *ipi_zone_laddr;
    152       1.1       rjs 	struct uma_zone *ipi_zone_net;
    153       1.1       rjs 	struct uma_zone *ipi_zone_chunk;
    154       1.1       rjs 	struct uma_zone *ipi_zone_sockq;
    155       1.1       rjs #else
    156       1.1       rjs 	struct vm_zone *ipi_zone_ep;
    157       1.1       rjs 	struct vm_zone *ipi_zone_asoc;
    158       1.1       rjs 	struct vm_zone *ipi_zone_laddr;
    159       1.1       rjs 	struct vm_zone *ipi_zone_net;
    160       1.1       rjs 	struct vm_zone *ipi_zone_chunk;
    161       1.1       rjs 	struct vm_zone *ipi_zone_sockq;
    162       1.1       rjs #endif
    163       1.1       rjs #endif
    164       1.1       rjs #if defined(__NetBSD__) || defined(__OpenBSD__)
    165       1.1       rjs 	struct pool ipi_zone_ep;
    166       1.1       rjs 	struct pool ipi_zone_asoc;
    167       1.1       rjs 	struct pool ipi_zone_laddr;
    168       1.1       rjs 	struct pool ipi_zone_net;
    169       1.1       rjs 	struct pool ipi_zone_chunk;
    170       1.1       rjs 	struct pool ipi_zone_sockq;
    171       1.1       rjs 	struct pool ipi_zone_hash;
    172       1.1       rjs #endif
    173       1.1       rjs 
    174       1.1       rjs #if defined(__FreeBSD__) && __FreeBSD_version >= 503000
    175       1.1       rjs 	struct mtx ipi_ep_mtx;
    176       1.1       rjs 	struct mtx it_mtx;
    177       1.1       rjs #elif 0 /* defined(__NetBSD__) */
    178       1.1       rjs 	krwlock_t ipi_ep_mtx;
    179       1.1       rjs 	kmutex_t it_mtx;
    180       1.1       rjs #endif
    181       1.1       rjs 	u_int ipi_count_ep;
    182       1.1       rjs 	u_quad_t ipi_gencnt_ep;
    183       1.1       rjs 
    184       1.1       rjs 	/* assoc/tcb zone info */
    185       1.1       rjs 	u_int ipi_count_asoc;
    186       1.1       rjs 	u_quad_t ipi_gencnt_asoc;
    187       1.1       rjs 
    188       1.1       rjs 	/* local addrlist zone info */
    189       1.1       rjs 	u_int ipi_count_laddr;
    190       1.1       rjs 	u_quad_t ipi_gencnt_laddr;
    191       1.1       rjs 
    192       1.1       rjs 	/* remote addrlist zone info */
    193       1.1       rjs 	u_int ipi_count_raddr;
    194       1.1       rjs 	u_quad_t ipi_gencnt_raddr;
    195       1.1       rjs 
    196       1.1       rjs 	/* chunk structure list for output */
    197       1.1       rjs 	u_int ipi_count_chunk;
    198       1.1       rjs 	u_quad_t ipi_gencnt_chunk;
    199       1.1       rjs 
    200       1.1       rjs 	/* socket queue zone info */
    201       1.1       rjs 	u_int ipi_count_sockq;
    202       1.1       rjs 	u_quad_t ipi_gencnt_sockq;
    203       1.1       rjs 
    204       1.1       rjs 	struct sctpvtaghead vtag_timewait[SCTP_STACK_VTAG_HASH_SIZE];
    205       1.1       rjs 
    206       1.1       rjs #ifdef _SCTP_NEEDS_CALLOUT_
    207       1.1       rjs 	struct calloutlist callqueue;
    208       1.1       rjs #endif /* _SCTP_NEEDS_CALLOUT_ */
    209       1.1       rjs 
    210       1.1       rjs 	uint32_t mbuf_track;
    211       1.1       rjs 
    212       1.1       rjs 	/* for port allocations */
    213       1.1       rjs 	uint16_t lastport;
    214       1.1       rjs 	uint16_t lastlow;
    215       1.1       rjs 	uint16_t lasthi;
    216       1.1       rjs 
    217       1.1       rjs };
    218       1.1       rjs 
    219       1.1       rjs extern uint32_t sctp_pegs[SCTP_NUMBER_OF_PEGS];
    220       1.1       rjs /*
    221       1.1       rjs  * Here we have all the relevant information for each SCTP entity created.
    222       1.1       rjs  * We will need to modify this as approprate. We also need to figure out
    223       1.1       rjs  * how to access /dev/random.
    224       1.1       rjs  */
    225       1.1       rjs struct sctp_pcb {
    226       1.1       rjs 	unsigned int time_of_secret_change; /* number of seconds from timeval.tv_sec */
    227       1.1       rjs 	uint32_t secret_key[SCTP_HOW_MANY_SECRETS][SCTP_NUMBER_OF_SECRETS];
    228       1.1       rjs 	unsigned int size_of_a_cookie;
    229       1.1       rjs 
    230       1.1       rjs 	unsigned int sctp_timeoutticks[SCTP_NUM_TMRS];
    231       1.1       rjs 	unsigned int sctp_minrto;
    232       1.1       rjs 	unsigned int sctp_maxrto;
    233       1.1       rjs 	unsigned int initial_rto;
    234       1.1       rjs 
    235       1.1       rjs 	int initial_init_rto_max;
    236       1.1       rjs 
    237       1.1       rjs 	uint32_t sctp_sws_sender;
    238       1.1       rjs 	uint32_t sctp_sws_receiver;
    239       1.1       rjs 
    240       1.1       rjs 	/* various thresholds */
    241       1.1       rjs 	/* Max times I will init at a guy */
    242       1.1       rjs 	uint16_t max_init_times;
    243       1.1       rjs 
    244       1.1       rjs 	/* Max times I will send before we consider someone dead */
    245       1.1       rjs 	uint16_t max_send_times;
    246       1.1       rjs 
    247       1.1       rjs 	uint16_t def_net_failure;
    248       1.1       rjs 
    249       1.1       rjs 	/* number of streams to pre-open on a association */
    250       1.1       rjs 	uint16_t pre_open_stream_count;
    251       1.1       rjs 	uint16_t max_open_streams_intome;
    252       1.1       rjs 
    253       1.1       rjs 	/* random number generator */
    254       1.1       rjs 	uint32_t random_counter;
    255       1.1       rjs 	uint8_t random_numbers[SCTP_SIGNATURE_ALOC_SIZE];
    256       1.1       rjs 	uint8_t random_store[SCTP_SIGNATURE_ALOC_SIZE];
    257       1.1       rjs 
    258       1.1       rjs 	/*
    259       1.1       rjs 	 * This timer is kept running per endpoint.  When it fires it
    260       1.1       rjs 	 * will change the secret key.  The default is once a hour
    261       1.1       rjs 	 */
    262       1.1       rjs 	struct sctp_timer signature_change;
    263       1.1       rjs 	int def_cookie_life;
    264       1.1       rjs 	/* defaults to 0 */
    265       1.1       rjs 	int auto_close_time;
    266       1.1       rjs 	uint32_t initial_sequence_debug;
    267       1.1       rjs 	uint32_t adaption_layer_indicator;
    268       1.1       rjs 	char store_at;
    269       1.1       rjs 	uint8_t max_burst;
    270       1.1       rjs 	char current_secret_number;
    271       1.1       rjs 	char last_secret_number;
    272       1.1       rjs };
    273       1.1       rjs 
    274       1.1       rjs #ifndef SCTP_ALIGNMENT
    275       1.1       rjs #define SCTP_ALIGNMENT 32
    276       1.1       rjs #endif
    277       1.1       rjs 
    278       1.1       rjs #ifndef SCTP_ALIGNM1
    279       1.1       rjs #define SCTP_ALIGNM1 (SCTP_ALIGNMENT-1)
    280       1.1       rjs #endif
    281       1.1       rjs 
    282       1.1       rjs #define sctp_lport ip_inp.inp.inp_lport
    283       1.1       rjs 
    284       1.1       rjs struct sctp_socket_q_list {
    285       1.1       rjs 	struct sctp_tcb *tcb;
    286       1.1       rjs 	TAILQ_ENTRY(sctp_socket_q_list) next_sq;
    287       1.1       rjs };
    288       1.1       rjs 
    289       1.1       rjs struct sctp_inpcb {
    290       1.1       rjs 	/*
    291       1.1       rjs 	 * put an inpcb in front of it all, kind of a waste but we need
    292       1.1       rjs 	 * to for compatability with all the other stuff.
    293       1.1       rjs 	 */
    294       1.1       rjs 	union {
    295       1.1       rjs 		struct inpcb inp;
    296       1.1       rjs 		char align[(sizeof(struct in6pcb) + SCTP_ALIGNM1) &
    297       1.1       rjs 			  ~SCTP_ALIGNM1];
    298       1.1       rjs 	} ip_inp;
    299       1.1       rjs 	LIST_ENTRY(sctp_inpcb) sctp_list;	/* lists all endpoints */
    300       1.1       rjs 	/* hash of all endpoints for model */
    301       1.1       rjs 	LIST_ENTRY(sctp_inpcb) sctp_hash;
    302       1.1       rjs 
    303       1.1       rjs 	/* count of local addresses bound, 0 if bound all */
    304       1.1       rjs 	int laddr_count;
    305       1.1       rjs 	/* list of addrs in use by the EP */
    306       1.1       rjs 	struct sctpladdr sctp_addr_list;
    307       1.1       rjs 	/* used for source address selection rotation */
    308       1.1       rjs 	struct sctp_laddr *next_addr_touse;
    309       1.1       rjs 	struct ifnet *next_ifn_touse;
    310       1.1       rjs 	/* back pointer to our socket */
    311       1.1       rjs 	struct socket *sctp_socket;
    312       1.1       rjs 	uint32_t sctp_flags;			/* flag set */
    313       1.1       rjs 	struct sctp_pcb sctp_ep;		/* SCTP ep data */
    314       1.1       rjs 	/* head of the hash of all associations */
    315       1.1       rjs 	struct sctpasochead *sctp_tcbhash;
    316       1.1       rjs 	u_long sctp_hashmark;
    317       1.1       rjs 	/* head of the list of all associations */
    318       1.1       rjs 	struct sctpasochead sctp_asoc_list;
    319       1.1       rjs 	/* queue of TCB's waiting to stuff data up the socket */
    320       1.1       rjs 	struct sctpsocketq sctp_queue_list;
    321       1.1       rjs 	void *sctp_tcb_at_block;
    322       1.1       rjs 	struct sctp_iterator *inp_starting_point_for_iterator;
    323       1.1       rjs 	int  error_on_block;
    324       1.1       rjs 	uint32_t sctp_frag_point;
    325       1.1       rjs 	uint32_t sctp_vtag_first;
    326       1.1       rjs 	struct mbuf *pkt, *pkt_last, *sb_last_mpkt;
    327       1.1       rjs 	struct mbuf *control;
    328       1.1       rjs #if !(defined(__FreeBSD__) || defined(__APPLE__))
    329       1.1       rjs #ifndef INP_IPV6
    330       1.1       rjs #define INP_IPV6	0x1
    331       1.1       rjs #endif
    332       1.1       rjs #ifndef INP_IPV4
    333       1.1       rjs #define INP_IPV4	0x2
    334       1.1       rjs #endif
    335       1.1       rjs 	u_char inp_vflag;
    336       1.1       rjs 	u_char inp_ip_ttl;
    337       1.1       rjs 	u_char inp_ip_tos;
    338       1.1       rjs 	u_char inp_ip_resv;
    339       1.1       rjs #endif
    340       1.1       rjs #if defined(__FreeBSD__) && __FreeBSD_version >= 503000
    341       1.1       rjs 	struct mtx inp_mtx;
    342       1.1       rjs 	struct mtx inp_create_mtx;
    343       1.1       rjs 	u_int32_t refcount;
    344       1.1       rjs #elif defined(__NetBSD__)
    345       1.1       rjs 	kmutex_t inp_mtx;
    346       1.1       rjs 	kmutex_t inp_create_mtx;
    347       1.1       rjs 	u_int32_t refcount;
    348       1.1       rjs #endif
    349       1.1       rjs };
    350       1.1       rjs 
    351       1.1       rjs struct sctp_tcb {
    352       1.1       rjs 	struct socket *sctp_socket;		/* back pointer to socket */
    353       1.1       rjs 	struct sctp_inpcb *sctp_ep;		/* back pointer to ep */
    354       1.1       rjs 	LIST_ENTRY(sctp_tcb) sctp_tcbhash;	/* next link in hash table */
    355       1.1       rjs 	LIST_ENTRY(sctp_tcb) sctp_tcblist;	/* list of all of the TCB's */
    356       1.1       rjs 	LIST_ENTRY(sctp_tcb) sctp_asocs;
    357       1.1       rjs 	struct sctp_association asoc;
    358       1.1       rjs 	uint16_t rport;			/* remote port in network format */
    359       1.1       rjs 	uint16_t resv;
    360       1.1       rjs #if defined(__FreeBSD__) && __FreeBSD_version >= 503000
    361       1.1       rjs 	struct mtx tcb_mtx;
    362       1.1       rjs #elif defined(__NetBSD__)
    363       1.1       rjs 	kmutex_t tcb_mtx;
    364       1.1       rjs #endif
    365       1.1       rjs };
    366       1.1       rjs 
    367       1.1       rjs #if defined(__FreeBSD__) && __FreeBSD_version >= 503000
    368       1.1       rjs 
    369       1.1       rjs /* General locking concepts:
    370       1.1       rjs  * The goal of our locking is to of course provide
    371       1.1       rjs  * consistency and yet minimize overhead. We will
    372       1.1       rjs  * attempt to use non-recursive locks which are supposed
    373       1.1       rjs  * to be quite inexpensive. Now in order to do this the goal
    374       1.1       rjs  * is that most functions are not aware of locking. Once we
    375       1.1       rjs  * have a TCB we lock it and unlock when we are through. This
    376       1.1       rjs  * means that the TCB lock is kind-of a "global" lock when
    377       1.1       rjs  * working on an association. Caution must be used when
    378       1.1       rjs  * asserting a TCB_LOCK since if we recurse we deadlock.
    379       1.1       rjs  *
    380       1.1       rjs  * Most other locks (INP and INFO) attempt to localize
    381       1.1       rjs  * the locking i.e. we try to contain the lock and
    382       1.1       rjs  * unlock within the function that needs to lock it. This
    383       1.1       rjs  * sometimes mean we do extra locks and unlocks and loose
    384       1.1       rjs  * a bit of efficency, but if the performance statements about
    385       1.1       rjs  * non-recursive locks are true this should not be a problem.
    386       1.1       rjs  * One issue that arises with this only lock when needed
    387       1.1       rjs  * is that if an implicit association setup is done we
    388       1.1       rjs  * have a problem. If at the time I lookup an association
    389       1.1       rjs  * I have NULL in the tcb return, by the time I call to
    390       1.1       rjs  * create the association some other processor could
    391       1.1       rjs  * have created it. This is what the CREATE lock on
    392       1.1       rjs  * the endpoint. Places where we will be implicitly
    393       1.1       rjs  * creating the association OR just creating an association
    394       1.1       rjs  * (the connect call) will assert the CREATE_INP lock. This
    395       1.1       rjs  * will assure us that during all the lookup of INP and INFO
    396       1.1       rjs  * if another creator is also locking/looking up we can
    397       1.1       rjs  * gate the two to synchronize. So the CREATE_INP lock is
    398       1.1       rjs  * also another one we must use extreme caution in locking
    399       1.1       rjs  * to make sure we don't hit a re-entrancy issue.
    400       1.1       rjs  *
    401       1.1       rjs  * For non FreeBSD 5.x and above we provide a bunch
    402       1.1       rjs  * of EMPTY lock macro's so we can blatantly put locks
    403       1.1       rjs  * everywhere and they reduce to nothing on NetBSD/OpenBSD
    404       1.1       rjs  * and FreeBSD 4.x
    405       1.1       rjs  *
    406       1.1       rjs  */
    407       1.1       rjs 
    408       1.1       rjs 
    409       1.1       rjs /* When working with the global SCTP lists we lock and unlock
    410       1.1       rjs  * the INP_INFO lock. So when we go to lookup an association
    411       1.1       rjs  * we will want to do a SCTP_INP_INFO_RLOCK() and then when
    412       1.1       rjs  * we want to add a new association to the sctppcbinfo list's
    413       1.1       rjs  * we will do a SCTP_INP_INFO_WLOCK().
    414       1.1       rjs  */
    415       1.1       rjs 
    416       1.1       rjs /*
    417       1.1       rjs  * FIX ME, all locks right now have a
    418       1.1       rjs  * recursive check/panic to validate that I
    419       1.1       rjs  * don't have any lock recursion going on.
    420       1.1       rjs  */
    421       1.1       rjs 
    422       1.1       rjs #define SCTP_INP_INFO_LOCK_INIT() \
    423       1.1       rjs         mtx_init(&sctppcbinfo.ipi_ep_mtx, "sctp", "inp_info", MTX_DEF)
    424       1.1       rjs 
    425       1.1       rjs #ifdef xyzzy
    426       1.1       rjs #define SCTP_INP_INFO_RLOCK()	do { 					\
    427       1.1       rjs              if (mtx_owned(&sctppcbinfo.ipi_ep_mtx))                     \
    428       1.1       rjs 		panic("INP INFO Recursive Lock-R");                     \
    429       1.1       rjs              mtx_lock(&sctppcbinfo.ipi_ep_mtx);                         \
    430       1.1       rjs } while (0)
    431       1.1       rjs 
    432       1.1       rjs #define SCTP_INP_INFO_WLOCK()	do { 					\
    433       1.1       rjs              if (mtx_owned(&sctppcbinfo.ipi_ep_mtx))                     \
    434       1.1       rjs 		panic("INP INFO Recursive Lock-W");                     \
    435       1.1       rjs              mtx_lock(&sctppcbinfo.ipi_ep_mtx);                         \
    436       1.1       rjs } while (0)
    437       1.1       rjs 
    438       1.1       rjs #else
    439       1.1       rjs 
    440       1.1       rjs void SCTP_INP_INFO_RLOCK(void);
    441       1.1       rjs void SCTP_INP_INFO_WLOCK(void);
    442       1.1       rjs 
    443       1.1       rjs #endif
    444       1.1       rjs 
    445       1.1       rjs #define SCTP_INP_INFO_RUNLOCK()		mtx_unlock(&sctppcbinfo.ipi_ep_mtx)
    446       1.1       rjs #define SCTP_INP_INFO_WUNLOCK()		mtx_unlock(&sctppcbinfo.ipi_ep_mtx)
    447       1.1       rjs 
    448       1.1       rjs /* The INP locks we will use for locking an SCTP endpoint, so for
    449       1.1       rjs  * example if we want to change something at the endpoint level for
    450       1.1       rjs  * example random_store or cookie secrets we lock the INP level.
    451       1.1       rjs  */
    452       1.1       rjs #define SCTP_INP_LOCK_INIT(_inp) \
    453       1.1       rjs 	mtx_init(&(_inp)->inp_mtx, "sctp", "inp", MTX_DEF | MTX_DUPOK)
    454       1.1       rjs 
    455       1.1       rjs #define SCTP_ASOC_CREATE_LOCK_INIT(_inp) \
    456       1.1       rjs 	mtx_init(&(_inp)->inp_create_mtx, "sctp", "inp_create", \
    457       1.1       rjs 		 MTX_DEF | MTX_DUPOK)
    458       1.1       rjs 
    459       1.1       rjs #define SCTP_INP_LOCK_DESTROY(_inp)	mtx_destroy(&(_inp)->inp_mtx)
    460       1.1       rjs #define SCTP_ASOC_CREATE_LOCK_DESTROY(_inp)	mtx_destroy(&(_inp)->inp_create_mtx)
    461       1.1       rjs 
    462       1.1       rjs #ifdef xyzzy
    463       1.1       rjs #define SCTP_INP_RLOCK(_inp)	do { 					\
    464       1.1       rjs         struct sctp_tcb *xx_stcb;					\
    465       1.1       rjs         xx_stcb = LIST_FIRST(&_inp->sctp_asoc_list);                    \
    466       1.1       rjs         if (xx_stcb)                                                     \
    467       1.1       rjs               if (mtx_owned(&(xx_stcb)->tcb_mtx))                        \
    468       1.1       rjs                      panic("I own TCB lock?");                          \
    469       1.1       rjs         if (mtx_owned(&(_inp)->inp_mtx))                                 \
    470       1.1       rjs 		panic("INP Recursive Lock-R");                          \
    471       1.1       rjs         mtx_lock(&(_inp)->inp_mtx);                                     \
    472       1.1       rjs } while (0)
    473       1.1       rjs 
    474       1.1       rjs #define SCTP_INP_WLOCK(_inp)	do { 					\
    475       1.1       rjs         struct sctp_tcb *xx_stcb;					\
    476       1.1       rjs         xx_stcb = LIST_FIRST(&_inp->sctp_asoc_list);                    \
    477       1.1       rjs         if (xx_stcb)                                                     \
    478       1.1       rjs               if (mtx_owned(&(xx_stcb)->tcb_mtx))                        \
    479       1.1       rjs                      panic("I own TCB lock?");                          \
    480       1.1       rjs         if (mtx_owned(&(_inp)->inp_mtx))                                 \
    481       1.1       rjs 		panic("INP Recursive Lock-W");                          \
    482       1.1       rjs         mtx_lock(&(_inp)->inp_mtx);                                     \
    483       1.1       rjs } while (0)
    484       1.1       rjs 
    485       1.1       rjs #else
    486       1.1       rjs void SCTP_INP_RLOCK(struct sctp_inpcb *);
    487       1.1       rjs void SCTP_INP_WLOCK(struct sctp_inpcb *);
    488       1.1       rjs 
    489       1.1       rjs #endif
    490       1.1       rjs 
    491       1.1       rjs 
    492       1.1       rjs #define SCTP_INP_INCR_REF(_inp)        _inp->refcount++
    493       1.1       rjs 
    494       1.1       rjs #define SCTP_INP_DECR_REF(_inp)         do {                                 \
    495       1.1       rjs                                              if (_inp->refcount > 0)          \
    496       1.1       rjs                                                   _inp->refcount--;          \
    497       1.1       rjs                                              else                            \
    498       1.1       rjs                                                   panic("bad inp refcount"); \
    499       1.1       rjs }while (0)
    500       1.1       rjs 
    501       1.1       rjs #define SCTP_ASOC_CREATE_LOCK(_inp)  do {				\
    502       1.1       rjs         if (mtx_owned(&(_inp)->inp_create_mtx))                          \
    503       1.1       rjs 		panic("INP Recursive CREATE");                          \
    504       1.1       rjs         mtx_lock(&(_inp)->inp_create_mtx);                              \
    505       1.1       rjs } while (0)
    506       1.1       rjs 
    507       1.1       rjs #define SCTP_INP_RUNLOCK(_inp)		mtx_unlock(&(_inp)->inp_mtx)
    508       1.1       rjs #define SCTP_INP_WUNLOCK(_inp)		mtx_unlock(&(_inp)->inp_mtx)
    509       1.1       rjs #define SCTP_ASOC_CREATE_UNLOCK(_inp)	mtx_unlock(&(_inp)->inp_create_mtx)
    510       1.1       rjs 
    511       1.1       rjs /* For the majority of things (once we have found the association) we
    512       1.1       rjs  * will lock the actual association mutex. This will protect all
    513       1.1       rjs  * the assoiciation level queues and streams and such. We will
    514       1.1       rjs  * need to lock the socket layer when we stuff data up into
    515       1.1       rjs  * the receiving sb_mb. I.e. we will need to do an extra
    516       1.1       rjs  * SOCKBUF_LOCK(&so->so_rcv) even though the association is
    517       1.1       rjs  * locked.
    518       1.1       rjs  */
    519       1.1       rjs 
    520       1.1       rjs #define SCTP_TCB_LOCK_INIT(_tcb) \
    521       1.1       rjs 	mutex_init(&(_tcb)->tcb_mtx, MUTEX_DEFAULT, IPL_NET)
    522       1.1       rjs #define SCTP_TCB_LOCK_DESTROY(_tcb)	mtx_destroy(&(_tcb)->tcb_mtx)
    523       1.1       rjs #define SCTP_TCB_LOCK(_tcb)  do {					\
    524       1.1       rjs         if (!mtx_owned(&(_tcb->sctp_ep->inp_mtx)))                       \
    525       1.1       rjs 		panic("TCB locking and no INP lock");                   \
    526       1.1       rjs         if (mtx_owned(&(_tcb)->tcb_mtx))                                 \
    527       1.1       rjs 		panic("TCB Lock-recursive");                            \
    528       1.1       rjs 	mtx_lock(&(_tcb)->tcb_mtx);                                     \
    529       1.1       rjs } while (0)
    530       1.1       rjs #define SCTP_TCB_UNLOCK(_tcb)		mtx_unlock(&(_tcb)->tcb_mtx)
    531       1.1       rjs 
    532       1.1       rjs #define SCTP_ITERATOR_LOCK_INIT() \
    533       1.1       rjs         mtx_init(&sctppcbinfo.it_mtx, "sctp", "iterator", MTX_DEF)
    534       1.1       rjs #define SCTP_ITERATOR_LOCK()  do {					\
    535       1.1       rjs         if (mtx_owned(&sctppcbinfo.it_mtx))                              \
    536       1.1       rjs 		panic("Iterator Lock");                                 \
    537       1.1       rjs 	mtx_lock(&sctppcbinfo.it_mtx);                                  \
    538       1.1       rjs } while (0)
    539       1.1       rjs 
    540       1.1       rjs #define SCTP_ITERATOR_UNLOCK()	        mtx_unlock(&sctppcbinfo.it_mtx)
    541       1.1       rjs #define SCTP_ITERATOR_LOCK_DESTROY()	mtx_destroy(&sctppcbinfo.it_mtx)
    542       1.1       rjs #elif 0 /* defined(__NetBSD__) */
    543       1.1       rjs #define SCTP_INP_INFO_LOCK_INIT() \
    544       1.1       rjs 	rw_init(&sctppcbinfo.ipi_ep_mtx)
    545       1.1       rjs 
    546       1.1       rjs #define SCTP_INP_INFO_RLOCK()	do { 					\
    547       1.1       rjs 		rw_enter(&sctppcbinfo.ipi_ep_mtx, RW_READER);           \
    548       1.1       rjs } while (0)
    549       1.1       rjs 
    550       1.1       rjs #define SCTP_INP_INFO_WLOCK()	do { 					\
    551       1.1       rjs              rw_enter(&sctppcbinfo.ipi_ep_mtx, RW_WRITER);              \
    552       1.1       rjs } while (0)
    553       1.1       rjs 
    554       1.1       rjs #define SCTP_INP_INFO_RUNLOCK()		rw_exit(&sctppcbinfo.ipi_ep_mtx)
    555       1.1       rjs #define SCTP_INP_INFO_WUNLOCK()		rw_exit(&sctppcbinfo.ipi_ep_mtx)
    556       1.1       rjs 
    557       1.1       rjs /* The INP locks we will use for locking an SCTP endpoint, so for
    558       1.1       rjs  * example if we want to change something at the endpoint level for
    559       1.1       rjs  * example random_store or cookie secrets we lock the INP level.
    560       1.1       rjs  */
    561       1.1       rjs #define SCTP_INP_LOCK_INIT(_inp) \
    562       1.1       rjs 	mutex_init(&(_inp)->inp_mtx, MUTEX_DEFAULT, IPL_NET)
    563       1.1       rjs 
    564       1.1       rjs #define SCTP_ASOC_CREATE_LOCK_INIT(_inp) \
    565       1.1       rjs 	mutex_init(&(_inp)->inp_create_mtx, MUTEX_DEFAULT, IPL_NET)
    566       1.1       rjs 
    567       1.1       rjs #define SCTP_INP_LOCK_DESTROY(_inp)	mutex_destroy(&(_inp)->inp_mtx)
    568       1.1       rjs #define SCTP_ASOC_CREATE_LOCK_DESTROY(_inp)	mutex_destroy(&(_inp)->inp_create_mtx)
    569       1.1       rjs 
    570       1.1       rjs #define SCTP_INP_RLOCK(_inp)	do { 					\
    571       1.1       rjs 	mutex_enter(&(_inp)->inp_mtx);                                  \
    572       1.1       rjs } while (0)
    573       1.1       rjs 
    574       1.1       rjs #define SCTP_INP_WLOCK(_inp)	do { 					\
    575       1.1       rjs 	mutex_enter(&(_inp)->inp_mtx);                                  \
    576       1.1       rjs } while (0)
    577       1.1       rjs 
    578       1.1       rjs 
    579       1.1       rjs #define SCTP_INP_INCR_REF(_inp) atomic_add_int(&((_inp)->refcount), 1)
    580       1.1       rjs 
    581       1.1       rjs #define SCTP_INP_DECR_REF(_inp) atomic_add_int(&((_inp)->refcount), -1)
    582       1.1       rjs 
    583       1.1       rjs #define SCTP_ASOC_CREATE_LOCK(_inp)  do {				\
    584       1.1       rjs         mutex_enter(&(_inp)->inp_create_mtx);                              \
    585       1.1       rjs } while (0)
    586       1.1       rjs 
    587       1.1       rjs #define SCTP_INP_RUNLOCK(_inp)		mutex_exit(&(_inp)->inp_mtx)
    588       1.1       rjs #define SCTP_INP_WUNLOCK(_inp)		mutex_exit(&(_inp)->inp_mtx)
    589       1.1       rjs #define SCTP_ASOC_CREATE_UNLOCK(_inp)	mutex_exit(&(_inp)->inp_create_mtx)
    590       1.1       rjs 
    591       1.1       rjs /* For the majority of things (once we have found the association) we
    592       1.1       rjs  * will lock the actual association mutex. This will protect all
    593       1.1       rjs  * the assoiciation level queues and streams and such. We will
    594       1.1       rjs  * need to lock the socket layer when we stuff data up into
    595       1.1       rjs  * the receiving sb_mb. I.e. we will need to do an extra
    596       1.1       rjs  * SOCKBUF_LOCK(&so->so_rcv) even though the association is
    597       1.1       rjs  * locked.
    598       1.1       rjs  */
    599       1.1       rjs 
    600       1.1       rjs #define SCTP_TCB_LOCK_INIT(_tcb) \
    601       1.1       rjs 	mutex_init(&(_tcb)->tcb_mtx, MUTEX_DEFAULT, IPL_NET)
    602       1.1       rjs #define SCTP_TCB_LOCK_DESTROY(_tcb)	mutex_destroy(&(_tcb)->tcb_mtx)
    603       1.1       rjs #define SCTP_TCB_LOCK(_tcb)  do {					\
    604       1.1       rjs 	mutex_enter(&(_tcb)->tcb_mtx);                                     \
    605       1.1       rjs } while (0)
    606       1.1       rjs #define SCTP_TCB_UNLOCK(_tcb)		mutex_exit(&(_tcb)->tcb_mtx)
    607       1.1       rjs 
    608       1.1       rjs #define SCTP_ITERATOR_LOCK_INIT() \
    609       1.1       rjs         mutex_init(&sctppcbinfo.it_mtx, MUTEX_DEFAULT, IPL_NET)
    610       1.1       rjs #define SCTP_ITERATOR_LOCK()  do {					\
    611       1.1       rjs         if (mutex_owned(&sctppcbinfo.it_mtx))                           \
    612       1.1       rjs 		panic("Iterator Lock");                                 \
    613       1.1       rjs 	mutex_enter(&sctppcbinfo.it_mtx);                               \
    614       1.1       rjs } while (0)
    615       1.1       rjs 
    616       1.1       rjs #define SCTP_ITERATOR_UNLOCK()	        mutex_exit(&sctppcbinfo.it_mtx)
    617       1.1       rjs #define SCTP_ITERATOR_LOCK_DESTROY()	mutex_destroy(&sctppcbinfo.it_mtx)
    618       1.1       rjs #else
    619       1.1       rjs 
    620       1.1       rjs /* Empty Lock declarations for all other
    621       1.1       rjs  * platforms pre-process away to nothing.
    622       1.1       rjs  */
    623       1.1       rjs 
    624       1.1       rjs /* Lock for INFO stuff */
    625       1.1       rjs #define SCTP_INP_INFO_LOCK_INIT()
    626       1.1       rjs #define SCTP_INP_INFO_RLOCK()
    627       1.1       rjs #define SCTP_INP_INFO_RLOCK()
    628       1.1       rjs #define SCTP_INP_INFO_WLOCK()
    629       1.1       rjs 
    630       1.1       rjs #define SCTP_INP_INFO_RUNLOCK()
    631       1.1       rjs #define SCTP_INP_INFO_WUNLOCK()
    632       1.1       rjs /* Lock for INP */
    633       1.1       rjs #define SCTP_INP_LOCK_INIT(_inp)
    634       1.1       rjs #define SCTP_INP_LOCK_DESTROY(_inp)
    635       1.1       rjs #define SCTP_INP_RLOCK(_inp)
    636       1.1       rjs #define SCTP_INP_RUNLOCK(_inp)
    637       1.1       rjs #define SCTP_INP_WLOCK(_inp)
    638       1.1       rjs #define SCTP_INP_INCR_REF(_inp)
    639       1.1       rjs #define SCTP_INP_DECR_REF(_inp)
    640       1.1       rjs #define SCTP_INP_WUNLOCK(_inp)
    641       1.1       rjs #define SCTP_ASOC_CREATE_LOCK_INIT(_inp)
    642       1.1       rjs #define SCTP_ASOC_CREATE_LOCK_DESTROY(_inp)
    643       1.1       rjs #define SCTP_ASOC_CREATE_LOCK(_inp)
    644       1.1       rjs #define SCTP_ASOC_CREATE_UNLOCK(_inp)
    645       1.1       rjs /* Lock for TCB */
    646       1.1       rjs #define SCTP_TCB_LOCK_INIT(_tcb)
    647       1.1       rjs #define SCTP_TCB_LOCK_DESTROY(_tcb)
    648       1.1       rjs #define SCTP_TCB_LOCK(_tcb)
    649       1.1       rjs #define SCTP_TCB_UNLOCK(_tcb)
    650       1.1       rjs /* iterator locks */
    651       1.1       rjs #define SCTP_ITERATOR_LOCK_INIT()
    652       1.1       rjs #define SCTP_ITERATOR_LOCK()
    653       1.1       rjs #define SCTP_ITERATOR_UNLOCK()
    654       1.1       rjs #define SCTP_ITERATOR_LOCK_DESTROY()
    655       1.1       rjs #endif
    656       1.1       rjs 
    657       1.1       rjs #if defined(_KERNEL)
    658       1.1       rjs 
    659       1.1       rjs extern struct sctp_epinfo sctppcbinfo;
    660       1.1       rjs extern int sctp_auto_asconf;
    661       1.1       rjs 
    662       1.1       rjs int SCTP6_ARE_ADDR_EQUAL(const struct in6_addr *a, const struct in6_addr *b);
    663       1.1       rjs 
    664       1.1       rjs void sctp_fill_pcbinfo(struct sctp_pcbinfo *);
    665       1.1       rjs 
    666       1.1       rjs struct sctp_nets *sctp_findnet(struct sctp_tcb *, struct sockaddr *);
    667       1.1       rjs 
    668       1.1       rjs struct sctp_inpcb *sctp_pcb_findep(struct sockaddr *, int, int);
    669       1.1       rjs 
    670       1.1       rjs int sctp_inpcb_bind(struct socket *, struct sockaddr *, struct lwp *);
    671       1.1       rjs 
    672       1.1       rjs struct sctp_tcb *sctp_findassociation_addr(struct mbuf *, int, int,
    673       1.1       rjs     struct sctphdr *, struct sctp_chunkhdr *, struct sctp_inpcb **,
    674       1.1       rjs     struct sctp_nets **);
    675       1.1       rjs 
    676       1.1       rjs struct sctp_tcb *sctp_findassociation_addr_sa(struct sockaddr *,
    677       1.1       rjs 	struct sockaddr *, struct sctp_inpcb **, struct sctp_nets **, int);
    678       1.1       rjs 
    679       1.1       rjs void sctp_move_pcb_and_assoc(struct sctp_inpcb *, struct sctp_inpcb *,
    680       1.1       rjs 	struct sctp_tcb *);
    681       1.1       rjs 
    682       1.1       rjs /*
    683       1.1       rjs  * For this call ep_addr, the to is the destination endpoint address
    684       1.1       rjs  * of the peer (relative to outbound). The from field is only used if
    685       1.1       rjs  * the TCP model is enabled and helps distingush amongst the subset
    686       1.1       rjs  * bound (non-boundall). The TCP model MAY change the actual ep field,
    687       1.1       rjs  * this is why it is passed.
    688       1.1       rjs  */
    689       1.1       rjs struct sctp_tcb *sctp_findassociation_ep_addr(struct sctp_inpcb **,
    690       1.1       rjs 	struct sockaddr *, struct sctp_nets **, struct sockaddr *, struct sctp_tcb *);
    691       1.1       rjs 
    692       1.1       rjs struct sctp_tcb *sctp_findassociation_ep_asocid(struct sctp_inpcb *, vaddr_t);
    693       1.1       rjs 
    694       1.1       rjs struct sctp_tcb *sctp_findassociation_ep_asconf(struct mbuf *, int, int,
    695       1.1       rjs     struct sctphdr *, struct sctp_inpcb **, struct sctp_nets **);
    696       1.1       rjs 
    697       1.1       rjs int sctp_inpcb_alloc(struct socket *);
    698       1.1       rjs 
    699       1.1       rjs 
    700       1.1       rjs int sctp_is_address_on_local_host(struct sockaddr *addr);
    701       1.1       rjs 
    702       1.1       rjs void sctp_inpcb_free(struct sctp_inpcb *, int);
    703       1.1       rjs 
    704       1.1       rjs struct sctp_tcb *sctp_aloc_assoc(struct sctp_inpcb *, struct sockaddr *,
    705       1.1       rjs 	int, int *, uint32_t);
    706       1.1       rjs 
    707       1.1       rjs void sctp_free_assoc(struct sctp_inpcb *, struct sctp_tcb *);
    708       1.1       rjs 
    709       1.1       rjs int sctp_add_local_addr_ep(struct sctp_inpcb *, struct ifaddr *);
    710       1.1       rjs 
    711       1.1       rjs int sctp_insert_laddr(struct sctpladdr *, struct ifaddr *);
    712       1.1       rjs 
    713       1.1       rjs void sctp_remove_laddr(struct sctp_laddr *);
    714       1.1       rjs 
    715       1.1       rjs int sctp_del_local_addr_ep(struct sctp_inpcb *, struct ifaddr *);
    716       1.1       rjs 
    717       1.1       rjs int sctp_del_local_addr_ep_sa(struct sctp_inpcb *, struct sockaddr *);
    718       1.1       rjs 
    719       1.1       rjs int sctp_add_remote_addr(struct sctp_tcb *, struct sockaddr *, int, int);
    720       1.1       rjs 
    721       1.1       rjs int sctp_del_remote_addr(struct sctp_tcb *, struct sockaddr *);
    722       1.1       rjs 
    723       1.1       rjs void sctp_pcb_init(void);
    724       1.1       rjs 
    725       1.1       rjs void sctp_free_remote_addr(struct sctp_nets *);
    726       1.1       rjs 
    727       1.1       rjs int sctp_add_local_addr_assoc(struct sctp_tcb *, struct ifaddr *);
    728       1.1       rjs 
    729       1.1       rjs int sctp_del_local_addr_assoc(struct sctp_tcb *, struct ifaddr *);
    730       1.1       rjs 
    731       1.1       rjs int sctp_del_local_addr_assoc_sa(struct sctp_tcb *, struct sockaddr *);
    732       1.1       rjs 
    733       1.1       rjs int sctp_load_addresses_from_init(struct sctp_tcb *, struct mbuf *, int, int,
    734       1.1       rjs     int, struct sctphdr *, struct sockaddr *);
    735       1.1       rjs 
    736       1.1       rjs int sctp_set_primary_addr(struct sctp_tcb *, struct sockaddr *, struct sctp_nets *);
    737       1.1       rjs 
    738       1.1       rjs int sctp_is_vtag_good(struct sctp_inpcb *, uint32_t, struct timeval *);
    739       1.1       rjs 
    740       1.1       rjs /*void sctp_drain(void);*/
    741       1.1       rjs 
    742       1.1       rjs int sctp_destination_is_reachable(struct sctp_tcb *, const struct sockaddr *);
    743       1.1       rjs 
    744       1.1       rjs int sctp_add_to_socket_q(struct sctp_inpcb *, struct sctp_tcb *);
    745       1.1       rjs 
    746       1.1       rjs struct sctp_tcb *sctp_remove_from_socket_q(struct sctp_inpcb *);
    747       1.1       rjs 
    748       1.1       rjs 
    749       1.1       rjs /* Null in last arg inpcb indicate run on ALL ep's. Specific
    750       1.1       rjs  * inp in last arg indicates run on ONLY assoc's of the
    751       1.1       rjs  * specified endpoint.
    752       1.1       rjs  */
    753       1.1       rjs int
    754       1.1       rjs sctp_initiate_iterator(asoc_func af, uint32_t, uint32_t, void *, uint32_t,
    755       1.1       rjs 		       end_func ef, struct sctp_inpcb *);
    756       1.1       rjs 
    757  1.1.22.1  christos void in6_sin6_2_sin (struct sockaddr_in *,
    758       1.1       rjs                             struct sockaddr_in6 *sin6);
    759       1.1       rjs 
    760       1.1       rjs #endif /* _KERNEL */
    761       1.1       rjs #endif /* !__SCTP_PCB_H__ */
    762