1 /* $KAME: sctp_pcb.h,v 1.19 2004/08/17 06:28:02 t-momose Exp $ */
2 /* $DragonFly: src/sys/netinet/sctp_pcb.h,v 1.2 2005/07/15 15:02:02 eirikn Exp $ */
8 * Copyright (c) 2001, 2002, 2003, 2004 Cisco Systems, Inc.
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
19 * 3. All advertising materials mentioning features or use of this software
20 * must display the following acknowledgement:
21 * This product includes software developed by Cisco Systems, Inc.
22 * 4. Neither the name of the project nor the names of its contributors
23 * may be used to endorse or promote products derived from this software
24 * without specific prior written permission.
26 * THIS SOFTWARE IS PROVIDED BY CISCO SYSTEMS AND CONTRIBUTORS ``AS IS'' AND
27 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
29 * ARE DISCLAIMED. IN NO EVENT SHALL CISCO SYSTEMS OR CONTRIBUTORS BE LIABLE
30 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
31 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
32 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
40 * We must have V6 so the size of the proto can be calculated. Otherwise
41 * we would not allocate enough for Net/Open BSD :-<
43 #if defined(__FreeBSD__) && __FreeBSD_version > 500000
48 #include <net/if_var.h>
50 #include <netinet/ip6.h>
51 #include <netinet6/ip6_var.h>
52 #include <netinet6/ip6protosw.h>
53 #include <netinet6/in6_var.h>
54 #if defined(__OpenBSD__)
55 #include <netinet/in_pcb.h>
57 #include <netinet6/in6_pcb.h>
60 #if defined(__OpenBSD__) || defined(__FreeBSD__)
66 #include <netinet/sctp.h>
67 #include <netinet/sctp_constants.h>
69 LIST_HEAD(sctppcbhead, sctp_inpcb);
70 LIST_HEAD(sctpasochead, sctp_tcb);
71 TAILQ_HEAD(sctpsocketq, sctp_socket_q_list);
72 LIST_HEAD(sctpladdr, sctp_laddr);
73 LIST_HEAD(sctpvtaghead, sctp_tagblock);
75 #include <netinet/sctp_structs.h>
76 #include <netinet/sctp_uio.h>
81 #define SCTP_PCB_FLAGS_UDPTYPE 0x00000001
82 #define SCTP_PCB_FLAGS_TCPTYPE 0x00000002
83 #define SCTP_PCB_FLAGS_BOUNDALL 0x00000004
84 #define SCTP_PCB_FLAGS_ACCEPTING 0x00000008
85 #define SCTP_PCB_FLAGS_UNBOUND 0x00000010
86 #define SCTP_PCB_FLAGS_DO_ASCONF 0x00000020
87 #define SCTP_PCB_FLAGS_AUTO_ASCONF 0x00000040
89 #define SCTP_PCB_FLAGS_NODELAY 0x00000100
90 #define SCTP_PCB_FLAGS_AUTOCLOSE 0x00000200
91 #define SCTP_PCB_FLAGS_RECVDATAIOEVNT 0x00000400
92 #define SCTP_PCB_FLAGS_RECVASSOCEVNT 0x00000800
93 #define SCTP_PCB_FLAGS_RECVPADDREVNT 0x00001000
94 #define SCTP_PCB_FLAGS_RECVPEERERR 0x00002000
95 #define SCTP_PCB_FLAGS_RECVSENDFAILEVNT 0x00004000
96 #define SCTP_PCB_FLAGS_RECVSHUTDOWNEVNT 0x00008000
97 #define SCTP_PCB_FLAGS_ADAPTIONEVNT 0x00010000
98 #define SCTP_PCB_FLAGS_PDAPIEVNT 0x00020000
99 #define SCTP_PCB_FLAGS_STREAM_RESETEVNT 0x00040000
100 #define SCTP_PCB_FLAGS_NO_FRAGMENT 0x00080000
101 /* TCP model support */
102 #define SCTP_PCB_FLAGS_CONNECTED 0x00100000
103 #define SCTP_PCB_FLAGS_IN_TCPPOOL 0x00200000
104 #define SCTP_PCB_FLAGS_DONT_WAKE 0x00400000
105 #define SCTP_PCB_FLAGS_WAKEOUTPUT 0x00800000
106 #define SCTP_PCB_FLAGS_WAKEINPUT 0x01000000
107 #define SCTP_PCB_FLAGS_BOUND_V6 0x02000000
108 #define SCTP_PCB_FLAGS_NEEDS_MAPPED_V4 0x04000000
109 #define SCTP_PCB_FLAGS_BLOCKING_IO 0x08000000
110 #define SCTP_PCB_FLAGS_SOCKET_GONE 0x10000000
111 #define SCTP_PCB_FLAGS_SOCKET_ALLGONE 0x20000000
113 /* flags to copy to new PCB */
114 #define SCTP_PCB_COPY_FLAGS 0x0707ff64
116 #define SCTP_PCBHASH_ALLADDR(port, mask) (port & mask)
117 #define SCTP_PCBHASH_ASOC(tag, mask) (tag & mask)
120 LIST_ENTRY(sctp_laddr) sctp_nxt_addr; /* next in list */
124 struct sctp_timewait {
125 uint32_t tv_sec_at_expire; /* the seconds from boot to expire */
126 uint32_t v_tag; /* the vtag that can not be reused */
129 struct sctp_tagblock {
130 LIST_ENTRY(sctp_tagblock) sctp_nxt_tagblock;
131 struct sctp_timewait vtag_block[SCTP_NUMBER_IN_VTAG_BLOCK];
135 struct sctpasochead *sctp_asochash;
138 struct sctppcbhead *sctp_ephash;
142 * The TCP model represents a substantial overhead in that we get
143 * an additional hash table to keep explicit connections in. The
144 * listening TCP endpoint will exist in the usual ephash above and
145 * accept only INIT's. It will be incapable of sending off an INIT.
146 * When a dg arrives we must look in the normal ephash. If we find
147 * a TCP endpoint that will tell us to go to the specific endpoint
148 * hash and re-hash to find the right assoc/socket. If we find a
149 * UDP model socket we then must complete the lookup. If this fails,
150 * i.e. no association can be found then we must continue to see if
151 * a sctp_peeloff()'d socket is in the tcpephash (a spun off socket
152 * acts like a TCP model connected socket).
154 struct sctppcbhead *sctp_tcpephash;
156 uint32_t hashtblsize;
158 struct sctppcbhead listhead;
160 struct sctpiterators iteratorhead;
163 #if defined(__FreeBSD__) || defined(__APPLE__) || defined(__DragonFly__)
164 #if __FreeBSD_version >= 500000
165 struct uma_zone *ipi_zone_ep;
166 struct uma_zone *ipi_zone_asoc;
167 struct uma_zone *ipi_zone_laddr;
168 struct uma_zone *ipi_zone_net;
169 struct uma_zone *ipi_zone_chunk;
170 struct uma_zone *ipi_zone_sockq;
172 struct vm_zone *ipi_zone_ep;
173 struct vm_zone *ipi_zone_asoc;
174 struct vm_zone *ipi_zone_laddr;
175 struct vm_zone *ipi_zone_net;
176 struct vm_zone *ipi_zone_chunk;
177 struct vm_zone *ipi_zone_sockq;
180 #if defined(__NetBSD__) || defined(__OpenBSD__)
181 struct pool ipi_zone_ep;
182 struct pool ipi_zone_asoc;
183 struct pool ipi_zone_laddr;
184 struct pool ipi_zone_net;
185 struct pool ipi_zone_chunk;
186 struct pool ipi_zone_sockq;
189 #if defined(__FreeBSD__) && __FreeBSD_version >= 503000
190 struct mtx ipi_ep_mtx;
194 u_quad_t ipi_gencnt_ep;
196 /* assoc/tcb zone info */
197 u_int ipi_count_asoc;
198 u_quad_t ipi_gencnt_asoc;
200 /* local addrlist zone info */
201 u_int ipi_count_laddr;
202 u_quad_t ipi_gencnt_laddr;
204 /* remote addrlist zone info */
205 u_int ipi_count_raddr;
206 u_quad_t ipi_gencnt_raddr;
208 /* chunk structure list for output */
209 u_int ipi_count_chunk;
210 u_quad_t ipi_gencnt_chunk;
212 /* socket queue zone info */
213 u_int ipi_count_sockq;
214 u_quad_t ipi_gencnt_sockq;
216 struct sctpvtaghead vtag_timewait[SCTP_STACK_VTAG_HASH_SIZE];
218 #ifdef _SCTP_NEEDS_CALLOUT_
219 struct calloutlist callqueue;
220 #endif /* _SCTP_NEEDS_CALLOUT_ */
224 /* for port allocations */
231 extern uint32_t sctp_pegs[SCTP_NUMBER_OF_PEGS];
233 * Here we have all the relevant information for each SCTP entity created.
234 * We will need to modify this as approprate. We also need to figure out
235 * how to access /dev/random.
238 unsigned int time_of_secret_change; /* number of seconds from timeval.tv_sec */
239 uint32_t secret_key[SCTP_HOW_MANY_SECRETS][SCTP_NUMBER_OF_SECRETS];
240 unsigned int size_of_a_cookie;
242 unsigned int sctp_timeoutticks[SCTP_NUM_TMRS];
243 unsigned int sctp_minrto;
244 unsigned int sctp_maxrto;
245 unsigned int initial_rto;
247 int initial_init_rto_max;
249 uint32_t sctp_sws_sender;
250 uint32_t sctp_sws_receiver;
252 /* various thresholds */
253 /* Max times I will init at a guy */
254 uint16_t max_init_times;
256 /* Max times I will send before we consider someone dead */
257 uint16_t max_send_times;
259 uint16_t def_net_failure;
261 /* number of streams to pre-open on a association */
262 uint16_t pre_open_stream_count;
263 uint16_t max_open_streams_intome;
265 /* random number generator */
266 uint32_t random_counter;
267 uint8_t random_numbers[SCTP_SIGNATURE_ALOC_SIZE];
268 uint8_t random_store[SCTP_SIGNATURE_ALOC_SIZE];
271 * This timer is kept running per endpoint. When it fires it
272 * will change the secret key. The default is once a hour
274 struct sctp_timer signature_change;
278 uint32_t initial_sequence_debug;
279 uint32_t adaption_layer_indicator;
282 char current_secret_number;
283 char last_secret_number;
286 #ifndef SCTP_ALIGNMENT
287 #define SCTP_ALIGNMENT 32
291 #define SCTP_ALIGNM1 (SCTP_ALIGNMENT-1)
294 #define sctp_lport ip_inp.inp.inp_lport
296 struct sctp_socket_q_list {
297 struct sctp_tcb *tcb;
298 TAILQ_ENTRY(sctp_socket_q_list) next_sq;
303 * put an inpcb in front of it all, kind of a waste but we need
304 * to for compatability with all the other stuff.
308 char align[(sizeof(struct in6pcb) + SCTP_ALIGNM1) &
311 LIST_ENTRY(sctp_inpcb) sctp_list; /* lists all endpoints */
312 /* hash of all endpoints for model */
313 LIST_ENTRY(sctp_inpcb) sctp_hash;
315 /* count of local addresses bound, 0 if bound all */
317 /* list of addrs in use by the EP */
318 struct sctpladdr sctp_addr_list;
319 /* used for source address selection rotation */
320 struct sctp_laddr *next_addr_touse;
321 struct ifnet *next_ifn_touse;
322 /* back pointer to our socket */
323 struct socket *sctp_socket;
324 uint32_t sctp_flags; /* flag set */
325 struct sctp_pcb sctp_ep; /* SCTP ep data */
326 /* head of the hash of all associations */
327 struct sctpasochead *sctp_tcbhash;
328 u_long sctp_hashmark;
329 /* head of the list of all associations */
330 struct sctpasochead sctp_asoc_list;
331 /* queue of TCB's waiting to stuff data up the socket */
332 struct sctpsocketq sctp_queue_list;
333 void *sctp_tcb_at_block;
334 struct sctp_iterator *inp_starting_point_for_iterator;
336 uint32_t sctp_frag_point;
337 uint32_t sctp_vtag_first;
338 struct mbuf *pkt, *pkt_last, *sb_last_mpkt;
339 struct mbuf *control;
340 #if !(defined(__FreeBSD__) || defined(__APPLE__) || defined(__DragonFly__))
352 #if defined(__FreeBSD__) && __FreeBSD_version >= 503000
354 struct mtx inp_create_mtx;
360 struct socket *sctp_socket; /* back pointer to socket */
361 struct sctp_inpcb *sctp_ep; /* back pointer to ep */
362 LIST_ENTRY(sctp_tcb) sctp_tcbhash; /* next link in hash table */
363 LIST_ENTRY(sctp_tcb) sctp_tcblist; /* list of all of the TCB's */
364 LIST_ENTRY(sctp_tcb) sctp_asocs;
365 struct sctp_association asoc;
366 uint16_t rport; /* remote port in network format */
368 #if defined(__FreeBSD__) && __FreeBSD_version >= 503000
373 #if defined(__FreeBSD__) && __FreeBSD_version >= 503000
375 /* General locking concepts:
376 * The goal of our locking is to of course provide
377 * consistency and yet minimize overhead. We will
378 * attempt to use non-recursive locks which are supposed
379 * to be quite inexpensive. Now in order to do this the goal
380 * is that most functions are not aware of locking. Once we
381 * have a TCB we lock it and unlock when we are through. This
382 * means that the TCB lock is kind-of a "global" lock when
383 * working on an association. Caution must be used when
384 * asserting a TCB_LOCK since if we recurse we deadlock.
386 * Most other locks (INP and INFO) attempt to localize
387 * the locking i.e. we try to contain the lock and
388 * unlock within the function that needs to lock it. This
389 * sometimes mean we do extra locks and unlocks and loose
390 * a bit of efficency, but if the performance statements about
391 * non-recursive locks are true this should not be a problem.
392 * One issue that arises with this only lock when needed
393 * is that if an implicit association setup is done we
394 * have a problem. If at the time I lookup an association
395 * I have NULL in the tcb return, by the time I call to
396 * create the association some other processor could
397 * have created it. This is what the CREATE lock on
398 * the endpoint. Places where we will be implicitly
399 * creating the association OR just creating an association
400 * (the connect call) will assert the CREATE_INP lock. This
401 * will assure us that during all the lookup of INP and INFO
402 * if another creator is also locking/looking up we can
403 * gate the two to synchronize. So the CREATE_INP lock is
404 * also another one we must use extreme caution in locking
405 * to make sure we don't hit a re-entrancy issue.
407 * For non FreeBSD 5.x and above we provide a bunch
408 * of EMPTY lock macro's so we can blatantly put locks
409 * everywhere and they reduce to nothing on NetBSD/OpenBSD
415 /* When working with the global SCTP lists we lock and unlock
416 * the INP_INFO lock. So when we go to lookup an association
417 * we will want to do a SCTP_INP_INFO_RLOCK() and then when
418 * we want to add a new association to the sctppcbinfo list's
419 * we will do a SCTP_INP_INFO_WLOCK().
423 * FIX ME, all locks right now have a
424 * recursive check/panic to validate that I
425 * don't have any lock recursion going on.
428 #define SCTP_INP_INFO_LOCK_INIT() \
429 mtx_init(&sctppcbinfo.ipi_ep_mtx, "sctp", "inp_info", MTX_DEF)
432 #define SCTP_INP_INFO_RLOCK() do { \
433 if (mtx_owned(&sctppcbinfo.ipi_ep_mtx)) \
434 panic("INP INFO Recursive Lock-R"); \
435 mtx_lock(&sctppcbinfo.ipi_ep_mtx); \
438 #define SCTP_INP_INFO_WLOCK() do { \
439 if (mtx_owned(&sctppcbinfo.ipi_ep_mtx)) \
440 panic("INP INFO Recursive Lock-W"); \
441 mtx_lock(&sctppcbinfo.ipi_ep_mtx); \
446 void SCTP_INP_INFO_RLOCK(void);
447 void SCTP_INP_INFO_WLOCK(void);
451 #define SCTP_INP_INFO_RUNLOCK() mtx_unlock(&sctppcbinfo.ipi_ep_mtx)
452 #define SCTP_INP_INFO_WUNLOCK() mtx_unlock(&sctppcbinfo.ipi_ep_mtx)
454 /* The INP locks we will use for locking an SCTP endpoint, so for
455 * example if we want to change something at the endpoint level for
456 * example random_store or cookie secrets we lock the INP level.
458 #define SCTP_INP_LOCK_INIT(_inp) \
459 mtx_init(&(_inp)->inp_mtx, "sctp", "inp", MTX_DEF | MTX_DUPOK)
461 #define SCTP_ASOC_CREATE_LOCK_INIT(_inp) \
462 mtx_init(&(_inp)->inp_create_mtx, "sctp", "inp_create", \
465 #define SCTP_INP_LOCK_DESTROY(_inp) mtx_destroy(&(_inp)->inp_mtx)
466 #define SCTP_ASOC_CREATE_LOCK_DESTROY(_inp) mtx_destroy(&(_inp)->inp_create_mtx)
469 #define SCTP_INP_RLOCK(_inp) do { \
470 struct sctp_tcb *xx_stcb; \
471 xx_stcb = LIST_FIRST(&_inp->sctp_asoc_list); \
473 if (mtx_owned(&(xx_stcb)->tcb_mtx)) \
474 panic("I own TCB lock?"); \
475 if (mtx_owned(&(_inp)->inp_mtx)) \
476 panic("INP Recursive Lock-R"); \
477 mtx_lock(&(_inp)->inp_mtx); \
480 #define SCTP_INP_WLOCK(_inp) do { \
481 struct sctp_tcb *xx_stcb; \
482 xx_stcb = LIST_FIRST(&_inp->sctp_asoc_list); \
484 if (mtx_owned(&(xx_stcb)->tcb_mtx)) \
485 panic("I own TCB lock?"); \
486 if (mtx_owned(&(_inp)->inp_mtx)) \
487 panic("INP Recursive Lock-W"); \
488 mtx_lock(&(_inp)->inp_mtx); \
492 void SCTP_INP_RLOCK(struct sctp_inpcb *);
493 void SCTP_INP_WLOCK(struct sctp_inpcb *);
498 #define SCTP_INP_INCR_REF(_inp) _inp->refcount++
500 #define SCTP_INP_DECR_REF(_inp) do { \
501 if (_inp->refcount > 0) \
504 panic("bad inp refcount"); \
507 #define SCTP_ASOC_CREATE_LOCK(_inp) do { \
508 if (mtx_owned(&(_inp)->inp_create_mtx)) \
509 panic("INP Recursive CREATE"); \
510 mtx_lock(&(_inp)->inp_create_mtx); \
513 #define SCTP_INP_RUNLOCK(_inp) mtx_unlock(&(_inp)->inp_mtx)
514 #define SCTP_INP_WUNLOCK(_inp) mtx_unlock(&(_inp)->inp_mtx)
515 #define SCTP_ASOC_CREATE_UNLOCK(_inp) mtx_unlock(&(_inp)->inp_create_mtx)
517 /* For the majority of things (once we have found the association) we
518 * will lock the actual association mutex. This will protect all
519 * the assoiciation level queues and streams and such. We will
520 * need to lock the socket layer when we stuff data up into
521 * the receiving sb_mb. I.e. we will need to do an extra
522 * SOCKBUF_LOCK(&so->so_rcv) even though the association is
526 #define SCTP_TCB_LOCK_INIT(_tcb) \
527 mtx_init(&(_tcb)->tcb_mtx, "sctp", "tcb", MTX_DEF | MTX_DUPOK)
528 #define SCTP_TCB_LOCK_DESTROY(_tcb) mtx_destroy(&(_tcb)->tcb_mtx)
529 #define SCTP_TCB_LOCK(_tcb) do { \
530 if (!mtx_owned(&(_tcb->sctp_ep->inp_mtx))) \
531 panic("TCB locking and no INP lock"); \
532 if (mtx_owned(&(_tcb)->tcb_mtx)) \
533 panic("TCB Lock-recursive"); \
534 mtx_lock(&(_tcb)->tcb_mtx); \
536 #define SCTP_TCB_UNLOCK(_tcb) mtx_unlock(&(_tcb)->tcb_mtx)
538 #define SCTP_ITERATOR_LOCK_INIT() \
539 mtx_init(&sctppcbinfo.it_mtx, "sctp", "iterator", MTX_DEF)
540 #define SCTP_ITERATOR_LOCK() do { \
541 if (mtx_owned(&sctppcbinfo.it_mtx)) \
542 panic("Iterator Lock"); \
543 mtx_lock(&sctppcbinfo.it_mtx); \
546 #define SCTP_ITERATOR_UNLOCK() mtx_unlock(&sctppcbinfo.it_mtx)
547 #define SCTP_ITERATOR_LOCK_DESTROY() mtx_destroy(&sctppcbinfo.it_mtx)
550 /* Empty Lock declarations for all other
551 * platforms pre-process away to nothing.
554 /* Lock for INFO stuff */
555 #define SCTP_INP_INFO_LOCK_INIT()
556 #define SCTP_INP_INFO_RLOCK()
557 #define SCTP_INP_INFO_RLOCK()
558 #define SCTP_INP_INFO_WLOCK()
560 #define SCTP_INP_INFO_RUNLOCK()
561 #define SCTP_INP_INFO_WUNLOCK()
563 #define SCTP_INP_LOCK_INIT(_inp)
564 #define SCTP_INP_LOCK_DESTROY(_inp)
565 #define SCTP_INP_RLOCK(_inp)
566 #define SCTP_INP_RUNLOCK(_inp)
567 #define SCTP_INP_WLOCK(_inp)
568 #define SCTP_INP_INCR_REF(_inp)
569 #define SCTP_INP_DECR_REF(_inp)
570 #define SCTP_INP_WUNLOCK(_inp)
571 #define SCTP_ASOC_CREATE_LOCK_INIT(_inp)
572 #define SCTP_ASOC_CREATE_LOCK_DESTROY(_inp)
573 #define SCTP_ASOC_CREATE_LOCK(_inp)
574 #define SCTP_ASOC_CREATE_UNLOCK(_inp)
576 #define SCTP_TCB_LOCK_INIT(_tcb)
577 #define SCTP_TCB_LOCK_DESTROY(_tcb)
578 #define SCTP_TCB_LOCK(_tcb)
579 #define SCTP_TCB_UNLOCK(_tcb)
580 /* socket locks that are not here in other than 5.3 > FreeBSD*/
581 #define SOCK_LOCK(_so)
582 #define SOCK_UNLOCK(_so)
583 #define SOCKBUF_LOCK(_so_buf)
584 #define SOCKBUF_UNLOCK(_so_buf)
586 #define SCTP_ITERATOR_LOCK_INIT()
587 #define SCTP_ITERATOR_LOCK()
588 #define SCTP_ITERATOR_UNLOCK()
589 #define SCTP_ITERATOR_LOCK_DESTROY()
592 #if defined(_KERNEL) || (defined(__APPLE__) && defined(KERNEL))
594 extern struct sctp_epinfo sctppcbinfo;
595 extern int sctp_auto_asconf;
597 int SCTP6_ARE_ADDR_EQUAL(struct in6_addr *a, struct in6_addr *b);
599 void sctp_fill_pcbinfo(struct sctp_pcbinfo *);
601 struct sctp_nets *sctp_findnet(struct sctp_tcb *, struct sockaddr *);
603 struct sctp_inpcb *sctp_pcb_findep(struct sockaddr *, int, int);
605 #if (defined(__FreeBSD__) && __FreeBSD_version >= 500000) || defined(__DragonFly__)
606 int sctp_inpcb_bind(struct socket *, struct sockaddr *, struct thread *);
608 int sctp_inpcb_bind(struct socket *, struct sockaddr *, struct proc *);
611 struct sctp_tcb *sctp_findassociation_addr(struct mbuf *, int, int,
612 struct sctphdr *, struct sctp_chunkhdr *, struct sctp_inpcb **,
613 struct sctp_nets **);
615 struct sctp_tcb *sctp_findassociation_addr_sa(struct sockaddr *,
616 struct sockaddr *, struct sctp_inpcb **, struct sctp_nets **, int);
618 void sctp_move_pcb_and_assoc(struct sctp_inpcb *, struct sctp_inpcb *,
622 * For this call ep_addr, the to is the destination endpoint address
623 * of the peer (relative to outbound). The from field is only used if
624 * the TCP model is enabled and helps distingush amongst the subset
625 * bound (non-boundall). The TCP model MAY change the actual ep field,
626 * this is why it is passed.
628 struct sctp_tcb *sctp_findassociation_ep_addr(struct sctp_inpcb **,
629 struct sockaddr *, struct sctp_nets **, struct sockaddr *, struct sctp_tcb *);
631 struct sctp_tcb *sctp_findassociation_ep_asocid(struct sctp_inpcb *, caddr_t);
633 struct sctp_tcb *sctp_findassociation_ep_asconf(struct mbuf *, int, int,
634 struct sctphdr *, struct sctp_inpcb **, struct sctp_nets **);
636 int sctp_inpcb_alloc(struct socket *);
639 int sctp_is_address_on_local_host(struct sockaddr *addr);
641 void sctp_inpcb_free(struct sctp_inpcb *, int);
643 struct sctp_tcb *sctp_aloc_assoc(struct sctp_inpcb *, struct sockaddr *,
644 int, int *, uint32_t);
646 void sctp_free_assoc(struct sctp_inpcb *, struct sctp_tcb *);
648 int sctp_add_local_addr_ep(struct sctp_inpcb *, struct ifaddr *);
650 int sctp_insert_laddr(struct sctpladdr *, struct ifaddr *);
652 void sctp_remove_laddr(struct sctp_laddr *);
654 int sctp_del_local_addr_ep(struct sctp_inpcb *, struct ifaddr *);
656 int sctp_del_local_addr_ep_sa(struct sctp_inpcb *, struct sockaddr *);
658 int sctp_add_remote_addr(struct sctp_tcb *, struct sockaddr *, int, int);
660 int sctp_del_remote_addr(struct sctp_tcb *, struct sockaddr *);
662 void sctp_pcb_init(void);
664 void sctp_free_remote_addr(struct sctp_nets *);
666 int sctp_add_local_addr_assoc(struct sctp_tcb *, struct ifaddr *);
668 int sctp_del_local_addr_assoc(struct sctp_tcb *, struct ifaddr *);
670 int sctp_del_local_addr_assoc_sa(struct sctp_tcb *, struct sockaddr *);
672 int sctp_load_addresses_from_init(struct sctp_tcb *, struct mbuf *, int, int,
673 int, struct sctphdr *, struct sockaddr *);
675 int sctp_set_primary_addr(struct sctp_tcb *, struct sockaddr *, struct sctp_nets *);
677 int sctp_is_vtag_good(struct sctp_inpcb *, uint32_t, struct timeval *);
679 /*void sctp_drain(void);*/
681 int sctp_destination_is_reachable(struct sctp_tcb *, struct sockaddr *);
683 int sctp_add_to_socket_q(struct sctp_inpcb *, struct sctp_tcb *);
685 struct sctp_tcb *sctp_remove_from_socket_q(struct sctp_inpcb *);
688 /* Null in last arg inpcb indicate run on ALL ep's. Specific
689 * inp in last arg indicates run on ONLY assoc's of the
690 * specified endpoint.
693 sctp_initiate_iterator(asoc_func af, uint32_t, uint32_t, void *, uint32_t,
694 end_func ef, struct sctp_inpcb *);
696 #if defined(__APPLE__)
697 void sctp_callout_alloc(struct sctp_timer *);
698 void sctp_callout_free(struct callout *);
702 extern void in6_sin6_2_sin (struct sockaddr_in *,
703 struct sockaddr_in6 *sin6);
707 #endif /* !__sctp_pcb_h__ */