Repo created
This commit is contained in:
parent
81b91f4139
commit
f8c34fa5ee
22732 changed files with 4815320 additions and 2 deletions
666
TMessagesProj/jni/third_party/usrsctplib/netinet/sctp.h
vendored
Executable file
666
TMessagesProj/jni/third_party/usrsctplib/netinet/sctp.h
vendored
Executable file
|
|
@ -0,0 +1,666 @@
|
|||
/*-
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*
|
||||
* Copyright (c) 2001-2008, 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.
|
||||
*/
|
||||
|
||||
#if defined(__FreeBSD__) && !defined(__Userspace__)
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD: head/sys/netinet/sctp.h 366750 2020-10-16 10:44:48Z tuexen $");
|
||||
#endif
|
||||
|
||||
#ifndef _NETINET_SCTP_H_
|
||||
#define _NETINET_SCTP_H_
|
||||
|
||||
#if defined(__APPLE__) || defined(__linux__)
|
||||
#include <stdint.h>
|
||||
#endif
|
||||
#include <sys/types.h>
|
||||
|
||||
#if !defined(_WIN32)
|
||||
#define SCTP_PACKED __attribute__((packed))
|
||||
#else
|
||||
#pragma pack (push, 1)
|
||||
#define SCTP_PACKED
|
||||
#endif
|
||||
|
||||
/*
|
||||
* SCTP protocol - RFC4960.
|
||||
*/
|
||||
struct sctphdr {
|
||||
uint16_t src_port; /* source port */
|
||||
uint16_t dest_port; /* destination port */
|
||||
uint32_t v_tag; /* verification tag of packet */
|
||||
uint32_t checksum; /* CRC32C checksum */
|
||||
/* chunks follow... */
|
||||
} SCTP_PACKED;
|
||||
|
||||
/*
|
||||
* SCTP Chunks
|
||||
*/
|
||||
struct sctp_chunkhdr {
|
||||
uint8_t chunk_type; /* chunk type */
|
||||
uint8_t chunk_flags; /* chunk flags */
|
||||
uint16_t chunk_length; /* chunk length */
|
||||
/* optional params follow */
|
||||
} SCTP_PACKED;
|
||||
|
||||
/*
|
||||
* SCTP chunk parameters
|
||||
*/
|
||||
struct sctp_paramhdr {
|
||||
uint16_t param_type; /* parameter type */
|
||||
uint16_t param_length; /* parameter length */
|
||||
} SCTP_PACKED;
|
||||
|
||||
/*
|
||||
* user socket options: socket API defined
|
||||
*/
|
||||
/*
|
||||
* read-write options
|
||||
*/
|
||||
#define SCTP_RTOINFO 0x00000001
|
||||
#define SCTP_ASSOCINFO 0x00000002
|
||||
#define SCTP_INITMSG 0x00000003
|
||||
#define SCTP_NODELAY 0x00000004
|
||||
#define SCTP_AUTOCLOSE 0x00000005
|
||||
#define SCTP_SET_PEER_PRIMARY_ADDR 0x00000006
|
||||
#define SCTP_PRIMARY_ADDR 0x00000007
|
||||
#define SCTP_ADAPTATION_LAYER 0x00000008
|
||||
/* same as above */
|
||||
#define SCTP_ADAPTION_LAYER 0x00000008
|
||||
#define SCTP_DISABLE_FRAGMENTS 0x00000009
|
||||
#define SCTP_PEER_ADDR_PARAMS 0x0000000a
|
||||
#define SCTP_DEFAULT_SEND_PARAM 0x0000000b
|
||||
/* ancillary data/notification interest options */
|
||||
#define SCTP_EVENTS 0x0000000c /* deprecated */
|
||||
/* Without this applied we will give V4 and V6 addresses on a V6 socket */
|
||||
#define SCTP_I_WANT_MAPPED_V4_ADDR 0x0000000d
|
||||
#define SCTP_MAXSEG 0x0000000e
|
||||
#define SCTP_DELAYED_SACK 0x0000000f
|
||||
#define SCTP_FRAGMENT_INTERLEAVE 0x00000010
|
||||
#define SCTP_PARTIAL_DELIVERY_POINT 0x00000011
|
||||
/* authentication support */
|
||||
#define SCTP_AUTH_CHUNK 0x00000012
|
||||
#define SCTP_AUTH_KEY 0x00000013
|
||||
#define SCTP_HMAC_IDENT 0x00000014
|
||||
#define SCTP_AUTH_ACTIVE_KEY 0x00000015
|
||||
#define SCTP_AUTH_DELETE_KEY 0x00000016
|
||||
#define SCTP_USE_EXT_RCVINFO 0x00000017
|
||||
#define SCTP_AUTO_ASCONF 0x00000018 /* rw */
|
||||
#define SCTP_MAXBURST 0x00000019 /* rw */
|
||||
#define SCTP_MAX_BURST 0x00000019 /* rw */
|
||||
/* assoc level context */
|
||||
#define SCTP_CONTEXT 0x0000001a /* rw */
|
||||
/* explicit EOR signalling */
|
||||
#define SCTP_EXPLICIT_EOR 0x0000001b
|
||||
#define SCTP_REUSE_PORT 0x0000001c /* rw */
|
||||
#define SCTP_AUTH_DEACTIVATE_KEY 0x0000001d
|
||||
#define SCTP_EVENT 0x0000001e
|
||||
#define SCTP_RECVRCVINFO 0x0000001f
|
||||
#define SCTP_RECVNXTINFO 0x00000020
|
||||
#define SCTP_DEFAULT_SNDINFO 0x00000021
|
||||
#define SCTP_DEFAULT_PRINFO 0x00000022
|
||||
#define SCTP_PEER_ADDR_THLDS 0x00000023
|
||||
#define SCTP_REMOTE_UDP_ENCAPS_PORT 0x00000024
|
||||
#define SCTP_ECN_SUPPORTED 0x00000025
|
||||
#define SCTP_PR_SUPPORTED 0x00000026
|
||||
#define SCTP_AUTH_SUPPORTED 0x00000027
|
||||
#define SCTP_ASCONF_SUPPORTED 0x00000028
|
||||
#define SCTP_RECONFIG_SUPPORTED 0x00000029
|
||||
#define SCTP_NRSACK_SUPPORTED 0x00000030
|
||||
#define SCTP_PKTDROP_SUPPORTED 0x00000031
|
||||
#define SCTP_MAX_CWND 0x00000032
|
||||
|
||||
/*
|
||||
* read-only options
|
||||
*/
|
||||
#define SCTP_STATUS 0x00000100
|
||||
#define SCTP_GET_PEER_ADDR_INFO 0x00000101
|
||||
/* authentication support */
|
||||
#define SCTP_PEER_AUTH_CHUNKS 0x00000102
|
||||
#define SCTP_LOCAL_AUTH_CHUNKS 0x00000103
|
||||
#define SCTP_GET_ASSOC_NUMBER 0x00000104 /* ro */
|
||||
#define SCTP_GET_ASSOC_ID_LIST 0x00000105 /* ro */
|
||||
#define SCTP_TIMEOUTS 0x00000106
|
||||
#define SCTP_PR_STREAM_STATUS 0x00000107
|
||||
#define SCTP_PR_ASSOC_STATUS 0x00000108
|
||||
|
||||
/*
|
||||
* user socket options: BSD implementation specific
|
||||
*/
|
||||
/*
|
||||
* Blocking I/O is enabled on any TCP type socket by default. For the UDP
|
||||
* model if this is turned on then the socket buffer is shared for send
|
||||
* resources amongst all associations. The default for the UDP model is that
|
||||
* is SS_NBIO is set. Which means all associations have a separate send
|
||||
* limit BUT they will NOT ever BLOCK instead you will get an error back
|
||||
* EAGAIN if you try to send too much. If you want the blocking semantics you
|
||||
* set this option at the cost of sharing one socket send buffer size amongst
|
||||
* all associations. Peeled off sockets turn this option off and block. But
|
||||
* since both TCP and peeled off sockets have only one assoc per socket this
|
||||
* is fine. It probably does NOT make sense to set this on SS_NBIO on a TCP
|
||||
* model OR peeled off UDP model, but we do allow you to do so. You just use
|
||||
* the normal syscall to toggle SS_NBIO the way you want.
|
||||
*
|
||||
* Blocking I/O is controlled by the SS_NBIO flag on the socket state so_state
|
||||
* field.
|
||||
*/
|
||||
|
||||
#define SCTP_ENABLE_STREAM_RESET 0x00000900 /* struct sctp_assoc_value */
|
||||
#define SCTP_RESET_STREAMS 0x00000901 /* struct sctp_reset_streams */
|
||||
#define SCTP_RESET_ASSOC 0x00000902 /* sctp_assoc_t */
|
||||
#define SCTP_ADD_STREAMS 0x00000903 /* struct sctp_add_streams */
|
||||
|
||||
/* For enable stream reset */
|
||||
#define SCTP_ENABLE_RESET_STREAM_REQ 0x00000001
|
||||
#define SCTP_ENABLE_RESET_ASSOC_REQ 0x00000002
|
||||
#define SCTP_ENABLE_CHANGE_ASSOC_REQ 0x00000004
|
||||
#define SCTP_ENABLE_VALUE_MASK 0x00000007
|
||||
/* For reset streams */
|
||||
#define SCTP_STREAM_RESET_INCOMING 0x00000001
|
||||
#define SCTP_STREAM_RESET_OUTGOING 0x00000002
|
||||
|
||||
/* here on down are more implementation specific */
|
||||
#define SCTP_SET_DEBUG_LEVEL 0x00001005
|
||||
#define SCTP_CLR_STAT_LOG 0x00001007
|
||||
/* CMT ON/OFF socket option */
|
||||
#define SCTP_CMT_ON_OFF 0x00001200
|
||||
#define SCTP_CMT_USE_DAC 0x00001201
|
||||
/* JRS - Pluggable Congestion Control Socket option */
|
||||
#define SCTP_PLUGGABLE_CC 0x00001202
|
||||
/* RS - Pluggable Stream Scheduling Socket option */
|
||||
#define SCTP_PLUGGABLE_SS 0x00001203
|
||||
#define SCTP_SS_VALUE 0x00001204
|
||||
#define SCTP_CC_OPTION 0x00001205 /* Options for CC modules */
|
||||
/* For I-DATA */
|
||||
#define SCTP_INTERLEAVING_SUPPORTED 0x00001206
|
||||
|
||||
/* read only */
|
||||
#define SCTP_GET_SNDBUF_USE 0x00001101
|
||||
#define SCTP_GET_STAT_LOG 0x00001103
|
||||
#define SCTP_PCB_STATUS 0x00001104
|
||||
#define SCTP_GET_NONCE_VALUES 0x00001105
|
||||
|
||||
/* Special hook for dynamically setting primary for all assoc's,
|
||||
* this is a write only option that requires root privilege.
|
||||
*/
|
||||
#define SCTP_SET_DYNAMIC_PRIMARY 0x00002001
|
||||
|
||||
/* VRF (virtual router feature) and multi-VRF support
|
||||
* options. VRF's provide splits within a router
|
||||
* that give the views of multiple routers. A
|
||||
* standard host, without VRF support, is just
|
||||
* a single VRF. If VRF's are supported then
|
||||
* the transport must be VRF aware. This means
|
||||
* that every socket call coming in must be directed
|
||||
* within the endpoint to one of the VRF's it belongs
|
||||
* to. The endpoint, before binding, may select
|
||||
* the "default" VRF it is in by using a set socket
|
||||
* option with SCTP_VRF_ID. This will also
|
||||
* get propagated to the default VRF. Once the
|
||||
* endpoint binds an address then it CANNOT add
|
||||
* additional VRF's to become a Multi-VRF endpoint.
|
||||
*
|
||||
* Before BINDING additional VRF's can be added with
|
||||
* the SCTP_ADD_VRF_ID call or deleted with
|
||||
* SCTP_DEL_VRF_ID.
|
||||
*
|
||||
* Associations are ALWAYS contained inside a single
|
||||
* VRF. They cannot reside in two (or more) VRF's. Incoming
|
||||
* packets, assuming the router is VRF aware, can always
|
||||
* tell us what VRF they arrived on. A host not supporting
|
||||
* any VRF's will find that the packets always arrived on the
|
||||
* single VRF that the host has.
|
||||
*
|
||||
*/
|
||||
|
||||
#define SCTP_VRF_ID 0x00003001
|
||||
#define SCTP_ADD_VRF_ID 0x00003002
|
||||
#define SCTP_GET_VRF_IDS 0x00003003
|
||||
#define SCTP_GET_ASOC_VRF 0x00003004
|
||||
#define SCTP_DEL_VRF_ID 0x00003005
|
||||
|
||||
/*
|
||||
* If you enable packet logging you can get
|
||||
* a poor mans ethereal output in binary
|
||||
* form. Note this is a compile option to
|
||||
* the kernel, SCTP_PACKET_LOGGING, and
|
||||
* without it in your kernel you
|
||||
* will get a EOPNOTSUPP
|
||||
*/
|
||||
#define SCTP_GET_PACKET_LOG 0x00004001
|
||||
|
||||
/*
|
||||
* hidden implementation specific options these are NOT user visible (should
|
||||
* move out of sctp.h)
|
||||
*/
|
||||
/* sctp_bindx() flags as hidden socket options */
|
||||
#define SCTP_BINDX_ADD_ADDR 0x00008001
|
||||
#define SCTP_BINDX_REM_ADDR 0x00008002
|
||||
/* Hidden socket option that gets the addresses */
|
||||
#define SCTP_GET_PEER_ADDRESSES 0x00008003
|
||||
#define SCTP_GET_LOCAL_ADDRESSES 0x00008004
|
||||
/* return the total count in bytes needed to hold all local addresses bound */
|
||||
#define SCTP_GET_LOCAL_ADDR_SIZE 0x00008005
|
||||
/* Return the total count in bytes needed to hold the remote address */
|
||||
#define SCTP_GET_REMOTE_ADDR_SIZE 0x00008006
|
||||
/* hidden option for connectx */
|
||||
#define SCTP_CONNECT_X 0x00008007
|
||||
/* hidden option for connectx_delayed, part of sendx */
|
||||
#define SCTP_CONNECT_X_DELAYED 0x00008008
|
||||
#define SCTP_CONNECT_X_COMPLETE 0x00008009
|
||||
/* hidden socket option based sctp_peeloff */
|
||||
#define SCTP_PEELOFF 0x0000800a
|
||||
/* the real worker for sctp_getaddrlen() */
|
||||
#define SCTP_GET_ADDR_LEN 0x0000800b
|
||||
#if defined(__APPLE__) && !defined(__Userspace__)
|
||||
/* temporary workaround for Apple listen() issue, no args used */
|
||||
#define SCTP_LISTEN_FIX 0x0000800c
|
||||
#endif
|
||||
#if defined(_WIN32) && !defined(__Userspace__)
|
||||
/* workaround for Cygwin on Windows: returns the SOCKET handle */
|
||||
#define SCTP_GET_HANDLE 0x0000800d
|
||||
#endif
|
||||
/* Debug things that need to be purged */
|
||||
#define SCTP_SET_INITIAL_DBG_SEQ 0x00009f00
|
||||
|
||||
/* JRS - Supported congestion control modules for pluggable
|
||||
* congestion control
|
||||
*/
|
||||
/* Standard TCP Congestion Control */
|
||||
#define SCTP_CC_RFC2581 0x00000000
|
||||
/* High Speed TCP Congestion Control (Floyd) */
|
||||
#define SCTP_CC_HSTCP 0x00000001
|
||||
/* HTCP Congestion Control */
|
||||
#define SCTP_CC_HTCP 0x00000002
|
||||
/* RTCC Congestion Control - RFC2581 plus */
|
||||
#define SCTP_CC_RTCC 0x00000003
|
||||
|
||||
#define SCTP_CC_OPT_RTCC_SETMODE 0x00002000
|
||||
#define SCTP_CC_OPT_USE_DCCC_ECN 0x00002001
|
||||
#define SCTP_CC_OPT_STEADY_STEP 0x00002002
|
||||
|
||||
#define SCTP_CMT_OFF 0
|
||||
#define SCTP_CMT_BASE 1
|
||||
#define SCTP_CMT_RPV1 2
|
||||
#define SCTP_CMT_RPV2 3
|
||||
#define SCTP_CMT_MPTCP 4
|
||||
#define SCTP_CMT_MAX SCTP_CMT_MPTCP
|
||||
|
||||
/* RS - Supported stream scheduling modules for pluggable
|
||||
* stream scheduling
|
||||
*/
|
||||
/* Default simple round-robin */
|
||||
#define SCTP_SS_DEFAULT 0x00000000
|
||||
/* Real round-robin */
|
||||
#define SCTP_SS_ROUND_ROBIN 0x00000001
|
||||
/* Real round-robin per packet */
|
||||
#define SCTP_SS_ROUND_ROBIN_PACKET 0x00000002
|
||||
/* Priority */
|
||||
#define SCTP_SS_PRIORITY 0x00000003
|
||||
/* Fair Bandwidth */
|
||||
#define SCTP_SS_FAIR_BANDWITH 0x00000004
|
||||
/* First-come, first-serve */
|
||||
#define SCTP_SS_FIRST_COME 0x00000005
|
||||
|
||||
/* fragment interleave constants
|
||||
* setting must be one of these or
|
||||
* EINVAL returned.
|
||||
*/
|
||||
#define SCTP_FRAG_LEVEL_0 0x00000000
|
||||
#define SCTP_FRAG_LEVEL_1 0x00000001
|
||||
#define SCTP_FRAG_LEVEL_2 0x00000002
|
||||
|
||||
/*
|
||||
* user state values
|
||||
*/
|
||||
#define SCTP_CLOSED 0x0000
|
||||
#define SCTP_BOUND 0x1000
|
||||
#define SCTP_LISTEN 0x2000
|
||||
#define SCTP_COOKIE_WAIT 0x0002
|
||||
#define SCTP_COOKIE_ECHOED 0x0004
|
||||
#define SCTP_ESTABLISHED 0x0008
|
||||
#define SCTP_SHUTDOWN_SENT 0x0010
|
||||
#define SCTP_SHUTDOWN_RECEIVED 0x0020
|
||||
#define SCTP_SHUTDOWN_ACK_SENT 0x0040
|
||||
#define SCTP_SHUTDOWN_PENDING 0x0080
|
||||
|
||||
/*
|
||||
* SCTP operational error codes (user visible)
|
||||
*/
|
||||
#define SCTP_CAUSE_NO_ERROR 0x0000
|
||||
#define SCTP_CAUSE_INVALID_STREAM 0x0001
|
||||
#define SCTP_CAUSE_MISSING_PARAM 0x0002
|
||||
#define SCTP_CAUSE_STALE_COOKIE 0x0003
|
||||
#define SCTP_CAUSE_OUT_OF_RESC 0x0004
|
||||
#define SCTP_CAUSE_UNRESOLVABLE_ADDR 0x0005
|
||||
#define SCTP_CAUSE_UNRECOG_CHUNK 0x0006
|
||||
#define SCTP_CAUSE_INVALID_PARAM 0x0007
|
||||
#define SCTP_CAUSE_UNRECOG_PARAM 0x0008
|
||||
#define SCTP_CAUSE_NO_USER_DATA 0x0009
|
||||
#define SCTP_CAUSE_COOKIE_IN_SHUTDOWN 0x000a
|
||||
#define SCTP_CAUSE_RESTART_W_NEWADDR 0x000b
|
||||
#define SCTP_CAUSE_USER_INITIATED_ABT 0x000c
|
||||
#define SCTP_CAUSE_PROTOCOL_VIOLATION 0x000d
|
||||
|
||||
/* Error causes from RFC5061 */
|
||||
#define SCTP_CAUSE_DELETING_LAST_ADDR 0x00a0
|
||||
#define SCTP_CAUSE_RESOURCE_SHORTAGE 0x00a1
|
||||
#define SCTP_CAUSE_DELETING_SRC_ADDR 0x00a2
|
||||
#define SCTP_CAUSE_ILLEGAL_ASCONF_ACK 0x00a3
|
||||
#define SCTP_CAUSE_REQUEST_REFUSED 0x00a4
|
||||
|
||||
/* Error causes from nat-draft */
|
||||
#define SCTP_CAUSE_NAT_COLLIDING_STATE 0x00b0
|
||||
#define SCTP_CAUSE_NAT_MISSING_STATE 0x00b1
|
||||
|
||||
/* Error causes from RFC4895 */
|
||||
#define SCTP_CAUSE_UNSUPPORTED_HMACID 0x0105
|
||||
|
||||
/*
|
||||
* error cause parameters (user visible)
|
||||
*/
|
||||
struct sctp_gen_error_cause {
|
||||
uint16_t code;
|
||||
uint16_t length;
|
||||
uint8_t info[];
|
||||
} SCTP_PACKED;
|
||||
|
||||
struct sctp_error_cause {
|
||||
uint16_t code;
|
||||
uint16_t length;
|
||||
/* optional cause-specific info may follow */
|
||||
} SCTP_PACKED;
|
||||
|
||||
struct sctp_error_invalid_stream {
|
||||
struct sctp_error_cause cause; /* code=SCTP_CAUSE_INVALID_STREAM */
|
||||
uint16_t stream_id; /* stream id of the DATA in error */
|
||||
uint16_t reserved;
|
||||
} SCTP_PACKED;
|
||||
|
||||
struct sctp_error_missing_param {
|
||||
struct sctp_error_cause cause; /* code=SCTP_CAUSE_MISSING_PARAM */
|
||||
uint32_t num_missing_params; /* number of missing parameters */
|
||||
uint16_t type[];
|
||||
} SCTP_PACKED;
|
||||
|
||||
struct sctp_error_stale_cookie {
|
||||
struct sctp_error_cause cause; /* code=SCTP_CAUSE_STALE_COOKIE */
|
||||
uint32_t stale_time; /* time in usec of staleness */
|
||||
} SCTP_PACKED;
|
||||
|
||||
struct sctp_error_out_of_resource {
|
||||
struct sctp_error_cause cause; /* code=SCTP_CAUSE_OUT_OF_RESOURCES */
|
||||
} SCTP_PACKED;
|
||||
|
||||
struct sctp_error_unresolv_addr {
|
||||
struct sctp_error_cause cause; /* code=SCTP_CAUSE_UNRESOLVABLE_ADDR */
|
||||
} SCTP_PACKED;
|
||||
|
||||
struct sctp_error_unrecognized_chunk {
|
||||
struct sctp_error_cause cause; /* code=SCTP_CAUSE_UNRECOG_CHUNK */
|
||||
struct sctp_chunkhdr ch;/* header from chunk in error */
|
||||
} SCTP_PACKED;
|
||||
|
||||
struct sctp_error_no_user_data {
|
||||
struct sctp_error_cause cause; /* code=SCTP_CAUSE_NO_USER_DATA */
|
||||
uint32_t tsn; /* TSN of the empty data chunk */
|
||||
} SCTP_PACKED;
|
||||
|
||||
struct sctp_error_auth_invalid_hmac {
|
||||
struct sctp_error_cause cause; /* code=SCTP_CAUSE_UNSUPPORTED_HMACID */
|
||||
uint16_t hmac_id;
|
||||
} SCTP_PACKED;
|
||||
|
||||
/*
|
||||
* Main SCTP chunk types we place these here so natd and f/w's in user land
|
||||
* can find them.
|
||||
*/
|
||||
/************0x00 series ***********/
|
||||
#define SCTP_DATA 0x00
|
||||
#define SCTP_INITIATION 0x01
|
||||
#define SCTP_INITIATION_ACK 0x02
|
||||
#define SCTP_SELECTIVE_ACK 0x03
|
||||
#define SCTP_HEARTBEAT_REQUEST 0x04
|
||||
#define SCTP_HEARTBEAT_ACK 0x05
|
||||
#define SCTP_ABORT_ASSOCIATION 0x06
|
||||
#define SCTP_SHUTDOWN 0x07
|
||||
#define SCTP_SHUTDOWN_ACK 0x08
|
||||
#define SCTP_OPERATION_ERROR 0x09
|
||||
#define SCTP_COOKIE_ECHO 0x0a
|
||||
#define SCTP_COOKIE_ACK 0x0b
|
||||
#define SCTP_ECN_ECHO 0x0c
|
||||
#define SCTP_ECN_CWR 0x0d
|
||||
#define SCTP_SHUTDOWN_COMPLETE 0x0e
|
||||
/* RFC4895 */
|
||||
#define SCTP_AUTHENTICATION 0x0f
|
||||
/* EY nr_sack chunk id*/
|
||||
#define SCTP_NR_SELECTIVE_ACK 0x10
|
||||
/************0x40 series ***********/
|
||||
#define SCTP_IDATA 0x40
|
||||
/************0x80 series ***********/
|
||||
/* RFC5061 */
|
||||
#define SCTP_ASCONF_ACK 0x80
|
||||
/* draft-ietf-stewart-pktdrpsctp */
|
||||
#define SCTP_PACKET_DROPPED 0x81
|
||||
/* draft-ietf-stewart-strreset-xxx */
|
||||
#define SCTP_STREAM_RESET 0x82
|
||||
|
||||
/* RFC4820 */
|
||||
#define SCTP_PAD_CHUNK 0x84
|
||||
/************0xc0 series ***********/
|
||||
/* RFC3758 */
|
||||
#define SCTP_FORWARD_CUM_TSN 0xc0
|
||||
/* RFC5061 */
|
||||
#define SCTP_ASCONF 0xc1
|
||||
#define SCTP_IFORWARD_CUM_TSN 0xc2
|
||||
|
||||
/* ABORT and SHUTDOWN COMPLETE FLAG */
|
||||
#define SCTP_HAD_NO_TCB 0x01
|
||||
|
||||
/* Packet dropped flags */
|
||||
#define SCTP_FROM_MIDDLE_BOX SCTP_HAD_NO_TCB
|
||||
#define SCTP_BADCRC 0x02
|
||||
#define SCTP_PACKET_TRUNCATED 0x04
|
||||
|
||||
/* Flag for ECN -CWR */
|
||||
#define SCTP_CWR_REDUCE_OVERRIDE 0x01
|
||||
#define SCTP_CWR_IN_SAME_WINDOW 0x02
|
||||
|
||||
#define SCTP_SAT_NETWORK_MIN 400 /* min ms for RTT to set satellite
|
||||
* time */
|
||||
#define SCTP_SAT_NETWORK_BURST_INCR 2 /* how many times to multiply maxburst
|
||||
* in sat */
|
||||
|
||||
/* Data Chuck Specific Flags */
|
||||
#define SCTP_DATA_FRAG_MASK 0x03
|
||||
#define SCTP_DATA_MIDDLE_FRAG 0x00
|
||||
#define SCTP_DATA_LAST_FRAG 0x01
|
||||
#define SCTP_DATA_FIRST_FRAG 0x02
|
||||
#define SCTP_DATA_NOT_FRAG 0x03
|
||||
#define SCTP_DATA_UNORDERED 0x04
|
||||
#define SCTP_DATA_SACK_IMMEDIATELY 0x08
|
||||
/* ECN Nonce: SACK Chunk Specific Flags */
|
||||
#define SCTP_SACK_NONCE_SUM 0x01
|
||||
|
||||
/* CMT DAC algorithm SACK flag */
|
||||
#define SCTP_SACK_CMT_DAC 0x80
|
||||
|
||||
/*
|
||||
* PCB flags (in sctp_flags bitmask).
|
||||
* Note the features and flags are meant
|
||||
* for use by netstat.
|
||||
*/
|
||||
#define SCTP_PCB_FLAGS_UDPTYPE 0x00000001
|
||||
#define SCTP_PCB_FLAGS_TCPTYPE 0x00000002
|
||||
#define SCTP_PCB_FLAGS_BOUNDALL 0x00000004
|
||||
#define SCTP_PCB_FLAGS_ACCEPTING 0x00000008
|
||||
#define SCTP_PCB_FLAGS_UNBOUND 0x00000010
|
||||
#define SCTP_PCB_FLAGS_SND_ITERATOR_UP 0x00000020
|
||||
#define SCTP_PCB_FLAGS_CLOSE_IP 0x00040000
|
||||
#define SCTP_PCB_FLAGS_WAS_CONNECTED 0x00080000
|
||||
#define SCTP_PCB_FLAGS_WAS_ABORTED 0x00100000
|
||||
/* TCP model support */
|
||||
|
||||
#define SCTP_PCB_FLAGS_CONNECTED 0x00200000
|
||||
#define SCTP_PCB_FLAGS_IN_TCPPOOL 0x00400000
|
||||
#define SCTP_PCB_FLAGS_DONT_WAKE 0x00800000
|
||||
#define SCTP_PCB_FLAGS_WAKEOUTPUT 0x01000000
|
||||
#define SCTP_PCB_FLAGS_WAKEINPUT 0x02000000
|
||||
#define SCTP_PCB_FLAGS_BOUND_V6 0x04000000
|
||||
#define SCTP_PCB_FLAGS_BLOCKING_IO 0x08000000
|
||||
#define SCTP_PCB_FLAGS_SOCKET_GONE 0x10000000
|
||||
#define SCTP_PCB_FLAGS_SOCKET_ALLGONE 0x20000000
|
||||
#define SCTP_PCB_FLAGS_SOCKET_CANT_READ 0x40000000
|
||||
#if defined(__Userspace__)
|
||||
#define SCTP_PCB_FLAGS_BOUND_CONN 0x80000000
|
||||
|
||||
/* flags to copy to new PCB */
|
||||
#define SCTP_PCB_COPY_FLAGS (SCTP_PCB_FLAGS_BOUNDALL|\
|
||||
SCTP_PCB_FLAGS_WAKEINPUT|\
|
||||
SCTP_PCB_FLAGS_BOUND_V6|\
|
||||
SCTP_PCB_FLAGS_BOUND_CONN)
|
||||
#else
|
||||
|
||||
/* flags to copy to new PCB */
|
||||
#define SCTP_PCB_COPY_FLAGS (SCTP_PCB_FLAGS_BOUNDALL|\
|
||||
SCTP_PCB_FLAGS_WAKEINPUT|\
|
||||
SCTP_PCB_FLAGS_BOUND_V6)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* PCB Features (in sctp_features bitmask)
|
||||
*/
|
||||
#define SCTP_PCB_FLAGS_DO_NOT_PMTUD 0x0000000000000001
|
||||
#define SCTP_PCB_FLAGS_EXT_RCVINFO 0x0000000000000002 /* deprecated */
|
||||
#define SCTP_PCB_FLAGS_DONOT_HEARTBEAT 0x0000000000000004
|
||||
#define SCTP_PCB_FLAGS_FRAG_INTERLEAVE 0x0000000000000008
|
||||
#define SCTP_PCB_FLAGS_INTERLEAVE_STRMS 0x0000000000000010
|
||||
#define SCTP_PCB_FLAGS_DO_ASCONF 0x0000000000000020
|
||||
#define SCTP_PCB_FLAGS_AUTO_ASCONF 0x0000000000000040
|
||||
/* socket options */
|
||||
#define SCTP_PCB_FLAGS_NODELAY 0x0000000000000100
|
||||
#define SCTP_PCB_FLAGS_AUTOCLOSE 0x0000000000000200
|
||||
#define SCTP_PCB_FLAGS_RECVDATAIOEVNT 0x0000000000000400 /* deprecated */
|
||||
#define SCTP_PCB_FLAGS_RECVASSOCEVNT 0x0000000000000800
|
||||
#define SCTP_PCB_FLAGS_RECVPADDREVNT 0x0000000000001000
|
||||
#define SCTP_PCB_FLAGS_RECVPEERERR 0x0000000000002000
|
||||
#define SCTP_PCB_FLAGS_RECVSENDFAILEVNT 0x0000000000004000 /* deprecated */
|
||||
#define SCTP_PCB_FLAGS_RECVSHUTDOWNEVNT 0x0000000000008000
|
||||
#define SCTP_PCB_FLAGS_ADAPTATIONEVNT 0x0000000000010000
|
||||
#define SCTP_PCB_FLAGS_PDAPIEVNT 0x0000000000020000
|
||||
#define SCTP_PCB_FLAGS_AUTHEVNT 0x0000000000040000
|
||||
#define SCTP_PCB_FLAGS_STREAM_RESETEVNT 0x0000000000080000
|
||||
#define SCTP_PCB_FLAGS_NO_FRAGMENT 0x0000000000100000
|
||||
#define SCTP_PCB_FLAGS_EXPLICIT_EOR 0x0000000000400000
|
||||
#define SCTP_PCB_FLAGS_NEEDS_MAPPED_V4 0x0000000000800000
|
||||
#define SCTP_PCB_FLAGS_MULTIPLE_ASCONFS 0x0000000001000000
|
||||
#define SCTP_PCB_FLAGS_PORTREUSE 0x0000000002000000
|
||||
#define SCTP_PCB_FLAGS_DRYEVNT 0x0000000004000000
|
||||
#define SCTP_PCB_FLAGS_RECVRCVINFO 0x0000000008000000
|
||||
#define SCTP_PCB_FLAGS_RECVNXTINFO 0x0000000010000000
|
||||
#define SCTP_PCB_FLAGS_ASSOC_RESETEVNT 0x0000000020000000
|
||||
#define SCTP_PCB_FLAGS_STREAM_CHANGEEVNT 0x0000000040000000
|
||||
#define SCTP_PCB_FLAGS_RECVNSENDFAILEVNT 0x0000000080000000
|
||||
|
||||
/*-
|
||||
* mobility_features parameters (by micchie).Note
|
||||
* these features are applied against the
|
||||
* sctp_mobility_features flags.. not the sctp_features
|
||||
* flags.
|
||||
*/
|
||||
#define SCTP_MOBILITY_BASE 0x00000001
|
||||
#define SCTP_MOBILITY_FASTHANDOFF 0x00000002
|
||||
#define SCTP_MOBILITY_PRIM_DELETED 0x00000004
|
||||
|
||||
/* Smallest PMTU allowed when disabling PMTU discovery */
|
||||
#define SCTP_SMALLEST_PMTU 512
|
||||
/* Largest PMTU allowed when disabling PMTU discovery */
|
||||
#define SCTP_LARGEST_PMTU 65536
|
||||
|
||||
#if defined(_WIN32)
|
||||
#pragma pack(pop)
|
||||
#endif
|
||||
#undef SCTP_PACKED
|
||||
|
||||
#include <netinet/sctp_uio.h>
|
||||
|
||||
/* This dictates the size of the packet
|
||||
* collection buffer. This only applies
|
||||
* if SCTP_PACKET_LOGGING is enabled in
|
||||
* your config.
|
||||
*/
|
||||
#define SCTP_PACKET_LOG_SIZE 65536
|
||||
|
||||
/* Maximum delays and such a user can set for options that
|
||||
* take ms.
|
||||
*/
|
||||
#define SCTP_MAX_SACK_DELAY 500 /* per RFC4960 */
|
||||
#define SCTP_MAX_HB_INTERVAL 14400000 /* 4 hours in ms */
|
||||
#define SCTP_MIN_COOKIE_LIFE 1000 /* 1 second in ms */
|
||||
#define SCTP_MAX_COOKIE_LIFE 3600000 /* 1 hour in ms */
|
||||
|
||||
/* Types of logging/KTR tracing that can be enabled via the
|
||||
* sysctl net.inet.sctp.sctp_logging. You must also enable
|
||||
* SUBSYS tracing.
|
||||
* Note that you must have the SCTP option in the kernel
|
||||
* to enable these as well.
|
||||
*/
|
||||
#define SCTP_BLK_LOGGING_ENABLE 0x00000001
|
||||
#define SCTP_CWND_MONITOR_ENABLE 0x00000002
|
||||
#define SCTP_CWND_LOGGING_ENABLE 0x00000004
|
||||
#define SCTP_FLIGHT_LOGGING_ENABLE 0x00000020
|
||||
#define SCTP_FR_LOGGING_ENABLE 0x00000040
|
||||
#define SCTP_LOCK_LOGGING_ENABLE 0x00000080
|
||||
#define SCTP_MAP_LOGGING_ENABLE 0x00000100
|
||||
#define SCTP_MBCNT_LOGGING_ENABLE 0x00000200
|
||||
#define SCTP_MBUF_LOGGING_ENABLE 0x00000400
|
||||
#define SCTP_NAGLE_LOGGING_ENABLE 0x00000800
|
||||
#define SCTP_RECV_RWND_LOGGING_ENABLE 0x00001000
|
||||
#define SCTP_RTTVAR_LOGGING_ENABLE 0x00002000
|
||||
#define SCTP_SACK_LOGGING_ENABLE 0x00004000
|
||||
#define SCTP_SACK_RWND_LOGGING_ENABLE 0x00008000
|
||||
#define SCTP_SB_LOGGING_ENABLE 0x00010000
|
||||
#define SCTP_STR_LOGGING_ENABLE 0x00020000
|
||||
#define SCTP_WAKE_LOGGING_ENABLE 0x00040000
|
||||
#define SCTP_LOG_MAXBURST_ENABLE 0x00080000
|
||||
#define SCTP_LOG_RWND_ENABLE 0x00100000
|
||||
#define SCTP_LOG_SACK_ARRIVALS_ENABLE 0x00200000
|
||||
#define SCTP_LTRACE_CHUNK_ENABLE 0x00400000
|
||||
#define SCTP_LTRACE_ERROR_ENABLE 0x00800000
|
||||
#define SCTP_LAST_PACKET_TRACING 0x01000000
|
||||
#define SCTP_THRESHOLD_LOGGING 0x02000000
|
||||
#define SCTP_LOG_AT_SEND_2_SCTP 0x04000000
|
||||
#define SCTP_LOG_AT_SEND_2_OUTQ 0x08000000
|
||||
#define SCTP_LOG_TRY_ADVANCE 0x10000000
|
||||
|
||||
#endif /* !_NETINET_SCTP_H_ */
|
||||
3517
TMessagesProj/jni/third_party/usrsctplib/netinet/sctp_asconf.c
vendored
Executable file
3517
TMessagesProj/jni/third_party/usrsctplib/netinet/sctp_asconf.c
vendored
Executable file
File diff suppressed because it is too large
Load diff
94
TMessagesProj/jni/third_party/usrsctplib/netinet/sctp_asconf.h
vendored
Executable file
94
TMessagesProj/jni/third_party/usrsctplib/netinet/sctp_asconf.h
vendored
Executable file
|
|
@ -0,0 +1,94 @@
|
|||
/*-
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#if defined(__FreeBSD__) && !defined(__Userspace__)
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD: head/sys/netinet/sctp_asconf.h 365071 2020-09-01 21:19:14Z mjg $");
|
||||
#endif
|
||||
|
||||
#ifndef _NETINET_SCTP_ASCONF_H_
|
||||
#define _NETINET_SCTP_ASCONF_H_
|
||||
|
||||
#if defined(_KERNEL) || defined(__Userspace__)
|
||||
|
||||
/*
|
||||
* function prototypes
|
||||
*/
|
||||
extern void sctp_asconf_cleanup(struct sctp_tcb *);
|
||||
|
||||
extern struct mbuf *sctp_compose_asconf(struct sctp_tcb *, int *, int);
|
||||
|
||||
extern void
|
||||
sctp_handle_asconf(struct mbuf *, unsigned int, struct sockaddr *,
|
||||
struct sctp_asconf_chunk *, struct sctp_tcb *, int);
|
||||
|
||||
extern void
|
||||
sctp_handle_asconf_ack(struct mbuf *, int, struct sctp_asconf_ack_chunk *,
|
||||
struct sctp_tcb *, struct sctp_nets *, int *);
|
||||
|
||||
extern uint32_t
|
||||
sctp_addr_mgmt_ep_sa(struct sctp_inpcb *, struct sockaddr *, uint32_t,
|
||||
uint32_t);
|
||||
|
||||
extern int sctp_asconf_iterator_ep(struct sctp_inpcb *inp, void *ptr,
|
||||
uint32_t val);
|
||||
extern void sctp_asconf_iterator_stcb(struct sctp_inpcb *inp,
|
||||
struct sctp_tcb *stcb,
|
||||
void *ptr, uint32_t type);
|
||||
extern void sctp_asconf_iterator_end(void *ptr, uint32_t val);
|
||||
|
||||
extern int32_t
|
||||
sctp_set_primary_ip_address_sa(struct sctp_tcb *,
|
||||
struct sockaddr *);
|
||||
|
||||
extern void
|
||||
sctp_check_address_list(struct sctp_tcb *, struct mbuf *, int, int,
|
||||
struct sockaddr *, uint16_t, uint16_t, uint16_t, uint16_t);
|
||||
|
||||
extern void
|
||||
sctp_assoc_immediate_retrans(struct sctp_tcb *, struct sctp_nets *);
|
||||
#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__Userspace__)
|
||||
extern void
|
||||
sctp_net_immediate_retrans(struct sctp_tcb *, struct sctp_nets *);
|
||||
#endif
|
||||
|
||||
extern void
|
||||
sctp_asconf_send_nat_state_update(struct sctp_tcb *stcb,
|
||||
struct sctp_nets *net);
|
||||
|
||||
extern int
|
||||
sctp_is_addr_pending(struct sctp_tcb *, struct sctp_ifa *);
|
||||
#endif /* _KERNEL */
|
||||
|
||||
#endif /* !_NETINET_SCTP_ASCONF_H_ */
|
||||
2302
TMessagesProj/jni/third_party/usrsctplib/netinet/sctp_auth.c
vendored
Executable file
2302
TMessagesProj/jni/third_party/usrsctplib/netinet/sctp_auth.c
vendored
Executable file
File diff suppressed because it is too large
Load diff
213
TMessagesProj/jni/third_party/usrsctplib/netinet/sctp_auth.h
vendored
Executable file
213
TMessagesProj/jni/third_party/usrsctplib/netinet/sctp_auth.h
vendored
Executable file
|
|
@ -0,0 +1,213 @@
|
|||
/*-
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*
|
||||
* Copyright (c) 2001-2008, 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.
|
||||
*/
|
||||
|
||||
#if defined(__FreeBSD__) && !defined(__Userspace__)
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD: head/sys/netinet/sctp_auth.h 365071 2020-09-01 21:19:14Z mjg $");
|
||||
#endif
|
||||
|
||||
#ifndef _NETINET_SCTP_AUTH_H_
|
||||
#define _NETINET_SCTP_AUTH_H_
|
||||
|
||||
#include <netinet/sctp_os.h>
|
||||
|
||||
/* digest lengths */
|
||||
#define SCTP_AUTH_DIGEST_LEN_SHA1 20
|
||||
#define SCTP_AUTH_DIGEST_LEN_SHA256 32
|
||||
#define SCTP_AUTH_DIGEST_LEN_MAX SCTP_AUTH_DIGEST_LEN_SHA256
|
||||
|
||||
/* random sizes */
|
||||
#define SCTP_AUTH_RANDOM_SIZE_DEFAULT 32
|
||||
#define SCTP_AUTH_RANDOM_SIZE_REQUIRED 32
|
||||
|
||||
/* union of all supported HMAC algorithm contexts */
|
||||
typedef union sctp_hash_context {
|
||||
SCTP_SHA1_CTX sha1;
|
||||
#if defined(SCTP_SUPPORT_HMAC_SHA256)
|
||||
SCTP_SHA256_CTX sha256;
|
||||
#endif
|
||||
} sctp_hash_context_t;
|
||||
|
||||
typedef struct sctp_key {
|
||||
uint32_t keylen;
|
||||
uint8_t key[];
|
||||
} sctp_key_t;
|
||||
|
||||
typedef struct sctp_shared_key {
|
||||
LIST_ENTRY(sctp_shared_key) next;
|
||||
sctp_key_t *key; /* key text */
|
||||
uint32_t refcount; /* reference count */
|
||||
uint16_t keyid; /* shared key ID */
|
||||
uint8_t deactivated; /* key is deactivated */
|
||||
} sctp_sharedkey_t;
|
||||
|
||||
LIST_HEAD(sctp_keyhead, sctp_shared_key);
|
||||
|
||||
/* authentication chunks list */
|
||||
typedef struct sctp_auth_chklist {
|
||||
uint8_t chunks[256];
|
||||
uint8_t num_chunks;
|
||||
} sctp_auth_chklist_t;
|
||||
|
||||
/* hmac algos supported list */
|
||||
typedef struct sctp_hmaclist {
|
||||
uint16_t max_algo; /* max algorithms allocated */
|
||||
uint16_t num_algo; /* num algorithms used */
|
||||
uint16_t hmac[];
|
||||
} sctp_hmaclist_t;
|
||||
|
||||
/* authentication info */
|
||||
typedef struct sctp_authinformation {
|
||||
sctp_key_t *random; /* local random key (concatenated) */
|
||||
uint32_t random_len; /* local random number length for param */
|
||||
sctp_key_t *peer_random;/* peer's random key (concatenated) */
|
||||
sctp_key_t *assoc_key; /* cached concatenated send key */
|
||||
sctp_key_t *recv_key; /* cached concatenated recv key */
|
||||
uint16_t active_keyid; /* active send keyid */
|
||||
uint16_t assoc_keyid; /* current send keyid (cached) */
|
||||
uint16_t recv_keyid; /* last recv keyid (cached) */
|
||||
} sctp_authinfo_t;
|
||||
|
||||
/*
|
||||
* Macros
|
||||
*/
|
||||
#define sctp_auth_is_required_chunk(chunk, list) ((list == NULL) ? (0) : (list->chunks[chunk] != 0))
|
||||
|
||||
/*
|
||||
* function prototypes
|
||||
*/
|
||||
|
||||
/* socket option api functions */
|
||||
extern sctp_auth_chklist_t *sctp_alloc_chunklist(void);
|
||||
extern void sctp_free_chunklist(sctp_auth_chklist_t *chklist);
|
||||
extern void sctp_clear_chunklist(sctp_auth_chklist_t *chklist);
|
||||
extern sctp_auth_chklist_t *sctp_copy_chunklist(sctp_auth_chklist_t *chklist);
|
||||
extern int sctp_auth_add_chunk(uint8_t chunk, sctp_auth_chklist_t *list);
|
||||
extern int sctp_auth_delete_chunk(uint8_t chunk, sctp_auth_chklist_t *list);
|
||||
extern size_t sctp_auth_get_chklist_size(const sctp_auth_chklist_t *list);
|
||||
extern int sctp_serialize_auth_chunks(const sctp_auth_chklist_t *list,
|
||||
uint8_t *ptr);
|
||||
extern int sctp_pack_auth_chunks(const sctp_auth_chklist_t *list,
|
||||
uint8_t *ptr);
|
||||
extern int sctp_unpack_auth_chunks(const uint8_t *ptr, uint8_t num_chunks,
|
||||
sctp_auth_chklist_t *list);
|
||||
|
||||
/* key handling */
|
||||
extern sctp_key_t *sctp_alloc_key(uint32_t keylen);
|
||||
extern void sctp_free_key(sctp_key_t *key);
|
||||
extern void sctp_print_key(sctp_key_t *key, const char *str);
|
||||
extern void sctp_show_key(sctp_key_t *key, const char *str);
|
||||
extern sctp_key_t *sctp_generate_random_key(uint32_t keylen);
|
||||
extern sctp_key_t *sctp_set_key(uint8_t *key, uint32_t keylen);
|
||||
extern sctp_key_t *sctp_compute_hashkey(sctp_key_t *key1, sctp_key_t *key2,
|
||||
sctp_key_t *shared);
|
||||
|
||||
/* shared key handling */
|
||||
extern sctp_sharedkey_t *sctp_alloc_sharedkey(void);
|
||||
extern void sctp_free_sharedkey(sctp_sharedkey_t *skey);
|
||||
extern sctp_sharedkey_t *sctp_find_sharedkey(struct sctp_keyhead *shared_keys,
|
||||
uint16_t key_id);
|
||||
extern int sctp_insert_sharedkey(struct sctp_keyhead *shared_keys,
|
||||
sctp_sharedkey_t *new_skey);
|
||||
extern int sctp_copy_skeylist(const struct sctp_keyhead *src,
|
||||
struct sctp_keyhead *dest);
|
||||
/* ref counts on shared keys, by key id */
|
||||
extern void sctp_auth_key_acquire(struct sctp_tcb *stcb, uint16_t keyid);
|
||||
extern void sctp_auth_key_release(struct sctp_tcb *stcb, uint16_t keyid,
|
||||
int so_locked);
|
||||
|
||||
/* hmac list handling */
|
||||
extern sctp_hmaclist_t *sctp_alloc_hmaclist(uint16_t num_hmacs);
|
||||
extern void sctp_free_hmaclist(sctp_hmaclist_t *list);
|
||||
extern int sctp_auth_add_hmacid(sctp_hmaclist_t *list, uint16_t hmac_id);
|
||||
extern sctp_hmaclist_t *sctp_copy_hmaclist(sctp_hmaclist_t *list);
|
||||
extern sctp_hmaclist_t *sctp_default_supported_hmaclist(void);
|
||||
extern uint16_t sctp_negotiate_hmacid(sctp_hmaclist_t *peer,
|
||||
sctp_hmaclist_t *local);
|
||||
extern int sctp_serialize_hmaclist(sctp_hmaclist_t *list, uint8_t *ptr);
|
||||
extern int sctp_verify_hmac_param(struct sctp_auth_hmac_algo *hmacs,
|
||||
uint32_t num_hmacs);
|
||||
|
||||
extern sctp_authinfo_t *sctp_alloc_authinfo(void);
|
||||
extern void sctp_free_authinfo(sctp_authinfo_t *authinfo);
|
||||
|
||||
/* keyed-HMAC functions */
|
||||
extern uint32_t sctp_get_auth_chunk_len(uint16_t hmac_algo);
|
||||
extern uint32_t sctp_get_hmac_digest_len(uint16_t hmac_algo);
|
||||
extern uint32_t sctp_hmac(uint16_t hmac_algo, uint8_t *key, uint32_t keylen,
|
||||
uint8_t *text, uint32_t textlen, uint8_t *digest);
|
||||
extern uint32_t sctp_compute_hmac(uint16_t hmac_algo, sctp_key_t *key,
|
||||
uint8_t *text, uint32_t textlen, uint8_t *digest);
|
||||
extern int sctp_auth_is_supported_hmac(sctp_hmaclist_t *list, uint16_t id);
|
||||
|
||||
/* mbuf versions */
|
||||
extern uint32_t sctp_hmac_m(uint16_t hmac_algo, uint8_t *key, uint32_t keylen,
|
||||
struct mbuf *m, uint32_t m_offset, uint8_t *digest, uint32_t trailer);
|
||||
extern uint32_t sctp_compute_hmac_m(uint16_t hmac_algo, sctp_key_t *key,
|
||||
struct mbuf *m, uint32_t m_offset, uint8_t *digest);
|
||||
|
||||
/*
|
||||
* authentication routines
|
||||
*/
|
||||
extern void sctp_clear_cachedkeys(struct sctp_tcb *stcb, uint16_t keyid);
|
||||
extern void sctp_clear_cachedkeys_ep(struct sctp_inpcb *inp, uint16_t keyid);
|
||||
extern int sctp_delete_sharedkey(struct sctp_tcb *stcb, uint16_t keyid);
|
||||
extern int sctp_delete_sharedkey_ep(struct sctp_inpcb *inp, uint16_t keyid);
|
||||
extern int sctp_auth_setactivekey(struct sctp_tcb *stcb, uint16_t keyid);
|
||||
extern int sctp_auth_setactivekey_ep(struct sctp_inpcb *inp, uint16_t keyid);
|
||||
extern int sctp_deact_sharedkey(struct sctp_tcb *stcb, uint16_t keyid);
|
||||
extern int sctp_deact_sharedkey_ep(struct sctp_inpcb *inp, uint16_t keyid);
|
||||
|
||||
extern void sctp_auth_get_cookie_params(struct sctp_tcb *stcb, struct mbuf *m,
|
||||
uint32_t offset, uint32_t length);
|
||||
extern void sctp_fill_hmac_digest_m(struct mbuf *m, uint32_t auth_offset,
|
||||
struct sctp_auth_chunk *auth, struct sctp_tcb *stcb, uint16_t key_id);
|
||||
extern struct mbuf *sctp_add_auth_chunk(struct mbuf *m, struct mbuf **m_end,
|
||||
struct sctp_auth_chunk **auth_ret, uint32_t *offset,
|
||||
struct sctp_tcb *stcb, uint8_t chunk);
|
||||
extern int sctp_handle_auth(struct sctp_tcb *stcb, struct sctp_auth_chunk *ch,
|
||||
struct mbuf *m, uint32_t offset);
|
||||
extern void sctp_notify_authentication(struct sctp_tcb *stcb,
|
||||
uint32_t indication, uint16_t keyid, uint16_t alt_keyid, int so_locked);
|
||||
extern int sctp_validate_init_auth_params(struct mbuf *m, int offset,
|
||||
int limit);
|
||||
extern void sctp_initialize_auth_params(struct sctp_inpcb *inp,
|
||||
struct sctp_tcb *stcb);
|
||||
|
||||
/* test functions */
|
||||
#ifdef SCTP_HMAC_TEST
|
||||
extern void sctp_test_hmac_sha1(void);
|
||||
extern void sctp_test_authkey(void);
|
||||
#endif
|
||||
#endif /* __SCTP_AUTH_H__ */
|
||||
990
TMessagesProj/jni/third_party/usrsctplib/netinet/sctp_bsd_addr.c
vendored
Executable file
990
TMessagesProj/jni/third_party/usrsctplib/netinet/sctp_bsd_addr.c
vendored
Executable file
|
|
@ -0,0 +1,990 @@
|
|||
/*-
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#if defined(__FreeBSD__) && !defined(__Userspace__)
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD: head/sys/netinet/sctp_bsd_addr.c 366426 2020-10-04 15:37:34Z tuexen $");
|
||||
#endif
|
||||
|
||||
#include <netinet/sctp_os.h>
|
||||
#include <netinet/sctp_var.h>
|
||||
#include <netinet/sctp_pcb.h>
|
||||
#include <netinet/sctp_header.h>
|
||||
#include <netinet/sctputil.h>
|
||||
#include <netinet/sctp_output.h>
|
||||
#include <netinet/sctp_bsd_addr.h>
|
||||
#include <netinet/sctp_uio.h>
|
||||
#include <netinet/sctputil.h>
|
||||
#include <netinet/sctp_timer.h>
|
||||
#include <netinet/sctp_asconf.h>
|
||||
#include <netinet/sctp_sysctl.h>
|
||||
#include <netinet/sctp_indata.h>
|
||||
#if defined(__FreeBSD__) && !defined(__Userspace__)
|
||||
#include <sys/unistd.h>
|
||||
#endif
|
||||
|
||||
/* Declare all of our malloc named types */
|
||||
MALLOC_DEFINE(SCTP_M_MAP, "sctp_map", "sctp asoc map descriptor");
|
||||
MALLOC_DEFINE(SCTP_M_STRMI, "sctp_stri", "sctp stream in array");
|
||||
MALLOC_DEFINE(SCTP_M_STRMO, "sctp_stro", "sctp stream out array");
|
||||
MALLOC_DEFINE(SCTP_M_ASC_ADDR, "sctp_aadr", "sctp asconf address");
|
||||
MALLOC_DEFINE(SCTP_M_ASC_IT, "sctp_a_it", "sctp asconf iterator");
|
||||
MALLOC_DEFINE(SCTP_M_AUTH_CL, "sctp_atcl", "sctp auth chunklist");
|
||||
MALLOC_DEFINE(SCTP_M_AUTH_KY, "sctp_atky", "sctp auth key");
|
||||
MALLOC_DEFINE(SCTP_M_AUTH_HL, "sctp_athm", "sctp auth hmac list");
|
||||
MALLOC_DEFINE(SCTP_M_AUTH_IF, "sctp_athi", "sctp auth info");
|
||||
MALLOC_DEFINE(SCTP_M_STRESET, "sctp_stre", "sctp stream reset");
|
||||
MALLOC_DEFINE(SCTP_M_CMSG, "sctp_cmsg", "sctp CMSG buffer");
|
||||
MALLOC_DEFINE(SCTP_M_COPYAL, "sctp_cpal", "sctp copy all");
|
||||
MALLOC_DEFINE(SCTP_M_VRF, "sctp_vrf", "sctp vrf struct");
|
||||
MALLOC_DEFINE(SCTP_M_IFA, "sctp_ifa", "sctp ifa struct");
|
||||
MALLOC_DEFINE(SCTP_M_IFN, "sctp_ifn", "sctp ifn struct");
|
||||
MALLOC_DEFINE(SCTP_M_TIMW, "sctp_timw", "sctp time block");
|
||||
MALLOC_DEFINE(SCTP_M_MVRF, "sctp_mvrf", "sctp mvrf pcb list");
|
||||
MALLOC_DEFINE(SCTP_M_ITER, "sctp_iter", "sctp iterator control");
|
||||
MALLOC_DEFINE(SCTP_M_SOCKOPT, "sctp_socko", "sctp socket option");
|
||||
MALLOC_DEFINE(SCTP_M_MCORE, "sctp_mcore", "sctp mcore queue");
|
||||
|
||||
/* Global NON-VNET structure that controls the iterator */
|
||||
struct iterator_control sctp_it_ctl;
|
||||
#if !(defined(__FreeBSD__) && !defined(__Userspace__))
|
||||
|
||||
static void
|
||||
sctp_cleanup_itqueue(void)
|
||||
{
|
||||
struct sctp_iterator *it, *nit;
|
||||
|
||||
TAILQ_FOREACH_SAFE(it, &sctp_it_ctl.iteratorhead, sctp_nxt_itr, nit) {
|
||||
if (it->function_atend != NULL) {
|
||||
(*it->function_atend) (it->pointer, it->val);
|
||||
}
|
||||
TAILQ_REMOVE(&sctp_it_ctl.iteratorhead, it, sctp_nxt_itr);
|
||||
SCTP_FREE(it, SCTP_M_ITER);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#if defined(__Userspace__)
|
||||
/*__Userspace__ TODO if we use thread based iterator
|
||||
* then the implementation of wakeup will need to change.
|
||||
* Currently we are using timeo_cond for ident so_timeo
|
||||
* but that is not sufficient if we need to use another ident
|
||||
* like wakeup(&sctppcbinfo.iterator_running);
|
||||
*/
|
||||
#endif
|
||||
|
||||
void
|
||||
sctp_wakeup_iterator(void)
|
||||
{
|
||||
#if defined(SCTP_PROCESS_LEVEL_LOCKS)
|
||||
#if defined(_WIN32)
|
||||
WakeAllConditionVariable(&sctp_it_ctl.iterator_wakeup);
|
||||
#else
|
||||
pthread_cond_broadcast(&sctp_it_ctl.iterator_wakeup);
|
||||
#endif
|
||||
#else
|
||||
wakeup(&sctp_it_ctl.iterator_running);
|
||||
#endif
|
||||
}
|
||||
|
||||
#if defined(__Userspace__)
|
||||
static void *
|
||||
#else
|
||||
static void
|
||||
#endif
|
||||
sctp_iterator_thread(void *v SCTP_UNUSED)
|
||||
{
|
||||
#if defined(__Userspace__)
|
||||
sctp_userspace_set_threadname("SCTP iterator");
|
||||
#endif
|
||||
SCTP_IPI_ITERATOR_WQ_LOCK();
|
||||
/* In FreeBSD this thread never terminates. */
|
||||
#if defined(__FreeBSD__) && !defined(__Userspace__)
|
||||
for (;;) {
|
||||
#else
|
||||
while ((sctp_it_ctl.iterator_flags & SCTP_ITERATOR_MUST_EXIT) == 0) {
|
||||
#endif
|
||||
#if !defined(__Userspace__)
|
||||
msleep(&sctp_it_ctl.iterator_running,
|
||||
#if defined(__FreeBSD__)
|
||||
&sctp_it_ctl.ipi_iterator_wq_mtx,
|
||||
#elif defined(__APPLE__)
|
||||
sctp_it_ctl.ipi_iterator_wq_mtx,
|
||||
#endif
|
||||
0, "waiting_for_work", 0);
|
||||
#else
|
||||
#if defined(_WIN32)
|
||||
SleepConditionVariableCS(&sctp_it_ctl.iterator_wakeup, &sctp_it_ctl.ipi_iterator_wq_mtx, INFINITE);
|
||||
#else
|
||||
pthread_cond_wait(&sctp_it_ctl.iterator_wakeup, &sctp_it_ctl.ipi_iterator_wq_mtx);
|
||||
#endif
|
||||
#endif
|
||||
#if !(defined(__FreeBSD__) && !defined(__Userspace__))
|
||||
if (sctp_it_ctl.iterator_flags & SCTP_ITERATOR_MUST_EXIT) {
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
sctp_iterator_worker();
|
||||
}
|
||||
#if !(defined(__FreeBSD__) && !defined(__Userspace__))
|
||||
/* Now this thread needs to be terminated */
|
||||
sctp_cleanup_itqueue();
|
||||
sctp_it_ctl.iterator_flags |= SCTP_ITERATOR_EXITED;
|
||||
SCTP_IPI_ITERATOR_WQ_UNLOCK();
|
||||
#if defined(__Userspace__)
|
||||
sctp_wakeup_iterator();
|
||||
return (NULL);
|
||||
#else
|
||||
wakeup(&sctp_it_ctl.iterator_flags);
|
||||
thread_terminate(current_thread());
|
||||
#ifdef INVARIANTS
|
||||
panic("Hmm. thread_terminate() continues...");
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
sctp_startup_iterator(void)
|
||||
{
|
||||
if (sctp_it_ctl.thread_proc) {
|
||||
/* You only get one */
|
||||
return;
|
||||
}
|
||||
/* Initialize global locks here, thus only once. */
|
||||
SCTP_ITERATOR_LOCK_INIT();
|
||||
SCTP_IPI_ITERATOR_WQ_INIT();
|
||||
TAILQ_INIT(&sctp_it_ctl.iteratorhead);
|
||||
#if defined(__Userspace__)
|
||||
if (sctp_userspace_thread_create(&sctp_it_ctl.thread_proc, &sctp_iterator_thread)) {
|
||||
SCTP_PRINTF("ERROR: Creating sctp_iterator_thread failed.\n");
|
||||
} else {
|
||||
SCTP_BASE_VAR(iterator_thread_started) = 1;
|
||||
}
|
||||
#elif defined(__FreeBSD__)
|
||||
kproc_create(sctp_iterator_thread,
|
||||
(void *)NULL,
|
||||
&sctp_it_ctl.thread_proc,
|
||||
0,
|
||||
SCTP_KTHREAD_PAGES,
|
||||
SCTP_KTRHEAD_NAME);
|
||||
#elif defined(__APPLE__)
|
||||
kernel_thread_start((thread_continue_t)sctp_iterator_thread, NULL, &sctp_it_ctl.thread_proc);
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef INET6
|
||||
|
||||
#if defined(__Userspace__)
|
||||
/* __Userspace__ TODO. struct in6_ifaddr is defined in sys/netinet6/in6_var.h
|
||||
ip6_use_deprecated is defined as int ip6_use_deprecated = 1; in /src/sys/netinet6/in6_proto.c
|
||||
*/
|
||||
void
|
||||
sctp_gather_internal_ifa_flags(struct sctp_ifa *ifa)
|
||||
{
|
||||
return; /* stub */
|
||||
}
|
||||
#else
|
||||
void
|
||||
sctp_gather_internal_ifa_flags(struct sctp_ifa *ifa)
|
||||
{
|
||||
struct in6_ifaddr *ifa6;
|
||||
|
||||
ifa6 = (struct in6_ifaddr *)ifa->ifa;
|
||||
ifa->flags = ifa6->ia6_flags;
|
||||
if (!MODULE_GLOBAL(ip6_use_deprecated)) {
|
||||
if (ifa->flags &
|
||||
IN6_IFF_DEPRECATED) {
|
||||
ifa->localifa_flags |= SCTP_ADDR_IFA_UNUSEABLE;
|
||||
} else {
|
||||
ifa->localifa_flags &= ~SCTP_ADDR_IFA_UNUSEABLE;
|
||||
}
|
||||
} else {
|
||||
ifa->localifa_flags &= ~SCTP_ADDR_IFA_UNUSEABLE;
|
||||
}
|
||||
if (ifa->flags &
|
||||
(IN6_IFF_DETACHED |
|
||||
IN6_IFF_ANYCAST |
|
||||
IN6_IFF_NOTREADY)) {
|
||||
ifa->localifa_flags |= SCTP_ADDR_IFA_UNUSEABLE;
|
||||
} else {
|
||||
ifa->localifa_flags &= ~SCTP_ADDR_IFA_UNUSEABLE;
|
||||
}
|
||||
}
|
||||
#endif /* __Userspace__ */
|
||||
#endif /* INET6 */
|
||||
|
||||
#if !defined(__Userspace__)
|
||||
static uint32_t
|
||||
sctp_is_desired_interface_type(struct ifnet *ifn)
|
||||
{
|
||||
int result;
|
||||
|
||||
/* check the interface type to see if it's one we care about */
|
||||
#if defined(__APPLE__) && !defined(__Userspace__)
|
||||
switch(ifnet_type(ifn)) {
|
||||
#else
|
||||
switch (ifn->if_type) {
|
||||
#endif
|
||||
case IFT_ETHER:
|
||||
case IFT_ISO88023:
|
||||
case IFT_ISO88024:
|
||||
case IFT_ISO88025:
|
||||
case IFT_ISO88026:
|
||||
case IFT_STARLAN:
|
||||
case IFT_P10:
|
||||
case IFT_P80:
|
||||
case IFT_HY:
|
||||
case IFT_FDDI:
|
||||
case IFT_XETHER:
|
||||
case IFT_ISDNBASIC:
|
||||
case IFT_ISDNPRIMARY:
|
||||
case IFT_PTPSERIAL:
|
||||
case IFT_OTHER:
|
||||
case IFT_PPP:
|
||||
case IFT_LOOP:
|
||||
case IFT_SLIP:
|
||||
case IFT_GIF:
|
||||
case IFT_L2VLAN:
|
||||
case IFT_STF:
|
||||
#if !(defined(__APPLE__) && !defined(__Userspace__))
|
||||
case IFT_IP:
|
||||
case IFT_IPOVERCDLC:
|
||||
case IFT_IPOVERCLAW:
|
||||
case IFT_PROPVIRTUAL: /* NetGraph Virtual too */
|
||||
case IFT_VIRTUALIPADDRESS:
|
||||
#endif
|
||||
result = 1;
|
||||
break;
|
||||
default:
|
||||
result = 0;
|
||||
}
|
||||
|
||||
return (result);
|
||||
}
|
||||
#endif
|
||||
#if defined(__APPLE__) && !defined(__Userspace__)
|
||||
|
||||
int
|
||||
sctp_is_vmware_interface(struct ifnet *ifn)
|
||||
{
|
||||
return (strncmp(ifnet_name(ifn), "vmnet", 5) == 0);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(_WIN32) && defined(__Userspace__)
|
||||
#ifdef MALLOC
|
||||
#undef MALLOC
|
||||
#define MALLOC(x) HeapAlloc(GetProcessHeap(), 0, (x))
|
||||
#endif
|
||||
#ifdef FREE
|
||||
#undef FREE
|
||||
#define FREE(x) HeapFree(GetProcessHeap(), 0, (x))
|
||||
#endif
|
||||
static void
|
||||
sctp_init_ifns_for_vrf(int vrfid)
|
||||
{
|
||||
#if defined(INET) || defined(INET6)
|
||||
struct sctp_ifa *sctp_ifa;
|
||||
DWORD Err, AdapterAddrsSize;
|
||||
PIP_ADAPTER_ADDRESSES pAdapterAddrs, pAdapt;
|
||||
PIP_ADAPTER_UNICAST_ADDRESS pUnicast;
|
||||
#endif
|
||||
|
||||
#ifdef INET
|
||||
AdapterAddrsSize = 0;
|
||||
|
||||
if ((Err = GetAdaptersAddresses(AF_INET, 0, NULL, NULL, &AdapterAddrsSize)) != 0) {
|
||||
if ((Err != ERROR_BUFFER_OVERFLOW) && (Err != ERROR_INSUFFICIENT_BUFFER)) {
|
||||
SCTP_PRINTF("GetAdaptersV4Addresses() sizing failed with error code %d\n", Err);
|
||||
SCTP_PRINTF("err = %d; AdapterAddrsSize = %d\n", Err, AdapterAddrsSize);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/* Allocate memory from sizing information */
|
||||
if ((pAdapterAddrs = (PIP_ADAPTER_ADDRESSES) GlobalAlloc(GPTR, AdapterAddrsSize)) == NULL) {
|
||||
SCTP_PRINTF("Memory allocation error!\n");
|
||||
return;
|
||||
}
|
||||
/* Get actual adapter information */
|
||||
if ((Err = GetAdaptersAddresses(AF_INET, 0, NULL, pAdapterAddrs, &AdapterAddrsSize)) != ERROR_SUCCESS) {
|
||||
SCTP_PRINTF("GetAdaptersV4Addresses() failed with error code %d\n", Err);
|
||||
FREE(pAdapterAddrs);
|
||||
return;
|
||||
}
|
||||
/* Enumerate through each returned adapter and save its information */
|
||||
for (pAdapt = pAdapterAddrs; pAdapt; pAdapt = pAdapt->Next) {
|
||||
if (pAdapt->IfType == IF_TYPE_IEEE80211 || pAdapt->IfType == IF_TYPE_ETHERNET_CSMACD) {
|
||||
for (pUnicast = pAdapt->FirstUnicastAddress; pUnicast; pUnicast = pUnicast->Next) {
|
||||
if (IN4_ISLINKLOCAL_ADDRESS(&(((struct sockaddr_in *)(pUnicast->Address.lpSockaddr))->sin_addr))) {
|
||||
continue;
|
||||
}
|
||||
sctp_ifa = sctp_add_addr_to_vrf(0,
|
||||
NULL,
|
||||
pAdapt->IfIndex,
|
||||
(pAdapt->IfType == IF_TYPE_IEEE80211)?MIB_IF_TYPE_ETHERNET:pAdapt->IfType,
|
||||
pAdapt->AdapterName,
|
||||
NULL,
|
||||
pUnicast->Address.lpSockaddr,
|
||||
pAdapt->Flags,
|
||||
0);
|
||||
if (sctp_ifa) {
|
||||
sctp_ifa->localifa_flags &= ~SCTP_ADDR_DEFER_USE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
FREE(pAdapterAddrs);
|
||||
#endif
|
||||
#ifdef INET6
|
||||
AdapterAddrsSize = 0;
|
||||
|
||||
if ((Err = GetAdaptersAddresses(AF_INET6, 0, NULL, NULL, &AdapterAddrsSize)) != 0) {
|
||||
if ((Err != ERROR_BUFFER_OVERFLOW) && (Err != ERROR_INSUFFICIENT_BUFFER)) {
|
||||
SCTP_PRINTF("GetAdaptersV6Addresses() sizing failed with error code %d\n", Err);
|
||||
SCTP_PRINTF("err = %d; AdapterAddrsSize = %d\n", Err, AdapterAddrsSize);
|
||||
return;
|
||||
}
|
||||
}
|
||||
/* Allocate memory from sizing information */
|
||||
if ((pAdapterAddrs = (PIP_ADAPTER_ADDRESSES) GlobalAlloc(GPTR, AdapterAddrsSize)) == NULL) {
|
||||
SCTP_PRINTF("Memory allocation error!\n");
|
||||
return;
|
||||
}
|
||||
/* Get actual adapter information */
|
||||
if ((Err = GetAdaptersAddresses(AF_INET6, 0, NULL, pAdapterAddrs, &AdapterAddrsSize)) != ERROR_SUCCESS) {
|
||||
SCTP_PRINTF("GetAdaptersV6Addresses() failed with error code %d\n", Err);
|
||||
FREE(pAdapterAddrs);
|
||||
return;
|
||||
}
|
||||
/* Enumerate through each returned adapter and save its information */
|
||||
for (pAdapt = pAdapterAddrs; pAdapt; pAdapt = pAdapt->Next) {
|
||||
if (pAdapt->IfType == IF_TYPE_IEEE80211 || pAdapt->IfType == IF_TYPE_ETHERNET_CSMACD) {
|
||||
for (pUnicast = pAdapt->FirstUnicastAddress; pUnicast; pUnicast = pUnicast->Next) {
|
||||
sctp_ifa = sctp_add_addr_to_vrf(0,
|
||||
NULL,
|
||||
pAdapt->Ipv6IfIndex,
|
||||
(pAdapt->IfType == IF_TYPE_IEEE80211)?MIB_IF_TYPE_ETHERNET:pAdapt->IfType,
|
||||
pAdapt->AdapterName,
|
||||
NULL,
|
||||
pUnicast->Address.lpSockaddr,
|
||||
pAdapt->Flags,
|
||||
0);
|
||||
if (sctp_ifa) {
|
||||
sctp_ifa->localifa_flags &= ~SCTP_ADDR_DEFER_USE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
FREE(pAdapterAddrs);
|
||||
#endif
|
||||
}
|
||||
#elif defined(__Userspace__)
|
||||
static void
|
||||
sctp_init_ifns_for_vrf(int vrfid)
|
||||
{
|
||||
#if defined(INET) || defined(INET6)
|
||||
int rc;
|
||||
struct ifaddrs *ifa, *ifas;
|
||||
struct sctp_ifa *sctp_ifa;
|
||||
uint32_t ifa_flags;
|
||||
|
||||
rc = getifaddrs(&ifas);
|
||||
if (rc != 0) {
|
||||
return;
|
||||
}
|
||||
for (ifa = ifas; ifa; ifa = ifa->ifa_next) {
|
||||
if (ifa->ifa_addr == NULL) {
|
||||
continue;
|
||||
}
|
||||
#if !defined(INET)
|
||||
if (ifa->ifa_addr->sa_family != AF_INET6) {
|
||||
/* non inet6 skip */
|
||||
continue;
|
||||
}
|
||||
#elif !defined(INET6)
|
||||
if (ifa->ifa_addr->sa_family != AF_INET) {
|
||||
/* non inet skip */
|
||||
continue;
|
||||
}
|
||||
#else
|
||||
if ((ifa->ifa_addr->sa_family != AF_INET) && (ifa->ifa_addr->sa_family != AF_INET6)) {
|
||||
/* non inet/inet6 skip */
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
#if defined(INET6)
|
||||
if ((ifa->ifa_addr->sa_family == AF_INET6) &&
|
||||
IN6_IS_ADDR_UNSPECIFIED(&((struct sockaddr_in6 *)ifa->ifa_addr)->sin6_addr)) {
|
||||
/* skip unspecifed addresses */
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
#if defined(INET)
|
||||
if (ifa->ifa_addr->sa_family == AF_INET &&
|
||||
((struct sockaddr_in *)ifa->ifa_addr)->sin_addr.s_addr == 0) {
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
ifa_flags = 0;
|
||||
sctp_ifa = sctp_add_addr_to_vrf(vrfid,
|
||||
NULL,
|
||||
if_nametoindex(ifa->ifa_name),
|
||||
0,
|
||||
ifa->ifa_name,
|
||||
NULL,
|
||||
ifa->ifa_addr,
|
||||
ifa_flags,
|
||||
0);
|
||||
if (sctp_ifa) {
|
||||
sctp_ifa->localifa_flags &= ~SCTP_ADDR_DEFER_USE;
|
||||
}
|
||||
}
|
||||
freeifaddrs(ifas);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
#if defined(__APPLE__) && !defined(__Userspace__)
|
||||
static void
|
||||
sctp_init_ifns_for_vrf(int vrfid)
|
||||
{
|
||||
/* Here we must apply ANY locks needed by the
|
||||
* IFN we access and also make sure we lock
|
||||
* any IFA that exists as we float through the
|
||||
* list of IFA's
|
||||
*/
|
||||
struct ifnet **ifnetlist;
|
||||
uint32_t i, j, count;
|
||||
char name[SCTP_IFNAMSIZ];
|
||||
struct ifnet *ifn;
|
||||
struct ifaddr **ifaddrlist;
|
||||
struct ifaddr *ifa;
|
||||
struct in6_ifaddr *ifa6;
|
||||
struct sctp_ifa *sctp_ifa;
|
||||
uint32_t ifa_flags;
|
||||
|
||||
if (ifnet_list_get(IFNET_FAMILY_ANY, &ifnetlist, &count) != 0) {
|
||||
return;
|
||||
}
|
||||
for (i = 0; i < count; i++) {
|
||||
ifn = ifnetlist[i];
|
||||
if (SCTP_BASE_SYSCTL(sctp_ignore_vmware_interfaces) && sctp_is_vmware_interface(ifn)) {
|
||||
continue;
|
||||
}
|
||||
if (sctp_is_desired_interface_type(ifn) == 0) {
|
||||
/* non desired type */
|
||||
continue;
|
||||
}
|
||||
if (ifnet_get_address_list(ifn, &ifaddrlist) != 0) {
|
||||
continue;
|
||||
}
|
||||
for (j = 0; ifaddrlist[j] != NULL; j++) {
|
||||
ifa = ifaddrlist[j];
|
||||
if (ifa->ifa_addr == NULL) {
|
||||
continue;
|
||||
}
|
||||
if ((ifa->ifa_addr->sa_family != AF_INET) && (ifa->ifa_addr->sa_family != AF_INET6)) {
|
||||
/* non inet/inet6 skip */
|
||||
continue;
|
||||
}
|
||||
if (ifa->ifa_addr->sa_family == AF_INET6) {
|
||||
if (IN6_IS_ADDR_UNSPECIFIED(&((struct sockaddr_in6 *)ifa->ifa_addr)->sin6_addr)) {
|
||||
/* skip unspecifed addresses */
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
if (((struct sockaddr_in *)ifa->ifa_addr)->sin_addr.s_addr == INADDR_ANY) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (ifa->ifa_addr->sa_family == AF_INET6) {
|
||||
ifa6 = (struct in6_ifaddr *)ifa;
|
||||
ifa_flags = ifa6->ia6_flags;
|
||||
} else {
|
||||
ifa_flags = 0;
|
||||
}
|
||||
SCTP_SNPRINTF(name, SCTP_IFNAMSIZ, "%s%d", ifnet_name(ifn), ifnet_unit(ifn));
|
||||
sctp_ifa = sctp_add_addr_to_vrf(vrfid,
|
||||
(void *)ifn, /* XXX */
|
||||
ifnet_index(ifn),
|
||||
ifnet_type(ifn),
|
||||
name,
|
||||
(void *)ifa, /* XXX */
|
||||
ifa->ifa_addr,
|
||||
ifa_flags,
|
||||
0);
|
||||
if (sctp_ifa) {
|
||||
sctp_ifa->localifa_flags &= ~SCTP_ADDR_DEFER_USE;
|
||||
}
|
||||
}
|
||||
ifnet_free_address_list(ifaddrlist);
|
||||
}
|
||||
ifnet_list_free(ifnetlist);
|
||||
}
|
||||
#endif
|
||||
#if defined(__FreeBSD__) && !defined(__Userspace__)
|
||||
static void
|
||||
sctp_init_ifns_for_vrf(int vrfid)
|
||||
{
|
||||
/* Here we must apply ANY locks needed by the
|
||||
* IFN we access and also make sure we lock
|
||||
* any IFA that exists as we float through the
|
||||
* list of IFA's
|
||||
*/
|
||||
struct epoch_tracker et;
|
||||
struct ifnet *ifn;
|
||||
struct ifaddr *ifa;
|
||||
struct sctp_ifa *sctp_ifa;
|
||||
uint32_t ifa_flags;
|
||||
#ifdef INET6
|
||||
struct in6_ifaddr *ifa6;
|
||||
#endif
|
||||
|
||||
IFNET_RLOCK();
|
||||
NET_EPOCH_ENTER(et);
|
||||
CK_STAILQ_FOREACH(ifn, &MODULE_GLOBAL(ifnet), if_link) {
|
||||
if (sctp_is_desired_interface_type(ifn) == 0) {
|
||||
/* non desired type */
|
||||
continue;
|
||||
}
|
||||
CK_STAILQ_FOREACH(ifa, &ifn->if_addrhead, ifa_link) {
|
||||
if (ifa->ifa_addr == NULL) {
|
||||
continue;
|
||||
}
|
||||
switch (ifa->ifa_addr->sa_family) {
|
||||
#ifdef INET
|
||||
case AF_INET:
|
||||
if (((struct sockaddr_in *)ifa->ifa_addr)->sin_addr.s_addr == 0) {
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
#ifdef INET6
|
||||
case AF_INET6:
|
||||
if (IN6_IS_ADDR_UNSPECIFIED(&((struct sockaddr_in6 *)ifa->ifa_addr)->sin6_addr)) {
|
||||
/* skip unspecifed addresses */
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
continue;
|
||||
}
|
||||
switch (ifa->ifa_addr->sa_family) {
|
||||
#ifdef INET
|
||||
case AF_INET:
|
||||
ifa_flags = 0;
|
||||
break;
|
||||
#endif
|
||||
#ifdef INET6
|
||||
case AF_INET6:
|
||||
ifa6 = (struct in6_ifaddr *)ifa;
|
||||
ifa_flags = ifa6->ia6_flags;
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
ifa_flags = 0;
|
||||
break;
|
||||
}
|
||||
sctp_ifa = sctp_add_addr_to_vrf(vrfid,
|
||||
(void *)ifn,
|
||||
ifn->if_index,
|
||||
ifn->if_type,
|
||||
ifn->if_xname,
|
||||
(void *)ifa,
|
||||
ifa->ifa_addr,
|
||||
ifa_flags,
|
||||
0);
|
||||
if (sctp_ifa) {
|
||||
sctp_ifa->localifa_flags &= ~SCTP_ADDR_DEFER_USE;
|
||||
}
|
||||
}
|
||||
}
|
||||
NET_EPOCH_EXIT(et);
|
||||
IFNET_RUNLOCK();
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
sctp_init_vrf_list(int vrfid)
|
||||
{
|
||||
if (vrfid > SCTP_MAX_VRF_ID)
|
||||
/* can't do that */
|
||||
return;
|
||||
|
||||
/* Don't care about return here */
|
||||
(void)sctp_allocate_vrf(vrfid);
|
||||
|
||||
/* Now we need to build all the ifn's
|
||||
* for this vrf and there addresses
|
||||
*/
|
||||
sctp_init_ifns_for_vrf(vrfid);
|
||||
}
|
||||
|
||||
void
|
||||
sctp_addr_change(struct ifaddr *ifa, int cmd)
|
||||
{
|
||||
#if defined(__Userspace__)
|
||||
return;
|
||||
#else
|
||||
uint32_t ifa_flags = 0;
|
||||
|
||||
if (SCTP_BASE_VAR(sctp_pcb_initialized) == 0) {
|
||||
return;
|
||||
}
|
||||
/* BSD only has one VRF, if this changes
|
||||
* we will need to hook in the right
|
||||
* things here to get the id to pass to
|
||||
* the address management routine.
|
||||
*/
|
||||
if (SCTP_BASE_VAR(first_time) == 0) {
|
||||
/* Special test to see if my ::1 will showup with this */
|
||||
SCTP_BASE_VAR(first_time) = 1;
|
||||
sctp_init_ifns_for_vrf(SCTP_DEFAULT_VRFID);
|
||||
}
|
||||
|
||||
if ((cmd != RTM_ADD) && (cmd != RTM_DELETE)) {
|
||||
/* don't know what to do with this */
|
||||
return;
|
||||
}
|
||||
|
||||
if (ifa->ifa_addr == NULL) {
|
||||
return;
|
||||
}
|
||||
if (sctp_is_desired_interface_type(ifa->ifa_ifp) == 0) {
|
||||
/* non desired type */
|
||||
return;
|
||||
}
|
||||
switch (ifa->ifa_addr->sa_family) {
|
||||
#ifdef INET
|
||||
case AF_INET:
|
||||
if (((struct sockaddr_in *)ifa->ifa_addr)->sin_addr.s_addr == 0) {
|
||||
return;
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
#ifdef INET6
|
||||
case AF_INET6:
|
||||
ifa_flags = ((struct in6_ifaddr *)ifa)->ia6_flags;
|
||||
if (IN6_IS_ADDR_UNSPECIFIED(&((struct sockaddr_in6 *)ifa->ifa_addr)->sin6_addr)) {
|
||||
/* skip unspecifed addresses */
|
||||
return;
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
/* non inet/inet6 skip */
|
||||
return;
|
||||
}
|
||||
if (cmd == RTM_ADD) {
|
||||
(void)sctp_add_addr_to_vrf(SCTP_DEFAULT_VRFID, (void *)ifa->ifa_ifp,
|
||||
#if defined(__APPLE__) && !defined(__Userspace__)
|
||||
ifnet_index(ifa->ifa_ifp), ifnet_type(ifa->ifa_ifp), ifnet_name(ifa->ifa_ifp),
|
||||
#else
|
||||
ifa->ifa_ifp->if_index, ifa->ifa_ifp->if_type, ifa->ifa_ifp->if_xname,
|
||||
#endif
|
||||
(void *)ifa, ifa->ifa_addr, ifa_flags, 1);
|
||||
} else {
|
||||
sctp_del_addr_from_vrf(SCTP_DEFAULT_VRFID, ifa->ifa_addr,
|
||||
#if defined(__APPLE__) && !defined(__Userspace__)
|
||||
ifnet_index(ifa->ifa_ifp),
|
||||
ifnet_name(ifa->ifa_ifp));
|
||||
#else
|
||||
ifa->ifa_ifp->if_index,
|
||||
ifa->ifa_ifp->if_xname);
|
||||
#endif
|
||||
|
||||
/* We don't bump refcount here so when it completes
|
||||
* the final delete will happen.
|
||||
*/
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#if defined(__FreeBSD__) && !defined(__Userspace__)
|
||||
void
|
||||
sctp_addr_change_event_handler(void *arg __unused, struct ifaddr *ifa, int cmd) {
|
||||
sctp_addr_change(ifa, cmd);
|
||||
}
|
||||
#endif
|
||||
#if defined(__APPLE__) && !defined(__Userspace__)
|
||||
void
|
||||
sctp_add_or_del_interfaces(int (*pred)(struct ifnet *), int add)
|
||||
{
|
||||
struct ifnet **ifnetlist;
|
||||
struct ifaddr **ifaddrlist;
|
||||
uint32_t i, j, count;
|
||||
|
||||
if (ifnet_list_get(IFNET_FAMILY_ANY, &ifnetlist, &count) != 0) {
|
||||
return;
|
||||
}
|
||||
for (i = 0; i < count; i++) {
|
||||
if (!(*pred)(ifnetlist[i])) {
|
||||
continue;
|
||||
}
|
||||
if (ifnet_get_address_list(ifnetlist[i], &ifaddrlist) != 0) {
|
||||
continue;
|
||||
}
|
||||
for (j = 0; ifaddrlist[j] != NULL; j++) {
|
||||
sctp_addr_change(ifaddrlist[j], add ? RTM_ADD : RTM_DELETE);
|
||||
}
|
||||
ifnet_free_address_list(ifaddrlist);
|
||||
}
|
||||
ifnet_list_free(ifnetlist);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
struct mbuf *
|
||||
sctp_get_mbuf_for_msg(unsigned int space_needed, int want_header,
|
||||
int how, int allonebuf, int type)
|
||||
{
|
||||
struct mbuf *m = NULL;
|
||||
#if defined(__FreeBSD__) || defined(__Userspace__)
|
||||
#if defined(__Userspace__)
|
||||
m = m_getm2(NULL, space_needed, how, type, want_header ? M_PKTHDR : 0, allonebuf);
|
||||
#else
|
||||
m = m_getm2(NULL, space_needed, how, type, want_header ? M_PKTHDR : 0);
|
||||
#endif
|
||||
if (m == NULL) {
|
||||
/* bad, no memory */
|
||||
return (m);
|
||||
}
|
||||
#if !defined(__Userspace__)
|
||||
if (allonebuf) {
|
||||
if (SCTP_BUF_SIZE(m) < space_needed) {
|
||||
m_freem(m);
|
||||
return (NULL);
|
||||
}
|
||||
KASSERT(SCTP_BUF_NEXT(m) == NULL, ("%s: no chain allowed", __func__));
|
||||
}
|
||||
#endif
|
||||
#ifdef SCTP_MBUF_LOGGING
|
||||
if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_MBUF_LOGGING_ENABLE) {
|
||||
sctp_log_mb(m, SCTP_MBUF_IALLOC);
|
||||
}
|
||||
#endif
|
||||
#else
|
||||
int mbuf_threshold;
|
||||
unsigned int size;
|
||||
|
||||
if (want_header) {
|
||||
MGETHDR(m, how, type);
|
||||
size = MHLEN;
|
||||
} else {
|
||||
MGET(m, how, type);
|
||||
size = MLEN;
|
||||
}
|
||||
if (m == NULL) {
|
||||
return (NULL);
|
||||
}
|
||||
if (allonebuf == 0) {
|
||||
mbuf_threshold = SCTP_BASE_SYSCTL(sctp_mbuf_threshold_count);
|
||||
} else {
|
||||
mbuf_threshold = 1;
|
||||
}
|
||||
|
||||
if (space_needed > (unsigned int)(((mbuf_threshold - 1) * MLEN) + MHLEN)) {
|
||||
MCLGET(m, how);
|
||||
if (m == NULL) {
|
||||
return (NULL);
|
||||
}
|
||||
if (SCTP_BUF_IS_EXTENDED(m) == 0) {
|
||||
sctp_m_freem(m);
|
||||
return (NULL);
|
||||
}
|
||||
size = SCTP_BUF_EXTEND_SIZE(m);
|
||||
}
|
||||
if (allonebuf != 0 && size < space_needed) {
|
||||
m_freem(m);
|
||||
return (NULL);
|
||||
}
|
||||
SCTP_BUF_LEN(m) = 0;
|
||||
SCTP_BUF_NEXT(m) = SCTP_BUF_NEXT_PKT(m) = NULL;
|
||||
#ifdef SCTP_MBUF_LOGGING
|
||||
if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_MBUF_LOGGING_ENABLE) {
|
||||
sctp_log_mb(m, SCTP_MBUF_IALLOC);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
return (m);
|
||||
}
|
||||
|
||||
#ifdef SCTP_PACKET_LOGGING
|
||||
void
|
||||
sctp_packet_log(struct mbuf *m)
|
||||
{
|
||||
int *lenat, thisone;
|
||||
void *copyto;
|
||||
uint32_t *tick_tock;
|
||||
int length;
|
||||
int total_len;
|
||||
int grabbed_lock = 0;
|
||||
int value, newval, thisend, thisbegin;
|
||||
/*
|
||||
* Buffer layout.
|
||||
* -sizeof this entry (total_len)
|
||||
* -previous end (value)
|
||||
* -ticks of log (ticks)
|
||||
* o -ip packet
|
||||
* o -as logged
|
||||
* - where this started (thisbegin)
|
||||
* x <--end points here
|
||||
*/
|
||||
length = SCTP_HEADER_LEN(m);
|
||||
total_len = SCTP_SIZE32((length + (4 * sizeof(int))));
|
||||
/* Log a packet to the buffer. */
|
||||
if (total_len> SCTP_PACKET_LOG_SIZE) {
|
||||
/* Can't log this packet I have not a buffer big enough */
|
||||
return;
|
||||
}
|
||||
if (length < (int)(SCTP_MIN_V4_OVERHEAD + sizeof(struct sctp_cookie_ack_chunk))) {
|
||||
return;
|
||||
}
|
||||
atomic_add_int(&SCTP_BASE_VAR(packet_log_writers), 1);
|
||||
try_again:
|
||||
if (SCTP_BASE_VAR(packet_log_writers) > SCTP_PKTLOG_WRITERS_NEED_LOCK) {
|
||||
SCTP_IP_PKTLOG_LOCK();
|
||||
grabbed_lock = 1;
|
||||
again_locked:
|
||||
value = SCTP_BASE_VAR(packet_log_end);
|
||||
newval = SCTP_BASE_VAR(packet_log_end) + total_len;
|
||||
if (newval >= SCTP_PACKET_LOG_SIZE) {
|
||||
/* we wrapped */
|
||||
thisbegin = 0;
|
||||
thisend = total_len;
|
||||
} else {
|
||||
thisbegin = SCTP_BASE_VAR(packet_log_end);
|
||||
thisend = newval;
|
||||
}
|
||||
if (!(atomic_cmpset_int(&SCTP_BASE_VAR(packet_log_end), value, thisend))) {
|
||||
goto again_locked;
|
||||
}
|
||||
} else {
|
||||
value = SCTP_BASE_VAR(packet_log_end);
|
||||
newval = SCTP_BASE_VAR(packet_log_end) + total_len;
|
||||
if (newval >= SCTP_PACKET_LOG_SIZE) {
|
||||
/* we wrapped */
|
||||
thisbegin = 0;
|
||||
thisend = total_len;
|
||||
} else {
|
||||
thisbegin = SCTP_BASE_VAR(packet_log_end);
|
||||
thisend = newval;
|
||||
}
|
||||
if (!(atomic_cmpset_int(&SCTP_BASE_VAR(packet_log_end), value, thisend))) {
|
||||
goto try_again;
|
||||
}
|
||||
}
|
||||
/* Sanity check */
|
||||
if (thisend >= SCTP_PACKET_LOG_SIZE) {
|
||||
SCTP_PRINTF("Insanity stops a log thisbegin:%d thisend:%d writers:%d lock:%d end:%d\n",
|
||||
thisbegin,
|
||||
thisend,
|
||||
SCTP_BASE_VAR(packet_log_writers),
|
||||
grabbed_lock,
|
||||
SCTP_BASE_VAR(packet_log_end));
|
||||
SCTP_BASE_VAR(packet_log_end) = 0;
|
||||
goto no_log;
|
||||
}
|
||||
lenat = (int *)&SCTP_BASE_VAR(packet_log_buffer)[thisbegin];
|
||||
*lenat = total_len;
|
||||
lenat++;
|
||||
*lenat = value;
|
||||
lenat++;
|
||||
tick_tock = (uint32_t *)lenat;
|
||||
lenat++;
|
||||
*tick_tock = sctp_get_tick_count();
|
||||
copyto = (void *)lenat;
|
||||
thisone = thisend - sizeof(int);
|
||||
lenat = (int *)&SCTP_BASE_VAR(packet_log_buffer)[thisone];
|
||||
*lenat = thisbegin;
|
||||
if (grabbed_lock) {
|
||||
SCTP_IP_PKTLOG_UNLOCK();
|
||||
grabbed_lock = 0;
|
||||
}
|
||||
m_copydata(m, 0, length, (caddr_t)copyto);
|
||||
no_log:
|
||||
if (grabbed_lock) {
|
||||
SCTP_IP_PKTLOG_UNLOCK();
|
||||
}
|
||||
atomic_subtract_int(&SCTP_BASE_VAR(packet_log_writers), 1);
|
||||
}
|
||||
|
||||
int
|
||||
sctp_copy_out_packet_log(uint8_t *target, int length)
|
||||
{
|
||||
/* We wind through the packet log starting at
|
||||
* start copying up to length bytes out.
|
||||
* We return the number of bytes copied.
|
||||
*/
|
||||
int tocopy, this_copy;
|
||||
int *lenat;
|
||||
int did_delay = 0;
|
||||
|
||||
tocopy = length;
|
||||
if (length < (int)(2 * sizeof(int))) {
|
||||
/* not enough room */
|
||||
return (0);
|
||||
}
|
||||
if (SCTP_PKTLOG_WRITERS_NEED_LOCK) {
|
||||
atomic_add_int(&SCTP_BASE_VAR(packet_log_writers), SCTP_PKTLOG_WRITERS_NEED_LOCK);
|
||||
again:
|
||||
if ((did_delay == 0) && (SCTP_BASE_VAR(packet_log_writers) != SCTP_PKTLOG_WRITERS_NEED_LOCK)) {
|
||||
/* we delay here for just a moment hoping the writer(s) that were
|
||||
* present when we entered will have left and we only have
|
||||
* locking ones that will contend with us for the lock. This
|
||||
* does not assure 100% access, but its good enough for
|
||||
* a logging facility like this.
|
||||
*/
|
||||
did_delay = 1;
|
||||
DELAY(10);
|
||||
goto again;
|
||||
}
|
||||
}
|
||||
SCTP_IP_PKTLOG_LOCK();
|
||||
lenat = (int *)target;
|
||||
*lenat = SCTP_BASE_VAR(packet_log_end);
|
||||
lenat++;
|
||||
this_copy = min((length - sizeof(int)), SCTP_PACKET_LOG_SIZE);
|
||||
memcpy((void *)lenat, (void *)SCTP_BASE_VAR(packet_log_buffer), this_copy);
|
||||
if (SCTP_PKTLOG_WRITERS_NEED_LOCK) {
|
||||
atomic_subtract_int(&SCTP_BASE_VAR(packet_log_writers),
|
||||
SCTP_PKTLOG_WRITERS_NEED_LOCK);
|
||||
}
|
||||
SCTP_IP_PKTLOG_UNLOCK();
|
||||
return (this_copy + sizeof(int));
|
||||
}
|
||||
|
||||
#endif
|
||||
72
TMessagesProj/jni/third_party/usrsctplib/netinet/sctp_bsd_addr.h
vendored
Executable file
72
TMessagesProj/jni/third_party/usrsctplib/netinet/sctp_bsd_addr.h
vendored
Executable file
|
|
@ -0,0 +1,72 @@
|
|||
/*-
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#if defined(__FreeBSD__) && !defined(__Userspace__)
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD: head/sys/netinet/sctp_bsd_addr.h 365071 2020-09-01 21:19:14Z mjg $");
|
||||
#endif
|
||||
|
||||
#ifndef _NETINET_SCTP_BSD_ADDR_H_
|
||||
#define _NETINET_SCTP_BSD_ADDR_H_
|
||||
|
||||
#include <netinet/sctp_pcb.h>
|
||||
|
||||
#if defined(_KERNEL) || defined(__Userspace__)
|
||||
|
||||
extern struct iterator_control sctp_it_ctl;
|
||||
void sctp_wakeup_iterator(void);
|
||||
|
||||
void sctp_startup_iterator(void);
|
||||
|
||||
#ifdef INET6
|
||||
void sctp_gather_internal_ifa_flags(struct sctp_ifa *ifa);
|
||||
#endif
|
||||
|
||||
#ifdef SCTP_PACKET_LOGGING
|
||||
|
||||
void sctp_packet_log(struct mbuf *m);
|
||||
int sctp_copy_out_packet_log(uint8_t *target, int length);
|
||||
|
||||
#endif
|
||||
|
||||
void sctp_addr_change(struct ifaddr *ifa, int cmd);
|
||||
#if defined(__FreeBSD__) && !defined(__Userspace__)
|
||||
|
||||
void sctp_addr_change_event_handler(void *, struct ifaddr *, int);
|
||||
#endif
|
||||
|
||||
void sctp_add_or_del_interfaces(int (*pred)(struct ifnet *), int add);
|
||||
|
||||
#endif
|
||||
#endif
|
||||
249
TMessagesProj/jni/third_party/usrsctplib/netinet/sctp_callout.c
vendored
Executable file
249
TMessagesProj/jni/third_party/usrsctplib/netinet/sctp_callout.c
vendored
Executable file
|
|
@ -0,0 +1,249 @@
|
|||
/*-
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#if defined(__Userspace__)
|
||||
#include <sys/types.h>
|
||||
#if !defined(_WIN32)
|
||||
#include <sys/wait.h>
|
||||
#include <unistd.h>
|
||||
#include <pthread.h>
|
||||
#endif
|
||||
#if defined(__native_client__)
|
||||
#include <sys/select.h>
|
||||
#endif
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <user_atomic.h>
|
||||
#include <netinet/sctp_sysctl.h>
|
||||
#include <netinet/sctp_pcb.h>
|
||||
#else
|
||||
#include <netinet/sctp_os.h>
|
||||
#include <netinet/sctp_callout.h>
|
||||
#include <netinet/sctp_pcb.h>
|
||||
#endif
|
||||
#include <netinet/sctputil.h>
|
||||
|
||||
/*
|
||||
* Callout/Timer routines for OS that doesn't have them
|
||||
*/
|
||||
#if defined(__APPLE__) || defined(__Userspace__)
|
||||
static uint32_t ticks = 0;
|
||||
#else
|
||||
extern int ticks;
|
||||
#endif
|
||||
|
||||
uint32_t sctp_get_tick_count(void) {
|
||||
uint32_t ret;
|
||||
|
||||
SCTP_TIMERQ_LOCK();
|
||||
ret = ticks;
|
||||
SCTP_TIMERQ_UNLOCK();
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
* SCTP_TIMERQ_LOCK protects:
|
||||
* - SCTP_BASE_INFO(callqueue)
|
||||
* - sctp_os_timer_next: next timer to check
|
||||
*/
|
||||
static sctp_os_timer_t *sctp_os_timer_next = NULL;
|
||||
|
||||
void
|
||||
sctp_os_timer_init(sctp_os_timer_t *c)
|
||||
{
|
||||
memset(c, 0, sizeof(*c));
|
||||
}
|
||||
|
||||
int
|
||||
sctp_os_timer_start(sctp_os_timer_t *c, uint32_t to_ticks, void (*ftn) (void *),
|
||||
void *arg)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
/* paranoia */
|
||||
if ((c == NULL) || (ftn == NULL))
|
||||
return (ret);
|
||||
|
||||
SCTP_TIMERQ_LOCK();
|
||||
/* check to see if we're rescheduling a timer */
|
||||
if (c->c_flags & SCTP_CALLOUT_PENDING) {
|
||||
ret = 1;
|
||||
if (c == sctp_os_timer_next) {
|
||||
sctp_os_timer_next = TAILQ_NEXT(c, tqe);
|
||||
}
|
||||
TAILQ_REMOVE(&SCTP_BASE_INFO(callqueue), c, tqe);
|
||||
/*
|
||||
* part of the normal "stop a pending callout" process
|
||||
* is to clear the CALLOUT_ACTIVE and CALLOUT_PENDING
|
||||
* flags. We don't bother since we are setting these
|
||||
* below and we still hold the lock.
|
||||
*/
|
||||
}
|
||||
|
||||
/*
|
||||
* We could unlock/splx here and lock/spl at the TAILQ_INSERT_TAIL,
|
||||
* but there's no point since doing this setup doesn't take much time.
|
||||
*/
|
||||
if (to_ticks == 0)
|
||||
to_ticks = 1;
|
||||
|
||||
c->c_arg = arg;
|
||||
c->c_flags = (SCTP_CALLOUT_ACTIVE | SCTP_CALLOUT_PENDING);
|
||||
c->c_func = ftn;
|
||||
c->c_time = ticks + to_ticks;
|
||||
TAILQ_INSERT_TAIL(&SCTP_BASE_INFO(callqueue), c, tqe);
|
||||
SCTP_TIMERQ_UNLOCK();
|
||||
return (ret);
|
||||
}
|
||||
|
||||
int
|
||||
sctp_os_timer_stop(sctp_os_timer_t *c)
|
||||
{
|
||||
SCTP_TIMERQ_LOCK();
|
||||
/*
|
||||
* Don't attempt to delete a callout that's not on the queue.
|
||||
*/
|
||||
if (!(c->c_flags & SCTP_CALLOUT_PENDING)) {
|
||||
c->c_flags &= ~SCTP_CALLOUT_ACTIVE;
|
||||
SCTP_TIMERQ_UNLOCK();
|
||||
return (0);
|
||||
}
|
||||
c->c_flags &= ~(SCTP_CALLOUT_ACTIVE | SCTP_CALLOUT_PENDING);
|
||||
if (c == sctp_os_timer_next) {
|
||||
sctp_os_timer_next = TAILQ_NEXT(c, tqe);
|
||||
}
|
||||
TAILQ_REMOVE(&SCTP_BASE_INFO(callqueue), c, tqe);
|
||||
SCTP_TIMERQ_UNLOCK();
|
||||
return (1);
|
||||
}
|
||||
|
||||
void
|
||||
sctp_handle_tick(uint32_t elapsed_ticks)
|
||||
{
|
||||
sctp_os_timer_t *c;
|
||||
void (*c_func)(void *);
|
||||
void *c_arg;
|
||||
|
||||
SCTP_TIMERQ_LOCK();
|
||||
/* update our tick count */
|
||||
ticks += elapsed_ticks;
|
||||
c = TAILQ_FIRST(&SCTP_BASE_INFO(callqueue));
|
||||
while (c) {
|
||||
if (SCTP_UINT32_GE(ticks, c->c_time)) {
|
||||
sctp_os_timer_next = TAILQ_NEXT(c, tqe);
|
||||
TAILQ_REMOVE(&SCTP_BASE_INFO(callqueue), c, tqe);
|
||||
c_func = c->c_func;
|
||||
c_arg = c->c_arg;
|
||||
c->c_flags &= ~SCTP_CALLOUT_PENDING;
|
||||
SCTP_TIMERQ_UNLOCK();
|
||||
c_func(c_arg);
|
||||
SCTP_TIMERQ_LOCK();
|
||||
c = sctp_os_timer_next;
|
||||
} else {
|
||||
c = TAILQ_NEXT(c, tqe);
|
||||
}
|
||||
}
|
||||
sctp_os_timer_next = NULL;
|
||||
SCTP_TIMERQ_UNLOCK();
|
||||
}
|
||||
|
||||
#if defined(__APPLE__) && !defined(__Userspace__)
|
||||
void
|
||||
sctp_timeout(void *arg SCTP_UNUSED)
|
||||
{
|
||||
sctp_handle_tick(SCTP_BASE_VAR(sctp_main_timer_ticks));
|
||||
sctp_start_main_timer();
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(__Userspace__)
|
||||
#define TIMEOUT_INTERVAL 10
|
||||
|
||||
void *
|
||||
user_sctp_timer_iterate(void *arg)
|
||||
{
|
||||
sctp_userspace_set_threadname("SCTP timer");
|
||||
for (;;) {
|
||||
#if defined(_WIN32)
|
||||
Sleep(TIMEOUT_INTERVAL);
|
||||
#else
|
||||
struct timespec amount, remaining;
|
||||
|
||||
remaining.tv_sec = 0;
|
||||
remaining.tv_nsec = TIMEOUT_INTERVAL * 1000 * 1000;
|
||||
do {
|
||||
amount = remaining;
|
||||
} while (nanosleep(&amount, &remaining) == -1);
|
||||
#endif
|
||||
if (atomic_cmpset_int(&SCTP_BASE_VAR(timer_thread_should_exit), 1, 1)) {
|
||||
break;
|
||||
}
|
||||
sctp_handle_tick(sctp_msecs_to_ticks(TIMEOUT_INTERVAL));
|
||||
}
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
void
|
||||
sctp_start_timer_thread(void)
|
||||
{
|
||||
/*
|
||||
* No need to do SCTP_TIMERQ_LOCK_INIT();
|
||||
* here, it is being done in sctp_pcb_init()
|
||||
*/
|
||||
int rc;
|
||||
|
||||
rc = sctp_userspace_thread_create(&SCTP_BASE_VAR(timer_thread), user_sctp_timer_iterate);
|
||||
if (rc) {
|
||||
SCTP_PRINTF("ERROR; return code from sctp_thread_create() is %d\n", rc);
|
||||
} else {
|
||||
SCTP_BASE_VAR(timer_thread_started) = 1;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
sctp_stop_timer_thread(void)
|
||||
{
|
||||
atomic_cmpset_int(&SCTP_BASE_VAR(timer_thread_should_exit), 0, 1);
|
||||
if (SCTP_BASE_VAR(timer_thread_started)) {
|
||||
#if defined(_WIN32)
|
||||
WaitForSingleObject(SCTP_BASE_VAR(timer_thread), INFINITE);
|
||||
CloseHandle(SCTP_BASE_VAR(timer_thread));
|
||||
#else
|
||||
pthread_join(SCTP_BASE_VAR(timer_thread), NULL);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#endif
|
||||
119
TMessagesProj/jni/third_party/usrsctplib/netinet/sctp_callout.h
vendored
Executable file
119
TMessagesProj/jni/third_party/usrsctplib/netinet/sctp_callout.h
vendored
Executable file
|
|
@ -0,0 +1,119 @@
|
|||
/*-
|
||||
* 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:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. 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.
|
||||
* 3. Neither the name of the project 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 PROJECT 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 PROJECT 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.
|
||||
*/
|
||||
|
||||
#if defined(__FreeBSD__) && !defined(__Userspace__)
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
#endif
|
||||
|
||||
#ifndef _NETINET_SCTP_CALLOUT_
|
||||
#define _NETINET_SCTP_CALLOUT_
|
||||
|
||||
/*
|
||||
* NOTE: the following MACROS are required for locking the callout
|
||||
* queue along with a lock/mutex in the OS specific headers and
|
||||
* implementation files::
|
||||
* - SCTP_TIMERQ_LOCK()
|
||||
* - SCTP_TIMERQ_UNLOCK()
|
||||
* - SCTP_TIMERQ_LOCK_INIT()
|
||||
* - SCTP_TIMERQ_LOCK_DESTROY()
|
||||
*/
|
||||
|
||||
#define _SCTP_NEEDS_CALLOUT_ 1
|
||||
|
||||
#define SCTP_TICKS_PER_FASTTIMO 20 /* called about every 20ms */
|
||||
|
||||
#if defined(__Userspace__)
|
||||
#if defined(_WIN32)
|
||||
#define SCTP_TIMERQ_LOCK() EnterCriticalSection(&SCTP_BASE_VAR(timer_mtx))
|
||||
#define SCTP_TIMERQ_UNLOCK() LeaveCriticalSection(&SCTP_BASE_VAR(timer_mtx))
|
||||
#define SCTP_TIMERQ_LOCK_INIT() InitializeCriticalSection(&SCTP_BASE_VAR(timer_mtx))
|
||||
#define SCTP_TIMERQ_LOCK_DESTROY() DeleteCriticalSection(&SCTP_BASE_VAR(timer_mtx))
|
||||
#else
|
||||
#ifdef INVARIANTS
|
||||
#define SCTP_TIMERQ_LOCK() KASSERT(pthread_mutex_lock(&SCTP_BASE_VAR(timer_mtx)) == 0, ("%s: timer_mtx already locked", __func__))
|
||||
#define SCTP_TIMERQ_UNLOCK() KASSERT(pthread_mutex_unlock(&SCTP_BASE_VAR(timer_mtx)) == 0, ("%s: timer_mtx not locked", __func__))
|
||||
#else
|
||||
#define SCTP_TIMERQ_LOCK() (void)pthread_mutex_lock(&SCTP_BASE_VAR(timer_mtx))
|
||||
#define SCTP_TIMERQ_UNLOCK() (void)pthread_mutex_unlock(&SCTP_BASE_VAR(timer_mtx))
|
||||
#endif
|
||||
#define SCTP_TIMERQ_LOCK_INIT() (void)pthread_mutex_init(&SCTP_BASE_VAR(timer_mtx), &SCTP_BASE_VAR(mtx_attr))
|
||||
#define SCTP_TIMERQ_LOCK_DESTROY() (void)pthread_mutex_destroy(&SCTP_BASE_VAR(timer_mtx))
|
||||
#endif
|
||||
#endif
|
||||
|
||||
uint32_t sctp_get_tick_count(void);
|
||||
|
||||
TAILQ_HEAD(calloutlist, sctp_callout);
|
||||
|
||||
struct sctp_callout {
|
||||
TAILQ_ENTRY(sctp_callout) tqe;
|
||||
uint32_t c_time; /* ticks to the event */
|
||||
void *c_arg; /* function argument */
|
||||
void (*c_func)(void *); /* function to call */
|
||||
int c_flags; /* state of this entry */
|
||||
};
|
||||
typedef struct sctp_callout sctp_os_timer_t;
|
||||
|
||||
#define SCTP_CALLOUT_ACTIVE 0x0002 /* callout is currently active */
|
||||
#define SCTP_CALLOUT_PENDING 0x0004 /* callout is waiting for timeout */
|
||||
|
||||
void sctp_os_timer_init(sctp_os_timer_t *tmr);
|
||||
/* Returns 1 if pending timer was rescheduled, 0 otherwise. */
|
||||
int sctp_os_timer_start(sctp_os_timer_t *, uint32_t, void (*)(void *), void *);
|
||||
/* Returns 1 if pending timer was stopped, 0 otherwise. */
|
||||
int sctp_os_timer_stop(sctp_os_timer_t *);
|
||||
void sctp_handle_tick(uint32_t);
|
||||
|
||||
#define SCTP_OS_TIMER_INIT sctp_os_timer_init
|
||||
/*
|
||||
* NOTE: The next two shouldn't be called directly outside of sctp_timer_start()
|
||||
* and sctp_timer_stop(), since they don't handle incrementing/decrementing
|
||||
* relevant reference counts.
|
||||
*/
|
||||
#define SCTP_OS_TIMER_START sctp_os_timer_start
|
||||
#define SCTP_OS_TIMER_STOP sctp_os_timer_stop
|
||||
/* MT FIXME: Is the following correct? */
|
||||
#define SCTP_OS_TIMER_STOP_DRAIN SCTP_OS_TIMER_STOP
|
||||
#define SCTP_OS_TIMER_PENDING(tmr) ((tmr)->c_flags & SCTP_CALLOUT_PENDING)
|
||||
#define SCTP_OS_TIMER_ACTIVE(tmr) ((tmr)->c_flags & SCTP_CALLOUT_ACTIVE)
|
||||
#define SCTP_OS_TIMER_DEACTIVATE(tmr) ((tmr)->c_flags &= ~SCTP_CALLOUT_ACTIVE)
|
||||
|
||||
#if defined(__Userspace__)
|
||||
void sctp_start_timer_thread(void);
|
||||
void sctp_stop_timer_thread(void);
|
||||
#endif
|
||||
#if defined(__APPLE__) && !defined(__Userspace__)
|
||||
void sctp_timeout(void *);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
2493
TMessagesProj/jni/third_party/usrsctplib/netinet/sctp_cc_functions.c
vendored
Executable file
2493
TMessagesProj/jni/third_party/usrsctplib/netinet/sctp_cc_functions.c
vendored
Executable file
File diff suppressed because it is too large
Load diff
1070
TMessagesProj/jni/third_party/usrsctplib/netinet/sctp_constants.h
vendored
Executable file
1070
TMessagesProj/jni/third_party/usrsctplib/netinet/sctp_constants.h
vendored
Executable file
File diff suppressed because it is too large
Load diff
831
TMessagesProj/jni/third_party/usrsctplib/netinet/sctp_crc32.c
vendored
Executable file
831
TMessagesProj/jni/third_party/usrsctplib/netinet/sctp_crc32.c
vendored
Executable file
|
|
@ -0,0 +1,831 @@
|
|||
/*-
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#if defined(__FreeBSD__) && !defined(__Userspace__)
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD: head/sys/netinet/sctp_crc32.c 362498 2020-06-22 14:36:14Z tuexen $");
|
||||
|
||||
#include "opt_sctp.h"
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/gsb_crc32.h>
|
||||
#include <sys/mbuf.h>
|
||||
|
||||
#include <netinet/sctp.h>
|
||||
#include <netinet/sctp_crc32.h>
|
||||
#if defined(SCTP) || defined(SCTP_SUPPORT)
|
||||
#include <netinet/sctp_os.h>
|
||||
#include <netinet/sctp_pcb.h>
|
||||
#endif
|
||||
#else
|
||||
#include <netinet/sctp_os.h>
|
||||
#include <netinet/sctp.h>
|
||||
#include <netinet/sctp_crc32.h>
|
||||
#include <netinet/sctp_pcb.h>
|
||||
#endif
|
||||
|
||||
#if !(defined(__FreeBSD__) && !defined(__Userspace__))
|
||||
/**
|
||||
*
|
||||
* Routine Description:
|
||||
*
|
||||
* Computes the CRC32c checksum for the specified buffer using the slicing by 8
|
||||
* algorithm over 64 bit quantities.
|
||||
*
|
||||
* Arguments:
|
||||
*
|
||||
* p_running_crc - pointer to the initial or final remainder value
|
||||
* used in CRC computations. It should be set to
|
||||
* non-NULL if the mode argument is equal to CONT or END
|
||||
* p_buf - the packet buffer where crc computations are being performed
|
||||
* length - the length of p_buf in bytes
|
||||
* init_bytes - the number of initial bytes that need to be procesed before
|
||||
* aligning p_buf to multiples of 4 bytes
|
||||
* mode - can be any of the following: BEGIN, CONT, END, BODY, ALIGN
|
||||
*
|
||||
* Return value:
|
||||
*
|
||||
* The computed CRC32c value
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* Copyright (c) 2004-2006 Intel Corporation - All Rights Reserved
|
||||
*
|
||||
*
|
||||
* This software program is licensed subject to the BSD License, available at
|
||||
* http://www.opensource.org/licenses/bsd-license.html.
|
||||
*
|
||||
* Abstract:
|
||||
*
|
||||
* Tables for software CRC generation
|
||||
*/
|
||||
|
||||
/*
|
||||
* The following CRC lookup table was generated automagically using the
|
||||
* following model parameters:
|
||||
*
|
||||
* Generator Polynomial = ................. 0x1EDC6F41
|
||||
* Generator Polynomial Length = .......... 32 bits
|
||||
* Reflected Bits = ....................... TRUE
|
||||
* Table Generation Offset = .............. 32 bits
|
||||
* Number of Slices = ..................... 8 slices
|
||||
* Slice Lengths = ........................ 8 8 8 8 8 8 8 8
|
||||
* Directory Name = ....................... .\
|
||||
* File Name = ............................ 8x256_tables.c
|
||||
*/
|
||||
|
||||
static const uint32_t sctp_crc_tableil8_o32[256] =
|
||||
{
|
||||
0x00000000, 0xF26B8303, 0xE13B70F7, 0x1350F3F4, 0xC79A971F, 0x35F1141C, 0x26A1E7E8, 0xD4CA64EB,
|
||||
0x8AD958CF, 0x78B2DBCC, 0x6BE22838, 0x9989AB3B, 0x4D43CFD0, 0xBF284CD3, 0xAC78BF27, 0x5E133C24,
|
||||
0x105EC76F, 0xE235446C, 0xF165B798, 0x030E349B, 0xD7C45070, 0x25AFD373, 0x36FF2087, 0xC494A384,
|
||||
0x9A879FA0, 0x68EC1CA3, 0x7BBCEF57, 0x89D76C54, 0x5D1D08BF, 0xAF768BBC, 0xBC267848, 0x4E4DFB4B,
|
||||
0x20BD8EDE, 0xD2D60DDD, 0xC186FE29, 0x33ED7D2A, 0xE72719C1, 0x154C9AC2, 0x061C6936, 0xF477EA35,
|
||||
0xAA64D611, 0x580F5512, 0x4B5FA6E6, 0xB93425E5, 0x6DFE410E, 0x9F95C20D, 0x8CC531F9, 0x7EAEB2FA,
|
||||
0x30E349B1, 0xC288CAB2, 0xD1D83946, 0x23B3BA45, 0xF779DEAE, 0x05125DAD, 0x1642AE59, 0xE4292D5A,
|
||||
0xBA3A117E, 0x4851927D, 0x5B016189, 0xA96AE28A, 0x7DA08661, 0x8FCB0562, 0x9C9BF696, 0x6EF07595,
|
||||
0x417B1DBC, 0xB3109EBF, 0xA0406D4B, 0x522BEE48, 0x86E18AA3, 0x748A09A0, 0x67DAFA54, 0x95B17957,
|
||||
0xCBA24573, 0x39C9C670, 0x2A993584, 0xD8F2B687, 0x0C38D26C, 0xFE53516F, 0xED03A29B, 0x1F682198,
|
||||
0x5125DAD3, 0xA34E59D0, 0xB01EAA24, 0x42752927, 0x96BF4DCC, 0x64D4CECF, 0x77843D3B, 0x85EFBE38,
|
||||
0xDBFC821C, 0x2997011F, 0x3AC7F2EB, 0xC8AC71E8, 0x1C661503, 0xEE0D9600, 0xFD5D65F4, 0x0F36E6F7,
|
||||
0x61C69362, 0x93AD1061, 0x80FDE395, 0x72966096, 0xA65C047D, 0x5437877E, 0x4767748A, 0xB50CF789,
|
||||
0xEB1FCBAD, 0x197448AE, 0x0A24BB5A, 0xF84F3859, 0x2C855CB2, 0xDEEEDFB1, 0xCDBE2C45, 0x3FD5AF46,
|
||||
0x7198540D, 0x83F3D70E, 0x90A324FA, 0x62C8A7F9, 0xB602C312, 0x44694011, 0x5739B3E5, 0xA55230E6,
|
||||
0xFB410CC2, 0x092A8FC1, 0x1A7A7C35, 0xE811FF36, 0x3CDB9BDD, 0xCEB018DE, 0xDDE0EB2A, 0x2F8B6829,
|
||||
0x82F63B78, 0x709DB87B, 0x63CD4B8F, 0x91A6C88C, 0x456CAC67, 0xB7072F64, 0xA457DC90, 0x563C5F93,
|
||||
0x082F63B7, 0xFA44E0B4, 0xE9141340, 0x1B7F9043, 0xCFB5F4A8, 0x3DDE77AB, 0x2E8E845F, 0xDCE5075C,
|
||||
0x92A8FC17, 0x60C37F14, 0x73938CE0, 0x81F80FE3, 0x55326B08, 0xA759E80B, 0xB4091BFF, 0x466298FC,
|
||||
0x1871A4D8, 0xEA1A27DB, 0xF94AD42F, 0x0B21572C, 0xDFEB33C7, 0x2D80B0C4, 0x3ED04330, 0xCCBBC033,
|
||||
0xA24BB5A6, 0x502036A5, 0x4370C551, 0xB11B4652, 0x65D122B9, 0x97BAA1BA, 0x84EA524E, 0x7681D14D,
|
||||
0x2892ED69, 0xDAF96E6A, 0xC9A99D9E, 0x3BC21E9D, 0xEF087A76, 0x1D63F975, 0x0E330A81, 0xFC588982,
|
||||
0xB21572C9, 0x407EF1CA, 0x532E023E, 0xA145813D, 0x758FE5D6, 0x87E466D5, 0x94B49521, 0x66DF1622,
|
||||
0x38CC2A06, 0xCAA7A905, 0xD9F75AF1, 0x2B9CD9F2, 0xFF56BD19, 0x0D3D3E1A, 0x1E6DCDEE, 0xEC064EED,
|
||||
0xC38D26C4, 0x31E6A5C7, 0x22B65633, 0xD0DDD530, 0x0417B1DB, 0xF67C32D8, 0xE52CC12C, 0x1747422F,
|
||||
0x49547E0B, 0xBB3FFD08, 0xA86F0EFC, 0x5A048DFF, 0x8ECEE914, 0x7CA56A17, 0x6FF599E3, 0x9D9E1AE0,
|
||||
0xD3D3E1AB, 0x21B862A8, 0x32E8915C, 0xC083125F, 0x144976B4, 0xE622F5B7, 0xF5720643, 0x07198540,
|
||||
0x590AB964, 0xAB613A67, 0xB831C993, 0x4A5A4A90, 0x9E902E7B, 0x6CFBAD78, 0x7FAB5E8C, 0x8DC0DD8F,
|
||||
0xE330A81A, 0x115B2B19, 0x020BD8ED, 0xF0605BEE, 0x24AA3F05, 0xD6C1BC06, 0xC5914FF2, 0x37FACCF1,
|
||||
0x69E9F0D5, 0x9B8273D6, 0x88D28022, 0x7AB90321, 0xAE7367CA, 0x5C18E4C9, 0x4F48173D, 0xBD23943E,
|
||||
0xF36E6F75, 0x0105EC76, 0x12551F82, 0xE03E9C81, 0x34F4F86A, 0xC69F7B69, 0xD5CF889D, 0x27A40B9E,
|
||||
0x79B737BA, 0x8BDCB4B9, 0x988C474D, 0x6AE7C44E, 0xBE2DA0A5, 0x4C4623A6, 0x5F16D052, 0xAD7D5351
|
||||
};
|
||||
|
||||
/*
|
||||
* end of the CRC lookup table crc_tableil8_o32
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* The following CRC lookup table was generated automagically using the
|
||||
* following model parameters:
|
||||
*
|
||||
* Generator Polynomial = ................. 0x1EDC6F41
|
||||
* Generator Polynomial Length = .......... 32 bits
|
||||
* Reflected Bits = ....................... TRUE
|
||||
* Table Generation Offset = .............. 32 bits
|
||||
* Number of Slices = ..................... 8 slices
|
||||
* Slice Lengths = ........................ 8 8 8 8 8 8 8 8
|
||||
* Directory Name = ....................... .\
|
||||
* File Name = ............................ 8x256_tables.c
|
||||
*/
|
||||
|
||||
static const uint32_t sctp_crc_tableil8_o40[256] =
|
||||
{
|
||||
0x00000000, 0x13A29877, 0x274530EE, 0x34E7A899, 0x4E8A61DC, 0x5D28F9AB, 0x69CF5132, 0x7A6DC945,
|
||||
0x9D14C3B8, 0x8EB65BCF, 0xBA51F356, 0xA9F36B21, 0xD39EA264, 0xC03C3A13, 0xF4DB928A, 0xE7790AFD,
|
||||
0x3FC5F181, 0x2C6769F6, 0x1880C16F, 0x0B225918, 0x714F905D, 0x62ED082A, 0x560AA0B3, 0x45A838C4,
|
||||
0xA2D13239, 0xB173AA4E, 0x859402D7, 0x96369AA0, 0xEC5B53E5, 0xFFF9CB92, 0xCB1E630B, 0xD8BCFB7C,
|
||||
0x7F8BE302, 0x6C297B75, 0x58CED3EC, 0x4B6C4B9B, 0x310182DE, 0x22A31AA9, 0x1644B230, 0x05E62A47,
|
||||
0xE29F20BA, 0xF13DB8CD, 0xC5DA1054, 0xD6788823, 0xAC154166, 0xBFB7D911, 0x8B507188, 0x98F2E9FF,
|
||||
0x404E1283, 0x53EC8AF4, 0x670B226D, 0x74A9BA1A, 0x0EC4735F, 0x1D66EB28, 0x298143B1, 0x3A23DBC6,
|
||||
0xDD5AD13B, 0xCEF8494C, 0xFA1FE1D5, 0xE9BD79A2, 0x93D0B0E7, 0x80722890, 0xB4958009, 0xA737187E,
|
||||
0xFF17C604, 0xECB55E73, 0xD852F6EA, 0xCBF06E9D, 0xB19DA7D8, 0xA23F3FAF, 0x96D89736, 0x857A0F41,
|
||||
0x620305BC, 0x71A19DCB, 0x45463552, 0x56E4AD25, 0x2C896460, 0x3F2BFC17, 0x0BCC548E, 0x186ECCF9,
|
||||
0xC0D23785, 0xD370AFF2, 0xE797076B, 0xF4359F1C, 0x8E585659, 0x9DFACE2E, 0xA91D66B7, 0xBABFFEC0,
|
||||
0x5DC6F43D, 0x4E646C4A, 0x7A83C4D3, 0x69215CA4, 0x134C95E1, 0x00EE0D96, 0x3409A50F, 0x27AB3D78,
|
||||
0x809C2506, 0x933EBD71, 0xA7D915E8, 0xB47B8D9F, 0xCE1644DA, 0xDDB4DCAD, 0xE9537434, 0xFAF1EC43,
|
||||
0x1D88E6BE, 0x0E2A7EC9, 0x3ACDD650, 0x296F4E27, 0x53028762, 0x40A01F15, 0x7447B78C, 0x67E52FFB,
|
||||
0xBF59D487, 0xACFB4CF0, 0x981CE469, 0x8BBE7C1E, 0xF1D3B55B, 0xE2712D2C, 0xD69685B5, 0xC5341DC2,
|
||||
0x224D173F, 0x31EF8F48, 0x050827D1, 0x16AABFA6, 0x6CC776E3, 0x7F65EE94, 0x4B82460D, 0x5820DE7A,
|
||||
0xFBC3FAF9, 0xE861628E, 0xDC86CA17, 0xCF245260, 0xB5499B25, 0xA6EB0352, 0x920CABCB, 0x81AE33BC,
|
||||
0x66D73941, 0x7575A136, 0x419209AF, 0x523091D8, 0x285D589D, 0x3BFFC0EA, 0x0F186873, 0x1CBAF004,
|
||||
0xC4060B78, 0xD7A4930F, 0xE3433B96, 0xF0E1A3E1, 0x8A8C6AA4, 0x992EF2D3, 0xADC95A4A, 0xBE6BC23D,
|
||||
0x5912C8C0, 0x4AB050B7, 0x7E57F82E, 0x6DF56059, 0x1798A91C, 0x043A316B, 0x30DD99F2, 0x237F0185,
|
||||
0x844819FB, 0x97EA818C, 0xA30D2915, 0xB0AFB162, 0xCAC27827, 0xD960E050, 0xED8748C9, 0xFE25D0BE,
|
||||
0x195CDA43, 0x0AFE4234, 0x3E19EAAD, 0x2DBB72DA, 0x57D6BB9F, 0x447423E8, 0x70938B71, 0x63311306,
|
||||
0xBB8DE87A, 0xA82F700D, 0x9CC8D894, 0x8F6A40E3, 0xF50789A6, 0xE6A511D1, 0xD242B948, 0xC1E0213F,
|
||||
0x26992BC2, 0x353BB3B5, 0x01DC1B2C, 0x127E835B, 0x68134A1E, 0x7BB1D269, 0x4F567AF0, 0x5CF4E287,
|
||||
0x04D43CFD, 0x1776A48A, 0x23910C13, 0x30339464, 0x4A5E5D21, 0x59FCC556, 0x6D1B6DCF, 0x7EB9F5B8,
|
||||
0x99C0FF45, 0x8A626732, 0xBE85CFAB, 0xAD2757DC, 0xD74A9E99, 0xC4E806EE, 0xF00FAE77, 0xE3AD3600,
|
||||
0x3B11CD7C, 0x28B3550B, 0x1C54FD92, 0x0FF665E5, 0x759BACA0, 0x663934D7, 0x52DE9C4E, 0x417C0439,
|
||||
0xA6050EC4, 0xB5A796B3, 0x81403E2A, 0x92E2A65D, 0xE88F6F18, 0xFB2DF76F, 0xCFCA5FF6, 0xDC68C781,
|
||||
0x7B5FDFFF, 0x68FD4788, 0x5C1AEF11, 0x4FB87766, 0x35D5BE23, 0x26772654, 0x12908ECD, 0x013216BA,
|
||||
0xE64B1C47, 0xF5E98430, 0xC10E2CA9, 0xD2ACB4DE, 0xA8C17D9B, 0xBB63E5EC, 0x8F844D75, 0x9C26D502,
|
||||
0x449A2E7E, 0x5738B609, 0x63DF1E90, 0x707D86E7, 0x0A104FA2, 0x19B2D7D5, 0x2D557F4C, 0x3EF7E73B,
|
||||
0xD98EEDC6, 0xCA2C75B1, 0xFECBDD28, 0xED69455F, 0x97048C1A, 0x84A6146D, 0xB041BCF4, 0xA3E32483
|
||||
};
|
||||
|
||||
/*
|
||||
* end of the CRC lookup table crc_tableil8_o40
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* The following CRC lookup table was generated automagically using the
|
||||
* following model parameters:
|
||||
*
|
||||
* Generator Polynomial = ................. 0x1EDC6F41
|
||||
* Generator Polynomial Length = .......... 32 bits
|
||||
* Reflected Bits = ....................... TRUE
|
||||
* Table Generation Offset = .............. 32 bits
|
||||
* Number of Slices = ..................... 8 slices
|
||||
* Slice Lengths = ........................ 8 8 8 8 8 8 8 8
|
||||
* Directory Name = ....................... .\
|
||||
* File Name = ............................ 8x256_tables.c
|
||||
*/
|
||||
|
||||
static const uint32_t sctp_crc_tableil8_o48[256] =
|
||||
{
|
||||
0x00000000, 0xA541927E, 0x4F6F520D, 0xEA2EC073, 0x9EDEA41A, 0x3B9F3664, 0xD1B1F617, 0x74F06469,
|
||||
0x38513EC5, 0x9D10ACBB, 0x773E6CC8, 0xD27FFEB6, 0xA68F9ADF, 0x03CE08A1, 0xE9E0C8D2, 0x4CA15AAC,
|
||||
0x70A27D8A, 0xD5E3EFF4, 0x3FCD2F87, 0x9A8CBDF9, 0xEE7CD990, 0x4B3D4BEE, 0xA1138B9D, 0x045219E3,
|
||||
0x48F3434F, 0xEDB2D131, 0x079C1142, 0xA2DD833C, 0xD62DE755, 0x736C752B, 0x9942B558, 0x3C032726,
|
||||
0xE144FB14, 0x4405696A, 0xAE2BA919, 0x0B6A3B67, 0x7F9A5F0E, 0xDADBCD70, 0x30F50D03, 0x95B49F7D,
|
||||
0xD915C5D1, 0x7C5457AF, 0x967A97DC, 0x333B05A2, 0x47CB61CB, 0xE28AF3B5, 0x08A433C6, 0xADE5A1B8,
|
||||
0x91E6869E, 0x34A714E0, 0xDE89D493, 0x7BC846ED, 0x0F382284, 0xAA79B0FA, 0x40577089, 0xE516E2F7,
|
||||
0xA9B7B85B, 0x0CF62A25, 0xE6D8EA56, 0x43997828, 0x37691C41, 0x92288E3F, 0x78064E4C, 0xDD47DC32,
|
||||
0xC76580D9, 0x622412A7, 0x880AD2D4, 0x2D4B40AA, 0x59BB24C3, 0xFCFAB6BD, 0x16D476CE, 0xB395E4B0,
|
||||
0xFF34BE1C, 0x5A752C62, 0xB05BEC11, 0x151A7E6F, 0x61EA1A06, 0xC4AB8878, 0x2E85480B, 0x8BC4DA75,
|
||||
0xB7C7FD53, 0x12866F2D, 0xF8A8AF5E, 0x5DE93D20, 0x29195949, 0x8C58CB37, 0x66760B44, 0xC337993A,
|
||||
0x8F96C396, 0x2AD751E8, 0xC0F9919B, 0x65B803E5, 0x1148678C, 0xB409F5F2, 0x5E273581, 0xFB66A7FF,
|
||||
0x26217BCD, 0x8360E9B3, 0x694E29C0, 0xCC0FBBBE, 0xB8FFDFD7, 0x1DBE4DA9, 0xF7908DDA, 0x52D11FA4,
|
||||
0x1E704508, 0xBB31D776, 0x511F1705, 0xF45E857B, 0x80AEE112, 0x25EF736C, 0xCFC1B31F, 0x6A802161,
|
||||
0x56830647, 0xF3C29439, 0x19EC544A, 0xBCADC634, 0xC85DA25D, 0x6D1C3023, 0x8732F050, 0x2273622E,
|
||||
0x6ED23882, 0xCB93AAFC, 0x21BD6A8F, 0x84FCF8F1, 0xF00C9C98, 0x554D0EE6, 0xBF63CE95, 0x1A225CEB,
|
||||
0x8B277743, 0x2E66E53D, 0xC448254E, 0x6109B730, 0x15F9D359, 0xB0B84127, 0x5A968154, 0xFFD7132A,
|
||||
0xB3764986, 0x1637DBF8, 0xFC191B8B, 0x595889F5, 0x2DA8ED9C, 0x88E97FE2, 0x62C7BF91, 0xC7862DEF,
|
||||
0xFB850AC9, 0x5EC498B7, 0xB4EA58C4, 0x11ABCABA, 0x655BAED3, 0xC01A3CAD, 0x2A34FCDE, 0x8F756EA0,
|
||||
0xC3D4340C, 0x6695A672, 0x8CBB6601, 0x29FAF47F, 0x5D0A9016, 0xF84B0268, 0x1265C21B, 0xB7245065,
|
||||
0x6A638C57, 0xCF221E29, 0x250CDE5A, 0x804D4C24, 0xF4BD284D, 0x51FCBA33, 0xBBD27A40, 0x1E93E83E,
|
||||
0x5232B292, 0xF77320EC, 0x1D5DE09F, 0xB81C72E1, 0xCCEC1688, 0x69AD84F6, 0x83834485, 0x26C2D6FB,
|
||||
0x1AC1F1DD, 0xBF8063A3, 0x55AEA3D0, 0xF0EF31AE, 0x841F55C7, 0x215EC7B9, 0xCB7007CA, 0x6E3195B4,
|
||||
0x2290CF18, 0x87D15D66, 0x6DFF9D15, 0xC8BE0F6B, 0xBC4E6B02, 0x190FF97C, 0xF321390F, 0x5660AB71,
|
||||
0x4C42F79A, 0xE90365E4, 0x032DA597, 0xA66C37E9, 0xD29C5380, 0x77DDC1FE, 0x9DF3018D, 0x38B293F3,
|
||||
0x7413C95F, 0xD1525B21, 0x3B7C9B52, 0x9E3D092C, 0xEACD6D45, 0x4F8CFF3B, 0xA5A23F48, 0x00E3AD36,
|
||||
0x3CE08A10, 0x99A1186E, 0x738FD81D, 0xD6CE4A63, 0xA23E2E0A, 0x077FBC74, 0xED517C07, 0x4810EE79,
|
||||
0x04B1B4D5, 0xA1F026AB, 0x4BDEE6D8, 0xEE9F74A6, 0x9A6F10CF, 0x3F2E82B1, 0xD50042C2, 0x7041D0BC,
|
||||
0xAD060C8E, 0x08479EF0, 0xE2695E83, 0x4728CCFD, 0x33D8A894, 0x96993AEA, 0x7CB7FA99, 0xD9F668E7,
|
||||
0x9557324B, 0x3016A035, 0xDA386046, 0x7F79F238, 0x0B899651, 0xAEC8042F, 0x44E6C45C, 0xE1A75622,
|
||||
0xDDA47104, 0x78E5E37A, 0x92CB2309, 0x378AB177, 0x437AD51E, 0xE63B4760, 0x0C158713, 0xA954156D,
|
||||
0xE5F54FC1, 0x40B4DDBF, 0xAA9A1DCC, 0x0FDB8FB2, 0x7B2BEBDB, 0xDE6A79A5, 0x3444B9D6, 0x91052BA8
|
||||
};
|
||||
|
||||
/*
|
||||
* end of the CRC lookup table crc_tableil8_o48
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* The following CRC lookup table was generated automagically using the
|
||||
* following model parameters:
|
||||
*
|
||||
* Generator Polynomial = ................. 0x1EDC6F41
|
||||
* Generator Polynomial Length = .......... 32 bits
|
||||
* Reflected Bits = ....................... TRUE
|
||||
* Table Generation Offset = .............. 32 bits
|
||||
* Number of Slices = ..................... 8 slices
|
||||
* Slice Lengths = ........................ 8 8 8 8 8 8 8 8
|
||||
* Directory Name = ....................... .\
|
||||
* File Name = ............................ 8x256_tables.c
|
||||
*/
|
||||
|
||||
static const uint32_t sctp_crc_tableil8_o56[256] =
|
||||
{
|
||||
0x00000000, 0xDD45AAB8, 0xBF672381, 0x62228939, 0x7B2231F3, 0xA6679B4B, 0xC4451272, 0x1900B8CA,
|
||||
0xF64463E6, 0x2B01C95E, 0x49234067, 0x9466EADF, 0x8D665215, 0x5023F8AD, 0x32017194, 0xEF44DB2C,
|
||||
0xE964B13D, 0x34211B85, 0x560392BC, 0x8B463804, 0x924680CE, 0x4F032A76, 0x2D21A34F, 0xF06409F7,
|
||||
0x1F20D2DB, 0xC2657863, 0xA047F15A, 0x7D025BE2, 0x6402E328, 0xB9474990, 0xDB65C0A9, 0x06206A11,
|
||||
0xD725148B, 0x0A60BE33, 0x6842370A, 0xB5079DB2, 0xAC072578, 0x71428FC0, 0x136006F9, 0xCE25AC41,
|
||||
0x2161776D, 0xFC24DDD5, 0x9E0654EC, 0x4343FE54, 0x5A43469E, 0x8706EC26, 0xE524651F, 0x3861CFA7,
|
||||
0x3E41A5B6, 0xE3040F0E, 0x81268637, 0x5C632C8F, 0x45639445, 0x98263EFD, 0xFA04B7C4, 0x27411D7C,
|
||||
0xC805C650, 0x15406CE8, 0x7762E5D1, 0xAA274F69, 0xB327F7A3, 0x6E625D1B, 0x0C40D422, 0xD1057E9A,
|
||||
0xABA65FE7, 0x76E3F55F, 0x14C17C66, 0xC984D6DE, 0xD0846E14, 0x0DC1C4AC, 0x6FE34D95, 0xB2A6E72D,
|
||||
0x5DE23C01, 0x80A796B9, 0xE2851F80, 0x3FC0B538, 0x26C00DF2, 0xFB85A74A, 0x99A72E73, 0x44E284CB,
|
||||
0x42C2EEDA, 0x9F874462, 0xFDA5CD5B, 0x20E067E3, 0x39E0DF29, 0xE4A57591, 0x8687FCA8, 0x5BC25610,
|
||||
0xB4868D3C, 0x69C32784, 0x0BE1AEBD, 0xD6A40405, 0xCFA4BCCF, 0x12E11677, 0x70C39F4E, 0xAD8635F6,
|
||||
0x7C834B6C, 0xA1C6E1D4, 0xC3E468ED, 0x1EA1C255, 0x07A17A9F, 0xDAE4D027, 0xB8C6591E, 0x6583F3A6,
|
||||
0x8AC7288A, 0x57828232, 0x35A00B0B, 0xE8E5A1B3, 0xF1E51979, 0x2CA0B3C1, 0x4E823AF8, 0x93C79040,
|
||||
0x95E7FA51, 0x48A250E9, 0x2A80D9D0, 0xF7C57368, 0xEEC5CBA2, 0x3380611A, 0x51A2E823, 0x8CE7429B,
|
||||
0x63A399B7, 0xBEE6330F, 0xDCC4BA36, 0x0181108E, 0x1881A844, 0xC5C402FC, 0xA7E68BC5, 0x7AA3217D,
|
||||
0x52A0C93F, 0x8FE56387, 0xEDC7EABE, 0x30824006, 0x2982F8CC, 0xF4C75274, 0x96E5DB4D, 0x4BA071F5,
|
||||
0xA4E4AAD9, 0x79A10061, 0x1B838958, 0xC6C623E0, 0xDFC69B2A, 0x02833192, 0x60A1B8AB, 0xBDE41213,
|
||||
0xBBC47802, 0x6681D2BA, 0x04A35B83, 0xD9E6F13B, 0xC0E649F1, 0x1DA3E349, 0x7F816A70, 0xA2C4C0C8,
|
||||
0x4D801BE4, 0x90C5B15C, 0xF2E73865, 0x2FA292DD, 0x36A22A17, 0xEBE780AF, 0x89C50996, 0x5480A32E,
|
||||
0x8585DDB4, 0x58C0770C, 0x3AE2FE35, 0xE7A7548D, 0xFEA7EC47, 0x23E246FF, 0x41C0CFC6, 0x9C85657E,
|
||||
0x73C1BE52, 0xAE8414EA, 0xCCA69DD3, 0x11E3376B, 0x08E38FA1, 0xD5A62519, 0xB784AC20, 0x6AC10698,
|
||||
0x6CE16C89, 0xB1A4C631, 0xD3864F08, 0x0EC3E5B0, 0x17C35D7A, 0xCA86F7C2, 0xA8A47EFB, 0x75E1D443,
|
||||
0x9AA50F6F, 0x47E0A5D7, 0x25C22CEE, 0xF8878656, 0xE1873E9C, 0x3CC29424, 0x5EE01D1D, 0x83A5B7A5,
|
||||
0xF90696D8, 0x24433C60, 0x4661B559, 0x9B241FE1, 0x8224A72B, 0x5F610D93, 0x3D4384AA, 0xE0062E12,
|
||||
0x0F42F53E, 0xD2075F86, 0xB025D6BF, 0x6D607C07, 0x7460C4CD, 0xA9256E75, 0xCB07E74C, 0x16424DF4,
|
||||
0x106227E5, 0xCD278D5D, 0xAF050464, 0x7240AEDC, 0x6B401616, 0xB605BCAE, 0xD4273597, 0x09629F2F,
|
||||
0xE6264403, 0x3B63EEBB, 0x59416782, 0x8404CD3A, 0x9D0475F0, 0x4041DF48, 0x22635671, 0xFF26FCC9,
|
||||
0x2E238253, 0xF36628EB, 0x9144A1D2, 0x4C010B6A, 0x5501B3A0, 0x88441918, 0xEA669021, 0x37233A99,
|
||||
0xD867E1B5, 0x05224B0D, 0x6700C234, 0xBA45688C, 0xA345D046, 0x7E007AFE, 0x1C22F3C7, 0xC167597F,
|
||||
0xC747336E, 0x1A0299D6, 0x782010EF, 0xA565BA57, 0xBC65029D, 0x6120A825, 0x0302211C, 0xDE478BA4,
|
||||
0x31035088, 0xEC46FA30, 0x8E647309, 0x5321D9B1, 0x4A21617B, 0x9764CBC3, 0xF54642FA, 0x2803E842
|
||||
};
|
||||
|
||||
/*
|
||||
* end of the CRC lookup table crc_tableil8_o56
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* The following CRC lookup table was generated automagically using the
|
||||
* following model parameters:
|
||||
*
|
||||
* Generator Polynomial = ................. 0x1EDC6F41
|
||||
* Generator Polynomial Length = .......... 32 bits
|
||||
* Reflected Bits = ....................... TRUE
|
||||
* Table Generation Offset = .............. 32 bits
|
||||
* Number of Slices = ..................... 8 slices
|
||||
* Slice Lengths = ........................ 8 8 8 8 8 8 8 8
|
||||
* Directory Name = ....................... .\
|
||||
* File Name = ............................ 8x256_tables.c
|
||||
*/
|
||||
|
||||
static const uint32_t sctp_crc_tableil8_o64[256] =
|
||||
{
|
||||
0x00000000, 0x38116FAC, 0x7022DF58, 0x4833B0F4, 0xE045BEB0, 0xD854D11C, 0x906761E8, 0xA8760E44,
|
||||
0xC5670B91, 0xFD76643D, 0xB545D4C9, 0x8D54BB65, 0x2522B521, 0x1D33DA8D, 0x55006A79, 0x6D1105D5,
|
||||
0x8F2261D3, 0xB7330E7F, 0xFF00BE8B, 0xC711D127, 0x6F67DF63, 0x5776B0CF, 0x1F45003B, 0x27546F97,
|
||||
0x4A456A42, 0x725405EE, 0x3A67B51A, 0x0276DAB6, 0xAA00D4F2, 0x9211BB5E, 0xDA220BAA, 0xE2336406,
|
||||
0x1BA8B557, 0x23B9DAFB, 0x6B8A6A0F, 0x539B05A3, 0xFBED0BE7, 0xC3FC644B, 0x8BCFD4BF, 0xB3DEBB13,
|
||||
0xDECFBEC6, 0xE6DED16A, 0xAEED619E, 0x96FC0E32, 0x3E8A0076, 0x069B6FDA, 0x4EA8DF2E, 0x76B9B082,
|
||||
0x948AD484, 0xAC9BBB28, 0xE4A80BDC, 0xDCB96470, 0x74CF6A34, 0x4CDE0598, 0x04EDB56C, 0x3CFCDAC0,
|
||||
0x51EDDF15, 0x69FCB0B9, 0x21CF004D, 0x19DE6FE1, 0xB1A861A5, 0x89B90E09, 0xC18ABEFD, 0xF99BD151,
|
||||
0x37516AAE, 0x0F400502, 0x4773B5F6, 0x7F62DA5A, 0xD714D41E, 0xEF05BBB2, 0xA7360B46, 0x9F2764EA,
|
||||
0xF236613F, 0xCA270E93, 0x8214BE67, 0xBA05D1CB, 0x1273DF8F, 0x2A62B023, 0x625100D7, 0x5A406F7B,
|
||||
0xB8730B7D, 0x806264D1, 0xC851D425, 0xF040BB89, 0x5836B5CD, 0x6027DA61, 0x28146A95, 0x10050539,
|
||||
0x7D1400EC, 0x45056F40, 0x0D36DFB4, 0x3527B018, 0x9D51BE5C, 0xA540D1F0, 0xED736104, 0xD5620EA8,
|
||||
0x2CF9DFF9, 0x14E8B055, 0x5CDB00A1, 0x64CA6F0D, 0xCCBC6149, 0xF4AD0EE5, 0xBC9EBE11, 0x848FD1BD,
|
||||
0xE99ED468, 0xD18FBBC4, 0x99BC0B30, 0xA1AD649C, 0x09DB6AD8, 0x31CA0574, 0x79F9B580, 0x41E8DA2C,
|
||||
0xA3DBBE2A, 0x9BCAD186, 0xD3F96172, 0xEBE80EDE, 0x439E009A, 0x7B8F6F36, 0x33BCDFC2, 0x0BADB06E,
|
||||
0x66BCB5BB, 0x5EADDA17, 0x169E6AE3, 0x2E8F054F, 0x86F90B0B, 0xBEE864A7, 0xF6DBD453, 0xCECABBFF,
|
||||
0x6EA2D55C, 0x56B3BAF0, 0x1E800A04, 0x269165A8, 0x8EE76BEC, 0xB6F60440, 0xFEC5B4B4, 0xC6D4DB18,
|
||||
0xABC5DECD, 0x93D4B161, 0xDBE70195, 0xE3F66E39, 0x4B80607D, 0x73910FD1, 0x3BA2BF25, 0x03B3D089,
|
||||
0xE180B48F, 0xD991DB23, 0x91A26BD7, 0xA9B3047B, 0x01C50A3F, 0x39D46593, 0x71E7D567, 0x49F6BACB,
|
||||
0x24E7BF1E, 0x1CF6D0B2, 0x54C56046, 0x6CD40FEA, 0xC4A201AE, 0xFCB36E02, 0xB480DEF6, 0x8C91B15A,
|
||||
0x750A600B, 0x4D1B0FA7, 0x0528BF53, 0x3D39D0FF, 0x954FDEBB, 0xAD5EB117, 0xE56D01E3, 0xDD7C6E4F,
|
||||
0xB06D6B9A, 0x887C0436, 0xC04FB4C2, 0xF85EDB6E, 0x5028D52A, 0x6839BA86, 0x200A0A72, 0x181B65DE,
|
||||
0xFA2801D8, 0xC2396E74, 0x8A0ADE80, 0xB21BB12C, 0x1A6DBF68, 0x227CD0C4, 0x6A4F6030, 0x525E0F9C,
|
||||
0x3F4F0A49, 0x075E65E5, 0x4F6DD511, 0x777CBABD, 0xDF0AB4F9, 0xE71BDB55, 0xAF286BA1, 0x9739040D,
|
||||
0x59F3BFF2, 0x61E2D05E, 0x29D160AA, 0x11C00F06, 0xB9B60142, 0x81A76EEE, 0xC994DE1A, 0xF185B1B6,
|
||||
0x9C94B463, 0xA485DBCF, 0xECB66B3B, 0xD4A70497, 0x7CD10AD3, 0x44C0657F, 0x0CF3D58B, 0x34E2BA27,
|
||||
0xD6D1DE21, 0xEEC0B18D, 0xA6F30179, 0x9EE26ED5, 0x36946091, 0x0E850F3D, 0x46B6BFC9, 0x7EA7D065,
|
||||
0x13B6D5B0, 0x2BA7BA1C, 0x63940AE8, 0x5B856544, 0xF3F36B00, 0xCBE204AC, 0x83D1B458, 0xBBC0DBF4,
|
||||
0x425B0AA5, 0x7A4A6509, 0x3279D5FD, 0x0A68BA51, 0xA21EB415, 0x9A0FDBB9, 0xD23C6B4D, 0xEA2D04E1,
|
||||
0x873C0134, 0xBF2D6E98, 0xF71EDE6C, 0xCF0FB1C0, 0x6779BF84, 0x5F68D028, 0x175B60DC, 0x2F4A0F70,
|
||||
0xCD796B76, 0xF56804DA, 0xBD5BB42E, 0x854ADB82, 0x2D3CD5C6, 0x152DBA6A, 0x5D1E0A9E, 0x650F6532,
|
||||
0x081E60E7, 0x300F0F4B, 0x783CBFBF, 0x402DD013, 0xE85BDE57, 0xD04AB1FB, 0x9879010F, 0xA0686EA3
|
||||
};
|
||||
|
||||
/*
|
||||
* end of the CRC lookup table crc_tableil8_o64
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* The following CRC lookup table was generated automagically using the
|
||||
* following model parameters:
|
||||
*
|
||||
* Generator Polynomial = ................. 0x1EDC6F41
|
||||
* Generator Polynomial Length = .......... 32 bits
|
||||
* Reflected Bits = ....................... TRUE
|
||||
* Table Generation Offset = .............. 32 bits
|
||||
* Number of Slices = ..................... 8 slices
|
||||
* Slice Lengths = ........................ 8 8 8 8 8 8 8 8
|
||||
* Directory Name = ....................... .\
|
||||
* File Name = ............................ 8x256_tables.c
|
||||
*/
|
||||
|
||||
static const uint32_t sctp_crc_tableil8_o72[256] =
|
||||
{
|
||||
0x00000000, 0xEF306B19, 0xDB8CA0C3, 0x34BCCBDA, 0xB2F53777, 0x5DC55C6E, 0x697997B4, 0x8649FCAD,
|
||||
0x6006181F, 0x8F367306, 0xBB8AB8DC, 0x54BAD3C5, 0xD2F32F68, 0x3DC34471, 0x097F8FAB, 0xE64FE4B2,
|
||||
0xC00C303E, 0x2F3C5B27, 0x1B8090FD, 0xF4B0FBE4, 0x72F90749, 0x9DC96C50, 0xA975A78A, 0x4645CC93,
|
||||
0xA00A2821, 0x4F3A4338, 0x7B8688E2, 0x94B6E3FB, 0x12FF1F56, 0xFDCF744F, 0xC973BF95, 0x2643D48C,
|
||||
0x85F4168D, 0x6AC47D94, 0x5E78B64E, 0xB148DD57, 0x370121FA, 0xD8314AE3, 0xEC8D8139, 0x03BDEA20,
|
||||
0xE5F20E92, 0x0AC2658B, 0x3E7EAE51, 0xD14EC548, 0x570739E5, 0xB83752FC, 0x8C8B9926, 0x63BBF23F,
|
||||
0x45F826B3, 0xAAC84DAA, 0x9E748670, 0x7144ED69, 0xF70D11C4, 0x183D7ADD, 0x2C81B107, 0xC3B1DA1E,
|
||||
0x25FE3EAC, 0xCACE55B5, 0xFE729E6F, 0x1142F576, 0x970B09DB, 0x783B62C2, 0x4C87A918, 0xA3B7C201,
|
||||
0x0E045BEB, 0xE13430F2, 0xD588FB28, 0x3AB89031, 0xBCF16C9C, 0x53C10785, 0x677DCC5F, 0x884DA746,
|
||||
0x6E0243F4, 0x813228ED, 0xB58EE337, 0x5ABE882E, 0xDCF77483, 0x33C71F9A, 0x077BD440, 0xE84BBF59,
|
||||
0xCE086BD5, 0x213800CC, 0x1584CB16, 0xFAB4A00F, 0x7CFD5CA2, 0x93CD37BB, 0xA771FC61, 0x48419778,
|
||||
0xAE0E73CA, 0x413E18D3, 0x7582D309, 0x9AB2B810, 0x1CFB44BD, 0xF3CB2FA4, 0xC777E47E, 0x28478F67,
|
||||
0x8BF04D66, 0x64C0267F, 0x507CEDA5, 0xBF4C86BC, 0x39057A11, 0xD6351108, 0xE289DAD2, 0x0DB9B1CB,
|
||||
0xEBF65579, 0x04C63E60, 0x307AF5BA, 0xDF4A9EA3, 0x5903620E, 0xB6330917, 0x828FC2CD, 0x6DBFA9D4,
|
||||
0x4BFC7D58, 0xA4CC1641, 0x9070DD9B, 0x7F40B682, 0xF9094A2F, 0x16392136, 0x2285EAEC, 0xCDB581F5,
|
||||
0x2BFA6547, 0xC4CA0E5E, 0xF076C584, 0x1F46AE9D, 0x990F5230, 0x763F3929, 0x4283F2F3, 0xADB399EA,
|
||||
0x1C08B7D6, 0xF338DCCF, 0xC7841715, 0x28B47C0C, 0xAEFD80A1, 0x41CDEBB8, 0x75712062, 0x9A414B7B,
|
||||
0x7C0EAFC9, 0x933EC4D0, 0xA7820F0A, 0x48B26413, 0xCEFB98BE, 0x21CBF3A7, 0x1577387D, 0xFA475364,
|
||||
0xDC0487E8, 0x3334ECF1, 0x0788272B, 0xE8B84C32, 0x6EF1B09F, 0x81C1DB86, 0xB57D105C, 0x5A4D7B45,
|
||||
0xBC029FF7, 0x5332F4EE, 0x678E3F34, 0x88BE542D, 0x0EF7A880, 0xE1C7C399, 0xD57B0843, 0x3A4B635A,
|
||||
0x99FCA15B, 0x76CCCA42, 0x42700198, 0xAD406A81, 0x2B09962C, 0xC439FD35, 0xF08536EF, 0x1FB55DF6,
|
||||
0xF9FAB944, 0x16CAD25D, 0x22761987, 0xCD46729E, 0x4B0F8E33, 0xA43FE52A, 0x90832EF0, 0x7FB345E9,
|
||||
0x59F09165, 0xB6C0FA7C, 0x827C31A6, 0x6D4C5ABF, 0xEB05A612, 0x0435CD0B, 0x308906D1, 0xDFB96DC8,
|
||||
0x39F6897A, 0xD6C6E263, 0xE27A29B9, 0x0D4A42A0, 0x8B03BE0D, 0x6433D514, 0x508F1ECE, 0xBFBF75D7,
|
||||
0x120CEC3D, 0xFD3C8724, 0xC9804CFE, 0x26B027E7, 0xA0F9DB4A, 0x4FC9B053, 0x7B757B89, 0x94451090,
|
||||
0x720AF422, 0x9D3A9F3B, 0xA98654E1, 0x46B63FF8, 0xC0FFC355, 0x2FCFA84C, 0x1B736396, 0xF443088F,
|
||||
0xD200DC03, 0x3D30B71A, 0x098C7CC0, 0xE6BC17D9, 0x60F5EB74, 0x8FC5806D, 0xBB794BB7, 0x544920AE,
|
||||
0xB206C41C, 0x5D36AF05, 0x698A64DF, 0x86BA0FC6, 0x00F3F36B, 0xEFC39872, 0xDB7F53A8, 0x344F38B1,
|
||||
0x97F8FAB0, 0x78C891A9, 0x4C745A73, 0xA344316A, 0x250DCDC7, 0xCA3DA6DE, 0xFE816D04, 0x11B1061D,
|
||||
0xF7FEE2AF, 0x18CE89B6, 0x2C72426C, 0xC3422975, 0x450BD5D8, 0xAA3BBEC1, 0x9E87751B, 0x71B71E02,
|
||||
0x57F4CA8E, 0xB8C4A197, 0x8C786A4D, 0x63480154, 0xE501FDF9, 0x0A3196E0, 0x3E8D5D3A, 0xD1BD3623,
|
||||
0x37F2D291, 0xD8C2B988, 0xEC7E7252, 0x034E194B, 0x8507E5E6, 0x6A378EFF, 0x5E8B4525, 0xB1BB2E3C
|
||||
};
|
||||
|
||||
/*
|
||||
* end of the CRC lookup table crc_tableil8_o72
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* The following CRC lookup table was generated automagically using the
|
||||
* following model parameters:
|
||||
*
|
||||
* Generator Polynomial = ................. 0x1EDC6F41
|
||||
* Generator Polynomial Length = .......... 32 bits
|
||||
* Reflected Bits = ....................... TRUE
|
||||
* Table Generation Offset = .............. 32 bits
|
||||
* Number of Slices = ..................... 8 slices
|
||||
* Slice Lengths = ........................ 8 8 8 8 8 8 8 8
|
||||
* Directory Name = ....................... .\
|
||||
* File Name = ............................ 8x256_tables.c
|
||||
*/
|
||||
|
||||
static const uint32_t sctp_crc_tableil8_o80[256] =
|
||||
{
|
||||
0x00000000, 0x68032CC8, 0xD0065990, 0xB8057558, 0xA5E0C5D1, 0xCDE3E919, 0x75E69C41, 0x1DE5B089,
|
||||
0x4E2DFD53, 0x262ED19B, 0x9E2BA4C3, 0xF628880B, 0xEBCD3882, 0x83CE144A, 0x3BCB6112, 0x53C84DDA,
|
||||
0x9C5BFAA6, 0xF458D66E, 0x4C5DA336, 0x245E8FFE, 0x39BB3F77, 0x51B813BF, 0xE9BD66E7, 0x81BE4A2F,
|
||||
0xD27607F5, 0xBA752B3D, 0x02705E65, 0x6A7372AD, 0x7796C224, 0x1F95EEEC, 0xA7909BB4, 0xCF93B77C,
|
||||
0x3D5B83BD, 0x5558AF75, 0xED5DDA2D, 0x855EF6E5, 0x98BB466C, 0xF0B86AA4, 0x48BD1FFC, 0x20BE3334,
|
||||
0x73767EEE, 0x1B755226, 0xA370277E, 0xCB730BB6, 0xD696BB3F, 0xBE9597F7, 0x0690E2AF, 0x6E93CE67,
|
||||
0xA100791B, 0xC90355D3, 0x7106208B, 0x19050C43, 0x04E0BCCA, 0x6CE39002, 0xD4E6E55A, 0xBCE5C992,
|
||||
0xEF2D8448, 0x872EA880, 0x3F2BDDD8, 0x5728F110, 0x4ACD4199, 0x22CE6D51, 0x9ACB1809, 0xF2C834C1,
|
||||
0x7AB7077A, 0x12B42BB2, 0xAAB15EEA, 0xC2B27222, 0xDF57C2AB, 0xB754EE63, 0x0F519B3B, 0x6752B7F3,
|
||||
0x349AFA29, 0x5C99D6E1, 0xE49CA3B9, 0x8C9F8F71, 0x917A3FF8, 0xF9791330, 0x417C6668, 0x297F4AA0,
|
||||
0xE6ECFDDC, 0x8EEFD114, 0x36EAA44C, 0x5EE98884, 0x430C380D, 0x2B0F14C5, 0x930A619D, 0xFB094D55,
|
||||
0xA8C1008F, 0xC0C22C47, 0x78C7591F, 0x10C475D7, 0x0D21C55E, 0x6522E996, 0xDD279CCE, 0xB524B006,
|
||||
0x47EC84C7, 0x2FEFA80F, 0x97EADD57, 0xFFE9F19F, 0xE20C4116, 0x8A0F6DDE, 0x320A1886, 0x5A09344E,
|
||||
0x09C17994, 0x61C2555C, 0xD9C72004, 0xB1C40CCC, 0xAC21BC45, 0xC422908D, 0x7C27E5D5, 0x1424C91D,
|
||||
0xDBB77E61, 0xB3B452A9, 0x0BB127F1, 0x63B20B39, 0x7E57BBB0, 0x16549778, 0xAE51E220, 0xC652CEE8,
|
||||
0x959A8332, 0xFD99AFFA, 0x459CDAA2, 0x2D9FF66A, 0x307A46E3, 0x58796A2B, 0xE07C1F73, 0x887F33BB,
|
||||
0xF56E0EF4, 0x9D6D223C, 0x25685764, 0x4D6B7BAC, 0x508ECB25, 0x388DE7ED, 0x808892B5, 0xE88BBE7D,
|
||||
0xBB43F3A7, 0xD340DF6F, 0x6B45AA37, 0x034686FF, 0x1EA33676, 0x76A01ABE, 0xCEA56FE6, 0xA6A6432E,
|
||||
0x6935F452, 0x0136D89A, 0xB933ADC2, 0xD130810A, 0xCCD53183, 0xA4D61D4B, 0x1CD36813, 0x74D044DB,
|
||||
0x27180901, 0x4F1B25C9, 0xF71E5091, 0x9F1D7C59, 0x82F8CCD0, 0xEAFBE018, 0x52FE9540, 0x3AFDB988,
|
||||
0xC8358D49, 0xA036A181, 0x1833D4D9, 0x7030F811, 0x6DD54898, 0x05D66450, 0xBDD31108, 0xD5D03DC0,
|
||||
0x8618701A, 0xEE1B5CD2, 0x561E298A, 0x3E1D0542, 0x23F8B5CB, 0x4BFB9903, 0xF3FEEC5B, 0x9BFDC093,
|
||||
0x546E77EF, 0x3C6D5B27, 0x84682E7F, 0xEC6B02B7, 0xF18EB23E, 0x998D9EF6, 0x2188EBAE, 0x498BC766,
|
||||
0x1A438ABC, 0x7240A674, 0xCA45D32C, 0xA246FFE4, 0xBFA34F6D, 0xD7A063A5, 0x6FA516FD, 0x07A63A35,
|
||||
0x8FD9098E, 0xE7DA2546, 0x5FDF501E, 0x37DC7CD6, 0x2A39CC5F, 0x423AE097, 0xFA3F95CF, 0x923CB907,
|
||||
0xC1F4F4DD, 0xA9F7D815, 0x11F2AD4D, 0x79F18185, 0x6414310C, 0x0C171DC4, 0xB412689C, 0xDC114454,
|
||||
0x1382F328, 0x7B81DFE0, 0xC384AAB8, 0xAB878670, 0xB66236F9, 0xDE611A31, 0x66646F69, 0x0E6743A1,
|
||||
0x5DAF0E7B, 0x35AC22B3, 0x8DA957EB, 0xE5AA7B23, 0xF84FCBAA, 0x904CE762, 0x2849923A, 0x404ABEF2,
|
||||
0xB2828A33, 0xDA81A6FB, 0x6284D3A3, 0x0A87FF6B, 0x17624FE2, 0x7F61632A, 0xC7641672, 0xAF673ABA,
|
||||
0xFCAF7760, 0x94AC5BA8, 0x2CA92EF0, 0x44AA0238, 0x594FB2B1, 0x314C9E79, 0x8949EB21, 0xE14AC7E9,
|
||||
0x2ED97095, 0x46DA5C5D, 0xFEDF2905, 0x96DC05CD, 0x8B39B544, 0xE33A998C, 0x5B3FECD4, 0x333CC01C,
|
||||
0x60F48DC6, 0x08F7A10E, 0xB0F2D456, 0xD8F1F89E, 0xC5144817, 0xAD1764DF, 0x15121187, 0x7D113D4F
|
||||
};
|
||||
|
||||
/*
|
||||
* end of the CRC lookup table crc_tableil8_o80
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* The following CRC lookup table was generated automagically using the
|
||||
* following model parameters:
|
||||
*
|
||||
* Generator Polynomial = ................. 0x1EDC6F41
|
||||
* Generator Polynomial Length = .......... 32 bits
|
||||
* Reflected Bits = ....................... TRUE
|
||||
* Table Generation Offset = .............. 32 bits
|
||||
* Number of Slices = ..................... 8 slices
|
||||
* Slice Lengths = ........................ 8 8 8 8 8 8 8 8
|
||||
* Directory Name = ....................... .\
|
||||
* File Name = ............................ 8x256_tables.c
|
||||
*/
|
||||
|
||||
static const uint32_t sctp_crc_tableil8_o88[256] =
|
||||
{
|
||||
0x00000000, 0x493C7D27, 0x9278FA4E, 0xDB448769, 0x211D826D, 0x6821FF4A, 0xB3657823, 0xFA590504,
|
||||
0x423B04DA, 0x0B0779FD, 0xD043FE94, 0x997F83B3, 0x632686B7, 0x2A1AFB90, 0xF15E7CF9, 0xB86201DE,
|
||||
0x847609B4, 0xCD4A7493, 0x160EF3FA, 0x5F328EDD, 0xA56B8BD9, 0xEC57F6FE, 0x37137197, 0x7E2F0CB0,
|
||||
0xC64D0D6E, 0x8F717049, 0x5435F720, 0x1D098A07, 0xE7508F03, 0xAE6CF224, 0x7528754D, 0x3C14086A,
|
||||
0x0D006599, 0x443C18BE, 0x9F789FD7, 0xD644E2F0, 0x2C1DE7F4, 0x65219AD3, 0xBE651DBA, 0xF759609D,
|
||||
0x4F3B6143, 0x06071C64, 0xDD439B0D, 0x947FE62A, 0x6E26E32E, 0x271A9E09, 0xFC5E1960, 0xB5626447,
|
||||
0x89766C2D, 0xC04A110A, 0x1B0E9663, 0x5232EB44, 0xA86BEE40, 0xE1579367, 0x3A13140E, 0x732F6929,
|
||||
0xCB4D68F7, 0x827115D0, 0x593592B9, 0x1009EF9E, 0xEA50EA9A, 0xA36C97BD, 0x782810D4, 0x31146DF3,
|
||||
0x1A00CB32, 0x533CB615, 0x8878317C, 0xC1444C5B, 0x3B1D495F, 0x72213478, 0xA965B311, 0xE059CE36,
|
||||
0x583BCFE8, 0x1107B2CF, 0xCA4335A6, 0x837F4881, 0x79264D85, 0x301A30A2, 0xEB5EB7CB, 0xA262CAEC,
|
||||
0x9E76C286, 0xD74ABFA1, 0x0C0E38C8, 0x453245EF, 0xBF6B40EB, 0xF6573DCC, 0x2D13BAA5, 0x642FC782,
|
||||
0xDC4DC65C, 0x9571BB7B, 0x4E353C12, 0x07094135, 0xFD504431, 0xB46C3916, 0x6F28BE7F, 0x2614C358,
|
||||
0x1700AEAB, 0x5E3CD38C, 0x857854E5, 0xCC4429C2, 0x361D2CC6, 0x7F2151E1, 0xA465D688, 0xED59ABAF,
|
||||
0x553BAA71, 0x1C07D756, 0xC743503F, 0x8E7F2D18, 0x7426281C, 0x3D1A553B, 0xE65ED252, 0xAF62AF75,
|
||||
0x9376A71F, 0xDA4ADA38, 0x010E5D51, 0x48322076, 0xB26B2572, 0xFB575855, 0x2013DF3C, 0x692FA21B,
|
||||
0xD14DA3C5, 0x9871DEE2, 0x4335598B, 0x0A0924AC, 0xF05021A8, 0xB96C5C8F, 0x6228DBE6, 0x2B14A6C1,
|
||||
0x34019664, 0x7D3DEB43, 0xA6796C2A, 0xEF45110D, 0x151C1409, 0x5C20692E, 0x8764EE47, 0xCE589360,
|
||||
0x763A92BE, 0x3F06EF99, 0xE44268F0, 0xAD7E15D7, 0x572710D3, 0x1E1B6DF4, 0xC55FEA9D, 0x8C6397BA,
|
||||
0xB0779FD0, 0xF94BE2F7, 0x220F659E, 0x6B3318B9, 0x916A1DBD, 0xD856609A, 0x0312E7F3, 0x4A2E9AD4,
|
||||
0xF24C9B0A, 0xBB70E62D, 0x60346144, 0x29081C63, 0xD3511967, 0x9A6D6440, 0x4129E329, 0x08159E0E,
|
||||
0x3901F3FD, 0x703D8EDA, 0xAB7909B3, 0xE2457494, 0x181C7190, 0x51200CB7, 0x8A648BDE, 0xC358F6F9,
|
||||
0x7B3AF727, 0x32068A00, 0xE9420D69, 0xA07E704E, 0x5A27754A, 0x131B086D, 0xC85F8F04, 0x8163F223,
|
||||
0xBD77FA49, 0xF44B876E, 0x2F0F0007, 0x66337D20, 0x9C6A7824, 0xD5560503, 0x0E12826A, 0x472EFF4D,
|
||||
0xFF4CFE93, 0xB67083B4, 0x6D3404DD, 0x240879FA, 0xDE517CFE, 0x976D01D9, 0x4C2986B0, 0x0515FB97,
|
||||
0x2E015D56, 0x673D2071, 0xBC79A718, 0xF545DA3F, 0x0F1CDF3B, 0x4620A21C, 0x9D642575, 0xD4585852,
|
||||
0x6C3A598C, 0x250624AB, 0xFE42A3C2, 0xB77EDEE5, 0x4D27DBE1, 0x041BA6C6, 0xDF5F21AF, 0x96635C88,
|
||||
0xAA7754E2, 0xE34B29C5, 0x380FAEAC, 0x7133D38B, 0x8B6AD68F, 0xC256ABA8, 0x19122CC1, 0x502E51E6,
|
||||
0xE84C5038, 0xA1702D1F, 0x7A34AA76, 0x3308D751, 0xC951D255, 0x806DAF72, 0x5B29281B, 0x1215553C,
|
||||
0x230138CF, 0x6A3D45E8, 0xB179C281, 0xF845BFA6, 0x021CBAA2, 0x4B20C785, 0x906440EC, 0xD9583DCB,
|
||||
0x613A3C15, 0x28064132, 0xF342C65B, 0xBA7EBB7C, 0x4027BE78, 0x091BC35F, 0xD25F4436, 0x9B633911,
|
||||
0xA777317B, 0xEE4B4C5C, 0x350FCB35, 0x7C33B612, 0x866AB316, 0xCF56CE31, 0x14124958, 0x5D2E347F,
|
||||
0xE54C35A1, 0xAC704886, 0x7734CFEF, 0x3E08B2C8, 0xC451B7CC, 0x8D6DCAEB, 0x56294D82, 0x1F1530A5
|
||||
};
|
||||
|
||||
/*
|
||||
* end of the CRC lookup table crc_tableil8_o88
|
||||
*/
|
||||
|
||||
|
||||
static uint32_t
|
||||
sctp_crc32c_sb8_64_bit(uint32_t crc,
|
||||
const unsigned char *p_buf,
|
||||
uint32_t length,
|
||||
uint32_t init_bytes)
|
||||
{
|
||||
uint32_t li;
|
||||
uint32_t term1, term2;
|
||||
uint32_t running_length;
|
||||
uint32_t end_bytes;
|
||||
|
||||
running_length = ((length - init_bytes) / 8) * 8;
|
||||
end_bytes = length - init_bytes - running_length;
|
||||
|
||||
for (li = 0; li < init_bytes; li++)
|
||||
crc = sctp_crc_tableil8_o32[(crc ^ *p_buf++) & 0x000000FF] ^
|
||||
(crc >> 8);
|
||||
for (li = 0; li < running_length / 8; li++) {
|
||||
#if BYTE_ORDER == BIG_ENDIAN
|
||||
crc ^= *p_buf++;
|
||||
crc ^= (*p_buf++) << 8;
|
||||
crc ^= (*p_buf++) << 16;
|
||||
crc ^= (*p_buf++) << 24;
|
||||
#else
|
||||
crc ^= *(const uint32_t *) p_buf;
|
||||
p_buf += 4;
|
||||
#endif
|
||||
term1 = sctp_crc_tableil8_o88[crc & 0x000000FF] ^
|
||||
sctp_crc_tableil8_o80[(crc >> 8) & 0x000000FF];
|
||||
term2 = crc >> 16;
|
||||
crc = term1 ^
|
||||
sctp_crc_tableil8_o72[term2 & 0x000000FF] ^
|
||||
sctp_crc_tableil8_o64[(term2 >> 8) & 0x000000FF];
|
||||
|
||||
#if BYTE_ORDER == BIG_ENDIAN
|
||||
crc ^= sctp_crc_tableil8_o56[*p_buf++];
|
||||
crc ^= sctp_crc_tableil8_o48[*p_buf++];
|
||||
crc ^= sctp_crc_tableil8_o40[*p_buf++];
|
||||
crc ^= sctp_crc_tableil8_o32[*p_buf++];
|
||||
#else
|
||||
term1 = sctp_crc_tableil8_o56[(*(const uint32_t *) p_buf) & 0x000000FF] ^
|
||||
sctp_crc_tableil8_o48[((*(const uint32_t *) p_buf) >> 8) & 0x000000FF];
|
||||
|
||||
term2 = (*(const uint32_t *) p_buf) >> 16;
|
||||
crc = crc ^
|
||||
term1 ^
|
||||
sctp_crc_tableil8_o40[term2 & 0x000000FF] ^
|
||||
sctp_crc_tableil8_o32[(term2 >> 8) & 0x000000FF];
|
||||
p_buf += 4;
|
||||
#endif
|
||||
}
|
||||
for (li = 0; li < end_bytes; li++)
|
||||
crc = sctp_crc_tableil8_o32[(crc ^ *p_buf++) & 0x000000FF] ^
|
||||
(crc >> 8);
|
||||
return (crc);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* Routine Description:
|
||||
*
|
||||
* warms the tables
|
||||
*
|
||||
* Arguments:
|
||||
*
|
||||
* none
|
||||
*
|
||||
* Return value:
|
||||
*
|
||||
* none
|
||||
*/
|
||||
static uint32_t
|
||||
multitable_crc32c(uint32_t crc32c,
|
||||
const unsigned char *buffer,
|
||||
unsigned int length)
|
||||
{
|
||||
uint32_t to_even_word;
|
||||
|
||||
if (length == 0) {
|
||||
return (crc32c);
|
||||
}
|
||||
to_even_word = (4 - (((uintptr_t) buffer) & 0x3));
|
||||
return (sctp_crc32c_sb8_64_bit(crc32c, buffer, length, to_even_word));
|
||||
}
|
||||
|
||||
static const uint32_t sctp_crc_c[256] = {
|
||||
0x00000000, 0xF26B8303, 0xE13B70F7, 0x1350F3F4,
|
||||
0xC79A971F, 0x35F1141C, 0x26A1E7E8, 0xD4CA64EB,
|
||||
0x8AD958CF, 0x78B2DBCC, 0x6BE22838, 0x9989AB3B,
|
||||
0x4D43CFD0, 0xBF284CD3, 0xAC78BF27, 0x5E133C24,
|
||||
0x105EC76F, 0xE235446C, 0xF165B798, 0x030E349B,
|
||||
0xD7C45070, 0x25AFD373, 0x36FF2087, 0xC494A384,
|
||||
0x9A879FA0, 0x68EC1CA3, 0x7BBCEF57, 0x89D76C54,
|
||||
0x5D1D08BF, 0xAF768BBC, 0xBC267848, 0x4E4DFB4B,
|
||||
0x20BD8EDE, 0xD2D60DDD, 0xC186FE29, 0x33ED7D2A,
|
||||
0xE72719C1, 0x154C9AC2, 0x061C6936, 0xF477EA35,
|
||||
0xAA64D611, 0x580F5512, 0x4B5FA6E6, 0xB93425E5,
|
||||
0x6DFE410E, 0x9F95C20D, 0x8CC531F9, 0x7EAEB2FA,
|
||||
0x30E349B1, 0xC288CAB2, 0xD1D83946, 0x23B3BA45,
|
||||
0xF779DEAE, 0x05125DAD, 0x1642AE59, 0xE4292D5A,
|
||||
0xBA3A117E, 0x4851927D, 0x5B016189, 0xA96AE28A,
|
||||
0x7DA08661, 0x8FCB0562, 0x9C9BF696, 0x6EF07595,
|
||||
0x417B1DBC, 0xB3109EBF, 0xA0406D4B, 0x522BEE48,
|
||||
0x86E18AA3, 0x748A09A0, 0x67DAFA54, 0x95B17957,
|
||||
0xCBA24573, 0x39C9C670, 0x2A993584, 0xD8F2B687,
|
||||
0x0C38D26C, 0xFE53516F, 0xED03A29B, 0x1F682198,
|
||||
0x5125DAD3, 0xA34E59D0, 0xB01EAA24, 0x42752927,
|
||||
0x96BF4DCC, 0x64D4CECF, 0x77843D3B, 0x85EFBE38,
|
||||
0xDBFC821C, 0x2997011F, 0x3AC7F2EB, 0xC8AC71E8,
|
||||
0x1C661503, 0xEE0D9600, 0xFD5D65F4, 0x0F36E6F7,
|
||||
0x61C69362, 0x93AD1061, 0x80FDE395, 0x72966096,
|
||||
0xA65C047D, 0x5437877E, 0x4767748A, 0xB50CF789,
|
||||
0xEB1FCBAD, 0x197448AE, 0x0A24BB5A, 0xF84F3859,
|
||||
0x2C855CB2, 0xDEEEDFB1, 0xCDBE2C45, 0x3FD5AF46,
|
||||
0x7198540D, 0x83F3D70E, 0x90A324FA, 0x62C8A7F9,
|
||||
0xB602C312, 0x44694011, 0x5739B3E5, 0xA55230E6,
|
||||
0xFB410CC2, 0x092A8FC1, 0x1A7A7C35, 0xE811FF36,
|
||||
0x3CDB9BDD, 0xCEB018DE, 0xDDE0EB2A, 0x2F8B6829,
|
||||
0x82F63B78, 0x709DB87B, 0x63CD4B8F, 0x91A6C88C,
|
||||
0x456CAC67, 0xB7072F64, 0xA457DC90, 0x563C5F93,
|
||||
0x082F63B7, 0xFA44E0B4, 0xE9141340, 0x1B7F9043,
|
||||
0xCFB5F4A8, 0x3DDE77AB, 0x2E8E845F, 0xDCE5075C,
|
||||
0x92A8FC17, 0x60C37F14, 0x73938CE0, 0x81F80FE3,
|
||||
0x55326B08, 0xA759E80B, 0xB4091BFF, 0x466298FC,
|
||||
0x1871A4D8, 0xEA1A27DB, 0xF94AD42F, 0x0B21572C,
|
||||
0xDFEB33C7, 0x2D80B0C4, 0x3ED04330, 0xCCBBC033,
|
||||
0xA24BB5A6, 0x502036A5, 0x4370C551, 0xB11B4652,
|
||||
0x65D122B9, 0x97BAA1BA, 0x84EA524E, 0x7681D14D,
|
||||
0x2892ED69, 0xDAF96E6A, 0xC9A99D9E, 0x3BC21E9D,
|
||||
0xEF087A76, 0x1D63F975, 0x0E330A81, 0xFC588982,
|
||||
0xB21572C9, 0x407EF1CA, 0x532E023E, 0xA145813D,
|
||||
0x758FE5D6, 0x87E466D5, 0x94B49521, 0x66DF1622,
|
||||
0x38CC2A06, 0xCAA7A905, 0xD9F75AF1, 0x2B9CD9F2,
|
||||
0xFF56BD19, 0x0D3D3E1A, 0x1E6DCDEE, 0xEC064EED,
|
||||
0xC38D26C4, 0x31E6A5C7, 0x22B65633, 0xD0DDD530,
|
||||
0x0417B1DB, 0xF67C32D8, 0xE52CC12C, 0x1747422F,
|
||||
0x49547E0B, 0xBB3FFD08, 0xA86F0EFC, 0x5A048DFF,
|
||||
0x8ECEE914, 0x7CA56A17, 0x6FF599E3, 0x9D9E1AE0,
|
||||
0xD3D3E1AB, 0x21B862A8, 0x32E8915C, 0xC083125F,
|
||||
0x144976B4, 0xE622F5B7, 0xF5720643, 0x07198540,
|
||||
0x590AB964, 0xAB613A67, 0xB831C993, 0x4A5A4A90,
|
||||
0x9E902E7B, 0x6CFBAD78, 0x7FAB5E8C, 0x8DC0DD8F,
|
||||
0xE330A81A, 0x115B2B19, 0x020BD8ED, 0xF0605BEE,
|
||||
0x24AA3F05, 0xD6C1BC06, 0xC5914FF2, 0x37FACCF1,
|
||||
0x69E9F0D5, 0x9B8273D6, 0x88D28022, 0x7AB90321,
|
||||
0xAE7367CA, 0x5C18E4C9, 0x4F48173D, 0xBD23943E,
|
||||
0xF36E6F75, 0x0105EC76, 0x12551F82, 0xE03E9C81,
|
||||
0x34F4F86A, 0xC69F7B69, 0xD5CF889D, 0x27A40B9E,
|
||||
0x79B737BA, 0x8BDCB4B9, 0x988C474D, 0x6AE7C44E,
|
||||
0xBE2DA0A5, 0x4C4623A6, 0x5F16D052, 0xAD7D5351,
|
||||
};
|
||||
|
||||
|
||||
#define SCTP_CRC32C(c,d) (c=(c>>8)^sctp_crc_c[(c^(d))&0xFF])
|
||||
|
||||
static uint32_t
|
||||
singletable_crc32c(uint32_t crc32c,
|
||||
const unsigned char *buffer,
|
||||
unsigned int length)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0; i < length; i++) {
|
||||
SCTP_CRC32C(crc32c, buffer[i]);
|
||||
}
|
||||
return (crc32c);
|
||||
}
|
||||
|
||||
#if defined(__Userspace__)
|
||||
uint32_t
|
||||
#else
|
||||
static uint32_t
|
||||
#endif
|
||||
calculate_crc32c(uint32_t crc32c,
|
||||
const unsigned char *buffer,
|
||||
unsigned int length)
|
||||
{
|
||||
if (length < 4) {
|
||||
return (singletable_crc32c(crc32c, buffer, length));
|
||||
} else {
|
||||
return (multitable_crc32c(crc32c, buffer, length));
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
#if defined(__Userspace__)
|
||||
uint32_t
|
||||
#else
|
||||
static uint32_t
|
||||
#endif
|
||||
sctp_finalize_crc32c(uint32_t crc32c)
|
||||
{
|
||||
uint32_t result;
|
||||
#if BYTE_ORDER == BIG_ENDIAN
|
||||
uint8_t byte0, byte1, byte2, byte3;
|
||||
#endif
|
||||
|
||||
/* Complement the result */
|
||||
result = ~crc32c;
|
||||
#if BYTE_ORDER == BIG_ENDIAN
|
||||
/*
|
||||
* For BIG-ENDIAN platforms the result is in little-endian form. So we
|
||||
* must swap the bytes to return the result in network byte order.
|
||||
*/
|
||||
byte0 = result & 0x000000ff;
|
||||
byte1 = (result >> 8) & 0x000000ff;
|
||||
byte2 = (result >> 16) & 0x000000ff;
|
||||
byte3 = (result >> 24) & 0x000000ff;
|
||||
crc32c = ((byte0 << 24) | (byte1 << 16) | (byte2 << 8) | byte3);
|
||||
#else
|
||||
/*
|
||||
* For LITTLE ENDIAN platforms the result is in already in network
|
||||
* byte order.
|
||||
*/
|
||||
crc32c = result;
|
||||
#endif
|
||||
return (crc32c);
|
||||
}
|
||||
|
||||
/*
|
||||
* Compute the SCTP checksum in network byte order for a given mbuf chain m
|
||||
* which contains an SCTP packet starting at offset.
|
||||
* Since this function is also called by ipfw, don't assume that
|
||||
* it is compiled on a kernel with SCTP support.
|
||||
*/
|
||||
uint32_t
|
||||
sctp_calculate_cksum(struct mbuf *m, uint32_t offset)
|
||||
{
|
||||
uint32_t base = 0xffffffff;
|
||||
|
||||
while (offset > 0) {
|
||||
KASSERT(m != NULL, ("sctp_calculate_cksum, offset > length of mbuf chain"));
|
||||
if (offset < (uint32_t)m->m_len) {
|
||||
break;
|
||||
}
|
||||
offset -= m->m_len;
|
||||
m = m->m_next;
|
||||
}
|
||||
if (offset > 0) {
|
||||
base = calculate_crc32c(base,
|
||||
(unsigned char *)(m->m_data + offset),
|
||||
(unsigned int)(m->m_len - offset));
|
||||
m = m->m_next;
|
||||
}
|
||||
while (m != NULL) {
|
||||
base = calculate_crc32c(base,
|
||||
(unsigned char *)m->m_data,
|
||||
(unsigned int)m->m_len);
|
||||
m = m->m_next;
|
||||
}
|
||||
base = sctp_finalize_crc32c(base);
|
||||
return (base);
|
||||
}
|
||||
|
||||
#if defined(__FreeBSD__) && !defined(__Userspace__)
|
||||
#if defined(SCTP) || defined(SCTP_SUPPORT)
|
||||
|
||||
VNET_DEFINE(struct sctp_base_info, system_base_info);
|
||||
|
||||
/*
|
||||
* Compute and insert the SCTP checksum in network byte order for a given
|
||||
* mbuf chain m which contains an SCTP packet starting at offset.
|
||||
*/
|
||||
void
|
||||
sctp_delayed_cksum(struct mbuf *m, uint32_t offset)
|
||||
{
|
||||
uint32_t checksum;
|
||||
|
||||
checksum = sctp_calculate_cksum(m, offset);
|
||||
SCTP_STAT_DECR(sctps_sendhwcrc);
|
||||
SCTP_STAT_INCR(sctps_sendswcrc);
|
||||
offset += offsetof(struct sctphdr, checksum);
|
||||
|
||||
if (offset + sizeof(uint32_t) > (uint32_t)(m->m_pkthdr.len)) {
|
||||
#ifdef INVARIANTS
|
||||
panic("sctp_delayed_cksum(): m->m_pkthdr.len: %d, offset: %u.",
|
||||
m->m_pkthdr.len, offset);
|
||||
#else
|
||||
SCTP_PRINTF("sctp_delayed_cksum(): m->m_pkthdr.len: %d, offset: %u.\n",
|
||||
m->m_pkthdr.len, offset);
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
m_copyback(m, (int)offset, (int)sizeof(uint32_t), (caddr_t)&checksum);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
56
TMessagesProj/jni/third_party/usrsctplib/netinet/sctp_crc32.h
vendored
Executable file
56
TMessagesProj/jni/third_party/usrsctplib/netinet/sctp_crc32.h
vendored
Executable file
|
|
@ -0,0 +1,56 @@
|
|||
/*-
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#if defined(__FreeBSD__) && !defined(__Userspace__)
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD: head/sys/netinet/sctp_crc32.h 362338 2020-06-18 19:32:34Z markj $");
|
||||
#endif
|
||||
|
||||
#ifndef _NETINET_SCTP_CRC32_H_
|
||||
#define _NETINET_SCTP_CRC32_H_
|
||||
|
||||
#if defined(_KERNEL)
|
||||
uint32_t sctp_calculate_cksum(struct mbuf *, uint32_t);
|
||||
#if defined(__FreeBSD__) && !defined(__Userspace__)
|
||||
#if defined(SCTP) || defined(SCTP_SUPPORT)
|
||||
void sctp_delayed_cksum(struct mbuf *, uint32_t offset);
|
||||
#endif
|
||||
#endif
|
||||
#endif /* _KERNEL */
|
||||
#if defined(__Userspace__)
|
||||
uint32_t calculate_crc32c(uint32_t, const unsigned char *, unsigned int);
|
||||
uint32_t sctp_finalize_crc32c(uint32_t);
|
||||
uint32_t sctp_calculate_cksum(struct mbuf *, uint32_t);
|
||||
#endif
|
||||
#endif /* __crc32c_h__ */
|
||||
595
TMessagesProj/jni/third_party/usrsctplib/netinet/sctp_header.h
vendored
Executable file
595
TMessagesProj/jni/third_party/usrsctplib/netinet/sctp_header.h
vendored
Executable file
|
|
@ -0,0 +1,595 @@
|
|||
/*-
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#if defined(__FreeBSD__) && !defined(__Userspace__)
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD: head/sys/netinet/sctp_header.h 366114 2020-09-24 12:26:06Z tuexen $");
|
||||
#endif
|
||||
|
||||
#ifndef _NETINET_SCTP_HEADER_H_
|
||||
#define _NETINET_SCTP_HEADER_H_
|
||||
|
||||
#if defined(_WIN32) && !defined(__Userspace__)
|
||||
#include <packon.h>
|
||||
#endif
|
||||
#if !defined(_WIN32)
|
||||
#include <sys/time.h>
|
||||
#endif
|
||||
#include <netinet/sctp.h>
|
||||
#include <netinet/sctp_constants.h>
|
||||
|
||||
#if !defined(_WIN32)
|
||||
#define SCTP_PACKED __attribute__((packed))
|
||||
#else
|
||||
#pragma pack (push, 1)
|
||||
#define SCTP_PACKED
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Parameter structures
|
||||
*/
|
||||
struct sctp_ipv4addr_param {
|
||||
struct sctp_paramhdr ph;/* type=SCTP_IPV4_PARAM_TYPE, len=8 */
|
||||
uint32_t addr; /* IPV4 address */
|
||||
} SCTP_PACKED;
|
||||
|
||||
#define SCTP_V6_ADDR_BYTES 16
|
||||
|
||||
struct sctp_ipv6addr_param {
|
||||
struct sctp_paramhdr ph;/* type=SCTP_IPV6_PARAM_TYPE, len=20 */
|
||||
uint8_t addr[SCTP_V6_ADDR_BYTES]; /* IPV6 address */
|
||||
} SCTP_PACKED;
|
||||
|
||||
/* Cookie Preservative */
|
||||
struct sctp_cookie_perserve_param {
|
||||
struct sctp_paramhdr ph;/* type=SCTP_COOKIE_PRESERVE, len=8 */
|
||||
uint32_t time; /* time in ms to extend cookie */
|
||||
} SCTP_PACKED;
|
||||
|
||||
#define SCTP_ARRAY_MIN_LEN 1
|
||||
/* Host Name Address */
|
||||
struct sctp_host_name_param {
|
||||
struct sctp_paramhdr ph;/* type=SCTP_HOSTNAME_ADDRESS */
|
||||
char name[SCTP_ARRAY_MIN_LEN]; /* host name */
|
||||
} SCTP_PACKED;
|
||||
|
||||
/*
|
||||
* This is the maximum padded size of a s-a-p
|
||||
* so paramheadr + 3 address types (6 bytes) + 2 byte pad = 12
|
||||
*/
|
||||
#define SCTP_MAX_ADDR_PARAMS_SIZE 12
|
||||
/* supported address type */
|
||||
struct sctp_supported_addr_param {
|
||||
struct sctp_paramhdr ph;/* type=SCTP_SUPPORTED_ADDRTYPE */
|
||||
uint16_t addr_type[2]; /* array of supported address types */
|
||||
} SCTP_PACKED;
|
||||
|
||||
/* heartbeat info parameter */
|
||||
struct sctp_heartbeat_info_param {
|
||||
struct sctp_paramhdr ph;
|
||||
uint32_t time_value_1;
|
||||
uint32_t time_value_2;
|
||||
uint32_t random_value1;
|
||||
uint32_t random_value2;
|
||||
uint8_t addr_family;
|
||||
uint8_t addr_len;
|
||||
/* make sure that this structure is 4 byte aligned */
|
||||
uint8_t padding[2];
|
||||
char address[SCTP_ADDRMAX];
|
||||
} SCTP_PACKED;
|
||||
|
||||
/* draft-ietf-tsvwg-prsctp */
|
||||
/* PR-SCTP supported parameter */
|
||||
struct sctp_prsctp_supported_param {
|
||||
struct sctp_paramhdr ph;
|
||||
} SCTP_PACKED;
|
||||
|
||||
/* draft-ietf-tsvwg-addip-sctp */
|
||||
struct sctp_asconf_paramhdr { /* an ASCONF "parameter" */
|
||||
struct sctp_paramhdr ph;/* a SCTP parameter header */
|
||||
uint32_t correlation_id;/* correlation id for this param */
|
||||
} SCTP_PACKED;
|
||||
|
||||
struct sctp_asconf_addr_param { /* an ASCONF address parameter */
|
||||
struct sctp_asconf_paramhdr aph; /* asconf "parameter" */
|
||||
struct sctp_ipv6addr_param addrp; /* max storage size */
|
||||
} SCTP_PACKED;
|
||||
|
||||
struct sctp_asconf_tag_param { /* an ASCONF NAT-Vtag parameter */
|
||||
struct sctp_asconf_paramhdr aph; /* asconf "parameter" */
|
||||
uint32_t local_vtag;
|
||||
uint32_t remote_vtag;
|
||||
} SCTP_PACKED;
|
||||
|
||||
struct sctp_asconf_addrv4_param { /* an ASCONF address (v4) parameter */
|
||||
struct sctp_asconf_paramhdr aph; /* asconf "parameter" */
|
||||
struct sctp_ipv4addr_param addrp; /* max storage size */
|
||||
} SCTP_PACKED;
|
||||
|
||||
#define SCTP_MAX_SUPPORTED_EXT 256
|
||||
|
||||
struct sctp_supported_chunk_types_param {
|
||||
struct sctp_paramhdr ph;/* type = 0x8008 len = x */
|
||||
uint8_t chunk_types[];
|
||||
} SCTP_PACKED;
|
||||
|
||||
/*
|
||||
* Structures for DATA chunks
|
||||
*/
|
||||
struct sctp_data {
|
||||
uint32_t tsn;
|
||||
uint16_t sid;
|
||||
uint16_t ssn;
|
||||
uint32_t ppid;
|
||||
/* user data follows */
|
||||
} SCTP_PACKED;
|
||||
|
||||
struct sctp_data_chunk {
|
||||
struct sctp_chunkhdr ch;
|
||||
struct sctp_data dp;
|
||||
} SCTP_PACKED;
|
||||
|
||||
struct sctp_idata {
|
||||
uint32_t tsn;
|
||||
uint16_t sid;
|
||||
uint16_t reserved; /* Where does the SSN go? */
|
||||
uint32_t mid;
|
||||
union {
|
||||
uint32_t ppid;
|
||||
uint32_t fsn; /* Fragment Sequence Number */
|
||||
} ppid_fsn;
|
||||
/* user data follows */
|
||||
} SCTP_PACKED;
|
||||
|
||||
struct sctp_idata_chunk {
|
||||
struct sctp_chunkhdr ch;
|
||||
struct sctp_idata dp;
|
||||
} SCTP_PACKED;
|
||||
|
||||
/*
|
||||
* Structures for the control chunks
|
||||
*/
|
||||
|
||||
/* Initiate (INIT)/Initiate Ack (INIT ACK) */
|
||||
struct sctp_init {
|
||||
uint32_t initiate_tag; /* initiate tag */
|
||||
uint32_t a_rwnd; /* a_rwnd */
|
||||
uint16_t num_outbound_streams; /* OS */
|
||||
uint16_t num_inbound_streams; /* MIS */
|
||||
uint32_t initial_tsn; /* I-TSN */
|
||||
/* optional param's follow */
|
||||
} SCTP_PACKED;
|
||||
#define SCTP_IDENTIFICATION_SIZE 16
|
||||
#define SCTP_ADDRESS_SIZE 4
|
||||
#if defined(__Userspace__)
|
||||
#define SCTP_RESERVE_SPACE 5
|
||||
#else
|
||||
#define SCTP_RESERVE_SPACE 6
|
||||
#endif
|
||||
/* state cookie header */
|
||||
struct sctp_state_cookie { /* this is our definition... */
|
||||
uint8_t identification[SCTP_IDENTIFICATION_SIZE];/* id of who we are */
|
||||
struct timeval time_entered; /* the time I built cookie */
|
||||
uint32_t cookie_life; /* life I will award this cookie */
|
||||
uint32_t tie_tag_my_vtag; /* my tag in old association */
|
||||
|
||||
uint32_t tie_tag_peer_vtag; /* peers tag in old association */
|
||||
uint32_t peers_vtag; /* peers tag in INIT (for quick ref) */
|
||||
|
||||
uint32_t my_vtag; /* my tag in INIT-ACK (for quick ref) */
|
||||
uint32_t address[SCTP_ADDRESS_SIZE]; /* 4 ints/128 bits */
|
||||
uint32_t addr_type; /* address type */
|
||||
uint32_t laddress[SCTP_ADDRESS_SIZE]; /* my local from address */
|
||||
uint32_t laddr_type; /* my local from address type */
|
||||
uint32_t scope_id; /* v6 scope id for link-locals */
|
||||
|
||||
uint16_t peerport; /* port address of the peer in the INIT */
|
||||
uint16_t myport; /* my port address used in the INIT */
|
||||
uint8_t ipv4_addr_legal;/* Are V4 addr legal? */
|
||||
uint8_t ipv6_addr_legal;/* Are V6 addr legal? */
|
||||
#if defined(__Userspace__)
|
||||
uint8_t conn_addr_legal;
|
||||
#endif
|
||||
uint8_t local_scope; /* IPv6 local scope flag */
|
||||
uint8_t site_scope; /* IPv6 site scope flag */
|
||||
|
||||
uint8_t ipv4_scope; /* IPv4 private addr scope */
|
||||
uint8_t loopback_scope; /* loopback scope information */
|
||||
uint8_t reserved[SCTP_RESERVE_SPACE]; /* Align to 64 bits */
|
||||
/*
|
||||
* at the end is tacked on the INIT chunk and the INIT-ACK chunk
|
||||
* (minus the cookie).
|
||||
*/
|
||||
} SCTP_PACKED;
|
||||
|
||||
/* state cookie parameter */
|
||||
struct sctp_state_cookie_param {
|
||||
struct sctp_paramhdr ph;
|
||||
struct sctp_state_cookie cookie;
|
||||
} SCTP_PACKED;
|
||||
|
||||
struct sctp_init_chunk {
|
||||
struct sctp_chunkhdr ch;
|
||||
struct sctp_init init;
|
||||
} SCTP_PACKED;
|
||||
|
||||
struct sctp_init_msg {
|
||||
struct sctphdr sh;
|
||||
struct sctp_init_chunk msg;
|
||||
} SCTP_PACKED;
|
||||
|
||||
/* ... used for both INIT and INIT ACK */
|
||||
#define sctp_init_ack sctp_init
|
||||
#define sctp_init_ack_chunk sctp_init_chunk
|
||||
#define sctp_init_ack_msg sctp_init_msg
|
||||
|
||||
/* Selective Ack (SACK) */
|
||||
struct sctp_gap_ack_block {
|
||||
uint16_t start; /* Gap Ack block start */
|
||||
uint16_t end; /* Gap Ack block end */
|
||||
} SCTP_PACKED;
|
||||
|
||||
struct sctp_sack {
|
||||
uint32_t cum_tsn_ack; /* cumulative TSN Ack */
|
||||
uint32_t a_rwnd; /* updated a_rwnd of sender */
|
||||
uint16_t num_gap_ack_blks; /* number of Gap Ack blocks */
|
||||
uint16_t num_dup_tsns; /* number of duplicate TSNs */
|
||||
/* struct sctp_gap_ack_block's follow */
|
||||
/* uint32_t duplicate_tsn's follow */
|
||||
} SCTP_PACKED;
|
||||
|
||||
struct sctp_sack_chunk {
|
||||
struct sctp_chunkhdr ch;
|
||||
struct sctp_sack sack;
|
||||
} SCTP_PACKED;
|
||||
|
||||
struct sctp_nr_sack {
|
||||
uint32_t cum_tsn_ack; /* cumulative TSN Ack */
|
||||
uint32_t a_rwnd; /* updated a_rwnd of sender */
|
||||
uint16_t num_gap_ack_blks; /* number of Gap Ack blocks */
|
||||
uint16_t num_nr_gap_ack_blks; /* number of NR Gap Ack blocks */
|
||||
uint16_t num_dup_tsns; /* number of duplicate TSNs */
|
||||
uint16_t reserved; /* not currently used*/
|
||||
/* struct sctp_gap_ack_block's follow */
|
||||
/* uint32_t duplicate_tsn's follow */
|
||||
} SCTP_PACKED;
|
||||
|
||||
struct sctp_nr_sack_chunk {
|
||||
struct sctp_chunkhdr ch;
|
||||
struct sctp_nr_sack nr_sack;
|
||||
} SCTP_PACKED;
|
||||
|
||||
/* Heartbeat Request (HEARTBEAT) */
|
||||
struct sctp_heartbeat {
|
||||
struct sctp_heartbeat_info_param hb_info;
|
||||
} SCTP_PACKED;
|
||||
|
||||
struct sctp_heartbeat_chunk {
|
||||
struct sctp_chunkhdr ch;
|
||||
struct sctp_heartbeat heartbeat;
|
||||
} SCTP_PACKED;
|
||||
|
||||
/* ... used for Heartbeat Ack (HEARTBEAT ACK) */
|
||||
#define sctp_heartbeat_ack sctp_heartbeat
|
||||
#define sctp_heartbeat_ack_chunk sctp_heartbeat_chunk
|
||||
|
||||
/* Abort Asssociation (ABORT) */
|
||||
struct sctp_abort_chunk {
|
||||
struct sctp_chunkhdr ch;
|
||||
/* optional error cause may follow */
|
||||
} SCTP_PACKED;
|
||||
|
||||
struct sctp_abort_msg {
|
||||
struct sctphdr sh;
|
||||
struct sctp_abort_chunk msg;
|
||||
} SCTP_PACKED;
|
||||
|
||||
/* Shutdown Association (SHUTDOWN) */
|
||||
struct sctp_shutdown_chunk {
|
||||
struct sctp_chunkhdr ch;
|
||||
uint32_t cumulative_tsn_ack;
|
||||
} SCTP_PACKED;
|
||||
|
||||
/* Shutdown Acknowledgment (SHUTDOWN ACK) */
|
||||
struct sctp_shutdown_ack_chunk {
|
||||
struct sctp_chunkhdr ch;
|
||||
} SCTP_PACKED;
|
||||
|
||||
/* Operation Error (ERROR) */
|
||||
struct sctp_error_chunk {
|
||||
struct sctp_chunkhdr ch;
|
||||
/* optional error causes follow */
|
||||
} SCTP_PACKED;
|
||||
|
||||
/* Cookie Echo (COOKIE ECHO) */
|
||||
struct sctp_cookie_echo_chunk {
|
||||
struct sctp_chunkhdr ch;
|
||||
struct sctp_state_cookie cookie;
|
||||
} SCTP_PACKED;
|
||||
|
||||
/* Cookie Acknowledgment (COOKIE ACK) */
|
||||
struct sctp_cookie_ack_chunk {
|
||||
struct sctp_chunkhdr ch;
|
||||
} SCTP_PACKED;
|
||||
|
||||
/* Explicit Congestion Notification Echo (ECNE) */
|
||||
struct old_sctp_ecne_chunk {
|
||||
struct sctp_chunkhdr ch;
|
||||
uint32_t tsn;
|
||||
} SCTP_PACKED;
|
||||
|
||||
struct sctp_ecne_chunk {
|
||||
struct sctp_chunkhdr ch;
|
||||
uint32_t tsn;
|
||||
uint32_t num_pkts_since_cwr;
|
||||
} SCTP_PACKED;
|
||||
|
||||
/* Congestion Window Reduced (CWR) */
|
||||
struct sctp_cwr_chunk {
|
||||
struct sctp_chunkhdr ch;
|
||||
uint32_t tsn;
|
||||
} SCTP_PACKED;
|
||||
|
||||
/* Shutdown Complete (SHUTDOWN COMPLETE) */
|
||||
struct sctp_shutdown_complete_chunk {
|
||||
struct sctp_chunkhdr ch;
|
||||
} SCTP_PACKED;
|
||||
|
||||
struct sctp_adaptation_layer_indication {
|
||||
struct sctp_paramhdr ph;
|
||||
uint32_t indication;
|
||||
} SCTP_PACKED;
|
||||
|
||||
/*
|
||||
* draft-ietf-tsvwg-addip-sctp
|
||||
*/
|
||||
/* Address/Stream Configuration Change (ASCONF) */
|
||||
struct sctp_asconf_chunk {
|
||||
struct sctp_chunkhdr ch;
|
||||
uint32_t serial_number;
|
||||
/* lookup address parameter (mandatory) */
|
||||
/* asconf parameters follow */
|
||||
} SCTP_PACKED;
|
||||
|
||||
/* Address/Stream Configuration Acknowledge (ASCONF ACK) */
|
||||
struct sctp_asconf_ack_chunk {
|
||||
struct sctp_chunkhdr ch;
|
||||
uint32_t serial_number;
|
||||
/* asconf parameters follow */
|
||||
} SCTP_PACKED;
|
||||
|
||||
/* draft-ietf-tsvwg-prsctp */
|
||||
/* Forward Cumulative TSN (FORWARD TSN) */
|
||||
struct sctp_forward_tsn_chunk {
|
||||
struct sctp_chunkhdr ch;
|
||||
uint32_t new_cumulative_tsn;
|
||||
/* stream/sequence pairs (sctp_strseq) follow */
|
||||
} SCTP_PACKED;
|
||||
|
||||
struct sctp_strseq {
|
||||
uint16_t sid;
|
||||
uint16_t ssn;
|
||||
} SCTP_PACKED;
|
||||
|
||||
struct sctp_strseq_mid {
|
||||
uint16_t sid;
|
||||
uint16_t flags;
|
||||
uint32_t mid;
|
||||
};
|
||||
|
||||
struct sctp_forward_tsn_msg {
|
||||
struct sctphdr sh;
|
||||
struct sctp_forward_tsn_chunk msg;
|
||||
} SCTP_PACKED;
|
||||
|
||||
/* should be a multiple of 4 - 1 aka 3/7/11 etc. */
|
||||
|
||||
#define SCTP_NUM_DB_TO_VERIFY 31
|
||||
|
||||
struct sctp_chunk_desc {
|
||||
uint8_t chunk_type;
|
||||
uint8_t data_bytes[SCTP_NUM_DB_TO_VERIFY];
|
||||
uint32_t tsn_ifany;
|
||||
} SCTP_PACKED;
|
||||
|
||||
struct sctp_pktdrop_chunk {
|
||||
struct sctp_chunkhdr ch;
|
||||
uint32_t bottle_bw;
|
||||
uint32_t current_onq;
|
||||
uint16_t trunc_len;
|
||||
uint16_t reserved;
|
||||
uint8_t data[];
|
||||
} SCTP_PACKED;
|
||||
|
||||
/**********STREAM RESET STUFF ******************/
|
||||
|
||||
struct sctp_stream_reset_request {
|
||||
struct sctp_paramhdr ph;
|
||||
uint32_t request_seq;
|
||||
} SCTP_PACKED;
|
||||
|
||||
struct sctp_stream_reset_out_request {
|
||||
struct sctp_paramhdr ph;
|
||||
uint32_t request_seq; /* monotonically increasing seq no */
|
||||
uint32_t response_seq; /* if a response, the resp seq no */
|
||||
uint32_t send_reset_at_tsn; /* last TSN I assigned outbound */
|
||||
uint16_t list_of_streams[]; /* if not all list of streams */
|
||||
} SCTP_PACKED;
|
||||
|
||||
struct sctp_stream_reset_in_request {
|
||||
struct sctp_paramhdr ph;
|
||||
uint32_t request_seq;
|
||||
uint16_t list_of_streams[]; /* if not all list of streams */
|
||||
} SCTP_PACKED;
|
||||
|
||||
struct sctp_stream_reset_tsn_request {
|
||||
struct sctp_paramhdr ph;
|
||||
uint32_t request_seq;
|
||||
} SCTP_PACKED;
|
||||
|
||||
struct sctp_stream_reset_response {
|
||||
struct sctp_paramhdr ph;
|
||||
uint32_t response_seq; /* if a response, the resp seq no */
|
||||
uint32_t result;
|
||||
} SCTP_PACKED;
|
||||
|
||||
struct sctp_stream_reset_response_tsn {
|
||||
struct sctp_paramhdr ph;
|
||||
uint32_t response_seq; /* if a response, the resp seq no */
|
||||
uint32_t result;
|
||||
uint32_t senders_next_tsn;
|
||||
uint32_t receivers_next_tsn;
|
||||
} SCTP_PACKED;
|
||||
|
||||
struct sctp_stream_reset_add_strm {
|
||||
struct sctp_paramhdr ph;
|
||||
uint32_t request_seq;
|
||||
uint16_t number_of_streams;
|
||||
uint16_t reserved;
|
||||
} SCTP_PACKED;
|
||||
|
||||
#define SCTP_STREAM_RESET_RESULT_NOTHING_TO_DO 0x00000000 /* XXX: unused */
|
||||
#define SCTP_STREAM_RESET_RESULT_PERFORMED 0x00000001
|
||||
#define SCTP_STREAM_RESET_RESULT_DENIED 0x00000002
|
||||
#define SCTP_STREAM_RESET_RESULT_ERR__WRONG_SSN 0x00000003 /* XXX: unused */
|
||||
#define SCTP_STREAM_RESET_RESULT_ERR_IN_PROGRESS 0x00000004
|
||||
#define SCTP_STREAM_RESET_RESULT_ERR_BAD_SEQNO 0x00000005
|
||||
#define SCTP_STREAM_RESET_RESULT_IN_PROGRESS 0x00000006 /* XXX: unused */
|
||||
|
||||
/*
|
||||
* convience structures, note that if you are making a request for specific
|
||||
* streams then the request will need to be an overlay structure.
|
||||
*/
|
||||
|
||||
struct sctp_stream_reset_tsn_req {
|
||||
struct sctp_chunkhdr ch;
|
||||
struct sctp_stream_reset_tsn_request sr_req;
|
||||
} SCTP_PACKED;
|
||||
|
||||
struct sctp_stream_reset_resp {
|
||||
struct sctp_chunkhdr ch;
|
||||
struct sctp_stream_reset_response sr_resp;
|
||||
} SCTP_PACKED;
|
||||
|
||||
/* respone only valid with a TSN request */
|
||||
struct sctp_stream_reset_resp_tsn {
|
||||
struct sctp_chunkhdr ch;
|
||||
struct sctp_stream_reset_response_tsn sr_resp;
|
||||
} SCTP_PACKED;
|
||||
|
||||
/****************************************************/
|
||||
|
||||
/*
|
||||
* Authenticated chunks support draft-ietf-tsvwg-sctp-auth
|
||||
*/
|
||||
|
||||
/* Should we make the max be 32? */
|
||||
#define SCTP_RANDOM_MAX_SIZE 256
|
||||
struct sctp_auth_random {
|
||||
struct sctp_paramhdr ph;/* type = 0x8002 */
|
||||
uint8_t random_data[];
|
||||
} SCTP_PACKED;
|
||||
|
||||
struct sctp_auth_chunk_list {
|
||||
struct sctp_paramhdr ph;/* type = 0x8003 */
|
||||
uint8_t chunk_types[];
|
||||
} SCTP_PACKED;
|
||||
|
||||
struct sctp_auth_hmac_algo {
|
||||
struct sctp_paramhdr ph;/* type = 0x8004 */
|
||||
uint16_t hmac_ids[];
|
||||
} SCTP_PACKED;
|
||||
|
||||
struct sctp_auth_chunk {
|
||||
struct sctp_chunkhdr ch;
|
||||
uint16_t shared_key_id;
|
||||
uint16_t hmac_id;
|
||||
uint8_t hmac[];
|
||||
} SCTP_PACKED;
|
||||
|
||||
/*
|
||||
* we pre-reserve enough room for a ECNE or CWR AND a SACK with no missing
|
||||
* pieces. If ENCE is missing we could have a couple of blocks. This way we
|
||||
* optimize so we MOST likely can bundle a SACK/ECN with the smallest size
|
||||
* data chunk I will split into. We could increase throughput slightly by
|
||||
* taking out these two but the 24-sack/8-CWR i.e. 32 bytes I pre-reserve I
|
||||
* feel is worth it for now.
|
||||
*/
|
||||
#ifndef SCTP_MAX_OVERHEAD
|
||||
#ifdef INET6
|
||||
#define SCTP_MAX_OVERHEAD (sizeof(struct sctp_data_chunk) + \
|
||||
sizeof(struct sctphdr) + \
|
||||
sizeof(struct sctp_ecne_chunk) + \
|
||||
sizeof(struct sctp_sack_chunk) + \
|
||||
sizeof(struct ip6_hdr))
|
||||
|
||||
#define SCTP_MED_OVERHEAD (sizeof(struct sctp_data_chunk) + \
|
||||
sizeof(struct sctphdr) + \
|
||||
sizeof(struct ip6_hdr))
|
||||
|
||||
#define SCTP_MIN_OVERHEAD (sizeof(struct ip6_hdr) + \
|
||||
sizeof(struct sctphdr))
|
||||
|
||||
#else
|
||||
#define SCTP_MAX_OVERHEAD (sizeof(struct sctp_data_chunk) + \
|
||||
sizeof(struct sctphdr) + \
|
||||
sizeof(struct sctp_ecne_chunk) + \
|
||||
sizeof(struct sctp_sack_chunk) + \
|
||||
sizeof(struct ip))
|
||||
|
||||
#define SCTP_MED_OVERHEAD (sizeof(struct sctp_data_chunk) + \
|
||||
sizeof(struct sctphdr) + \
|
||||
sizeof(struct ip))
|
||||
|
||||
#define SCTP_MIN_OVERHEAD (sizeof(struct ip) + \
|
||||
sizeof(struct sctphdr))
|
||||
|
||||
#endif /* INET6 */
|
||||
#endif /* !SCTP_MAX_OVERHEAD */
|
||||
|
||||
#define SCTP_MED_V4_OVERHEAD (sizeof(struct sctp_data_chunk) + \
|
||||
sizeof(struct sctphdr) + \
|
||||
sizeof(struct ip))
|
||||
|
||||
#define SCTP_MIN_V4_OVERHEAD (sizeof(struct ip) + \
|
||||
sizeof(struct sctphdr))
|
||||
|
||||
#if defined(_WIN32) && !defined(__Userspace__)
|
||||
#include <packoff.h>
|
||||
#endif
|
||||
#if defined(_WIN32) && defined(__Userspace__)
|
||||
#pragma pack(pop)
|
||||
#endif
|
||||
#undef SCTP_PACKED
|
||||
#endif /* !__sctp_header_h__ */
|
||||
5800
TMessagesProj/jni/third_party/usrsctplib/netinet/sctp_indata.c
vendored
Executable file
5800
TMessagesProj/jni/third_party/usrsctplib/netinet/sctp_indata.c
vendored
Executable file
File diff suppressed because it is too large
Load diff
121
TMessagesProj/jni/third_party/usrsctplib/netinet/sctp_indata.h
vendored
Executable file
121
TMessagesProj/jni/third_party/usrsctplib/netinet/sctp_indata.h
vendored
Executable file
|
|
@ -0,0 +1,121 @@
|
|||
/*-
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#if defined(__FreeBSD__) && !defined(__Userspace__)
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD: head/sys/netinet/sctp_indata.h 365071 2020-09-01 21:19:14Z mjg $");
|
||||
#endif
|
||||
|
||||
#ifndef _NETINET_SCTP_INDATA_H_
|
||||
#define _NETINET_SCTP_INDATA_H_
|
||||
|
||||
#if defined(_KERNEL) || defined(__Userspace__)
|
||||
|
||||
struct sctp_queued_to_read *
|
||||
sctp_build_readq_entry(struct sctp_tcb *stcb,
|
||||
struct sctp_nets *net,
|
||||
uint32_t tsn, uint32_t ppid,
|
||||
uint32_t context, uint16_t sid,
|
||||
uint32_t mid, uint8_t flags,
|
||||
struct mbuf *dm);
|
||||
|
||||
#define sctp_build_readq_entry_mac(_ctl, in_it, context, net, tsn, ppid, sid, flags, dm, tfsn, mid) do { \
|
||||
if (_ctl) { \
|
||||
atomic_add_int(&((net)->ref_count), 1); \
|
||||
memset(_ctl, 0, sizeof(struct sctp_queued_to_read)); \
|
||||
(_ctl)->sinfo_stream = sid; \
|
||||
TAILQ_INIT(&_ctl->reasm); \
|
||||
(_ctl)->top_fsn = tfsn; \
|
||||
(_ctl)->mid = mid; \
|
||||
(_ctl)->sinfo_flags = (flags << 8); \
|
||||
(_ctl)->sinfo_ppid = ppid; \
|
||||
(_ctl)->sinfo_context = context; \
|
||||
(_ctl)->fsn_included = 0xffffffff; \
|
||||
(_ctl)->sinfo_tsn = tsn; \
|
||||
(_ctl)->sinfo_cumtsn = tsn; \
|
||||
(_ctl)->sinfo_assoc_id = sctp_get_associd((in_it)); \
|
||||
(_ctl)->whoFrom = net; \
|
||||
(_ctl)->data = dm; \
|
||||
(_ctl)->stcb = (in_it); \
|
||||
(_ctl)->port_from = (in_it)->rport; \
|
||||
if ((in_it)->asoc.state & SCTP_STATE_ABOUT_TO_BE_FREED) { \
|
||||
(_ctl)->do_not_ref_stcb = 1; \
|
||||
}\
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
struct mbuf *
|
||||
sctp_build_ctl_nchunk(struct sctp_inpcb *inp,
|
||||
struct sctp_sndrcvinfo *sinfo);
|
||||
|
||||
void sctp_set_rwnd(struct sctp_tcb *, struct sctp_association *);
|
||||
|
||||
uint32_t
|
||||
sctp_calc_rwnd(struct sctp_tcb *stcb, struct sctp_association *asoc);
|
||||
|
||||
void
|
||||
sctp_express_handle_sack(struct sctp_tcb *stcb, uint32_t cumack,
|
||||
uint32_t rwnd, int *abort_now, int ecne_seen);
|
||||
|
||||
void
|
||||
sctp_handle_sack(struct mbuf *m, int offset_seg, int offset_dup,
|
||||
struct sctp_tcb *stcb,
|
||||
uint16_t num_seg, uint16_t num_nr_seg, uint16_t num_dup,
|
||||
int *abort_now, uint8_t flags,
|
||||
uint32_t cum_ack, uint32_t rwnd, int ecne_seen);
|
||||
|
||||
/* draft-ietf-tsvwg-usctp */
|
||||
void
|
||||
sctp_handle_forward_tsn(struct sctp_tcb *,
|
||||
struct sctp_forward_tsn_chunk *, int *, struct mbuf *, int);
|
||||
|
||||
struct sctp_tmit_chunk *
|
||||
sctp_try_advance_peer_ack_point(struct sctp_tcb *, struct sctp_association *);
|
||||
|
||||
void sctp_service_queues(struct sctp_tcb *, struct sctp_association *);
|
||||
|
||||
void
|
||||
sctp_update_acked(struct sctp_tcb *, struct sctp_shutdown_chunk *, int *);
|
||||
|
||||
int
|
||||
sctp_process_data(struct mbuf **, int, int *, int,
|
||||
struct sctp_inpcb *, struct sctp_tcb *,
|
||||
struct sctp_nets *, uint32_t *);
|
||||
|
||||
void sctp_slide_mapping_arrays(struct sctp_tcb *stcb);
|
||||
|
||||
void sctp_sack_check(struct sctp_tcb *, int);
|
||||
|
||||
#endif
|
||||
#endif
|
||||
6411
TMessagesProj/jni/third_party/usrsctplib/netinet/sctp_input.c
vendored
Executable file
6411
TMessagesProj/jni/third_party/usrsctplib/netinet/sctp_input.c
vendored
Executable file
File diff suppressed because it is too large
Load diff
66
TMessagesProj/jni/third_party/usrsctplib/netinet/sctp_input.h
vendored
Executable file
66
TMessagesProj/jni/third_party/usrsctplib/netinet/sctp_input.h
vendored
Executable file
|
|
@ -0,0 +1,66 @@
|
|||
/*-
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#if defined(__FreeBSD__) && !defined(__Userspace__)
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD: head/sys/netinet/sctp_input.h 365071 2020-09-01 21:19:14Z mjg $");
|
||||
#endif
|
||||
|
||||
#ifndef _NETINET_SCTP_INPUT_H_
|
||||
#define _NETINET_SCTP_INPUT_H_
|
||||
|
||||
#if defined(_KERNEL) || defined(__Userspace__)
|
||||
void
|
||||
sctp_common_input_processing(struct mbuf **, int, int, int,
|
||||
struct sockaddr *, struct sockaddr *,
|
||||
struct sctphdr *, struct sctp_chunkhdr *,
|
||||
uint8_t,
|
||||
uint8_t,
|
||||
#if defined(__FreeBSD__) && !defined(__Userspace__)
|
||||
uint8_t, uint32_t, uint16_t,
|
||||
#endif
|
||||
uint32_t, uint16_t);
|
||||
|
||||
struct sctp_stream_reset_request *
|
||||
sctp_find_stream_reset(struct sctp_tcb *stcb, uint32_t seq,
|
||||
struct sctp_tmit_chunk **bchk);
|
||||
|
||||
void
|
||||
sctp_reset_in_stream(struct sctp_tcb *stcb, uint32_t number_entries,
|
||||
uint16_t *list);
|
||||
|
||||
int sctp_is_there_unsent_data(struct sctp_tcb *stcb, int so_locked);
|
||||
|
||||
#endif
|
||||
#endif
|
||||
248
TMessagesProj/jni/third_party/usrsctplib/netinet/sctp_lock_userspace.h
vendored
Executable file
248
TMessagesProj/jni/third_party/usrsctplib/netinet/sctp_lock_userspace.h
vendored
Executable file
|
|
@ -0,0 +1,248 @@
|
|||
/*-
|
||||
* 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.
|
||||
* Copyright (c) 2008-2012, by Brad Penoff. 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.
|
||||
*/
|
||||
|
||||
#if defined(__FreeBSD__) && !defined(__Userspace__)
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
#endif
|
||||
|
||||
#ifndef _NETINET_SCTP_LOCK_EMPTY_H_
|
||||
#define _NETINET_SCTP_LOCK_EMPTY_H_
|
||||
|
||||
/*
|
||||
* Empty Lock declarations for all other platforms. Pre-process away to
|
||||
* nothing.
|
||||
*/
|
||||
|
||||
/* __Userspace__ putting lock macros in same order as sctp_lock_bsd.h ...*/
|
||||
|
||||
#define SCTP_IPI_COUNT_INIT()
|
||||
|
||||
#define SCTP_STATLOG_INIT_LOCK()
|
||||
#define SCTP_STATLOG_LOCK()
|
||||
#define SCTP_STATLOG_UNLOCK()
|
||||
#define SCTP_STATLOG_DESTROY()
|
||||
|
||||
#define SCTP_INP_INFO_LOCK_DESTROY()
|
||||
|
||||
#define SCTP_INP_INFO_LOCK_INIT()
|
||||
#define SCTP_INP_INFO_RLOCK()
|
||||
#define SCTP_INP_INFO_WLOCK()
|
||||
#define SCTP_INP_INFO_TRYLOCK() 1
|
||||
#define SCTP_INP_INFO_RUNLOCK()
|
||||
#define SCTP_INP_INFO_WUNLOCK()
|
||||
#define SCTP_INP_INFO_LOCK_ASSERT()
|
||||
#define SCTP_INP_INFO_RLOCK_ASSERT()
|
||||
#define SCTP_INP_INFO_WLOCK_ASSERT()
|
||||
|
||||
#define SCTP_WQ_ADDR_INIT()
|
||||
#define SCTP_WQ_ADDR_DESTROY()
|
||||
#define SCTP_WQ_ADDR_LOCK()
|
||||
#define SCTP_WQ_ADDR_UNLOCK()
|
||||
#define SCTP_WQ_ADDR_LOCK_ASSERT()
|
||||
|
||||
#define SCTP_IPI_ADDR_INIT()
|
||||
#define SCTP_IPI_ADDR_DESTROY()
|
||||
#define SCTP_IPI_ADDR_RLOCK()
|
||||
#define SCTP_IPI_ADDR_WLOCK()
|
||||
#define SCTP_IPI_ADDR_RUNLOCK()
|
||||
#define SCTP_IPI_ADDR_WUNLOCK()
|
||||
#define SCTP_IPI_ADDR_LOCK_ASSERT()
|
||||
#define SCTP_IPI_ADDR_WLOCK_ASSERT()
|
||||
|
||||
#define SCTP_IPI_ITERATOR_WQ_INIT()
|
||||
#define SCTP_IPI_ITERATOR_WQ_DESTROY()
|
||||
#define SCTP_IPI_ITERATOR_WQ_LOCK()
|
||||
#define SCTP_IPI_ITERATOR_WQ_UNLOCK()
|
||||
|
||||
#define SCTP_IP_PKTLOG_INIT()
|
||||
#define SCTP_IP_PKTLOG_LOCK()
|
||||
#define SCTP_IP_PKTLOG_UNLOCK()
|
||||
#define SCTP_IP_PKTLOG_DESTROY()
|
||||
|
||||
#define SCTP_INP_READ_INIT(_inp)
|
||||
#define SCTP_INP_READ_DESTROY(_inp)
|
||||
#define SCTP_INP_READ_LOCK(_inp)
|
||||
#define SCTP_INP_READ_UNLOCK(_inp)
|
||||
|
||||
#define SCTP_INP_LOCK_INIT(_inp)
|
||||
#define SCTP_ASOC_CREATE_LOCK_INIT(_inp)
|
||||
#define SCTP_INP_LOCK_DESTROY(_inp)
|
||||
#define SCTP_ASOC_CREATE_LOCK_DESTROY(_inp)
|
||||
|
||||
#define SCTP_INP_RLOCK(_inp)
|
||||
#define SCTP_INP_WLOCK(_inp)
|
||||
#define SCTP_INP_RLOCK_ASSERT(_inp)
|
||||
#define SCTP_INP_WLOCK_ASSERT(_inp)
|
||||
|
||||
#define SCTP_INP_LOCK_CONTENDED(_inp) (0) /* Don't know if this is possible */
|
||||
|
||||
#define SCTP_INP_READ_CONTENDED(_inp) (0) /* Don't know if this is possible */
|
||||
|
||||
#define SCTP_ASOC_CREATE_LOCK_CONTENDED(_inp) (0) /* Don't know if this is possible */
|
||||
|
||||
|
||||
#define SCTP_TCB_SEND_LOCK_INIT(_tcb)
|
||||
#define SCTP_TCB_SEND_LOCK_DESTROY(_tcb)
|
||||
#define SCTP_TCB_SEND_LOCK(_tcb)
|
||||
#define SCTP_TCB_SEND_UNLOCK(_tcb)
|
||||
|
||||
#define SCTP_INP_INCR_REF(_inp)
|
||||
#define SCTP_INP_DECR_REF(_inp)
|
||||
|
||||
#define SCTP_ASOC_CREATE_LOCK(_inp)
|
||||
|
||||
#define SCTP_INP_RUNLOCK(_inp)
|
||||
#define SCTP_INP_WUNLOCK(_inp)
|
||||
#define SCTP_ASOC_CREATE_UNLOCK(_inp)
|
||||
|
||||
|
||||
#define SCTP_TCB_LOCK_INIT(_tcb)
|
||||
#define SCTP_TCB_LOCK_DESTROY(_tcb)
|
||||
#define SCTP_TCB_LOCK(_tcb)
|
||||
#define SCTP_TCB_TRYLOCK(_tcb) 1
|
||||
#define SCTP_TCB_UNLOCK(_tcb)
|
||||
#define SCTP_TCB_UNLOCK_IFOWNED(_tcb)
|
||||
#define SCTP_TCB_LOCK_ASSERT(_tcb)
|
||||
|
||||
|
||||
|
||||
#define SCTP_ITERATOR_LOCK_INIT()
|
||||
#define SCTP_ITERATOR_LOCK()
|
||||
#define SCTP_ITERATOR_UNLOCK()
|
||||
#define SCTP_ITERATOR_LOCK_DESTROY()
|
||||
|
||||
|
||||
|
||||
#define SCTP_INCR_EP_COUNT() \
|
||||
do { \
|
||||
sctppcbinfo.ipi_count_ep++; \
|
||||
} while (0)
|
||||
|
||||
#define SCTP_DECR_EP_COUNT() \
|
||||
do { \
|
||||
sctppcbinfo.ipi_count_ep--; \
|
||||
} while (0)
|
||||
|
||||
#define SCTP_INCR_ASOC_COUNT() \
|
||||
do { \
|
||||
sctppcbinfo.ipi_count_asoc++; \
|
||||
} while (0)
|
||||
|
||||
#define SCTP_DECR_ASOC_COUNT() \
|
||||
do { \
|
||||
sctppcbinfo.ipi_count_asoc--; \
|
||||
} while (0)
|
||||
|
||||
#define SCTP_INCR_LADDR_COUNT() \
|
||||
do { \
|
||||
sctppcbinfo.ipi_count_laddr++; \
|
||||
} while (0)
|
||||
|
||||
#define SCTP_DECR_LADDR_COUNT() \
|
||||
do { \
|
||||
sctppcbinfo.ipi_count_laddr--; \
|
||||
} while (0)
|
||||
|
||||
#define SCTP_INCR_RADDR_COUNT() \
|
||||
do { \
|
||||
sctppcbinfo.ipi_count_raddr++; \
|
||||
} while (0)
|
||||
|
||||
#define SCTP_DECR_RADDR_COUNT() \
|
||||
do { \
|
||||
sctppcbinfo.ipi_count_raddr--; \
|
||||
} while (0)
|
||||
|
||||
#define SCTP_INCR_CHK_COUNT() \
|
||||
do { \
|
||||
sctppcbinfo.ipi_count_chunk++; \
|
||||
} while (0)
|
||||
|
||||
#define SCTP_DECR_CHK_COUNT() \
|
||||
do { \
|
||||
sctppcbinfo.ipi_count_chunk--; \
|
||||
} while (0)
|
||||
|
||||
#define SCTP_INCR_READQ_COUNT() \
|
||||
do { \
|
||||
sctppcbinfo.ipi_count_readq++; \
|
||||
} while (0)
|
||||
|
||||
#define SCTP_DECR_READQ_COUNT() \
|
||||
do { \
|
||||
sctppcbinfo.ipi_count_readq--; \
|
||||
} while (0)
|
||||
|
||||
#define SCTP_INCR_STRMOQ_COUNT() \
|
||||
do { \
|
||||
sctppcbinfo.ipi_count_strmoq++; \
|
||||
} while (0)
|
||||
|
||||
#define SCTP_DECR_STRMOQ_COUNT() \
|
||||
do { \
|
||||
sctppcbinfo.ipi_count_strmoq--; \
|
||||
} while (0)
|
||||
|
||||
|
||||
/* these were in sctp_lock_empty.h but aren't in sctp_lock_bsd.h ... */
|
||||
#if 0
|
||||
#define SCTP_IPI_ADDR_LOCK()
|
||||
#define SCTP_IPI_ADDR_UNLOCK()
|
||||
#endif
|
||||
|
||||
|
||||
/* These were in sctp_lock_empty.h because they were commented out within
|
||||
* within user_include/user_socketvar.h . If they are NOT commented out
|
||||
* in user_socketvar.h (because that seems the more natural place for them
|
||||
* to live), then change this "if" to 0. Keep the "if" as 1 if these ARE
|
||||
* indeed commented out in user_socketvar.h .
|
||||
*
|
||||
* This modularity is kept so this file can easily be chosen as an alternative
|
||||
* to SCTP_PROCESS_LEVEL_LOCKS. If one defines SCTP_PROCESS_LEVEL_LOCKS in
|
||||
* user_include/opt_sctp.h, then the file sctp_process_lock.h (which we didn't
|
||||
* implement) is used, and that declares these locks already (so using
|
||||
* SCTP_PROCESS_LEVEL_LOCKS *requires* that these defintions be commented out
|
||||
* in user_socketvar.h).
|
||||
*/
|
||||
#if 1
|
||||
#define SOCK_LOCK(_so)
|
||||
#define SOCK_UNLOCK(_so)
|
||||
#define SOCKBUF_LOCK(_so_buf)
|
||||
#define SOCKBUF_UNLOCK(_so_buf)
|
||||
#define SOCKBUF_LOCK_ASSERT(_so_buf)
|
||||
#endif
|
||||
|
||||
#endif
|
||||
89
TMessagesProj/jni/third_party/usrsctplib/netinet/sctp_os.h
vendored
Executable file
89
TMessagesProj/jni/third_party/usrsctplib/netinet/sctp_os.h
vendored
Executable file
|
|
@ -0,0 +1,89 @@
|
|||
/*-
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*
|
||||
* Copyright (c) 2006-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.
|
||||
*/
|
||||
|
||||
#if defined(__FreeBSD__) && !defined(__Userspace__)
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD: head/sys/netinet/sctp_os.h 365071 2020-09-01 21:19:14Z mjg $");
|
||||
#endif
|
||||
|
||||
#ifndef _NETINET_SCTP_OS_H_
|
||||
#define _NETINET_SCTP_OS_H_
|
||||
|
||||
/*
|
||||
* General kernel memory allocation:
|
||||
* SCTP_MALLOC(element, type, size, name)
|
||||
* SCTP_FREE(element)
|
||||
* Kernel memory allocation for "soname"- memory must be zeroed.
|
||||
* SCTP_MALLOC_SONAME(name, type, size)
|
||||
* SCTP_FREE_SONAME(name)
|
||||
*/
|
||||
|
||||
/*
|
||||
* Zone(pool) allocation routines: MUST be defined for each OS.
|
||||
* zone = zone/pool pointer.
|
||||
* name = string name of the zone/pool.
|
||||
* size = size of each zone/pool element.
|
||||
* number = number of elements in zone/pool.
|
||||
* type = structure type to allocate
|
||||
*
|
||||
* sctp_zone_t
|
||||
* SCTP_ZONE_INIT(zone, name, size, number)
|
||||
* SCTP_ZONE_GET(zone, type)
|
||||
* SCTP_ZONE_FREE(zone, element)
|
||||
* SCTP_ZONE_DESTROY(zone)
|
||||
*/
|
||||
|
||||
#if defined(__FreeBSD__) && !defined(__Userspace__)
|
||||
#include <netinet/sctp_os_bsd.h>
|
||||
#else
|
||||
#define MODULE_GLOBAL(_B) (_B)
|
||||
#endif
|
||||
#if defined(__Userspace__)
|
||||
#include <netinet/sctp_os_userspace.h>
|
||||
#endif
|
||||
#if defined(__APPLE__) && !defined(__Userspace__)
|
||||
#include <netinet/sctp_os_macosx.h>
|
||||
#endif
|
||||
#if defined(_WIN32) && !defined(__Userspace__)
|
||||
#include <netinet/sctp_os_windows.h>
|
||||
#endif
|
||||
|
||||
/* All os's must implement this address gatherer. If
|
||||
* no VRF's exist, then vrf 0 is the only one and all
|
||||
* addresses and ifn's live here.
|
||||
*/
|
||||
#define SCTP_DEFAULT_VRF 0
|
||||
void sctp_init_vrf_list(int vrfid);
|
||||
|
||||
#endif
|
||||
1144
TMessagesProj/jni/third_party/usrsctplib/netinet/sctp_os_userspace.h
vendored
Executable file
1144
TMessagesProj/jni/third_party/usrsctplib/netinet/sctp_os_userspace.h
vendored
Executable file
File diff suppressed because it is too large
Load diff
15035
TMessagesProj/jni/third_party/usrsctplib/netinet/sctp_output.c
vendored
Executable file
15035
TMessagesProj/jni/third_party/usrsctplib/netinet/sctp_output.c
vendored
Executable file
File diff suppressed because it is too large
Load diff
240
TMessagesProj/jni/third_party/usrsctplib/netinet/sctp_output.h
vendored
Executable file
240
TMessagesProj/jni/third_party/usrsctplib/netinet/sctp_output.h
vendored
Executable file
|
|
@ -0,0 +1,240 @@
|
|||
/*-
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#if defined(__FreeBSD__) && !defined(__Userspace__)
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD: head/sys/netinet/sctp_output.h 366114 2020-09-24 12:26:06Z tuexen $");
|
||||
#endif
|
||||
|
||||
#ifndef _NETINET_SCTP_OUTPUT_H_
|
||||
#define _NETINET_SCTP_OUTPUT_H_
|
||||
|
||||
#include <netinet/sctp_header.h>
|
||||
|
||||
#if defined(_KERNEL) || defined(__Userspace__)
|
||||
|
||||
struct mbuf *
|
||||
sctp_add_addresses_to_i_ia(struct sctp_inpcb *inp,
|
||||
struct sctp_tcb *stcb,
|
||||
struct sctp_scoping *scope,
|
||||
struct mbuf *m_at,
|
||||
int cnt_inits_to,
|
||||
uint16_t *padding_len, uint16_t *chunk_len);
|
||||
|
||||
int sctp_is_addr_restricted(struct sctp_tcb *, struct sctp_ifa *);
|
||||
|
||||
int
|
||||
sctp_is_address_in_scope(struct sctp_ifa *ifa,
|
||||
struct sctp_scoping *scope,
|
||||
int do_update);
|
||||
|
||||
int
|
||||
sctp_is_addr_in_ep(struct sctp_inpcb *inp, struct sctp_ifa *ifa);
|
||||
|
||||
struct sctp_ifa *
|
||||
sctp_source_address_selection(struct sctp_inpcb *inp,
|
||||
struct sctp_tcb *stcb,
|
||||
sctp_route_t *ro, struct sctp_nets *net,
|
||||
int non_asoc_addr_ok, uint32_t vrf_id);
|
||||
|
||||
#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__Userspace__)
|
||||
int sctp_v6src_match_nexthop(struct sockaddr_in6 *src6, sctp_route_t *ro);
|
||||
|
||||
int sctp_v4src_match_nexthop(struct sctp_ifa *sifa, sctp_route_t *ro);
|
||||
#endif
|
||||
|
||||
void sctp_send_initiate(struct sctp_inpcb *, struct sctp_tcb *, int);
|
||||
|
||||
void
|
||||
sctp_send_initiate_ack(struct sctp_inpcb *, struct sctp_tcb *,
|
||||
struct sctp_nets *, struct mbuf *,
|
||||
int, int,
|
||||
struct sockaddr *, struct sockaddr *,
|
||||
struct sctphdr *, struct sctp_init_chunk *,
|
||||
#if defined(__FreeBSD__) && !defined(__Userspace__)
|
||||
uint8_t, uint32_t,
|
||||
#endif
|
||||
uint32_t, uint16_t);
|
||||
|
||||
struct mbuf *
|
||||
sctp_arethere_unrecognized_parameters(struct mbuf *, int, int *,
|
||||
struct sctp_chunkhdr *, int *, int *);
|
||||
void sctp_queue_op_err(struct sctp_tcb *, struct mbuf *);
|
||||
|
||||
int
|
||||
sctp_send_cookie_echo(struct mbuf *, int, int, struct sctp_tcb *,
|
||||
struct sctp_nets *);
|
||||
|
||||
void sctp_send_cookie_ack(struct sctp_tcb *);
|
||||
|
||||
void
|
||||
sctp_send_heartbeat_ack(struct sctp_tcb *, struct mbuf *, int, int,
|
||||
struct sctp_nets *);
|
||||
|
||||
void
|
||||
sctp_remove_from_wheel(struct sctp_tcb *stcb,
|
||||
struct sctp_association *asoc,
|
||||
struct sctp_stream_out *strq, int holds_lock);
|
||||
|
||||
void sctp_send_shutdown(struct sctp_tcb *, struct sctp_nets *);
|
||||
|
||||
void sctp_send_shutdown_ack(struct sctp_tcb *, struct sctp_nets *);
|
||||
|
||||
void sctp_send_shutdown_complete(struct sctp_tcb *, struct sctp_nets *, int);
|
||||
|
||||
void sctp_send_shutdown_complete2(struct sockaddr *, struct sockaddr *,
|
||||
struct sctphdr *,
|
||||
#if defined(__FreeBSD__) && !defined(__Userspace__)
|
||||
uint8_t, uint32_t, uint16_t,
|
||||
#endif
|
||||
uint32_t, uint16_t);
|
||||
|
||||
void sctp_send_asconf(struct sctp_tcb *, struct sctp_nets *, int addr_locked);
|
||||
|
||||
void sctp_send_asconf_ack(struct sctp_tcb *);
|
||||
|
||||
int sctp_get_frag_point(struct sctp_tcb *, struct sctp_association *);
|
||||
|
||||
void sctp_toss_old_cookies(struct sctp_tcb *, struct sctp_association *);
|
||||
|
||||
void sctp_toss_old_asconf(struct sctp_tcb *);
|
||||
|
||||
void sctp_fix_ecn_echo(struct sctp_association *);
|
||||
|
||||
void sctp_move_chunks_from_net(struct sctp_tcb *stcb, struct sctp_nets *net);
|
||||
|
||||
#define SCTP_DATA_CHUNK_OVERHEAD(stcb) ((stcb)->asoc.idata_supported ? \
|
||||
sizeof(struct sctp_idata_chunk) : \
|
||||
sizeof(struct sctp_data_chunk))
|
||||
|
||||
#if defined(__FreeBSD__) && !defined(__Userspace__)
|
||||
int
|
||||
sctp_output(struct sctp_inpcb *, struct mbuf *, struct sockaddr *,
|
||||
struct mbuf *, struct thread *, int);
|
||||
#elif defined(_WIN32) && !defined(__Userspace__)
|
||||
sctp_output(struct sctp_inpcb *, struct mbuf *, struct sockaddr *,
|
||||
struct mbuf *, PKTHREAD, int);
|
||||
#else
|
||||
#if defined(__Userspace__)
|
||||
/* sctp_output is called bu sctp_sendm. Not using sctp_sendm for __Userspace__ */
|
||||
#endif
|
||||
int
|
||||
sctp_output(struct sctp_inpcb *,
|
||||
struct mbuf *,
|
||||
struct sockaddr *,
|
||||
struct mbuf *,
|
||||
struct proc *, int);
|
||||
#endif
|
||||
|
||||
void sctp_chunk_output(struct sctp_inpcb *, struct sctp_tcb *, int, int);
|
||||
|
||||
void sctp_send_abort_tcb(struct sctp_tcb *, struct mbuf *, int);
|
||||
|
||||
void send_forward_tsn(struct sctp_tcb *, struct sctp_association *);
|
||||
|
||||
void sctp_send_sack(struct sctp_tcb *, int);
|
||||
|
||||
void sctp_send_hb(struct sctp_tcb *, struct sctp_nets *, int);
|
||||
|
||||
void sctp_send_ecn_echo(struct sctp_tcb *, struct sctp_nets *, uint32_t);
|
||||
|
||||
void
|
||||
sctp_send_packet_dropped(struct sctp_tcb *, struct sctp_nets *, struct mbuf *,
|
||||
int, int, int);
|
||||
|
||||
void sctp_send_cwr(struct sctp_tcb *, struct sctp_nets *, uint32_t, uint8_t);
|
||||
|
||||
void
|
||||
sctp_add_stream_reset_result(struct sctp_tmit_chunk *, uint32_t, uint32_t);
|
||||
|
||||
void
|
||||
sctp_send_deferred_reset_response(struct sctp_tcb *,
|
||||
struct sctp_stream_reset_list *,
|
||||
int);
|
||||
|
||||
void
|
||||
sctp_add_stream_reset_result_tsn(struct sctp_tmit_chunk *,
|
||||
uint32_t, uint32_t, uint32_t, uint32_t);
|
||||
int
|
||||
sctp_send_stream_reset_out_if_possible(struct sctp_tcb *, int);
|
||||
|
||||
int
|
||||
sctp_send_str_reset_req(struct sctp_tcb *, uint16_t , uint16_t *,
|
||||
uint8_t, uint8_t, uint8_t, uint16_t, uint16_t, uint8_t);
|
||||
|
||||
void
|
||||
sctp_send_abort(struct mbuf *, int, struct sockaddr *, struct sockaddr *,
|
||||
struct sctphdr *, uint32_t, struct mbuf *,
|
||||
#if defined(__FreeBSD__) && !defined(__Userspace__)
|
||||
uint8_t, uint32_t, uint16_t,
|
||||
#endif
|
||||
uint32_t, uint16_t);
|
||||
|
||||
void
|
||||
sctp_send_operr_to(struct sockaddr *, struct sockaddr *,
|
||||
struct sctphdr *, uint32_t, struct mbuf *,
|
||||
#if defined(__FreeBSD__) && !defined(__Userspace__)
|
||||
uint8_t, uint32_t, uint16_t,
|
||||
#endif
|
||||
uint32_t, uint16_t);
|
||||
|
||||
#endif /* _KERNEL || __Userspace__ */
|
||||
|
||||
#if defined(_KERNEL) || defined(__Userspace__)
|
||||
int
|
||||
sctp_sosend(struct socket *so,
|
||||
struct sockaddr *addr,
|
||||
struct uio *uio,
|
||||
struct mbuf *top,
|
||||
struct mbuf *control,
|
||||
#if defined(__APPLE__) && !defined(__Userspace__)
|
||||
int flags
|
||||
#else
|
||||
int flags,
|
||||
#if defined(__FreeBSD__) && !defined(__Userspace__)
|
||||
struct thread *p
|
||||
#elif defined(_WIN32) && !defined(__Userspace__)
|
||||
PKTHREAD p
|
||||
#else
|
||||
#if defined(__Userspace__)
|
||||
/* proc is a dummy in __Userspace__ and will not be passed to sctp_lower_sosend */
|
||||
#endif
|
||||
struct proc *p
|
||||
#endif
|
||||
#endif
|
||||
);
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
8078
TMessagesProj/jni/third_party/usrsctplib/netinet/sctp_pcb.c
vendored
Executable file
8078
TMessagesProj/jni/third_party/usrsctplib/netinet/sctp_pcb.c
vendored
Executable file
File diff suppressed because it is too large
Load diff
882
TMessagesProj/jni/third_party/usrsctplib/netinet/sctp_pcb.h
vendored
Executable file
882
TMessagesProj/jni/third_party/usrsctplib/netinet/sctp_pcb.h
vendored
Executable file
|
|
@ -0,0 +1,882 @@
|
|||
/*-
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#if defined(__FreeBSD__) && !defined(__Userspace__)
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
#endif
|
||||
|
||||
#ifndef _NETINET_SCTP_PCB_H_
|
||||
#define _NETINET_SCTP_PCB_H_
|
||||
|
||||
#include <netinet/sctp_os.h>
|
||||
#include <netinet/sctp.h>
|
||||
#include <netinet/sctp_constants.h>
|
||||
#include <netinet/sctp_sysctl.h>
|
||||
|
||||
LIST_HEAD(sctppcbhead, sctp_inpcb);
|
||||
LIST_HEAD(sctpasochead, sctp_tcb);
|
||||
LIST_HEAD(sctpladdr, sctp_laddr);
|
||||
LIST_HEAD(sctpvtaghead, sctp_tagblock);
|
||||
LIST_HEAD(sctp_vrflist, sctp_vrf);
|
||||
LIST_HEAD(sctp_ifnlist, sctp_ifn);
|
||||
LIST_HEAD(sctp_ifalist, sctp_ifa);
|
||||
TAILQ_HEAD(sctp_readhead, sctp_queued_to_read);
|
||||
TAILQ_HEAD(sctp_streamhead, sctp_stream_queue_pending);
|
||||
|
||||
#include <netinet/sctp_structs.h>
|
||||
#include <netinet/sctp_auth.h>
|
||||
|
||||
#define SCTP_PCBHASH_ALLADDR(port, mask) (port & mask)
|
||||
#define SCTP_PCBHASH_ASOC(tag, mask) (tag & mask)
|
||||
|
||||
struct sctp_vrf {
|
||||
LIST_ENTRY (sctp_vrf) next_vrf;
|
||||
struct sctp_ifalist *vrf_addr_hash;
|
||||
struct sctp_ifnlist ifnlist;
|
||||
uint32_t vrf_id;
|
||||
uint32_t tbl_id_v4; /* default v4 table id */
|
||||
uint32_t tbl_id_v6; /* default v6 table id */
|
||||
uint32_t total_ifa_count;
|
||||
u_long vrf_addr_hashmark;
|
||||
uint32_t refcount;
|
||||
};
|
||||
|
||||
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 {
|
||||
uint32_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 */
|
||||
};
|
||||
|
||||
struct sctp_tagblock {
|
||||
LIST_ENTRY(sctp_tagblock) sctp_nxt_tagblock;
|
||||
struct sctp_timewait vtag_block[SCTP_NUMBER_IN_VTAG_BLOCK];
|
||||
};
|
||||
|
||||
struct sctp_epinfo {
|
||||
#if defined(__FreeBSD__) && !defined(__Userspace__)
|
||||
#ifdef INET
|
||||
struct socket *udp4_tun_socket;
|
||||
#endif
|
||||
#ifdef INET6
|
||||
struct socket *udp6_tun_socket;
|
||||
#endif
|
||||
#endif
|
||||
struct sctpasochead *sctp_asochash;
|
||||
u_long hashasocmark;
|
||||
|
||||
struct sctppcbhead *sctp_ephash;
|
||||
u_long hashmark;
|
||||
|
||||
/*-
|
||||
* 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_vrflist *sctp_vrfhash;
|
||||
u_long hashvrfmark;
|
||||
|
||||
struct sctp_ifnlist *vrf_ifn_hash;
|
||||
u_long vrf_ifn_hashmark;
|
||||
|
||||
struct sctppcbhead listhead;
|
||||
struct sctpladdr addr_wq;
|
||||
|
||||
#if defined(__APPLE__) && !defined(__Userspace__)
|
||||
struct inpcbhead inplisthead;
|
||||
struct inpcbinfo sctbinfo;
|
||||
#endif
|
||||
/* ep zone info */
|
||||
sctp_zone_t ipi_zone_ep;
|
||||
sctp_zone_t ipi_zone_asoc;
|
||||
sctp_zone_t ipi_zone_laddr;
|
||||
sctp_zone_t ipi_zone_net;
|
||||
sctp_zone_t ipi_zone_chunk;
|
||||
sctp_zone_t ipi_zone_readq;
|
||||
sctp_zone_t ipi_zone_strmoq;
|
||||
sctp_zone_t ipi_zone_asconf;
|
||||
sctp_zone_t ipi_zone_asconf_ack;
|
||||
|
||||
#if defined(__FreeBSD__) && !defined(__Userspace__)
|
||||
struct rwlock ipi_ep_mtx;
|
||||
struct mtx ipi_iterator_wq_mtx;
|
||||
struct rwlock ipi_addr_mtx;
|
||||
struct mtx ipi_pktlog_mtx;
|
||||
struct mtx wq_addr_mtx;
|
||||
#elif defined(SCTP_PROCESS_LEVEL_LOCKS)
|
||||
userland_mutex_t ipi_ep_mtx;
|
||||
userland_mutex_t ipi_addr_mtx;
|
||||
userland_mutex_t ipi_count_mtx;
|
||||
userland_mutex_t ipi_pktlog_mtx;
|
||||
userland_mutex_t wq_addr_mtx;
|
||||
#elif defined(__APPLE__) && !defined(__Userspace__)
|
||||
#ifdef _KERN_LOCKS_H_
|
||||
lck_mtx_t *ipi_addr_mtx;
|
||||
lck_mtx_t *ipi_count_mtx;
|
||||
lck_mtx_t *ipi_pktlog_mtx;
|
||||
lck_mtx_t *logging_mtx;
|
||||
lck_mtx_t *wq_addr_mtx;
|
||||
#else
|
||||
void *ipi_count_mtx;
|
||||
void *logging_mtx;
|
||||
#endif /* _KERN_LOCKS_H_ */
|
||||
#elif defined(_WIN32) && !defined(__Userspace__)
|
||||
struct rwlock ipi_ep_lock;
|
||||
struct rwlock ipi_addr_lock;
|
||||
struct spinlock ipi_pktlog_mtx;
|
||||
struct rwlock wq_addr_mtx;
|
||||
#elif defined(__Userspace__)
|
||||
#endif
|
||||
uint32_t ipi_count_ep;
|
||||
|
||||
/* assoc/tcb zone info */
|
||||
uint32_t ipi_count_asoc;
|
||||
|
||||
/* local addrlist zone info */
|
||||
uint32_t ipi_count_laddr;
|
||||
|
||||
/* remote addrlist zone info */
|
||||
uint32_t ipi_count_raddr;
|
||||
|
||||
/* chunk structure list for output */
|
||||
uint32_t ipi_count_chunk;
|
||||
|
||||
/* socket queue zone info */
|
||||
uint32_t ipi_count_readq;
|
||||
|
||||
/* socket queue zone info */
|
||||
uint32_t ipi_count_strmoq;
|
||||
|
||||
/* Number of vrfs */
|
||||
uint32_t ipi_count_vrfs;
|
||||
|
||||
/* Number of ifns */
|
||||
uint32_t ipi_count_ifns;
|
||||
|
||||
/* Number of ifas */
|
||||
uint32_t ipi_count_ifas;
|
||||
|
||||
/* system wide number of free chunks hanging around */
|
||||
uint32_t ipi_free_chunks;
|
||||
uint32_t ipi_free_strmoq;
|
||||
|
||||
struct sctpvtaghead vtag_timewait[SCTP_STACK_VTAG_HASH_SIZE];
|
||||
|
||||
/* address work queue handling */
|
||||
struct sctp_timer addr_wq_timer;
|
||||
|
||||
#if defined(_SCTP_NEEDS_CALLOUT_) || defined(_USER_SCTP_NEEDS_CALLOUT_)
|
||||
struct calloutlist callqueue;
|
||||
#endif
|
||||
};
|
||||
|
||||
struct sctp_base_info {
|
||||
/* All static structures that
|
||||
* anchor the system must be here.
|
||||
*/
|
||||
struct sctp_epinfo sctppcbinfo;
|
||||
#if defined(__FreeBSD__) && !defined(__Userspace__)
|
||||
#if defined(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;
|
||||
#if defined(SCTP_PACKET_LOGGING)
|
||||
int packet_log_writers;
|
||||
int packet_log_end;
|
||||
uint8_t packet_log_buffer[SCTP_PACKET_LOG_SIZE];
|
||||
#endif
|
||||
#if defined(__FreeBSD__) && !defined(__Userspace__)
|
||||
eventhandler_tag eh_tag;
|
||||
#endif
|
||||
#if defined(__APPLE__) && !defined(__Userspace__)
|
||||
int sctp_main_timer_ticks;
|
||||
#endif
|
||||
#if defined(__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;
|
||||
#if defined(INET) || defined(INET6)
|
||||
int userspace_route;
|
||||
userland_thread_t recvthreadroute;
|
||||
#endif
|
||||
#endif
|
||||
#ifdef INET
|
||||
#if defined(_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
|
||||
#if defined(_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)(const char *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 {
|
||||
unsigned int time_of_secret_change; /* number of seconds from
|
||||
* timeval.tv_sec */
|
||||
uint32_t secret_key[SCTP_HOW_MANY_SECRETS][SCTP_NUMBER_OF_SECRETS];
|
||||
unsigned int size_of_a_cookie;
|
||||
|
||||
uint32_t sctp_timeoutticks[SCTP_NUM_TMRS];
|
||||
uint32_t sctp_minrto;
|
||||
uint32_t sctp_maxrto;
|
||||
uint32_t initial_rto;
|
||||
uint32_t initial_init_rto_max;
|
||||
|
||||
unsigned int sctp_sack_freq;
|
||||
uint32_t sctp_sws_sender;
|
||||
uint32_t sctp_sws_receiver;
|
||||
|
||||
uint32_t sctp_default_cc_module;
|
||||
uint32_t sctp_default_ss_module;
|
||||
/* authentication related fields */
|
||||
struct sctp_keyhead shared_keys;
|
||||
sctp_auth_chklist_t *local_auth_chunks;
|
||||
sctp_hmaclist_t *local_hmacs;
|
||||
uint16_t default_keyid;
|
||||
uint32_t default_mtu;
|
||||
|
||||
/* 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;
|
||||
|
||||
uint32_t def_cookie_life;
|
||||
/* defaults to 0 */
|
||||
uint32_t auto_close_time;
|
||||
uint32_t initial_sequence_debug;
|
||||
uint32_t adaptation_layer_indicator;
|
||||
uint8_t adaptation_layer_indicator_provided;
|
||||
uint32_t store_at;
|
||||
uint32_t max_burst;
|
||||
uint32_t fr_max_burst;
|
||||
#ifdef INET6
|
||||
uint32_t default_flowlabel;
|
||||
#endif
|
||||
uint8_t default_dscp;
|
||||
char current_secret_number;
|
||||
char last_secret_number;
|
||||
uint16_t port; /* remote UDP encapsulation port */
|
||||
};
|
||||
|
||||
#ifndef SCTP_ALIGNMENT
|
||||
#define SCTP_ALIGNMENT 32
|
||||
#endif
|
||||
|
||||
#ifndef SCTP_ALIGNM1
|
||||
#define SCTP_ALIGNM1 (SCTP_ALIGNMENT-1)
|
||||
#endif
|
||||
|
||||
#define sctp_lport ip_inp.inp.inp_lport
|
||||
|
||||
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;
|
||||
#if defined(__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;
|
||||
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;
|
||||
#if defined(__FreeBSD__) && !defined(__Userspace__)
|
||||
struct mtx inp_mtx;
|
||||
struct mtx inp_create_mtx;
|
||||
struct mtx inp_rdata_mtx;
|
||||
int32_t refcount;
|
||||
#elif defined(SCTP_PROCESS_LEVEL_LOCKS)
|
||||
userland_mutex_t inp_mtx;
|
||||
userland_mutex_t inp_create_mtx;
|
||||
userland_mutex_t inp_rdata_mtx;
|
||||
int32_t refcount;
|
||||
#elif defined(__APPLE__) && !defined(__Userspace__)
|
||||
#if defined(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;
|
||||
#elif defined(_WIN32) && !defined(__Userspace__)
|
||||
struct rwlock inp_lock;
|
||||
struct spinlock inp_create_lock;
|
||||
struct spinlock inp_rdata_lock;
|
||||
int32_t refcount;
|
||||
#elif defined(__Userspace__)
|
||||
int32_t refcount;
|
||||
#endif
|
||||
#if defined(__APPLE__) && !defined(__Userspace__)
|
||||
int32_t refcount;
|
||||
|
||||
uint32_t lock_caller1;
|
||||
uint32_t lock_caller2;
|
||||
uint32_t lock_caller3;
|
||||
uint32_t unlock_caller1;
|
||||
uint32_t unlock_caller2;
|
||||
uint32_t unlock_caller3;
|
||||
uint32_t getlock_caller1;
|
||||
uint32_t getlock_caller2;
|
||||
uint32_t getlock_caller3;
|
||||
uint32_t gen_count;
|
||||
uint32_t lock_gen_count;
|
||||
uint32_t unlock_gen_count;
|
||||
uint32_t getlock_gen_count;
|
||||
|
||||
uint32_t i_am_here_file;
|
||||
uint32_t i_am_here_line;
|
||||
#endif
|
||||
uint32_t def_vrf_id;
|
||||
uint16_t fibnum;
|
||||
#ifdef SCTP_MVRF
|
||||
uint32_t *m_vrf_ids;
|
||||
uint32_t num_vrfs;
|
||||
uint32_t vrf_size;
|
||||
#endif
|
||||
uint32_t total_sends;
|
||||
uint32_t total_recvs;
|
||||
uint32_t last_abort_code;
|
||||
uint32_t total_nospaces;
|
||||
struct sctpasochead *sctp_asocidhash;
|
||||
u_long hashasocidmark;
|
||||
uint32_t sctp_associd_counter;
|
||||
|
||||
#ifdef SCTP_ASOCLOG_OF_TSNS
|
||||
struct sctp_pcbtsn_rlog readlog[SCTP_READ_LOG_SIZE];
|
||||
uint32_t readlog_index;
|
||||
#endif
|
||||
#if defined(__Userspace__)
|
||||
void *ulp_info;
|
||||
int (*recv_callback)(struct socket *, union sctp_sockstore, void *, size_t,
|
||||
struct sctp_rcvinfo, int, void *);
|
||||
uint32_t send_sb_threshold;
|
||||
int (*send_callback)(struct socket *, uint32_t, void *);
|
||||
#endif
|
||||
};
|
||||
|
||||
#if defined(__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;
|
||||
#if defined(__FreeBSD__) && !defined(__Userspace__)
|
||||
struct mtx tcb_mtx;
|
||||
struct mtx tcb_send_mtx;
|
||||
#elif defined(SCTP_PROCESS_LEVEL_LOCKS)
|
||||
userland_mutex_t tcb_mtx;
|
||||
userland_mutex_t tcb_send_mtx;
|
||||
#elif defined(__APPLE__) && !defined(__Userspace__)
|
||||
lck_mtx_t* tcb_mtx;
|
||||
lck_mtx_t* tcb_send_mtx;
|
||||
#elif defined(_WIN32) && !defined(__Userspace__)
|
||||
struct spinlock tcb_lock;
|
||||
struct spinlock tcb_send_lock;
|
||||
#elif defined(__Userspace__)
|
||||
#endif
|
||||
#if defined(__APPLE__) && !defined(__Userspace__)
|
||||
uint32_t caller1;
|
||||
uint32_t caller2;
|
||||
uint32_t caller3;
|
||||
#endif
|
||||
};
|
||||
|
||||
#if defined(__FreeBSD__) && !defined(__Userspace__)
|
||||
#include <netinet/sctp_lock_bsd.h>
|
||||
#elif defined(__APPLE__) && !defined(__Userspace__)
|
||||
/*
|
||||
* Apple MacOS X 10.4 "Tiger"
|
||||
*/
|
||||
|
||||
#include <netinet/sctp_lock_apple_fg.h>
|
||||
|
||||
#elif defined(SCTP_PROCESS_LEVEL_LOCKS)
|
||||
|
||||
#include <netinet/sctp_process_lock.h>
|
||||
|
||||
#elif defined(_WIN32) && !defined(__Userspace__)
|
||||
|
||||
#include <netinet/sctp_lock_windows.h>
|
||||
|
||||
#elif defined(__Userspace__)
|
||||
|
||||
#include <netinet/sctp_lock_userspace.h>
|
||||
|
||||
#else
|
||||
/*
|
||||
* Pre-5.x FreeBSD, and others.
|
||||
*/
|
||||
#include <netinet/sctp_lock_empty.h>
|
||||
#endif
|
||||
|
||||
#if defined(_KERNEL) || defined(__Userspace__)
|
||||
|
||||
/* Attention Julian, this is the extern that
|
||||
* goes with the base info. sctp_pcb.c has
|
||||
* the real definition.
|
||||
*/
|
||||
#if defined(__FreeBSD__) && !defined(__Userspace__)
|
||||
VNET_DECLARE(struct sctp_base_info, system_base_info);
|
||||
#else
|
||||
extern struct sctp_base_info system_base_info;
|
||||
#endif
|
||||
|
||||
#ifdef INET6
|
||||
int SCTP6_ARE_ADDR_EQUAL(struct sockaddr_in6 *a, struct sockaddr_in6 *b);
|
||||
#endif
|
||||
|
||||
void sctp_fill_pcbinfo(struct sctp_pcbinfo *);
|
||||
|
||||
struct sctp_ifn *
|
||||
sctp_find_ifn(void *ifn, uint32_t ifn_index);
|
||||
|
||||
struct sctp_vrf *sctp_allocate_vrf(int vrfid);
|
||||
struct sctp_vrf *sctp_find_vrf(uint32_t vrfid);
|
||||
void sctp_free_vrf(struct sctp_vrf *vrf);
|
||||
|
||||
/*-
|
||||
* 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, const char *if_name, uint32_t ifn_index);
|
||||
void sctp_mark_ifa_addr_up(uint32_t vrf_id, struct sockaddr *addr, const char *if_name, uint32_t ifn_index);
|
||||
|
||||
struct sctp_ifa *
|
||||
sctp_add_addr_to_vrf(uint32_t vrfid,
|
||||
void *ifn, uint32_t ifn_index, uint32_t ifn_type,
|
||||
const char *if_name,
|
||||
void *ifa, struct sockaddr *addr, uint32_t ifa_flags,
|
||||
int dynamic_add);
|
||||
|
||||
void sctp_update_ifn_mtu(uint32_t ifn_index, uint32_t mtu);
|
||||
|
||||
void sctp_free_ifn(struct sctp_ifn *sctp_ifnp);
|
||||
void sctp_free_ifa(struct sctp_ifa *sctp_ifap);
|
||||
|
||||
void sctp_del_addr_from_vrf(uint32_t vrfid, struct sockaddr *addr,
|
||||
uint32_t ifn_index, const char *if_name);
|
||||
|
||||
struct sctp_nets *sctp_findnet(struct sctp_tcb *, struct sockaddr *);
|
||||
|
||||
struct sctp_inpcb *sctp_pcb_findep(struct sockaddr *, int, int, uint32_t);
|
||||
|
||||
#if defined(__FreeBSD__) && !defined(__Userspace__)
|
||||
int
|
||||
sctp_inpcb_bind(struct socket *, struct sockaddr *,
|
||||
struct sctp_ifa *, struct thread *);
|
||||
int
|
||||
sctp_inpcb_bind_locked(struct sctp_inpcb *, struct sockaddr *,
|
||||
struct sctp_ifa *, struct thread *);
|
||||
#elif defined(_WIN32) && !defined(__Userspace__)
|
||||
int
|
||||
sctp_inpcb_bind(struct socket *, struct sockaddr *,
|
||||
struct sctp_ifa *, PKTHREAD);
|
||||
int
|
||||
sctp_inpcb_bind_locked(struct sctp_inpcb *, struct sockaddr *,
|
||||
struct sctp_ifa *, PKTHREAD);
|
||||
#else
|
||||
/* struct proc is a dummy for __Userspace__ */
|
||||
int
|
||||
sctp_inpcb_bind(struct socket *, struct sockaddr *,
|
||||
struct sctp_ifa *, struct proc *);
|
||||
int
|
||||
sctp_inpcb_bind_locked(struct sctp_inpcb *, struct sockaddr *,
|
||||
struct sctp_ifa *, struct proc *);
|
||||
#endif
|
||||
|
||||
struct sctp_tcb *
|
||||
sctp_findassociation_addr(struct mbuf *, int,
|
||||
struct sockaddr *, struct sockaddr *,
|
||||
struct sctphdr *, struct sctp_chunkhdr *, struct sctp_inpcb **,
|
||||
struct sctp_nets **, uint32_t vrf_id);
|
||||
|
||||
struct sctp_tcb *
|
||||
sctp_findassociation_addr_sa(struct sockaddr *,
|
||||
struct sockaddr *, struct sctp_inpcb **, struct sctp_nets **, int, uint32_t);
|
||||
|
||||
void
|
||||
sctp_move_pcb_and_assoc(struct sctp_inpcb *, struct sctp_inpcb *,
|
||||
struct sctp_tcb *);
|
||||
|
||||
/*-
|
||||
* 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);
|
||||
|
||||
struct sctp_tcb *
|
||||
sctp_findassociation_ep_asocid(struct sctp_inpcb *,
|
||||
sctp_assoc_t, int);
|
||||
|
||||
struct sctp_tcb *
|
||||
sctp_findassociation_ep_asconf(struct mbuf *, int, struct sockaddr *,
|
||||
struct sctphdr *, struct sctp_inpcb **, struct sctp_nets **, uint32_t vrf_id);
|
||||
|
||||
int sctp_inpcb_alloc(struct socket *so, uint32_t vrf_id);
|
||||
|
||||
int sctp_is_address_on_local_host(struct sockaddr *addr, uint32_t vrf_id);
|
||||
|
||||
void sctp_inpcb_free(struct sctp_inpcb *, int, int);
|
||||
|
||||
#define SCTP_DONT_INITIALIZE_AUTH_PARAMS 0
|
||||
#define SCTP_INITIALIZE_AUTH_PARAMS 1
|
||||
|
||||
#if defined(__FreeBSD__) && !defined(__Userspace__)
|
||||
struct sctp_tcb *
|
||||
sctp_aloc_assoc(struct sctp_inpcb *, struct sockaddr *,
|
||||
int *, uint32_t, uint32_t, uint32_t, uint16_t, uint16_t,
|
||||
struct thread *, int);
|
||||
struct sctp_tcb *
|
||||
sctp_aloc_assoc_connected(struct sctp_inpcb *, struct sockaddr *,
|
||||
int *, uint32_t, uint32_t, uint32_t, uint16_t, uint16_t,
|
||||
struct thread *, int);
|
||||
#elif defined(_WIN32) && !defined(__Userspace__)
|
||||
struct sctp_tcb *
|
||||
sctp_aloc_assoc(struct sctp_inpcb *, struct sockaddr *, int *, uint32_t,
|
||||
uint32_t, uint32_t, uint16_t, uint16_t, PKTHREAD, int);
|
||||
struct sctp_tcb *
|
||||
sctp_aloc_assoc_connected(struct sctp_inpcb *, struct sockaddr *, int *, uint32_t,
|
||||
uint32_t, uint32_t, uint16_t, uint16_t, PKTHREAD, int);
|
||||
#else
|
||||
/* proc will be NULL for __Userspace__ */
|
||||
struct sctp_tcb *
|
||||
sctp_aloc_assoc(struct sctp_inpcb *, struct sockaddr *, int *, uint32_t,
|
||||
uint32_t, uint32_t, uint16_t, uint16_t, struct proc *, int);
|
||||
struct sctp_tcb *
|
||||
sctp_aloc_assoc_connected(struct sctp_inpcb *, struct sockaddr *, int *, uint32_t,
|
||||
uint32_t, uint32_t, uint16_t, uint16_t, struct proc *, int);
|
||||
#endif
|
||||
|
||||
int sctp_free_assoc(struct sctp_inpcb *, struct sctp_tcb *, int, int);
|
||||
|
||||
void sctp_add_local_addr_ep(struct sctp_inpcb *, struct sctp_ifa *, uint32_t);
|
||||
|
||||
void sctp_del_local_addr_ep(struct sctp_inpcb *, struct sctp_ifa *);
|
||||
|
||||
int sctp_add_remote_addr(struct sctp_tcb *, struct sockaddr *, struct sctp_nets **, uint16_t, int, int);
|
||||
|
||||
void sctp_remove_net(struct sctp_tcb *, struct sctp_nets *);
|
||||
|
||||
int sctp_del_remote_addr(struct sctp_tcb *, struct sockaddr *);
|
||||
|
||||
#if defined(__Userspace__)
|
||||
void sctp_pcb_init(int);
|
||||
#else
|
||||
void sctp_pcb_init(void);
|
||||
#endif
|
||||
|
||||
void sctp_pcb_finish(void);
|
||||
|
||||
void sctp_add_local_addr_restricted(struct sctp_tcb *, struct sctp_ifa *);
|
||||
void sctp_del_local_addr_restricted(struct sctp_tcb *, struct sctp_ifa *);
|
||||
|
||||
int
|
||||
sctp_load_addresses_from_init(struct sctp_tcb *, struct mbuf *, int, int,
|
||||
struct sockaddr *, struct sockaddr *, struct sockaddr *, uint16_t);
|
||||
|
||||
int
|
||||
sctp_set_primary_addr(struct sctp_tcb *, struct sockaddr *,
|
||||
struct sctp_nets *);
|
||||
|
||||
bool
|
||||
sctp_is_vtag_good(uint32_t, uint16_t lport, uint16_t rport, struct timeval *);
|
||||
|
||||
/* void sctp_drain(void); */
|
||||
|
||||
int sctp_destination_is_reachable(struct sctp_tcb *, struct sockaddr *);
|
||||
|
||||
int sctp_swap_inpcb_for_listen(struct sctp_inpcb *inp);
|
||||
|
||||
void sctp_clean_up_stream(struct sctp_tcb *stcb, struct sctp_readhead *rh);
|
||||
|
||||
/*-
|
||||
* 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);
|
||||
#if defined(__FreeBSD__) && !defined(__Userspace__)
|
||||
#if defined(SCTP_MCORE_INPUT) && defined(SMP)
|
||||
void
|
||||
sctp_queue_to_mcore(struct mbuf *m, int off, int cpu_to_use);
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif /* _KERNEL */
|
||||
#endif /* !__sctp_pcb_h__ */
|
||||
302
TMessagesProj/jni/third_party/usrsctplib/netinet/sctp_peeloff.c
vendored
Executable file
302
TMessagesProj/jni/third_party/usrsctplib/netinet/sctp_peeloff.c
vendored
Executable file
|
|
@ -0,0 +1,302 @@
|
|||
/*-
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#if defined(__FreeBSD__) && !defined(__Userspace__)
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
#endif
|
||||
|
||||
#include <netinet/sctp_os.h>
|
||||
#include <netinet/sctp_pcb.h>
|
||||
#include <netinet/sctputil.h>
|
||||
#include <netinet/sctp_var.h>
|
||||
#include <netinet/sctp_var.h>
|
||||
#include <netinet/sctp_sysctl.h>
|
||||
#include <netinet/sctp.h>
|
||||
#include <netinet/sctp_uio.h>
|
||||
#include <netinet/sctp_peeloff.h>
|
||||
#include <netinet/sctputil.h>
|
||||
#include <netinet/sctp_auth.h>
|
||||
|
||||
int
|
||||
sctp_can_peel_off(struct socket *head, sctp_assoc_t assoc_id)
|
||||
{
|
||||
struct sctp_inpcb *inp;
|
||||
struct sctp_tcb *stcb;
|
||||
uint32_t state;
|
||||
|
||||
if (head == NULL) {
|
||||
SCTP_LTRACE_ERR_RET(NULL, NULL, NULL, SCTP_FROM_SCTP_PEELOFF, EBADF);
|
||||
return (EBADF);
|
||||
}
|
||||
inp = (struct sctp_inpcb *)head->so_pcb;
|
||||
if (inp == NULL) {
|
||||
SCTP_LTRACE_ERR_RET(NULL, NULL, NULL, SCTP_FROM_SCTP_PEELOFF, EFAULT);
|
||||
return (EFAULT);
|
||||
}
|
||||
if ((inp->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) ||
|
||||
(inp->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL)) {
|
||||
SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PEELOFF, EOPNOTSUPP);
|
||||
return (EOPNOTSUPP);
|
||||
}
|
||||
stcb = sctp_findassociation_ep_asocid(inp, assoc_id, 1);
|
||||
if (stcb == NULL) {
|
||||
SCTP_LTRACE_ERR_RET(inp, stcb, NULL, SCTP_FROM_SCTP_PEELOFF, ENOENT);
|
||||
return (ENOENT);
|
||||
}
|
||||
state = SCTP_GET_STATE(stcb);
|
||||
if ((state == SCTP_STATE_EMPTY) ||
|
||||
(state == SCTP_STATE_INUSE)) {
|
||||
SCTP_TCB_UNLOCK(stcb);
|
||||
SCTP_LTRACE_ERR_RET(inp, stcb, NULL, SCTP_FROM_SCTP_PEELOFF, ENOTCONN);
|
||||
return (ENOTCONN);
|
||||
}
|
||||
SCTP_TCB_UNLOCK(stcb);
|
||||
/* We are clear to peel this one off */
|
||||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
sctp_do_peeloff(struct socket *head, struct socket *so, sctp_assoc_t assoc_id)
|
||||
{
|
||||
struct sctp_inpcb *inp, *n_inp;
|
||||
struct sctp_tcb *stcb;
|
||||
uint32_t state;
|
||||
|
||||
inp = (struct sctp_inpcb *)head->so_pcb;
|
||||
if (inp == NULL) {
|
||||
SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PEELOFF, EFAULT);
|
||||
return (EFAULT);
|
||||
}
|
||||
stcb = sctp_findassociation_ep_asocid(inp, assoc_id, 1);
|
||||
if (stcb == NULL) {
|
||||
SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PEELOFF, ENOTCONN);
|
||||
return (ENOTCONN);
|
||||
}
|
||||
|
||||
state = SCTP_GET_STATE(stcb);
|
||||
if ((state == SCTP_STATE_EMPTY) ||
|
||||
(state == SCTP_STATE_INUSE)) {
|
||||
SCTP_TCB_UNLOCK(stcb);
|
||||
SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PEELOFF, ENOTCONN);
|
||||
return (ENOTCONN);
|
||||
}
|
||||
|
||||
n_inp = (struct sctp_inpcb *)so->so_pcb;
|
||||
n_inp->sctp_flags = (SCTP_PCB_FLAGS_UDPTYPE |
|
||||
SCTP_PCB_FLAGS_CONNECTED |
|
||||
SCTP_PCB_FLAGS_IN_TCPPOOL | /* Turn on Blocking IO */
|
||||
(SCTP_PCB_COPY_FLAGS & inp->sctp_flags));
|
||||
n_inp->sctp_socket = so;
|
||||
n_inp->sctp_features = inp->sctp_features;
|
||||
n_inp->sctp_mobility_features = inp->sctp_mobility_features;
|
||||
n_inp->sctp_frag_point = inp->sctp_frag_point;
|
||||
n_inp->sctp_cmt_on_off = inp->sctp_cmt_on_off;
|
||||
n_inp->ecn_supported = inp->ecn_supported;
|
||||
n_inp->prsctp_supported = inp->prsctp_supported;
|
||||
n_inp->auth_supported = inp->auth_supported;
|
||||
n_inp->asconf_supported = inp->asconf_supported;
|
||||
n_inp->reconfig_supported = inp->reconfig_supported;
|
||||
n_inp->nrsack_supported = inp->nrsack_supported;
|
||||
n_inp->pktdrop_supported = inp->pktdrop_supported;
|
||||
n_inp->partial_delivery_point = inp->partial_delivery_point;
|
||||
n_inp->sctp_context = inp->sctp_context;
|
||||
n_inp->max_cwnd = inp->max_cwnd;
|
||||
n_inp->local_strreset_support = inp->local_strreset_support;
|
||||
/* copy in the authentication parameters from the original endpoint */
|
||||
if (n_inp->sctp_ep.local_hmacs)
|
||||
sctp_free_hmaclist(n_inp->sctp_ep.local_hmacs);
|
||||
n_inp->sctp_ep.local_hmacs =
|
||||
sctp_copy_hmaclist(inp->sctp_ep.local_hmacs);
|
||||
if (n_inp->sctp_ep.local_auth_chunks)
|
||||
sctp_free_chunklist(n_inp->sctp_ep.local_auth_chunks);
|
||||
n_inp->sctp_ep.local_auth_chunks =
|
||||
sctp_copy_chunklist(inp->sctp_ep.local_auth_chunks);
|
||||
(void)sctp_copy_skeylist(&inp->sctp_ep.shared_keys,
|
||||
&n_inp->sctp_ep.shared_keys);
|
||||
#if defined(__Userspace__)
|
||||
n_inp->ulp_info = inp->ulp_info;
|
||||
n_inp->recv_callback = inp->recv_callback;
|
||||
n_inp->send_callback = inp->send_callback;
|
||||
n_inp->send_sb_threshold = inp->send_sb_threshold;
|
||||
#endif
|
||||
/*
|
||||
* Now we must move it from one hash table to another and get the
|
||||
* stcb in the right place.
|
||||
*/
|
||||
sctp_move_pcb_and_assoc(inp, n_inp, stcb);
|
||||
atomic_add_int(&stcb->asoc.refcnt, 1);
|
||||
SCTP_TCB_UNLOCK(stcb);
|
||||
|
||||
#if defined(__FreeBSD__) && !defined(__Userspace__)
|
||||
sctp_pull_off_control_to_new_inp(inp, n_inp, stcb, SBL_WAIT);
|
||||
#else
|
||||
sctp_pull_off_control_to_new_inp(inp, n_inp, stcb, M_WAITOK);
|
||||
#endif
|
||||
atomic_subtract_int(&stcb->asoc.refcnt, 1);
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
#if defined(HAVE_SCTP_PEELOFF_SOCKOPT)
|
||||
struct socket *
|
||||
sctp_get_peeloff(struct socket *head, sctp_assoc_t assoc_id, int *error)
|
||||
{
|
||||
struct socket *newso;
|
||||
struct sctp_inpcb *inp, *n_inp;
|
||||
struct sctp_tcb *stcb;
|
||||
|
||||
SCTPDBG(SCTP_DEBUG_PEEL1, "SCTP peel-off called\n");
|
||||
inp = (struct sctp_inpcb *)head->so_pcb;
|
||||
if (inp == NULL) {
|
||||
SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PEELOFF, EFAULT);
|
||||
*error = EFAULT;
|
||||
return (NULL);
|
||||
}
|
||||
stcb = sctp_findassociation_ep_asocid(inp, assoc_id, 1);
|
||||
if (stcb == NULL) {
|
||||
SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PEELOFF, ENOTCONN);
|
||||
*error = ENOTCONN;
|
||||
return (NULL);
|
||||
}
|
||||
atomic_add_int(&stcb->asoc.refcnt, 1);
|
||||
SCTP_TCB_UNLOCK(stcb);
|
||||
#if defined(__FreeBSD__) && !defined(__Userspace__)
|
||||
CURVNET_SET(head->so_vnet);
|
||||
#endif
|
||||
newso = sonewconn(head, SS_ISCONNECTED
|
||||
#if defined(__APPLE__) && !defined(__Userspace__)
|
||||
, NULL
|
||||
#endif
|
||||
);
|
||||
#if defined(__FreeBSD__) && !defined(__Userspace__)
|
||||
CURVNET_RESTORE();
|
||||
#endif
|
||||
if (newso == NULL) {
|
||||
SCTPDBG(SCTP_DEBUG_PEEL1, "sctp_peeloff:sonewconn failed\n");
|
||||
SCTP_LTRACE_ERR_RET(NULL, stcb, NULL, SCTP_FROM_SCTP_PEELOFF, ENOMEM);
|
||||
*error = ENOMEM;
|
||||
atomic_subtract_int(&stcb->asoc.refcnt, 1);
|
||||
return (NULL);
|
||||
|
||||
}
|
||||
#if defined(__APPLE__) && !defined(__Userspace__)
|
||||
else {
|
||||
SCTP_SOCKET_LOCK(newso, 1);
|
||||
}
|
||||
#endif
|
||||
SCTP_TCB_LOCK(stcb);
|
||||
atomic_subtract_int(&stcb->asoc.refcnt, 1);
|
||||
n_inp = (struct sctp_inpcb *)newso->so_pcb;
|
||||
SOCK_LOCK(head);
|
||||
n_inp->sctp_flags = (SCTP_PCB_FLAGS_UDPTYPE |
|
||||
SCTP_PCB_FLAGS_CONNECTED |
|
||||
SCTP_PCB_FLAGS_IN_TCPPOOL | /* Turn on Blocking IO */
|
||||
(SCTP_PCB_COPY_FLAGS & inp->sctp_flags));
|
||||
n_inp->sctp_features = inp->sctp_features;
|
||||
n_inp->sctp_frag_point = inp->sctp_frag_point;
|
||||
n_inp->sctp_cmt_on_off = inp->sctp_cmt_on_off;
|
||||
n_inp->ecn_supported = inp->ecn_supported;
|
||||
n_inp->prsctp_supported = inp->prsctp_supported;
|
||||
n_inp->auth_supported = inp->auth_supported;
|
||||
n_inp->asconf_supported = inp->asconf_supported;
|
||||
n_inp->reconfig_supported = inp->reconfig_supported;
|
||||
n_inp->nrsack_supported = inp->nrsack_supported;
|
||||
n_inp->pktdrop_supported = inp->pktdrop_supported;
|
||||
n_inp->partial_delivery_point = inp->partial_delivery_point;
|
||||
n_inp->sctp_context = inp->sctp_context;
|
||||
n_inp->max_cwnd = inp->max_cwnd;
|
||||
n_inp->local_strreset_support = inp->local_strreset_support;
|
||||
n_inp->inp_starting_point_for_iterator = NULL;
|
||||
#if defined(__Userspace__)
|
||||
n_inp->ulp_info = inp->ulp_info;
|
||||
n_inp->recv_callback = inp->recv_callback;
|
||||
n_inp->send_callback = inp->send_callback;
|
||||
n_inp->send_sb_threshold = inp->send_sb_threshold;
|
||||
#endif
|
||||
|
||||
/* copy in the authentication parameters from the original endpoint */
|
||||
if (n_inp->sctp_ep.local_hmacs)
|
||||
sctp_free_hmaclist(n_inp->sctp_ep.local_hmacs);
|
||||
n_inp->sctp_ep.local_hmacs =
|
||||
sctp_copy_hmaclist(inp->sctp_ep.local_hmacs);
|
||||
if (n_inp->sctp_ep.local_auth_chunks)
|
||||
sctp_free_chunklist(n_inp->sctp_ep.local_auth_chunks);
|
||||
n_inp->sctp_ep.local_auth_chunks =
|
||||
sctp_copy_chunklist(inp->sctp_ep.local_auth_chunks);
|
||||
(void)sctp_copy_skeylist(&inp->sctp_ep.shared_keys,
|
||||
&n_inp->sctp_ep.shared_keys);
|
||||
|
||||
n_inp->sctp_socket = newso;
|
||||
if (sctp_is_feature_on(inp, SCTP_PCB_FLAGS_AUTOCLOSE)) {
|
||||
sctp_feature_off(n_inp, SCTP_PCB_FLAGS_AUTOCLOSE);
|
||||
n_inp->sctp_ep.auto_close_time = 0;
|
||||
sctp_timer_stop(SCTP_TIMER_TYPE_AUTOCLOSE, n_inp, stcb, NULL,
|
||||
SCTP_FROM_SCTP_PEELOFF + SCTP_LOC_1);
|
||||
}
|
||||
/* Turn off any non-blocking semantic. */
|
||||
SOCK_LOCK(newso);
|
||||
SCTP_CLEAR_SO_NBIO(newso);
|
||||
newso->so_state |= SS_ISCONNECTED;
|
||||
SOCK_UNLOCK(newso);
|
||||
/* We remove it right away */
|
||||
|
||||
#ifdef SCTP_LOCK_LOGGING
|
||||
if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_LOCK_LOGGING_ENABLE) {
|
||||
sctp_log_lock(inp, (struct sctp_tcb *)NULL, SCTP_LOG_LOCK_SOCK);
|
||||
}
|
||||
#endif
|
||||
TAILQ_REMOVE(&head->so_comp, newso, so_list);
|
||||
head->so_qlen--;
|
||||
SOCK_UNLOCK(head);
|
||||
/*
|
||||
* Now we must move it from one hash table to another and get the
|
||||
* stcb in the right place.
|
||||
*/
|
||||
sctp_move_pcb_and_assoc(inp, n_inp, stcb);
|
||||
atomic_add_int(&stcb->asoc.refcnt, 1);
|
||||
SCTP_TCB_UNLOCK(stcb);
|
||||
/*
|
||||
* And now the final hack. We move data in the pending side i.e.
|
||||
* head to the new socket buffer. Let the GRUBBING begin :-0
|
||||
*/
|
||||
#if defined(__FreeBSD__) && !defined(__Userspace__)
|
||||
sctp_pull_off_control_to_new_inp(inp, n_inp, stcb, SBL_WAIT);
|
||||
#else
|
||||
sctp_pull_off_control_to_new_inp(inp, n_inp, stcb, M_WAITOK);
|
||||
#endif
|
||||
atomic_subtract_int(&stcb->asoc.refcnt, 1);
|
||||
return (newso);
|
||||
}
|
||||
#endif
|
||||
70
TMessagesProj/jni/third_party/usrsctplib/netinet/sctp_peeloff.h
vendored
Executable file
70
TMessagesProj/jni/third_party/usrsctplib/netinet/sctp_peeloff.h
vendored
Executable file
|
|
@ -0,0 +1,70 @@
|
|||
/*-
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#if defined(__FreeBSD__) && !defined(__Userspace__)
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD: head/sys/netinet/sctp_peeloff.h 309607 2016-12-06 10:21:25Z tuexen $");
|
||||
#endif
|
||||
|
||||
#ifndef _NETINET_SCTP_PEELOFF_H_
|
||||
#define _NETINET_SCTP_PEELOFF_H_
|
||||
#if defined(HAVE_SCTP_PEELOFF_SOCKOPT)
|
||||
/* socket option peeloff */
|
||||
struct sctp_peeloff_opt {
|
||||
#if !(defined(_WIN32) && !defined(__Userspace__))
|
||||
int s;
|
||||
#else
|
||||
HANDLE s;
|
||||
#endif
|
||||
sctp_assoc_t assoc_id;
|
||||
#if !(defined(_WIN32) && !defined(__Userspace__))
|
||||
int new_sd;
|
||||
#else
|
||||
HANDLE new_sd;
|
||||
#endif
|
||||
};
|
||||
#endif /* HAVE_SCTP_PEELOFF_SOCKOPT */
|
||||
#if defined(_KERNEL)
|
||||
int sctp_can_peel_off(struct socket *, sctp_assoc_t);
|
||||
int sctp_do_peeloff(struct socket *, struct socket *, sctp_assoc_t);
|
||||
#if defined(HAVE_SCTP_PEELOFF_SOCKOPT)
|
||||
struct socket *sctp_get_peeloff(struct socket *, sctp_assoc_t, int *);
|
||||
int sctp_peeloff_option(struct proc *p, struct sctp_peeloff_opt *peeloff);
|
||||
#endif /* HAVE_SCTP_PEELOFF_SOCKOPT */
|
||||
#endif /* _KERNEL */
|
||||
#if defined(__Userspace__)
|
||||
int sctp_can_peel_off(struct socket *, sctp_assoc_t);
|
||||
int sctp_do_peeloff(struct socket *, struct socket *, sctp_assoc_t);
|
||||
#endif /* __Userspace__ */
|
||||
#endif /* _NETINET_SCTP_PEELOFF_H_ */
|
||||
692
TMessagesProj/jni/third_party/usrsctplib/netinet/sctp_process_lock.h
vendored
Executable file
692
TMessagesProj/jni/third_party/usrsctplib/netinet/sctp_process_lock.h
vendored
Executable file
|
|
@ -0,0 +1,692 @@
|
|||
/*-
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*
|
||||
* Copyright (c) 2001-2007, by Cisco Systems, Inc. All rights reserved.
|
||||
* Copyright (c) 2008-2011, by Randall Stewart. All rights reserved.
|
||||
* Copyright (c) 2008-2011, 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.
|
||||
*/
|
||||
#ifndef __sctp_process_lock_h__
|
||||
#define __sctp_process_lock_h__
|
||||
|
||||
/*
|
||||
* Need to yet define five atomic fuctions or
|
||||
* their equivalant.
|
||||
* - atomic_add_int(&foo, val) - add atomically the value
|
||||
* - atomic_fetchadd_int(&foo, val) - does same as atomic_add_int
|
||||
* but value it was is returned.
|
||||
* - atomic_subtract_int(&foo, val) - can be made from atomic_add_int()
|
||||
*
|
||||
* - atomic_cmpset_int(&foo, value, newvalue) - Does a set of newvalue
|
||||
* in foo if and only if
|
||||
* foo is value. Returns 0
|
||||
* on success.
|
||||
*/
|
||||
|
||||
#ifdef SCTP_PER_SOCKET_LOCKING
|
||||
/*
|
||||
* per socket level locking
|
||||
*/
|
||||
|
||||
#if defined(_WIN32)
|
||||
/* Lock for INFO stuff */
|
||||
#define SCTP_INP_INFO_LOCK_INIT()
|
||||
#define SCTP_INP_INFO_RLOCK()
|
||||
#define SCTP_INP_INFO_RUNLOCK()
|
||||
#define SCTP_INP_INFO_WLOCK()
|
||||
#define SCTP_INP_INFO_WUNLOCK()
|
||||
#define SCTP_INP_INFO_LOCK_ASSERT()
|
||||
#define SCTP_INP_INFO_RLOCK_ASSERT()
|
||||
#define SCTP_INP_INFO_WLOCK_ASSERT()
|
||||
#define SCTP_INP_INFO_LOCK_DESTROY()
|
||||
#define SCTP_IPI_COUNT_INIT()
|
||||
#define SCTP_IPI_COUNT_DESTROY()
|
||||
#else
|
||||
#define SCTP_INP_INFO_LOCK_INIT()
|
||||
#define SCTP_INP_INFO_RLOCK()
|
||||
#define SCTP_INP_INFO_RUNLOCK()
|
||||
#define SCTP_INP_INFO_WLOCK()
|
||||
#define SCTP_INP_INFO_WUNLOCK()
|
||||
#define SCTP_INP_INFO_LOCK_ASSERT()
|
||||
#define SCTP_INP_INFO_RLOCK_ASSERT()
|
||||
#define SCTP_INP_INFO_WLOCK_ASSERT()
|
||||
#define SCTP_INP_INFO_LOCK_DESTROY()
|
||||
#define SCTP_IPI_COUNT_INIT()
|
||||
#define SCTP_IPI_COUNT_DESTROY()
|
||||
#endif
|
||||
|
||||
#define SCTP_TCB_SEND_LOCK_INIT(_tcb)
|
||||
#define SCTP_TCB_SEND_LOCK_DESTROY(_tcb)
|
||||
#define SCTP_TCB_SEND_LOCK(_tcb)
|
||||
#define SCTP_TCB_SEND_UNLOCK(_tcb)
|
||||
|
||||
/* Lock for INP */
|
||||
#define SCTP_INP_LOCK_INIT(_inp)
|
||||
#define SCTP_INP_LOCK_DESTROY(_inp)
|
||||
|
||||
#define SCTP_INP_RLOCK(_inp)
|
||||
#define SCTP_INP_RUNLOCK(_inp)
|
||||
#define SCTP_INP_WLOCK(_inp)
|
||||
#define SCTP_INP_WUNLOCK(_inp)
|
||||
#define SCTP_INP_RLOCK_ASSERT(_inp)
|
||||
#define SCTP_INP_WLOCK_ASSERT(_inp)
|
||||
#define SCTP_INP_INCR_REF(_inp)
|
||||
#define SCTP_INP_DECR_REF(_inp)
|
||||
|
||||
#define SCTP_ASOC_CREATE_LOCK_INIT(_inp)
|
||||
#define SCTP_ASOC_CREATE_LOCK_DESTROY(_inp)
|
||||
#define SCTP_ASOC_CREATE_LOCK(_inp)
|
||||
#define SCTP_ASOC_CREATE_UNLOCK(_inp)
|
||||
|
||||
#define SCTP_INP_READ_INIT(_inp)
|
||||
#define SCTP_INP_READ_DESTROY(_inp)
|
||||
#define SCTP_INP_READ_LOCK(_inp)
|
||||
#define SCTP_INP_READ_UNLOCK(_inp)
|
||||
|
||||
/* Lock for TCB */
|
||||
#define SCTP_TCB_LOCK_INIT(_tcb)
|
||||
#define SCTP_TCB_LOCK_DESTROY(_tcb)
|
||||
#define SCTP_TCB_LOCK(_tcb)
|
||||
#define SCTP_TCB_TRYLOCK(_tcb) 1
|
||||
#define SCTP_TCB_UNLOCK(_tcb)
|
||||
#define SCTP_TCB_UNLOCK_IFOWNED(_tcb)
|
||||
#define SCTP_TCB_LOCK_ASSERT(_tcb)
|
||||
|
||||
#else
|
||||
/*
|
||||
* per tcb level locking
|
||||
*/
|
||||
#define SCTP_IPI_COUNT_INIT()
|
||||
|
||||
#if defined(_WIN32)
|
||||
#define SCTP_WQ_ADDR_INIT() \
|
||||
InitializeCriticalSection(&SCTP_BASE_INFO(wq_addr_mtx))
|
||||
#define SCTP_WQ_ADDR_DESTROY() \
|
||||
DeleteCriticalSection(&SCTP_BASE_INFO(wq_addr_mtx))
|
||||
#define SCTP_WQ_ADDR_LOCK() \
|
||||
EnterCriticalSection(&SCTP_BASE_INFO(wq_addr_mtx))
|
||||
#define SCTP_WQ_ADDR_UNLOCK() \
|
||||
LeaveCriticalSection(&SCTP_BASE_INFO(wq_addr_mtx))
|
||||
#define SCTP_WQ_ADDR_LOCK_ASSERT()
|
||||
|
||||
#define SCTP_INP_INFO_LOCK_INIT() \
|
||||
InitializeCriticalSection(&SCTP_BASE_INFO(ipi_ep_mtx))
|
||||
#define SCTP_INP_INFO_LOCK_DESTROY() \
|
||||
DeleteCriticalSection(&SCTP_BASE_INFO(ipi_ep_mtx))
|
||||
#define SCTP_INP_INFO_RLOCK() \
|
||||
EnterCriticalSection(&SCTP_BASE_INFO(ipi_ep_mtx))
|
||||
#define SCTP_INP_INFO_TRYLOCK() \
|
||||
TryEnterCriticalSection(&SCTP_BASE_INFO(ipi_ep_mtx))
|
||||
#define SCTP_INP_INFO_WLOCK() \
|
||||
EnterCriticalSection(&SCTP_BASE_INFO(ipi_ep_mtx))
|
||||
#define SCTP_INP_INFO_RUNLOCK() \
|
||||
LeaveCriticalSection(&SCTP_BASE_INFO(ipi_ep_mtx))
|
||||
#define SCTP_INP_INFO_WUNLOCK() \
|
||||
LeaveCriticalSection(&SCTP_BASE_INFO(ipi_ep_mtx))
|
||||
#define SCTP_INP_INFO_LOCK_ASSERT()
|
||||
#define SCTP_INP_INFO_RLOCK_ASSERT()
|
||||
#define SCTP_INP_INFO_WLOCK_ASSERT()
|
||||
|
||||
#define SCTP_IP_PKTLOG_INIT() \
|
||||
InitializeCriticalSection(&SCTP_BASE_INFO(ipi_pktlog_mtx))
|
||||
#define SCTP_IP_PKTLOG_DESTROY () \
|
||||
DeleteCriticalSection(&SCTP_BASE_INFO(ipi_pktlog_mtx))
|
||||
#define SCTP_IP_PKTLOG_LOCK() \
|
||||
EnterCriticalSection(&SCTP_BASE_INFO(ipi_pktlog_mtx))
|
||||
#define SCTP_IP_PKTLOG_UNLOCK() \
|
||||
LeaveCriticalSection(&SCTP_BASE_INFO(ipi_pktlog_mtx))
|
||||
|
||||
/*
|
||||
* The INP locks we will use for locking an SCTP endpoint, so for example if
|
||||
* we want to change something at the endpoint level for example random_store
|
||||
* or cookie secrets we lock the INP level.
|
||||
*/
|
||||
#define SCTP_INP_READ_INIT(_inp) \
|
||||
InitializeCriticalSection(&(_inp)->inp_rdata_mtx)
|
||||
#define SCTP_INP_READ_DESTROY(_inp) \
|
||||
DeleteCriticalSection(&(_inp)->inp_rdata_mtx)
|
||||
#define SCTP_INP_READ_LOCK(_inp) \
|
||||
EnterCriticalSection(&(_inp)->inp_rdata_mtx)
|
||||
#define SCTP_INP_READ_UNLOCK(_inp) \
|
||||
LeaveCriticalSection(&(_inp)->inp_rdata_mtx)
|
||||
|
||||
#define SCTP_INP_LOCK_INIT(_inp) \
|
||||
InitializeCriticalSection(&(_inp)->inp_mtx)
|
||||
#define SCTP_INP_LOCK_DESTROY(_inp) \
|
||||
DeleteCriticalSection(&(_inp)->inp_mtx)
|
||||
#ifdef SCTP_LOCK_LOGGING
|
||||
#define SCTP_INP_RLOCK(_inp) do { \
|
||||
if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_LOCK_LOGGING_ENABLE) \
|
||||
sctp_log_lock(_inp, NULL, SCTP_LOG_LOCK_INP); \
|
||||
EnterCriticalSection(&(_inp)->inp_mtx); \
|
||||
} while (0)
|
||||
#define SCTP_INP_WLOCK(_inp) do { \
|
||||
if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_LOCK_LOGGING_ENABLE) \
|
||||
sctp_log_lock(_inp, NULL, SCTP_LOG_LOCK_INP); \
|
||||
EnterCriticalSection(&(_inp)->inp_mtx); \
|
||||
} while (0)
|
||||
#else
|
||||
#define SCTP_INP_RLOCK(_inp) \
|
||||
EnterCriticalSection(&(_inp)->inp_mtx)
|
||||
#define SCTP_INP_WLOCK(_inp) \
|
||||
EnterCriticalSection(&(_inp)->inp_mtx)
|
||||
#endif
|
||||
#define SCTP_INP_RLOCK_ASSERT(_tcb)
|
||||
#define SCTP_INP_WLOCK_ASSERT(_tcb)
|
||||
|
||||
#define SCTP_TCB_SEND_LOCK_INIT(_tcb) \
|
||||
InitializeCriticalSection(&(_tcb)->tcb_send_mtx)
|
||||
#define SCTP_TCB_SEND_LOCK_DESTROY(_tcb) \
|
||||
DeleteCriticalSection(&(_tcb)->tcb_send_mtx)
|
||||
#define SCTP_TCB_SEND_LOCK(_tcb) \
|
||||
EnterCriticalSection(&(_tcb)->tcb_send_mtx)
|
||||
#define SCTP_TCB_SEND_UNLOCK(_tcb) \
|
||||
LeaveCriticalSection(&(_tcb)->tcb_send_mtx)
|
||||
|
||||
#define SCTP_INP_INCR_REF(_inp) atomic_add_int(&((_inp)->refcount), 1)
|
||||
#define SCTP_INP_DECR_REF(_inp) atomic_add_int(&((_inp)->refcount), -1)
|
||||
|
||||
#define SCTP_ASOC_CREATE_LOCK_INIT(_inp) \
|
||||
InitializeCriticalSection(&(_inp)->inp_create_mtx)
|
||||
#define SCTP_ASOC_CREATE_LOCK_DESTROY(_inp) \
|
||||
DeleteCriticalSection(&(_inp)->inp_create_mtx)
|
||||
#ifdef SCTP_LOCK_LOGGING
|
||||
#define SCTP_ASOC_CREATE_LOCK(_inp) do { \
|
||||
if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_LOCK_LOGGING_ENABLE) \
|
||||
sctp_log_lock(_inp, NULL, SCTP_LOG_LOCK_CREATE); \
|
||||
EnterCriticalSection(&(_inp)->inp_create_mtx); \
|
||||
} while (0)
|
||||
#else
|
||||
#define SCTP_ASOC_CREATE_LOCK(_inp) \
|
||||
EnterCriticalSection(&(_inp)->inp_create_mtx)
|
||||
#endif
|
||||
|
||||
#define SCTP_INP_RUNLOCK(_inp) \
|
||||
LeaveCriticalSection(&(_inp)->inp_mtx)
|
||||
#define SCTP_INP_WUNLOCK(_inp) \
|
||||
LeaveCriticalSection(&(_inp)->inp_mtx)
|
||||
#define SCTP_ASOC_CREATE_UNLOCK(_inp) \
|
||||
LeaveCriticalSection(&(_inp)->inp_create_mtx)
|
||||
|
||||
/*
|
||||
* For the majority of things (once we have found the association) we will
|
||||
* lock the actual association mutex. This will protect all the assoiciation
|
||||
* level queues and streams and such. We will need to lock the socket layer
|
||||
* when we stuff data up into the receiving sb_mb. I.e. we will need to do an
|
||||
* extra SOCKBUF_LOCK(&so->so_rcv) even though the association is locked.
|
||||
*/
|
||||
|
||||
#define SCTP_TCB_LOCK_INIT(_tcb) \
|
||||
InitializeCriticalSection(&(_tcb)->tcb_mtx)
|
||||
#define SCTP_TCB_LOCK_DESTROY(_tcb) \
|
||||
DeleteCriticalSection(&(_tcb)->tcb_mtx)
|
||||
#ifdef SCTP_LOCK_LOGGING
|
||||
#define SCTP_TCB_LOCK(_tcb) do { \
|
||||
if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_LOCK_LOGGING_ENABLE) \
|
||||
sctp_log_lock(_tcb->sctp_ep, _tcb, SCTP_LOG_LOCK_TCB); \
|
||||
EnterCriticalSection(&(_tcb)->tcb_mtx); \
|
||||
} while (0)
|
||||
#else
|
||||
#define SCTP_TCB_LOCK(_tcb) \
|
||||
EnterCriticalSection(&(_tcb)->tcb_mtx)
|
||||
#endif
|
||||
#define SCTP_TCB_TRYLOCK(_tcb) ((TryEnterCriticalSection(&(_tcb)->tcb_mtx)))
|
||||
#define SCTP_TCB_UNLOCK(_tcb) \
|
||||
LeaveCriticalSection(&(_tcb)->tcb_mtx)
|
||||
#define SCTP_TCB_LOCK_ASSERT(_tcb)
|
||||
|
||||
#else /* all Userspaces except Windows */
|
||||
#define SCTP_WQ_ADDR_INIT() \
|
||||
(void)pthread_mutex_init(&SCTP_BASE_INFO(wq_addr_mtx), &SCTP_BASE_VAR(mtx_attr))
|
||||
#define SCTP_WQ_ADDR_DESTROY() \
|
||||
(void)pthread_mutex_destroy(&SCTP_BASE_INFO(wq_addr_mtx))
|
||||
#ifdef INVARIANTS
|
||||
#define SCTP_WQ_ADDR_LOCK() \
|
||||
KASSERT(pthread_mutex_lock(&SCTP_BASE_INFO(wq_addr_mtx)) == 0, ("%s: wq_addr_mtx already locked", __func__))
|
||||
#define SCTP_WQ_ADDR_UNLOCK() \
|
||||
KASSERT(pthread_mutex_unlock(&SCTP_BASE_INFO(wq_addr_mtx)) == 0, ("%s: wq_addr_mtx not locked", __func__))
|
||||
#else
|
||||
#define SCTP_WQ_ADDR_LOCK() \
|
||||
(void)pthread_mutex_lock(&SCTP_BASE_INFO(wq_addr_mtx))
|
||||
#define SCTP_WQ_ADDR_UNLOCK() \
|
||||
(void)pthread_mutex_unlock(&SCTP_BASE_INFO(wq_addr_mtx))
|
||||
#endif
|
||||
#define SCTP_WQ_ADDR_LOCK_ASSERT() \
|
||||
KASSERT(pthread_mutex_trylock(&SCTP_BASE_INFO(wq_addr_mtx)) == EBUSY, ("%s: wq_addr_mtx not locked", __func__))
|
||||
|
||||
#define SCTP_INP_INFO_LOCK_INIT() \
|
||||
(void)pthread_mutex_init(&SCTP_BASE_INFO(ipi_ep_mtx), &SCTP_BASE_VAR(mtx_attr))
|
||||
#define SCTP_INP_INFO_LOCK_DESTROY() \
|
||||
(void)pthread_mutex_destroy(&SCTP_BASE_INFO(ipi_ep_mtx))
|
||||
#ifdef INVARIANTS
|
||||
#define SCTP_INP_INFO_RLOCK() \
|
||||
KASSERT(pthread_mutex_lock(&SCTP_BASE_INFO(ipi_ep_mtx)) == 0, ("%s: ipi_ep_mtx already locked", __func__))
|
||||
#define SCTP_INP_INFO_WLOCK() \
|
||||
KASSERT(pthread_mutex_lock(&SCTP_BASE_INFO(ipi_ep_mtx)) == 0, ("%s: ipi_ep_mtx already locked", __func__))
|
||||
#define SCTP_INP_INFO_RUNLOCK() \
|
||||
KASSERT(pthread_mutex_unlock(&SCTP_BASE_INFO(ipi_ep_mtx)) == 0, ("%s: ipi_ep_mtx not locked", __func__))
|
||||
#define SCTP_INP_INFO_WUNLOCK() \
|
||||
KASSERT(pthread_mutex_unlock(&SCTP_BASE_INFO(ipi_ep_mtx)) == 0, ("%s: ipi_ep_mtx not locked", __func__))
|
||||
#else
|
||||
#define SCTP_INP_INFO_RLOCK() \
|
||||
(void)pthread_mutex_lock(&SCTP_BASE_INFO(ipi_ep_mtx))
|
||||
#define SCTP_INP_INFO_WLOCK() \
|
||||
(void)pthread_mutex_lock(&SCTP_BASE_INFO(ipi_ep_mtx))
|
||||
#define SCTP_INP_INFO_RUNLOCK() \
|
||||
(void)pthread_mutex_unlock(&SCTP_BASE_INFO(ipi_ep_mtx))
|
||||
#define SCTP_INP_INFO_WUNLOCK() \
|
||||
(void)pthread_mutex_unlock(&SCTP_BASE_INFO(ipi_ep_mtx))
|
||||
#endif
|
||||
#define SCTP_INP_INFO_LOCK_ASSERT() \
|
||||
KASSERT(pthread_mutex_trylock(&SCTP_BASE_INFO(ipi_ep_mtx)) == EBUSY, ("%s: ipi_ep_mtx not locked", __func__))
|
||||
#define SCTP_INP_INFO_RLOCK_ASSERT() \
|
||||
KASSERT(pthread_mutex_trylock(&SCTP_BASE_INFO(ipi_ep_mtx)) == EBUSY, ("%s: ipi_ep_mtx not locked", __func__))
|
||||
#define SCTP_INP_INFO_WLOCK_ASSERT() \
|
||||
KASSERT(pthread_mutex_trylock(&SCTP_BASE_INFO(ipi_ep_mtx)) == EBUSY, ("%s: ipi_ep_mtx not locked", __func__))
|
||||
#define SCTP_INP_INFO_TRYLOCK() \
|
||||
(!(pthread_mutex_trylock(&SCTP_BASE_INFO(ipi_ep_mtx))))
|
||||
|
||||
#define SCTP_IP_PKTLOG_INIT() \
|
||||
(void)pthread_mutex_init(&SCTP_BASE_INFO(ipi_pktlog_mtx), &SCTP_BASE_VAR(mtx_attr))
|
||||
#define SCTP_IP_PKTLOG_DESTROY() \
|
||||
(void)pthread_mutex_destroy(&SCTP_BASE_INFO(ipi_pktlog_mtx))
|
||||
#ifdef INVARIANTS
|
||||
#define SCTP_IP_PKTLOG_LOCK() \
|
||||
KASSERT(pthread_mutex_lock(&SCTP_BASE_INFO(ipi_pktlog_mtx)) == 0, ("%s: ipi_pktlog_mtx already locked", __func__))
|
||||
#define SCTP_IP_PKTLOG_UNLOCK() \
|
||||
KASSERT(pthread_mutex_unlock(&SCTP_BASE_INFO(ipi_pktlog_mtx)) == 0, ("%s: ipi_pktlog_mtx not locked", __func__))
|
||||
#else
|
||||
#define SCTP_IP_PKTLOG_LOCK() \
|
||||
(void)pthread_mutex_lock(&SCTP_BASE_INFO(ipi_pktlog_mtx))
|
||||
#define SCTP_IP_PKTLOG_UNLOCK() \
|
||||
(void)pthread_mutex_unlock(&SCTP_BASE_INFO(ipi_pktlog_mtx))
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* The INP locks we will use for locking an SCTP endpoint, so for example if
|
||||
* we want to change something at the endpoint level for example random_store
|
||||
* or cookie secrets we lock the INP level.
|
||||
*/
|
||||
#define SCTP_INP_READ_INIT(_inp) \
|
||||
(void)pthread_mutex_init(&(_inp)->inp_rdata_mtx, &SCTP_BASE_VAR(mtx_attr))
|
||||
#define SCTP_INP_READ_DESTROY(_inp) \
|
||||
(void)pthread_mutex_destroy(&(_inp)->inp_rdata_mtx)
|
||||
#ifdef INVARIANTS
|
||||
#define SCTP_INP_READ_LOCK(_inp) \
|
||||
KASSERT(pthread_mutex_lock(&(_inp)->inp_rdata_mtx) == 0, ("%s: inp_rdata_mtx already locked", __func__))
|
||||
#define SCTP_INP_READ_UNLOCK(_inp) \
|
||||
KASSERT(pthread_mutex_unlock(&(_inp)->inp_rdata_mtx) == 0, ("%s: inp_rdata_mtx not locked", __func__))
|
||||
#else
|
||||
#define SCTP_INP_READ_LOCK(_inp) \
|
||||
(void)pthread_mutex_lock(&(_inp)->inp_rdata_mtx)
|
||||
#define SCTP_INP_READ_UNLOCK(_inp) \
|
||||
(void)pthread_mutex_unlock(&(_inp)->inp_rdata_mtx)
|
||||
#endif
|
||||
|
||||
#define SCTP_INP_LOCK_INIT(_inp) \
|
||||
(void)pthread_mutex_init(&(_inp)->inp_mtx, &SCTP_BASE_VAR(mtx_attr))
|
||||
#define SCTP_INP_LOCK_DESTROY(_inp) \
|
||||
(void)pthread_mutex_destroy(&(_inp)->inp_mtx)
|
||||
#ifdef INVARIANTS
|
||||
#ifdef SCTP_LOCK_LOGGING
|
||||
#define SCTP_INP_RLOCK(_inp) do { \
|
||||
if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_LOCK_LOGGING_ENABLE) \
|
||||
sctp_log_lock(_inp, NULL, SCTP_LOG_LOCK_INP); \
|
||||
KASSERT(pthread_mutex_lock(&(_inp)->inp_mtx) == 0, ("%s: inp_mtx already locked", __func__)) \
|
||||
} while (0)
|
||||
#define SCTP_INP_WLOCK(_inp) do { \
|
||||
if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_LOCK_LOGGING_ENABLE) \
|
||||
sctp_log_lock(_inp, NULL, SCTP_LOG_LOCK_INP); \
|
||||
KASSERT(pthread_mutex_lock(&(_inp)->inp_mtx) == 0, ("%s: inp_mtx already locked", __func__))
|
||||
} while (0)
|
||||
#else
|
||||
#define SCTP_INP_RLOCK(_inp) \
|
||||
KASSERT(pthread_mutex_lock(&(_inp)->inp_mtx) == 0, ("%s: inp_mtx already locked", __func__))
|
||||
#define SCTP_INP_WLOCK(_inp) \
|
||||
KASSERT(pthread_mutex_lock(&(_inp)->inp_mtx) == 0, ("%s: inp_mtx already locked", __func__))
|
||||
#endif
|
||||
#define SCTP_INP_RUNLOCK(_inp) \
|
||||
KASSERT(pthread_mutex_unlock(&(_inp)->inp_mtx) == 0, ("%s: inp_mtx not locked", __func__))
|
||||
#define SCTP_INP_WUNLOCK(_inp) \
|
||||
KASSERT(pthread_mutex_unlock(&(_inp)->inp_mtx) == 0, ("%s: inp_mtx not locked", __func__))
|
||||
#else
|
||||
#ifdef SCTP_LOCK_LOGGING
|
||||
#define SCTP_INP_RLOCK(_inp) do { \
|
||||
if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_LOCK_LOGGING_ENABLE) \
|
||||
sctp_log_lock(_inp, NULL, SCTP_LOG_LOCK_INP); \
|
||||
(void)pthread_mutex_lock(&(_inp)->inp_mtx); \
|
||||
} while (0)
|
||||
#define SCTP_INP_WLOCK(_inp) do { \
|
||||
if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_LOCK_LOGGING_ENABLE) \
|
||||
sctp_log_lock(_inp, NULL, SCTP_LOG_LOCK_INP); \
|
||||
(void)pthread_mutex_lock(&(_inp)->inp_mtx); \
|
||||
} while (0)
|
||||
#else
|
||||
#define SCTP_INP_RLOCK(_inp) \
|
||||
(void)pthread_mutex_lock(&(_inp)->inp_mtx)
|
||||
#define SCTP_INP_WLOCK(_inp) \
|
||||
(void)pthread_mutex_lock(&(_inp)->inp_mtx)
|
||||
#endif
|
||||
#define SCTP_INP_RUNLOCK(_inp) \
|
||||
(void)pthread_mutex_unlock(&(_inp)->inp_mtx)
|
||||
#define SCTP_INP_WUNLOCK(_inp) \
|
||||
(void)pthread_mutex_unlock(&(_inp)->inp_mtx)
|
||||
#endif
|
||||
#define SCTP_INP_RLOCK_ASSERT(_inp) \
|
||||
KASSERT(pthread_mutex_trylock(&(_inp)->inp_mtx) == EBUSY, ("%s: inp_mtx not locked", __func__))
|
||||
#define SCTP_INP_WLOCK_ASSERT(_inp) \
|
||||
KASSERT(pthread_mutex_trylock(&(_inp)->inp_mtx) == EBUSY, ("%s: inp_mtx not locked", __func__))
|
||||
#define SCTP_INP_INCR_REF(_inp) atomic_add_int(&((_inp)->refcount), 1)
|
||||
#define SCTP_INP_DECR_REF(_inp) atomic_add_int(&((_inp)->refcount), -1)
|
||||
|
||||
#define SCTP_TCB_SEND_LOCK_INIT(_tcb) \
|
||||
(void)pthread_mutex_init(&(_tcb)->tcb_send_mtx, &SCTP_BASE_VAR(mtx_attr))
|
||||
#define SCTP_TCB_SEND_LOCK_DESTROY(_tcb) \
|
||||
(void)pthread_mutex_destroy(&(_tcb)->tcb_send_mtx)
|
||||
#ifdef INVARIANTS
|
||||
#define SCTP_TCB_SEND_LOCK(_tcb) \
|
||||
KASSERT(pthread_mutex_lock(&(_tcb)->tcb_send_mtx) == 0, ("%s: tcb_send_mtx already locked", __func__))
|
||||
#define SCTP_TCB_SEND_UNLOCK(_tcb) \
|
||||
KASSERT(pthread_mutex_unlock(&(_tcb)->tcb_send_mtx) == 0, ("%s: tcb_send_mtx not locked", __func__))
|
||||
#else
|
||||
#define SCTP_TCB_SEND_LOCK(_tcb) \
|
||||
(void)pthread_mutex_lock(&(_tcb)->tcb_send_mtx)
|
||||
#define SCTP_TCB_SEND_UNLOCK(_tcb) \
|
||||
(void)pthread_mutex_unlock(&(_tcb)->tcb_send_mtx)
|
||||
#endif
|
||||
|
||||
#define SCTP_ASOC_CREATE_LOCK_INIT(_inp) \
|
||||
(void)pthread_mutex_init(&(_inp)->inp_create_mtx, &SCTP_BASE_VAR(mtx_attr))
|
||||
#define SCTP_ASOC_CREATE_LOCK_DESTROY(_inp) \
|
||||
(void)pthread_mutex_destroy(&(_inp)->inp_create_mtx)
|
||||
#ifdef INVARIANTS
|
||||
#ifdef SCTP_LOCK_LOGGING
|
||||
#define SCTP_ASOC_CREATE_LOCK(_inp) do { \
|
||||
if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_LOCK_LOGGING_ENABLE) \
|
||||
sctp_log_lock(_inp, NULL, SCTP_LOG_LOCK_CREATE); \
|
||||
KASSERT(pthread_mutex_lock(&(_inp)->inp_create_mtx) == 0, ("%s: inp_create_mtx already locked", __func__)) \
|
||||
} while (0)
|
||||
#else
|
||||
#define SCTP_ASOC_CREATE_LOCK(_inp) \
|
||||
KASSERT(pthread_mutex_lock(&(_inp)->inp_create_mtx) == 0, ("%s: inp_create_mtx already locked", __func__))
|
||||
#endif
|
||||
#define SCTP_ASOC_CREATE_UNLOCK(_inp) \
|
||||
KASSERT(pthread_mutex_unlock(&(_inp)->inp_create_mtx) == 0, ("%s: inp_create_mtx not locked", __func__))
|
||||
#else
|
||||
#ifdef SCTP_LOCK_LOGGING
|
||||
#define SCTP_ASOC_CREATE_LOCK(_inp) do { \
|
||||
if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_LOCK_LOGGING_ENABLE) \
|
||||
sctp_log_lock(_inp, NULL, SCTP_LOG_LOCK_CREATE); \
|
||||
(void)pthread_mutex_lock(&(_inp)->inp_create_mtx); \
|
||||
} while (0)
|
||||
#else
|
||||
#define SCTP_ASOC_CREATE_LOCK(_inp) \
|
||||
(void)pthread_mutex_lock(&(_inp)->inp_create_mtx)
|
||||
#endif
|
||||
#define SCTP_ASOC_CREATE_UNLOCK(_inp) \
|
||||
(void)pthread_mutex_unlock(&(_inp)->inp_create_mtx)
|
||||
#endif
|
||||
/*
|
||||
* For the majority of things (once we have found the association) we will
|
||||
* lock the actual association mutex. This will protect all the assoiciation
|
||||
* level queues and streams and such. We will need to lock the socket layer
|
||||
* when we stuff data up into the receiving sb_mb. I.e. we will need to do an
|
||||
* extra SOCKBUF_LOCK(&so->so_rcv) even though the association is locked.
|
||||
*/
|
||||
|
||||
#define SCTP_TCB_LOCK_INIT(_tcb) \
|
||||
(void)pthread_mutex_init(&(_tcb)->tcb_mtx, &SCTP_BASE_VAR(mtx_attr))
|
||||
#define SCTP_TCB_LOCK_DESTROY(_tcb) \
|
||||
(void)pthread_mutex_destroy(&(_tcb)->tcb_mtx)
|
||||
#ifdef INVARIANTS
|
||||
#ifdef SCTP_LOCK_LOGGING
|
||||
#define SCTP_TCB_LOCK(_tcb) do { \
|
||||
if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_LOCK_LOGGING_ENABLE) \
|
||||
sctp_log_lock(_tcb->sctp_ep, _tcb, SCTP_LOG_LOCK_TCB); \
|
||||
KASSERT(pthread_mutex_lock(&(_tcb)->tcb_mtx) == 0, ("%s: tcb_mtx already locked", __func__)) \
|
||||
} while (0)
|
||||
#else
|
||||
#define SCTP_TCB_LOCK(_tcb) \
|
||||
KASSERT(pthread_mutex_lock(&(_tcb)->tcb_mtx) == 0, ("%s: tcb_mtx already locked", __func__))
|
||||
#endif
|
||||
#define SCTP_TCB_UNLOCK(_tcb) \
|
||||
KASSERT(pthread_mutex_unlock(&(_tcb)->tcb_mtx) == 0, ("%s: tcb_mtx not locked", __func__))
|
||||
#else
|
||||
#ifdef SCTP_LOCK_LOGGING
|
||||
#define SCTP_TCB_LOCK(_tcb) do { \
|
||||
if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_LOCK_LOGGING_ENABLE) \
|
||||
sctp_log_lock(_tcb->sctp_ep, _tcb, SCTP_LOG_LOCK_TCB); \
|
||||
(void)pthread_mutex_lock(&(_tcb)->tcb_mtx); \
|
||||
} while (0)
|
||||
#else
|
||||
#define SCTP_TCB_LOCK(_tcb) \
|
||||
(void)pthread_mutex_lock(&(_tcb)->tcb_mtx)
|
||||
#endif
|
||||
#define SCTP_TCB_UNLOCK(_tcb) (void)pthread_mutex_unlock(&(_tcb)->tcb_mtx)
|
||||
#endif
|
||||
#define SCTP_TCB_LOCK_ASSERT(_tcb) \
|
||||
KASSERT(pthread_mutex_trylock(&(_tcb)->tcb_mtx) == EBUSY, ("%s: tcb_mtx not locked", __func__))
|
||||
#define SCTP_TCB_TRYLOCK(_tcb) (!(pthread_mutex_trylock(&(_tcb)->tcb_mtx)))
|
||||
#endif
|
||||
|
||||
#endif /* SCTP_PER_SOCKET_LOCKING */
|
||||
|
||||
|
||||
/*
|
||||
* common locks
|
||||
*/
|
||||
|
||||
/* copied over to compile */
|
||||
#define SCTP_INP_LOCK_CONTENDED(_inp) (0) /* Don't know if this is possible */
|
||||
#define SCTP_INP_READ_CONTENDED(_inp) (0) /* Don't know if this is possible */
|
||||
#define SCTP_ASOC_CREATE_LOCK_CONTENDED(_inp) (0) /* Don't know if this is possible */
|
||||
|
||||
/* socket locks */
|
||||
|
||||
#if defined(_WIN32)
|
||||
#define SOCKBUF_LOCK_ASSERT(_so_buf)
|
||||
#define SOCKBUF_LOCK(_so_buf) \
|
||||
EnterCriticalSection(&(_so_buf)->sb_mtx)
|
||||
#define SOCKBUF_UNLOCK(_so_buf) \
|
||||
LeaveCriticalSection(&(_so_buf)->sb_mtx)
|
||||
#define SOCK_LOCK(_so) \
|
||||
SOCKBUF_LOCK(&(_so)->so_rcv)
|
||||
#define SOCK_UNLOCK(_so) \
|
||||
SOCKBUF_UNLOCK(&(_so)->so_rcv)
|
||||
#else
|
||||
#define SOCKBUF_LOCK_ASSERT(_so_buf) \
|
||||
KASSERT(pthread_mutex_trylock(SOCKBUF_MTX(_so_buf)) == EBUSY, ("%s: socket buffer not locked", __func__))
|
||||
#ifdef INVARIANTS
|
||||
#define SOCKBUF_LOCK(_so_buf) \
|
||||
KASSERT(pthread_mutex_lock(SOCKBUF_MTX(_so_buf)) == 0, ("%s: sockbuf_mtx already locked", __func__))
|
||||
#define SOCKBUF_UNLOCK(_so_buf) \
|
||||
KASSERT(pthread_mutex_unlock(SOCKBUF_MTX(_so_buf)) == 0, ("%s: sockbuf_mtx not locked", __func__))
|
||||
#else
|
||||
#define SOCKBUF_LOCK(_so_buf) \
|
||||
pthread_mutex_lock(SOCKBUF_MTX(_so_buf))
|
||||
#define SOCKBUF_UNLOCK(_so_buf) \
|
||||
pthread_mutex_unlock(SOCKBUF_MTX(_so_buf))
|
||||
#endif
|
||||
#define SOCK_LOCK(_so) \
|
||||
SOCKBUF_LOCK(&(_so)->so_rcv)
|
||||
#define SOCK_UNLOCK(_so) \
|
||||
SOCKBUF_UNLOCK(&(_so)->so_rcv)
|
||||
#endif
|
||||
|
||||
#define SCTP_STATLOG_INIT_LOCK()
|
||||
#define SCTP_STATLOG_LOCK()
|
||||
#define SCTP_STATLOG_UNLOCK()
|
||||
#define SCTP_STATLOG_DESTROY()
|
||||
|
||||
#if defined(_WIN32)
|
||||
/* address list locks */
|
||||
#define SCTP_IPI_ADDR_INIT() \
|
||||
InitializeCriticalSection(&SCTP_BASE_INFO(ipi_addr_mtx))
|
||||
#define SCTP_IPI_ADDR_DESTROY() \
|
||||
DeleteCriticalSection(&SCTP_BASE_INFO(ipi_addr_mtx))
|
||||
#define SCTP_IPI_ADDR_RLOCK() \
|
||||
EnterCriticalSection(&SCTP_BASE_INFO(ipi_addr_mtx))
|
||||
#define SCTP_IPI_ADDR_RUNLOCK() \
|
||||
LeaveCriticalSection(&SCTP_BASE_INFO(ipi_addr_mtx))
|
||||
#define SCTP_IPI_ADDR_WLOCK() \
|
||||
EnterCriticalSection(&SCTP_BASE_INFO(ipi_addr_mtx))
|
||||
#define SCTP_IPI_ADDR_WUNLOCK() \
|
||||
LeaveCriticalSection(&SCTP_BASE_INFO(ipi_addr_mtx))
|
||||
#define SCTP_IPI_ADDR_LOCK_ASSERT()
|
||||
#define SCTP_IPI_ADDR_WLOCK_ASSERT()
|
||||
|
||||
|
||||
/* iterator locks */
|
||||
#define SCTP_ITERATOR_LOCK_INIT() \
|
||||
InitializeCriticalSection(&sctp_it_ctl.it_mtx)
|
||||
#define SCTP_ITERATOR_LOCK_DESTROY() \
|
||||
DeleteCriticalSection(&sctp_it_ctl.it_mtx)
|
||||
#define SCTP_ITERATOR_LOCK() \
|
||||
EnterCriticalSection(&sctp_it_ctl.it_mtx)
|
||||
#define SCTP_ITERATOR_UNLOCK() \
|
||||
LeaveCriticalSection(&sctp_it_ctl.it_mtx)
|
||||
|
||||
#define SCTP_IPI_ITERATOR_WQ_INIT() \
|
||||
InitializeCriticalSection(&sctp_it_ctl.ipi_iterator_wq_mtx)
|
||||
#define SCTP_IPI_ITERATOR_WQ_DESTROY() \
|
||||
DeleteCriticalSection(&sctp_it_ctl.ipi_iterator_wq_mtx)
|
||||
#define SCTP_IPI_ITERATOR_WQ_LOCK() \
|
||||
EnterCriticalSection(&sctp_it_ctl.ipi_iterator_wq_mtx)
|
||||
#define SCTP_IPI_ITERATOR_WQ_UNLOCK() \
|
||||
LeaveCriticalSection(&sctp_it_ctl.ipi_iterator_wq_mtx)
|
||||
|
||||
#else
|
||||
/* address list locks */
|
||||
#define SCTP_IPI_ADDR_INIT() \
|
||||
(void)pthread_mutex_init(&SCTP_BASE_INFO(ipi_addr_mtx), &SCTP_BASE_VAR(mtx_attr))
|
||||
#define SCTP_IPI_ADDR_DESTROY() \
|
||||
(void)pthread_mutex_destroy(&SCTP_BASE_INFO(ipi_addr_mtx))
|
||||
#ifdef INVARIANTS
|
||||
#define SCTP_IPI_ADDR_RLOCK() \
|
||||
KASSERT(pthread_mutex_lock(&SCTP_BASE_INFO(ipi_addr_mtx)) == 0, ("%s: ipi_addr_mtx already locked", __func__))
|
||||
#define SCTP_IPI_ADDR_RUNLOCK() \
|
||||
KASSERT(pthread_mutex_unlock(&SCTP_BASE_INFO(ipi_addr_mtx)) == 0, ("%s: ipi_addr_mtx not locked", __func__))
|
||||
#define SCTP_IPI_ADDR_WLOCK() \
|
||||
KASSERT(pthread_mutex_lock(&SCTP_BASE_INFO(ipi_addr_mtx)) == 0, ("%s: ipi_addr_mtx already locked", __func__))
|
||||
#define SCTP_IPI_ADDR_WUNLOCK() \
|
||||
KASSERT(pthread_mutex_unlock(&SCTP_BASE_INFO(ipi_addr_mtx)) == 0, ("%s: ipi_addr_mtx not locked", __func__))
|
||||
#define SCTP_IPI_ADDR_LOCK_ASSERT() \
|
||||
KASSERT(pthread_mutex_trylock(&SCTP_BASE_INFO(ipi_addr_mtx)) == EBUSY, ("%s: ipi_addr_mtx not locked", __func__))
|
||||
#define SCTP_IPI_ADDR_WLOCK_ASSERT() \
|
||||
KASSERT(pthread_mutex_trylock(&SCTP_BASE_INFO(ipi_addr_mtx)) == EBUSY, ("%s: ipi_addr_mtx not locked", __func__))
|
||||
#else
|
||||
#define SCTP_IPI_ADDR_RLOCK() \
|
||||
(void)pthread_mutex_lock(&SCTP_BASE_INFO(ipi_addr_mtx))
|
||||
#define SCTP_IPI_ADDR_RUNLOCK() \
|
||||
(void)pthread_mutex_unlock(&SCTP_BASE_INFO(ipi_addr_mtx))
|
||||
#define SCTP_IPI_ADDR_WLOCK() \
|
||||
(void)pthread_mutex_lock(&SCTP_BASE_INFO(ipi_addr_mtx))
|
||||
#define SCTP_IPI_ADDR_WUNLOCK() \
|
||||
(void)pthread_mutex_unlock(&SCTP_BASE_INFO(ipi_addr_mtx))
|
||||
#define SCTP_IPI_ADDR_LOCK_ASSERT()
|
||||
#define SCTP_IPI_ADDR_WLOCK_ASSERT()
|
||||
#endif
|
||||
|
||||
/* iterator locks */
|
||||
#define SCTP_ITERATOR_LOCK_INIT() \
|
||||
(void)pthread_mutex_init(&sctp_it_ctl.it_mtx, &SCTP_BASE_VAR(mtx_attr))
|
||||
#define SCTP_ITERATOR_LOCK_DESTROY() \
|
||||
(void)pthread_mutex_destroy(&sctp_it_ctl.it_mtx)
|
||||
#ifdef INVARIANTS
|
||||
#define SCTP_ITERATOR_LOCK() \
|
||||
KASSERT(pthread_mutex_lock(&sctp_it_ctl.it_mtx) == 0, ("%s: it_mtx already locked", __func__))
|
||||
#define SCTP_ITERATOR_UNLOCK() \
|
||||
KASSERT(pthread_mutex_unlock(&sctp_it_ctl.it_mtx) == 0, ("%s: it_mtx not locked", __func__))
|
||||
#else
|
||||
#define SCTP_ITERATOR_LOCK() \
|
||||
(void)pthread_mutex_lock(&sctp_it_ctl.it_mtx)
|
||||
#define SCTP_ITERATOR_UNLOCK() \
|
||||
(void)pthread_mutex_unlock(&sctp_it_ctl.it_mtx)
|
||||
#endif
|
||||
|
||||
#define SCTP_IPI_ITERATOR_WQ_INIT() \
|
||||
(void)pthread_mutex_init(&sctp_it_ctl.ipi_iterator_wq_mtx, &SCTP_BASE_VAR(mtx_attr))
|
||||
#define SCTP_IPI_ITERATOR_WQ_DESTROY() \
|
||||
(void)pthread_mutex_destroy(&sctp_it_ctl.ipi_iterator_wq_mtx)
|
||||
#ifdef INVARIANTS
|
||||
#define SCTP_IPI_ITERATOR_WQ_LOCK() \
|
||||
KASSERT(pthread_mutex_lock(&sctp_it_ctl.ipi_iterator_wq_mtx) == 0, ("%s: ipi_iterator_wq_mtx already locked", __func__))
|
||||
#define SCTP_IPI_ITERATOR_WQ_UNLOCK() \
|
||||
KASSERT(pthread_mutex_unlock(&sctp_it_ctl.ipi_iterator_wq_mtx) == 0, ("%s: ipi_iterator_wq_mtx not locked", __func__))
|
||||
#else
|
||||
#define SCTP_IPI_ITERATOR_WQ_LOCK() \
|
||||
(void)pthread_mutex_lock(&sctp_it_ctl.ipi_iterator_wq_mtx)
|
||||
#define SCTP_IPI_ITERATOR_WQ_UNLOCK() \
|
||||
(void)pthread_mutex_unlock(&sctp_it_ctl.ipi_iterator_wq_mtx)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define SCTP_INCR_EP_COUNT() \
|
||||
atomic_add_int(&SCTP_BASE_INFO(ipi_count_ep), 1)
|
||||
|
||||
#define SCTP_DECR_EP_COUNT() \
|
||||
atomic_subtract_int(&SCTP_BASE_INFO(ipi_count_ep), 1)
|
||||
|
||||
#define SCTP_INCR_ASOC_COUNT() \
|
||||
atomic_add_int(&SCTP_BASE_INFO(ipi_count_asoc), 1)
|
||||
|
||||
#define SCTP_DECR_ASOC_COUNT() \
|
||||
atomic_subtract_int(&SCTP_BASE_INFO(ipi_count_asoc), 1)
|
||||
|
||||
#define SCTP_INCR_LADDR_COUNT() \
|
||||
atomic_add_int(&SCTP_BASE_INFO(ipi_count_laddr), 1)
|
||||
|
||||
#define SCTP_DECR_LADDR_COUNT() \
|
||||
atomic_subtract_int(&SCTP_BASE_INFO(ipi_count_laddr), 1)
|
||||
|
||||
#define SCTP_INCR_RADDR_COUNT() \
|
||||
atomic_add_int(&SCTP_BASE_INFO(ipi_count_raddr), 1)
|
||||
|
||||
#define SCTP_DECR_RADDR_COUNT() \
|
||||
atomic_subtract_int(&SCTP_BASE_INFO(ipi_count_raddr), 1)
|
||||
|
||||
#define SCTP_INCR_CHK_COUNT() \
|
||||
atomic_add_int(&SCTP_BASE_INFO(ipi_count_chunk), 1)
|
||||
|
||||
#define SCTP_DECR_CHK_COUNT() \
|
||||
atomic_subtract_int(&SCTP_BASE_INFO(ipi_count_chunk), 1)
|
||||
|
||||
#define SCTP_INCR_READQ_COUNT() \
|
||||
atomic_add_int(&SCTP_BASE_INFO(ipi_count_readq), 1)
|
||||
|
||||
#define SCTP_DECR_READQ_COUNT() \
|
||||
atomic_subtract_int(&SCTP_BASE_INFO(ipi_count_readq), 1)
|
||||
|
||||
#define SCTP_INCR_STRMOQ_COUNT() \
|
||||
atomic_add_int(&SCTP_BASE_INFO(ipi_count_strmoq), 1)
|
||||
|
||||
#define SCTP_DECR_STRMOQ_COUNT() \
|
||||
atomic_subtract_int(&SCTP_BASE_INFO(ipi_count_strmoq), 1)
|
||||
|
||||
#endif
|
||||
347
TMessagesProj/jni/third_party/usrsctplib/netinet/sctp_sha1.c
vendored
Executable file
347
TMessagesProj/jni/third_party/usrsctplib/netinet/sctp_sha1.c
vendored
Executable file
|
|
@ -0,0 +1,347 @@
|
|||
/*-
|
||||
* 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-2013, by Michael Tuexen. All rights reserved.
|
||||
* Copyright (c) 2013, by Lally Singh. 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.
|
||||
*/
|
||||
|
||||
#include <netinet/sctp_sha1.h>
|
||||
|
||||
#if defined(SCTP_USE_NSS_SHA1)
|
||||
/* A SHA-1 Digest is 160 bits, or 20 bytes */
|
||||
#define SHA_DIGEST_LENGTH (20)
|
||||
|
||||
void
|
||||
sctp_sha1_init(struct sctp_sha1_context *ctx)
|
||||
{
|
||||
ctx->pk11_ctx = PK11_CreateDigestContext(SEC_OID_SHA1);
|
||||
PK11_DigestBegin(ctx->pk11_ctx);
|
||||
}
|
||||
|
||||
void
|
||||
sctp_sha1_update(struct sctp_sha1_context *ctx, const unsigned char *ptr, unsigned int siz)
|
||||
{
|
||||
PK11_DigestOp(ctx->pk11_ctx, ptr, siz);
|
||||
}
|
||||
|
||||
void
|
||||
sctp_sha1_final(unsigned char *digest, struct sctp_sha1_context *ctx)
|
||||
{
|
||||
unsigned int output_len = 0;
|
||||
|
||||
PK11_DigestFinal(ctx->pk11_ctx, digest, &output_len, SHA_DIGEST_LENGTH);
|
||||
PK11_DestroyContext(ctx->pk11_ctx, PR_TRUE);
|
||||
}
|
||||
|
||||
#elif defined(SCTP_USE_OPENSSL_SHA1)
|
||||
|
||||
void
|
||||
sctp_sha1_init(struct sctp_sha1_context *ctx)
|
||||
{
|
||||
SHA1_Init(&ctx->sha_ctx);
|
||||
}
|
||||
|
||||
void
|
||||
sctp_sha1_update(struct sctp_sha1_context *ctx, const unsigned char *ptr, unsigned int siz)
|
||||
{
|
||||
SHA1_Update(&ctx->sha_ctx, ptr, (unsigned long)siz);
|
||||
}
|
||||
|
||||
void
|
||||
sctp_sha1_final(unsigned char *digest, struct sctp_sha1_context *ctx)
|
||||
{
|
||||
SHA1_Final(digest, &ctx->sha_ctx);
|
||||
}
|
||||
#elif defined(SCTP_USE_MBEDTLS_SHA1)
|
||||
void
|
||||
sctp_sha1_init(struct sctp_sha1_context *ctx)
|
||||
{
|
||||
mbedtls_sha1_init(&ctx->sha1_ctx);
|
||||
mbedtls_sha1_starts_ret(&ctx->sha1_ctx);
|
||||
}
|
||||
|
||||
void
|
||||
sctp_sha1_update(struct sctp_sha1_context *ctx, const unsigned char *ptr, unsigned int siz)
|
||||
{
|
||||
mbedtls_sha1_update_ret(&ctx->sha1_ctx, ptr, siz);
|
||||
}
|
||||
|
||||
void
|
||||
sctp_sha1_final(unsigned char *digest, struct sctp_sha1_context *ctx)
|
||||
{
|
||||
mbedtls_sha1_finish_ret(&ctx->sha1_ctx, digest);
|
||||
}
|
||||
#else
|
||||
|
||||
#include <string.h>
|
||||
#if defined(_WIN32) && defined(__Userspace__)
|
||||
#include <winsock2.h>
|
||||
#elif !(defined(_WIN32) && !defined(__Userspace__))
|
||||
#include <arpa/inet.h>
|
||||
#endif
|
||||
|
||||
#define F1(B,C,D) (((B & C) | ((~B) & D))) /* 0 <= t <= 19 */
|
||||
#define F2(B,C,D) (B ^ C ^ D) /* 20 <= t <= 39 */
|
||||
#define F3(B,C,D) ((B & C) | (B & D) | (C & D)) /* 40 <= t <= 59 */
|
||||
#define F4(B,C,D) (B ^ C ^ D) /* 600 <= t <= 79 */
|
||||
|
||||
/* circular shift */
|
||||
#define CSHIFT(A,B) ((B << A) | (B >> (32-A)))
|
||||
|
||||
#define K1 0x5a827999 /* 0 <= t <= 19 */
|
||||
#define K2 0x6ed9eba1 /* 20 <= t <= 39 */
|
||||
#define K3 0x8f1bbcdc /* 40 <= t <= 59 */
|
||||
#define K4 0xca62c1d6 /* 60 <= t <= 79 */
|
||||
|
||||
#define H0INIT 0x67452301
|
||||
#define H1INIT 0xefcdab89
|
||||
#define H2INIT 0x98badcfe
|
||||
#define H3INIT 0x10325476
|
||||
#define H4INIT 0xc3d2e1f0
|
||||
|
||||
void
|
||||
sctp_sha1_init(struct sctp_sha1_context *ctx)
|
||||
{
|
||||
/* Init the SHA-1 context structure */
|
||||
ctx->A = 0;
|
||||
ctx->B = 0;
|
||||
ctx->C = 0;
|
||||
ctx->D = 0;
|
||||
ctx->E = 0;
|
||||
ctx->H0 = H0INIT;
|
||||
ctx->H1 = H1INIT;
|
||||
ctx->H2 = H2INIT;
|
||||
ctx->H3 = H3INIT;
|
||||
ctx->H4 = H4INIT;
|
||||
ctx->TEMP = 0;
|
||||
memset(ctx->words, 0, sizeof(ctx->words));
|
||||
ctx->how_many_in_block = 0;
|
||||
ctx->running_total = 0;
|
||||
}
|
||||
|
||||
static void
|
||||
sctp_sha1_process_a_block(struct sctp_sha1_context *ctx, unsigned int *block)
|
||||
{
|
||||
int i;
|
||||
|
||||
/* init the W0-W15 to the block of words being hashed. */
|
||||
/* step a) */
|
||||
for (i = 0; i < 16; i++) {
|
||||
ctx->words[i] = ntohl(block[i]);
|
||||
}
|
||||
/* now init the rest based on the SHA-1 formula, step b) */
|
||||
for (i = 16; i < 80; i++) {
|
||||
ctx->words[i] = CSHIFT(1, ((ctx->words[(i - 3)]) ^
|
||||
(ctx->words[(i - 8)]) ^
|
||||
(ctx->words[(i - 14)]) ^
|
||||
(ctx->words[(i - 16)])));
|
||||
}
|
||||
/* step c) */
|
||||
ctx->A = ctx->H0;
|
||||
ctx->B = ctx->H1;
|
||||
ctx->C = ctx->H2;
|
||||
ctx->D = ctx->H3;
|
||||
ctx->E = ctx->H4;
|
||||
|
||||
/* step d) */
|
||||
for (i = 0; i < 80; i++) {
|
||||
if (i < 20) {
|
||||
ctx->TEMP = ((CSHIFT(5, ctx->A)) +
|
||||
(F1(ctx->B, ctx->C, ctx->D)) +
|
||||
(ctx->E) +
|
||||
ctx->words[i] +
|
||||
K1);
|
||||
} else if (i < 40) {
|
||||
ctx->TEMP = ((CSHIFT(5, ctx->A)) +
|
||||
(F2(ctx->B, ctx->C, ctx->D)) +
|
||||
(ctx->E) +
|
||||
(ctx->words[i]) +
|
||||
K2);
|
||||
} else if (i < 60) {
|
||||
ctx->TEMP = ((CSHIFT(5, ctx->A)) +
|
||||
(F3(ctx->B, ctx->C, ctx->D)) +
|
||||
(ctx->E) +
|
||||
(ctx->words[i]) +
|
||||
K3);
|
||||
} else {
|
||||
ctx->TEMP = ((CSHIFT(5, ctx->A)) +
|
||||
(F4(ctx->B, ctx->C, ctx->D)) +
|
||||
(ctx->E) +
|
||||
(ctx->words[i]) +
|
||||
K4);
|
||||
}
|
||||
ctx->E = ctx->D;
|
||||
ctx->D = ctx->C;
|
||||
ctx->C = CSHIFT(30, ctx->B);
|
||||
ctx->B = ctx->A;
|
||||
ctx->A = ctx->TEMP;
|
||||
}
|
||||
/* step e) */
|
||||
ctx->H0 = (ctx->H0) + (ctx->A);
|
||||
ctx->H1 = (ctx->H1) + (ctx->B);
|
||||
ctx->H2 = (ctx->H2) + (ctx->C);
|
||||
ctx->H3 = (ctx->H3) + (ctx->D);
|
||||
ctx->H4 = (ctx->H4) + (ctx->E);
|
||||
}
|
||||
|
||||
void
|
||||
sctp_sha1_update(struct sctp_sha1_context *ctx, const unsigned char *ptr, unsigned int siz)
|
||||
{
|
||||
unsigned int number_left, left_to_fill;
|
||||
|
||||
number_left = siz;
|
||||
while (number_left > 0) {
|
||||
left_to_fill = sizeof(ctx->sha_block) - ctx->how_many_in_block;
|
||||
if (left_to_fill > number_left) {
|
||||
/* can only partially fill up this one */
|
||||
memcpy(&ctx->sha_block[ctx->how_many_in_block],
|
||||
ptr, number_left);
|
||||
ctx->how_many_in_block += number_left;
|
||||
ctx->running_total += number_left;
|
||||
break;
|
||||
} else {
|
||||
/* block is now full, process it */
|
||||
memcpy(&ctx->sha_block[ctx->how_many_in_block],
|
||||
ptr, left_to_fill);
|
||||
sctp_sha1_process_a_block(ctx,
|
||||
(unsigned int *)ctx->sha_block);
|
||||
number_left -= left_to_fill;
|
||||
ctx->running_total += left_to_fill;
|
||||
ctx->how_many_in_block = 0;
|
||||
ptr = (const unsigned char *)(ptr + left_to_fill);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
sctp_sha1_final(unsigned char *digest, struct sctp_sha1_context *ctx)
|
||||
{
|
||||
/*
|
||||
* if any left in block fill with padding and process. Then transfer
|
||||
* the digest to the pointer. At the last block some special rules
|
||||
* need to apply. We must add a 1 bit following the message, then we
|
||||
* pad with 0's. The total size is encoded as a 64 bit number at the
|
||||
* end. Now if the last buffer has more than 55 octets in it we
|
||||
* cannot fit the 64 bit number + 10000000 pad on the end and must
|
||||
* add the 10000000 pad, pad the rest of the message with 0's and
|
||||
* then create an all 0 message with just the 64 bit size at the end
|
||||
* and run this block through by itself. Also the 64 bit int must
|
||||
* be in network byte order.
|
||||
*/
|
||||
int left_to_fill;
|
||||
unsigned int i, *ptr;
|
||||
|
||||
if (ctx->how_many_in_block > 55) {
|
||||
/*
|
||||
* special case, we need to process two blocks here. One for
|
||||
* the current stuff plus possibly the pad. The other for
|
||||
* the size.
|
||||
*/
|
||||
left_to_fill = sizeof(ctx->sha_block) - ctx->how_many_in_block;
|
||||
if (left_to_fill == 0) {
|
||||
/* Should not really happen but I am paranoid */
|
||||
sctp_sha1_process_a_block(ctx,
|
||||
(unsigned int *)ctx->sha_block);
|
||||
/* init last block, a bit different than the rest */
|
||||
ctx->sha_block[0] = '\x80';
|
||||
for (i = 1; i < sizeof(ctx->sha_block); i++) {
|
||||
ctx->sha_block[i] = 0x0;
|
||||
}
|
||||
} else if (left_to_fill == 1) {
|
||||
ctx->sha_block[ctx->how_many_in_block] = '\x80';
|
||||
sctp_sha1_process_a_block(ctx,
|
||||
(unsigned int *)ctx->sha_block);
|
||||
/* init last block */
|
||||
memset(ctx->sha_block, 0, sizeof(ctx->sha_block));
|
||||
} else {
|
||||
ctx->sha_block[ctx->how_many_in_block] = '\x80';
|
||||
for (i = (ctx->how_many_in_block + 1);
|
||||
i < sizeof(ctx->sha_block);
|
||||
i++) {
|
||||
ctx->sha_block[i] = 0x0;
|
||||
}
|
||||
sctp_sha1_process_a_block(ctx,
|
||||
(unsigned int *)ctx->sha_block);
|
||||
/* init last block */
|
||||
memset(ctx->sha_block, 0, sizeof(ctx->sha_block));
|
||||
}
|
||||
/* This is in bits so multiply by 8 */
|
||||
ctx->running_total *= 8;
|
||||
ptr = (unsigned int *)&ctx->sha_block[60];
|
||||
*ptr = htonl(ctx->running_total);
|
||||
sctp_sha1_process_a_block(ctx, (unsigned int *)ctx->sha_block);
|
||||
} else {
|
||||
/*
|
||||
* easy case, we just pad this message to size - end with 0
|
||||
* add the magic 0x80 to the next word and then put the
|
||||
* network byte order size in the last spot and process the
|
||||
* block.
|
||||
*/
|
||||
ctx->sha_block[ctx->how_many_in_block] = '\x80';
|
||||
for (i = (ctx->how_many_in_block + 1);
|
||||
i < sizeof(ctx->sha_block);
|
||||
i++) {
|
||||
ctx->sha_block[i] = 0x0;
|
||||
}
|
||||
/* get last int spot */
|
||||
ctx->running_total *= 8;
|
||||
ptr = (unsigned int *)&ctx->sha_block[60];
|
||||
*ptr = htonl(ctx->running_total);
|
||||
sctp_sha1_process_a_block(ctx, (unsigned int *)ctx->sha_block);
|
||||
}
|
||||
/* transfer the digest back to the user */
|
||||
digest[3] = (ctx->H0 & 0xff);
|
||||
digest[2] = ((ctx->H0 >> 8) & 0xff);
|
||||
digest[1] = ((ctx->H0 >> 16) & 0xff);
|
||||
digest[0] = ((ctx->H0 >> 24) & 0xff);
|
||||
|
||||
digest[7] = (ctx->H1 & 0xff);
|
||||
digest[6] = ((ctx->H1 >> 8) & 0xff);
|
||||
digest[5] = ((ctx->H1 >> 16) & 0xff);
|
||||
digest[4] = ((ctx->H1 >> 24) & 0xff);
|
||||
|
||||
digest[11] = (ctx->H2 & 0xff);
|
||||
digest[10] = ((ctx->H2 >> 8) & 0xff);
|
||||
digest[9] = ((ctx->H2 >> 16) & 0xff);
|
||||
digest[8] = ((ctx->H2 >> 24) & 0xff);
|
||||
|
||||
digest[15] = (ctx->H3 & 0xff);
|
||||
digest[14] = ((ctx->H3 >> 8) & 0xff);
|
||||
digest[13] = ((ctx->H3 >> 16) & 0xff);
|
||||
digest[12] = ((ctx->H3 >> 24) & 0xff);
|
||||
|
||||
digest[19] = (ctx->H4 & 0xff);
|
||||
digest[18] = ((ctx->H4 >> 8) & 0xff);
|
||||
digest[17] = ((ctx->H4 >> 16) & 0xff);
|
||||
digest[16] = ((ctx->H4 >> 24) & 0xff);
|
||||
}
|
||||
|
||||
#endif
|
||||
94
TMessagesProj/jni/third_party/usrsctplib/netinet/sctp_sha1.h
vendored
Executable file
94
TMessagesProj/jni/third_party/usrsctplib/netinet/sctp_sha1.h
vendored
Executable file
|
|
@ -0,0 +1,94 @@
|
|||
/*-
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#if defined(__FreeBSD__) && !defined(__Userspace__)
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef __NETINET_SCTP_SHA1_H__
|
||||
#define __NETINET_SCTP_SHA1_H__
|
||||
|
||||
#include <sys/types.h>
|
||||
#if defined(SCTP_USE_NSS_SHA1)
|
||||
#include <pk11pub.h>
|
||||
#elif defined(SCTP_USE_OPENSSL_SHA1)
|
||||
#include <openssl/sha.h>
|
||||
#elif defined(SCTP_USE_MBEDTLS_SHA1)
|
||||
#include <mbedtls/sha1.h>
|
||||
#endif
|
||||
|
||||
struct sctp_sha1_context {
|
||||
#if defined(SCTP_USE_NSS_SHA1)
|
||||
struct PK11Context *pk11_ctx;
|
||||
#elif defined(SCTP_USE_OPENSSL_SHA1)
|
||||
SHA_CTX sha_ctx;
|
||||
#elif defined(SCTP_USE_MBEDTLS_SHA1)
|
||||
mbedtls_sha1_context sha1_ctx;
|
||||
#else
|
||||
unsigned int A;
|
||||
unsigned int B;
|
||||
unsigned int C;
|
||||
unsigned int D;
|
||||
unsigned int E;
|
||||
unsigned int H0;
|
||||
unsigned int H1;
|
||||
unsigned int H2;
|
||||
unsigned int H3;
|
||||
unsigned int H4;
|
||||
unsigned int words[80];
|
||||
unsigned int TEMP;
|
||||
/* block I am collecting to process */
|
||||
char sha_block[64];
|
||||
/* collected so far */
|
||||
int how_many_in_block;
|
||||
unsigned int running_total;
|
||||
#endif
|
||||
};
|
||||
|
||||
#if (defined(__APPLE__) && !defined(__Userspace__) && defined(KERNEL))
|
||||
#ifndef _KERNEL
|
||||
#define _KERNEL
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(_KERNEL) || defined(__Userspace__)
|
||||
|
||||
void sctp_sha1_init(struct sctp_sha1_context *);
|
||||
void sctp_sha1_update(struct sctp_sha1_context *, const unsigned char *, unsigned int);
|
||||
void sctp_sha1_final(unsigned char *, struct sctp_sha1_context *);
|
||||
|
||||
#endif
|
||||
#endif
|
||||
1126
TMessagesProj/jni/third_party/usrsctplib/netinet/sctp_ss_functions.c
vendored
Executable file
1126
TMessagesProj/jni/third_party/usrsctplib/netinet/sctp_ss_functions.c
vendored
Executable file
File diff suppressed because it is too large
Load diff
1288
TMessagesProj/jni/third_party/usrsctplib/netinet/sctp_structs.h
vendored
Executable file
1288
TMessagesProj/jni/third_party/usrsctplib/netinet/sctp_structs.h
vendored
Executable file
File diff suppressed because it is too large
Load diff
1625
TMessagesProj/jni/third_party/usrsctplib/netinet/sctp_sysctl.c
vendored
Executable file
1625
TMessagesProj/jni/third_party/usrsctplib/netinet/sctp_sysctl.c
vendored
Executable file
File diff suppressed because it is too large
Load diff
627
TMessagesProj/jni/third_party/usrsctplib/netinet/sctp_sysctl.h
vendored
Executable file
627
TMessagesProj/jni/third_party/usrsctplib/netinet/sctp_sysctl.h
vendored
Executable file
|
|
@ -0,0 +1,627 @@
|
|||
/*-
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*
|
||||
* Copyright (c) 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.
|
||||
*/
|
||||
|
||||
#if defined(__FreeBSD__) && !defined(__Userspace__)
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD: head/sys/netinet/sctp_sysctl.h 366750 2020-10-16 10:44:48Z tuexen $");
|
||||
#endif
|
||||
|
||||
#ifndef _NETINET_SCTP_SYSCTL_H_
|
||||
#define _NETINET_SCTP_SYSCTL_H_
|
||||
|
||||
#include <netinet/sctp_os.h>
|
||||
#include <netinet/sctp_constants.h>
|
||||
|
||||
struct sctp_sysctl {
|
||||
uint32_t sctp_sendspace;
|
||||
uint32_t sctp_recvspace;
|
||||
uint32_t sctp_auto_asconf;
|
||||
uint32_t sctp_multiple_asconfs;
|
||||
uint32_t sctp_ecn_enable;
|
||||
uint32_t sctp_pr_enable;
|
||||
uint32_t sctp_auth_enable;
|
||||
uint32_t sctp_asconf_enable;
|
||||
uint32_t sctp_reconfig_enable;
|
||||
uint32_t sctp_nrsack_enable;
|
||||
uint32_t sctp_pktdrop_enable;
|
||||
uint32_t sctp_fr_max_burst_default;
|
||||
#if !(defined(__FreeBSD__) && !defined(__Userspace__))
|
||||
uint32_t sctp_no_csum_on_loopback;
|
||||
#endif
|
||||
uint32_t sctp_peer_chunk_oh;
|
||||
uint32_t sctp_max_burst_default;
|
||||
uint32_t sctp_max_chunks_on_queue;
|
||||
uint32_t sctp_hashtblsize;
|
||||
uint32_t sctp_pcbtblsize;
|
||||
uint32_t sctp_min_split_point;
|
||||
uint32_t sctp_chunkscale;
|
||||
uint32_t sctp_delayed_sack_time_default;
|
||||
uint32_t sctp_sack_freq_default;
|
||||
uint32_t sctp_system_free_resc_limit;
|
||||
uint32_t sctp_asoc_free_resc_limit;
|
||||
uint32_t sctp_heartbeat_interval_default;
|
||||
uint32_t sctp_pmtu_raise_time_default;
|
||||
uint32_t sctp_shutdown_guard_time_default;
|
||||
uint32_t sctp_secret_lifetime_default;
|
||||
uint32_t sctp_rto_max_default;
|
||||
uint32_t sctp_rto_min_default;
|
||||
uint32_t sctp_rto_initial_default;
|
||||
uint32_t sctp_init_rto_max_default;
|
||||
uint32_t sctp_valid_cookie_life_default;
|
||||
uint32_t sctp_init_rtx_max_default;
|
||||
uint32_t sctp_assoc_rtx_max_default;
|
||||
uint32_t sctp_path_rtx_max_default;
|
||||
uint32_t sctp_path_pf_threshold;
|
||||
uint32_t sctp_add_more_threshold;
|
||||
uint32_t sctp_nr_incoming_streams_default;
|
||||
uint32_t sctp_nr_outgoing_streams_default;
|
||||
uint32_t sctp_cmt_on_off;
|
||||
uint32_t sctp_cmt_use_dac;
|
||||
uint32_t sctp_use_cwnd_based_maxburst;
|
||||
uint32_t sctp_nat_friendly;
|
||||
uint32_t sctp_L2_abc_variable;
|
||||
uint32_t sctp_mbuf_threshold_count;
|
||||
uint32_t sctp_do_drain;
|
||||
uint32_t sctp_hb_maxburst;
|
||||
uint32_t sctp_abort_if_one_2_one_hits_limit;
|
||||
uint32_t sctp_min_residual;
|
||||
uint32_t sctp_max_retran_chunk;
|
||||
uint32_t sctp_logging_level;
|
||||
/* JRS - Variable for default congestion control module */
|
||||
uint32_t sctp_default_cc_module;
|
||||
/* RS - Variable for default stream scheduling module */
|
||||
uint32_t sctp_default_ss_module;
|
||||
uint32_t sctp_default_frag_interleave;
|
||||
uint32_t sctp_mobility_base;
|
||||
uint32_t sctp_mobility_fasthandoff;
|
||||
uint32_t sctp_inits_include_nat_friendly;
|
||||
uint32_t sctp_rttvar_bw;
|
||||
uint32_t sctp_rttvar_rtt;
|
||||
uint32_t sctp_rttvar_eqret;
|
||||
uint32_t sctp_steady_step;
|
||||
uint32_t sctp_use_dccc_ecn;
|
||||
uint32_t sctp_diag_info_code;
|
||||
#if defined(SCTP_LOCAL_TRACE_BUF)
|
||||
#if defined(_WIN32) && !defined(__Userspace__)
|
||||
struct sctp_log *sctp_log;
|
||||
#else
|
||||
struct sctp_log sctp_log;
|
||||
#endif
|
||||
#endif
|
||||
uint32_t sctp_udp_tunneling_port;
|
||||
uint32_t sctp_enable_sack_immediately;
|
||||
uint32_t sctp_vtag_time_wait;
|
||||
uint32_t sctp_buffer_splitting;
|
||||
uint32_t sctp_initial_cwnd;
|
||||
uint32_t sctp_blackhole;
|
||||
uint32_t sctp_sendall_limit;
|
||||
#if defined(SCTP_DEBUG)
|
||||
uint32_t sctp_debug_on;
|
||||
#endif
|
||||
#if defined(__APPLE__) && !defined(__Userspace__)
|
||||
uint32_t sctp_ignore_vmware_interfaces;
|
||||
uint32_t sctp_main_timer;
|
||||
uint32_t sctp_addr_watchdog_limit;
|
||||
uint32_t sctp_vtag_watchdog_limit;
|
||||
#endif
|
||||
#if defined(__APPLE__) && !defined(__Userspace__)
|
||||
uint32_t sctp_output_unlocked;
|
||||
#endif
|
||||
};
|
||||
|
||||
/*
|
||||
* limits for the sysctl variables
|
||||
*/
|
||||
/* maxdgram: Maximum outgoing SCTP buffer size */
|
||||
#define SCTPCTL_MAXDGRAM_DESC "Maximum outgoing SCTP buffer size"
|
||||
#define SCTPCTL_MAXDGRAM_MIN 0
|
||||
#define SCTPCTL_MAXDGRAM_MAX 0xFFFFFFFF
|
||||
#if defined(__Userspace__)
|
||||
#define SCTPCTL_MAXDGRAM_DEFAULT SB_MAX
|
||||
#else
|
||||
#define SCTPCTL_MAXDGRAM_DEFAULT 262144 /* 256k */
|
||||
#endif
|
||||
|
||||
/* recvspace: Maximum incoming SCTP buffer size */
|
||||
#define SCTPCTL_RECVSPACE_DESC "Maximum incoming SCTP buffer size"
|
||||
#define SCTPCTL_RECVSPACE_MIN 0
|
||||
#define SCTPCTL_RECVSPACE_MAX 0xFFFFFFFF
|
||||
#if defined(__Userspace__)
|
||||
#define SCTPCTL_RECVSPACE_DEFAULT SB_RAW
|
||||
#else
|
||||
#define SCTPCTL_RECVSPACE_DEFAULT 262144 /* 256k */
|
||||
#endif
|
||||
|
||||
/* autoasconf: Enable SCTP Auto-ASCONF */
|
||||
#define SCTPCTL_AUTOASCONF_DESC "Enable SCTP Auto-ASCONF"
|
||||
#define SCTPCTL_AUTOASCONF_MIN 0
|
||||
#define SCTPCTL_AUTOASCONF_MAX 1
|
||||
#define SCTPCTL_AUTOASCONF_DEFAULT 1
|
||||
|
||||
/* autoasconf: Enable SCTP Auto-ASCONF */
|
||||
#define SCTPCTL_MULTIPLEASCONFS_DESC "Enable SCTP Muliple-ASCONFs"
|
||||
#define SCTPCTL_MULTIPLEASCONFS_MIN 0
|
||||
#define SCTPCTL_MULTIPLEASCONFS_MAX 1
|
||||
#define SCTPCTL_MULTIPLEASCONFS_DEFAULT SCTP_DEFAULT_MULTIPLE_ASCONFS
|
||||
|
||||
/* ecn_enable: Enable SCTP ECN */
|
||||
#define SCTPCTL_ECN_ENABLE_DESC "Enable SCTP ECN"
|
||||
#define SCTPCTL_ECN_ENABLE_MIN 0
|
||||
#define SCTPCTL_ECN_ENABLE_MAX 1
|
||||
#define SCTPCTL_ECN_ENABLE_DEFAULT 1
|
||||
|
||||
/* pr_enable: Enable PR-SCTP */
|
||||
#define SCTPCTL_PR_ENABLE_DESC "Enable PR-SCTP"
|
||||
#define SCTPCTL_PR_ENABLE_MIN 0
|
||||
#define SCTPCTL_PR_ENABLE_MAX 1
|
||||
#define SCTPCTL_PR_ENABLE_DEFAULT 1
|
||||
|
||||
/* auth_enable: Enable SCTP AUTH function */
|
||||
#define SCTPCTL_AUTH_ENABLE_DESC "Enable SCTP AUTH function"
|
||||
#define SCTPCTL_AUTH_ENABLE_MIN 0
|
||||
#define SCTPCTL_AUTH_ENABLE_MAX 1
|
||||
#define SCTPCTL_AUTH_ENABLE_DEFAULT 1
|
||||
|
||||
/* asconf_enable: Enable SCTP ASCONF */
|
||||
#define SCTPCTL_ASCONF_ENABLE_DESC "Enable SCTP ASCONF"
|
||||
#define SCTPCTL_ASCONF_ENABLE_MIN 0
|
||||
#define SCTPCTL_ASCONF_ENABLE_MAX 1
|
||||
#define SCTPCTL_ASCONF_ENABLE_DEFAULT 1
|
||||
|
||||
/* reconfig_enable: Enable SCTP RE-CONFIG */
|
||||
#define SCTPCTL_RECONFIG_ENABLE_DESC "Enable SCTP RE-CONFIG"
|
||||
#define SCTPCTL_RECONFIG_ENABLE_MIN 0
|
||||
#define SCTPCTL_RECONFIG_ENABLE_MAX 1
|
||||
#define SCTPCTL_RECONFIG_ENABLE_DEFAULT 1
|
||||
|
||||
/* nrsack_enable: Enable NR_SACK */
|
||||
#define SCTPCTL_NRSACK_ENABLE_DESC "Enable SCTP NR-SACK"
|
||||
#define SCTPCTL_NRSACK_ENABLE_MIN 0
|
||||
#define SCTPCTL_NRSACK_ENABLE_MAX 1
|
||||
#define SCTPCTL_NRSACK_ENABLE_DEFAULT 0
|
||||
|
||||
/* pktdrop_enable: Enable SCTP Packet Drop Reports */
|
||||
#define SCTPCTL_PKTDROP_ENABLE_DESC "Enable SCTP PKTDROP"
|
||||
#define SCTPCTL_PKTDROP_ENABLE_MIN 0
|
||||
#define SCTPCTL_PKTDROP_ENABLE_MAX 1
|
||||
#define SCTPCTL_PKTDROP_ENABLE_DEFAULT 0
|
||||
|
||||
/* loopback_nocsum: Enable NO Csum on packets sent on loopback */
|
||||
#define SCTPCTL_LOOPBACK_NOCSUM_DESC "Enable NO Csum on packets sent on loopback"
|
||||
#define SCTPCTL_LOOPBACK_NOCSUM_MIN 0
|
||||
#define SCTPCTL_LOOPBACK_NOCSUM_MAX 1
|
||||
#define SCTPCTL_LOOPBACK_NOCSUM_DEFAULT 1
|
||||
|
||||
/* peer_chkoh: Amount to debit peers rwnd per chunk sent */
|
||||
#define SCTPCTL_PEER_CHKOH_DESC "Amount to debit peers rwnd per chunk sent"
|
||||
#define SCTPCTL_PEER_CHKOH_MIN 0
|
||||
#define SCTPCTL_PEER_CHKOH_MAX 0xFFFFFFFF
|
||||
#define SCTPCTL_PEER_CHKOH_DEFAULT 256
|
||||
|
||||
/* maxburst: Default max burst for sctp endpoints */
|
||||
#define SCTPCTL_MAXBURST_DESC "Default max burst for sctp endpoints"
|
||||
#define SCTPCTL_MAXBURST_MIN 0
|
||||
#define SCTPCTL_MAXBURST_MAX 0xFFFFFFFF
|
||||
#define SCTPCTL_MAXBURST_DEFAULT SCTP_DEF_MAX_BURST
|
||||
|
||||
/* fr_maxburst: Default max burst for sctp endpoints when fast retransmitting */
|
||||
#define SCTPCTL_FRMAXBURST_DESC "Default max burst for SCTP endpoints when fast retransmitting"
|
||||
#define SCTPCTL_FRMAXBURST_MIN 0
|
||||
#define SCTPCTL_FRMAXBURST_MAX 0xFFFFFFFF
|
||||
#define SCTPCTL_FRMAXBURST_DEFAULT SCTP_DEF_FRMAX_BURST
|
||||
|
||||
/* maxchunks: Default max chunks on queue per asoc */
|
||||
#define SCTPCTL_MAXCHUNKS_DESC "Default max chunks on queue per asoc"
|
||||
#define SCTPCTL_MAXCHUNKS_MIN 0
|
||||
#define SCTPCTL_MAXCHUNKS_MAX 0xFFFFFFFF
|
||||
#define SCTPCTL_MAXCHUNKS_DEFAULT SCTP_ASOC_MAX_CHUNKS_ON_QUEUE
|
||||
|
||||
/* tcbhashsize: Tunable for Hash table sizes */
|
||||
#define SCTPCTL_TCBHASHSIZE_DESC "Tunable for TCB hash table sizes"
|
||||
#define SCTPCTL_TCBHASHSIZE_MIN 1
|
||||
#define SCTPCTL_TCBHASHSIZE_MAX 0xFFFFFFFF
|
||||
#define SCTPCTL_TCBHASHSIZE_DEFAULT SCTP_TCBHASHSIZE
|
||||
|
||||
/* pcbhashsize: Tunable for PCB Hash table sizes */
|
||||
#define SCTPCTL_PCBHASHSIZE_DESC "Tunable for PCB hash table sizes"
|
||||
#define SCTPCTL_PCBHASHSIZE_MIN 1
|
||||
#define SCTPCTL_PCBHASHSIZE_MAX 0xFFFFFFFF
|
||||
#define SCTPCTL_PCBHASHSIZE_DEFAULT SCTP_PCBHASHSIZE
|
||||
|
||||
/* min_split_point: Minimum size when splitting a chunk */
|
||||
#define SCTPCTL_MIN_SPLIT_POINT_DESC "Minimum size when splitting a chunk"
|
||||
#define SCTPCTL_MIN_SPLIT_POINT_MIN 0
|
||||
#define SCTPCTL_MIN_SPLIT_POINT_MAX 0xFFFFFFFF
|
||||
#define SCTPCTL_MIN_SPLIT_POINT_DEFAULT SCTP_DEFAULT_SPLIT_POINT_MIN
|
||||
|
||||
/* chunkscale: Tunable for Scaling of number of chunks and messages */
|
||||
#define SCTPCTL_CHUNKSCALE_DESC "Tunable for scaling of number of chunks and messages"
|
||||
#define SCTPCTL_CHUNKSCALE_MIN 1
|
||||
#define SCTPCTL_CHUNKSCALE_MAX 0xFFFFFFFF
|
||||
#define SCTPCTL_CHUNKSCALE_DEFAULT SCTP_CHUNKQUEUE_SCALE
|
||||
|
||||
/* delayed_sack_time: Default delayed SACK timer in ms */
|
||||
#define SCTPCTL_DELAYED_SACK_TIME_DESC "Default delayed SACK timer in ms"
|
||||
#define SCTPCTL_DELAYED_SACK_TIME_MIN 0
|
||||
#define SCTPCTL_DELAYED_SACK_TIME_MAX 0xFFFFFFFF
|
||||
#define SCTPCTL_DELAYED_SACK_TIME_DEFAULT SCTP_RECV_MSEC
|
||||
|
||||
/* sack_freq: Default SACK frequency */
|
||||
#define SCTPCTL_SACK_FREQ_DESC "Default SACK frequency"
|
||||
#define SCTPCTL_SACK_FREQ_MIN 0
|
||||
#define SCTPCTL_SACK_FREQ_MAX 0xFFFFFFFF
|
||||
#define SCTPCTL_SACK_FREQ_DEFAULT SCTP_DEFAULT_SACK_FREQ
|
||||
|
||||
/* sys_resource: Max number of cached resources in the system */
|
||||
#define SCTPCTL_SYS_RESOURCE_DESC "Max number of cached resources in the system"
|
||||
#define SCTPCTL_SYS_RESOURCE_MIN 0
|
||||
#define SCTPCTL_SYS_RESOURCE_MAX 0xFFFFFFFF
|
||||
#define SCTPCTL_SYS_RESOURCE_DEFAULT SCTP_DEF_SYSTEM_RESC_LIMIT
|
||||
|
||||
/* asoc_resource: Max number of cached resources in an asoc */
|
||||
#define SCTPCTL_ASOC_RESOURCE_DESC "Max number of cached resources in an asoc"
|
||||
#define SCTPCTL_ASOC_RESOURCE_MIN 0
|
||||
#define SCTPCTL_ASOC_RESOURCE_MAX 0xFFFFFFFF
|
||||
#define SCTPCTL_ASOC_RESOURCE_DEFAULT SCTP_DEF_ASOC_RESC_LIMIT
|
||||
|
||||
/* heartbeat_interval: Default heartbeat interval in ms */
|
||||
#define SCTPCTL_HEARTBEAT_INTERVAL_DESC "Default heartbeat interval in ms"
|
||||
#define SCTPCTL_HEARTBEAT_INTERVAL_MIN 0
|
||||
#define SCTPCTL_HEARTBEAT_INTERVAL_MAX 0xFFFFFFFF
|
||||
#define SCTPCTL_HEARTBEAT_INTERVAL_DEFAULT SCTP_HB_DEFAULT_MSEC
|
||||
|
||||
/* pmtu_raise_time: Default PMTU raise timer in seconds */
|
||||
#define SCTPCTL_PMTU_RAISE_TIME_DESC "Default PMTU raise timer in seconds"
|
||||
#define SCTPCTL_PMTU_RAISE_TIME_MIN 0
|
||||
#define SCTPCTL_PMTU_RAISE_TIME_MAX 0xFFFFFFFF
|
||||
#define SCTPCTL_PMTU_RAISE_TIME_DEFAULT SCTP_DEF_PMTU_RAISE_SEC
|
||||
|
||||
/* shutdown_guard_time: Default shutdown guard timer in seconds */
|
||||
#define SCTPCTL_SHUTDOWN_GUARD_TIME_DESC "Shutdown guard timer in seconds (0 means 5 times RTO.Max)"
|
||||
#define SCTPCTL_SHUTDOWN_GUARD_TIME_MIN 0
|
||||
#define SCTPCTL_SHUTDOWN_GUARD_TIME_MAX 0xFFFFFFFF
|
||||
#define SCTPCTL_SHUTDOWN_GUARD_TIME_DEFAULT 0
|
||||
|
||||
/* secret_lifetime: Default secret lifetime in seconds */
|
||||
#define SCTPCTL_SECRET_LIFETIME_DESC "Default secret lifetime in seconds"
|
||||
#define SCTPCTL_SECRET_LIFETIME_MIN 0
|
||||
#define SCTPCTL_SECRET_LIFETIME_MAX 0xFFFFFFFF
|
||||
#define SCTPCTL_SECRET_LIFETIME_DEFAULT SCTP_DEFAULT_SECRET_LIFE_SEC
|
||||
|
||||
/* rto_max: Default maximum retransmission timeout in ms */
|
||||
#define SCTPCTL_RTO_MAX_DESC "Default maximum retransmission timeout in ms"
|
||||
#define SCTPCTL_RTO_MAX_MIN 0
|
||||
#define SCTPCTL_RTO_MAX_MAX 0xFFFFFFFF
|
||||
#define SCTPCTL_RTO_MAX_DEFAULT SCTP_RTO_UPPER_BOUND
|
||||
|
||||
/* rto_min: Default minimum retransmission timeout in ms */
|
||||
#define SCTPCTL_RTO_MIN_DESC "Default minimum retransmission timeout in ms"
|
||||
#define SCTPCTL_RTO_MIN_MIN 0
|
||||
#define SCTPCTL_RTO_MIN_MAX 0xFFFFFFFF
|
||||
#define SCTPCTL_RTO_MIN_DEFAULT SCTP_RTO_LOWER_BOUND
|
||||
|
||||
/* rto_initial: Default initial retransmission timeout in ms */
|
||||
#define SCTPCTL_RTO_INITIAL_DESC "Default initial retransmission timeout in ms"
|
||||
#define SCTPCTL_RTO_INITIAL_MIN 0
|
||||
#define SCTPCTL_RTO_INITIAL_MAX 0xFFFFFFFF
|
||||
#define SCTPCTL_RTO_INITIAL_DEFAULT SCTP_RTO_INITIAL
|
||||
|
||||
/* init_rto_max: Default maximum retransmission timeout during association setup in ms */
|
||||
#define SCTPCTL_INIT_RTO_MAX_DESC "Default maximum retransmission timeout during association setup in ms"
|
||||
#define SCTPCTL_INIT_RTO_MAX_MIN 0
|
||||
#define SCTPCTL_INIT_RTO_MAX_MAX 0xFFFFFFFF
|
||||
#define SCTPCTL_INIT_RTO_MAX_DEFAULT SCTP_RTO_UPPER_BOUND
|
||||
|
||||
/* valid_cookie_life: Default cookie lifetime in ms */
|
||||
#define SCTPCTL_VALID_COOKIE_LIFE_DESC "Default cookie lifetime in ms"
|
||||
#define SCTPCTL_VALID_COOKIE_LIFE_MIN SCTP_MIN_COOKIE_LIFE
|
||||
#define SCTPCTL_VALID_COOKIE_LIFE_MAX SCTP_MAX_COOKIE_LIFE
|
||||
#define SCTPCTL_VALID_COOKIE_LIFE_DEFAULT SCTP_DEFAULT_COOKIE_LIFE
|
||||
|
||||
/* init_rtx_max: Default maximum number of retransmission for INIT chunks */
|
||||
#define SCTPCTL_INIT_RTX_MAX_DESC "Default maximum number of retransmissions for INIT chunks"
|
||||
#define SCTPCTL_INIT_RTX_MAX_MIN 0
|
||||
#define SCTPCTL_INIT_RTX_MAX_MAX 0xFFFFFFFF
|
||||
#define SCTPCTL_INIT_RTX_MAX_DEFAULT SCTP_DEF_MAX_INIT
|
||||
|
||||
/* assoc_rtx_max: Default maximum number of retransmissions per association */
|
||||
#define SCTPCTL_ASSOC_RTX_MAX_DESC "Default maximum number of retransmissions per association"
|
||||
#define SCTPCTL_ASSOC_RTX_MAX_MIN 0
|
||||
#define SCTPCTL_ASSOC_RTX_MAX_MAX 0xFFFFFFFF
|
||||
#define SCTPCTL_ASSOC_RTX_MAX_DEFAULT SCTP_DEF_MAX_SEND
|
||||
|
||||
/* path_rtx_max: Default maximum of retransmissions per path */
|
||||
#define SCTPCTL_PATH_RTX_MAX_DESC "Default maximum of retransmissions per path"
|
||||
#define SCTPCTL_PATH_RTX_MAX_MIN 0
|
||||
#define SCTPCTL_PATH_RTX_MAX_MAX 0xFFFFFFFF
|
||||
#define SCTPCTL_PATH_RTX_MAX_DEFAULT SCTP_DEF_MAX_PATH_RTX
|
||||
|
||||
/* path_pf_threshold: threshold for considering the path potentially failed */
|
||||
#define SCTPCTL_PATH_PF_THRESHOLD_DESC "Default potentially failed threshold"
|
||||
#define SCTPCTL_PATH_PF_THRESHOLD_MIN 0
|
||||
#define SCTPCTL_PATH_PF_THRESHOLD_MAX 0xFFFF
|
||||
#define SCTPCTL_PATH_PF_THRESHOLD_DEFAULT SCTPCTL_PATH_PF_THRESHOLD_MAX
|
||||
|
||||
/* add_more_on_output: When space-wise is it worthwhile to try to add more to a socket send buffer */
|
||||
#define SCTPCTL_ADD_MORE_ON_OUTPUT_DESC "When space-wise is it worthwhile to try to add more to a socket send buffer"
|
||||
#define SCTPCTL_ADD_MORE_ON_OUTPUT_MIN 0
|
||||
#define SCTPCTL_ADD_MORE_ON_OUTPUT_MAX 0xFFFFFFFF
|
||||
#define SCTPCTL_ADD_MORE_ON_OUTPUT_DEFAULT SCTP_DEFAULT_ADD_MORE
|
||||
|
||||
/* incoming_streams: Default number of incoming streams */
|
||||
#define SCTPCTL_INCOMING_STREAMS_DESC "Default number of incoming streams"
|
||||
#define SCTPCTL_INCOMING_STREAMS_MIN 1
|
||||
#define SCTPCTL_INCOMING_STREAMS_MAX 65535
|
||||
#define SCTPCTL_INCOMING_STREAMS_DEFAULT SCTP_ISTREAM_INITIAL
|
||||
|
||||
/* outgoing_streams: Default number of outgoing streams */
|
||||
#define SCTPCTL_OUTGOING_STREAMS_DESC "Default number of outgoing streams"
|
||||
#define SCTPCTL_OUTGOING_STREAMS_MIN 1
|
||||
#define SCTPCTL_OUTGOING_STREAMS_MAX 65535
|
||||
#define SCTPCTL_OUTGOING_STREAMS_DEFAULT SCTP_OSTREAM_INITIAL
|
||||
|
||||
/* cmt_on_off: CMT on/off flag */
|
||||
#define SCTPCTL_CMT_ON_OFF_DESC "CMT settings"
|
||||
#define SCTPCTL_CMT_ON_OFF_MIN SCTP_CMT_OFF
|
||||
#define SCTPCTL_CMT_ON_OFF_MAX SCTP_CMT_MAX
|
||||
#define SCTPCTL_CMT_ON_OFF_DEFAULT SCTP_CMT_OFF
|
||||
|
||||
/* cmt_use_dac: CMT DAC on/off flag */
|
||||
#define SCTPCTL_CMT_USE_DAC_DESC "CMT DAC on/off flag"
|
||||
#define SCTPCTL_CMT_USE_DAC_MIN 0
|
||||
#define SCTPCTL_CMT_USE_DAC_MAX 1
|
||||
#define SCTPCTL_CMT_USE_DAC_DEFAULT 0
|
||||
|
||||
/* cwnd_maxburst: Use a CWND adjusting to implement maxburst */
|
||||
#define SCTPCTL_CWND_MAXBURST_DESC "Adjust congestion control window to limit maximum burst when sending"
|
||||
#define SCTPCTL_CWND_MAXBURST_MIN 0
|
||||
#define SCTPCTL_CWND_MAXBURST_MAX 1
|
||||
#define SCTPCTL_CWND_MAXBURST_DEFAULT 1
|
||||
|
||||
/* nat_friendly: SCTP NAT friendly operation */
|
||||
#define SCTPCTL_NAT_FRIENDLY_DESC "SCTP NAT friendly operation"
|
||||
#define SCTPCTL_NAT_FRIENDLY_MIN 0
|
||||
#define SCTPCTL_NAT_FRIENDLY_MAX 1
|
||||
#define SCTPCTL_NAT_FRIENDLY_DEFAULT 1
|
||||
|
||||
/* abc_l_var: SCTP ABC max increase per SACK (L) */
|
||||
#define SCTPCTL_ABC_L_VAR_DESC "SCTP ABC max increase per SACK (L)"
|
||||
#define SCTPCTL_ABC_L_VAR_MIN 0
|
||||
#define SCTPCTL_ABC_L_VAR_MAX 0xFFFFFFFF
|
||||
#define SCTPCTL_ABC_L_VAR_DEFAULT 2
|
||||
|
||||
/* max_chained_mbufs: Default max number of small mbufs on a chain */
|
||||
#define SCTPCTL_MAX_CHAINED_MBUFS_DESC "Default max number of small mbufs on a chain"
|
||||
#define SCTPCTL_MAX_CHAINED_MBUFS_MIN 0
|
||||
#define SCTPCTL_MAX_CHAINED_MBUFS_MAX 0xFFFFFFFF
|
||||
#define SCTPCTL_MAX_CHAINED_MBUFS_DEFAULT SCTP_DEFAULT_MBUFS_IN_CHAIN
|
||||
|
||||
/* do_sctp_drain: Should SCTP respond to the drain calls */
|
||||
#define SCTPCTL_DO_SCTP_DRAIN_DESC "Should SCTP respond to the drain calls"
|
||||
#define SCTPCTL_DO_SCTP_DRAIN_MIN 0
|
||||
#define SCTPCTL_DO_SCTP_DRAIN_MAX 1
|
||||
#define SCTPCTL_DO_SCTP_DRAIN_DEFAULT 1
|
||||
|
||||
/* hb_max_burst: Confirmation Heartbeat max burst? */
|
||||
#define SCTPCTL_HB_MAX_BURST_DESC "Confirmation Heartbeat max burst"
|
||||
#define SCTPCTL_HB_MAX_BURST_MIN 1
|
||||
#define SCTPCTL_HB_MAX_BURST_MAX 0xFFFFFFFF
|
||||
#define SCTPCTL_HB_MAX_BURST_DEFAULT SCTP_DEF_HBMAX_BURST
|
||||
|
||||
/* abort_at_limit: When one-2-one hits qlimit abort */
|
||||
#define SCTPCTL_ABORT_AT_LIMIT_DESC "Abort when one-to-one hits qlimit"
|
||||
#define SCTPCTL_ABORT_AT_LIMIT_MIN 0
|
||||
#define SCTPCTL_ABORT_AT_LIMIT_MAX 1
|
||||
#define SCTPCTL_ABORT_AT_LIMIT_DEFAULT 0
|
||||
|
||||
/* min_residual: min residual in a data fragment leftover */
|
||||
#define SCTPCTL_MIN_RESIDUAL_DESC "Minimum residual data chunk in second part of split"
|
||||
#define SCTPCTL_MIN_RESIDUAL_MIN 20
|
||||
#define SCTPCTL_MIN_RESIDUAL_MAX 65535
|
||||
#define SCTPCTL_MIN_RESIDUAL_DEFAULT 1452
|
||||
|
||||
/* max_retran_chunk: max chunk retransmissions */
|
||||
#define SCTPCTL_MAX_RETRAN_CHUNK_DESC "Maximum times an unlucky chunk can be retransmitted before assoc abort"
|
||||
#define SCTPCTL_MAX_RETRAN_CHUNK_MIN 0
|
||||
#define SCTPCTL_MAX_RETRAN_CHUNK_MAX 65535
|
||||
#define SCTPCTL_MAX_RETRAN_CHUNK_DEFAULT 30
|
||||
|
||||
/* sctp_logging: This gives us logging when the options are enabled */
|
||||
#define SCTPCTL_LOGGING_LEVEL_DESC "Ltrace/KTR trace logging level"
|
||||
#define SCTPCTL_LOGGING_LEVEL_MIN 0
|
||||
#define SCTPCTL_LOGGING_LEVEL_MAX 0xffffffff
|
||||
#define SCTPCTL_LOGGING_LEVEL_DEFAULT 0
|
||||
|
||||
/* JRS - default congestion control module sysctl */
|
||||
#define SCTPCTL_DEFAULT_CC_MODULE_DESC "Default congestion control module"
|
||||
#define SCTPCTL_DEFAULT_CC_MODULE_MIN 0
|
||||
#define SCTPCTL_DEFAULT_CC_MODULE_MAX 2
|
||||
#define SCTPCTL_DEFAULT_CC_MODULE_DEFAULT 0
|
||||
|
||||
/* RS - default stream scheduling module sysctl */
|
||||
#define SCTPCTL_DEFAULT_SS_MODULE_DESC "Default stream scheduling module"
|
||||
#define SCTPCTL_DEFAULT_SS_MODULE_MIN 0
|
||||
#define SCTPCTL_DEFAULT_SS_MODULE_MAX 5
|
||||
#define SCTPCTL_DEFAULT_SS_MODULE_DEFAULT 0
|
||||
|
||||
/* RRS - default fragment interleave */
|
||||
#define SCTPCTL_DEFAULT_FRAG_INTERLEAVE_DESC "Default fragment interleave level"
|
||||
#define SCTPCTL_DEFAULT_FRAG_INTERLEAVE_MIN 0
|
||||
#define SCTPCTL_DEFAULT_FRAG_INTERLEAVE_MAX 2
|
||||
#define SCTPCTL_DEFAULT_FRAG_INTERLEAVE_DEFAULT 1
|
||||
|
||||
/* mobility_base: Enable SCTP mobility support */
|
||||
#define SCTPCTL_MOBILITY_BASE_DESC "Enable SCTP base mobility"
|
||||
#define SCTPCTL_MOBILITY_BASE_MIN 0
|
||||
#define SCTPCTL_MOBILITY_BASE_MAX 1
|
||||
#define SCTPCTL_MOBILITY_BASE_DEFAULT 0
|
||||
|
||||
/* mobility_fasthandoff: Enable SCTP fast handoff support */
|
||||
#define SCTPCTL_MOBILITY_FASTHANDOFF_DESC "Enable SCTP fast handoff"
|
||||
#define SCTPCTL_MOBILITY_FASTHANDOFF_MIN 0
|
||||
#define SCTPCTL_MOBILITY_FASTHANDOFF_MAX 1
|
||||
#define SCTPCTL_MOBILITY_FASTHANDOFF_DEFAULT 0
|
||||
|
||||
/* Enable SCTP/UDP tunneling port */
|
||||
#define SCTPCTL_UDP_TUNNELING_PORT_DESC "Set the SCTP/UDP tunneling port"
|
||||
#define SCTPCTL_UDP_TUNNELING_PORT_MIN 0
|
||||
#define SCTPCTL_UDP_TUNNELING_PORT_MAX 65535
|
||||
#if defined(__FreeBSD__) && !defined(__Userspace__)
|
||||
#define SCTPCTL_UDP_TUNNELING_PORT_DEFAULT 0
|
||||
#else
|
||||
#define SCTPCTL_UDP_TUNNELING_PORT_DEFAULT SCTP_OVER_UDP_TUNNELING_PORT
|
||||
#endif
|
||||
|
||||
/* Enable sending of the SACK-IMMEDIATELY bit */
|
||||
#define SCTPCTL_SACK_IMMEDIATELY_ENABLE_DESC "Enable sending of the SACK-IMMEDIATELY-bit"
|
||||
#define SCTPCTL_SACK_IMMEDIATELY_ENABLE_MIN 0
|
||||
#define SCTPCTL_SACK_IMMEDIATELY_ENABLE_MAX 1
|
||||
#define SCTPCTL_SACK_IMMEDIATELY_ENABLE_DEFAULT SCTPCTL_SACK_IMMEDIATELY_ENABLE_MAX
|
||||
|
||||
/* Enable sending of the NAT-FRIENDLY message */
|
||||
#define SCTPCTL_NAT_FRIENDLY_INITS_DESC "Enable sending of the nat-friendly SCTP option on INITs"
|
||||
#define SCTPCTL_NAT_FRIENDLY_INITS_MIN 0
|
||||
#define SCTPCTL_NAT_FRIENDLY_INITS_MAX 1
|
||||
#define SCTPCTL_NAT_FRIENDLY_INITS_DEFAULT SCTPCTL_NAT_FRIENDLY_INITS_MIN
|
||||
|
||||
/* Vtag time wait in seconds */
|
||||
#define SCTPCTL_TIME_WAIT_DESC "Vtag time wait time in seconds, 0 disables it"
|
||||
#define SCTPCTL_TIME_WAIT_MIN 0
|
||||
#define SCTPCTL_TIME_WAIT_MAX 0xffffffff
|
||||
#define SCTPCTL_TIME_WAIT_DEFAULT SCTP_TIME_WAIT
|
||||
|
||||
/* Enable Send/Receive buffer splitting */
|
||||
#define SCTPCTL_BUFFER_SPLITTING_DESC "Enable send/receive buffer splitting"
|
||||
#define SCTPCTL_BUFFER_SPLITTING_MIN 0
|
||||
#define SCTPCTL_BUFFER_SPLITTING_MAX 0x3
|
||||
#define SCTPCTL_BUFFER_SPLITTING_DEFAULT SCTPCTL_BUFFER_SPLITTING_MIN
|
||||
|
||||
/* Initial congestion window in MTUs */
|
||||
#define SCTPCTL_INITIAL_CWND_DESC "Defines the initial congestion window size in MTUs"
|
||||
#define SCTPCTL_INITIAL_CWND_MIN 0
|
||||
#define SCTPCTL_INITIAL_CWND_MAX 0xffffffff
|
||||
#define SCTPCTL_INITIAL_CWND_DEFAULT 3
|
||||
|
||||
/* rttvar smooth avg for bw calc */
|
||||
#define SCTPCTL_RTTVAR_BW_DESC "Shift amount DCCC uses for bw smoothing on rtt calc"
|
||||
#define SCTPCTL_RTTVAR_BW_MIN 0
|
||||
#define SCTPCTL_RTTVAR_BW_MAX 32
|
||||
#define SCTPCTL_RTTVAR_BW_DEFAULT 4
|
||||
|
||||
/* rttvar smooth avg for bw calc */
|
||||
#define SCTPCTL_RTTVAR_RTT_DESC "Shift amount DCCC uses for rtt smoothing on rtt calc"
|
||||
#define SCTPCTL_RTTVAR_RTT_MIN 0
|
||||
#define SCTPCTL_RTTVAR_RTT_MAX 32
|
||||
#define SCTPCTL_RTTVAR_RTT_DEFAULT 5
|
||||
|
||||
#define SCTPCTL_RTTVAR_EQRET_DESC "Whether DCCC increases cwnd when the rtt and bw are unchanged"
|
||||
#define SCTPCTL_RTTVAR_EQRET_MIN 0
|
||||
#define SCTPCTL_RTTVAR_EQRET_MAX 1
|
||||
#define SCTPCTL_RTTVAR_EQRET_DEFAULT 0
|
||||
|
||||
#define SCTPCTL_RTTVAR_STEADYS_DESC "Number of identical bw measurements DCCC takes to try step down of cwnd"
|
||||
#define SCTPCTL_RTTVAR_STEADYS_MIN 0
|
||||
#define SCTPCTL_RTTVAR_STEADYS_MAX 0xFFFF
|
||||
#define SCTPCTL_RTTVAR_STEADYS_DEFAULT 20 /* 0 means disable feature */
|
||||
|
||||
#define SCTPCTL_RTTVAR_DCCCECN_DESC "Enable ECN for DCCC."
|
||||
#define SCTPCTL_RTTVAR_DCCCECN_MIN 0
|
||||
#define SCTPCTL_RTTVAR_DCCCECN_MAX 1
|
||||
#define SCTPCTL_RTTVAR_DCCCECN_DEFAULT 1 /* 0 means disable feature */
|
||||
|
||||
#define SCTPCTL_BLACKHOLE_DESC "Enable SCTP blackholing, see blackhole(4) for more details"
|
||||
#define SCTPCTL_BLACKHOLE_MIN 0
|
||||
#define SCTPCTL_BLACKHOLE_MAX 2
|
||||
#define SCTPCTL_BLACKHOLE_DEFAULT SCTPCTL_BLACKHOLE_MIN
|
||||
|
||||
/* sendall_limit: Maximum message with SCTP_SENDALL */
|
||||
#define SCTPCTL_SENDALL_LIMIT_DESC "Maximum size of a message send with SCTP_SENDALL"
|
||||
#define SCTPCTL_SENDALL_LIMIT_MIN 0
|
||||
#define SCTPCTL_SENDALL_LIMIT_MAX 0xFFFFFFFF
|
||||
#define SCTPCTL_SENDALL_LIMIT_DEFAULT 1432
|
||||
|
||||
#define SCTPCTL_DIAG_INFO_CODE_DESC "Diagnostic information error cause code"
|
||||
#define SCTPCTL_DIAG_INFO_CODE_MIN 0
|
||||
#define SCTPCTL_DIAG_INFO_CODE_MAX 65535
|
||||
#define SCTPCTL_DIAG_INFO_CODE_DEFAULT 0
|
||||
|
||||
#if defined(SCTP_DEBUG)
|
||||
/* debug: Configure debug output */
|
||||
#define SCTPCTL_DEBUG_DESC "Configure debug output"
|
||||
#define SCTPCTL_DEBUG_MIN 0
|
||||
#define SCTPCTL_DEBUG_MAX 0xFFFFFFFF
|
||||
#define SCTPCTL_DEBUG_DEFAULT 0
|
||||
#endif
|
||||
|
||||
#if defined(__APPLE__) && !defined(__Userspace__)
|
||||
#define SCTPCTL_MAIN_TIMER_DESC "Main timer interval in ms"
|
||||
#define SCTPCTL_MAIN_TIMER_MIN 1
|
||||
#define SCTPCTL_MAIN_TIMER_MAX 0xFFFFFFFF
|
||||
#define SCTPCTL_MAIN_TIMER_DEFAULT 10
|
||||
|
||||
#define SCTPCTL_IGNORE_VMWARE_INTERFACES_DESC "Ignore VMware Interfaces"
|
||||
#define SCTPCTL_IGNORE_VMWARE_INTERFACES_MIN 0
|
||||
#define SCTPCTL_IGNORE_VMWARE_INTERFACES_MAX 1
|
||||
#define SCTPCTL_IGNORE_VMWARE_INTERFACES_DEFAULT SCTPCTL_IGNORE_VMWARE_INTERFACES_MAX
|
||||
|
||||
#define SCTPCTL_OUTPUT_UNLOCKED_DESC "Unlock socket when sending packets down to IP"
|
||||
#define SCTPCTL_OUTPUT_UNLOCKED_MIN 0
|
||||
#define SCTPCTL_OUTPUT_UNLOCKED_MAX 1
|
||||
#define SCTPCTL_OUTPUT_UNLOCKED_DEFAULT SCTPCTL_OUTPUT_UNLOCKED_MIN
|
||||
|
||||
#define SCTPCTL_ADDR_WATCHDOG_LIMIT_DESC "Address watchdog limit"
|
||||
#define SCTPCTL_ADDR_WATCHDOG_LIMIT_MIN 0
|
||||
#define SCTPCTL_ADDR_WATCHDOG_LIMIT_MAX 0xFFFFFFFF
|
||||
#define SCTPCTL_ADDR_WATCHDOG_LIMIT_DEFAULT SCTPCTL_ADDR_WATCHDOG_LIMIT_MIN
|
||||
|
||||
#define SCTPCTL_VTAG_WATCHDOG_LIMIT_DESC "VTag watchdog limit"
|
||||
#define SCTPCTL_VTAG_WATCHDOG_LIMIT_MIN 0
|
||||
#define SCTPCTL_VTAG_WATCHDOG_LIMIT_MAX 0xFFFFFFFF
|
||||
#define SCTPCTL_VTAG_WATCHDOG_LIMIT_DEFAULT SCTPCTL_VTAG_WATCHDOG_LIMIT_MIN
|
||||
|
||||
#endif
|
||||
#if defined(_KERNEL) || defined(__Userspace__)
|
||||
#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__Userspace__)
|
||||
#if defined(SYSCTL_DECL)
|
||||
SYSCTL_DECL(_net_inet_sctp);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
void sctp_init_sysctls(void);
|
||||
#if defined(_WIN32) && !defined(__Userspace__)
|
||||
void sctp_finish_sysctls(void);
|
||||
#endif
|
||||
|
||||
#endif /* _KERNEL */
|
||||
#endif /* __sctp_sysctl_h__ */
|
||||
1641
TMessagesProj/jni/third_party/usrsctplib/netinet/sctp_timer.c
vendored
Executable file
1641
TMessagesProj/jni/third_party/usrsctplib/netinet/sctp_timer.c
vendored
Executable file
File diff suppressed because it is too large
Load diff
103
TMessagesProj/jni/third_party/usrsctplib/netinet/sctp_timer.h
vendored
Executable file
103
TMessagesProj/jni/third_party/usrsctplib/netinet/sctp_timer.h
vendored
Executable file
|
|
@ -0,0 +1,103 @@
|
|||
/*-
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#if defined(__FreeBSD__) && !defined(__Userspace__)
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD: head/sys/netinet/sctp_timer.h 365071 2020-09-01 21:19:14Z mjg $");
|
||||
#endif
|
||||
|
||||
#ifndef _NETINET_SCTP_TIMER_H_
|
||||
#define _NETINET_SCTP_TIMER_H_
|
||||
|
||||
#if defined(_KERNEL) || defined(__Userspace__)
|
||||
|
||||
#define SCTP_RTT_SHIFT 3
|
||||
#define SCTP_RTT_VAR_SHIFT 2
|
||||
|
||||
struct sctp_nets *
|
||||
sctp_find_alternate_net(struct sctp_tcb *, struct sctp_nets *, int);
|
||||
|
||||
int
|
||||
sctp_t3rxt_timer(struct sctp_inpcb *, struct sctp_tcb *,
|
||||
struct sctp_nets *);
|
||||
|
||||
int
|
||||
sctp_t1init_timer(struct sctp_inpcb *, struct sctp_tcb *,
|
||||
struct sctp_nets *);
|
||||
|
||||
int
|
||||
sctp_shutdown_timer(struct sctp_inpcb *, struct sctp_tcb *,
|
||||
struct sctp_nets *);
|
||||
|
||||
int
|
||||
sctp_heartbeat_timer(struct sctp_inpcb *, struct sctp_tcb *,
|
||||
struct sctp_nets *);
|
||||
|
||||
int
|
||||
sctp_cookie_timer(struct sctp_inpcb *, struct sctp_tcb *,
|
||||
struct sctp_nets *);
|
||||
|
||||
void
|
||||
sctp_pathmtu_timer(struct sctp_inpcb *, struct sctp_tcb *,
|
||||
struct sctp_nets *);
|
||||
|
||||
int
|
||||
sctp_shutdownack_timer(struct sctp_inpcb *, struct sctp_tcb *,
|
||||
struct sctp_nets *);
|
||||
int
|
||||
sctp_strreset_timer(struct sctp_inpcb *, struct sctp_tcb *);
|
||||
|
||||
int
|
||||
sctp_asconf_timer(struct sctp_inpcb *, struct sctp_tcb *,
|
||||
struct sctp_nets *);
|
||||
|
||||
void
|
||||
sctp_delete_prim_timer(struct sctp_inpcb *, struct sctp_tcb *);
|
||||
|
||||
void
|
||||
sctp_autoclose_timer(struct sctp_inpcb *, struct sctp_tcb *);
|
||||
|
||||
void sctp_audit_retranmission_queue(struct sctp_association *);
|
||||
|
||||
void sctp_iterator_timer(struct sctp_iterator *it);
|
||||
|
||||
#if defined(__APPLE__) && !defined(__Userspace__)
|
||||
#if defined(APPLE_LEOPARD) || defined(APPLE_SNOWLEOPARD) || defined(APPLE_LION) || defined(APPLE_MOUNTAINLION)
|
||||
void sctp_slowtimo(void);
|
||||
#else
|
||||
void sctp_gc(struct inpcbinfo *);
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
1352
TMessagesProj/jni/third_party/usrsctplib/netinet/sctp_uio.h
vendored
Executable file
1352
TMessagesProj/jni/third_party/usrsctplib/netinet/sctp_uio.h
vendored
Executable file
File diff suppressed because it is too large
Load diff
444
TMessagesProj/jni/third_party/usrsctplib/netinet/sctp_userspace.c
vendored
Executable file
444
TMessagesProj/jni/third_party/usrsctplib/netinet/sctp_userspace.c
vendored
Executable file
|
|
@ -0,0 +1,444 @@
|
|||
/*-
|
||||
* Copyright (c) 2011-2012 Irene Ruengeler
|
||||
* Copyright (c) 2011-2012 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:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. 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.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <netinet/sctp_pcb.h>
|
||||
#include <sys/timeb.h>
|
||||
#include <iphlpapi.h>
|
||||
#if !defined(__MINGW32__)
|
||||
#pragma comment(lib, "iphlpapi.lib")
|
||||
#endif
|
||||
#endif
|
||||
#include <netinet/sctp_os_userspace.h>
|
||||
#if defined(__FreeBSD__)
|
||||
#include <pthread_np.h>
|
||||
#endif
|
||||
|
||||
#if defined(__linux__)
|
||||
#include <sys/prctl.h>
|
||||
#endif
|
||||
|
||||
#if defined(_WIN32)
|
||||
/* Adapter to translate Unix thread start routines to Windows thread start
|
||||
* routines.
|
||||
*/
|
||||
#if defined(__MINGW32__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wpedantic"
|
||||
#endif
|
||||
static DWORD WINAPI
|
||||
sctp_create_thread_adapter(void *arg) {
|
||||
start_routine_t start_routine = (start_routine_t)arg;
|
||||
return start_routine(NULL) == NULL;
|
||||
}
|
||||
|
||||
int
|
||||
sctp_userspace_thread_create(userland_thread_t *thread, start_routine_t start_routine)
|
||||
{
|
||||
*thread = CreateThread(NULL, 0, sctp_create_thread_adapter,
|
||||
(void *)start_routine, 0, NULL);
|
||||
if (*thread == NULL)
|
||||
return GetLastError();
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if defined(__MINGW32__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
|
||||
#else
|
||||
int
|
||||
sctp_userspace_thread_create(userland_thread_t *thread, start_routine_t start_routine)
|
||||
{
|
||||
return pthread_create(thread, NULL, start_routine, NULL);
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
sctp_userspace_set_threadname(const char *name)
|
||||
{
|
||||
#if defined(__APPLE__)
|
||||
pthread_setname_np(name);
|
||||
#endif
|
||||
#if defined(__linux__)
|
||||
prctl(PR_SET_NAME, name);
|
||||
#endif
|
||||
#if defined(__FreeBSD__)
|
||||
pthread_set_name_np(pthread_self(), name);
|
||||
#endif
|
||||
}
|
||||
|
||||
#if !defined(_WIN32) && !defined(__native_client__)
|
||||
int
|
||||
sctp_userspace_get_mtu_from_ifn(uint32_t if_index, int af)
|
||||
{
|
||||
#if defined(INET) || defined(INET6)
|
||||
struct ifreq ifr;
|
||||
int fd;
|
||||
#endif
|
||||
int mtu;
|
||||
|
||||
switch (af) {
|
||||
#if defined(INET)
|
||||
case AF_INET:
|
||||
#endif
|
||||
#if defined(INET6)
|
||||
case AF_INET6:
|
||||
#endif
|
||||
#if defined(INET) || defined(INET6)
|
||||
memset(&ifr, 0, sizeof(struct ifreq));
|
||||
mtu = 0;
|
||||
if (if_indextoname(if_index, ifr.ifr_name) != NULL) {
|
||||
/* TODO can I use the raw socket here and not have to open a new one with each query? */
|
||||
if ((fd = socket(af, SOCK_DGRAM, 0)) < 0) {
|
||||
break;
|
||||
}
|
||||
if (ioctl(fd, SIOCGIFMTU, &ifr) >= 0) {
|
||||
mtu = ifr.ifr_mtu;
|
||||
}
|
||||
close(fd);
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
case AF_CONN:
|
||||
mtu = 1280;
|
||||
break;
|
||||
default:
|
||||
mtu = 0;
|
||||
break;
|
||||
}
|
||||
return (mtu);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(__native_client__)
|
||||
int
|
||||
sctp_userspace_get_mtu_from_ifn(uint32_t if_index, int af)
|
||||
{
|
||||
return 1280;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(__APPLE__) || defined(__DragonFly__) || defined(__linux__) || defined(__native_client__) || defined(__NetBSD__) || defined(_WIN32) || defined(__Fuchsia__) || defined(__EMSCRIPTEN__)
|
||||
int
|
||||
timingsafe_bcmp(const void *b1, const void *b2, size_t n)
|
||||
{
|
||||
const unsigned char *p1 = b1, *p2 = b2;
|
||||
int ret = 0;
|
||||
|
||||
for (; n > 0; n--)
|
||||
ret |= *p1++ ^ *p2++;
|
||||
return (ret != 0);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
int
|
||||
sctp_userspace_get_mtu_from_ifn(uint32_t if_index, int af)
|
||||
{
|
||||
#if defined(INET) || defined(INET6)
|
||||
PIP_ADAPTER_ADDRESSES pAdapterAddrs, pAdapt;
|
||||
DWORD AdapterAddrsSize, Err;
|
||||
#endif
|
||||
int mtu;
|
||||
|
||||
switch (af) {
|
||||
#if defined(INET)
|
||||
case AF_INET:
|
||||
#endif
|
||||
#if defined(INET6)
|
||||
case AF_INET6:
|
||||
#endif
|
||||
#if defined(INET) || defined(INET6)
|
||||
mtu = 0;
|
||||
AdapterAddrsSize = 0;
|
||||
pAdapterAddrs = NULL;
|
||||
if ((Err = GetAdaptersAddresses(AF_UNSPEC, 0, NULL, NULL, &AdapterAddrsSize)) != 0) {
|
||||
if ((Err != ERROR_BUFFER_OVERFLOW) && (Err != ERROR_INSUFFICIENT_BUFFER)) {
|
||||
SCTPDBG(SCTP_DEBUG_USR, "GetAdaptersAddresses() sizing failed with error code %d, AdapterAddrsSize = %d\n", Err, AdapterAddrsSize);
|
||||
mtu = -1;
|
||||
goto cleanup;
|
||||
}
|
||||
}
|
||||
if ((pAdapterAddrs = (PIP_ADAPTER_ADDRESSES) GlobalAlloc(GPTR, AdapterAddrsSize)) == NULL) {
|
||||
SCTPDBG(SCTP_DEBUG_USR, "Memory allocation error!\n");
|
||||
mtu = -1;
|
||||
goto cleanup;
|
||||
}
|
||||
if ((Err = GetAdaptersAddresses(AF_UNSPEC, 0, NULL, pAdapterAddrs, &AdapterAddrsSize)) != ERROR_SUCCESS) {
|
||||
SCTPDBG(SCTP_DEBUG_USR, "GetAdaptersAddresses() failed with error code %d\n", Err);
|
||||
mtu = -1;
|
||||
goto cleanup;
|
||||
}
|
||||
for (pAdapt = pAdapterAddrs; pAdapt; pAdapt = pAdapt->Next) {
|
||||
if (pAdapt->IfIndex == if_index) {
|
||||
mtu = pAdapt->Mtu;
|
||||
break;
|
||||
}
|
||||
}
|
||||
cleanup:
|
||||
if (pAdapterAddrs != NULL) {
|
||||
GlobalFree(pAdapterAddrs);
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
case AF_CONN:
|
||||
mtu = 1280;
|
||||
break;
|
||||
default:
|
||||
mtu = 0;
|
||||
break;
|
||||
}
|
||||
return (mtu);
|
||||
}
|
||||
|
||||
void
|
||||
getwintimeofday(struct timeval *tv)
|
||||
{
|
||||
FILETIME filetime;
|
||||
ULARGE_INTEGER ularge;
|
||||
|
||||
GetSystemTimeAsFileTime(&filetime);
|
||||
ularge.LowPart = filetime.dwLowDateTime;
|
||||
ularge.HighPart = filetime.dwHighDateTime;
|
||||
/* Change base from Jan 1 1601 00:00:00 to Jan 1 1970 00:00:00 */
|
||||
#if defined(__MINGW32__)
|
||||
ularge.QuadPart -= 116444736000000000ULL;
|
||||
#else
|
||||
ularge.QuadPart -= 116444736000000000UI64;
|
||||
#endif
|
||||
/*
|
||||
* ularge.QuadPart is now the number of 100-nanosecond intervals
|
||||
* since Jan 1 1970 00:00:00.
|
||||
*/
|
||||
#if defined(__MINGW32__)
|
||||
tv->tv_sec = (long)(ularge.QuadPart / 10000000ULL);
|
||||
tv->tv_usec = (long)((ularge.QuadPart % 10000000ULL) / 10ULL);
|
||||
#else
|
||||
tv->tv_sec = (long)(ularge.QuadPart / 10000000UI64);
|
||||
tv->tv_usec = (long)((ularge.QuadPart % 10000000UI64) / 10UI64);
|
||||
#endif
|
||||
}
|
||||
|
||||
int
|
||||
win_if_nametoindex(const char *ifname)
|
||||
{
|
||||
IP_ADAPTER_ADDRESSES *addresses, *addr;
|
||||
ULONG status, size;
|
||||
int index = 0;
|
||||
|
||||
if (!ifname) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
size = 0;
|
||||
status = GetAdaptersAddresses(AF_UNSPEC, 0, NULL, NULL, &size);
|
||||
if (status != ERROR_BUFFER_OVERFLOW) {
|
||||
return 0;
|
||||
}
|
||||
addresses = malloc(size);
|
||||
status = GetAdaptersAddresses(AF_UNSPEC, 0, NULL, addresses, &size);
|
||||
if (status == ERROR_SUCCESS) {
|
||||
for (addr = addresses; addr; addr = addr->Next) {
|
||||
if (addr->AdapterName && !strcmp(ifname, addr->AdapterName)) {
|
||||
index = addr->IfIndex;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
free(addresses);
|
||||
return index;
|
||||
}
|
||||
|
||||
#if WINVER < 0x0600
|
||||
/* These functions are written based on the code at
|
||||
* http://www.cs.wustl.edu/~schmidt/win32-cv-1.html
|
||||
* Therefore, for the rest of the file the following applies:
|
||||
*
|
||||
*
|
||||
* Copyright and Licensing Information for ACE(TM), TAO(TM), CIAO(TM),
|
||||
* DAnCE(TM), and CoSMIC(TM)
|
||||
*
|
||||
* [1]ACE(TM), [2]TAO(TM), [3]CIAO(TM), DAnCE(TM), and [4]CoSMIC(TM)
|
||||
* (henceforth referred to as "DOC software") are copyrighted by
|
||||
* [5]Douglas C. Schmidt and his [6]research group at [7]Washington
|
||||
* University, [8]University of California, Irvine, and [9]Vanderbilt
|
||||
* University, Copyright (c) 1993-2012, all rights reserved. Since DOC
|
||||
* software is open-source, freely available software, you are free to
|
||||
* use, modify, copy, and distribute--perpetually and irrevocably--the
|
||||
* DOC software source code and object code produced from the source, as
|
||||
* well as copy and distribute modified versions of this software. You
|
||||
* must, however, include this copyright statement along with any code
|
||||
* built using DOC software that you release. No copyright statement
|
||||
* needs to be provided if you just ship binary executables of your
|
||||
* software products.
|
||||
*
|
||||
* You can use DOC software in commercial and/or binary software releases
|
||||
* and are under no obligation to redistribute any of your source code
|
||||
* that is built using DOC software. Note, however, that you may not
|
||||
* misappropriate the DOC software code, such as copyrighting it yourself
|
||||
* or claiming authorship of the DOC software code, in a way that will
|
||||
* prevent DOC software from being distributed freely using an
|
||||
* open-source development model. You needn't inform anyone that you're
|
||||
* using DOC software in your software, though we encourage you to let
|
||||
* [10]us know so we can promote your project in the [11]DOC software
|
||||
* success stories.
|
||||
*
|
||||
* The [12]ACE, [13]TAO, [14]CIAO, [15]DAnCE, and [16]CoSMIC web sites
|
||||
* are maintained by the [17]DOC Group at the [18]Institute for Software
|
||||
* Integrated Systems (ISIS) and the [19]Center for Distributed Object
|
||||
* Computing of Washington University, St. Louis for the development of
|
||||
* open-source software as part of the open-source software community.
|
||||
* Submissions are provided by the submitter ``as is'' with no warranties
|
||||
* whatsoever, including any warranty of merchantability, noninfringement
|
||||
* of third party intellectual property, or fitness for any particular
|
||||
* purpose. In no event shall the submitter be liable for any direct,
|
||||
* indirect, special, exemplary, punitive, or consequential damages,
|
||||
* including without limitation, lost profits, even if advised of the
|
||||
* possibility of such damages. Likewise, DOC software is provided as is
|
||||
* with no warranties of any kind, including the warranties of design,
|
||||
* merchantability, and fitness for a particular purpose,
|
||||
* noninfringement, or arising from a course of dealing, usage or trade
|
||||
* practice. Washington University, UC Irvine, Vanderbilt University,
|
||||
* their employees, and students shall have no liability with respect to
|
||||
* the infringement of copyrights, trade secrets or any patents by DOC
|
||||
* software or any part thereof. Moreover, in no event will Washington
|
||||
* University, UC Irvine, or Vanderbilt University, their employees, or
|
||||
* students be liable for any lost revenue or profits or other special,
|
||||
* indirect and consequential damages.
|
||||
*
|
||||
* DOC software is provided with no support and without any obligation on
|
||||
* the part of Washington University, UC Irvine, Vanderbilt University,
|
||||
* their employees, or students to assist in its use, correction,
|
||||
* modification, or enhancement. A [20]number of companies around the
|
||||
* world provide commercial support for DOC software, however. DOC
|
||||
* software is Y2K-compliant, as long as the underlying OS platform is
|
||||
* Y2K-compliant. Likewise, DOC software is compliant with the new US
|
||||
* daylight savings rule passed by Congress as "The Energy Policy Act of
|
||||
* 2005," which established new daylight savings times (DST) rules for
|
||||
* the United States that expand DST as of March 2007. Since DOC software
|
||||
* obtains time/date and calendaring information from operating systems
|
||||
* users will not be affected by the new DST rules as long as they
|
||||
* upgrade their operating systems accordingly.
|
||||
*
|
||||
* The names ACE(TM), TAO(TM), CIAO(TM), DAnCE(TM), CoSMIC(TM),
|
||||
* Washington University, UC Irvine, and Vanderbilt University, may not
|
||||
* be used to endorse or promote products or services derived from this
|
||||
* source without express written permission from Washington University,
|
||||
* UC Irvine, or Vanderbilt University. This license grants no permission
|
||||
* to call products or services derived from this source ACE(TM),
|
||||
* TAO(TM), CIAO(TM), DAnCE(TM), or CoSMIC(TM), nor does it grant
|
||||
* permission for the name Washington University, UC Irvine, or
|
||||
* Vanderbilt University to appear in their names.
|
||||
*
|
||||
* If you have any suggestions, additions, comments, or questions, please
|
||||
* let [21]me know.
|
||||
*
|
||||
* [22]Douglas C. Schmidt
|
||||
*
|
||||
* References
|
||||
*
|
||||
* 1. http://www.cs.wustl.edu/~schmidt/ACE.html
|
||||
* 2. http://www.cs.wustl.edu/~schmidt/TAO.html
|
||||
* 3. http://www.dre.vanderbilt.edu/CIAO/
|
||||
* 4. http://www.dre.vanderbilt.edu/cosmic/
|
||||
* 5. http://www.dre.vanderbilt.edu/~schmidt/
|
||||
* 6. http://www.cs.wustl.edu/~schmidt/ACE-members.html
|
||||
* 7. http://www.wustl.edu/
|
||||
* 8. http://www.uci.edu/
|
||||
* 9. http://www.vanderbilt.edu/
|
||||
* 10. mailto:doc_group@cs.wustl.edu
|
||||
* 11. http://www.cs.wustl.edu/~schmidt/ACE-users.html
|
||||
* 12. http://www.cs.wustl.edu/~schmidt/ACE.html
|
||||
* 13. http://www.cs.wustl.edu/~schmidt/TAO.html
|
||||
* 14. http://www.dre.vanderbilt.edu/CIAO/
|
||||
* 15. http://www.dre.vanderbilt.edu/~schmidt/DOC_ROOT/DAnCE/
|
||||
* 16. http://www.dre.vanderbilt.edu/cosmic/
|
||||
* 17. http://www.dre.vanderbilt.edu/
|
||||
* 18. http://www.isis.vanderbilt.edu/
|
||||
* 19. http://www.cs.wustl.edu/~schmidt/doc-center.html
|
||||
* 20. http://www.cs.wustl.edu/~schmidt/commercial-support.html
|
||||
* 21. mailto:d.schmidt@vanderbilt.edu
|
||||
* 22. http://www.dre.vanderbilt.edu/~schmidt/
|
||||
* 23. http://www.cs.wustl.edu/ACE.html
|
||||
*/
|
||||
|
||||
void
|
||||
InitializeXPConditionVariable(userland_cond_t *cv)
|
||||
{
|
||||
cv->waiters_count = 0;
|
||||
InitializeCriticalSection(&(cv->waiters_count_lock));
|
||||
cv->events_[C_SIGNAL] = CreateEvent (NULL, FALSE, FALSE, NULL);
|
||||
cv->events_[C_BROADCAST] = CreateEvent (NULL, TRUE, FALSE, NULL);
|
||||
}
|
||||
|
||||
void
|
||||
DeleteXPConditionVariable(userland_cond_t *cv)
|
||||
{
|
||||
CloseHandle(cv->events_[C_BROADCAST]);
|
||||
CloseHandle(cv->events_[C_SIGNAL]);
|
||||
DeleteCriticalSection(&(cv->waiters_count_lock));
|
||||
}
|
||||
|
||||
int
|
||||
SleepXPConditionVariable(userland_cond_t *cv, userland_mutex_t *mtx)
|
||||
{
|
||||
int result, last_waiter;
|
||||
|
||||
EnterCriticalSection(&cv->waiters_count_lock);
|
||||
cv->waiters_count++;
|
||||
LeaveCriticalSection(&cv->waiters_count_lock);
|
||||
LeaveCriticalSection (mtx);
|
||||
result = WaitForMultipleObjects(2, cv->events_, FALSE, INFINITE);
|
||||
if (result==-1) {
|
||||
result = GetLastError();
|
||||
}
|
||||
EnterCriticalSection(&cv->waiters_count_lock);
|
||||
cv->waiters_count--;
|
||||
last_waiter = result == (C_SIGNAL + C_BROADCAST && (cv->waiters_count == 0));
|
||||
LeaveCriticalSection(&cv->waiters_count_lock);
|
||||
if (last_waiter)
|
||||
ResetEvent(cv->events_[C_BROADCAST]);
|
||||
EnterCriticalSection (mtx);
|
||||
return result;
|
||||
}
|
||||
|
||||
void
|
||||
WakeAllXPConditionVariable(userland_cond_t *cv)
|
||||
{
|
||||
int have_waiters;
|
||||
EnterCriticalSection(&cv->waiters_count_lock);
|
||||
have_waiters = cv->waiters_count > 0;
|
||||
LeaveCriticalSection(&cv->waiters_count_lock);
|
||||
if (have_waiters)
|
||||
SetEvent (cv->events_[C_BROADCAST]);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
9039
TMessagesProj/jni/third_party/usrsctplib/netinet/sctp_usrreq.c
vendored
Executable file
9039
TMessagesProj/jni/third_party/usrsctplib/netinet/sctp_usrreq.c
vendored
Executable file
File diff suppressed because it is too large
Load diff
443
TMessagesProj/jni/third_party/usrsctplib/netinet/sctp_var.h
vendored
Executable file
443
TMessagesProj/jni/third_party/usrsctplib/netinet/sctp_var.h
vendored
Executable file
|
|
@ -0,0 +1,443 @@
|
|||
/*-
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*
|
||||
* Copyright (c) 2001-2008, 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.
|
||||
*/
|
||||
|
||||
#if defined(__FreeBSD__) && !defined(__Userspace__)
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD: head/sys/netinet/sctp_var.h 365071 2020-09-01 21:19:14Z mjg $");
|
||||
#endif
|
||||
|
||||
#ifndef _NETINET_SCTP_VAR_H_
|
||||
#define _NETINET_SCTP_VAR_H_
|
||||
|
||||
#include <netinet/sctp_uio.h>
|
||||
|
||||
#if defined(_KERNEL) || defined(__Userspace__)
|
||||
|
||||
#if !defined(__Userspace__)
|
||||
extern struct pr_usrreqs sctp_usrreqs;
|
||||
#endif
|
||||
|
||||
#define sctp_feature_on(inp, feature) (inp->sctp_features |= feature)
|
||||
#define sctp_feature_off(inp, feature) (inp->sctp_features &= ~feature)
|
||||
#define sctp_is_feature_on(inp, feature) ((inp->sctp_features & feature) == feature)
|
||||
#define sctp_is_feature_off(inp, feature) ((inp->sctp_features & feature) == 0)
|
||||
|
||||
#define sctp_stcb_feature_on(inp, stcb, feature) {\
|
||||
if (stcb) { \
|
||||
stcb->asoc.sctp_features |= feature; \
|
||||
} else if (inp) { \
|
||||
inp->sctp_features |= feature; \
|
||||
} \
|
||||
}
|
||||
#define sctp_stcb_feature_off(inp, stcb, feature) {\
|
||||
if (stcb) { \
|
||||
stcb->asoc.sctp_features &= ~feature; \
|
||||
} else if (inp) { \
|
||||
inp->sctp_features &= ~feature; \
|
||||
} \
|
||||
}
|
||||
#define sctp_stcb_is_feature_on(inp, stcb, feature) \
|
||||
(((stcb != NULL) && \
|
||||
((stcb->asoc.sctp_features & feature) == feature)) || \
|
||||
((stcb == NULL) && (inp != NULL) && \
|
||||
((inp->sctp_features & feature) == feature)))
|
||||
#define sctp_stcb_is_feature_off(inp, stcb, feature) \
|
||||
(((stcb != NULL) && \
|
||||
((stcb->asoc.sctp_features & feature) == 0)) || \
|
||||
((stcb == NULL) && (inp != NULL) && \
|
||||
((inp->sctp_features & feature) == 0)) || \
|
||||
((stcb == NULL) && (inp == NULL)))
|
||||
|
||||
/* managing mobility_feature in inpcb (by micchie) */
|
||||
#define sctp_mobility_feature_on(inp, feature) (inp->sctp_mobility_features |= feature)
|
||||
#define sctp_mobility_feature_off(inp, feature) (inp->sctp_mobility_features &= ~feature)
|
||||
#define sctp_is_mobility_feature_on(inp, feature) (inp->sctp_mobility_features & feature)
|
||||
#define sctp_is_mobility_feature_off(inp, feature) ((inp->sctp_mobility_features & feature) == 0)
|
||||
|
||||
#define sctp_maxspace(sb) (max((sb)->sb_hiwat,SCTP_MINIMAL_RWND))
|
||||
|
||||
#define sctp_sbspace(asoc, sb) ((long) ((sctp_maxspace(sb) > (asoc)->sb_cc) ? (sctp_maxspace(sb) - (asoc)->sb_cc) : 0))
|
||||
|
||||
#define sctp_sbspace_failedmsgs(sb) ((long) ((sctp_maxspace(sb) > (sb)->sb_cc) ? (sctp_maxspace(sb) - (sb)->sb_cc) : 0))
|
||||
|
||||
#define sctp_sbspace_sub(a,b) (((a) > (b)) ? ((a) - (b)) : 0)
|
||||
|
||||
/*
|
||||
* I tried to cache the readq entries at one point. But the reality
|
||||
* is that it did not add any performance since this meant we had to
|
||||
* lock the STCB on read. And at that point once you have to do an
|
||||
* extra lock, it really does not matter if the lock is in the ZONE
|
||||
* stuff or in our code. Note that this same problem would occur with
|
||||
* an mbuf cache as well so it is not really worth doing, at least
|
||||
* right now :-D
|
||||
*/
|
||||
#ifdef INVARIANTS
|
||||
#define sctp_free_a_readq(_stcb, _readq) { \
|
||||
if ((_readq)->on_strm_q) \
|
||||
panic("On strm q stcb:%p readq:%p", (_stcb), (_readq)); \
|
||||
SCTP_ZONE_FREE(SCTP_BASE_INFO(ipi_zone_readq), (_readq)); \
|
||||
SCTP_DECR_READQ_COUNT(); \
|
||||
}
|
||||
#else
|
||||
#define sctp_free_a_readq(_stcb, _readq) { \
|
||||
SCTP_ZONE_FREE(SCTP_BASE_INFO(ipi_zone_readq), (_readq)); \
|
||||
SCTP_DECR_READQ_COUNT(); \
|
||||
}
|
||||
#endif
|
||||
|
||||
#define sctp_alloc_a_readq(_stcb, _readq) { \
|
||||
(_readq) = SCTP_ZONE_GET(SCTP_BASE_INFO(ipi_zone_readq), struct sctp_queued_to_read); \
|
||||
if ((_readq)) { \
|
||||
SCTP_INCR_READQ_COUNT(); \
|
||||
} \
|
||||
}
|
||||
|
||||
#define sctp_free_a_strmoq(_stcb, _strmoq, _so_locked) { \
|
||||
if ((_strmoq)->holds_key_ref) { \
|
||||
sctp_auth_key_release(stcb, sp->auth_keyid, _so_locked); \
|
||||
(_strmoq)->holds_key_ref = 0; \
|
||||
} \
|
||||
SCTP_ZONE_FREE(SCTP_BASE_INFO(ipi_zone_strmoq), (_strmoq)); \
|
||||
SCTP_DECR_STRMOQ_COUNT(); \
|
||||
}
|
||||
|
||||
#define sctp_alloc_a_strmoq(_stcb, _strmoq) { \
|
||||
(_strmoq) = SCTP_ZONE_GET(SCTP_BASE_INFO(ipi_zone_strmoq), struct sctp_stream_queue_pending); \
|
||||
if ((_strmoq)) { \
|
||||
memset(_strmoq, 0, sizeof(struct sctp_stream_queue_pending)); \
|
||||
SCTP_INCR_STRMOQ_COUNT(); \
|
||||
(_strmoq)->holds_key_ref = 0; \
|
||||
} \
|
||||
}
|
||||
|
||||
#define sctp_free_a_chunk(_stcb, _chk, _so_locked) { \
|
||||
if ((_chk)->holds_key_ref) {\
|
||||
sctp_auth_key_release((_stcb), (_chk)->auth_keyid, _so_locked); \
|
||||
(_chk)->holds_key_ref = 0; \
|
||||
} \
|
||||
if (_stcb) { \
|
||||
SCTP_TCB_LOCK_ASSERT((_stcb)); \
|
||||
if ((_chk)->whoTo) { \
|
||||
sctp_free_remote_addr((_chk)->whoTo); \
|
||||
(_chk)->whoTo = NULL; \
|
||||
} \
|
||||
if (((_stcb)->asoc.free_chunk_cnt > SCTP_BASE_SYSCTL(sctp_asoc_free_resc_limit)) || \
|
||||
(SCTP_BASE_INFO(ipi_free_chunks) > SCTP_BASE_SYSCTL(sctp_system_free_resc_limit))) { \
|
||||
SCTP_ZONE_FREE(SCTP_BASE_INFO(ipi_zone_chunk), (_chk)); \
|
||||
SCTP_DECR_CHK_COUNT(); \
|
||||
} else { \
|
||||
TAILQ_INSERT_TAIL(&(_stcb)->asoc.free_chunks, (_chk), sctp_next); \
|
||||
(_stcb)->asoc.free_chunk_cnt++; \
|
||||
atomic_add_int(&SCTP_BASE_INFO(ipi_free_chunks), 1); \
|
||||
} \
|
||||
} else { \
|
||||
SCTP_ZONE_FREE(SCTP_BASE_INFO(ipi_zone_chunk), (_chk)); \
|
||||
SCTP_DECR_CHK_COUNT(); \
|
||||
} \
|
||||
}
|
||||
|
||||
#define sctp_alloc_a_chunk(_stcb, _chk) { \
|
||||
if (TAILQ_EMPTY(&(_stcb)->asoc.free_chunks)) { \
|
||||
(_chk) = SCTP_ZONE_GET(SCTP_BASE_INFO(ipi_zone_chunk), struct sctp_tmit_chunk); \
|
||||
if ((_chk)) { \
|
||||
SCTP_INCR_CHK_COUNT(); \
|
||||
(_chk)->whoTo = NULL; \
|
||||
(_chk)->holds_key_ref = 0; \
|
||||
} \
|
||||
} else { \
|
||||
(_chk) = TAILQ_FIRST(&(_stcb)->asoc.free_chunks); \
|
||||
TAILQ_REMOVE(&(_stcb)->asoc.free_chunks, (_chk), sctp_next); \
|
||||
atomic_subtract_int(&SCTP_BASE_INFO(ipi_free_chunks), 1); \
|
||||
(_chk)->holds_key_ref = 0; \
|
||||
SCTP_STAT_INCR(sctps_cached_chk); \
|
||||
(_stcb)->asoc.free_chunk_cnt--; \
|
||||
} \
|
||||
}
|
||||
|
||||
#if defined(__FreeBSD__) && !defined(__Userspace__)
|
||||
#define sctp_free_remote_addr(__net) { \
|
||||
if ((__net)) { \
|
||||
if (SCTP_DECREMENT_AND_CHECK_REFCOUNT(&(__net)->ref_count)) { \
|
||||
RO_NHFREE(&(__net)->ro); \
|
||||
if ((__net)->src_addr_selected) { \
|
||||
sctp_free_ifa((__net)->ro._s_addr); \
|
||||
(__net)->ro._s_addr = NULL; \
|
||||
} \
|
||||
(__net)->src_addr_selected = 0; \
|
||||
(__net)->dest_state &= ~SCTP_ADDR_REACHABLE; \
|
||||
SCTP_ZONE_FREE(SCTP_BASE_INFO(ipi_zone_net), (__net)); \
|
||||
SCTP_DECR_RADDR_COUNT(); \
|
||||
} \
|
||||
} \
|
||||
}
|
||||
|
||||
#define sctp_sbfree(ctl, stcb, sb, m) { \
|
||||
SCTP_SAVE_ATOMIC_DECREMENT(&(sb)->sb_cc, SCTP_BUF_LEN((m))); \
|
||||
SCTP_SAVE_ATOMIC_DECREMENT(&(sb)->sb_mbcnt, MSIZE); \
|
||||
if (((ctl)->do_not_ref_stcb == 0) && stcb) {\
|
||||
SCTP_SAVE_ATOMIC_DECREMENT(&(stcb)->asoc.sb_cc, SCTP_BUF_LEN((m))); \
|
||||
SCTP_SAVE_ATOMIC_DECREMENT(&(stcb)->asoc.my_rwnd_control_len, MSIZE); \
|
||||
} \
|
||||
if (SCTP_BUF_TYPE(m) != MT_DATA && SCTP_BUF_TYPE(m) != MT_HEADER && \
|
||||
SCTP_BUF_TYPE(m) != MT_OOBDATA) \
|
||||
atomic_subtract_int(&(sb)->sb_ctl,SCTP_BUF_LEN((m))); \
|
||||
}
|
||||
|
||||
#define sctp_sballoc(stcb, sb, m) { \
|
||||
atomic_add_int(&(sb)->sb_cc,SCTP_BUF_LEN((m))); \
|
||||
atomic_add_int(&(sb)->sb_mbcnt, MSIZE); \
|
||||
if (stcb) { \
|
||||
atomic_add_int(&(stcb)->asoc.sb_cc, SCTP_BUF_LEN((m))); \
|
||||
atomic_add_int(&(stcb)->asoc.my_rwnd_control_len, MSIZE); \
|
||||
} \
|
||||
if (SCTP_BUF_TYPE(m) != MT_DATA && SCTP_BUF_TYPE(m) != MT_HEADER && \
|
||||
SCTP_BUF_TYPE(m) != MT_OOBDATA) \
|
||||
atomic_add_int(&(sb)->sb_ctl,SCTP_BUF_LEN((m))); \
|
||||
}
|
||||
#else /* FreeBSD Version <= 500000 or non-FreeBSD */
|
||||
#define sctp_free_remote_addr(__net) { \
|
||||
if ((__net)) { \
|
||||
if (SCTP_DECREMENT_AND_CHECK_REFCOUNT(&(__net)->ref_count)) { \
|
||||
if ((__net)->ro.ro_rt) { \
|
||||
RTFREE((__net)->ro.ro_rt); \
|
||||
(__net)->ro.ro_rt = NULL; \
|
||||
} \
|
||||
if ((__net)->src_addr_selected) { \
|
||||
sctp_free_ifa((__net)->ro._s_addr); \
|
||||
(__net)->ro._s_addr = NULL; \
|
||||
} \
|
||||
(__net)->src_addr_selected = 0; \
|
||||
(__net)->dest_state &=~SCTP_ADDR_REACHABLE; \
|
||||
SCTP_ZONE_FREE(SCTP_BASE_INFO(ipi_zone_net), (__net)); \
|
||||
SCTP_DECR_RADDR_COUNT(); \
|
||||
} \
|
||||
} \
|
||||
}
|
||||
|
||||
#define sctp_sbfree(ctl, stcb, sb, m) { \
|
||||
SCTP_SAVE_ATOMIC_DECREMENT(&(sb)->sb_cc, SCTP_BUF_LEN((m))); \
|
||||
SCTP_SAVE_ATOMIC_DECREMENT(&(sb)->sb_mbcnt, MSIZE); \
|
||||
if (((ctl)->do_not_ref_stcb == 0) && stcb) { \
|
||||
SCTP_SAVE_ATOMIC_DECREMENT(&(stcb)->asoc.sb_cc, SCTP_BUF_LEN((m))); \
|
||||
SCTP_SAVE_ATOMIC_DECREMENT(&(stcb)->asoc.my_rwnd_control_len, MSIZE); \
|
||||
} \
|
||||
}
|
||||
|
||||
#define sctp_sballoc(stcb, sb, m) { \
|
||||
atomic_add_int(&(sb)->sb_cc, SCTP_BUF_LEN((m))); \
|
||||
atomic_add_int(&(sb)->sb_mbcnt, MSIZE); \
|
||||
if (stcb) { \
|
||||
atomic_add_int(&(stcb)->asoc.sb_cc, SCTP_BUF_LEN((m))); \
|
||||
atomic_add_int(&(stcb)->asoc.my_rwnd_control_len, MSIZE); \
|
||||
} \
|
||||
}
|
||||
#endif
|
||||
|
||||
#define sctp_ucount_incr(val) { \
|
||||
val++; \
|
||||
}
|
||||
|
||||
#define sctp_ucount_decr(val) { \
|
||||
if (val > 0) { \
|
||||
val--; \
|
||||
} else { \
|
||||
val = 0; \
|
||||
} \
|
||||
}
|
||||
|
||||
#define sctp_mbuf_crush(data) do { \
|
||||
struct mbuf *_m; \
|
||||
_m = (data); \
|
||||
while (_m && (SCTP_BUF_LEN(_m) == 0)) { \
|
||||
(data) = SCTP_BUF_NEXT(_m); \
|
||||
SCTP_BUF_NEXT(_m) = NULL; \
|
||||
sctp_m_free(_m); \
|
||||
_m = (data); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define sctp_flight_size_decrease(tp1) do { \
|
||||
if (tp1->whoTo->flight_size >= tp1->book_size) \
|
||||
tp1->whoTo->flight_size -= tp1->book_size; \
|
||||
else \
|
||||
tp1->whoTo->flight_size = 0; \
|
||||
} while (0)
|
||||
|
||||
#define sctp_flight_size_increase(tp1) do { \
|
||||
(tp1)->whoTo->flight_size += (tp1)->book_size; \
|
||||
} while (0)
|
||||
|
||||
#ifdef SCTP_FS_SPEC_LOG
|
||||
#define sctp_total_flight_decrease(stcb, tp1) do { \
|
||||
if (stcb->asoc.fs_index > SCTP_FS_SPEC_LOG_SIZE) \
|
||||
stcb->asoc.fs_index = 0;\
|
||||
stcb->asoc.fslog[stcb->asoc.fs_index].total_flight = stcb->asoc.total_flight; \
|
||||
stcb->asoc.fslog[stcb->asoc.fs_index].tsn = tp1->rec.data.tsn; \
|
||||
stcb->asoc.fslog[stcb->asoc.fs_index].book = tp1->book_size; \
|
||||
stcb->asoc.fslog[stcb->asoc.fs_index].sent = tp1->sent; \
|
||||
stcb->asoc.fslog[stcb->asoc.fs_index].incr = 0; \
|
||||
stcb->asoc.fslog[stcb->asoc.fs_index].decr = 1; \
|
||||
stcb->asoc.fs_index++; \
|
||||
tp1->window_probe = 0; \
|
||||
if (stcb->asoc.total_flight >= tp1->book_size) { \
|
||||
stcb->asoc.total_flight -= tp1->book_size; \
|
||||
if (stcb->asoc.total_flight_count > 0) \
|
||||
stcb->asoc.total_flight_count--; \
|
||||
} else { \
|
||||
stcb->asoc.total_flight = 0; \
|
||||
stcb->asoc.total_flight_count = 0; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define sctp_total_flight_increase(stcb, tp1) do { \
|
||||
if (stcb->asoc.fs_index > SCTP_FS_SPEC_LOG_SIZE) \
|
||||
stcb->asoc.fs_index = 0;\
|
||||
stcb->asoc.fslog[stcb->asoc.fs_index].total_flight = stcb->asoc.total_flight; \
|
||||
stcb->asoc.fslog[stcb->asoc.fs_index].tsn = tp1->rec.data.tsn; \
|
||||
stcb->asoc.fslog[stcb->asoc.fs_index].book = tp1->book_size; \
|
||||
stcb->asoc.fslog[stcb->asoc.fs_index].sent = tp1->sent; \
|
||||
stcb->asoc.fslog[stcb->asoc.fs_index].incr = 1; \
|
||||
stcb->asoc.fslog[stcb->asoc.fs_index].decr = 0; \
|
||||
stcb->asoc.fs_index++; \
|
||||
(stcb)->asoc.total_flight_count++; \
|
||||
(stcb)->asoc.total_flight += (tp1)->book_size; \
|
||||
} while (0)
|
||||
|
||||
#else
|
||||
|
||||
#define sctp_total_flight_decrease(stcb, tp1) do { \
|
||||
tp1->window_probe = 0; \
|
||||
if (stcb->asoc.total_flight >= tp1->book_size) { \
|
||||
stcb->asoc.total_flight -= tp1->book_size; \
|
||||
if (stcb->asoc.total_flight_count > 0) \
|
||||
stcb->asoc.total_flight_count--; \
|
||||
} else { \
|
||||
stcb->asoc.total_flight = 0; \
|
||||
stcb->asoc.total_flight_count = 0; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define sctp_total_flight_increase(stcb, tp1) do { \
|
||||
(stcb)->asoc.total_flight_count++; \
|
||||
(stcb)->asoc.total_flight += (tp1)->book_size; \
|
||||
} while (0)
|
||||
|
||||
#endif
|
||||
|
||||
#define SCTP_PF_ENABLED(_net) (_net->pf_threshold < _net->failure_threshold)
|
||||
#define SCTP_NET_IS_PF(_net) (_net->pf_threshold < _net->error_count)
|
||||
|
||||
struct sctp_nets;
|
||||
struct sctp_inpcb;
|
||||
struct sctp_tcb;
|
||||
struct sctphdr;
|
||||
|
||||
#if defined(__FreeBSD__) || defined(_WIN32) || defined(__Userspace__)
|
||||
void sctp_close(struct socket *so);
|
||||
#else
|
||||
int sctp_detach(struct socket *so);
|
||||
#endif
|
||||
int sctp_disconnect(struct socket *so);
|
||||
#if !defined(__Userspace__)
|
||||
#if defined(__APPLE__) && !defined(APPLE_LEOPARD) && !defined(APPLE_SNOWLEOPARD) && !defined(APPLE_LION) && !defined(APPLE_MOUNTAINLION) && !defined(APPLE_ELCAPITAN)
|
||||
void sctp_ctlinput(int, struct sockaddr *, void *, struct ifnet * SCTP_UNUSED);
|
||||
#else
|
||||
void sctp_ctlinput(int, struct sockaddr *, void *);
|
||||
#endif
|
||||
int sctp_ctloutput(struct socket *, struct sockopt *);
|
||||
#ifdef INET
|
||||
void sctp_input_with_port(struct mbuf *, int, uint16_t);
|
||||
#if defined(__FreeBSD__) && !defined(__Userspace__)
|
||||
int sctp_input(struct mbuf **, int *, int);
|
||||
#else
|
||||
void sctp_input(struct mbuf *, int);
|
||||
#endif
|
||||
#endif
|
||||
void sctp_pathmtu_adjustment(struct sctp_tcb *, uint16_t);
|
||||
#else
|
||||
#if defined(__Userspace__)
|
||||
void sctp_pathmtu_adjustment(struct sctp_tcb *, uint16_t);
|
||||
#else
|
||||
void sctp_input(struct mbuf *,...);
|
||||
#endif
|
||||
void *sctp_ctlinput(int, struct sockaddr *, void *);
|
||||
int sctp_ctloutput(int, struct socket *, int, int, struct mbuf **);
|
||||
#endif
|
||||
void sctp_drain(void);
|
||||
#if defined(__Userspace__)
|
||||
void sctp_init(uint16_t,
|
||||
int (*)(void *addr, void *buffer, size_t length, uint8_t tos, uint8_t set_df),
|
||||
void (*)(const char *, ...), int start_threads);
|
||||
#elif defined(__APPLE__) && (!defined(APPLE_LEOPARD) && !defined(APPLE_SNOWLEOPARD) &&!defined(APPLE_LION) && !defined(APPLE_MOUNTAINLION))
|
||||
void sctp_init(struct protosw *pp, struct domain *dp);
|
||||
#else
|
||||
void sctp_init(void);
|
||||
void sctp_notify(struct sctp_inpcb *, struct sctp_tcb *, struct sctp_nets *,
|
||||
uint8_t, uint8_t, uint16_t, uint32_t);
|
||||
#endif
|
||||
#if !defined(__FreeBSD__) && !defined(__Userspace__)
|
||||
void sctp_finish(void);
|
||||
#endif
|
||||
#if defined(__FreeBSD__) || defined(_WIN32) || defined(__Userspace__)
|
||||
int sctp_flush(struct socket *, int);
|
||||
#endif
|
||||
int sctp_shutdown(struct socket *);
|
||||
int sctp_bindx(struct socket *, int, struct sockaddr_storage *,
|
||||
int, int, struct proc *);
|
||||
/* can't use sctp_assoc_t here */
|
||||
int sctp_peeloff(struct socket *, struct socket *, int, caddr_t, int *);
|
||||
#if !defined(__Userspace__)
|
||||
int sctp_ingetaddr(struct socket *, struct sockaddr **);
|
||||
#else
|
||||
int sctp_ingetaddr(struct socket *, struct mbuf *);
|
||||
#endif
|
||||
#if !defined(__Userspace__)
|
||||
int sctp_peeraddr(struct socket *, struct sockaddr **);
|
||||
#else
|
||||
int sctp_peeraddr(struct socket *, struct mbuf *);
|
||||
#endif
|
||||
#if defined(__FreeBSD__) && !defined(__Userspace__)
|
||||
int sctp_listen(struct socket *, int, struct thread *);
|
||||
#elif defined(_WIN32) && !defined(__Userspace__)
|
||||
int sctp_listen(struct socket *, int, PKTHREAD);
|
||||
#elif defined(__Userspace__)
|
||||
int sctp_listen(struct socket *, int, struct proc *);
|
||||
#else
|
||||
int sctp_listen(struct socket *, struct proc *);
|
||||
#endif
|
||||
int sctp_accept(struct socket *, struct sockaddr **);
|
||||
|
||||
#endif /* _KERNEL */
|
||||
|
||||
#endif /* !_NETINET_SCTP_VAR_H_ */
|
||||
8710
TMessagesProj/jni/third_party/usrsctplib/netinet/sctputil.c
vendored
Executable file
8710
TMessagesProj/jni/third_party/usrsctplib/netinet/sctputil.c
vendored
Executable file
File diff suppressed because it is too large
Load diff
417
TMessagesProj/jni/third_party/usrsctplib/netinet/sctputil.h
vendored
Executable file
417
TMessagesProj/jni/third_party/usrsctplib/netinet/sctputil.h
vendored
Executable file
|
|
@ -0,0 +1,417 @@
|
|||
/*-
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#if defined(__FreeBSD__) && !defined(__Userspace__)
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
#endif
|
||||
|
||||
#ifndef _NETINET_SCTP_UTIL_H_
|
||||
#define _NETINET_SCTP_UTIL_H_
|
||||
|
||||
#if defined(_KERNEL) || defined(__Userspace__)
|
||||
|
||||
#define SCTP_READ_LOCK_HELD 1
|
||||
#define SCTP_READ_LOCK_NOT_HELD 0
|
||||
|
||||
#ifdef SCTP_ASOCLOG_OF_TSNS
|
||||
void sctp_print_out_track_log(struct sctp_tcb *stcb);
|
||||
#endif
|
||||
|
||||
#ifdef SCTP_MBUF_LOGGING
|
||||
struct mbuf *sctp_m_free(struct mbuf *m);
|
||||
void sctp_m_freem(struct mbuf *m);
|
||||
#else
|
||||
#define sctp_m_free m_free
|
||||
#define sctp_m_freem m_freem
|
||||
#endif
|
||||
|
||||
#if defined(SCTP_LOCAL_TRACE_BUF)
|
||||
void
|
||||
sctp_log_trace(uint32_t fr, const char *str SCTP_UNUSED, uint32_t a, uint32_t b, uint32_t c, uint32_t d, uint32_t e, uint32_t f);
|
||||
#endif
|
||||
|
||||
#define sctp_get_associd(stcb) ((sctp_assoc_t)stcb->asoc.assoc_id)
|
||||
|
||||
/*
|
||||
* Function prototypes
|
||||
*/
|
||||
int32_t
|
||||
sctp_map_assoc_state(int);
|
||||
|
||||
uint32_t
|
||||
sctp_get_ifa_hash_val(struct sockaddr *addr);
|
||||
|
||||
struct sctp_ifa *
|
||||
sctp_find_ifa_in_ep(struct sctp_inpcb *inp, struct sockaddr *addr, int hold_lock);
|
||||
|
||||
struct sctp_ifa *
|
||||
sctp_find_ifa_by_addr(struct sockaddr *addr, uint32_t vrf_id, int holds_lock);
|
||||
|
||||
uint32_t sctp_select_initial_TSN(struct sctp_pcb *);
|
||||
|
||||
uint32_t sctp_select_a_tag(struct sctp_inpcb *, uint16_t lport, uint16_t rport, int);
|
||||
|
||||
int sctp_init_asoc(struct sctp_inpcb *, struct sctp_tcb *, uint32_t, uint32_t, uint32_t, uint16_t);
|
||||
|
||||
void sctp_fill_random_store(struct sctp_pcb *);
|
||||
|
||||
void
|
||||
sctp_notify_stream_reset_add(struct sctp_tcb *stcb, uint16_t numberin,
|
||||
uint16_t numberout, int flag);
|
||||
void
|
||||
sctp_notify_stream_reset_tsn(struct sctp_tcb *stcb, uint32_t sending_tsn, uint32_t recv_tsn, int flag);
|
||||
|
||||
/*
|
||||
* NOTE: sctp_timer_start() will increment the reference count of any relevant
|
||||
* structure the timer is referencing, in order to prevent a race condition
|
||||
* between the timer executing and the structure being freed.
|
||||
*
|
||||
* When the timer fires or sctp_timer_stop() is called, these references are
|
||||
* removed.
|
||||
*/
|
||||
void
|
||||
sctp_timer_start(int, struct sctp_inpcb *, struct sctp_tcb *,
|
||||
struct sctp_nets *);
|
||||
|
||||
void
|
||||
sctp_timer_stop(int, struct sctp_inpcb *, struct sctp_tcb *,
|
||||
struct sctp_nets *, uint32_t);
|
||||
|
||||
int
|
||||
sctp_dynamic_set_primary(struct sockaddr *sa, uint32_t vrf_id);
|
||||
|
||||
void
|
||||
sctp_mtu_size_reset(struct sctp_inpcb *, struct sctp_association *, uint32_t);
|
||||
|
||||
void
|
||||
sctp_wakeup_the_read_socket(struct sctp_inpcb *inp, struct sctp_tcb *stcb,
|
||||
int so_locked
|
||||
#if !(defined(__APPLE__) && !defined(__Userspace__))
|
||||
SCTP_UNUSED
|
||||
#endif
|
||||
);
|
||||
|
||||
#if defined(__Userspace__)
|
||||
void sctp_invoke_recv_callback(struct sctp_inpcb *,
|
||||
struct sctp_tcb *,
|
||||
struct sctp_queued_to_read *,
|
||||
int);
|
||||
|
||||
#endif
|
||||
void
|
||||
sctp_add_to_readq(struct sctp_inpcb *inp,
|
||||
struct sctp_tcb *stcb,
|
||||
struct sctp_queued_to_read *control,
|
||||
struct sockbuf *sb,
|
||||
int end,
|
||||
int inpread_locked,
|
||||
int so_locked);
|
||||
|
||||
void sctp_iterator_worker(void);
|
||||
|
||||
uint32_t sctp_get_prev_mtu(uint32_t);
|
||||
uint32_t sctp_get_next_mtu(uint32_t);
|
||||
|
||||
void
|
||||
sctp_timeout_handler(void *);
|
||||
|
||||
int
|
||||
sctp_calculate_rto(struct sctp_tcb *, struct sctp_association *,
|
||||
struct sctp_nets *, struct timeval *, int);
|
||||
|
||||
uint32_t sctp_calculate_len(struct mbuf *);
|
||||
|
||||
caddr_t sctp_m_getptr(struct mbuf *, int, int, uint8_t *);
|
||||
|
||||
struct sctp_paramhdr *
|
||||
sctp_get_next_param(struct mbuf *, int,
|
||||
struct sctp_paramhdr *, int);
|
||||
|
||||
struct mbuf *
|
||||
sctp_add_pad_tombuf(struct mbuf *, int);
|
||||
|
||||
struct mbuf *
|
||||
sctp_pad_lastmbuf(struct mbuf *, int, struct mbuf *);
|
||||
|
||||
void sctp_ulp_notify(uint32_t, struct sctp_tcb *, uint32_t, void *, int);
|
||||
|
||||
void
|
||||
sctp_pull_off_control_to_new_inp(struct sctp_inpcb *old_inp,
|
||||
struct sctp_inpcb *new_inp,
|
||||
struct sctp_tcb *stcb, int waitflags);
|
||||
|
||||
void sctp_stop_timers_for_shutdown(struct sctp_tcb *);
|
||||
|
||||
/* Stop all timers for association and remote addresses. */
|
||||
void sctp_stop_association_timers(struct sctp_tcb *, bool);
|
||||
|
||||
void sctp_report_all_outbound(struct sctp_tcb *, uint16_t, int);
|
||||
|
||||
int sctp_expand_mapping_array(struct sctp_association *, uint32_t);
|
||||
|
||||
void sctp_abort_notification(struct sctp_tcb *, bool, bool, uint16_t,
|
||||
struct sctp_abort_chunk *, int);
|
||||
|
||||
/* We abort responding to an IP packet for some reason */
|
||||
void
|
||||
sctp_abort_association(struct sctp_inpcb *, struct sctp_tcb *, struct mbuf *,
|
||||
int, struct sockaddr *, struct sockaddr *,
|
||||
struct sctphdr *, struct mbuf *,
|
||||
#if defined(__FreeBSD__) && !defined(__Userspace__)
|
||||
uint8_t, uint32_t,
|
||||
#endif
|
||||
uint32_t, uint16_t);
|
||||
|
||||
/* We choose to abort via user input */
|
||||
void
|
||||
sctp_abort_an_association(struct sctp_inpcb *, struct sctp_tcb *,
|
||||
struct mbuf *, bool, int);
|
||||
|
||||
void sctp_handle_ootb(struct mbuf *, int, int,
|
||||
struct sockaddr *, struct sockaddr *,
|
||||
struct sctphdr *, struct sctp_inpcb *,
|
||||
struct mbuf *,
|
||||
#if defined(__FreeBSD__) && !defined(__Userspace__)
|
||||
uint8_t, uint32_t, uint16_t,
|
||||
#endif
|
||||
uint32_t, uint16_t);
|
||||
|
||||
int sctp_connectx_helper_add(struct sctp_tcb *stcb, struct sockaddr *addr,
|
||||
int totaddr, int *error);
|
||||
|
||||
int
|
||||
sctp_connectx_helper_find(struct sctp_inpcb *, struct sockaddr *,
|
||||
unsigned int, unsigned int *, unsigned int *, unsigned int);
|
||||
|
||||
int sctp_is_there_an_abort_here(struct mbuf *, int, uint32_t *);
|
||||
#ifdef INET6
|
||||
uint32_t sctp_is_same_scope(struct sockaddr_in6 *, struct sockaddr_in6 *);
|
||||
|
||||
#if defined(SCTP_EMBEDDED_V6_SCOPE)
|
||||
struct sockaddr_in6 *
|
||||
sctp_recover_scope(struct sockaddr_in6 *, struct sockaddr_in6 *);
|
||||
|
||||
#ifdef SCTP_KAME
|
||||
#define sctp_recover_scope_mac(addr, store) do { \
|
||||
if ((addr->sin6_family == AF_INET6) && \
|
||||
(IN6_IS_SCOPE_LINKLOCAL(&addr->sin6_addr))) { \
|
||||
*store = *addr; \
|
||||
if (addr->sin6_scope_id == 0) { \
|
||||
if (!sa6_recoverscope(store)) { \
|
||||
addr = store; \
|
||||
} \
|
||||
} else { \
|
||||
in6_clearscope(&addr->sin6_addr); \
|
||||
addr = store; \
|
||||
} \
|
||||
} \
|
||||
} while (0)
|
||||
#else
|
||||
#define sctp_recover_scope_mac(addr, store) do { \
|
||||
if ((addr->sin6_family == AF_INET6) && \
|
||||
(IN6_IS_SCOPE_LINKLOCAL(&addr->sin6_addr))) { \
|
||||
*store = *addr; \
|
||||
if (addr->sin6_scope_id == 0) { \
|
||||
if (!in6_recoverscope(store, &store->sin6_addr, \
|
||||
NULL)) { \
|
||||
addr = store; \
|
||||
} \
|
||||
} else { \
|
||||
in6_clearscope(&addr->sin6_addr); \
|
||||
addr = store; \
|
||||
} \
|
||||
} \
|
||||
} while (0)
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
int sctp_cmpaddr(struct sockaddr *, struct sockaddr *);
|
||||
|
||||
void sctp_print_address(struct sockaddr *);
|
||||
|
||||
int
|
||||
sctp_release_pr_sctp_chunk(struct sctp_tcb *, struct sctp_tmit_chunk *,
|
||||
uint8_t, int);
|
||||
|
||||
struct mbuf *sctp_generate_cause(uint16_t, char *);
|
||||
struct mbuf *sctp_generate_no_user_data_cause(uint32_t);
|
||||
|
||||
void sctp_bindx_add_address(struct socket *so, struct sctp_inpcb *inp,
|
||||
struct sockaddr *sa, uint32_t vrf_id, int *error,
|
||||
void *p);
|
||||
void sctp_bindx_delete_address(struct sctp_inpcb *inp, struct sockaddr *sa,
|
||||
uint32_t vrf_id, int *error);
|
||||
|
||||
int sctp_local_addr_count(struct sctp_tcb *stcb);
|
||||
|
||||
#ifdef SCTP_MBCNT_LOGGING
|
||||
void
|
||||
sctp_free_bufspace(struct sctp_tcb *, struct sctp_association *,
|
||||
struct sctp_tmit_chunk *, int);
|
||||
|
||||
#else
|
||||
#define sctp_free_bufspace(stcb, asoc, tp1, chk_cnt) \
|
||||
do { \
|
||||
if (tp1->data != NULL) { \
|
||||
atomic_subtract_int(&((asoc)->chunks_on_out_queue), chk_cnt); \
|
||||
if ((asoc)->total_output_queue_size >= tp1->book_size) { \
|
||||
atomic_subtract_int(&((asoc)->total_output_queue_size), tp1->book_size); \
|
||||
} else { \
|
||||
(asoc)->total_output_queue_size = 0; \
|
||||
} \
|
||||
if (stcb->sctp_socket && ((stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) || \
|
||||
(stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL))) { \
|
||||
if (stcb->sctp_socket->so_snd.sb_cc >= tp1->book_size) { \
|
||||
atomic_subtract_int(&((stcb)->sctp_socket->so_snd.sb_cc), tp1->book_size); \
|
||||
} else { \
|
||||
stcb->sctp_socket->so_snd.sb_cc = 0; \
|
||||
} \
|
||||
} \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#endif
|
||||
|
||||
#define sctp_free_spbufspace(stcb, asoc, sp) \
|
||||
do { \
|
||||
if (sp->data != NULL) { \
|
||||
if ((asoc)->total_output_queue_size >= sp->length) { \
|
||||
atomic_subtract_int(&(asoc)->total_output_queue_size, sp->length); \
|
||||
} else { \
|
||||
(asoc)->total_output_queue_size = 0; \
|
||||
} \
|
||||
if (stcb->sctp_socket && ((stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) || \
|
||||
(stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL))) { \
|
||||
if (stcb->sctp_socket->so_snd.sb_cc >= sp->length) { \
|
||||
atomic_subtract_int(&stcb->sctp_socket->so_snd.sb_cc,sp->length); \
|
||||
} else { \
|
||||
stcb->sctp_socket->so_snd.sb_cc = 0; \
|
||||
} \
|
||||
} \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define sctp_snd_sb_alloc(stcb, sz) \
|
||||
do { \
|
||||
atomic_add_int(&stcb->asoc.total_output_queue_size,sz); \
|
||||
if ((stcb->sctp_socket != NULL) && \
|
||||
((stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) || \
|
||||
(stcb->sctp_ep->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL))) { \
|
||||
atomic_add_int(&stcb->sctp_socket->so_snd.sb_cc,sz); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
/* functions to start/stop udp tunneling */
|
||||
#if (defined(__APPLE__) || defined(__FreeBSD__)) && !defined(__Userspace__)
|
||||
void sctp_over_udp_stop(void);
|
||||
int sctp_over_udp_start(void);
|
||||
#endif
|
||||
#if defined(_WIN32) && !defined(__Userspace__)
|
||||
void sctp_over_udp_restart(void);
|
||||
#endif
|
||||
|
||||
int
|
||||
sctp_soreceive(struct socket *so, struct sockaddr **psa,
|
||||
struct uio *uio,
|
||||
struct mbuf **mp0,
|
||||
struct mbuf **controlp,
|
||||
int *flagsp);
|
||||
|
||||
void
|
||||
sctp_misc_ints(uint8_t from, uint32_t a, uint32_t b, uint32_t c, uint32_t d);
|
||||
|
||||
void
|
||||
sctp_wakeup_log(struct sctp_tcb *stcb,
|
||||
uint32_t wake_cnt, int from);
|
||||
|
||||
void sctp_log_strm_del_alt(struct sctp_tcb *stcb, uint32_t, uint16_t, uint16_t, int);
|
||||
|
||||
void sctp_log_nagle_event(struct sctp_tcb *stcb, int action);
|
||||
|
||||
#ifdef SCTP_MBUF_LOGGING
|
||||
void
|
||||
sctp_log_mb(struct mbuf *m, int from);
|
||||
|
||||
void
|
||||
sctp_log_mbc(struct mbuf *m, int from);
|
||||
#endif
|
||||
|
||||
void
|
||||
sctp_sblog(struct sockbuf *sb,
|
||||
struct sctp_tcb *stcb, int from, int incr);
|
||||
|
||||
void
|
||||
sctp_log_strm_del(struct sctp_queued_to_read *control,
|
||||
struct sctp_queued_to_read *poschk,
|
||||
int from);
|
||||
void sctp_log_cwnd(struct sctp_tcb *stcb, struct sctp_nets *, int, uint8_t);
|
||||
void rto_logging(struct sctp_nets *net, int from);
|
||||
|
||||
void sctp_log_closing(struct sctp_inpcb *inp, struct sctp_tcb *stcb, int16_t loc);
|
||||
|
||||
void sctp_log_lock(struct sctp_inpcb *inp, struct sctp_tcb *stcb, uint8_t from);
|
||||
void sctp_log_maxburst(struct sctp_tcb *stcb, struct sctp_nets *, int, int, uint8_t);
|
||||
void sctp_log_block(uint8_t, struct sctp_association *, ssize_t);
|
||||
void sctp_log_rwnd(uint8_t, uint32_t, uint32_t, uint32_t);
|
||||
void sctp_log_rwnd_set(uint8_t, uint32_t, uint32_t, uint32_t, uint32_t);
|
||||
int sctp_fill_stat_log(void *, size_t *);
|
||||
void sctp_log_fr(uint32_t, uint32_t, uint32_t, int);
|
||||
void sctp_log_sack(uint32_t, uint32_t, uint32_t, uint16_t, uint16_t, int);
|
||||
void sctp_log_map(uint32_t, uint32_t, uint32_t, int);
|
||||
void sctp_print_mapping_array(struct sctp_association *asoc);
|
||||
void sctp_clr_stat_log(void);
|
||||
|
||||
#ifdef SCTP_AUDITING_ENABLED
|
||||
void
|
||||
sctp_auditing(int, struct sctp_inpcb *, struct sctp_tcb *,
|
||||
struct sctp_nets *);
|
||||
void sctp_audit_log(uint8_t, uint8_t);
|
||||
|
||||
#endif
|
||||
uint32_t sctp_min_mtu(uint32_t, uint32_t, uint32_t);
|
||||
#if defined(__FreeBSD__) && !defined(__Userspace__)
|
||||
void sctp_hc_set_mtu(union sctp_sockstore *, uint16_t, uint32_t);
|
||||
uint32_t sctp_hc_get_mtu(union sctp_sockstore *, uint16_t);
|
||||
#endif
|
||||
void sctp_set_state(struct sctp_tcb *, int);
|
||||
void sctp_add_substate(struct sctp_tcb *, int);
|
||||
uint32_t sctp_ticks_to_msecs(uint32_t);
|
||||
uint32_t sctp_msecs_to_ticks(uint32_t);
|
||||
uint32_t sctp_ticks_to_secs(uint32_t);
|
||||
uint32_t sctp_secs_to_ticks(uint32_t);
|
||||
|
||||
#endif /* _KERNEL */
|
||||
#endif
|
||||
1851
TMessagesProj/jni/third_party/usrsctplib/netinet6/sctp6_usrreq.c
vendored
Normal file
1851
TMessagesProj/jni/third_party/usrsctplib/netinet6/sctp6_usrreq.c
vendored
Normal file
File diff suppressed because it is too large
Load diff
81
TMessagesProj/jni/third_party/usrsctplib/netinet6/sctp6_var.h
vendored
Executable file
81
TMessagesProj/jni/third_party/usrsctplib/netinet6/sctp6_var.h
vendored
Executable file
|
|
@ -0,0 +1,81 @@
|
|||
/*-
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#if defined(__FreeBSD__) && !defined(__Userspace__)
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD: head/sys/netinet6/sctp6_var.h 317457 2017-04-26 19:26:40Z tuexen $");
|
||||
#endif
|
||||
|
||||
#ifndef _NETINET6_SCTP6_VAR_H_
|
||||
#define _NETINET6_SCTP6_VAR_H_
|
||||
|
||||
#if defined(__Userspace__)
|
||||
#ifdef INET
|
||||
extern void in6_sin6_2_sin(struct sockaddr_in *, struct sockaddr_in6 *);
|
||||
extern void in6_sin6_2_sin_in_sock(struct sockaddr *);
|
||||
extern void in6_sin_2_v4mapsin6(const struct sockaddr_in *, struct sockaddr_in6 *);
|
||||
#endif
|
||||
#endif
|
||||
#if defined(_KERNEL)
|
||||
|
||||
#if !defined(__Userspace__)
|
||||
SYSCTL_DECL(_net_inet6_sctp6);
|
||||
extern struct pr_usrreqs sctp6_usrreqs;
|
||||
#else
|
||||
int sctp6_usrreq(struct socket *, int, struct mbuf *, struct mbuf *, struct mbuf *);
|
||||
#endif
|
||||
|
||||
#if defined(__APPLE__) && !defined(__Userspace__)
|
||||
int sctp6_input(struct mbuf **, int *);
|
||||
int sctp6_input_with_port(struct mbuf **, int *, uint16_t);
|
||||
#else
|
||||
int sctp6_input(struct mbuf **, int *, int);
|
||||
int sctp6_input_with_port(struct mbuf **, int *, uint16_t);
|
||||
#endif
|
||||
int sctp6_output(struct sctp_inpcb *, struct mbuf *, struct sockaddr *,
|
||||
struct mbuf *, struct proc *);
|
||||
#if defined(__APPLE__) && !defined(__Userspace__) && !defined(APPLE_LEOPARD) && !defined(APPLE_SNOWLEOPARD) && !defined(APPLE_LION) && !defined(APPLE_MOUNTAINLION) && !defined(APPLE_ELCAPITAN)
|
||||
void sctp6_ctlinput(int, struct sockaddr *, void *, struct ifnet * SCTP_UNUSED);
|
||||
#else
|
||||
void sctp6_ctlinput(int, struct sockaddr *, void *);
|
||||
#endif
|
||||
#if !((defined(__FreeBSD__) || defined(__APPLE__)) && !defined(__Userspace__))
|
||||
extern void in6_sin_2_v4mapsin6(struct sockaddr_in *, struct sockaddr_in6 *);
|
||||
extern void in6_sin6_2_sin(struct sockaddr_in *, struct sockaddr_in6 *);
|
||||
extern void in6_sin6_2_sin_in_sock(struct sockaddr *);
|
||||
#endif
|
||||
void sctp6_notify(struct sctp_inpcb *, struct sctp_tcb *, struct sctp_nets *,
|
||||
uint8_t, uint8_t, uint32_t);
|
||||
#endif
|
||||
#endif
|
||||
315
TMessagesProj/jni/third_party/usrsctplib/user_atomic.h
vendored
Executable file
315
TMessagesProj/jni/third_party/usrsctplib/user_atomic.h
vendored
Executable file
|
|
@ -0,0 +1,315 @@
|
|||
/*-
|
||||
* Copyright (c) 2009-2010 Brad Penoff
|
||||
* Copyright (c) 2009-2010 Humaira Kamal
|
||||
* Copyright (c) 2011-2012 Irene Ruengeler
|
||||
* Copyright (c) 2011-2012 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:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. 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.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
|
||||
*/
|
||||
|
||||
#ifndef _USER_ATOMIC_H_
|
||||
#define _USER_ATOMIC_H_
|
||||
|
||||
/* __Userspace__ version of sys/i386/include/atomic.h goes here */
|
||||
|
||||
/* TODO In the future, might want to not use i386 specific assembly.
|
||||
* The options include:
|
||||
* - implement them generically (but maybe not truly atomic?) in userspace
|
||||
* - have ifdef's for __Userspace_arch_ perhaps (OS isn't enough...)
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#if defined(__APPLE__) || defined(_WIN32)
|
||||
#if defined(_WIN32)
|
||||
#define atomic_add_int(addr, val) InterlockedExchangeAdd((LPLONG)addr, (LONG)val)
|
||||
#define atomic_fetchadd_int(addr, val) InterlockedExchangeAdd((LPLONG)addr, (LONG)val)
|
||||
#define atomic_subtract_int(addr, val) InterlockedExchangeAdd((LPLONG)addr,-((LONG)val))
|
||||
#define atomic_cmpset_int(dst, exp, src) InterlockedCompareExchange((LPLONG)dst, src, exp)
|
||||
#define SCTP_DECREMENT_AND_CHECK_REFCOUNT(addr) (InterlockedExchangeAdd((LPLONG)addr, (-1L)) == 1)
|
||||
#else
|
||||
#include <libkern/OSAtomic.h>
|
||||
#define atomic_add_int(addr, val) OSAtomicAdd32Barrier(val, (int32_t *)addr)
|
||||
#define atomic_fetchadd_int(addr, val) OSAtomicAdd32Barrier(val, (int32_t *)addr)
|
||||
#define atomic_subtract_int(addr, val) OSAtomicAdd32Barrier(-val, (int32_t *)addr)
|
||||
#define atomic_cmpset_int(dst, exp, src) OSAtomicCompareAndSwapIntBarrier(exp, src, (int *)dst)
|
||||
#define SCTP_DECREMENT_AND_CHECK_REFCOUNT(addr) (atomic_fetchadd_int(addr, -1) == 0)
|
||||
#endif
|
||||
|
||||
#if defined(INVARIANTS)
|
||||
#define SCTP_SAVE_ATOMIC_DECREMENT(addr, val) \
|
||||
{ \
|
||||
int32_t newval; \
|
||||
newval = atomic_fetchadd_int(addr, -val); \
|
||||
if (newval < 0) { \
|
||||
panic("Counter goes negative"); \
|
||||
} \
|
||||
}
|
||||
#else
|
||||
#define SCTP_SAVE_ATOMIC_DECREMENT(addr, val) \
|
||||
{ \
|
||||
int32_t newval; \
|
||||
newval = atomic_fetchadd_int(addr, -val); \
|
||||
if (newval < 0) { \
|
||||
*addr = 0; \
|
||||
} \
|
||||
}
|
||||
#endif
|
||||
#if defined(_WIN32)
|
||||
static void atomic_init(void) {} /* empty when we are not using atomic_mtx */
|
||||
#else
|
||||
static inline void atomic_init(void) {} /* empty when we are not using atomic_mtx */
|
||||
#endif
|
||||
|
||||
#else
|
||||
/* Using gcc built-in functions for atomic memory operations
|
||||
Reference: http://gcc.gnu.org/onlinedocs/gcc-4.1.0/gcc/Atomic-Builtins.html
|
||||
Requires gcc version 4.1.0
|
||||
compile with -march=i486
|
||||
*/
|
||||
|
||||
/*Atomically add V to *P.*/
|
||||
#define atomic_add_int(P, V) (void) __sync_fetch_and_add(P, V)
|
||||
|
||||
/*Atomically subtrace V from *P.*/
|
||||
#define atomic_subtract_int(P, V) (void) __sync_fetch_and_sub(P, V)
|
||||
|
||||
/*
|
||||
* Atomically add the value of v to the integer pointed to by p and return
|
||||
* the previous value of *p.
|
||||
*/
|
||||
#define atomic_fetchadd_int(p, v) __sync_fetch_and_add(p, v)
|
||||
|
||||
/* Following explanation from src/sys/i386/include/atomic.h,
|
||||
* for atomic compare and set
|
||||
*
|
||||
* if (*dst == exp) *dst = src (all 32 bit words)
|
||||
*
|
||||
* Returns 0 on failure, non-zero on success
|
||||
*/
|
||||
|
||||
#define atomic_cmpset_int(dst, exp, src) __sync_bool_compare_and_swap(dst, exp, src)
|
||||
|
||||
#define SCTP_DECREMENT_AND_CHECK_REFCOUNT(addr) (atomic_fetchadd_int(addr, -1) == 1)
|
||||
#if defined(INVARIANTS)
|
||||
#define SCTP_SAVE_ATOMIC_DECREMENT(addr, val) \
|
||||
{ \
|
||||
int32_t oldval; \
|
||||
oldval = atomic_fetchadd_int(addr, -val); \
|
||||
if (oldval < val) { \
|
||||
panic("Counter goes negative"); \
|
||||
} \
|
||||
}
|
||||
#else
|
||||
#define SCTP_SAVE_ATOMIC_DECREMENT(addr, val) \
|
||||
{ \
|
||||
int32_t oldval; \
|
||||
oldval = atomic_fetchadd_int(addr, -val); \
|
||||
if (oldval < val) { \
|
||||
*addr = 0; \
|
||||
} \
|
||||
}
|
||||
#endif
|
||||
static inline void atomic_init(void) {} /* empty when we are not using atomic_mtx */
|
||||
#endif
|
||||
|
||||
#if 0 /* using libatomic_ops */
|
||||
#include "user_include/atomic_ops.h"
|
||||
|
||||
/*Atomically add incr to *P, and return the original value of *P.*/
|
||||
#define atomic_add_int(P, V) AO_fetch_and_add((AO_t*)P, V)
|
||||
|
||||
#define atomic_subtract_int(P, V) AO_fetch_and_add((AO_t*)P, -(V))
|
||||
|
||||
/*
|
||||
* Atomically add the value of v to the integer pointed to by p and return
|
||||
* the previous value of *p.
|
||||
*/
|
||||
#define atomic_fetchadd_int(p, v) AO_fetch_and_add((AO_t*)p, v)
|
||||
|
||||
/* Atomically compare *addr to old_val, and replace *addr by new_val
|
||||
if the first comparison succeeds. Returns nonzero if the comparison
|
||||
succeeded and *addr was updated.
|
||||
*/
|
||||
/* Following Explanation from src/sys/i386/include/atomic.h, which
|
||||
matches that of AO_compare_and_swap above.
|
||||
* Atomic compare and set, used by the mutex functions
|
||||
*
|
||||
* if (*dst == exp) *dst = src (all 32 bit words)
|
||||
*
|
||||
* Returns 0 on failure, non-zero on success
|
||||
*/
|
||||
|
||||
#define atomic_cmpset_int(dst, exp, src) AO_compare_and_swap((AO_t*)dst, exp, src)
|
||||
|
||||
static inline void atomic_init() {} /* empty when we are not using atomic_mtx */
|
||||
#endif /* closing #if for libatomic */
|
||||
|
||||
#if 0 /* using atomic_mtx */
|
||||
|
||||
#include <pthread.h>
|
||||
|
||||
extern userland_mutex_t atomic_mtx;
|
||||
|
||||
#if defined(_WIN32)
|
||||
static inline void atomic_init() {
|
||||
InitializeCriticalSection(&atomic_mtx);
|
||||
}
|
||||
static inline void atomic_destroy() {
|
||||
DeleteCriticalSection(&atomic_mtx);
|
||||
}
|
||||
static inline void atomic_lock() {
|
||||
EnterCriticalSection(&atomic_mtx);
|
||||
}
|
||||
static inline void atomic_unlock() {
|
||||
LeaveCriticalSection(&atomic_mtx);
|
||||
}
|
||||
#else
|
||||
static inline void atomic_init() {
|
||||
pthread_mutexattr_t mutex_attr;
|
||||
|
||||
pthread_mutexattr_init(&mutex_attr);
|
||||
#ifdef INVARIANTS
|
||||
pthread_mutexattr_settype(&mutex_attr, PTHREAD_MUTEX_ERRORCHECK);
|
||||
#endif
|
||||
pthread_mutex_init(&accept_mtx, &mutex_attr);
|
||||
pthread_mutexattr_destroy(&mutex_attr);
|
||||
}
|
||||
static inline void atomic_destroy() {
|
||||
(void)pthread_mutex_destroy(&atomic_mtx);
|
||||
}
|
||||
static inline void atomic_lock() {
|
||||
#ifdef INVARIANTS
|
||||
KASSERT(pthread_mutex_lock(&atomic_mtx) == 0, ("atomic_lock: atomic_mtx already locked"))
|
||||
#else
|
||||
(void)pthread_mutex_lock(&atomic_mtx);
|
||||
#endif
|
||||
}
|
||||
static inline void atomic_unlock() {
|
||||
#ifdef INVARIANTS
|
||||
KASSERT(pthread_mutex_unlock(&atomic_mtx) == 0, ("atomic_unlock: atomic_mtx not locked"))
|
||||
#else
|
||||
(void)pthread_mutex_unlock(&atomic_mtx);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
/*
|
||||
* For userland, always use lock prefixes so that the binaries will run
|
||||
* on both SMP and !SMP systems.
|
||||
*/
|
||||
|
||||
#define MPLOCKED "lock ; "
|
||||
|
||||
/*
|
||||
* Atomically add the value of v to the integer pointed to by p and return
|
||||
* the previous value of *p.
|
||||
*/
|
||||
static __inline u_int
|
||||
atomic_fetchadd_int(volatile void *n, u_int v)
|
||||
{
|
||||
int *p = (int *) n;
|
||||
atomic_lock();
|
||||
__asm __volatile(
|
||||
" " MPLOCKED " "
|
||||
" xaddl %0, %1 ; "
|
||||
"# atomic_fetchadd_int"
|
||||
: "+r" (v), /* 0 (result) */
|
||||
"=m" (*p) /* 1 */
|
||||
: "m" (*p)); /* 2 */
|
||||
atomic_unlock();
|
||||
|
||||
return (v);
|
||||
}
|
||||
|
||||
|
||||
#ifdef CPU_DISABLE_CMPXCHG
|
||||
|
||||
static __inline int
|
||||
atomic_cmpset_int(volatile u_int *dst, u_int exp, u_int src)
|
||||
{
|
||||
u_char res;
|
||||
|
||||
atomic_lock();
|
||||
__asm __volatile(
|
||||
" pushfl ; "
|
||||
" cli ; "
|
||||
" cmpl %3,%4 ; "
|
||||
" jne 1f ; "
|
||||
" movl %2,%1 ; "
|
||||
"1: "
|
||||
" sete %0 ; "
|
||||
" popfl ; "
|
||||
"# atomic_cmpset_int"
|
||||
: "=q" (res), /* 0 */
|
||||
"=m" (*dst) /* 1 */
|
||||
: "r" (src), /* 2 */
|
||||
"r" (exp), /* 3 */
|
||||
"m" (*dst) /* 4 */
|
||||
: "memory");
|
||||
atomic_unlock();
|
||||
|
||||
return (res);
|
||||
}
|
||||
|
||||
#else /* !CPU_DISABLE_CMPXCHG */
|
||||
|
||||
static __inline int
|
||||
atomic_cmpset_int(volatile u_int *dst, u_int exp, u_int src)
|
||||
{
|
||||
atomic_lock();
|
||||
u_char res;
|
||||
|
||||
__asm __volatile(
|
||||
" " MPLOCKED " "
|
||||
" cmpxchgl %2,%1 ; "
|
||||
" sete %0 ; "
|
||||
"1: "
|
||||
"# atomic_cmpset_int"
|
||||
: "=a" (res), /* 0 */
|
||||
"=m" (*dst) /* 1 */
|
||||
: "r" (src), /* 2 */
|
||||
"a" (exp), /* 3 */
|
||||
"m" (*dst) /* 4 */
|
||||
: "memory");
|
||||
atomic_unlock();
|
||||
|
||||
return (res);
|
||||
}
|
||||
|
||||
#endif /* CPU_DISABLE_CMPXCHG */
|
||||
|
||||
#define atomic_add_int(P, V) do { \
|
||||
atomic_lock(); \
|
||||
(*(u_int *)(P) += (V)); \
|
||||
atomic_unlock(); \
|
||||
} while(0)
|
||||
#define atomic_subtract_int(P, V) do { \
|
||||
atomic_lock(); \
|
||||
(*(u_int *)(P) -= (V)); \
|
||||
atomic_unlock(); \
|
||||
} while(0)
|
||||
|
||||
#endif
|
||||
#endif
|
||||
384
TMessagesProj/jni/third_party/usrsctplib/user_environment.c
vendored
Executable file
384
TMessagesProj/jni/third_party/usrsctplib/user_environment.c
vendored
Executable file
|
|
@ -0,0 +1,384 @@
|
|||
/*-
|
||||
* Copyright (c) 2009-2010 Brad Penoff
|
||||
* Copyright (c) 2009-2010 Humaira Kamal
|
||||
* Copyright (c) 2011-2012 Irene Ruengeler
|
||||
* Copyright (c) 2011-2012 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:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. 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.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
|
||||
*/
|
||||
|
||||
/* __Userspace__ */
|
||||
|
||||
#if defined(_WIN32)
|
||||
#if !defined(_CRT_RAND_S) && !defined(FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION)
|
||||
#define _CRT_RAND_S
|
||||
#endif
|
||||
#else
|
||||
#include <stdint.h>
|
||||
#include <netinet/sctp_os_userspace.h>
|
||||
#endif
|
||||
#ifdef INVARIANTS
|
||||
#include <netinet/sctp_pcb.h>
|
||||
#endif
|
||||
#include <user_environment.h>
|
||||
#include <sys/types.h>
|
||||
/* #include <sys/param.h> defines MIN */
|
||||
#if !defined(MIN)
|
||||
#define MIN(arg1,arg2) ((arg1) < (arg2) ? (arg1) : (arg2))
|
||||
#endif
|
||||
|
||||
#define uHZ 1000
|
||||
|
||||
/* See user_include/user_environment.h for comments about these variables */
|
||||
int maxsockets = 25600;
|
||||
int hz = uHZ;
|
||||
int ip_defttl = 64;
|
||||
int ipport_firstauto = 49152, ipport_lastauto = 65535;
|
||||
int nmbclusters = 65536;
|
||||
|
||||
/* Source ip_output.c. extern'd in ip_var.h */
|
||||
u_short ip_id = 0; /*__Userspace__ TODO Should it be initialized to zero? */
|
||||
|
||||
/* used in user_include/user_atomic.h in order to make the operations
|
||||
* defined there truly atomic
|
||||
*/
|
||||
userland_mutex_t atomic_mtx;
|
||||
|
||||
/* If the entropy device is not loaded, make a token effort to
|
||||
* provide _some_ kind of randomness. This should only be used
|
||||
* inside other RNG's, like arc4random(9).
|
||||
*/
|
||||
#if defined(FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION)
|
||||
#include <string.h>
|
||||
|
||||
void
|
||||
init_random(void)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
read_random(void *buf, size_t size)
|
||||
{
|
||||
memset(buf, 'A', size);
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
finish_random(void)
|
||||
{
|
||||
return;
|
||||
}
|
||||
/* This define can be used to optionally use OpenSSL's random number utility,
|
||||
* which is capable of bypassing the chromium sandbox which normally would
|
||||
* prevent opening files, including /dev/urandom.
|
||||
*/
|
||||
#elif defined(SCTP_USE_OPENSSL_RAND)
|
||||
#include <openssl/rand.h>
|
||||
|
||||
/* Requiring BoringSSL because it guarantees that RAND_bytes will succeed. */
|
||||
#ifndef OPENSSL_IS_BORINGSSL
|
||||
#error Only BoringSSL is supported with SCTP_USE_OPENSSL_RAND.
|
||||
#endif
|
||||
|
||||
void
|
||||
init_random(void)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
read_random(void *buf, size_t size)
|
||||
{
|
||||
RAND_bytes((uint8_t *)buf, size);
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
finish_random(void)
|
||||
{
|
||||
return;
|
||||
}
|
||||
#elif defined(__FreeBSD__) || defined(__DragonFly__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__APPLE__) || defined(__Bitrig__)
|
||||
#include <stdlib.h>
|
||||
|
||||
void
|
||||
init_random(void)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
read_random(void *buf, size_t size)
|
||||
{
|
||||
arc4random_buf(buf, size);
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
finish_random(void)
|
||||
{
|
||||
return;
|
||||
}
|
||||
#elif defined(_WIN32)
|
||||
#include <stdlib.h>
|
||||
|
||||
void
|
||||
init_random(void)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
read_random(void *buf, size_t size)
|
||||
{
|
||||
unsigned int randval;
|
||||
size_t position, remaining;
|
||||
|
||||
position = 0;
|
||||
while (position < size) {
|
||||
if (rand_s(&randval) == 0) {
|
||||
remaining = MIN(size - position, sizeof(unsigned int));
|
||||
memcpy((char *)buf + position, &randval, remaining);
|
||||
position += sizeof(unsigned int);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
finish_random(void)
|
||||
{
|
||||
return;
|
||||
}
|
||||
#elif (defined(__ANDROID__) && (__ANDROID_API__ < 28)) || defined(__EMSCRIPTEN__)
|
||||
#include <fcntl.h>
|
||||
|
||||
static int fd = -1;
|
||||
|
||||
void
|
||||
init_random(void)
|
||||
{
|
||||
fd = open("/dev/urandom", O_RDONLY);
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
read_random(void *buf, size_t size)
|
||||
{
|
||||
size_t position;
|
||||
ssize_t n;
|
||||
|
||||
position = 0;
|
||||
while (position < size) {
|
||||
n = read(fd, (char *)buf + position, size - position);
|
||||
if (n > 0) {
|
||||
position += n;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
finish_random(void)
|
||||
{
|
||||
close(fd);
|
||||
return;
|
||||
}
|
||||
#elif defined(__ANDROID__) && (__ANDROID_API__ >= 28)
|
||||
#include <sys/random.h>
|
||||
|
||||
void
|
||||
init_random(void)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
read_random(void *buf, size_t size)
|
||||
{
|
||||
size_t position;
|
||||
ssize_t n;
|
||||
|
||||
position = 0;
|
||||
while (position < size) {
|
||||
n = getrandom((char *)buf + position, size - position, 0);
|
||||
if (n > 0) {
|
||||
position += n;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
finish_random(void)
|
||||
{
|
||||
return;
|
||||
}
|
||||
#elif defined(__linux__)
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/syscall.h>
|
||||
|
||||
#if defined(__has_feature)
|
||||
#if __has_feature(memory_sanitizer)
|
||||
void __msan_unpoison(void *, size_t);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef __NR_getrandom
|
||||
#if !defined(GRND_NONBLOCK)
|
||||
#define GRND_NONBLOCK 1
|
||||
#endif
|
||||
static int getrandom_available = 0;
|
||||
#endif
|
||||
static int fd = -1;
|
||||
|
||||
void
|
||||
init_random(void)
|
||||
{
|
||||
#ifdef __NR_getrandom
|
||||
char dummy;
|
||||
ssize_t n = syscall(__NR_getrandom, &dummy, sizeof(dummy), GRND_NONBLOCK);
|
||||
if (n > 0 || errno == EINTR || errno == EAGAIN) {
|
||||
/* Either getrandom succeeded, was interrupted or is waiting for entropy;
|
||||
* all of which mean the syscall is available.
|
||||
*/
|
||||
getrandom_available = 1;
|
||||
} else {
|
||||
#ifdef INVARIANTS
|
||||
if (errno != ENOSYS) {
|
||||
panic("getrandom syscall returned unexpected error: %d", errno);
|
||||
}
|
||||
#endif
|
||||
/* If the syscall isn't available, fall back to /dev/urandom. */
|
||||
#endif
|
||||
fd = open("/dev/urandom", O_RDONLY);
|
||||
#ifdef __NR_getrandom
|
||||
}
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
read_random(void *buf, size_t size)
|
||||
{
|
||||
size_t position;
|
||||
ssize_t n;
|
||||
|
||||
position = 0;
|
||||
while (position < size) {
|
||||
#ifdef __NR_getrandom
|
||||
if (getrandom_available) {
|
||||
/* Using syscall directly because getrandom isn't present in glibc < 2.25.
|
||||
*/
|
||||
n = syscall(__NR_getrandom, (char *)buf + position, size - position, 0);
|
||||
if (n > 0) {
|
||||
#if defined(__has_feature)
|
||||
#if __has_feature(memory_sanitizer)
|
||||
/* Need to do this because MSan doesn't realize that syscall has
|
||||
* initialized the output buffer.
|
||||
*/
|
||||
__msan_unpoison(buf + position, n);
|
||||
#endif
|
||||
#endif
|
||||
position += n;
|
||||
} else if (errno != EINTR && errno != EAGAIN) {
|
||||
#ifdef INVARIANTS
|
||||
panic("getrandom syscall returned unexpected error: %d", errno);
|
||||
#endif
|
||||
}
|
||||
} else
|
||||
#endif /* __NR_getrandom */
|
||||
{
|
||||
n = read(fd, (char *)buf + position, size - position);
|
||||
if (n > 0) {
|
||||
position += n;
|
||||
}
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
finish_random(void)
|
||||
{
|
||||
if (fd != -1) {
|
||||
close(fd);
|
||||
}
|
||||
return;
|
||||
}
|
||||
#elif defined(__Fuchsia__)
|
||||
#include <zircon/syscalls.h>
|
||||
|
||||
void
|
||||
init_random(void)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
read_random(void *buf, size_t size)
|
||||
{
|
||||
zx_cprng_draw(buf, size);
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
finish_random(void)
|
||||
{
|
||||
return;
|
||||
}
|
||||
#elif defined(__native_client__)
|
||||
#include <nacl/nacl_random.h>
|
||||
|
||||
void
|
||||
init_random(void)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
read_random(void *buf, size_t size)
|
||||
{
|
||||
size_t position;
|
||||
size_t n;
|
||||
|
||||
position = 0;
|
||||
while (position < size) {
|
||||
if (nacl_secure_random((char *)buf + position, size - position, &n) == 0)
|
||||
position += n;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
finish_random(void)
|
||||
{
|
||||
return;
|
||||
}
|
||||
#else
|
||||
#error "Unknown platform. Please provide platform specific RNG."
|
||||
#endif
|
||||
123
TMessagesProj/jni/third_party/usrsctplib/user_environment.h
vendored
Executable file
123
TMessagesProj/jni/third_party/usrsctplib/user_environment.h
vendored
Executable file
|
|
@ -0,0 +1,123 @@
|
|||
/*-
|
||||
* Copyright (c) 2009-2010 Brad Penoff
|
||||
* Copyright (c) 2009-2010 Humaira Kamal
|
||||
* Copyright (c) 2011-2012 Irene Ruengeler
|
||||
* Copyright (c) 2011-2012 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:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. 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.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
|
||||
*/
|
||||
|
||||
#ifndef _USER_ENVIRONMENT_H_
|
||||
#define _USER_ENVIRONMENT_H_
|
||||
/* __Userspace__ */
|
||||
#include <sys/types.h>
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
#ifndef _SYS_MUTEX_H_
|
||||
#include <sys/mutex.h>
|
||||
#endif
|
||||
#endif
|
||||
#if defined(_WIN32)
|
||||
#include "netinet/sctp_os_userspace.h"
|
||||
#endif
|
||||
|
||||
/* maxsockets is used in SCTP_ZONE_INIT call. It refers to
|
||||
* kern.ipc.maxsockets kernel environment variable.
|
||||
*/
|
||||
extern int maxsockets;
|
||||
|
||||
/* int hz; is declared in sys/kern/subr_param.c and refers to kernel timer frequency.
|
||||
* See http://ivoras.sharanet.org/freebsd/vmware.html for additional info about kern.hz
|
||||
* hz is initialized in void init_param1(void) in that file.
|
||||
*/
|
||||
extern int hz;
|
||||
|
||||
|
||||
/* The following two ints define a range of available ephemeral ports. */
|
||||
extern int ipport_firstauto, ipport_lastauto;
|
||||
|
||||
/* nmbclusters is used in sctp_usrreq.c (e.g., sctp_init). In the FreeBSD kernel,
|
||||
* this is 1024 + maxusers * 64.
|
||||
*/
|
||||
extern int nmbclusters;
|
||||
|
||||
#if !defined(_MSC_VER) && !defined(__MINGW32__)
|
||||
#define min(a,b) (((a)>(b))?(b):(a))
|
||||
#define max(a,b) (((a)>(b))?(a):(b))
|
||||
#endif
|
||||
|
||||
void init_random(void);
|
||||
void read_random(void *, size_t);
|
||||
void finish_random(void);
|
||||
|
||||
/* errno's may differ per OS. errno.h now included in sctp_os_userspace.h */
|
||||
/* Source: /usr/src/sys/sys/errno.h */
|
||||
/* #define ENOSPC 28 */ /* No space left on device */
|
||||
/* #define ENOBUFS 55 */ /* No buffer space available */
|
||||
/* #define ENOMEM 12 */ /* Cannot allocate memory */
|
||||
/* #define EACCES 13 */ /* Permission denied */
|
||||
/* #define EFAULT 14 */ /* Bad address */
|
||||
/* #define EHOSTDOWN 64 */ /* Host is down */
|
||||
/* #define EHOSTUNREACH 65 */ /* No route to host */
|
||||
|
||||
/* Source ip_output.c. extern'd in ip_var.h */
|
||||
extern u_short ip_id;
|
||||
|
||||
#if defined(__linux__)
|
||||
#define IPV6_VERSION 0x60
|
||||
#endif
|
||||
|
||||
#if defined(INVARIANTS)
|
||||
#include <stdlib.h>
|
||||
|
||||
#if defined(_WIN32)
|
||||
static inline void __declspec(noreturn)
|
||||
#else
|
||||
static inline void __attribute__((__noreturn__))
|
||||
#endif
|
||||
terminate_non_graceful(void) {
|
||||
abort();
|
||||
}
|
||||
|
||||
#define panic(...) \
|
||||
do { \
|
||||
SCTP_PRINTF("%s(): ", __func__); \
|
||||
SCTP_PRINTF(__VA_ARGS__); \
|
||||
SCTP_PRINTF("\n"); \
|
||||
terminate_non_graceful(); \
|
||||
} while (0)
|
||||
|
||||
#define KASSERT(cond, args) \
|
||||
do { \
|
||||
if (!(cond)) { \
|
||||
panic args ; \
|
||||
} \
|
||||
} while (0)
|
||||
#else
|
||||
#define KASSERT(cond, args)
|
||||
#endif
|
||||
|
||||
/* necessary for sctp_pcb.c */
|
||||
extern int ip_defttl;
|
||||
#endif
|
||||
373
TMessagesProj/jni/third_party/usrsctplib/user_inpcb.h
vendored
Executable file
373
TMessagesProj/jni/third_party/usrsctplib/user_inpcb.h
vendored
Executable file
|
|
@ -0,0 +1,373 @@
|
|||
/*-
|
||||
* Copyright (c) 1982, 1986, 1990, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. 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.
|
||||
* 3. Neither the name of the University 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 REGENTS 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 REGENTS 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.
|
||||
*
|
||||
* @(#)in_pcb.h 8.1 (Berkeley) 6/10/93
|
||||
* $FreeBSD: src/sys/netinet/in_pcb.h,v 1.100.2.1 2007/12/07 05:46:08 kmacy Exp $
|
||||
*/
|
||||
|
||||
#ifndef _USER_INPCB_H_
|
||||
#define _USER_INPCB_H_
|
||||
|
||||
#include <user_route.h> /* was <net/route.h> */
|
||||
|
||||
struct inpcbpolicy;
|
||||
|
||||
/*
|
||||
* Struct inpcb is the ommon structure pcb for the Internet Protocol
|
||||
* implementation.
|
||||
*
|
||||
* Pointers to local and foreign host table entries, local and foreign socket
|
||||
* numbers, and pointers up (to a socket structure) and down (to a
|
||||
* protocol-specific control block) are stored here.
|
||||
*/
|
||||
LIST_HEAD(inpcbhead, inpcb);
|
||||
LIST_HEAD(inpcbporthead, inpcbport);
|
||||
|
||||
/*
|
||||
* PCB with AF_INET6 null bind'ed laddr can receive AF_INET input packet.
|
||||
* So, AF_INET6 null laddr is also used as AF_INET null laddr, by utilizing
|
||||
* the following structure.
|
||||
*/
|
||||
struct in_addr_4in6 {
|
||||
uint32_t ia46_pad32[3];
|
||||
struct in_addr ia46_addr4;
|
||||
};
|
||||
|
||||
/*
|
||||
* NOTE: ipv6 addrs should be 64-bit aligned, per RFC 2553. in_conninfo has
|
||||
* some extra padding to accomplish this.
|
||||
*/
|
||||
struct in_endpoints {
|
||||
uint16_t ie_fport; /* foreign port */
|
||||
uint16_t ie_lport; /* local port */
|
||||
/* protocol dependent part, local and foreign addr */
|
||||
union {
|
||||
/* foreign host table entry */
|
||||
struct in_addr_4in6 ie46_foreign;
|
||||
struct in6_addr ie6_foreign;
|
||||
} ie_dependfaddr;
|
||||
union {
|
||||
/* local host table entry */
|
||||
struct in_addr_4in6 ie46_local;
|
||||
struct in6_addr ie6_local;
|
||||
} ie_dependladdr;
|
||||
#define ie_faddr ie_dependfaddr.ie46_foreign.ia46_addr4
|
||||
#define ie_laddr ie_dependladdr.ie46_local.ia46_addr4
|
||||
#define ie6_faddr ie_dependfaddr.ie6_foreign
|
||||
#define ie6_laddr ie_dependladdr.ie6_local
|
||||
};
|
||||
|
||||
/*
|
||||
* XXX The defines for inc_* are hacks and should be changed to direct
|
||||
* references.
|
||||
*/
|
||||
struct in_conninfo {
|
||||
uint8_t inc_flags;
|
||||
uint8_t inc_len;
|
||||
uint16_t inc_pad; /* XXX alignment for in_endpoints */
|
||||
/* protocol dependent part */
|
||||
struct in_endpoints inc_ie;
|
||||
};
|
||||
#define inc_isipv6 inc_flags /* temp compatibility */
|
||||
#define inc_fport inc_ie.ie_fport
|
||||
#define inc_lport inc_ie.ie_lport
|
||||
#define inc_faddr inc_ie.ie_faddr
|
||||
#define inc_laddr inc_ie.ie_laddr
|
||||
#define inc6_faddr inc_ie.ie6_faddr
|
||||
#define inc6_laddr inc_ie.ie6_laddr
|
||||
|
||||
struct icmp6_filter;
|
||||
|
||||
struct inpcb {
|
||||
LIST_ENTRY(inpcb) inp_hash; /* hash list */
|
||||
LIST_ENTRY(inpcb) inp_list; /* list for all PCBs of this proto */
|
||||
void *inp_ppcb; /* pointer to per-protocol pcb */
|
||||
struct inpcbinfo *inp_pcbinfo; /* PCB list info */
|
||||
struct socket *inp_socket; /* back pointer to socket */
|
||||
|
||||
uint32_t inp_flow;
|
||||
int inp_flags; /* generic IP/datagram flags */
|
||||
|
||||
u_char inp_vflag; /* IP version flag (v4/v6) */
|
||||
#define INP_IPV4 0x1
|
||||
#define INP_IPV6 0x2
|
||||
#define INP_IPV6PROTO 0x4 /* opened under IPv6 protocol */
|
||||
#define INP_TIMEWAIT 0x8 /* .. probably doesn't go here */
|
||||
#define INP_ONESBCAST 0x10 /* send all-ones broadcast */
|
||||
#define INP_DROPPED 0x20 /* protocol drop flag */
|
||||
#define INP_SOCKREF 0x40 /* strong socket reference */
|
||||
#define INP_CONN 0x80
|
||||
u_char inp_ip_ttl; /* time to live proto */
|
||||
u_char inp_ip_p; /* protocol proto */
|
||||
u_char inp_ip_minttl; /* minimum TTL or drop */
|
||||
uint32_t inp_ispare1; /* connection id / queue id */
|
||||
void *inp_pspare[2]; /* rtentry / general use */
|
||||
|
||||
/* Local and foreign ports, local and foreign addr. */
|
||||
struct in_conninfo inp_inc;
|
||||
|
||||
/* list for this PCB's local port */
|
||||
struct label *inp_label; /* MAC label */
|
||||
struct inpcbpolicy *inp_sp; /* for IPSEC */
|
||||
|
||||
/* Protocol-dependent part; options. */
|
||||
struct {
|
||||
u_char inp4_ip_tos; /* type of service proto */
|
||||
struct mbuf *inp4_options; /* IP options */
|
||||
struct ip_moptions *inp4_moptions; /* IP multicast options */
|
||||
} inp_depend4;
|
||||
#define inp_fport inp_inc.inc_fport
|
||||
#define inp_lport inp_inc.inc_lport
|
||||
#define inp_faddr inp_inc.inc_faddr
|
||||
#define inp_laddr inp_inc.inc_laddr
|
||||
#define inp_ip_tos inp_depend4.inp4_ip_tos
|
||||
#define inp_options inp_depend4.inp4_options
|
||||
#define inp_moptions inp_depend4.inp4_moptions
|
||||
struct {
|
||||
/* IP options */
|
||||
struct mbuf *inp6_options;
|
||||
/* IP6 options for outgoing packets */
|
||||
struct ip6_pktopts *inp6_outputopts;
|
||||
/* IP multicast options */
|
||||
#if 0
|
||||
struct ip6_moptions *inp6_moptions;
|
||||
#endif
|
||||
/* ICMPv6 code type filter */
|
||||
struct icmp6_filter *inp6_icmp6filt;
|
||||
/* IPV6_CHECKSUM setsockopt */
|
||||
int inp6_cksum;
|
||||
short inp6_hops;
|
||||
} inp_depend6;
|
||||
LIST_ENTRY(inpcb) inp_portlist;
|
||||
struct inpcbport *inp_phd; /* head of this list */
|
||||
#define inp_zero_size offsetof(struct inpcb, inp_gencnt)
|
||||
struct mtx inp_mtx;
|
||||
|
||||
#define in6p_faddr inp_inc.inc6_faddr
|
||||
#define in6p_laddr inp_inc.inc6_laddr
|
||||
#define in6p_hops inp_depend6.inp6_hops /* default hop limit */
|
||||
#define in6p_ip6_nxt inp_ip_p
|
||||
#define in6p_flowinfo inp_flow
|
||||
#define in6p_vflag inp_vflag
|
||||
#define in6p_options inp_depend6.inp6_options
|
||||
#define in6p_outputopts inp_depend6.inp6_outputopts
|
||||
#if 0
|
||||
#define in6p_moptions inp_depend6.inp6_moptions
|
||||
#endif
|
||||
#define in6p_icmp6filt inp_depend6.inp6_icmp6filt
|
||||
#define in6p_cksum inp_depend6.inp6_cksum
|
||||
#define in6p_flags inp_flags /* for KAME src sync over BSD*'s */
|
||||
#define in6p_socket inp_socket /* for KAME src sync over BSD*'s */
|
||||
#define in6p_lport inp_lport /* for KAME src sync over BSD*'s */
|
||||
#define in6p_fport inp_fport /* for KAME src sync over BSD*'s */
|
||||
#define in6p_ppcb inp_ppcb /* for KAME src sync over BSD*'s */
|
||||
};
|
||||
/*
|
||||
* The range of the generation count, as used in this implementation, is 9e19.
|
||||
* We would have to create 300 billion connections per second for this number
|
||||
* to roll over in a year. This seems sufficiently unlikely that we simply
|
||||
* don't concern ourselves with that possibility.
|
||||
*/
|
||||
|
||||
struct inpcbport {
|
||||
LIST_ENTRY(inpcbport) phd_hash;
|
||||
struct inpcbhead phd_pcblist;
|
||||
u_short phd_port;
|
||||
};
|
||||
|
||||
/*
|
||||
* Global data structure for each high-level protocol (UDP, TCP, ...) in both
|
||||
* IPv4 and IPv6. Holds inpcb lists and information for managing them.
|
||||
*/
|
||||
struct inpcbinfo {
|
||||
/*
|
||||
* Global list of inpcbs on the protocol.
|
||||
*/
|
||||
struct inpcbhead *ipi_listhead;
|
||||
u_int ipi_count;
|
||||
|
||||
/*
|
||||
* Global hash of inpcbs, hashed by local and foreign addresses and
|
||||
* port numbers.
|
||||
*/
|
||||
struct inpcbhead *ipi_hashbase;
|
||||
u_long ipi_hashmask;
|
||||
|
||||
/*
|
||||
* Global hash of inpcbs, hashed by only local port number.
|
||||
*/
|
||||
struct inpcbporthead *ipi_porthashbase;
|
||||
u_long ipi_porthashmask;
|
||||
|
||||
/*
|
||||
* Fields associated with port lookup and allocation.
|
||||
*/
|
||||
u_short ipi_lastport;
|
||||
u_short ipi_lastlow;
|
||||
u_short ipi_lasthi;
|
||||
|
||||
/*
|
||||
* UMA zone from which inpcbs are allocated for this protocol.
|
||||
*/
|
||||
struct uma_zone *ipi_zone;
|
||||
|
||||
/*
|
||||
* Generation count--incremented each time a connection is allocated
|
||||
* or freed.
|
||||
*/
|
||||
struct mtx ipi_mtx;
|
||||
|
||||
/*
|
||||
* vimage 1
|
||||
* general use 1
|
||||
*/
|
||||
void *ipi_pspare[2];
|
||||
};
|
||||
|
||||
#define INP_LOCK_INIT(inp, d, t) \
|
||||
mtx_init(&(inp)->inp_mtx, (d), (t), MTX_DEF | MTX_RECURSE | MTX_DUPOK)
|
||||
#define INP_LOCK_DESTROY(inp) mtx_destroy(&(inp)->inp_mtx)
|
||||
#define INP_LOCK(inp) mtx_lock(&(inp)->inp_mtx)
|
||||
#define INP_UNLOCK(inp) mtx_unlock(&(inp)->inp_mtx)
|
||||
#define INP_LOCK_ASSERT(inp) mtx_assert(&(inp)->inp_mtx, MA_OWNED)
|
||||
#define INP_UNLOCK_ASSERT(inp) mtx_assert(&(inp)->inp_mtx, MA_NOTOWNED)
|
||||
|
||||
#define INP_INFO_LOCK_INIT(ipi, d) \
|
||||
mtx_init(&(ipi)->ipi_mtx, (d), NULL, MTX_DEF | MTX_RECURSE)
|
||||
#define INP_INFO_LOCK_DESTROY(ipi) mtx_destroy(&(ipi)->ipi_mtx)
|
||||
#define INP_INFO_RLOCK(ipi) mtx_lock(&(ipi)->ipi_mtx)
|
||||
#define INP_INFO_WLOCK(ipi) mtx_lock(&(ipi)->ipi_mtx)
|
||||
#define INP_INFO_RUNLOCK(ipi) mtx_unlock(&(ipi)->ipi_mtx)
|
||||
#define INP_INFO_WUNLOCK(ipi) mtx_unlock(&(ipi)->ipi_mtx)
|
||||
#define INP_INFO_RLOCK_ASSERT(ipi) mtx_assert(&(ipi)->ipi_mtx, MA_OWNED)
|
||||
#define INP_INFO_WLOCK_ASSERT(ipi) mtx_assert(&(ipi)->ipi_mtx, MA_OWNED)
|
||||
#define INP_INFO_UNLOCK_ASSERT(ipi) mtx_assert(&(ipi)->ipi_mtx, MA_NOTOWNED)
|
||||
|
||||
#define INP_PCBHASH(faddr, lport, fport, mask) \
|
||||
(((faddr) ^ ((faddr) >> 16) ^ ntohs((lport) ^ (fport))) & (mask))
|
||||
#define INP_PCBPORTHASH(lport, mask) \
|
||||
(ntohs((lport)) & (mask))
|
||||
|
||||
/* flags in inp_flags: */
|
||||
#define INP_RECVOPTS 0x01 /* receive incoming IP options */
|
||||
#define INP_RECVRETOPTS 0x02 /* receive IP options for reply */
|
||||
#define INP_RECVDSTADDR 0x04 /* receive IP dst address */
|
||||
#define INP_HDRINCL 0x08 /* user supplies entire IP header */
|
||||
#define INP_HIGHPORT 0x10 /* user wants "high" port binding */
|
||||
#define INP_LOWPORT 0x20 /* user wants "low" port binding */
|
||||
#define INP_ANONPORT 0x40 /* port chosen for user */
|
||||
#define INP_RECVIF 0x80 /* receive incoming interface */
|
||||
#define INP_MTUDISC 0x100 /* user can do MTU discovery */
|
||||
#define INP_FAITH 0x200 /* accept FAITH'ed connections */
|
||||
#define INP_RECVTTL 0x400 /* receive incoming IP TTL */
|
||||
#define INP_DONTFRAG 0x800 /* don't fragment packet */
|
||||
|
||||
#define IN6P_IPV6_V6ONLY 0x008000 /* restrict AF_INET6 socket for v6 */
|
||||
|
||||
#define IN6P_PKTINFO 0x010000 /* receive IP6 dst and I/F */
|
||||
#define IN6P_HOPLIMIT 0x020000 /* receive hoplimit */
|
||||
#define IN6P_HOPOPTS 0x040000 /* receive hop-by-hop options */
|
||||
#define IN6P_DSTOPTS 0x080000 /* receive dst options after rthdr */
|
||||
#define IN6P_RTHDR 0x100000 /* receive routing header */
|
||||
#define IN6P_RTHDRDSTOPTS 0x200000 /* receive dstoptions before rthdr */
|
||||
#define IN6P_TCLASS 0x400000 /* receive traffic class value */
|
||||
#define IN6P_AUTOFLOWLABEL 0x800000 /* attach flowlabel automatically */
|
||||
#define IN6P_RFC2292 0x40000000 /* used RFC2292 API on the socket */
|
||||
#define IN6P_MTU 0x80000000 /* receive path MTU */
|
||||
|
||||
#define INP_CONTROLOPTS (INP_RECVOPTS|INP_RECVRETOPTS|INP_RECVDSTADDR|\
|
||||
INP_RECVIF|INP_RECVTTL|\
|
||||
IN6P_PKTINFO|IN6P_HOPLIMIT|IN6P_HOPOPTS|\
|
||||
IN6P_DSTOPTS|IN6P_RTHDR|IN6P_RTHDRDSTOPTS|\
|
||||
IN6P_TCLASS|IN6P_AUTOFLOWLABEL|IN6P_RFC2292|\
|
||||
IN6P_MTU)
|
||||
#define INP_UNMAPPABLEOPTS (IN6P_HOPOPTS|IN6P_DSTOPTS|IN6P_RTHDR|\
|
||||
IN6P_TCLASS|IN6P_AUTOFLOWLABEL)
|
||||
|
||||
/* for KAME src sync over BSD*'s */
|
||||
#define IN6P_HIGHPORT INP_HIGHPORT
|
||||
#define IN6P_LOWPORT INP_LOWPORT
|
||||
#define IN6P_ANONPORT INP_ANONPORT
|
||||
#define IN6P_RECVIF INP_RECVIF
|
||||
#define IN6P_MTUDISC INP_MTUDISC
|
||||
#define IN6P_FAITH INP_FAITH
|
||||
#define IN6P_CONTROLOPTS INP_CONTROLOPTS
|
||||
/*
|
||||
* socket AF version is {newer than,or include}
|
||||
* actual datagram AF version
|
||||
*/
|
||||
|
||||
#define INPLOOKUP_WILDCARD 1
|
||||
#define sotoinpcb(so) ((struct inpcb *)(so)->so_pcb)
|
||||
|
||||
#define INP_SOCKAF(so) so->so_proto->pr_domain->dom_family
|
||||
|
||||
#define INP_CHECK_SOCKAF(so, af) (INP_SOCKAF(so) == af)
|
||||
|
||||
extern int ipport_reservedhigh;
|
||||
extern int ipport_reservedlow;
|
||||
extern int ipport_lowfirstauto;
|
||||
extern int ipport_lowlastauto;
|
||||
extern int ipport_firstauto;
|
||||
extern int ipport_lastauto;
|
||||
extern int ipport_hifirstauto;
|
||||
extern int ipport_hilastauto;
|
||||
extern struct callout ipport_tick_callout;
|
||||
|
||||
void in_pcbpurgeif0(struct inpcbinfo *, struct ifnet *);
|
||||
int in_pcballoc(struct socket *, struct inpcbinfo *);
|
||||
int in_pcbbind(struct inpcb *, struct sockaddr *, struct ucred *);
|
||||
int in_pcbconnect(struct inpcb *, struct sockaddr *, struct ucred *);
|
||||
void in_pcbdetach(struct inpcb *);
|
||||
void in_pcbdisconnect(struct inpcb *);
|
||||
void in_pcbdrop(struct inpcb *);
|
||||
void in_pcbfree(struct inpcb *);
|
||||
int in_pcbinshash(struct inpcb *);
|
||||
struct inpcb *
|
||||
in_pcblookup_local(struct inpcbinfo *,
|
||||
struct in_addr, u_int, int);
|
||||
struct inpcb *
|
||||
in_pcblookup_hash(struct inpcbinfo *, struct in_addr, u_int,
|
||||
struct in_addr, u_int, int, struct ifnet *);
|
||||
void in_pcbnotifyall(struct inpcbinfo *pcbinfo, struct in_addr,
|
||||
int, struct inpcb *(*)(struct inpcb *, int));
|
||||
void in_pcbrehash(struct inpcb *);
|
||||
void in_pcbsetsolabel(struct socket *so);
|
||||
int in_getpeeraddr(struct socket *so, struct sockaddr **nam);
|
||||
int in_getsockaddr(struct socket *so, struct sockaddr **nam);
|
||||
void in_pcbsosetlabel(struct socket *so);
|
||||
void in_pcbremlists(struct inpcb *inp);
|
||||
void ipport_tick(void *xtp);
|
||||
|
||||
/*
|
||||
* Debugging routines compiled in when DDB is present.
|
||||
*/
|
||||
void db_print_inpcb(struct inpcb *inp, const char *name, int indent);
|
||||
|
||||
|
||||
#endif /* !_NETINET_IN_PCB_H_ */
|
||||
124
TMessagesProj/jni/third_party/usrsctplib/user_ip6_var.h
vendored
Executable file
124
TMessagesProj/jni/third_party/usrsctplib/user_ip6_var.h
vendored
Executable file
|
|
@ -0,0 +1,124 @@
|
|||
/*-
|
||||
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. 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.
|
||||
* 3. Neither the name of the project 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 PROJECT 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 PROJECT 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.
|
||||
*
|
||||
*/
|
||||
/*-
|
||||
* Copyright (c) 1982, 1986, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. 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.
|
||||
* 3. Neither the name of the University 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 REGENTS 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 REGENTS 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _USER_IP6_VAR_H_
|
||||
#define _USER_IP6_VAR_H_
|
||||
|
||||
#if defined(_WIN32)
|
||||
struct ip6_hdr {
|
||||
union {
|
||||
struct ip6_hdrctl {
|
||||
uint32_t ip6_un1_flow; /* 20 bits of flow-ID */
|
||||
uint16_t ip6_un1_plen; /* payload length */
|
||||
uint8_t ip6_un1_nxt; /* next header */
|
||||
uint8_t ip6_un1_hlim; /* hop limit */
|
||||
} ip6_un1;
|
||||
uint8_t ip6_un2_vfc; /* 4 bits version, top 4 bits class */
|
||||
} ip6_ctlun;
|
||||
struct in6_addr ip6_src; /* source address */
|
||||
struct in6_addr ip6_dst; /* destination address */
|
||||
};
|
||||
#define ip6_vfc ip6_ctlun.ip6_un2_vfc
|
||||
#define ip6_flow ip6_ctlun.ip6_un1.ip6_un1_flow
|
||||
#define ip6_plen ip6_ctlun.ip6_un1.ip6_un1_plen
|
||||
#define ip6_nxt ip6_ctlun.ip6_un1.ip6_un1_nxt
|
||||
#define ip6_hlim ip6_ctlun.ip6_un1.ip6_un1_hlim
|
||||
#define ip6_hops ip6_ctlun.ip6_un1.ip6_un1_hlim
|
||||
|
||||
#define IPV6_VERSION 0x60
|
||||
#endif
|
||||
|
||||
#if defined(_WIN32)
|
||||
#define s6_addr16 u.Word
|
||||
#endif
|
||||
#if !defined(_WIN32) && !defined(__linux__) && !defined(__EMSCRIPTEN__)
|
||||
#define s6_addr8 __u6_addr.__u6_addr8
|
||||
#define s6_addr16 __u6_addr.__u6_addr16
|
||||
#define s6_addr32 __u6_addr.__u6_addr32
|
||||
#endif
|
||||
|
||||
#if !defined(__FreeBSD__) && !defined(__OpenBSD__) && !defined(__DragonFly__)
|
||||
struct route_in6 {
|
||||
struct rtentry *ro_rt;
|
||||
struct llentry *ro_lle;
|
||||
struct in6_addr *ro_ia6;
|
||||
int ro_flags;
|
||||
struct sockaddr_in6 ro_dst;
|
||||
};
|
||||
#endif
|
||||
#define IP6_EXTHDR_GET(val, typ, m, off, len) \
|
||||
do { \
|
||||
struct mbuf *t; \
|
||||
int tmp; \
|
||||
if ((m)->m_len >= (off) + (len)) \
|
||||
(val) = (typ)(mtod((m), caddr_t) + (off)); \
|
||||
else { \
|
||||
t = m_pulldown((m), (off), (len), &tmp); \
|
||||
if (t) { \
|
||||
KASSERT(t->m_len >= tmp + (len), \
|
||||
("m_pulldown malfunction")); \
|
||||
(val) = (typ)(mtod(t, caddr_t) + tmp); \
|
||||
} else { \
|
||||
(val) = (typ)NULL; \
|
||||
(m) = NULL; \
|
||||
} \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#endif /* !_USER_IP6_VAR_H_ */
|
||||
225
TMessagesProj/jni/third_party/usrsctplib/user_ip_icmp.h
vendored
Executable file
225
TMessagesProj/jni/third_party/usrsctplib/user_ip_icmp.h
vendored
Executable file
|
|
@ -0,0 +1,225 @@
|
|||
/*-
|
||||
* Copyright (c) 1982, 1986, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. 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.
|
||||
* 3. Neither the name of the University 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 REGENTS 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 REGENTS 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _USER_IP_ICMP_H_
|
||||
#define _USER_IP_ICMP_H_
|
||||
|
||||
/*
|
||||
* Interface Control Message Protocol Definitions.
|
||||
* Per RFC 792, September 1981.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Internal of an ICMP Router Advertisement
|
||||
*/
|
||||
struct icmp_ra_addr {
|
||||
uint32_t ira_addr;
|
||||
uint32_t ira_preference;
|
||||
};
|
||||
|
||||
/*
|
||||
* Structure of an icmp header.
|
||||
*/
|
||||
struct icmphdr {
|
||||
u_char icmp_type; /* type of message, see below */
|
||||
u_char icmp_code; /* type sub code */
|
||||
u_short icmp_cksum; /* ones complement cksum of struct */
|
||||
};
|
||||
|
||||
#if defined(_WIN32)
|
||||
#pragma pack (push, 1)
|
||||
struct icmp6_hdr {
|
||||
uint8_t icmp6_type;
|
||||
uint8_t icmp6_code;
|
||||
uint16_t icmp6_cksum;
|
||||
union {
|
||||
uint32_t icmp6_un_data32[1];
|
||||
uint16_t icmp6_un_data16[2];
|
||||
uint8_t icmp6_un_data8[4];
|
||||
} icmp6_dataun;
|
||||
};
|
||||
#pragma pack(pop)
|
||||
|
||||
#define icmp6_data32 icmp6_dataun.icmp6_un_data32
|
||||
#define icmp6_mtu icmp6_data32[0]
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Structure of an icmp packet.
|
||||
*
|
||||
* XXX: should start with a struct icmphdr.
|
||||
*/
|
||||
struct icmp {
|
||||
u_char icmp_type; /* type of message, see below */
|
||||
u_char icmp_code; /* type sub code */
|
||||
u_short icmp_cksum; /* ones complement cksum of struct */
|
||||
union {
|
||||
u_char ih_pptr; /* ICMP_PARAMPROB */
|
||||
struct in_addr ih_gwaddr; /* ICMP_REDIRECT */
|
||||
struct ih_idseq {
|
||||
uint16_t icd_id; /* network format */
|
||||
uint16_t icd_seq; /* network format */
|
||||
} ih_idseq;
|
||||
int ih_void;
|
||||
|
||||
/* ICMP_UNREACH_NEEDFRAG -- Path MTU Discovery (RFC1191) */
|
||||
struct ih_pmtu {
|
||||
uint16_t ipm_void; /* network format */
|
||||
uint16_t ipm_nextmtu; /* network format */
|
||||
} ih_pmtu;
|
||||
|
||||
struct ih_rtradv {
|
||||
u_char irt_num_addrs;
|
||||
u_char irt_wpa;
|
||||
uint16_t irt_lifetime;
|
||||
} ih_rtradv;
|
||||
} icmp_hun;
|
||||
#define icmp_pptr icmp_hun.ih_pptr
|
||||
#define icmp_gwaddr icmp_hun.ih_gwaddr
|
||||
#define icmp_id icmp_hun.ih_idseq.icd_id
|
||||
#define icmp_seq icmp_hun.ih_idseq.icd_seq
|
||||
#define icmp_void icmp_hun.ih_void
|
||||
#define icmp_pmvoid icmp_hun.ih_pmtu.ipm_void
|
||||
#define icmp_nextmtu icmp_hun.ih_pmtu.ipm_nextmtu
|
||||
#define icmp_num_addrs icmp_hun.ih_rtradv.irt_num_addrs
|
||||
#define icmp_wpa icmp_hun.ih_rtradv.irt_wpa
|
||||
#define icmp_lifetime icmp_hun.ih_rtradv.irt_lifetime
|
||||
union {
|
||||
struct id_ts { /* ICMP Timestamp */
|
||||
/*
|
||||
* The next 3 fields are in network format,
|
||||
* milliseconds since 00:00 GMT
|
||||
*/
|
||||
uint32_t its_otime; /* Originate */
|
||||
uint32_t its_rtime; /* Receive */
|
||||
uint32_t its_ttime; /* Transmit */
|
||||
} id_ts;
|
||||
struct id_ip {
|
||||
struct ip idi_ip;
|
||||
/* options and then 64 bits of data */
|
||||
} id_ip;
|
||||
struct icmp_ra_addr id_radv;
|
||||
uint32_t id_mask;
|
||||
char id_data[1];
|
||||
} icmp_dun;
|
||||
#define icmp_otime icmp_dun.id_ts.its_otime
|
||||
#define icmp_rtime icmp_dun.id_ts.its_rtime
|
||||
#define icmp_ttime icmp_dun.id_ts.its_ttime
|
||||
#define icmp_ip icmp_dun.id_ip.idi_ip
|
||||
#define icmp_radv icmp_dun.id_radv
|
||||
#define icmp_mask icmp_dun.id_mask
|
||||
#define icmp_data icmp_dun.id_data
|
||||
};
|
||||
|
||||
/*
|
||||
* Lower bounds on packet lengths for various types.
|
||||
* For the error advice packets must first insure that the
|
||||
* packet is large enough to contain the returned ip header.
|
||||
* Only then can we do the check to see if 64 bits of packet
|
||||
* data have been returned, since we need to check the returned
|
||||
* ip header length.
|
||||
*/
|
||||
#define ICMP_MINLEN 8 /* abs minimum */
|
||||
#define ICMP_TSLEN (8 + 3 * sizeof (uint32_t)) /* timestamp */
|
||||
#define ICMP_MASKLEN 12 /* address mask */
|
||||
#define ICMP_ADVLENMIN (8 + sizeof (struct ip) + 8) /* min */
|
||||
#define ICMP_ADVLEN(p) (8 + ((p)->icmp_ip.ip_hl << 2) + 8)
|
||||
/* N.B.: must separately check that ip_hl >= 5 */
|
||||
|
||||
/*
|
||||
* Definition of type and code field values.
|
||||
*/
|
||||
#define ICMP_ECHOREPLY 0 /* echo reply */
|
||||
#define ICMP_UNREACH 3 /* dest unreachable, codes: */
|
||||
#define ICMP_UNREACH_NET 0 /* bad net */
|
||||
#define ICMP_UNREACH_HOST 1 /* bad host */
|
||||
#define ICMP_UNREACH_PROTOCOL 2 /* bad protocol */
|
||||
#define ICMP_UNREACH_PORT 3 /* bad port */
|
||||
#define ICMP_UNREACH_NEEDFRAG 4 /* IP_DF caused drop */
|
||||
#define ICMP_UNREACH_SRCFAIL 5 /* src route failed */
|
||||
#define ICMP_UNREACH_NET_UNKNOWN 6 /* unknown net */
|
||||
#define ICMP_UNREACH_HOST_UNKNOWN 7 /* unknown host */
|
||||
#define ICMP_UNREACH_ISOLATED 8 /* src host isolated */
|
||||
#define ICMP_UNREACH_NET_PROHIB 9 /* prohibited access */
|
||||
#define ICMP_UNREACH_HOST_PROHIB 10 /* ditto */
|
||||
#define ICMP_UNREACH_TOSNET 11 /* bad tos for net */
|
||||
#define ICMP_UNREACH_TOSHOST 12 /* bad tos for host */
|
||||
#define ICMP_UNREACH_FILTER_PROHIB 13 /* admin prohib */
|
||||
#define ICMP_UNREACH_HOST_PRECEDENCE 14 /* host prec vio. */
|
||||
#define ICMP_UNREACH_PRECEDENCE_CUTOFF 15 /* prec cutoff */
|
||||
#define ICMP_SOURCEQUENCH 4 /* packet lost, slow down */
|
||||
#define ICMP_REDIRECT 5 /* shorter route, codes: */
|
||||
#define ICMP_REDIRECT_NET 0 /* for network */
|
||||
#define ICMP_REDIRECT_HOST 1 /* for host */
|
||||
#define ICMP_REDIRECT_TOSNET 2 /* for tos and net */
|
||||
#define ICMP_REDIRECT_TOSHOST 3 /* for tos and host */
|
||||
#define ICMP_ALTHOSTADDR 6 /* alternate host address */
|
||||
#define ICMP_ECHO 8 /* echo service */
|
||||
#define ICMP_ROUTERADVERT 9 /* router advertisement */
|
||||
#define ICMP_ROUTERADVERT_NORMAL 0 /* normal advertisement */
|
||||
#define ICMP_ROUTERADVERT_NOROUTE_COMMON 16 /* selective routing */
|
||||
#define ICMP_ROUTERSOLICIT 10 /* router solicitation */
|
||||
#define ICMP_TIMXCEED 11 /* time exceeded, code: */
|
||||
#define ICMP_TIMXCEED_INTRANS 0 /* ttl==0 in transit */
|
||||
#define ICMP_TIMXCEED_REASS 1 /* ttl==0 in reass */
|
||||
#define ICMP_PARAMPROB 12 /* ip header bad */
|
||||
#define ICMP_PARAMPROB_ERRATPTR 0 /* error at param ptr */
|
||||
#define ICMP_PARAMPROB_OPTABSENT 1 /* req. opt. absent */
|
||||
#define ICMP_PARAMPROB_LENGTH 2 /* bad length */
|
||||
#define ICMP_TSTAMP 13 /* timestamp request */
|
||||
#define ICMP_TSTAMPREPLY 14 /* timestamp reply */
|
||||
#define ICMP_IREQ 15 /* information request */
|
||||
#define ICMP_IREQREPLY 16 /* information reply */
|
||||
#define ICMP_MASKREQ 17 /* address mask request */
|
||||
#define ICMP_MASKREPLY 18 /* address mask reply */
|
||||
#define ICMP_TRACEROUTE 30 /* traceroute */
|
||||
#define ICMP_DATACONVERR 31 /* data conversion error */
|
||||
#define ICMP_MOBILE_REDIRECT 32 /* mobile host redirect */
|
||||
#define ICMP_IPV6_WHEREAREYOU 33 /* IPv6 where-are-you */
|
||||
#define ICMP_IPV6_IAMHERE 34 /* IPv6 i-am-here */
|
||||
#define ICMP_MOBILE_REGREQUEST 35 /* mobile registration req */
|
||||
#define ICMP_MOBILE_REGREPLY 36 /* mobile registration reply */
|
||||
#define ICMP_SKIP 39 /* SKIP */
|
||||
#define ICMP_PHOTURIS 40 /* Photuris */
|
||||
#define ICMP_PHOTURIS_UNKNOWN_INDEX 1 /* unknown sec index */
|
||||
#define ICMP_PHOTURIS_AUTH_FAILED 2 /* auth failed */
|
||||
#define ICMP_PHOTURIS_DECRYPT_FAILED 3 /* decrypt failed */
|
||||
|
||||
#define ICMP_MAXTYPE 40
|
||||
|
||||
#define ICMP_INFOTYPE(type) \
|
||||
((type) == ICMP_ECHOREPLY || (type) == ICMP_ECHO || \
|
||||
(type) == ICMP_ROUTERADVERT || (type) == ICMP_ROUTERSOLICIT || \
|
||||
(type) == ICMP_TSTAMP || (type) == ICMP_TSTAMPREPLY || \
|
||||
(type) == ICMP_IREQ || (type) == ICMP_IREQREPLY || \
|
||||
(type) == ICMP_MASKREQ || (type) == ICMP_MASKREPLY)
|
||||
|
||||
|
||||
#endif
|
||||
203
TMessagesProj/jni/third_party/usrsctplib/user_malloc.h
vendored
Executable file
203
TMessagesProj/jni/third_party/usrsctplib/user_malloc.h
vendored
Executable file
|
|
@ -0,0 +1,203 @@
|
|||
/*-
|
||||
* Copyright (c) 1987, 1993
|
||||
* The Regents of the University of California.
|
||||
* Copyright (c) 2005 Robert N. M. Watson
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. 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.
|
||||
* 3. Neither the name of the University 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 REGENTS 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 REGENTS 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.
|
||||
*
|
||||
*/
|
||||
|
||||
/* This file has been renamed user_malloc.h for Userspace */
|
||||
#ifndef _USER_MALLOC_H_
|
||||
#define _USER_MALLOC_H_
|
||||
|
||||
/*__Userspace__*/
|
||||
#include <stdlib.h>
|
||||
#include <sys/types.h>
|
||||
#if !defined(_WIN32)
|
||||
#include <strings.h>
|
||||
#include <stdint.h>
|
||||
#else
|
||||
#if (defined(_MSC_VER) && _MSC_VER >= 1600) || (defined(__MSVCRT_VERSION__) && __MSVCRT_VERSION__ >= 1400)
|
||||
#include <stdint.h>
|
||||
#elif defined(SCTP_STDINT_INCLUDE)
|
||||
#include SCTP_STDINT_INCLUDE
|
||||
#else
|
||||
#define uint32_t unsigned __int32
|
||||
#define uint64_t unsigned __int64
|
||||
#endif
|
||||
#include <winsock2.h>
|
||||
#endif
|
||||
|
||||
#define MINALLOCSIZE UMA_SMALLEST_UNIT
|
||||
|
||||
/*
|
||||
* flags to malloc.
|
||||
*/
|
||||
#define M_NOWAIT 0x0001 /* do not block */
|
||||
#define M_WAITOK 0x0002 /* ok to block */
|
||||
#define M_ZERO 0x0100 /* bzero the allocation */
|
||||
#define M_NOVM 0x0200 /* don't ask VM for pages */
|
||||
#define M_USE_RESERVE 0x0400 /* can alloc out of reserve memory */
|
||||
|
||||
#define M_MAGIC 877983977 /* time when first defined :-) */
|
||||
|
||||
/*
|
||||
* Two malloc type structures are present: malloc_type, which is used by a
|
||||
* type owner to declare the type, and malloc_type_internal, which holds
|
||||
* malloc-owned statistics and other ABI-sensitive fields, such as the set of
|
||||
* malloc statistics indexed by the compile-time MAXCPU constant.
|
||||
* Applications should avoid introducing dependence on the allocator private
|
||||
* data layout and size.
|
||||
*
|
||||
* The malloc_type ks_next field is protected by malloc_mtx. Other fields in
|
||||
* malloc_type are static after initialization so unsynchronized.
|
||||
*
|
||||
* Statistics in malloc_type_stats are written only when holding a critical
|
||||
* section and running on the CPU associated with the index into the stat
|
||||
* array, but read lock-free resulting in possible (minor) races, which the
|
||||
* monitoring app should take into account.
|
||||
*/
|
||||
struct malloc_type_stats {
|
||||
uint64_t mts_memalloced; /* Bytes allocated on CPU. */
|
||||
uint64_t mts_memfreed; /* Bytes freed on CPU. */
|
||||
uint64_t mts_numallocs; /* Number of allocates on CPU. */
|
||||
uint64_t mts_numfrees; /* number of frees on CPU. */
|
||||
uint64_t mts_size; /* Bitmask of sizes allocated on CPU. */
|
||||
uint64_t _mts_reserved1; /* Reserved field. */
|
||||
uint64_t _mts_reserved2; /* Reserved field. */
|
||||
uint64_t _mts_reserved3; /* Reserved field. */
|
||||
};
|
||||
|
||||
#ifndef MAXCPU /* necessary on Linux */
|
||||
#define MAXCPU 4 /* arbitrary? */
|
||||
#endif
|
||||
|
||||
struct malloc_type_internal {
|
||||
struct malloc_type_stats mti_stats[MAXCPU];
|
||||
};
|
||||
|
||||
/*
|
||||
* ABI-compatible version of the old 'struct malloc_type', only all stats are
|
||||
* now malloc-managed in malloc-owned memory rather than in caller memory, so
|
||||
* as to avoid ABI issues. The ks_next pointer is reused as a pointer to the
|
||||
* internal data handle.
|
||||
*/
|
||||
struct malloc_type {
|
||||
struct malloc_type *ks_next; /* Next in global chain. */
|
||||
u_long _ks_memuse; /* No longer used. */
|
||||
u_long _ks_size; /* No longer used. */
|
||||
u_long _ks_inuse; /* No longer used. */
|
||||
uint64_t _ks_calls; /* No longer used. */
|
||||
u_long _ks_maxused; /* No longer used. */
|
||||
u_long ks_magic; /* Detect programmer error. */
|
||||
const char *ks_shortdesc; /* Printable type name. */
|
||||
|
||||
/*
|
||||
* struct malloc_type was terminated with a struct mtx, which is no
|
||||
* longer required. For ABI reasons, continue to flesh out the full
|
||||
* size of the old structure, but reuse the _lo_class field for our
|
||||
* internal data handle.
|
||||
*/
|
||||
void *ks_handle; /* Priv. data, was lo_class. */
|
||||
const char *_lo_name;
|
||||
const char *_lo_type;
|
||||
u_int _lo_flags;
|
||||
void *_lo_list_next;
|
||||
struct witness *_lo_witness;
|
||||
uintptr_t _mtx_lock;
|
||||
u_int _mtx_recurse;
|
||||
};
|
||||
|
||||
/*
|
||||
* Statistics structure headers for user space. The kern.malloc sysctl
|
||||
* exposes a structure stream consisting of a stream header, then a series of
|
||||
* malloc type headers and statistics structures (quantity maxcpus). For
|
||||
* convenience, the kernel will provide the current value of maxcpus at the
|
||||
* head of the stream.
|
||||
*/
|
||||
#define MALLOC_TYPE_STREAM_VERSION 0x00000001
|
||||
struct malloc_type_stream_header {
|
||||
uint32_t mtsh_version; /* Stream format version. */
|
||||
uint32_t mtsh_maxcpus; /* Value of MAXCPU for stream. */
|
||||
uint32_t mtsh_count; /* Number of records. */
|
||||
uint32_t _mtsh_pad; /* Pad/reserved field. */
|
||||
};
|
||||
|
||||
#define MALLOC_MAX_NAME 32
|
||||
struct malloc_type_header {
|
||||
char mth_name[MALLOC_MAX_NAME];
|
||||
};
|
||||
|
||||
/* __Userspace__
|
||||
Notice that at places it uses ifdef _KERNEL. That line cannot be
|
||||
removed because it causes conflicts with malloc definition in
|
||||
/usr/include/malloc.h, which essentially says that malloc.h has
|
||||
been overridden by stdlib.h. We will need to use names like
|
||||
user_malloc.h for isolating kernel interface headers. using
|
||||
original names like malloc.h in a user_include header can be
|
||||
confusing, All userspace header files are being placed in ./user_include
|
||||
Better still to remove from user_include.h all irrelevant code such
|
||||
as that in the block starting with #ifdef _KERNEL. I am only leaving
|
||||
it in for the time being to see what functionality is in this file
|
||||
that kernel uses.
|
||||
|
||||
Start copy: Copied code for __Userspace__ */
|
||||
#define MALLOC_DEFINE(type, shortdesc, longdesc) \
|
||||
struct malloc_type type[1] = { \
|
||||
{ NULL, 0, 0, 0, 0, 0, M_MAGIC, shortdesc, NULL, NULL, \
|
||||
NULL, 0, NULL, NULL, 0, 0 } \
|
||||
}
|
||||
|
||||
/* Removed "extern" in __Userspace__ code */
|
||||
/* If we need to use MALLOC_DECLARE before using MALLOC then
|
||||
we have to remove extern.
|
||||
In /usr/include/sys/malloc.h there is this definition:
|
||||
#define MALLOC_DECLARE(type) \
|
||||
extern struct malloc_type type[1]
|
||||
and loader is unable to find the extern malloc_type because
|
||||
it may be defined in one of kernel object files.
|
||||
It seems that MALLOC_DECLARE and MALLOC_DEFINE cannot be used at
|
||||
the same time for same "type" variable. Also, in Randall's architecture
|
||||
document, where it specifies O/S specific macros and functions, it says
|
||||
that the name in SCTP_MALLOC does not have to be used.
|
||||
*/
|
||||
#define MALLOC_DECLARE(type) \
|
||||
extern struct malloc_type type[1]
|
||||
|
||||
#define FREE(addr, type) free((addr))
|
||||
|
||||
/* changed definitions of MALLOC and FREE */
|
||||
/* Using memset if flag M_ZERO is specified. Todo: M_WAITOK and M_NOWAIT */
|
||||
#define MALLOC(space, cast, size, type, flags) \
|
||||
((space) = (cast)malloc((u_long)(size))); \
|
||||
do { \
|
||||
if (flags & M_ZERO) { \
|
||||
memset(space,0,size); \
|
||||
} \
|
||||
} while (0);
|
||||
|
||||
#endif /* !_SYS_MALLOC_H_ */
|
||||
1557
TMessagesProj/jni/third_party/usrsctplib/user_mbuf.c
vendored
Executable file
1557
TMessagesProj/jni/third_party/usrsctplib/user_mbuf.c
vendored
Executable file
File diff suppressed because it is too large
Load diff
407
TMessagesProj/jni/third_party/usrsctplib/user_mbuf.h
vendored
Executable file
407
TMessagesProj/jni/third_party/usrsctplib/user_mbuf.h
vendored
Executable file
|
|
@ -0,0 +1,407 @@
|
|||
/*-
|
||||
* Copyright (c) 1982, 1986, 1988, 1993
|
||||
* The Regents of the University of California.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. 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.
|
||||
* 3. Neither the name of the University 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 REGENTS 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 REGENTS 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _USER_MBUF_H_
|
||||
#define _USER_MBUF_H_
|
||||
|
||||
/* __Userspace__ header file for mbufs */
|
||||
#include <stdio.h>
|
||||
#if !defined(SCTP_SIMPLE_ALLOCATOR)
|
||||
#include "umem.h"
|
||||
#endif
|
||||
#include "user_malloc.h"
|
||||
#include "netinet/sctp_os_userspace.h"
|
||||
|
||||
#define USING_MBUF_CONSTRUCTOR 0
|
||||
|
||||
/* For Linux */
|
||||
#ifndef MSIZE
|
||||
#define MSIZE 256
|
||||
/* #define MSIZE 1024 */
|
||||
#endif
|
||||
#ifndef MCLBYTES
|
||||
#define MCLBYTES 2048
|
||||
#endif
|
||||
|
||||
struct mbuf * m_gethdr(int how, short type);
|
||||
struct mbuf * m_get(int how, short type);
|
||||
struct mbuf * m_free(struct mbuf *m);
|
||||
void m_clget(struct mbuf *m, int how);
|
||||
struct mbuf * m_getm2(struct mbuf *m, int len, int how, short type, int flags, int allonebuf);
|
||||
struct mbuf *m_uiotombuf(struct uio *uio, int how, int len, int align, int flags);
|
||||
u_int m_length(struct mbuf *m0, struct mbuf **last);
|
||||
struct mbuf *m_last(struct mbuf *m);
|
||||
|
||||
/* mbuf initialization function */
|
||||
void mbuf_initialize(void *);
|
||||
|
||||
#define M_MOVE_PKTHDR(to, from) m_move_pkthdr((to), (from))
|
||||
#define MGET(m, how, type) ((m) = m_get((how), (type)))
|
||||
#define MGETHDR(m, how, type) ((m) = m_gethdr((how), (type)))
|
||||
#define MCLGET(m, how) m_clget((m), (how))
|
||||
|
||||
|
||||
#define M_HDR_PAD ((sizeof(intptr_t)==4) ? 2 : 6) /* modified for __Userspace__ */
|
||||
|
||||
/* Length to m_copy to copy all. */
|
||||
#define M_COPYALL 1000000000
|
||||
|
||||
/* umem_cache_t is defined in user_include/umem.h as
|
||||
* typedef struct umem_cache umem_cache_t;
|
||||
* Note:umem_zone_t is a pointer.
|
||||
*/
|
||||
#if defined(SCTP_SIMPLE_ALLOCATOR)
|
||||
typedef size_t sctp_zone_t;
|
||||
#else
|
||||
typedef umem_cache_t *sctp_zone_t;
|
||||
#endif
|
||||
|
||||
extern sctp_zone_t zone_mbuf;
|
||||
extern sctp_zone_t zone_clust;
|
||||
extern sctp_zone_t zone_ext_refcnt;
|
||||
|
||||
/*-
|
||||
* Macros for type conversion:
|
||||
* mtod(m, t) -- Convert mbuf pointer to data pointer of correct type.
|
||||
* dtom(x) -- Convert data pointer within mbuf to mbuf pointer (XXX).
|
||||
*/
|
||||
#define mtod(m, t) ((t)((m)->m_data))
|
||||
#define dtom(x) ((struct mbuf *)((intptr_t)(x) & ~(MSIZE-1)))
|
||||
|
||||
struct mb_args {
|
||||
int flags; /* Flags for mbuf being allocated */
|
||||
short type; /* Type of mbuf being allocated */
|
||||
};
|
||||
|
||||
struct clust_args {
|
||||
struct mbuf * parent_mbuf;
|
||||
};
|
||||
|
||||
struct mbuf * m_split(struct mbuf *, int, int);
|
||||
void m_cat(struct mbuf *m, struct mbuf *n);
|
||||
void m_adj(struct mbuf *, int);
|
||||
void mb_free_ext(struct mbuf *);
|
||||
void m_freem(struct mbuf *);
|
||||
struct m_tag *m_tag_alloc(uint32_t, int, int, int);
|
||||
struct mbuf *m_copym(struct mbuf *, int, int, int);
|
||||
void m_copyback(struct mbuf *, int, int, caddr_t);
|
||||
struct mbuf *m_pullup(struct mbuf *, int);
|
||||
struct mbuf *m_pulldown(struct mbuf *, int off, int len, int *offp);
|
||||
int m_dup_pkthdr(struct mbuf *, struct mbuf *, int);
|
||||
struct m_tag *m_tag_copy(struct m_tag *, int);
|
||||
int m_tag_copy_chain(struct mbuf *, struct mbuf *, int);
|
||||
struct mbuf *m_prepend(struct mbuf *, int, int);
|
||||
void m_copydata(const struct mbuf *, int, int, caddr_t);
|
||||
|
||||
#define MBUF_MEM_NAME "mbuf"
|
||||
#define MBUF_CLUSTER_MEM_NAME "mbuf_cluster"
|
||||
#define MBUF_EXTREFCNT_MEM_NAME "mbuf_ext_refcnt"
|
||||
|
||||
/*
|
||||
* Mbufs are of a single size, MSIZE (sys/param.h), which includes overhead.
|
||||
* An mbuf may add a single "mbuf cluster" of size MCLBYTES (also in
|
||||
* sys/param.h), which has no additional overhead and is used instead of the
|
||||
* internal data area; this is done when at least MINCLSIZE of data must be
|
||||
* stored. Additionally, it is possible to allocate a separate buffer
|
||||
* externally and attach it to the mbuf in a way similar to that of mbuf
|
||||
* clusters.
|
||||
*/
|
||||
#define MLEN ((int)(MSIZE - sizeof(struct m_hdr))) /* normal data len */
|
||||
#define MHLEN ((int)(MLEN - sizeof(struct pkthdr))) /* data len w/pkthdr */
|
||||
#define MINCLSIZE ((int)(MHLEN + 1)) /* smallest amount to put in cluster */
|
||||
#define M_MAXCOMPRESS (MHLEN / 2) /* max amount to copy for compression */
|
||||
|
||||
|
||||
/*
|
||||
* Header present at the beginning of every mbuf.
|
||||
*/
|
||||
struct m_hdr {
|
||||
struct mbuf *mh_next; /* next buffer in chain */
|
||||
struct mbuf *mh_nextpkt; /* next chain in queue/record */
|
||||
caddr_t mh_data; /* location of data */
|
||||
int mh_len; /* amount of data in this mbuf */
|
||||
int mh_flags; /* flags; see below */
|
||||
short mh_type; /* type of data in this mbuf */
|
||||
uint8_t pad[M_HDR_PAD];/* word align */
|
||||
};
|
||||
|
||||
/*
|
||||
* Packet tag structure (see below for details).
|
||||
*/
|
||||
struct m_tag {
|
||||
SLIST_ENTRY(m_tag) m_tag_link; /* List of packet tags */
|
||||
uint16_t m_tag_id; /* Tag ID */
|
||||
uint16_t m_tag_len; /* Length of data */
|
||||
uint32_t m_tag_cookie; /* ABI/Module ID */
|
||||
void (*m_tag_free)(struct m_tag *);
|
||||
};
|
||||
|
||||
/*
|
||||
* Record/packet header in first mbuf of chain; valid only if M_PKTHDR is set.
|
||||
*/
|
||||
struct pkthdr {
|
||||
struct ifnet *rcvif; /* rcv interface */
|
||||
/* variables for ip and tcp reassembly */
|
||||
void *header; /* pointer to packet header */
|
||||
int len; /* total packet length */
|
||||
/* variables for hardware checksum */
|
||||
int csum_flags; /* flags regarding checksum */
|
||||
int csum_data; /* data field used by csum routines */
|
||||
uint16_t tso_segsz; /* TSO segment size */
|
||||
uint16_t ether_vtag; /* Ethernet 802.1p+q vlan tag */
|
||||
SLIST_HEAD(packet_tags, m_tag) tags; /* list of packet tags */
|
||||
};
|
||||
|
||||
/*
|
||||
* Description of external storage mapped into mbuf; valid only if M_EXT is
|
||||
* set.
|
||||
*/
|
||||
struct m_ext {
|
||||
caddr_t ext_buf; /* start of buffer */
|
||||
void (*ext_free) /* free routine if not the usual */
|
||||
(void *, void *);
|
||||
void *ext_args; /* optional argument pointer */
|
||||
u_int ext_size; /* size of buffer, for ext_free */
|
||||
volatile u_int *ref_cnt; /* pointer to ref count info */
|
||||
int ext_type; /* type of external storage */
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
* The core of the mbuf object along with some shortcut defined for practical
|
||||
* purposes.
|
||||
*/
|
||||
struct mbuf {
|
||||
struct m_hdr m_hdr;
|
||||
union {
|
||||
struct {
|
||||
struct pkthdr MH_pkthdr; /* M_PKTHDR set */
|
||||
union {
|
||||
struct m_ext MH_ext; /* M_EXT set */
|
||||
char MH_databuf[MHLEN];
|
||||
} MH_dat;
|
||||
} MH;
|
||||
char M_databuf[MLEN]; /* !M_PKTHDR, !M_EXT */
|
||||
} M_dat;
|
||||
};
|
||||
|
||||
#define m_next m_hdr.mh_next
|
||||
#define m_len m_hdr.mh_len
|
||||
#define m_data m_hdr.mh_data
|
||||
#define m_type m_hdr.mh_type
|
||||
#define m_flags m_hdr.mh_flags
|
||||
#define m_nextpkt m_hdr.mh_nextpkt
|
||||
#define m_act m_nextpkt
|
||||
#define m_pkthdr M_dat.MH.MH_pkthdr
|
||||
#define m_ext M_dat.MH.MH_dat.MH_ext
|
||||
#define m_pktdat M_dat.MH.MH_dat.MH_databuf
|
||||
#define m_dat M_dat.M_databuf
|
||||
|
||||
|
||||
/*
|
||||
* mbuf flags.
|
||||
*/
|
||||
#define M_EXT 0x0001 /* has associated external storage */
|
||||
#define M_PKTHDR 0x0002 /* start of record */
|
||||
#define M_EOR 0x0004 /* end of record */
|
||||
#define M_RDONLY 0x0008 /* associated data is marked read-only */
|
||||
#define M_PROTO1 0x0010 /* protocol-specific */
|
||||
#define M_PROTO2 0x0020 /* protocol-specific */
|
||||
#define M_PROTO3 0x0040 /* protocol-specific */
|
||||
#define M_PROTO4 0x0080 /* protocol-specific */
|
||||
#define M_PROTO5 0x0100 /* protocol-specific */
|
||||
#define M_FREELIST 0x8000 /* mbuf is on the free list */
|
||||
|
||||
|
||||
/*
|
||||
* Flags copied when copying m_pkthdr.
|
||||
*/
|
||||
#define M_COPYFLAGS (M_PKTHDR|M_EOR|M_RDONLY|M_PROTO1|M_PROTO1|M_PROTO2|\
|
||||
M_PROTO3|M_PROTO4|M_PROTO5|\
|
||||
M_BCAST|M_MCAST|M_FRAG|M_FIRSTFRAG|M_LASTFRAG|\
|
||||
M_VLANTAG|M_PROMISC)
|
||||
|
||||
|
||||
/*
|
||||
* mbuf pkthdr flags (also stored in m_flags).
|
||||
*/
|
||||
#define M_BCAST 0x0200 /* send/received as link-level broadcast */
|
||||
#define M_MCAST 0x0400 /* send/received as link-level multicast */
|
||||
#define M_FRAG 0x0800 /* packet is a fragment of a larger packet */
|
||||
#define M_FIRSTFRAG 0x1000 /* packet is first fragment */
|
||||
#define M_LASTFRAG 0x2000 /* packet is last fragment */
|
||||
#define M_VLANTAG 0x10000 /* ether_vtag is valid */
|
||||
#define M_PROMISC 0x20000 /* packet was not for us */
|
||||
#define M_NOFREE 0x40000 /* do not free mbuf - it is embedded in the cluster */
|
||||
|
||||
|
||||
/*
|
||||
* External buffer types: identify ext_buf type.
|
||||
*/
|
||||
#define EXT_CLUSTER 1 /* mbuf cluster */
|
||||
#define EXT_SFBUF 2 /* sendfile(2)'s sf_bufs */
|
||||
#define EXT_JUMBOP 3 /* jumbo cluster 4096 bytes */
|
||||
#define EXT_JUMBO9 4 /* jumbo cluster 9216 bytes */
|
||||
#define EXT_JUMBO16 5 /* jumbo cluster 16184 bytes */
|
||||
#define EXT_PACKET 6 /* mbuf+cluster from packet zone */
|
||||
#define EXT_MBUF 7 /* external mbuf reference (M_IOVEC) */
|
||||
#define EXT_NET_DRV 100 /* custom ext_buf provided by net driver(s) */
|
||||
#define EXT_MOD_TYPE 200 /* custom module's ext_buf type */
|
||||
#define EXT_DISPOSABLE 300 /* can throw this buffer away w/page flipping */
|
||||
#define EXT_EXTREF 400 /* has externally maintained ref_cnt ptr */
|
||||
|
||||
|
||||
/*
|
||||
* mbuf types.
|
||||
*/
|
||||
#define MT_NOTMBUF 0 /* USED INTERNALLY ONLY! Object is not mbuf */
|
||||
#define MT_DATA 1 /* dynamic (data) allocation */
|
||||
#define MT_HEADER MT_DATA /* packet header, use M_PKTHDR instead */
|
||||
#define MT_SONAME 8 /* socket name */
|
||||
#define MT_CONTROL 14 /* extra-data protocol message */
|
||||
#define MT_OOBDATA 15 /* expedited data */
|
||||
#define MT_NTYPES 16 /* number of mbuf types for mbtypes[] */
|
||||
|
||||
/*
|
||||
* __Userspace__ flags like M_NOWAIT are defined in malloc.h
|
||||
* Flags like these are used in functions like uma_zalloc()
|
||||
* but don't have an equivalent in userland umem
|
||||
* Flags specifying how an allocation should be made.
|
||||
*
|
||||
* The flag to use is as follows:
|
||||
* - M_DONTWAIT or M_NOWAIT from an interrupt handler to not block allocation.
|
||||
* - M_WAIT or M_WAITOK or M_TRYWAIT from wherever it is safe to block.
|
||||
*
|
||||
* M_DONTWAIT/M_NOWAIT means that we will not block the thread explicitly and
|
||||
* if we cannot allocate immediately we may return NULL, whereas
|
||||
* M_WAIT/M_WAITOK/M_TRYWAIT means that if we cannot allocate resources we
|
||||
* will block until they are available, and thus never return NULL.
|
||||
*
|
||||
* XXX Eventually just phase this out to use M_WAITOK/M_NOWAIT.
|
||||
*/
|
||||
#define MBTOM(how) (how)
|
||||
|
||||
void m_tag_delete(struct mbuf *, struct m_tag *);
|
||||
void m_tag_delete_chain(struct mbuf *, struct m_tag *);
|
||||
void m_move_pkthdr(struct mbuf *, struct mbuf *);
|
||||
void m_tag_free_default(struct m_tag *);
|
||||
|
||||
extern int max_linkhdr; /* Largest link-level header */
|
||||
extern int max_protohdr; /* Size of largest protocol layer header. See user_mbuf.c */
|
||||
|
||||
/*
|
||||
* Evaluate TRUE if it's safe to write to the mbuf m's data region (this can
|
||||
* be both the local data payload, or an external buffer area, depending on
|
||||
* whether M_EXT is set).
|
||||
*/
|
||||
#define M_WRITABLE(m) (!((m)->m_flags & M_RDONLY) && \
|
||||
(!(((m)->m_flags & M_EXT)) || \
|
||||
(*((m)->m_ext.ref_cnt) == 1)) ) \
|
||||
|
||||
|
||||
/*
|
||||
* Compute the amount of space available before the current start of data in
|
||||
* an mbuf.
|
||||
*
|
||||
* The M_WRITABLE() is a temporary, conservative safety measure: the burden
|
||||
* of checking writability of the mbuf data area rests solely with the caller.
|
||||
*/
|
||||
#define M_LEADINGSPACE(m) \
|
||||
(((m)->m_flags & M_EXT) ? \
|
||||
(M_WRITABLE(m) ? (m)->m_data - (m)->m_ext.ext_buf : 0): \
|
||||
((m)->m_flags & M_PKTHDR)? (m)->m_data - (m)->m_pktdat : \
|
||||
(m)->m_data - (m)->m_dat)
|
||||
|
||||
/*
|
||||
* Compute the amount of space available after the end of data in an mbuf.
|
||||
*
|
||||
* The M_WRITABLE() is a temporary, conservative safety measure: the burden
|
||||
* of checking writability of the mbuf data area rests solely with the caller.
|
||||
*/
|
||||
#define M_TRAILINGSPACE(m) \
|
||||
(((m)->m_flags & M_EXT) ? \
|
||||
(M_WRITABLE(m) ? (m)->m_ext.ext_buf + (m)->m_ext.ext_size \
|
||||
- ((m)->m_data + (m)->m_len) : 0) : \
|
||||
&(m)->m_dat[MLEN] - ((m)->m_data + (m)->m_len))
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Arrange to prepend space of size plen to mbuf m. If a new mbuf must be
|
||||
* allocated, how specifies whether to wait. If the allocation fails, the
|
||||
* original mbuf chain is freed and m is set to NULL.
|
||||
*/
|
||||
#define M_PREPEND(m, plen, how) do { \
|
||||
struct mbuf **_mmp = &(m); \
|
||||
struct mbuf *_mm = *_mmp; \
|
||||
int _mplen = (plen); \
|
||||
int __mhow = (how); \
|
||||
\
|
||||
if (M_LEADINGSPACE(_mm) >= _mplen) { \
|
||||
_mm->m_data -= _mplen; \
|
||||
_mm->m_len += _mplen; \
|
||||
} else \
|
||||
_mm = m_prepend(_mm, _mplen, __mhow); \
|
||||
if (_mm != NULL && _mm->m_flags & M_PKTHDR) \
|
||||
_mm->m_pkthdr.len += _mplen; \
|
||||
*_mmp = _mm; \
|
||||
} while (0)
|
||||
|
||||
/*
|
||||
* Set the m_data pointer of a newly-allocated mbuf (m_get/MGET) to place an
|
||||
* object of the specified size at the end of the mbuf, longword aligned.
|
||||
*/
|
||||
#define M_ALIGN(m, len) do { \
|
||||
KASSERT(!((m)->m_flags & (M_PKTHDR|M_EXT)), \
|
||||
("%s: M_ALIGN not normal mbuf", __func__)); \
|
||||
KASSERT((m)->m_data == (m)->m_dat, \
|
||||
("%s: M_ALIGN not a virgin mbuf", __func__)); \
|
||||
(m)->m_data += (MLEN - (len)) & ~(sizeof(long) - 1); \
|
||||
} while (0)
|
||||
|
||||
/*
|
||||
* As above, for mbufs allocated with m_gethdr/MGETHDR or initialized by
|
||||
* M_DUP/MOVE_PKTHDR.
|
||||
*/
|
||||
#define MH_ALIGN(m, len) do { \
|
||||
KASSERT((m)->m_flags & M_PKTHDR && !((m)->m_flags & M_EXT), \
|
||||
("%s: MH_ALIGN not PKTHDR mbuf", __func__)); \
|
||||
KASSERT((m)->m_data == (m)->m_pktdat, \
|
||||
("%s: MH_ALIGN not a virgin mbuf", __func__)); \
|
||||
(m)->m_data += (MHLEN - (len)) & ~(sizeof(long) - 1); \
|
||||
} while (0)
|
||||
|
||||
#define M_SIZE(m) \
|
||||
(((m)->m_flags & M_EXT) ? (m)->m_ext.ext_size : \
|
||||
((m)->m_flags & M_PKTHDR) ? MHLEN : \
|
||||
MLEN)
|
||||
|
||||
#endif
|
||||
639
TMessagesProj/jni/third_party/usrsctplib/user_queue.h
vendored
Executable file
639
TMessagesProj/jni/third_party/usrsctplib/user_queue.h
vendored
Executable file
|
|
@ -0,0 +1,639 @@
|
|||
/*-
|
||||
* Copyright (c) 1991, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. 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.
|
||||
* 3. Neither the name of the University 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 REGENTS 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 REGENTS 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _USER_QUEUE_H_
|
||||
#define _USER_QUEUE_H_
|
||||
|
||||
/*
|
||||
* This file defines four types of data structures: singly-linked lists,
|
||||
* singly-linked tail queues, lists and tail queues.
|
||||
*
|
||||
* A singly-linked list is headed by a single forward pointer. The elements
|
||||
* are singly linked for minimum space and pointer manipulation overhead at
|
||||
* the expense of O(n) removal for arbitrary elements. New elements can be
|
||||
* added to the list after an existing element or at the head of the list.
|
||||
* Elements being removed from the head of the list should use the explicit
|
||||
* macro for this purpose for optimum efficiency. A singly-linked list may
|
||||
* only be traversed in the forward direction. Singly-linked lists are ideal
|
||||
* for applications with large datasets and few or no removals or for
|
||||
* implementing a LIFO queue.
|
||||
*
|
||||
* A singly-linked tail queue is headed by a pair of pointers, one to the
|
||||
* head of the list and the other to the tail of the list. The elements are
|
||||
* singly linked for minimum space and pointer manipulation overhead at the
|
||||
* expense of O(n) removal for arbitrary elements. New elements can be added
|
||||
* to the list after an existing element, at the head of the list, or at the
|
||||
* end of the list. Elements being removed from the head of the tail queue
|
||||
* should use the explicit macro for this purpose for optimum efficiency.
|
||||
* A singly-linked tail queue may only be traversed in the forward direction.
|
||||
* Singly-linked tail queues are ideal for applications with large datasets
|
||||
* and few or no removals or for implementing a FIFO queue.
|
||||
*
|
||||
* A list is headed by a single forward pointer (or an array of forward
|
||||
* pointers for a hash table header). The elements are doubly linked
|
||||
* so that an arbitrary element can be removed without a need to
|
||||
* traverse the list. New elements can be added to the list before
|
||||
* or after an existing element or at the head of the list. A list
|
||||
* may only be traversed in the forward direction.
|
||||
*
|
||||
* A tail queue is headed by a pair of pointers, one to the head of the
|
||||
* list and the other to the tail of the list. The elements are doubly
|
||||
* linked so that an arbitrary element can be removed without a need to
|
||||
* traverse the list. New elements can be added to the list before or
|
||||
* after an existing element, at the head of the list, or at the end of
|
||||
* the list. A tail queue may be traversed in either direction.
|
||||
*
|
||||
* For details on the use of these macros, see the queue(3) manual page.
|
||||
*
|
||||
*
|
||||
* SLIST LIST STAILQ TAILQ
|
||||
* _HEAD + + + +
|
||||
* _HEAD_INITIALIZER + + + +
|
||||
* _ENTRY + + + +
|
||||
* _INIT + + + +
|
||||
* _EMPTY + + + +
|
||||
* _FIRST + + + +
|
||||
* _NEXT + + + +
|
||||
* _PREV - - - +
|
||||
* _LAST - - + +
|
||||
* _FOREACH + + + +
|
||||
* _FOREACH_SAFE + + + +
|
||||
* _FOREACH_REVERSE - - - +
|
||||
* _FOREACH_REVERSE_SAFE - - - +
|
||||
* _INSERT_HEAD + + + +
|
||||
* _INSERT_BEFORE - + - +
|
||||
* _INSERT_AFTER + + + +
|
||||
* _INSERT_TAIL - - + +
|
||||
* _CONCAT - - + +
|
||||
* _REMOVE_AFTER + - + -
|
||||
* _REMOVE_HEAD + - + -
|
||||
* _REMOVE + + + +
|
||||
* _SWAP + + + +
|
||||
*
|
||||
*/
|
||||
#ifdef QUEUE_MACRO_DEBUG
|
||||
/* Store the last 2 places the queue element or head was altered */
|
||||
struct qm_trace {
|
||||
char * lastfile;
|
||||
int lastline;
|
||||
char * prevfile;
|
||||
int prevline;
|
||||
};
|
||||
|
||||
#define TRACEBUF struct qm_trace trace;
|
||||
#define TRASHIT(x) do {(x) = (void *)-1;} while (0)
|
||||
#define QMD_SAVELINK(name, link) void **name = (void *)&(link)
|
||||
|
||||
#define QMD_TRACE_HEAD(head) do { \
|
||||
(head)->trace.prevline = (head)->trace.lastline; \
|
||||
(head)->trace.prevfile = (head)->trace.lastfile; \
|
||||
(head)->trace.lastline = __LINE__; \
|
||||
(head)->trace.lastfile = __FILE__; \
|
||||
} while (0)
|
||||
|
||||
#define QMD_TRACE_ELEM(elem) do { \
|
||||
(elem)->trace.prevline = (elem)->trace.lastline; \
|
||||
(elem)->trace.prevfile = (elem)->trace.lastfile; \
|
||||
(elem)->trace.lastline = __LINE__; \
|
||||
(elem)->trace.lastfile = __FILE__; \
|
||||
} while (0)
|
||||
|
||||
#else
|
||||
#define QMD_TRACE_ELEM(elem)
|
||||
#define QMD_TRACE_HEAD(head)
|
||||
#define QMD_SAVELINK(name, link)
|
||||
#define TRACEBUF
|
||||
#define TRASHIT(x)
|
||||
#endif /* QUEUE_MACRO_DEBUG */
|
||||
|
||||
/*
|
||||
* Singly-linked List declarations.
|
||||
*/
|
||||
#define SLIST_HEAD(name, type) \
|
||||
struct name { \
|
||||
struct type *slh_first; /* first element */ \
|
||||
}
|
||||
|
||||
#define SLIST_HEAD_INITIALIZER(head) \
|
||||
{ NULL }
|
||||
|
||||
#if defined(_WIN32)
|
||||
#if defined(SLIST_ENTRY)
|
||||
#undef SLIST_ENTRY
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define SLIST_ENTRY(type) \
|
||||
struct { \
|
||||
struct type *sle_next; /* next element */ \
|
||||
}
|
||||
|
||||
/*
|
||||
* Singly-linked List functions.
|
||||
*/
|
||||
#define SLIST_EMPTY(head) ((head)->slh_first == NULL)
|
||||
|
||||
#define SLIST_FIRST(head) ((head)->slh_first)
|
||||
|
||||
#define SLIST_FOREACH(var, head, field) \
|
||||
for ((var) = SLIST_FIRST((head)); \
|
||||
(var); \
|
||||
(var) = SLIST_NEXT((var), field))
|
||||
|
||||
#define SLIST_FOREACH_SAFE(var, head, field, tvar) \
|
||||
for ((var) = SLIST_FIRST((head)); \
|
||||
(var) && ((tvar) = SLIST_NEXT((var), field), 1); \
|
||||
(var) = (tvar))
|
||||
|
||||
#define SLIST_FOREACH_PREVPTR(var, varp, head, field) \
|
||||
for ((varp) = &SLIST_FIRST((head)); \
|
||||
((var) = *(varp)) != NULL; \
|
||||
(varp) = &SLIST_NEXT((var), field))
|
||||
|
||||
#define SLIST_INIT(head) do { \
|
||||
SLIST_FIRST((head)) = NULL; \
|
||||
} while (0)
|
||||
|
||||
#define SLIST_INSERT_AFTER(slistelm, elm, field) do { \
|
||||
SLIST_NEXT((elm), field) = SLIST_NEXT((slistelm), field); \
|
||||
SLIST_NEXT((slistelm), field) = (elm); \
|
||||
} while (0)
|
||||
|
||||
#define SLIST_INSERT_HEAD(head, elm, field) do { \
|
||||
SLIST_NEXT((elm), field) = SLIST_FIRST((head)); \
|
||||
SLIST_FIRST((head)) = (elm); \
|
||||
} while (0)
|
||||
|
||||
#define SLIST_NEXT(elm, field) ((elm)->field.sle_next)
|
||||
|
||||
#define SLIST_REMOVE(head, elm, type, field) do { \
|
||||
QMD_SAVELINK(oldnext, (elm)->field.sle_next); \
|
||||
if (SLIST_FIRST((head)) == (elm)) { \
|
||||
SLIST_REMOVE_HEAD((head), field); \
|
||||
} \
|
||||
else { \
|
||||
struct type *curelm = SLIST_FIRST((head)); \
|
||||
while (SLIST_NEXT(curelm, field) != (elm)) \
|
||||
curelm = SLIST_NEXT(curelm, field); \
|
||||
SLIST_REMOVE_AFTER(curelm, field); \
|
||||
} \
|
||||
TRASHIT(*oldnext); \
|
||||
} while (0)
|
||||
|
||||
#define SLIST_REMOVE_AFTER(elm, field) do { \
|
||||
SLIST_NEXT(elm, field) = \
|
||||
SLIST_NEXT(SLIST_NEXT(elm, field), field); \
|
||||
} while (0)
|
||||
|
||||
#define SLIST_REMOVE_HEAD(head, field) do { \
|
||||
SLIST_FIRST((head)) = SLIST_NEXT(SLIST_FIRST((head)), field); \
|
||||
} while (0)
|
||||
|
||||
#define SLIST_SWAP(head1, head2, type) do { \
|
||||
struct type *swap_first = SLIST_FIRST(head1); \
|
||||
SLIST_FIRST(head1) = SLIST_FIRST(head2); \
|
||||
SLIST_FIRST(head2) = swap_first; \
|
||||
} while (0)
|
||||
|
||||
/*
|
||||
* Singly-linked Tail queue declarations.
|
||||
*/
|
||||
#define STAILQ_HEAD(name, type) \
|
||||
struct name { \
|
||||
struct type *stqh_first;/* first element */ \
|
||||
struct type **stqh_last;/* addr of last next element */ \
|
||||
}
|
||||
|
||||
#define STAILQ_HEAD_INITIALIZER(head) \
|
||||
{ NULL, &(head).stqh_first }
|
||||
|
||||
#define STAILQ_ENTRY(type) \
|
||||
struct { \
|
||||
struct type *stqe_next; /* next element */ \
|
||||
}
|
||||
|
||||
/*
|
||||
* Singly-linked Tail queue functions.
|
||||
*/
|
||||
#define STAILQ_CONCAT(head1, head2) do { \
|
||||
if (!STAILQ_EMPTY((head2))) { \
|
||||
*(head1)->stqh_last = (head2)->stqh_first; \
|
||||
(head1)->stqh_last = (head2)->stqh_last; \
|
||||
STAILQ_INIT((head2)); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define STAILQ_EMPTY(head) ((head)->stqh_first == NULL)
|
||||
|
||||
#define STAILQ_FIRST(head) ((head)->stqh_first)
|
||||
|
||||
#define STAILQ_FOREACH(var, head, field) \
|
||||
for((var) = STAILQ_FIRST((head)); \
|
||||
(var); \
|
||||
(var) = STAILQ_NEXT((var), field))
|
||||
|
||||
|
||||
#define STAILQ_FOREACH_SAFE(var, head, field, tvar) \
|
||||
for ((var) = STAILQ_FIRST((head)); \
|
||||
(var) && ((tvar) = STAILQ_NEXT((var), field), 1); \
|
||||
(var) = (tvar))
|
||||
|
||||
#define STAILQ_INIT(head) do { \
|
||||
STAILQ_FIRST((head)) = NULL; \
|
||||
(head)->stqh_last = &STAILQ_FIRST((head)); \
|
||||
} while (0)
|
||||
|
||||
#define STAILQ_INSERT_AFTER(head, tqelm, elm, field) do { \
|
||||
if ((STAILQ_NEXT((elm), field) = STAILQ_NEXT((tqelm), field)) == NULL)\
|
||||
(head)->stqh_last = &STAILQ_NEXT((elm), field); \
|
||||
STAILQ_NEXT((tqelm), field) = (elm); \
|
||||
} while (0)
|
||||
|
||||
#define STAILQ_INSERT_HEAD(head, elm, field) do { \
|
||||
if ((STAILQ_NEXT((elm), field) = STAILQ_FIRST((head))) == NULL) \
|
||||
(head)->stqh_last = &STAILQ_NEXT((elm), field); \
|
||||
STAILQ_FIRST((head)) = (elm); \
|
||||
} while (0)
|
||||
|
||||
#define STAILQ_INSERT_TAIL(head, elm, field) do { \
|
||||
STAILQ_NEXT((elm), field) = NULL; \
|
||||
*(head)->stqh_last = (elm); \
|
||||
(head)->stqh_last = &STAILQ_NEXT((elm), field); \
|
||||
} while (0)
|
||||
|
||||
#define STAILQ_LAST(head, type, field) \
|
||||
(STAILQ_EMPTY((head)) ? \
|
||||
NULL : \
|
||||
((struct type *)(void *) \
|
||||
((char *)((head)->stqh_last) - __offsetof(struct type, field))))
|
||||
|
||||
#define STAILQ_NEXT(elm, field) ((elm)->field.stqe_next)
|
||||
|
||||
#define STAILQ_REMOVE(head, elm, type, field) do { \
|
||||
QMD_SAVELINK(oldnext, (elm)->field.stqe_next); \
|
||||
if (STAILQ_FIRST((head)) == (elm)) { \
|
||||
STAILQ_REMOVE_HEAD((head), field); \
|
||||
} \
|
||||
else { \
|
||||
struct type *curelm = STAILQ_FIRST((head)); \
|
||||
while (STAILQ_NEXT(curelm, field) != (elm)) \
|
||||
curelm = STAILQ_NEXT(curelm, field); \
|
||||
STAILQ_REMOVE_AFTER(head, curelm, field); \
|
||||
} \
|
||||
TRASHIT(*oldnext); \
|
||||
} while (0)
|
||||
|
||||
#define STAILQ_REMOVE_AFTER(head, elm, field) do { \
|
||||
if ((STAILQ_NEXT(elm, field) = \
|
||||
STAILQ_NEXT(STAILQ_NEXT(elm, field), field)) == NULL) \
|
||||
(head)->stqh_last = &STAILQ_NEXT((elm), field); \
|
||||
} while (0)
|
||||
|
||||
#define STAILQ_REMOVE_HEAD(head, field) do { \
|
||||
if ((STAILQ_FIRST((head)) = \
|
||||
STAILQ_NEXT(STAILQ_FIRST((head)), field)) == NULL) \
|
||||
(head)->stqh_last = &STAILQ_FIRST((head)); \
|
||||
} while (0)
|
||||
|
||||
#define STAILQ_SWAP(head1, head2, type) do { \
|
||||
struct type *swap_first = STAILQ_FIRST(head1); \
|
||||
struct type **swap_last = (head1)->stqh_last; \
|
||||
STAILQ_FIRST(head1) = STAILQ_FIRST(head2); \
|
||||
(head1)->stqh_last = (head2)->stqh_last; \
|
||||
STAILQ_FIRST(head2) = swap_first; \
|
||||
(head2)->stqh_last = swap_last; \
|
||||
if (STAILQ_EMPTY(head1)) \
|
||||
(head1)->stqh_last = &STAILQ_FIRST(head1); \
|
||||
if (STAILQ_EMPTY(head2)) \
|
||||
(head2)->stqh_last = &STAILQ_FIRST(head2); \
|
||||
} while (0)
|
||||
|
||||
|
||||
/*
|
||||
* List declarations.
|
||||
*/
|
||||
#define LIST_HEAD(name, type) \
|
||||
struct name { \
|
||||
struct type *lh_first; /* first element */ \
|
||||
}
|
||||
|
||||
#define LIST_HEAD_INITIALIZER(head) \
|
||||
{ NULL }
|
||||
|
||||
#define LIST_ENTRY(type) \
|
||||
struct { \
|
||||
struct type *le_next; /* next element */ \
|
||||
struct type **le_prev; /* address of previous next element */ \
|
||||
}
|
||||
|
||||
/*
|
||||
* List functions.
|
||||
*/
|
||||
|
||||
#if defined(INVARIANTS)
|
||||
#define QMD_LIST_CHECK_HEAD(head, field) do { \
|
||||
if (LIST_FIRST((head)) != NULL && \
|
||||
LIST_FIRST((head))->field.le_prev != \
|
||||
&LIST_FIRST((head))) \
|
||||
panic("Bad list head %p first->prev != head", (void *)(head)); \
|
||||
} while (0)
|
||||
|
||||
#define QMD_LIST_CHECK_NEXT(elm, field) do { \
|
||||
if (LIST_NEXT((elm), field) != NULL && \
|
||||
LIST_NEXT((elm), field)->field.le_prev != \
|
||||
&((elm)->field.le_next)) \
|
||||
panic("Bad link elm %p next->prev != elm", (void *)(elm)); \
|
||||
} while (0)
|
||||
|
||||
#define QMD_LIST_CHECK_PREV(elm, field) do { \
|
||||
if (*(elm)->field.le_prev != (elm)) \
|
||||
panic("Bad link elm %p prev->next != elm", (void *)(elm)); \
|
||||
} while (0)
|
||||
#else
|
||||
#define QMD_LIST_CHECK_HEAD(head, field)
|
||||
#define QMD_LIST_CHECK_NEXT(elm, field)
|
||||
#define QMD_LIST_CHECK_PREV(elm, field)
|
||||
#endif /* (INVARIANTS) */
|
||||
|
||||
#define LIST_EMPTY(head) ((head)->lh_first == NULL)
|
||||
|
||||
#define LIST_FIRST(head) ((head)->lh_first)
|
||||
|
||||
#define LIST_FOREACH(var, head, field) \
|
||||
for ((var) = LIST_FIRST((head)); \
|
||||
(var); \
|
||||
(var) = LIST_NEXT((var), field))
|
||||
|
||||
#define LIST_FOREACH_SAFE(var, head, field, tvar) \
|
||||
for ((var) = LIST_FIRST((head)); \
|
||||
(var) && ((tvar) = LIST_NEXT((var), field), 1); \
|
||||
(var) = (tvar))
|
||||
|
||||
#define LIST_INIT(head) do { \
|
||||
LIST_FIRST((head)) = NULL; \
|
||||
} while (0)
|
||||
|
||||
#define LIST_INSERT_AFTER(listelm, elm, field) do { \
|
||||
QMD_LIST_CHECK_NEXT(listelm, field); \
|
||||
if ((LIST_NEXT((elm), field) = LIST_NEXT((listelm), field)) != NULL)\
|
||||
LIST_NEXT((listelm), field)->field.le_prev = \
|
||||
&LIST_NEXT((elm), field); \
|
||||
LIST_NEXT((listelm), field) = (elm); \
|
||||
(elm)->field.le_prev = &LIST_NEXT((listelm), field); \
|
||||
} while (0)
|
||||
|
||||
#define LIST_INSERT_BEFORE(listelm, elm, field) do { \
|
||||
QMD_LIST_CHECK_PREV(listelm, field); \
|
||||
(elm)->field.le_prev = (listelm)->field.le_prev; \
|
||||
LIST_NEXT((elm), field) = (listelm); \
|
||||
*(listelm)->field.le_prev = (elm); \
|
||||
(listelm)->field.le_prev = &LIST_NEXT((elm), field); \
|
||||
} while (0)
|
||||
|
||||
#define LIST_INSERT_HEAD(head, elm, field) do { \
|
||||
QMD_LIST_CHECK_HEAD((head), field); \
|
||||
if ((LIST_NEXT((elm), field) = LIST_FIRST((head))) != NULL) \
|
||||
LIST_FIRST((head))->field.le_prev = &LIST_NEXT((elm), field);\
|
||||
LIST_FIRST((head)) = (elm); \
|
||||
(elm)->field.le_prev = &LIST_FIRST((head)); \
|
||||
} while (0)
|
||||
|
||||
#define LIST_NEXT(elm, field) ((elm)->field.le_next)
|
||||
|
||||
#define LIST_REMOVE(elm, field) do { \
|
||||
QMD_SAVELINK(oldnext, (elm)->field.le_next); \
|
||||
QMD_SAVELINK(oldprev, (elm)->field.le_prev); \
|
||||
QMD_LIST_CHECK_NEXT(elm, field); \
|
||||
QMD_LIST_CHECK_PREV(elm, field); \
|
||||
if (LIST_NEXT((elm), field) != NULL) \
|
||||
LIST_NEXT((elm), field)->field.le_prev = \
|
||||
(elm)->field.le_prev; \
|
||||
*(elm)->field.le_prev = LIST_NEXT((elm), field); \
|
||||
TRASHIT(*oldnext); \
|
||||
TRASHIT(*oldprev); \
|
||||
} while (0)
|
||||
|
||||
#define LIST_SWAP(head1, head2, type, field) do { \
|
||||
struct type *swap_tmp = LIST_FIRST((head1)); \
|
||||
LIST_FIRST((head1)) = LIST_FIRST((head2)); \
|
||||
LIST_FIRST((head2)) = swap_tmp; \
|
||||
if ((swap_tmp = LIST_FIRST((head1))) != NULL) \
|
||||
swap_tmp->field.le_prev = &LIST_FIRST((head1)); \
|
||||
if ((swap_tmp = LIST_FIRST((head2))) != NULL) \
|
||||
swap_tmp->field.le_prev = &LIST_FIRST((head2)); \
|
||||
} while (0)
|
||||
|
||||
/*
|
||||
* Tail queue declarations.
|
||||
*/
|
||||
#define TAILQ_HEAD(name, type) \
|
||||
struct name { \
|
||||
struct type *tqh_first; /* first element */ \
|
||||
struct type **tqh_last; /* addr of last next element */ \
|
||||
TRACEBUF \
|
||||
}
|
||||
|
||||
#define TAILQ_HEAD_INITIALIZER(head) \
|
||||
{ NULL, &(head).tqh_first }
|
||||
|
||||
#define TAILQ_ENTRY(type) \
|
||||
struct { \
|
||||
struct type *tqe_next; /* next element */ \
|
||||
struct type **tqe_prev; /* address of previous next element */ \
|
||||
TRACEBUF \
|
||||
}
|
||||
|
||||
/*
|
||||
* Tail queue functions.
|
||||
*/
|
||||
#if defined(INVARIANTS)
|
||||
#define QMD_TAILQ_CHECK_HEAD(head, field) do { \
|
||||
if (!TAILQ_EMPTY(head) && \
|
||||
TAILQ_FIRST((head))->field.tqe_prev != \
|
||||
&TAILQ_FIRST((head))) \
|
||||
panic("Bad tailq head %p first->prev != head", (void *)(head)); \
|
||||
} while (0)
|
||||
|
||||
#define QMD_TAILQ_CHECK_TAIL(head, field) do { \
|
||||
if (*(head)->tqh_last != NULL) \
|
||||
panic("Bad tailq NEXT(%p->tqh_last) != NULL", (void *)(head)); \
|
||||
} while (0)
|
||||
|
||||
#define QMD_TAILQ_CHECK_NEXT(elm, field) do { \
|
||||
if (TAILQ_NEXT((elm), field) != NULL && \
|
||||
TAILQ_NEXT((elm), field)->field.tqe_prev != \
|
||||
&((elm)->field.tqe_next)) \
|
||||
panic("Bad link elm %p next->prev != elm", (void *)(elm)); \
|
||||
} while (0)
|
||||
|
||||
#define QMD_TAILQ_CHECK_PREV(elm, field) do { \
|
||||
if (*(elm)->field.tqe_prev != (elm)) \
|
||||
panic("Bad link elm %p prev->next != elm", (void *)(elm)); \
|
||||
} while (0)
|
||||
#else
|
||||
#define QMD_TAILQ_CHECK_HEAD(head, field)
|
||||
#define QMD_TAILQ_CHECK_TAIL(head, headname)
|
||||
#define QMD_TAILQ_CHECK_NEXT(elm, field)
|
||||
#define QMD_TAILQ_CHECK_PREV(elm, field)
|
||||
#endif /* (INVARIANTS) */
|
||||
|
||||
#define TAILQ_CONCAT(head1, head2, field) do { \
|
||||
if (!TAILQ_EMPTY(head2)) { \
|
||||
*(head1)->tqh_last = (head2)->tqh_first; \
|
||||
(head2)->tqh_first->field.tqe_prev = (head1)->tqh_last; \
|
||||
(head1)->tqh_last = (head2)->tqh_last; \
|
||||
TAILQ_INIT((head2)); \
|
||||
QMD_TRACE_HEAD(head1); \
|
||||
QMD_TRACE_HEAD(head2); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define TAILQ_EMPTY(head) ((head)->tqh_first == NULL)
|
||||
|
||||
#define TAILQ_FIRST(head) ((head)->tqh_first)
|
||||
|
||||
#define TAILQ_FOREACH(var, head, field) \
|
||||
for ((var) = TAILQ_FIRST((head)); \
|
||||
(var); \
|
||||
(var) = TAILQ_NEXT((var), field))
|
||||
|
||||
#define TAILQ_FOREACH_SAFE(var, head, field, tvar) \
|
||||
for ((var) = TAILQ_FIRST((head)); \
|
||||
(var) && ((tvar) = TAILQ_NEXT((var), field), 1); \
|
||||
(var) = (tvar))
|
||||
|
||||
#define TAILQ_FOREACH_REVERSE(var, head, headname, field) \
|
||||
for ((var) = TAILQ_LAST((head), headname); \
|
||||
(var); \
|
||||
(var) = TAILQ_PREV((var), headname, field))
|
||||
|
||||
#define TAILQ_FOREACH_REVERSE_SAFE(var, head, headname, field, tvar) \
|
||||
for ((var) = TAILQ_LAST((head), headname); \
|
||||
(var) && ((tvar) = TAILQ_PREV((var), headname, field), 1); \
|
||||
(var) = (tvar))
|
||||
|
||||
#define TAILQ_INIT(head) do { \
|
||||
TAILQ_FIRST((head)) = NULL; \
|
||||
(head)->tqh_last = &TAILQ_FIRST((head)); \
|
||||
QMD_TRACE_HEAD(head); \
|
||||
} while (0)
|
||||
|
||||
#define TAILQ_INSERT_AFTER(head, listelm, elm, field) do { \
|
||||
QMD_TAILQ_CHECK_NEXT(listelm, field); \
|
||||
if ((TAILQ_NEXT((elm), field) = TAILQ_NEXT((listelm), field)) != NULL)\
|
||||
TAILQ_NEXT((elm), field)->field.tqe_prev = \
|
||||
&TAILQ_NEXT((elm), field); \
|
||||
else { \
|
||||
(head)->tqh_last = &TAILQ_NEXT((elm), field); \
|
||||
QMD_TRACE_HEAD(head); \
|
||||
} \
|
||||
TAILQ_NEXT((listelm), field) = (elm); \
|
||||
(elm)->field.tqe_prev = &TAILQ_NEXT((listelm), field); \
|
||||
QMD_TRACE_ELEM(&(elm)->field); \
|
||||
QMD_TRACE_ELEM(&listelm->field); \
|
||||
} while (0)
|
||||
|
||||
#define TAILQ_INSERT_BEFORE(listelm, elm, field) do { \
|
||||
QMD_TAILQ_CHECK_PREV(listelm, field); \
|
||||
(elm)->field.tqe_prev = (listelm)->field.tqe_prev; \
|
||||
TAILQ_NEXT((elm), field) = (listelm); \
|
||||
*(listelm)->field.tqe_prev = (elm); \
|
||||
(listelm)->field.tqe_prev = &TAILQ_NEXT((elm), field); \
|
||||
QMD_TRACE_ELEM(&(elm)->field); \
|
||||
QMD_TRACE_ELEM(&listelm->field); \
|
||||
} while (0)
|
||||
|
||||
#define TAILQ_INSERT_HEAD(head, elm, field) do { \
|
||||
QMD_TAILQ_CHECK_HEAD(head, field); \
|
||||
if ((TAILQ_NEXT((elm), field) = TAILQ_FIRST((head))) != NULL) \
|
||||
TAILQ_FIRST((head))->field.tqe_prev = \
|
||||
&TAILQ_NEXT((elm), field); \
|
||||
else \
|
||||
(head)->tqh_last = &TAILQ_NEXT((elm), field); \
|
||||
TAILQ_FIRST((head)) = (elm); \
|
||||
(elm)->field.tqe_prev = &TAILQ_FIRST((head)); \
|
||||
QMD_TRACE_HEAD(head); \
|
||||
QMD_TRACE_ELEM(&(elm)->field); \
|
||||
} while (0)
|
||||
|
||||
#define TAILQ_INSERT_TAIL(head, elm, field) do { \
|
||||
QMD_TAILQ_CHECK_TAIL(head, field); \
|
||||
TAILQ_NEXT((elm), field) = NULL; \
|
||||
(elm)->field.tqe_prev = (head)->tqh_last; \
|
||||
*(head)->tqh_last = (elm); \
|
||||
(head)->tqh_last = &TAILQ_NEXT((elm), field); \
|
||||
QMD_TRACE_HEAD(head); \
|
||||
QMD_TRACE_ELEM(&(elm)->field); \
|
||||
} while (0)
|
||||
|
||||
#define TAILQ_LAST(head, headname) \
|
||||
(*(((struct headname *)((head)->tqh_last))->tqh_last))
|
||||
|
||||
#define TAILQ_NEXT(elm, field) ((elm)->field.tqe_next)
|
||||
|
||||
#define TAILQ_PREV(elm, headname, field) \
|
||||
(*(((struct headname *)((elm)->field.tqe_prev))->tqh_last))
|
||||
|
||||
#define TAILQ_REMOVE(head, elm, field) do { \
|
||||
QMD_SAVELINK(oldnext, (elm)->field.tqe_next); \
|
||||
QMD_SAVELINK(oldprev, (elm)->field.tqe_prev); \
|
||||
QMD_TAILQ_CHECK_NEXT(elm, field); \
|
||||
QMD_TAILQ_CHECK_PREV(elm, field); \
|
||||
if ((TAILQ_NEXT((elm), field)) != NULL) \
|
||||
TAILQ_NEXT((elm), field)->field.tqe_prev = \
|
||||
(elm)->field.tqe_prev; \
|
||||
else { \
|
||||
(head)->tqh_last = (elm)->field.tqe_prev; \
|
||||
QMD_TRACE_HEAD(head); \
|
||||
} \
|
||||
*(elm)->field.tqe_prev = TAILQ_NEXT((elm), field); \
|
||||
TRASHIT(*oldnext); \
|
||||
TRASHIT(*oldprev); \
|
||||
QMD_TRACE_ELEM(&(elm)->field); \
|
||||
} while (0)
|
||||
|
||||
#define TAILQ_SWAP(head1, head2, type, field) do { \
|
||||
struct type *swap_first = (head1)->tqh_first; \
|
||||
struct type **swap_last = (head1)->tqh_last; \
|
||||
(head1)->tqh_first = (head2)->tqh_first; \
|
||||
(head1)->tqh_last = (head2)->tqh_last; \
|
||||
(head2)->tqh_first = swap_first; \
|
||||
(head2)->tqh_last = swap_last; \
|
||||
if ((swap_first = (head1)->tqh_first) != NULL) \
|
||||
swap_first->field.tqe_prev = &(head1)->tqh_first; \
|
||||
else \
|
||||
(head1)->tqh_last = &(head1)->tqh_first; \
|
||||
if ((swap_first = (head2)->tqh_first) != NULL) \
|
||||
swap_first->field.tqe_prev = &(head2)->tqh_first; \
|
||||
else \
|
||||
(head2)->tqh_last = &(head2)->tqh_first; \
|
||||
} while (0)
|
||||
|
||||
#endif /* !_SYS_QUEUE_H_ */
|
||||
1566
TMessagesProj/jni/third_party/usrsctplib/user_recv_thread.c
vendored
Executable file
1566
TMessagesProj/jni/third_party/usrsctplib/user_recv_thread.c
vendored
Executable file
File diff suppressed because it is too large
Load diff
34
TMessagesProj/jni/third_party/usrsctplib/user_recv_thread.h
vendored
Executable file
34
TMessagesProj/jni/third_party/usrsctplib/user_recv_thread.h
vendored
Executable file
|
|
@ -0,0 +1,34 @@
|
|||
/*-
|
||||
* Copyright (c) 2012 Michael Tuexen
|
||||
* Copyright (c) 2012 Irene Ruengeler
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. 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.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
|
||||
*/
|
||||
|
||||
#ifndef _USER_RECV_THREAD_H_
|
||||
#define _USER_RECV_THREAD_H_
|
||||
|
||||
void recv_thread_init(void);
|
||||
void recv_thread_destroy(void);
|
||||
|
||||
#endif
|
||||
130
TMessagesProj/jni/third_party/usrsctplib/user_route.h
vendored
Executable file
130
TMessagesProj/jni/third_party/usrsctplib/user_route.h
vendored
Executable file
|
|
@ -0,0 +1,130 @@
|
|||
/*-
|
||||
* Copyright (c) 1980, 1986, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. 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.
|
||||
* 3. Neither the name of the University 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 REGENTS 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 REGENTS 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _USER_ROUTE_H_
|
||||
#define _USER_ROUTE_H_
|
||||
|
||||
/*
|
||||
* Kernel resident routing tables.
|
||||
*
|
||||
* The routing tables are initialized when interface addresses
|
||||
* are set by making entries for all directly connected interfaces.
|
||||
*/
|
||||
|
||||
/*
|
||||
* A route consists of a destination address and a reference
|
||||
* to a routing entry. These are often held by protocols
|
||||
* in their control blocks, e.g. inpcb.
|
||||
*/
|
||||
|
||||
struct sctp_route {
|
||||
struct sctp_rtentry *ro_rt;
|
||||
struct sockaddr ro_dst;
|
||||
};
|
||||
|
||||
/*
|
||||
* These numbers are used by reliable protocols for determining
|
||||
* retransmission behavior and are included in the routing structure.
|
||||
*/
|
||||
struct sctp_rt_metrics_lite {
|
||||
uint32_t rmx_mtu; /* MTU for this path */
|
||||
#if 0
|
||||
u_long rmx_expire; /* lifetime for route, e.g. redirect */
|
||||
u_long rmx_pksent; /* packets sent using this route */
|
||||
#endif
|
||||
};
|
||||
|
||||
/*
|
||||
* We distinguish between routes to hosts and routes to networks,
|
||||
* preferring the former if available. For each route we infer
|
||||
* the interface to use from the gateway address supplied when
|
||||
* the route was entered. Routes that forward packets through
|
||||
* gateways are marked so that the output routines know to address the
|
||||
* gateway rather than the ultimate destination.
|
||||
*/
|
||||
struct sctp_rtentry {
|
||||
#if 0
|
||||
struct radix_node rt_nodes[2]; /* tree glue, and other values */
|
||||
/*
|
||||
* XXX struct rtentry must begin with a struct radix_node (or two!)
|
||||
* because the code does some casts of a 'struct radix_node *'
|
||||
* to a 'struct rtentry *'
|
||||
*/
|
||||
#define rt_key(r) (*((struct sockaddr **)(&(r)->rt_nodes->rn_key)))
|
||||
#define rt_mask(r) (*((struct sockaddr **)(&(r)->rt_nodes->rn_mask)))
|
||||
struct sockaddr *rt_gateway; /* value */
|
||||
u_long rt_flags; /* up/down?, host/net */
|
||||
#endif
|
||||
struct ifnet *rt_ifp; /* the answer: interface to use */
|
||||
struct ifaddr *rt_ifa; /* the answer: interface address to use */
|
||||
struct sctp_rt_metrics_lite rt_rmx; /* metrics used by rx'ing protocols */
|
||||
long rt_refcnt; /* # held references */
|
||||
#if 0
|
||||
struct sockaddr *rt_genmask; /* for generation of cloned routes */
|
||||
caddr_t rt_llinfo; /* pointer to link level info cache */
|
||||
struct rtentry *rt_gwroute; /* implied entry for gatewayed routes */
|
||||
struct rtentry *rt_parent; /* cloning parent of this route */
|
||||
#endif
|
||||
struct mtx rt_mtx; /* mutex for routing entry */
|
||||
};
|
||||
|
||||
#define RT_LOCK_INIT(_rt) mtx_init(&(_rt)->rt_mtx, "rtentry", NULL, MTX_DEF | MTX_DUPOK)
|
||||
#define RT_LOCK(_rt) mtx_lock(&(_rt)->rt_mtx)
|
||||
#define RT_UNLOCK(_rt) mtx_unlock(&(_rt)->rt_mtx)
|
||||
#define RT_LOCK_DESTROY(_rt) mtx_destroy(&(_rt)->rt_mtx)
|
||||
#define RT_LOCK_ASSERT(_rt) mtx_assert(&(_rt)->rt_mtx, MA_OWNED)
|
||||
|
||||
#define RT_ADDREF(_rt) do { \
|
||||
RT_LOCK_ASSERT(_rt); \
|
||||
KASSERT((_rt)->rt_refcnt >= 0, \
|
||||
("negative refcnt %ld", (_rt)->rt_refcnt)); \
|
||||
(_rt)->rt_refcnt++; \
|
||||
} while (0)
|
||||
#define RT_REMREF(_rt) do { \
|
||||
RT_LOCK_ASSERT(_rt); \
|
||||
KASSERT((_rt)->rt_refcnt > 0, \
|
||||
("bogus refcnt %ld", (_rt)->rt_refcnt)); \
|
||||
(_rt)->rt_refcnt--; \
|
||||
} while (0)
|
||||
#define RTFREE_LOCKED(_rt) do { \
|
||||
if ((_rt)->rt_refcnt <= 1) { \
|
||||
rtfree(_rt); \
|
||||
} else { \
|
||||
RT_REMREF(_rt); \
|
||||
RT_UNLOCK(_rt); \
|
||||
} \
|
||||
/* guard against invalid refs */ \
|
||||
_rt = NULL; \
|
||||
} while (0)
|
||||
#define RTFREE(_rt) do { \
|
||||
RT_LOCK(_rt); \
|
||||
RTFREE_LOCKED(_rt); \
|
||||
} while (0)
|
||||
#endif
|
||||
3584
TMessagesProj/jni/third_party/usrsctplib/user_socket.c
vendored
Executable file
3584
TMessagesProj/jni/third_party/usrsctplib/user_socket.c
vendored
Executable file
File diff suppressed because it is too large
Load diff
527
TMessagesProj/jni/third_party/usrsctplib/user_socketvar.h
vendored
Executable file
527
TMessagesProj/jni/third_party/usrsctplib/user_socketvar.h
vendored
Executable file
|
|
@ -0,0 +1,527 @@
|
|||
/*-
|
||||
* Copyright (c) 1982, 1986, 1990, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. 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.
|
||||
* 3. Neither the name of the University 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 REGENTS 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 REGENTS 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.
|
||||
*
|
||||
*/
|
||||
|
||||
/* __Userspace__ version of <sys/socketvar.h> goes here.*/
|
||||
|
||||
#ifndef _USER_SOCKETVAR_H_
|
||||
#define _USER_SOCKETVAR_H_
|
||||
|
||||
#if defined(__APPLE__)
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
/* #include <sys/selinfo.h> */ /*__Userspace__ alternative?*/ /* for struct selinfo */
|
||||
/* #include <sys/_lock.h> was 0 byte file */
|
||||
/* #include <sys/_mutex.h> was 0 byte file */
|
||||
/* #include <sys/_sx.h> */ /*__Userspace__ alternative?*/
|
||||
#if !defined(__DragonFly__) && !defined(__FreeBSD__) && !defined(__NetBSD__) && !defined(_WIN32) && !defined(__native_client__)
|
||||
#include <sys/uio.h>
|
||||
#endif
|
||||
#define SOCK_MAXADDRLEN 255
|
||||
#if !defined(MSG_NOTIFICATION)
|
||||
#define MSG_NOTIFICATION 0x2000 /* SCTP notification */
|
||||
#endif
|
||||
#define SCTP_SO_LINGER 0x0001
|
||||
#define SCTP_SO_ACCEPTCONN 0x0002
|
||||
#define SS_CANTRCVMORE 0x020
|
||||
#define SS_CANTSENDMORE 0x010
|
||||
|
||||
#if defined(__APPLE__) || defined(__DragonFly__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(_WIN32) || defined(__native_client__)
|
||||
#define UIO_MAXIOV 1024
|
||||
#define ERESTART (-1)
|
||||
#endif
|
||||
|
||||
#if !defined(__APPLE__) && !defined(__NetBSD__) && !defined(__OpenBSD__)
|
||||
enum uio_rw { UIO_READ, UIO_WRITE };
|
||||
#endif
|
||||
|
||||
#if !defined(__NetBSD__) && !defined(__OpenBSD__)
|
||||
/* Segment flag values. */
|
||||
enum uio_seg {
|
||||
UIO_USERSPACE, /* from user data space */
|
||||
UIO_SYSSPACE /* from system space */
|
||||
};
|
||||
#endif
|
||||
|
||||
struct proc {
|
||||
int stub; /* struct proc is a dummy for __Userspace__ */
|
||||
};
|
||||
|
||||
MALLOC_DECLARE(M_ACCF);
|
||||
MALLOC_DECLARE(M_PCB);
|
||||
MALLOC_DECLARE(M_SONAME);
|
||||
|
||||
/* __Userspace__ Are these all the fields we need?
|
||||
* Removing struct thread *uio_td; owner field
|
||||
*/
|
||||
struct uio {
|
||||
struct iovec *uio_iov; /* scatter/gather list */
|
||||
int uio_iovcnt; /* length of scatter/gather list */
|
||||
off_t uio_offset; /* offset in target object */
|
||||
ssize_t uio_resid; /* remaining bytes to process */
|
||||
enum uio_seg uio_segflg; /* address space */
|
||||
enum uio_rw uio_rw; /* operation */
|
||||
};
|
||||
|
||||
|
||||
/* __Userspace__ */
|
||||
|
||||
/*
|
||||
* Kernel structure per socket.
|
||||
* Contains send and receive buffer queues,
|
||||
* handle on protocol and pointer to protocol
|
||||
* private data and error information.
|
||||
*/
|
||||
#if defined(_WIN32)
|
||||
#define AF_ROUTE 17
|
||||
#if !defined(__MINGW32__)
|
||||
typedef __int32 pid_t;
|
||||
#endif
|
||||
typedef unsigned __int32 uid_t;
|
||||
enum sigType {
|
||||
SIGNAL = 0,
|
||||
BROADCAST = 1,
|
||||
MAX_EVENTS = 2
|
||||
};
|
||||
#endif
|
||||
|
||||
/*-
|
||||
* Locking key to struct socket:
|
||||
* (a) constant after allocation, no locking required.
|
||||
* (b) locked by SOCK_LOCK(so).
|
||||
* (c) locked by SOCKBUF_LOCK(&so->so_rcv).
|
||||
* (d) locked by SOCKBUF_LOCK(&so->so_snd).
|
||||
* (e) locked by ACCEPT_LOCK().
|
||||
* (f) not locked since integer reads/writes are atomic.
|
||||
* (g) used only as a sleep/wakeup address, no value.
|
||||
* (h) locked by global mutex so_global_mtx.
|
||||
*/
|
||||
struct socket {
|
||||
int so_count; /* (b) reference count */
|
||||
short so_type; /* (a) generic type, see socket.h */
|
||||
short so_options; /* from socket call, see socket.h */
|
||||
short so_linger; /* time to linger while closing */
|
||||
short so_state; /* (b) internal state flags SS_* */
|
||||
int so_qstate; /* (e) internal state flags SQ_* */
|
||||
void *so_pcb; /* protocol control block */
|
||||
int so_dom;
|
||||
/*
|
||||
* Variables for connection queuing.
|
||||
* Socket where accepts occur is so_head in all subsidiary sockets.
|
||||
* If so_head is 0, socket is not related to an accept.
|
||||
* For head socket so_incomp queues partially completed connections,
|
||||
* while so_comp is a queue of connections ready to be accepted.
|
||||
* If a connection is aborted and it has so_head set, then
|
||||
* it has to be pulled out of either so_incomp or so_comp.
|
||||
* We allow connections to queue up based on current queue lengths
|
||||
* and limit on number of queued connections for this socket.
|
||||
*/
|
||||
struct socket *so_head; /* (e) back pointer to listen socket */
|
||||
TAILQ_HEAD(, socket) so_incomp; /* (e) queue of partial unaccepted connections */
|
||||
TAILQ_HEAD(, socket) so_comp; /* (e) queue of complete unaccepted connections */
|
||||
TAILQ_ENTRY(socket) so_list; /* (e) list of unaccepted connections */
|
||||
u_short so_qlen; /* (e) number of unaccepted connections */
|
||||
u_short so_incqlen; /* (e) number of unaccepted incomplete
|
||||
connections */
|
||||
u_short so_qlimit; /* (e) max number queued connections */
|
||||
short so_timeo; /* (g) connection timeout */
|
||||
userland_cond_t timeo_cond; /* timeo_cond condition variable being used in wakeup */
|
||||
|
||||
u_short so_error; /* (f) error affecting connection */
|
||||
struct sigio *so_sigio; /* [sg] information for async I/O or
|
||||
out of band data (SIGURG) */
|
||||
u_long so_oobmark; /* (c) chars to oob mark */
|
||||
TAILQ_HEAD(, aiocblist) so_aiojobq; /* AIO ops waiting on socket */
|
||||
/*
|
||||
* Variables for socket buffering.
|
||||
*/
|
||||
struct sockbuf {
|
||||
/* __Userspace__ Many of these fields may
|
||||
* not be required for the sctp stack.
|
||||
* Commenting out the following.
|
||||
* Including pthread mutex and condition variable to be
|
||||
* used by sbwait, sorwakeup and sowwakeup.
|
||||
*/
|
||||
/* struct selinfo sb_sel;*/ /* process selecting read/write */
|
||||
/* struct mtx sb_mtx;*/ /* sockbuf lock */
|
||||
/* struct sx sb_sx;*/ /* prevent I/O interlacing */
|
||||
userland_cond_t sb_cond; /* sockbuf condition variable */
|
||||
userland_mutex_t sb_mtx; /* sockbuf lock associated with sb_cond */
|
||||
short sb_state; /* (c/d) socket state on sockbuf */
|
||||
#define sb_startzero sb_mb
|
||||
struct mbuf *sb_mb; /* (c/d) the mbuf chain */
|
||||
struct mbuf *sb_mbtail; /* (c/d) the last mbuf in the chain */
|
||||
struct mbuf *sb_lastrecord; /* (c/d) first mbuf of last
|
||||
* record in socket buffer */
|
||||
struct mbuf *sb_sndptr; /* (c/d) pointer into mbuf chain */
|
||||
u_int sb_sndptroff; /* (c/d) byte offset of ptr into chain */
|
||||
u_int sb_cc; /* (c/d) actual chars in buffer */
|
||||
u_int sb_hiwat; /* (c/d) max actual char count */
|
||||
u_int sb_mbcnt; /* (c/d) chars of mbufs used */
|
||||
u_int sb_mbmax; /* (c/d) max chars of mbufs to use */
|
||||
u_int sb_ctl; /* (c/d) non-data chars in buffer */
|
||||
int sb_lowat; /* (c/d) low water mark */
|
||||
int sb_timeo; /* (c/d) timeout for read/write */
|
||||
short sb_flags; /* (c/d) flags, see below */
|
||||
} so_rcv, so_snd;
|
||||
/*
|
||||
* Constants for sb_flags field of struct sockbuf.
|
||||
*/
|
||||
#define SB_MAX (256*1024) /* default for max chars in sockbuf */
|
||||
#define SB_RAW (64*1024*2) /*Aligning so->so_rcv.sb_hiwat with the receive buffer size of raw socket*/
|
||||
/*
|
||||
* Constants for sb_flags field of struct sockbuf.
|
||||
*/
|
||||
#define SB_WAIT 0x04 /* someone is waiting for data/space */
|
||||
#define SB_SEL 0x08 /* someone is selecting */
|
||||
#define SB_ASYNC 0x10 /* ASYNC I/O, need signals */
|
||||
#define SB_UPCALL 0x20 /* someone wants an upcall */
|
||||
#define SB_NOINTR 0x40 /* operations not interruptible */
|
||||
#define SB_AIO 0x80 /* AIO operations queued */
|
||||
#define SB_KNOTE 0x100 /* kernel note attached */
|
||||
#define SB_AUTOSIZE 0x800 /* automatically size socket buffer */
|
||||
|
||||
void (*so_upcall)(struct socket *, void *, int);
|
||||
void *so_upcallarg;
|
||||
struct ucred *so_cred; /* (a) user credentials */
|
||||
struct label *so_label; /* (b) MAC label for socket */
|
||||
struct label *so_peerlabel; /* (b) cached MAC label for peer */
|
||||
/* NB: generation count must not be first. */
|
||||
uint32_t so_gencnt; /* (h) generation count */
|
||||
void *so_emuldata; /* (b) private data for emulators */
|
||||
struct so_accf {
|
||||
struct accept_filter *so_accept_filter;
|
||||
void *so_accept_filter_arg; /* saved filter args */
|
||||
char *so_accept_filter_str; /* saved user args */
|
||||
} *so_accf;
|
||||
};
|
||||
|
||||
#define SB_EMPTY_FIXUP(sb) do { \
|
||||
if ((sb)->sb_mb == NULL) { \
|
||||
(sb)->sb_mbtail = NULL; \
|
||||
(sb)->sb_lastrecord = NULL; \
|
||||
} \
|
||||
} while (/*CONSTCOND*/0)
|
||||
|
||||
/*
|
||||
* Global accept mutex to serialize access to accept queues and
|
||||
* fields associated with multiple sockets. This allows us to
|
||||
* avoid defining a lock order between listen and accept sockets
|
||||
* until such time as it proves to be a good idea.
|
||||
*/
|
||||
#if defined(_WIN32)
|
||||
extern userland_mutex_t accept_mtx;
|
||||
extern userland_cond_t accept_cond;
|
||||
#define ACCEPT_LOCK_ASSERT()
|
||||
#define ACCEPT_LOCK() do { \
|
||||
EnterCriticalSection(&accept_mtx); \
|
||||
} while (0)
|
||||
#define ACCEPT_UNLOCK() do { \
|
||||
LeaveCriticalSection(&accept_mtx); \
|
||||
} while (0)
|
||||
#define ACCEPT_UNLOCK_ASSERT()
|
||||
#else
|
||||
extern userland_mutex_t accept_mtx;
|
||||
|
||||
extern userland_cond_t accept_cond;
|
||||
#ifdef INVARIANTS
|
||||
#define ACCEPT_LOCK() KASSERT(pthread_mutex_lock(&accept_mtx) == 0, ("%s: accept_mtx already locked", __func__))
|
||||
#define ACCEPT_UNLOCK() KASSERT(pthread_mutex_unlock(&accept_mtx) == 0, ("%s: accept_mtx not locked", __func__))
|
||||
#else
|
||||
#define ACCEPT_LOCK() (void)pthread_mutex_lock(&accept_mtx)
|
||||
#define ACCEPT_UNLOCK() (void)pthread_mutex_unlock(&accept_mtx)
|
||||
#endif
|
||||
#define ACCEPT_LOCK_ASSERT() \
|
||||
KASSERT(pthread_mutex_trylock(&accept_mtx) == EBUSY, ("%s: accept_mtx not locked", __func__))
|
||||
#define ACCEPT_UNLOCK_ASSERT() do { \
|
||||
KASSERT(pthread_mutex_trylock(&accept_mtx) == 0, ("%s: accept_mtx locked", __func__)); \
|
||||
(void)pthread_mutex_unlock(&accept_mtx); \
|
||||
} while (0)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Per-socket buffer mutex used to protect most fields in the socket
|
||||
* buffer.
|
||||
*/
|
||||
#define SOCKBUF_MTX(_sb) (&(_sb)->sb_mtx)
|
||||
#if defined(_WIN32)
|
||||
#define SOCKBUF_LOCK_INIT(_sb, _name) \
|
||||
InitializeCriticalSection(SOCKBUF_MTX(_sb))
|
||||
#define SOCKBUF_LOCK_DESTROY(_sb) DeleteCriticalSection(SOCKBUF_MTX(_sb))
|
||||
#define SOCKBUF_COND_INIT(_sb) InitializeConditionVariable((&(_sb)->sb_cond))
|
||||
#define SOCKBUF_COND_DESTROY(_sb) DeleteConditionVariable((&(_sb)->sb_cond))
|
||||
#define SOCK_COND_INIT(_so) InitializeConditionVariable((&(_so)->timeo_cond))
|
||||
#define SOCK_COND_DESTROY(_so) DeleteConditionVariable((&(_so)->timeo_cond))
|
||||
#define SOCK_COND(_so) (&(_so)->timeo_cond)
|
||||
#else
|
||||
#ifdef INVARIANTS
|
||||
#define SOCKBUF_LOCK_INIT(_sb, _name) do { \
|
||||
pthread_mutexattr_t mutex_attr; \
|
||||
\
|
||||
pthread_mutexattr_init(&mutex_attr); \
|
||||
pthread_mutexattr_settype(&mutex_attr, PTHREAD_MUTEX_ERRORCHECK); \
|
||||
pthread_mutex_init(SOCKBUF_MTX(_sb), &mutex_attr); \
|
||||
pthread_mutexattr_destroy(&mutex_attr); \
|
||||
} while (0)
|
||||
#else
|
||||
#define SOCKBUF_LOCK_INIT(_sb, _name) \
|
||||
pthread_mutex_init(SOCKBUF_MTX(_sb), NULL)
|
||||
#endif
|
||||
#define SOCKBUF_LOCK_DESTROY(_sb) pthread_mutex_destroy(SOCKBUF_MTX(_sb))
|
||||
#define SOCKBUF_COND_INIT(_sb) pthread_cond_init((&(_sb)->sb_cond), NULL)
|
||||
#define SOCKBUF_COND_DESTROY(_sb) pthread_cond_destroy((&(_sb)->sb_cond))
|
||||
#define SOCK_COND_INIT(_so) pthread_cond_init((&(_so)->timeo_cond), NULL)
|
||||
#define SOCK_COND_DESTROY(_so) pthread_cond_destroy((&(_so)->timeo_cond))
|
||||
#define SOCK_COND(_so) (&(_so)->timeo_cond)
|
||||
#endif
|
||||
/*__Userspace__ SOCKBUF_LOCK(_sb) is now defined in netinet/sctp_process_lock.h */
|
||||
|
||||
/* #define SOCKBUF_OWNED(_sb) mtx_owned(SOCKBUF_MTX(_sb)) unused */
|
||||
/*__Userspace__ SOCKBUF_UNLOCK(_sb) is now defined in netinet/sctp_process_lock.h */
|
||||
|
||||
/*__Userspace__ SOCKBUF_LOCK_ASSERT(_sb) is now defined in netinet/sctp_process_lock.h */
|
||||
|
||||
/* #define SOCKBUF_UNLOCK_ASSERT(_sb) mtx_assert(SOCKBUF_MTX(_sb), MA_NOTOWNED) unused */
|
||||
|
||||
/*
|
||||
* Per-socket mutex: we reuse the receive socket buffer mutex for space
|
||||
* efficiency. This decision should probably be revisited as we optimize
|
||||
* locking for the socket code.
|
||||
*/
|
||||
#define SOCK_MTX(_so) SOCKBUF_MTX(&(_so)->so_rcv)
|
||||
/*__Userspace__ SOCK_LOCK(_so) is now defined in netinet/sctp_process_lock.h */
|
||||
|
||||
/* #define SOCK_OWNED(_so) SOCKBUF_OWNED(&(_so)->so_rcv) unused */
|
||||
/*__Userspace__ SOCK_UNLOCK(_so) is now defined in netinet/sctp_process_lock.h */
|
||||
|
||||
#define SOCK_LOCK_ASSERT(_so) SOCKBUF_LOCK_ASSERT(&(_so)->so_rcv)
|
||||
|
||||
/*
|
||||
* Socket state bits.
|
||||
*
|
||||
* Historically, this bits were all kept in the so_state field. For
|
||||
* locking reasons, they are now in multiple fields, as they are
|
||||
* locked differently. so_state maintains basic socket state protected
|
||||
* by the socket lock. so_qstate holds information about the socket
|
||||
* accept queues. Each socket buffer also has a state field holding
|
||||
* information relevant to that socket buffer (can't send, rcv). Many
|
||||
* fields will be read without locks to improve performance and avoid
|
||||
* lock order issues. However, this approach must be used with caution.
|
||||
*/
|
||||
#define SS_NOFDREF 0x0001 /* no file table ref any more */
|
||||
#define SS_ISCONNECTED 0x0002 /* socket connected to a peer */
|
||||
#define SS_ISCONNECTING 0x0004 /* in process of connecting to peer */
|
||||
#define SS_ISDISCONNECTING 0x0008 /* in process of disconnecting */
|
||||
#define SS_NBIO 0x0100 /* non-blocking ops */
|
||||
#define SS_ASYNC 0x0200 /* async i/o notify */
|
||||
#define SS_ISCONFIRMING 0x0400 /* deciding to accept connection req */
|
||||
#define SS_ISDISCONNECTED 0x2000 /* socket disconnected from peer */
|
||||
/*
|
||||
* Protocols can mark a socket as SS_PROTOREF to indicate that, following
|
||||
* pru_detach, they still want the socket to persist, and will free it
|
||||
* themselves when they are done. Protocols should only ever call sofree()
|
||||
* following setting this flag in pru_detach(), and never otherwise, as
|
||||
* sofree() bypasses socket reference counting.
|
||||
*/
|
||||
#define SS_PROTOREF 0x4000 /* strong protocol reference */
|
||||
|
||||
/*
|
||||
* Socket state bits now stored in the socket buffer state field.
|
||||
*/
|
||||
#define SBS_CANTSENDMORE 0x0010 /* can't send more data to peer */
|
||||
#define SBS_CANTRCVMORE 0x0020 /* can't receive more data from peer */
|
||||
#define SBS_RCVATMARK 0x0040 /* at mark on input */
|
||||
|
||||
/*
|
||||
* Socket state bits stored in so_qstate.
|
||||
*/
|
||||
#define SQ_INCOMP 0x0800 /* unaccepted, incomplete connection */
|
||||
#define SQ_COMP 0x1000 /* unaccepted, complete connection */
|
||||
|
||||
/*
|
||||
* Socket event flags
|
||||
*/
|
||||
#define SCTP_EVENT_READ 0x0001 /* socket is readable */
|
||||
#define SCTP_EVENT_WRITE 0x0002 /* socket is writeable */
|
||||
#define SCTP_EVENT_ERROR 0x0004 /* socket has an error state */
|
||||
|
||||
|
||||
/*-------------------------------------------------------------*/
|
||||
/*-------------------------------------------------------------*/
|
||||
/* __Userspace__ */
|
||||
/*-------------------------------------------------------------*/
|
||||
/*-------------------------------------------------------------*/
|
||||
/* this new __Userspace__ section is to copy portions of the _KERNEL block
|
||||
* above into, avoiding having to port the entire thing at once...
|
||||
* For function prototypes, the full bodies are in user_socket.c .
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------- */
|
||||
/* --- function prototypes (implemented in user_socket.c) --- */
|
||||
/* ---------------------------------------------------------- */
|
||||
void soisconnecting(struct socket *so);
|
||||
void soisdisconnecting(struct socket *so);
|
||||
void soisconnected(struct socket *so);
|
||||
struct socket * sonewconn(struct socket *head, int connstatus);
|
||||
void socantrcvmore(struct socket *so);
|
||||
void socantsendmore(struct socket *so);
|
||||
void sofree(struct socket *so);
|
||||
|
||||
|
||||
|
||||
/* -------------- */
|
||||
/* --- macros --- */
|
||||
/* -------------- */
|
||||
|
||||
#define soref(so) do { \
|
||||
SOCK_LOCK_ASSERT(so); \
|
||||
++(so)->so_count; \
|
||||
} while (0)
|
||||
|
||||
#define sorele(so) do { \
|
||||
ACCEPT_LOCK_ASSERT(); \
|
||||
SOCK_LOCK_ASSERT(so); \
|
||||
KASSERT((so)->so_count > 0, ("sorele")); \
|
||||
if (--(so)->so_count == 0) \
|
||||
sofree(so); \
|
||||
else { \
|
||||
SOCK_UNLOCK(so); \
|
||||
ACCEPT_UNLOCK(); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
|
||||
/* replacing imin with min (user_environment.h) */
|
||||
#define sbspace(sb) \
|
||||
((long) min((int)((sb)->sb_hiwat - (sb)->sb_cc), \
|
||||
(int)((sb)->sb_mbmax - (sb)->sb_mbcnt)))
|
||||
|
||||
/* do we have to send all at once on a socket? */
|
||||
#define sosendallatonce(so) \
|
||||
((so)->so_proto->pr_flags & PR_ATOMIC)
|
||||
|
||||
/* can we read something from so? */
|
||||
#define soreadable(so) \
|
||||
((int)((so)->so_rcv.sb_cc) >= (so)->so_rcv.sb_lowat || \
|
||||
((so)->so_rcv.sb_state & SBS_CANTRCVMORE) || \
|
||||
!TAILQ_EMPTY(&(so)->so_comp) || (so)->so_error)
|
||||
|
||||
#if 0 /* original */
|
||||
#define PR_CONNREQUIRED 0x04 /* from sys/protosw.h "needed" for sowriteable */
|
||||
#define sowriteable(so) \
|
||||
((sbspace(&(so)->so_snd) >= (so)->so_snd.sb_lowat && \
|
||||
(((so)->so_state&SS_ISCONNECTED) || \
|
||||
((so)->so_proto->pr_flags&PR_CONNREQUIRED)==0)) || \
|
||||
((so)->so_snd.sb_state & SBS_CANTSENDMORE) || \
|
||||
(so)->so_error)
|
||||
#else /* line with PR_CONNREQUIRED removed */
|
||||
/* can we write something to so? */
|
||||
#define sowriteable(so) \
|
||||
((sbspace(&(so)->so_snd) >= (so)->so_snd.sb_lowat && \
|
||||
(((so)->so_state&SS_ISCONNECTED))) || \
|
||||
((so)->so_snd.sb_state & SBS_CANTSENDMORE) || \
|
||||
(so)->so_error)
|
||||
#endif
|
||||
|
||||
extern void solisten_proto(struct socket *so, int backlog);
|
||||
extern int solisten_proto_check(struct socket *so);
|
||||
extern int sctp_listen(struct socket *so, int backlog, struct proc *p);
|
||||
extern void socantrcvmore_locked(struct socket *so);
|
||||
extern int sctp_bind(struct socket *so, struct sockaddr *addr);
|
||||
extern int sctp6_bind(struct socket *so, struct sockaddr *addr, void *proc);
|
||||
extern int sctpconn_bind(struct socket *so, struct sockaddr *addr);
|
||||
extern int sctp_accept(struct socket *so, struct sockaddr **addr);
|
||||
extern int sctp_attach(struct socket *so, int proto, uint32_t vrf_id);
|
||||
extern int sctp6_attach(struct socket *so, int proto, uint32_t vrf_id);
|
||||
extern int sctp_abort(struct socket *so);
|
||||
extern int sctp6_abort(struct socket *so);
|
||||
extern void sctp_close(struct socket *so);
|
||||
extern int soaccept(struct socket *so, struct sockaddr **nam);
|
||||
extern int solisten(struct socket *so, int backlog);
|
||||
extern int soreserve(struct socket *so, u_long sndcc, u_long rcvcc);
|
||||
extern void sowakeup(struct socket *so, struct sockbuf *sb);
|
||||
extern void wakeup(void *ident, struct socket *so); /*__Userspace__ */
|
||||
extern int uiomove(void *cp, int n, struct uio *uio);
|
||||
extern int sbwait(struct sockbuf *sb);
|
||||
extern int sodisconnect(struct socket *so);
|
||||
extern int soconnect(struct socket *so, struct sockaddr *nam);
|
||||
extern int sctp_disconnect(struct socket *so);
|
||||
extern int sctp_connect(struct socket *so, struct sockaddr *addr);
|
||||
extern int sctp6_connect(struct socket *so, struct sockaddr *addr);
|
||||
extern int sctpconn_connect(struct socket *so, struct sockaddr *addr);
|
||||
extern void sctp_finish(void);
|
||||
|
||||
/* ------------------------------------------------ */
|
||||
/* ----- macros copied from above ---- */
|
||||
/* ------------------------------------------------ */
|
||||
|
||||
/*
|
||||
* Do we need to notify the other side when I/O is possible?
|
||||
*/
|
||||
#define sb_notify(sb) (((sb)->sb_flags & (SB_WAIT | SB_SEL | SB_ASYNC | \
|
||||
SB_UPCALL | SB_AIO | SB_KNOTE)) != 0)
|
||||
|
||||
|
||||
/*
|
||||
* In sorwakeup() and sowwakeup(), acquire the socket buffer lock to
|
||||
* avoid a non-atomic test-and-wakeup. However, sowakeup is
|
||||
* responsible for releasing the lock if it is called. We unlock only
|
||||
* if we don't call into sowakeup. If any code is introduced that
|
||||
* directly invokes the underlying sowakeup() primitives, it must
|
||||
* maintain the same semantics.
|
||||
*/
|
||||
#define sorwakeup_locked(so) do { \
|
||||
SOCKBUF_LOCK_ASSERT(&(so)->so_rcv); \
|
||||
if (sb_notify(&(so)->so_rcv)) \
|
||||
sowakeup((so), &(so)->so_rcv); \
|
||||
else \
|
||||
SOCKBUF_UNLOCK(&(so)->so_rcv); \
|
||||
} while (0)
|
||||
|
||||
#define sorwakeup(so) do { \
|
||||
SOCKBUF_LOCK(&(so)->so_rcv); \
|
||||
sorwakeup_locked(so); \
|
||||
} while (0)
|
||||
|
||||
#define sowwakeup_locked(so) do { \
|
||||
SOCKBUF_LOCK_ASSERT(&(so)->so_snd); \
|
||||
if (sb_notify(&(so)->so_snd)) \
|
||||
sowakeup((so), &(so)->so_snd); \
|
||||
else \
|
||||
SOCKBUF_UNLOCK(&(so)->so_snd); \
|
||||
} while (0)
|
||||
|
||||
#define sowwakeup(so) do { \
|
||||
SOCKBUF_LOCK(&(so)->so_snd); \
|
||||
sowwakeup_locked(so); \
|
||||
} while (0)
|
||||
|
||||
#endif /* !_SYS_SOCKETVAR_H_ */
|
||||
96
TMessagesProj/jni/third_party/usrsctplib/user_uma.h
vendored
Executable file
96
TMessagesProj/jni/third_party/usrsctplib/user_uma.h
vendored
Executable file
|
|
@ -0,0 +1,96 @@
|
|||
/*-
|
||||
* Copyright (c) 2009-2010 Brad Penoff
|
||||
* Copyright (c) 2009-2010 Humaira Kamal
|
||||
* Copyright (c) 2011-2012 Irene Ruengeler
|
||||
* Copyright (c) 2011-2012 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:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. 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.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
|
||||
*/
|
||||
|
||||
#ifndef _USER_UMA_H_
|
||||
#define _USER_UMA_H_
|
||||
|
||||
#define UMA_ZFLAG_FULL 0x40000000 /* Reached uz_maxpages */
|
||||
#define UMA_ALIGN_PTR (sizeof(void *) - 1) /* Alignment fit for ptr */
|
||||
|
||||
/* __Userspace__ All these definitions will change for
|
||||
userspace Universal Memory Allocator (UMA). These are included
|
||||
for reference purposes and to avoid compile errors for the time being.
|
||||
*/
|
||||
typedef int (*uma_ctor)(void *mem, int size, void *arg, int flags);
|
||||
typedef void (*uma_dtor)(void *mem, int size, void *arg);
|
||||
typedef int (*uma_init)(void *mem, int size, int flags);
|
||||
typedef void (*uma_fini)(void *mem, int size);
|
||||
typedef struct uma_zone * uma_zone_t;
|
||||
typedef struct uma_keg * uma_keg_t;
|
||||
|
||||
struct uma_cache {
|
||||
int stub; /* TODO __Userspace__ */
|
||||
};
|
||||
|
||||
struct uma_keg {
|
||||
int stub; /* TODO __Userspace__ */
|
||||
};
|
||||
|
||||
struct uma_zone {
|
||||
char *uz_name; /* Text name of the zone */
|
||||
struct mtx *uz_lock; /* Lock for the zone (keg's lock) */
|
||||
uma_keg_t uz_keg; /* Our underlying Keg */
|
||||
|
||||
LIST_ENTRY(uma_zone) uz_link; /* List of all zones in keg */
|
||||
LIST_HEAD(,uma_bucket) uz_full_bucket; /* full buckets */
|
||||
LIST_HEAD(,uma_bucket) uz_free_bucket; /* Buckets for frees */
|
||||
|
||||
uma_ctor uz_ctor; /* Constructor for each allocation */
|
||||
uma_dtor uz_dtor; /* Destructor */
|
||||
uma_init uz_init; /* Initializer for each item */
|
||||
uma_fini uz_fini; /* Discards memory */
|
||||
|
||||
u_int64_t uz_allocs; /* Total number of allocations */
|
||||
u_int64_t uz_frees; /* Total number of frees */
|
||||
u_int64_t uz_fails; /* Total number of alloc failures */
|
||||
uint16_t uz_fills; /* Outstanding bucket fills */
|
||||
uint16_t uz_count; /* Highest value ub_ptr can have */
|
||||
|
||||
/*
|
||||
* This HAS to be the last item because we adjust the zone size
|
||||
* based on NCPU and then allocate the space for the zones.
|
||||
*/
|
||||
struct uma_cache uz_cpu[1]; /* Per cpu caches */
|
||||
};
|
||||
|
||||
/* Prototype */
|
||||
uma_zone_t
|
||||
uma_zcreate(char *name, size_t size, uma_ctor ctor, uma_dtor dtor,
|
||||
uma_init uminit, uma_fini fini, int align, uint32_t flags);
|
||||
|
||||
|
||||
#define uma_zone_set_max(zone, number) /* stub TODO __Userspace__ */
|
||||
|
||||
uma_zone_t
|
||||
uma_zcreate(char *name, size_t size, uma_ctor ctor, uma_dtor dtor,
|
||||
uma_init uminit, uma_fini fini, int align, uint32_t flags) {
|
||||
return NULL; /* stub TODO __Userspace__. Also place implementation in a separate .c file */
|
||||
}
|
||||
#endif
|
||||
1321
TMessagesProj/jni/third_party/usrsctplib/usrsctp.h
vendored
Normal file
1321
TMessagesProj/jni/third_party/usrsctplib/usrsctp.h
vendored
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue