Commit 6f71b757 authored by ldixon@google.com's avatar ldixon@google.com

Updated usrsctp to latest version (to 8603) with fixes upstream. Fixed usrsctp...

Updated usrsctp to latest version (to 8603) with fixes upstream. Fixed usrsctp gyp file; removed overides. 

usrsctp update = 8554:8603

Review URL: https://chromiumcodereview.appspot.com/23960004

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@221656 0039d316-1c4b-4281-b951-d872f2087c98
parent 567ff5af
...@@ -175,7 +175,7 @@ deps = { ...@@ -175,7 +175,7 @@ deps = {
"src/third_party/usrsctp/usrsctplib": "src/third_party/usrsctp/usrsctplib":
(Var("googlecode_url") % "sctp-refimpl") + (Var("googlecode_url") % "sctp-refimpl") +
"/trunk/KERN/usrsctp/usrsctplib@8554", "/trunk/KERN/usrsctp/usrsctplib@8603",
"src/third_party/libsrtp": "src/third_party/libsrtp":
"/trunk/deps/third_party/libsrtp@214783", "/trunk/deps/third_party/libsrtp@214783",
......
/*-
* 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.
*/
#ifdef __FreeBSD__
#include <sys/cdefs.h>
__FBSDID("$FreeBSD: head/sys/netinet/sctp_auth.h 235828 2012-05-23 11:26:28Z tuexen $");
#endif
#ifndef _NETINET_SCTP_AUTH_H_
#define _NETINET_SCTP_AUTH_H_
#include <netinet/sctp_sha1.h>
/* digest lengths */
#define SCTP_AUTH_DIGEST_LEN_SHA1 20
#define SCTP_AUTH_DIGEST_LEN_SHA224 28
#define SCTP_AUTH_DIGEST_LEN_SHA256 32
#define SCTP_AUTH_DIGEST_LEN_SHA384 48
#define SCTP_AUTH_DIGEST_LEN_SHA512 64
#define SCTP_AUTH_DIGEST_LEN_MAX 64
/* random sizes */
#define SCTP_AUTH_RANDOM_SIZE_DEFAULT 32
#define SCTP_AUTH_RANDOM_SIZE_REQUIRED 32
#define SCTP_AUTH_RANDOM_SIZE_MAX 256
/* union of all supported HMAC algorithm contexts */
typedef union sctp_hash_context {
SHA1_CTX sha1;
#ifdef HAVE_SHA2
SHA256_CTX sha256;
SHA384_CTX sha384;
SHA512_CTX sha512;
#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 void sctp_auth_set_default_chunks(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(uint8_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 int sctp_verify_hmac(uint16_t hmac_algo, uint8_t *key, uint32_t keylen,
uint8_t *text, uint32_t textlen, uint8_t *digest, uint32_t digestlen);
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__ */
/*-
* 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.
*/
#ifdef __FreeBSD__
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#endif
#ifdef SCTP_USE_NSS_SHA1
#include <netinet/sctp_nss_sha1.h>
/* A SHA-1 Digest is 160 bits, or 20 bytes */
#define SHA_DIGEST_LENGTH (20)
void
SCTP_NSS_SHA1_Init(struct sha1_context *ctx)
{
ctx->pk11_ctx = PK11_CreateDigestContext(SEC_OID_SHA1);
PK11_DigestBegin(ctx->pk11_ctx);
}
void
SCTP_NSS_SHA1_Update(struct sha1_context *ctx, const unsigned char *ptr, int siz)
{
PK11_DigestOp(ctx->pk11_ctx, ptr, siz);
}
void
SCTP_NSS_SHA1_Final(unsigned char *digest, struct 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);
}
#endif
/*-
* 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.
*/
#ifdef __FreeBSD__
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#endif
#ifndef __SCTP_NSS_SHA1_h__
#define __SCTP_NSS_SHA1_h__
#ifdef __Userspace_os_Darwin
#define __APPLE__
#endif
#include <sys/types.h>
#include <pk11pub.h>
#ifdef __Userspace_os_Darwin
#undef __APPLE__
#endif
struct sha1_context {
struct PK11Context *pk11_ctx;
}; // Opaque structure.
typedef struct sha1_context SHA1_CTX;
#if defined(_KERNEL) || defined(__Userspace__)
#define SHA1_Init SCTP_NSS_SHA1_Init
#define SHA1_Update SCTP_NSS_SHA1_Update
#define SHA1_Final SCTP_NSS_SHA1_Final
#endif /* _KERNEL */
#endif /* __SCTP_NSS_SHA1_h__ */
/*-
* 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.
*/
#ifdef __FreeBSD__
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#endif
#ifndef __SCTP_OPENSSL_SHA1_h__
#define __SCTP_OPENSSL_SHA1_h__
#include <openssl/md5.h>
#include <openssl/sha.h>
/* libssl-dev calls this SHA_CTX, but it's refered to as SHA1_CTX within the
* SCTP stack code so here we typedef (or macro?) to equate the two.
*/
typedef SHA_CTX SHA1_CTX;
#endif
/*-
* 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.
*/
#ifdef __FreeBSD__
#include <sys/cdefs.h>
__FBSDID("$FreeBSD: head/sys/netinet/sctp_os.h 235828 2012-05-23 11:26:28Z tuexen $");
#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__)
#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__)
#undef __APPLE__
// #include <netinet/sctp_os_macosx.h>
#endif
#if defined(__Panda__)
#include <ip/sctp/sctp_os_iox.h>
#endif
#if defined(__Windows__)
#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
/*-
* 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.
*/
#ifdef __FreeBSD__
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#endif
#ifndef __SCTP_SHA1_h__
#define __SCTP_SHA1_h__
#include <sys/types.h>
#if !defined(SSL_USE_OPENSSL) && !defined(SSL_USE_NSS)
#if defined(WIN32)
#define SCTP_USE_SCTP_SHA1 1
#else // defined(WIN32)
#if defined(HAVE_OPENSSL_SSL_H)
#define SSL_USE_OPENSSL 1
#elif defined(HAVE_NSS_SSL_H)
#define SSL_USE_NSS 1
#else
#define SCTP_USE_SCTP_SHA1
#endif
#endif // !defined(WIN32)
#endif
#if defined(SSL_USE_NSS)
#include <netinet/sctp_nss_sha1.h>
#elif defined(SSL_USE_OPENSSL)
#include <netinet/sctp_openssl_sha1.h>
#else // SCTP_USE_SCTP_SHA1
struct sha1_context {
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;
};
typedef struct sha1_context SHA1_CTX;
#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
#if (defined(__APPLE__) && defined(KERNEL))
#ifndef _KERNEL
#define _KERNEL
#endif
#endif
#if defined(_KERNEL) || defined(__Userspace__)
void SHA1_Init(struct sha1_context *);
void SHA1_Update(struct sha1_context *, const unsigned char *, int);
void SHA1_Final(unsigned char *, struct sha1_context *);
#endif /* _KERNEL */
#endif /* !defined(SSL_USE_OPENSSL) && !defined(SSL_USE_NSS) */
#endif /* __SCTP_SHA1_h__ */
...@@ -13,42 +13,28 @@ ...@@ -13,42 +13,28 @@
# 'SCTP_DEBUG', # Uncomment for SCTP debugging. # 'SCTP_DEBUG', # Uncomment for SCTP debugging.
], ],
'include_dirs': [ 'include_dirs': [
'overrides/usrsctplib',
'overrides/usrsctplib/netinet',
'usrsctplib/', 'usrsctplib/',
'usrsctplib/netinet', 'usrsctplib/netinet',
'usrsctplib/netinet6',
], ],
'direct_dependent_settings': { 'direct_dependent_settings': {
'include_dirs': [ 'include_dirs': [
'overrides/usrsctplib',
'overrides/usrsctplib/netinet',
'usrsctplib/', 'usrsctplib/',
'usrsctplib/netinet', 'usrsctplib/netinet',
'usrsctplib/netinet6',
], ],
}, },
'conditions': [ 'conditions': [
['use_openssl==1', { ['use_openssl==1', {
'defines': [ 'defines': [
'SSL_USE_OPENSSL', 'SCTP_USE_OPENSSL_SHA1',
], ],
'dependencies': [ 'dependencies': [
'<(DEPTH)/third_party/openssl/openssl.gyp:openssl', '<(DEPTH)/third_party/openssl/openssl.gyp:openssl',
], ],
'sources': [
'overrides/usrsctplib/netinet/sctp_openssl_sha1.h',
],
}, },
{ # else use_openssl==0, use NSS. { # else use_openssl==0, use NSS.
'defines' : [ 'defines' : [
'SSL_USE_NSS',
'SCTP_USE_NSS_SHA1', 'SCTP_USE_NSS_SHA1',
], ],
'sources': [
'overrides/usrsctplib/netinet/sctp_nss_sha1.c',
'overrides/usrsctplib/netinet/sctp_nss_sha1.h',
],
'conditions': [ 'conditions': [
['os_posix == 1 and OS != "mac" and OS != "ios" and OS != "android"', { ['os_posix == 1 and OS != "mac" and OS != "ios" and OS != "android"', {
'dependencies': [ # The system.gyp:ssl dependency includes nss 'dependencies': [ # The system.gyp:ssl dependency includes nss
...@@ -70,30 +56,10 @@ ...@@ -70,30 +56,10 @@
'target_name': 'usrsctplib', 'target_name': 'usrsctplib',
'type': 'static_library', 'type': 'static_library',
'sources': [ 'sources': [
'overrides/usrsctplib/netinet/sctp_auth.h',
'overrides/usrsctplib/netinet/sctp_os.h',
'overrides/usrsctplib/netinet/sctp_os_userspace.h',
'overrides/usrsctplib/netinet/sctp_sha1.h',
'usrsctplib/usrsctp.h',
'usrsctplib/user_atomic.h',
'usrsctplib/user_environment.c',
'usrsctplib/user_environment.h',
'usrsctplib/user_inpcb.h',
'usrsctplib/user_ip6_var.h',
'usrsctplib/user_ip_icmp.h',
'usrsctplib/user_mbuf.c',
'usrsctplib/user_mbuf.h',
'usrsctplib/user_queue.h',
'usrsctplib/user_recv_thread.c',
'usrsctplib/user_recv_thread.h',
'usrsctplib/user_route.h',
'usrsctplib/user_sctp_timer_iterate.c',
'usrsctplib/user_socket.c',
'usrsctplib/user_socketvar.h',
'usrsctplib/user_uma.h',
'usrsctplib/netinet/sctp_asconf.c', 'usrsctplib/netinet/sctp_asconf.c',
'usrsctplib/netinet/sctp_asconf.h', 'usrsctplib/netinet/sctp_asconf.h',
'usrsctplib/netinet/sctp_auth.c', 'usrsctplib/netinet/sctp_auth.c',
'usrsctplib/netinet/sctp_auth.h',
'usrsctplib/netinet/sctp_bsd_addr.c', 'usrsctplib/netinet/sctp_bsd_addr.c',
'usrsctplib/netinet/sctp_bsd_addr.h', 'usrsctplib/netinet/sctp_bsd_addr.h',
'usrsctplib/netinet/sctp_callout.c', 'usrsctplib/netinet/sctp_callout.c',
...@@ -108,12 +74,16 @@ ...@@ -108,12 +74,16 @@
'usrsctplib/netinet/sctp_input.c', 'usrsctplib/netinet/sctp_input.c',
'usrsctplib/netinet/sctp_input.h', 'usrsctplib/netinet/sctp_input.h',
'usrsctplib/netinet/sctp_lock_userspace.h', 'usrsctplib/netinet/sctp_lock_userspace.h',
'usrsctplib/netinet/sctp_os.h',
'usrsctplib/netinet/sctp_os_userspace.h',
'usrsctplib/netinet/sctp_output.c', 'usrsctplib/netinet/sctp_output.c',
'usrsctplib/netinet/sctp_output.h', 'usrsctplib/netinet/sctp_output.h',
'usrsctplib/netinet/sctp_pcb.c', 'usrsctplib/netinet/sctp_pcb.c',
'usrsctplib/netinet/sctp_pcb.h', 'usrsctplib/netinet/sctp_pcb.h',
'usrsctplib/netinet/sctp_peeloff.c', 'usrsctplib/netinet/sctp_peeloff.c',
'usrsctplib/netinet/sctp_peeloff.h', 'usrsctplib/netinet/sctp_peeloff.h',
'usrsctplib/netinet/sctp_sha1.c',
'usrsctplib/netinet/sctp_sha1.h',
'usrsctplib/netinet/sctp_ss_functions.c', 'usrsctplib/netinet/sctp_ss_functions.c',
'usrsctplib/netinet/sctp_structs.h', 'usrsctplib/netinet/sctp_structs.h',
'usrsctplib/netinet/sctp_sysctl.c', 'usrsctplib/netinet/sctp_sysctl.c',
...@@ -123,9 +93,26 @@ ...@@ -123,9 +93,26 @@
'usrsctplib/netinet/sctp_uio.h', 'usrsctplib/netinet/sctp_uio.h',
'usrsctplib/netinet/sctp_userspace.c', 'usrsctplib/netinet/sctp_userspace.c',
'usrsctplib/netinet/sctp_usrreq.c', 'usrsctplib/netinet/sctp_usrreq.c',
'usrsctplib/netinet/sctp_var.h',
'usrsctplib/netinet/sctputil.c', 'usrsctplib/netinet/sctputil.c',
'usrsctplib/netinet/sctputil.h', 'usrsctplib/netinet/sctputil.h',
'usrsctplib/netinet/sctp_var.h', 'usrsctplib/user_atomic.h',
'usrsctplib/user_environment.c',
'usrsctplib/user_environment.h',
'usrsctplib/user_inpcb.h',
'usrsctplib/user_ip6_var.h',
'usrsctplib/user_ip_icmp.h',
'usrsctplib/user_mbuf.c',
'usrsctplib/user_mbuf.h',
'usrsctplib/user_queue.h',
'usrsctplib/user_recv_thread.c',
'usrsctplib/user_recv_thread.h',
'usrsctplib/user_route.h',
'usrsctplib/user_sctp_timer_iterate.c',
'usrsctplib/user_socket.c',
'usrsctplib/user_socketvar.h',
'usrsctplib/user_uma.h',
'usrsctplib/usrsctp.h',
], # sources ], # sources
'conditions': [ 'conditions': [
['OS=="linux"', { ['OS=="linux"', {
...@@ -142,15 +129,23 @@ ...@@ -142,15 +129,23 @@
'__APPLE_USE_RFC_2292', '__APPLE_USE_RFC_2292',
'__Userspace_os_Darwin', '__Userspace_os_Darwin',
], ],
# TODO(ldixon): explore why gyp cflags here does not get picked up. # usrsctp requires that __APPLE__ is undefined for compilation (for
# historical reasons). There is a plan to change this, and when it
# happens and we re-roll DEPS for usrsctp, we can remove the manual
# undefining of __APPLE__.
'xcode_settings': { 'xcode_settings': {
'OTHER_CFLAGS!': [ '-Werror', '-Wall' ], 'OTHER_CFLAGS!': [ '-Werror', '-Wall' ],
'OTHER_CFLAGS': [ '-w' ], 'OTHER_CFLAGS': [ '-U__APPLE__', '-w' ],
}, },
}], }],
['OS=="win"', { ['OS=="win"', {
'defines': [ 'defines': [
'__Userspace_os_Windows', '__Userspace_os_Windows',
# Manually setting WINVER and _WIN32_WINNT is needed because Chrome
# sets WINVER to a newer version of windows. But compiling usrsctp
# this way would is incompatible with windows XP.
'WINVER=0x0502',
'_WIN32_WINNT=0x0502',
], ],
'cflags!': [ '/W3', '/WX' ], 'cflags!': [ '/W3', '/WX' ],
'cflags': [ '/w' ], 'cflags': [ '/w' ],
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment