/*- * SPDX-License-Identifier: BSD-3-Clause * * Copyright (c) 2001-2007, by Cisco Systems, Inc. All rights reserved. * Copyright (c) 2008-2012, by Randall Stewart. All rights reserved. * Copyright (c) 2008-2012, by Michael Tuexen. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * a) Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * b) Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the distribution. * * c) Neither the name of Cisco Systems, Inc. nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE.
*/
struct sctp_ifn { struct sctp_ifalist ifalist; struct sctp_vrf *vrf;
LIST_ENTRY(sctp_ifn) next_ifn;
LIST_ENTRY(sctp_ifn) next_bucket; void *ifn_p; /* never access without appropriate lock */
uint32_t ifn_mtu;
uint32_t ifn_type;
uint32_t ifn_index; /* shorthand way to look at ifn for reference */
uint32_t refcount; /* number of reference held should be >= ifa_count */
uint32_t ifa_count; /* IFA's we hold (in our list - ifalist)*/
uint32_t num_v6; /* number of v6 addresses */
uint32_t num_v4; /* number of v4 addresses */
uint32_t registered_af; /* registered address family for i/f events */ char ifn_name[SCTP_IFNAMSIZ];
};
/* SCTP local IFA flags */ #define SCTP_ADDR_VALID 0x00000001 /* its up and active */ #define SCTP_BEING_DELETED 0x00000002 /* being deleted, * when refcount = 0. Note * that it is pulled from the ifn list * and ifa_p is nulled right away but * it cannot be freed until the last *net * pointing to it is deleted.
*/ #define SCTP_ADDR_DEFER_USE 0x00000004 /* Hold off using this one */ #define SCTP_ADDR_IFA_UNUSEABLE 0x00000008
struct sctp_ifa {
LIST_ENTRY(sctp_ifa) next_ifa;
LIST_ENTRY(sctp_ifa) next_bucket; struct sctp_ifn *ifn_p; /* back pointer to parent ifn */ void *ifa; /* pointer to ifa, needed for flag * update for that we MUST lock * appropriate locks. This is for V6.
*/ union sctp_sockstore address;
uint32_t refcount; /* number of folks referring to this */
uint32_t flags;
uint32_t localifa_flags;
uint32_t vrf_id; /* vrf_id of this addr (for deleting) */
uint8_t src_is_loop;
uint8_t src_is_priv;
uint8_t src_is_glob;
uint8_t resv;
};
struct sctp_laddr {
LIST_ENTRY(sctp_laddr) sctp_nxt_addr; /* next in list */ struct sctp_ifa *ifa;
uint32_t action; /* Used during asconf and adding * if no-zero src-addr selection will * not consider this address.
*/ struct timeval start_time; /* time when this address was created */
};
struct sctp_block_entry { int error;
};
struct sctp_timewait {
time_t tv_sec_at_expire; /* the seconds from boot to expire */
uint32_t v_tag; /* the vtag that can not be reused */
uint16_t lport; /* the local port used in vtag */
uint16_t rport; /* the remote port used in vtag */
};
/*- * The TCP model represents a substantial overhead in that we get an * additional hash table to keep explicit connections in. The * listening TCP endpoint will exist in the usual ephash above and * accept only INIT's. It will be incapable of sending off an INIT. * When a dg arrives we must look in the normal ephash. If we find a * TCP endpoint that will tell us to go to the specific endpoint * hash and re-hash to find the right assoc/socket. If we find a UDP * model socket we then must complete the lookup. If this fails, * i.e. no association can be found then we must continue to see if * a sctp_peeloff()'d socket is in the tcpephash (a spun off socket * acts like a TCP model connected socket).
*/ struct sctppcbhead *sctp_tcpephash;
u_long hashtcpmark;
uint32_t hashtblsize;
struct sctp_base_info { /* All static structures that * anchor the system must be here.
*/ struct sctp_epinfo sctppcbinfo; #ifdefined(__FreeBSD__) && !defined(__Userspace__) #ifdefined(SMP) && defined(SCTP_USE_PERCPU_STAT) struct sctpstat *sctpstat; #else struct sctpstat sctpstat; #endif #else struct sctpstat sctpstat; #endif struct sctp_sysctl sctpsysctl;
uint8_t first_time; char sctp_pcb_initialized; #ifdefined(SCTP_PACKET_LOGGING) int packet_log_writers; int packet_log_end;
uint8_t packet_log_buffer[SCTP_PACKET_LOG_SIZE]; #endif #ifdefined(__FreeBSD__) && !defined(__Userspace__)
eventhandler_tag eh_tag; #endif #ifdefined(__APPLE__) && !defined(__Userspace__) int sctp_main_timer_ticks; #endif #ifdefined(__Userspace__)
userland_mutex_t timer_mtx;
userland_thread_t timer_thread; int timer_thread_should_exit; int iterator_thread_started; int timer_thread_started; #if !defined(_WIN32)
pthread_mutexattr_t mtx_attr;
pthread_rwlockattr_t rwlock_attr; #ifdefined(INET) || defined(INET6) int userspace_route;
userland_thread_t recvthreadroute; #endif #endif #ifdef INET #ifdefined(_WIN32) && !defined(__MINGW32__)
SOCKET userspace_rawsctp;
SOCKET userspace_udpsctp; #else int userspace_rawsctp; int userspace_udpsctp; #endif
userland_thread_t recvthreadraw;
userland_thread_t recvthreadudp; #endif #ifdef INET6 #ifdefined(_WIN32) && !defined(__MINGW32__)
SOCKET userspace_rawsctp6;
SOCKET userspace_udpsctp6; #else int userspace_rawsctp6; int userspace_udpsctp6; #endif
userland_thread_t recvthreadraw6;
userland_thread_t recvthreadudp6; #endif int (*conn_output)(void *addr, void *buffer, size_t length, uint8_t tos, uint8_t set_df); void (*debug_printf)(constchar *format, ...); int crc32c_offloaded; #endif
};
/*- * Here we have all the relevant information for each SCTP entity created. We * will need to modify this as approprate. We also need to figure out how to * access /dev/random.
*/ struct sctp_pcb {
time_t time_of_secret_change; /* number of seconds from
* timeval.tv_sec */
uint32_t secret_key[SCTP_HOW_MANY_SECRETS][SCTP_NUMBER_OF_SECRETS]; unsignedint size_of_a_cookie;
/* various thresholds */ /* Max times I will init at a guy */
uint16_t max_init_times;
/* Max times I will send before we consider someone dead */
uint16_t max_send_times;
uint16_t def_net_failure;
uint16_t def_net_pf_threshold;
/* number of streams to pre-open on a association */
uint16_t pre_open_stream_count;
uint16_t max_open_streams_intome;
/* random number generator */
uint32_t random_counter;
uint8_t random_numbers[SCTP_SIGNATURE_ALOC_SIZE];
uint8_t random_store[SCTP_SIGNATURE_ALOC_SIZE];
/* * This timer is kept running per endpoint. When it fires it will * change the secret key. The default is once a hour
*/ struct sctp_timer signature_change;
struct sctp_pcbtsn_rlog {
uint32_t vtag;
uint16_t strm;
uint16_t seq;
uint16_t sz;
uint16_t flgs;
}; #define SCTP_READ_LOG_SIZE 135 /* we choose the number to make a pcb a page */
struct sctp_inpcb { /*- * put an inpcb in front of it all, kind of a waste but we need to * for compatibility with all the other stuff.
*/ union { struct inpcb inp; char align[(sizeof(struct inpcb) + SCTP_ALIGNM1) &
~SCTP_ALIGNM1];
} ip_inp; #ifdefined(__APPLE__) && !defined(__Userspace__) /* leave some space in case i386 inpcb is bigger than ppc */
uint8_t padding[128]; #endif
/* Socket buffer lock protects read_queue and of course sb_cc */ struct sctp_readhead read_queue;
LIST_ENTRY(sctp_inpcb) sctp_list; /* lists all endpoints */ /* hash of all endpoints for model */
LIST_ENTRY(sctp_inpcb) sctp_hash; /* count of local addresses bound, 0 if bound all */ int laddr_count;
/* list of addrs in use by the EP, NULL if bound-all */ struct sctpladdr sctp_addr_list; /* used for source address selection rotation when we are subset bound */ struct sctp_laddr *next_addr_touse;
/* back pointer to our socket */ struct socket *sctp_socket;
uint64_t sctp_features; /* Feature flags */
uint32_t sctp_flags; /* INP state flag set */
uint32_t sctp_mobility_features; /* Mobility Feature flags */ struct sctp_pcb sctp_ep;/* SCTP ep data */ /* head of the hash of all associations */ struct sctpasochead *sctp_tcbhash;
u_long sctp_hashmark; /* head of the list of all associations */ struct sctpasochead sctp_asoc_list; #ifdef SCTP_TRACK_FREED_ASOCS struct sctpasochead sctp_asoc_free_list; #endif
uint32_t sctp_frag_point;
uint32_t partial_delivery_point;
uint32_t sctp_context;
uint32_t max_cwnd;
uint8_t local_strreset_support;
uint32_t sctp_cmt_on_off;
uint8_t ecn_supported;
uint8_t prsctp_supported;
uint8_t auth_supported;
uint8_t idata_supported;
uint8_t asconf_supported;
uint8_t reconfig_supported;
uint8_t nrsack_supported;
uint8_t pktdrop_supported;
uint8_t rcv_edmid; struct sctp_nonpad_sndrcvinfo def_send; /*- * These three are here for the sosend_dgram * (pkt, pkt_last and control). * routine. However, I don't think anyone in * the current FreeBSD kernel calls this. So * they are candidates with sctp_sendm for * de-supporting.
*/ struct mbuf *pkt, *pkt_last; struct mbuf *control; #ifdefined(__FreeBSD__) && !defined(__Userspace__) struct mtx inp_mtx; struct mtx inp_create_mtx; struct mtx inp_rdata_mtx;
int32_t refcount; #elifdefined(SCTP_PROCESS_LEVEL_LOCKS)
userland_mutex_t inp_mtx;
userland_mutex_t inp_create_mtx;
userland_mutex_t inp_rdata_mtx;
int32_t refcount; #elifdefined(__APPLE__) && !defined(__Userspace__) #ifdefined(SCTP_APPLE_RWLOCK)
lck_rw_t *inp_mtx; #else
lck_mtx_t *inp_mtx; #endif
lck_mtx_t *inp_create_mtx;
lck_mtx_t *inp_rdata_mtx; #elifdefined(_WIN32) && !defined(__Userspace__) struct rwlock inp_lock; struct spinlock inp_create_lock; struct spinlock inp_rdata_lock;
int32_t refcount; #elifdefined(__Userspace__)
int32_t refcount; #endif #ifdefined(__APPLE__) && !defined(__Userspace__)
int32_t refcount;
#ifdefined(__Userspace__) int register_recv_cb (struct socket *, int (*)(struct socket *, union sctp_sockstore, void *, size_t, struct sctp_rcvinfo, int, void *)); int register_send_cb (struct socket *, uint32_t, int (*)(struct socket *, uint32_t, void *)); int register_ulp_info (struct socket *, void *); int retrieve_ulp_info (struct socket *, void **);
#endif struct sctp_tcb { struct socket *sctp_socket; /* back pointer to socket */ struct sctp_inpcb *sctp_ep; /* back pointer to ep */
LIST_ENTRY(sctp_tcb) sctp_tcbhash; /* next link in hash
* table */
LIST_ENTRY(sctp_tcb) sctp_tcblist; /* list of all of the
* TCB's */
LIST_ENTRY(sctp_tcb) sctp_tcbasocidhash; /* next link in asocid * hash table
*/
LIST_ENTRY(sctp_tcb) sctp_asocs; /* vtag hash list */ struct sctp_block_entry *block_entry; /* pointer locked by socket
* send buffer */ struct sctp_association asoc; /*- * freed_by_sorcv_sincelast is protected by the sockbuf_lock NOT the * tcb_lock. Its special in this way to help avoid extra mutex calls * in the reading of data.
*/
uint32_t freed_by_sorcv_sincelast;
uint32_t total_sends;
uint32_t total_recvs; int freed_from_where;
uint16_t rport; /* remote port in network format */
uint16_t resv; #ifdefined(__FreeBSD__) && !defined(__Userspace__) struct mtx tcb_mtx; #elifdefined(SCTP_PROCESS_LEVEL_LOCKS)
userland_mutex_t tcb_mtx; #elifdefined(__APPLE__) && !defined(__Userspace__)
lck_mtx_t* tcb_mtx; #elifdefined(_WIN32) && !defined(__Userspace__) struct spinlock tcb_lock; #elifdefined(__Userspace__) #endif #ifdefined(__APPLE__) && !defined(__Userspace__)
uint32_t caller1;
uint32_t caller2;
uint32_t caller3; #endif
};
#ifdefined(__FreeBSD__) && !defined(__Userspace__) #include <netinet/sctp_lock_bsd.h> #elifdefined(__APPLE__) && !defined(__Userspace__) /* * Apple MacOS X 10.4 "Tiger"
*/
/* Attention Julian, this is the extern that * goes with the base info. sctp_pcb.c has * the real definition.
*/ #ifdefined(__FreeBSD__) && !defined(__Userspace__)
VNET_DECLARE(struct sctp_base_info, system_base_info); #else externstruct sctp_base_info system_base_info; #endif
#ifdef INET6 int SCTP6_ARE_ADDR_EQUAL(struct sockaddr_in6 *a, struct sockaddr_in6 *b); #endif
/*- * Change address state, can be used if * O/S supports telling transports about * changes to IFA/IFN's (link layer triggers). * If a ifn goes down, we will do src-addr-selection * and NOT use that, as a source address. This does * not stop the routing system from routing out * that interface, but we won't put it as a source.
*/ void sctp_mark_ifa_addr_down(uint32_t vrf_id, struct sockaddr *addr, constchar *if_name, uint32_t ifn_index); void sctp_mark_ifa_addr_up(uint32_t vrf_id, struct sockaddr *addr, constchar *if_name, uint32_t ifn_index);
/*- * For this call ep_addr, the to is the destination endpoint address of the * peer (relative to outbound). The from field is only used if the TCP model * is enabled and helps distingush amongst the subset bound (non-boundall). * The TCP model MAY change the actual ep field, this is why it is passed.
*/ struct sctp_tcb *
sctp_findassociation_ep_addr(struct sctp_inpcb **, struct sockaddr *, struct sctp_nets **, struct sockaddr *, struct sctp_tcb *);
struct sctp_tcb *
sctp_findasoc_ep_asocid_locked(struct sctp_inpcb *inp, sctp_assoc_t asoc_id, int want_lock);
/*- * Null in last arg inpcb indicate run on ALL ep's. Specific inp in last arg * indicates run on ONLY assoc's of the specified endpoint.
*/ int
sctp_initiate_iterator(inp_func inpf,
asoc_func af,
inp_func inpe,
uint32_t, uint32_t,
uint32_t, void *,
uint32_t,
end_func ef, struct sctp_inpcb *,
uint8_t co_off); #ifdefined(__FreeBSD__) && !defined(__Userspace__) #ifdefined(SCTP_MCORE_INPUT) && defined(SMP) void
sctp_queue_to_mcore(struct mbuf *m, int off, int cpu_to_use);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.