1 /* $KAME: sctp_pcb.h,v 1.19 2004/08/17 06:28:02 t-momose Exp $ */
4 * Copyright (c) 2001, 2002, 2003, 2004 Cisco Systems, Inc.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. All advertising materials mentioning features or use of this software
16 * must display the following acknowledgement:
17 * This product includes software developed by Cisco Systems, Inc.
18 * 4. Neither the name of the project nor the names of its contributors
19 * may be used to endorse or promote products derived from this software
20 * without specific prior written permission.
22 * THIS SOFTWARE IS PROVIDED BY CISCO SYSTEMS AND CONTRIBUTORS ``AS IS'' AND
23 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 * ARE DISCLAIMED. IN NO EVENT SHALL CISCO SYSTEMS OR CONTRIBUTORS BE LIABLE
26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35 #ifndef _NETINET_SCTP_PCB_H_
36 #define _NETINET_SCTP_PCB_H_
38 #ifndef _NETINET_IN_PCB_H_
39 #include <netinet/in_pcb.h>
43 * We must have V6 so the size of the proto can be calculated. Otherwise
44 * we would not allocate enough for Net/Open BSD :-<
46 #if defined(__FreeBSD__) && __FreeBSD_version > 500000
51 #include <net/if_var.h>
53 #include <netinet/ip6.h>
54 #include <netinet6/ip6_var.h>
55 #include <netinet6/ip6protosw.h>
56 #include <netinet6/in6_var.h>
57 #if defined(__OpenBSD__)
58 #include <netinet/in_pcb.h>
60 #include <netinet6/in6_pcb.h>
63 #if defined(__OpenBSD__) || defined(__FreeBSD__)
69 #include <netinet/sctp.h>
70 #include <netinet/sctp_constants.h>
72 LIST_HEAD(sctppcbhead, sctp_inpcb);
73 LIST_HEAD(sctpasochead, sctp_tcb);
74 TAILQ_HEAD(sctpsocketq, sctp_socket_q_list);
75 LIST_HEAD(sctpvtaghead, sctp_tagblock);
77 #include <netinet/sctp_structs.h>
78 #include <netinet/sctp_uio.h>
83 #define SCTP_PCB_FLAGS_UDPTYPE 0x00000001
84 #define SCTP_PCB_FLAGS_TCPTYPE 0x00000002
85 #define SCTP_PCB_FLAGS_BOUNDALL 0x00000004
86 #define SCTP_PCB_FLAGS_ACCEPTING 0x00000008
87 #define SCTP_PCB_FLAGS_UNBOUND 0x00000010
88 #define SCTP_PCB_FLAGS_DO_ASCONF 0x00000020
89 #define SCTP_PCB_FLAGS_AUTO_ASCONF 0x00000040
91 #define SCTP_PCB_FLAGS_NODELAY 0x00000100
92 #define SCTP_PCB_FLAGS_AUTOCLOSE 0x00000200
93 #define SCTP_PCB_FLAGS_RECVDATAIOEVNT 0x00000400
94 #define SCTP_PCB_FLAGS_RECVASSOCEVNT 0x00000800
95 #define SCTP_PCB_FLAGS_RECVPADDREVNT 0x00001000
96 #define SCTP_PCB_FLAGS_RECVPEERERR 0x00002000
97 #define SCTP_PCB_FLAGS_RECVSENDFAILEVNT 0x00004000
98 #define SCTP_PCB_FLAGS_RECVSHUTDOWNEVNT 0x00008000
99 #define SCTP_PCB_FLAGS_ADAPTIONEVNT 0x00010000
100 #define SCTP_PCB_FLAGS_PDAPIEVNT 0x00020000
101 #define SCTP_PCB_FLAGS_STREAM_RESETEVNT 0x00040000
102 #define SCTP_PCB_FLAGS_NO_FRAGMENT 0x00080000
103 /* TCP model support */
104 #define SCTP_PCB_FLAGS_CONNECTED 0x00100000
105 #define SCTP_PCB_FLAGS_IN_TCPPOOL 0x00200000
106 #define SCTP_PCB_FLAGS_DONT_WAKE 0x00400000
107 #define SCTP_PCB_FLAGS_WAKEOUTPUT 0x00800000
108 #define SCTP_PCB_FLAGS_WAKEINPUT 0x01000000
109 #define SCTP_PCB_FLAGS_BOUND_V6 0x02000000
110 #define SCTP_PCB_FLAGS_NEEDS_MAPPED_V4 0x04000000
111 #define SCTP_PCB_FLAGS_BLOCKING_IO 0x08000000
112 #define SCTP_PCB_FLAGS_SOCKET_GONE 0x10000000
113 #define SCTP_PCB_FLAGS_SOCKET_ALLGONE 0x20000000
115 /* flags to copy to new PCB */
116 #define SCTP_PCB_COPY_FLAGS 0x0707ff64
118 #define SCTP_PCBHASH_ALLADDR(port, mask) (port & mask)
119 #define SCTP_PCBHASH_ASOC(tag, mask) (tag & mask)
122 LIST_ENTRY(sctp_laddr) sctp_nxt_addr; /* next in list */
126 struct sctp_timewait {
127 uint32_t tv_sec_at_expire; /* the seconds from boot to expire */
128 uint32_t v_tag; /* the vtag that can not be reused */
131 struct sctp_tagblock {
132 LIST_ENTRY(sctp_tagblock) sctp_nxt_tagblock;
133 struct sctp_timewait vtag_block[SCTP_NUMBER_IN_VTAG_BLOCK];
137 struct sctpasochead *sctp_asochash;
140 struct sctppcbhead *sctp_ephash;
144 * The TCP model represents a substantial overhead in that we get
145 * an additional hash table to keep explicit connections in. The
146 * listening TCP endpoint will exist in the usual ephash above and
147 * accept only INIT's. It will be incapable of sending off an INIT.
148 * When a dg arrives we must look in the normal ephash. If we find
149 * a TCP endpoint that will tell us to go to the specific endpoint
150 * hash and re-hash to find the right assoc/socket. If we find a
151 * UDP model socket we then must complete the lookup. If this fails,
152 * i.e. no association can be found then we must continue to see if
153 * a sctp_peeloff()'d socket is in the tcpephash (a spun off socket
154 * acts like a TCP model connected socket).
156 struct sctppcbhead *sctp_tcpephash;
158 uint32_t hashtblsize;
160 struct sctppcbhead listhead;
162 struct sctpiterators iteratorhead;
165 #if defined(__FreeBSD__) || defined(__APPLE__) || defined(__DragonFly__)
166 #if defined(__FreeBSD__) && __FreeBSD_version >= 500000
167 struct uma_zone *ipi_zone_ep;
168 struct uma_zone *ipi_zone_asoc;
169 struct uma_zone *ipi_zone_laddr;
170 struct uma_zone *ipi_zone_net;
171 struct uma_zone *ipi_zone_chunk;
172 struct uma_zone *ipi_zone_sockq;
174 struct malloc_type ipi_zone_ep;
175 struct malloc_type ipi_zone_asoc;
176 struct malloc_type ipi_zone_laddr;
177 struct malloc_type ipi_zone_net;
178 struct malloc_type ipi_zone_chunk;
179 struct malloc_type ipi_zone_sockq;
182 #if defined(__NetBSD__) || defined(__OpenBSD__)
183 struct pool ipi_zone_ep;
184 struct pool ipi_zone_asoc;
185 struct pool ipi_zone_laddr;
186 struct pool ipi_zone_net;
187 struct pool ipi_zone_chunk;
188 struct pool ipi_zone_sockq;
191 #if defined(__FreeBSD__) && __FreeBSD_version >= 503000
192 struct mtx ipi_ep_mtx;
196 u_quad_t ipi_gencnt_ep;
198 /* assoc/tcb zone info */
199 u_int ipi_count_asoc;
200 u_quad_t ipi_gencnt_asoc;
202 /* local addrlist zone info */
203 u_int ipi_count_laddr;
204 u_quad_t ipi_gencnt_laddr;
206 /* remote addrlist zone info */
207 u_int ipi_count_raddr;
208 u_quad_t ipi_gencnt_raddr;
210 /* chunk structure list for output */
211 u_int ipi_count_chunk;
212 u_quad_t ipi_gencnt_chunk;
214 /* socket queue zone info */
215 u_int ipi_count_sockq;
216 u_quad_t ipi_gencnt_sockq;
218 struct sctpvtaghead vtag_timewait[SCTP_STACK_VTAG_HASH_SIZE];
220 #ifdef _SCTP_NEEDS_CALLOUT_
221 struct calloutlist callqueue;
222 #endif /* _SCTP_NEEDS_CALLOUT_ */
226 /* for port allocations */
233 extern uint32_t sctp_pegs[SCTP_NUMBER_OF_PEGS];
235 * Here we have all the relevant information for each SCTP entity created.
236 * We will need to modify this as approprate. We also need to figure out
237 * how to access /dev/random.
240 unsigned int time_of_secret_change; /* number of seconds from timeval.tv_sec */
241 uint32_t secret_key[SCTP_HOW_MANY_SECRETS][SCTP_NUMBER_OF_SECRETS];
242 unsigned int size_of_a_cookie;
244 unsigned int sctp_timeoutticks[SCTP_NUM_TMRS];
245 unsigned int sctp_minrto;
246 unsigned int sctp_maxrto;
247 unsigned int initial_rto;
249 int initial_init_rto_max;
251 uint32_t sctp_sws_sender;
252 uint32_t sctp_sws_receiver;
254 /* various thresholds */
255 /* Max times I will init at a guy */
256 uint16_t max_init_times;
258 /* Max times I will send before we consider someone dead */
259 uint16_t max_send_times;
261 uint16_t def_net_failure;
263 /* number of streams to pre-open on a association */
264 uint16_t pre_open_stream_count;
265 uint16_t max_open_streams_intome;
267 /* random number generator */
268 uint32_t random_counter;
269 uint8_t random_numbers[SCTP_SIGNATURE_ALOC_SIZE];
270 uint8_t random_store[SCTP_SIGNATURE_ALOC_SIZE];
273 * This timer is kept running per endpoint. When it fires it
274 * will change the secret key. The default is once a hour
276 struct sctp_timer signature_change;
280 uint32_t initial_sequence_debug;
281 uint32_t adaption_layer_indicator;
284 char current_secret_number;
285 char last_secret_number;
288 #ifndef SCTP_ALIGNMENT
289 #define SCTP_ALIGNMENT 32
293 #define SCTP_ALIGNM1 (SCTP_ALIGNMENT-1)
296 #define sctp_lport ip_inp.inp.inp_lport
298 struct sctp_socket_q_list {
299 struct sctp_tcb *tcb;
300 TAILQ_ENTRY(sctp_socket_q_list) next_sq;
305 * put an inpcb in front of it all, kind of a waste but we need
306 * to for compatability with all the other stuff.
310 char align[(sizeof(struct in6pcb) + SCTP_ALIGNM1) &
313 LIST_ENTRY(sctp_inpcb) sctp_list; /* lists all endpoints */
314 /* hash of all endpoints for model */
315 LIST_ENTRY(sctp_inpcb) sctp_hash;
317 /* count of local addresses bound, 0 if bound all */
319 /* list of addrs in use by the EP */
320 struct sctpladdr sctp_addr_list;
321 /* used for source address selection rotation */
322 struct sctp_laddr *next_addr_touse;
323 struct ifnet *next_ifn_touse;
324 /* back pointer to our socket */
325 struct socket *sctp_socket;
326 uint32_t sctp_flags; /* flag set */
327 struct sctp_pcb sctp_ep; /* SCTP ep data */
328 /* head of the hash of all associations */
329 struct sctpasochead *sctp_tcbhash;
330 u_long sctp_hashmark;
331 /* head of the list of all associations */
332 struct sctpasochead sctp_asoc_list;
333 /* queue of TCB's waiting to stuff data up the socket */
334 struct sctpsocketq sctp_queue_list;
335 void *sctp_tcb_at_block;
336 struct sctp_iterator *inp_starting_point_for_iterator;
338 uint32_t sctp_frag_point;
339 uint32_t sctp_vtag_first;
340 struct mbuf *pkt, *pkt_last, *sb_last_mpkt;
341 struct mbuf *control;
342 #if defined(__FreeBSD__) && __FreeBSD_version >= 503000
344 struct mtx inp_create_mtx;
350 struct socket *sctp_socket; /* back pointer to socket */
351 struct sctp_inpcb *sctp_ep; /* back pointer to ep */
352 LIST_ENTRY(sctp_tcb) sctp_tcbhash; /* next link in hash table */
353 LIST_ENTRY(sctp_tcb) sctp_tcblist; /* list of all of the TCB's */
354 LIST_ENTRY(sctp_tcb) sctp_asocs;
355 struct sctp_association asoc;
356 uint16_t rport; /* remote port in network format */
358 #if defined(__FreeBSD__) && __FreeBSD_version >= 503000
363 #if defined(__FreeBSD__) && __FreeBSD_version >= 503000
365 /* General locking concepts:
366 * The goal of our locking is to of course provide
367 * consistency and yet minimize overhead. We will
368 * attempt to use non-recursive locks which are supposed
369 * to be quite inexpensive. Now in order to do this the goal
370 * is that most functions are not aware of locking. Once we
371 * have a TCB we lock it and unlock when we are through. This
372 * means that the TCB lock is kind-of a "global" lock when
373 * working on an association. Caution must be used when
374 * asserting a TCB_LOCK since if we recurse we deadlock.
376 * Most other locks (INP and INFO) attempt to localize
377 * the locking i.e. we try to contain the lock and
378 * unlock within the function that needs to lock it. This
379 * sometimes mean we do extra locks and unlocks and loose
380 * a bit of efficency, but if the performance statements about
381 * non-recursive locks are true this should not be a problem.
382 * One issue that arises with this only lock when needed
383 * is that if an implicit association setup is done we
384 * have a problem. If at the time I lookup an association
385 * I have NULL in the tcb return, by the time I call to
386 * create the association some other processor could
387 * have created it. This is what the CREATE lock on
388 * the endpoint. Places where we will be implicitly
389 * creating the association OR just creating an association
390 * (the connect call) will assert the CREATE_INP lock. This
391 * will assure us that during all the lookup of INP and INFO
392 * if another creator is also locking/looking up we can
393 * gate the two to synchronize. So the CREATE_INP lock is
394 * also another one we must use extreme caution in locking
395 * to make sure we don't hit a re-entrancy issue.
397 * For non FreeBSD 5.x and above we provide a bunch
398 * of EMPTY lock macro's so we can blatantly put locks
399 * everywhere and they reduce to nothing on NetBSD/OpenBSD
405 /* When working with the global SCTP lists we lock and unlock
406 * the INP_INFO lock. So when we go to lookup an association
407 * we will want to do a SCTP_INP_INFO_RLOCK() and then when
408 * we want to add a new association to the sctppcbinfo list's
409 * we will do a SCTP_INP_INFO_WLOCK().
413 * FIX ME, all locks right now have a
414 * recursive check/panic to validate that I
415 * don't have any lock recursion going on.
418 #define SCTP_INP_INFO_LOCK_INIT() \
419 mtx_init(&sctppcbinfo.ipi_ep_mtx, "sctp", "inp_info", MTX_DEF)
422 #define SCTP_INP_INFO_RLOCK() do { \
423 if (mtx_owned(&sctppcbinfo.ipi_ep_mtx)) \
424 panic("INP INFO Recursive Lock-R"); \
425 mtx_lock(&sctppcbinfo.ipi_ep_mtx); \
428 #define SCTP_INP_INFO_WLOCK() do { \
429 if (mtx_owned(&sctppcbinfo.ipi_ep_mtx)) \
430 panic("INP INFO Recursive Lock-W"); \
431 mtx_lock(&sctppcbinfo.ipi_ep_mtx); \
436 void SCTP_INP_INFO_RLOCK(void);
437 void SCTP_INP_INFO_WLOCK(void);
441 #define SCTP_INP_INFO_RUNLOCK() mtx_unlock(&sctppcbinfo.ipi_ep_mtx)
442 #define SCTP_INP_INFO_WUNLOCK() mtx_unlock(&sctppcbinfo.ipi_ep_mtx)
444 /* The INP locks we will use for locking an SCTP endpoint, so for
445 * example if we want to change something at the endpoint level for
446 * example random_store or cookie secrets we lock the INP level.
448 #define SCTP_INP_LOCK_INIT(_inp) \
449 mtx_init(&(_inp)->inp_mtx, "sctp", "inp", MTX_DEF | MTX_DUPOK)
451 #define SCTP_ASOC_CREATE_LOCK_INIT(_inp) \
452 mtx_init(&(_inp)->inp_create_mtx, "sctp", "inp_create", \
455 #define SCTP_INP_LOCK_DESTROY(_inp) mtx_destroy(&(_inp)->inp_mtx)
456 #define SCTP_ASOC_CREATE_LOCK_DESTROY(_inp) mtx_destroy(&(_inp)->inp_create_mtx)
459 #define SCTP_INP_RLOCK(_inp) do { \
460 struct sctp_tcb *xx_stcb; \
461 xx_stcb = LIST_FIRST(&_inp->sctp_asoc_list); \
463 if (mtx_owned(&(xx_stcb)->tcb_mtx)) \
464 panic("I own TCB lock?"); \
465 if (mtx_owned(&(_inp)->inp_mtx)) \
466 panic("INP Recursive Lock-R"); \
467 mtx_lock(&(_inp)->inp_mtx); \
470 #define SCTP_INP_WLOCK(_inp) do { \
471 struct sctp_tcb *xx_stcb; \
472 xx_stcb = LIST_FIRST(&_inp->sctp_asoc_list); \
474 if (mtx_owned(&(xx_stcb)->tcb_mtx)) \
475 panic("I own TCB lock?"); \
476 if (mtx_owned(&(_inp)->inp_mtx)) \
477 panic("INP Recursive Lock-W"); \
478 mtx_lock(&(_inp)->inp_mtx); \
482 void SCTP_INP_RLOCK(struct sctp_inpcb *);
483 void SCTP_INP_WLOCK(struct sctp_inpcb *);
488 #define SCTP_INP_INCR_REF(_inp) _inp->refcount++
490 #define SCTP_INP_DECR_REF(_inp) do { \
491 if (_inp->refcount > 0) \
494 panic("bad inp refcount"); \
497 #define SCTP_ASOC_CREATE_LOCK(_inp) do { \
498 if (mtx_owned(&(_inp)->inp_create_mtx)) \
499 panic("INP Recursive CREATE"); \
500 mtx_lock(&(_inp)->inp_create_mtx); \
503 #define SCTP_INP_RUNLOCK(_inp) mtx_unlock(&(_inp)->inp_mtx)
504 #define SCTP_INP_WUNLOCK(_inp) mtx_unlock(&(_inp)->inp_mtx)
505 #define SCTP_ASOC_CREATE_UNLOCK(_inp) mtx_unlock(&(_inp)->inp_create_mtx)
507 /* For the majority of things (once we have found the association) we
508 * will lock the actual association mutex. This will protect all
509 * the assoiciation level queues and streams and such. We will
510 * need to lock the socket layer when we stuff data up into
511 * the receiving sb_mb. I.e. we will need to do an extra
512 * SOCKBUF_LOCK(&so->so_rcv) even though the association is
516 #define SCTP_TCB_LOCK_INIT(_tcb) \
517 mtx_init(&(_tcb)->tcb_mtx, "sctp", "tcb", MTX_DEF | MTX_DUPOK)
518 #define SCTP_TCB_LOCK_DESTROY(_tcb) mtx_destroy(&(_tcb)->tcb_mtx)
519 #define SCTP_TCB_LOCK(_tcb) do { \
520 if (!mtx_owned(&(_tcb->sctp_ep->inp_mtx))) \
521 panic("TCB locking and no INP lock"); \
522 if (mtx_owned(&(_tcb)->tcb_mtx)) \
523 panic("TCB Lock-recursive"); \
524 mtx_lock(&(_tcb)->tcb_mtx); \
526 #define SCTP_TCB_UNLOCK(_tcb) mtx_unlock(&(_tcb)->tcb_mtx)
528 #define SCTP_ITERATOR_LOCK_INIT() \
529 mtx_init(&sctppcbinfo.it_mtx, "sctp", "iterator", MTX_DEF)
530 #define SCTP_ITERATOR_LOCK() do { \
531 if (mtx_owned(&sctppcbinfo.it_mtx)) \
532 panic("Iterator Lock"); \
533 mtx_lock(&sctppcbinfo.it_mtx); \
536 #define SCTP_ITERATOR_UNLOCK() mtx_unlock(&sctppcbinfo.it_mtx)
537 #define SCTP_ITERATOR_LOCK_DESTROY() mtx_destroy(&sctppcbinfo.it_mtx)
540 /* Empty Lock declarations for all other
541 * platforms pre-process away to nothing.
544 /* Lock for INFO stuff */
545 #define SCTP_INP_INFO_LOCK_INIT()
546 #define SCTP_INP_INFO_RLOCK()
547 #define SCTP_INP_INFO_RLOCK()
548 #define SCTP_INP_INFO_WLOCK()
550 #define SCTP_INP_INFO_RUNLOCK()
551 #define SCTP_INP_INFO_WUNLOCK()
553 #define SCTP_INP_LOCK_INIT(_inp)
554 #define SCTP_INP_LOCK_DESTROY(_inp)
555 #define SCTP_INP_RLOCK(_inp)
556 #define SCTP_INP_RUNLOCK(_inp)
557 #define SCTP_INP_WLOCK(_inp)
558 #define SCTP_INP_INCR_REF(_inp)
559 #define SCTP_INP_DECR_REF(_inp)
560 #define SCTP_INP_WUNLOCK(_inp)
561 #define SCTP_ASOC_CREATE_LOCK_INIT(_inp)
562 #define SCTP_ASOC_CREATE_LOCK_DESTROY(_inp)
563 #define SCTP_ASOC_CREATE_LOCK(_inp)
564 #define SCTP_ASOC_CREATE_UNLOCK(_inp)
566 #define SCTP_TCB_LOCK_INIT(_tcb)
567 #define SCTP_TCB_LOCK_DESTROY(_tcb)
568 #define SCTP_TCB_LOCK(_tcb)
569 #define SCTP_TCB_UNLOCK(_tcb)
570 /* socket locks that are not here in other than 5.3 > FreeBSD*/
571 #define SOCK_LOCK(_so)
572 #define SOCK_UNLOCK(_so)
573 #define SOCKBUF_LOCK(_so_buf)
574 #define SOCKBUF_UNLOCK(_so_buf)
576 #define SCTP_ITERATOR_LOCK_INIT()
577 #define SCTP_ITERATOR_LOCK()
578 #define SCTP_ITERATOR_UNLOCK()
579 #define SCTP_ITERATOR_LOCK_DESTROY()
582 #if defined(_KERNEL) || (defined(__APPLE__) && defined(KERNEL))
584 extern struct sctp_epinfo sctppcbinfo;
585 extern int sctp_auto_asconf;
587 int SCTP6_ARE_ADDR_EQUAL(struct in6_addr *a, struct in6_addr *b);
589 void sctp_fill_pcbinfo(struct sctp_pcbinfo *);
591 struct sctp_nets *sctp_findnet(struct sctp_tcb *, struct sockaddr *);
593 struct sctp_inpcb *sctp_pcb_findep(struct sockaddr *, int, int);
595 #if (defined(__FreeBSD__) && __FreeBSD_version >= 500000) || defined(__DragonFly__)
596 int sctp_inpcb_bind(struct socket *, struct sockaddr *, struct thread *);
598 int sctp_inpcb_bind(struct socket *, struct sockaddr *, struct proc *);
601 struct sctp_tcb *sctp_findassociation_addr(struct mbuf *, int, int,
602 struct sctphdr *, struct sctp_chunkhdr *, struct sctp_inpcb **,
603 struct sctp_nets **);
605 struct sctp_tcb *sctp_findassociation_addr_sa(struct sockaddr *,
606 struct sockaddr *, struct sctp_inpcb **, struct sctp_nets **, int);
608 void sctp_move_pcb_and_assoc(struct sctp_inpcb *, struct sctp_inpcb *,
612 * For this call ep_addr, the to is the destination endpoint address
613 * of the peer (relative to outbound). The from field is only used if
614 * the TCP model is enabled and helps distingush amongst the subset
615 * bound (non-boundall). The TCP model MAY change the actual ep field,
616 * this is why it is passed.
618 struct sctp_tcb *sctp_findassociation_ep_addr(struct sctp_inpcb **,
619 struct sockaddr *, struct sctp_nets **, struct sockaddr *, struct sctp_tcb *);
621 struct sctp_tcb *sctp_findassociation_ep_asocid(struct sctp_inpcb *, caddr_t);
623 struct sctp_tcb *sctp_findassociation_ep_asconf(struct mbuf *, int, int,
624 struct sctphdr *, struct sctp_inpcb **, struct sctp_nets **);
626 int sctp_inpcb_alloc(struct socket *);
629 int sctp_is_address_on_local_host(struct sockaddr *addr);
631 void sctp_inpcb_free(struct sctp_inpcb *, int);
633 struct sctp_tcb *sctp_aloc_assoc(struct sctp_inpcb *, struct sockaddr *,
634 int, int *, uint32_t);
636 void sctp_free_assoc(struct sctp_inpcb *, struct sctp_tcb *);
638 int sctp_add_local_addr_ep(struct sctp_inpcb *, struct ifaddr *);
640 int sctp_insert_laddr(struct sctpladdr *, struct ifaddr *);
642 void sctp_remove_laddr(struct sctp_laddr *);
644 int sctp_del_local_addr_ep(struct sctp_inpcb *, struct ifaddr *);
646 int sctp_del_local_addr_ep_sa(struct sctp_inpcb *, struct sockaddr *);
648 int sctp_add_remote_addr(struct sctp_tcb *, struct sockaddr *, int, int);
650 int sctp_del_remote_addr(struct sctp_tcb *, struct sockaddr *);
652 void sctp_pcb_init(void);
654 void sctp_free_remote_addr(struct sctp_nets *);
656 int sctp_add_local_addr_assoc(struct sctp_tcb *, struct ifaddr *);
658 int sctp_del_local_addr_assoc(struct sctp_tcb *, struct ifaddr *);
660 int sctp_del_local_addr_assoc_sa(struct sctp_tcb *, struct sockaddr *);
662 int sctp_load_addresses_from_init(struct sctp_tcb *, struct mbuf *, int, int,
663 int, struct sctphdr *, struct sockaddr *);
665 int sctp_set_primary_addr(struct sctp_tcb *, struct sockaddr *, struct sctp_nets *);
667 int sctp_is_vtag_good(struct sctp_inpcb *, uint32_t, struct timeval *);
669 /*void sctp_drain(void);*/
671 int sctp_destination_is_reachable(struct sctp_tcb *, struct sockaddr *);
673 int sctp_add_to_socket_q(struct sctp_inpcb *, struct sctp_tcb *);
675 struct sctp_tcb *sctp_remove_from_socket_q(struct sctp_inpcb *);
678 /* Null in last arg inpcb indicate run on ALL ep's. Specific
679 * inp in last arg indicates run on ONLY assoc's of the
680 * specified endpoint.
683 sctp_initiate_iterator(asoc_func af, uint32_t, uint32_t, void *, uint32_t,
684 end_func ef, struct sctp_inpcb *);
686 #if defined(__APPLE__)
687 void sctp_callout_alloc(struct sctp_timer *);
688 void sctp_callout_free(struct callout *);
692 #endif /* _NETINET_SCTP_PCB_H_ */