diff options
author | Android Chromium Automerger <chromium-automerger@android> | 2014-10-02 00:26:36 +0000 |
---|---|---|
committer | Android Chromium Automerger <chromium-automerger@android> | 2014-10-02 00:26:36 +0000 |
commit | 524321421920f031158210af68b238db190b6fcb (patch) | |
tree | 09f63226c3e60c24a670e0899f134d2722fc217c | |
parent | 793f45e9442f232795b0a33a22de234710c06613 (diff) | |
parent | d5685d4cc67d1fba57b7cb0024fc9065971e5ac1 (diff) | |
download | usrsctplib-524321421920f031158210af68b238db190b6fcb.tar.gz |
Merge third_party/usrsctp/usrsctplib from https://chromium.googlesource.com/external/usrsctplib.git at d5685d4cc67d1fba57b7cb0024fc9065971e5ac1
This commit was generated by merge_from_chromium.py.
Change-Id: I12fa2c1bcb9e48a54975f5346a7fcebd63ff1d10
-rw-r--r-- | Makefile.nmake | 2 | ||||
-rwxr-xr-x | netinet/sctp_auth.c | 8 | ||||
-rwxr-xr-x | netinet/sctp_auth.h | 4 | ||||
-rwxr-xr-x | netinet/sctp_bsd_addr.c | 6 | ||||
-rwxr-xr-x | netinet/sctp_cc_functions.c | 14 | ||||
-rwxr-xr-x | netinet/sctp_os_userspace.h | 152 | ||||
-rwxr-xr-x | netinet/sctp_output.c | 9 | ||||
-rwxr-xr-x | netinet/sctp_pcb.c | 6 | ||||
-rwxr-xr-x | netinet/sctp_structs.h | 6 | ||||
-rwxr-xr-x | netinet/sctp_userspace.c | 27 | ||||
-rwxr-xr-x | netinet/sctp_usrreq.c | 9 | ||||
-rwxr-xr-x | netinet/sctputil.c | 6 | ||||
-rwxr-xr-x | user_route.h | 2 | ||||
-rwxr-xr-x | user_sctp_timer_iterate.c | 3 | ||||
-rwxr-xr-x | user_socket.c | 8 | ||||
-rwxr-xr-x | user_socketvar.h | 4 |
16 files changed, 147 insertions, 119 deletions
diff --git a/Makefile.nmake b/Makefile.nmake index a564fd4..9be1077 100644 --- a/Makefile.nmake +++ b/Makefile.nmake @@ -28,7 +28,7 @@ # SUCH DAMAGE.
#
-CFLAGS=/I. /W3
+CFLAGS=/I. /W3 /WX
CVARSDLL=-DSCTP_DEBUG -DSCTP_SIMPLE_ALLOCATOR -DSCTP_PROCESS_LEVEL_LOCKS
CVARSDLL=$(CVARSDLL) -D__Userspace__ -D__Userspace_os_Windows
diff --git a/netinet/sctp_auth.c b/netinet/sctp_auth.c index 00ff978..50432ad 100755 --- a/netinet/sctp_auth.c +++ b/netinet/sctp_auth.c @@ -32,7 +32,7 @@ #ifdef __FreeBSD__ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: head/sys/netinet/sctp_auth.c 269858 2014-08-12 11:30:16Z tuexen $"); +__FBSDID("$FreeBSD: head/sys/netinet/sctp_auth.c 271673 2014-09-16 14:20:33Z tuexen $"); #endif #include <netinet/sctp_os.h> @@ -633,7 +633,7 @@ sctp_copy_skeylist(const struct sctp_keyhead *src, struct sctp_keyhead *dest) sctp_hmaclist_t * -sctp_alloc_hmaclist(uint8_t num_hmacs) +sctp_alloc_hmaclist(uint16_t num_hmacs) { sctp_hmaclist_t *new_list; int alloc_size; @@ -1464,8 +1464,8 @@ sctp_auth_get_cookie_params(struct sctp_tcb *stcb, struct mbuf *m, p_random = (struct sctp_auth_random *)phdr; random_len = plen - sizeof(*p_random); } else if (ptype == SCTP_HMAC_LIST) { - int num_hmacs; - int i; + uint16_t num_hmacs; + uint16_t i; if (plen > sizeof(hmacs_store)) break; diff --git a/netinet/sctp_auth.h b/netinet/sctp_auth.h index 04649ad..9973893 100755 --- a/netinet/sctp_auth.h +++ b/netinet/sctp_auth.h @@ -32,7 +32,7 @@ #ifdef __FreeBSD__ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: head/sys/netinet/sctp_auth.h 269858 2014-08-12 11:30:16Z tuexen $"); +__FBSDID("$FreeBSD: head/sys/netinet/sctp_auth.h 271673 2014-09-16 14:20:33Z tuexen $"); #endif #ifndef _NETINET_SCTP_AUTH_H_ @@ -149,7 +149,7 @@ extern void sctp_auth_key_release(struct sctp_tcb *stcb, uint16_t keyid, /* hmac list handling */ -extern sctp_hmaclist_t *sctp_alloc_hmaclist(uint8_t num_hmacs); +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); diff --git a/netinet/sctp_bsd_addr.c b/netinet/sctp_bsd_addr.c index fe20ea9..b9ddb48 100755 --- a/netinet/sctp_bsd_addr.c +++ b/netinet/sctp_bsd_addr.c @@ -355,7 +355,7 @@ sctp_init_ifns_for_vrf(int vrfid) continue; } ifa = (struct ifaddrs*)malloc(sizeof(struct ifaddrs)); - ifa->ifa_name = strdup(pAdapt->AdapterName); + ifa->ifa_name = _strdup(pAdapt->AdapterName); ifa->ifa_flags = pAdapt->Flags; ifa->ifa_addr = (struct sockaddr *)malloc(sizeof(struct sockaddr_in)); memcpy(ifa->ifa_addr, pUnicast->Address.lpSockaddr, sizeof(struct sockaddr_in)); @@ -403,7 +403,7 @@ sctp_init_ifns_for_vrf(int vrfid) if (pAdapt->IfType == IF_TYPE_IEEE80211 || pAdapt->IfType == IF_TYPE_ETHERNET_CSMACD) { for (pUnicast = pAdapt->FirstUnicastAddress; pUnicast; pUnicast = pUnicast->Next) { ifa = (struct ifaddrs*)malloc(sizeof(struct ifaddrs)); - ifa->ifa_name = strdup(pAdapt->AdapterName); + ifa->ifa_name = _strdup(pAdapt->AdapterName); ifa->ifa_flags = pAdapt->Flags; ifa->ifa_addr = (struct sockaddr *)malloc(sizeof(struct sockaddr_in6)); memcpy(ifa->ifa_addr, pUnicast->Address.lpSockaddr, sizeof(struct sockaddr_in6)); @@ -745,7 +745,7 @@ sctp_addr_change(struct ifaddr *ifa, int cmd) 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. */ diff --git a/netinet/sctp_cc_functions.c b/netinet/sctp_cc_functions.c index 6c6c946..3027e46 100755 --- a/netinet/sctp_cc_functions.c +++ b/netinet/sctp_cc_functions.c @@ -32,7 +32,7 @@ #ifdef __FreeBSD__ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: head/sys/netinet/sctp_cc_functions.c 240158 2012-09-06 07:03:56Z tuexen $"); +__FBSDID("$FreeBSD: head/sys/netinet/sctp_cc_functions.c 271672 2014-09-16 13:48:46Z tuexen $"); #endif #include <netinet/sctp_os.h> @@ -1218,12 +1218,9 @@ sctp_cwnd_update_after_packet_dropped(struct sctp_tcb *stcb, uint32_t *bottle_bw, uint32_t *on_queue) { uint32_t bw_avail; - int rtt; unsigned int incr; int old_cwnd = net->cwnd; - /* need real RTT in msd for this calc */ - rtt = net->rtt / 1000; /* get bottle neck bw */ *bottle_bw = ntohl(cp->bottle_bw); /* and whats on queue */ @@ -1232,10 +1229,11 @@ sctp_cwnd_update_after_packet_dropped(struct sctp_tcb *stcb, * adjust the on-queue if our flight is more it could be * that the router has not yet gotten data "in-flight" to it */ - if (*on_queue < net->flight_size) + if (*on_queue < net->flight_size) { *on_queue = net->flight_size; - /* calculate the available space */ - bw_avail = (*bottle_bw * rtt) / 1000; + } + /* rtt is measured in micro seconds, bottle_bw in bytes per second */ + bw_avail = (uint32_t)(((uint64_t)(*bottle_bw) * net->rtt) / (uint64_t)1000000); if (bw_avail > *bottle_bw) { /* * Cap the growth to no more than the bottle neck. @@ -1253,8 +1251,8 @@ sctp_cwnd_update_after_packet_dropped(struct sctp_tcb *stcb, * else to be "added to the fire". */ int seg_inflight, seg_onqueue, my_portion; - net->partial_bytes_acked = 0; + net->partial_bytes_acked = 0; /* how much are we over queue size? */ incr = *on_queue - bw_avail; if (stcb->asoc.seen_a_sack_this_pkt) { diff --git a/netinet/sctp_os_userspace.h b/netinet/sctp_os_userspace.h index eca3e18..e8de92f 100755 --- a/netinet/sctp_os_userspace.h +++ b/netinet/sctp_os_userspace.h @@ -103,7 +103,6 @@ typedef HANDLE userland_thread_t; #define n_time unsigned __int32 #define sa_family_t unsigned __int8 #define ssize_t __int64 -#define IFNAMSIZ 64 #define __func__ __FUNCTION__ #ifndef EWOULDBLOCK @@ -222,8 +221,6 @@ typedef char* caddr_t; #define snprintf(data, size, format, ...) _snprintf_s(data, size, _TRUNCATE, format, __VA_ARGS__) #define inline __inline #define __inline__ __inline -#define random() rand() -#define srandom(s) srand(s) #define MSG_EOR 0x8 /* data completes record */ #define MSG_DONTWAIT 0x80 /* this message should be nonblocking */ @@ -265,6 +262,37 @@ typedef char* caddr_t; #define SCTP_GET_IF_INDEX_FROM_ROUTE(ro) 1 /* compiles... TODO use routing socket to determine */ +#define BIG_ENDIAN 1 +#define LITTLE_ENDIAN 0 +#ifdef WORDS_BIGENDIAN +#define BYTE_ORDER BIG_ENDIAN +#else +#define BYTE_ORDER LITTLE_ENDIAN +#endif + +int Win_getifaddrs(struct ifaddrs**); +#define getifaddrs(interfaces) (int)Win_getifaddrs(interfaces) +int win_if_nametoindex(const char *); +#define if_nametoindex(x) win_if_nametoindex(x) + +#else /* !defined(Userspace_os_Windows) */ +#include <sys/cdefs.h> /* needed? added from old __FreeBSD__ */ +#include <sys/socket.h> +#if defined(__Userspace_os_DragonFly) || defined(__Userspace_os_FreeBSD) || defined(__Userspace_os_Linux) || defined(__Userspace_os_NetBSD) || defined(__Userspace_os_OpenBSD) || defined(__Userspace_os_NaCl) +#include <pthread.h> +#endif +typedef pthread_mutex_t userland_mutex_t; +typedef pthread_cond_t userland_cond_t; +typedef pthread_t userland_thread_t; +#endif + +#if defined(__Userspace_os_Windows) || defined(__Userspace_os_NaCl) + +#define IFNAMSIZ 64 + +#define random() rand() +#define srandom(s) srand(s) + #define timeradd(tvp, uvp, vvp) \ do { \ (vvp)->tv_sec = (tvp)->tv_sec + (uvp)->tv_sec; \ @@ -285,30 +313,57 @@ typedef char* caddr_t; } \ } while (0) -#define BIG_ENDIAN 1 -#define LITTLE_ENDIAN 0 -#ifdef WORDS_BIGENDIAN -#define BYTE_ORDER BIG_ENDIAN -#else -#define BYTE_ORDER LITTLE_ENDIAN -#endif +/*#include <packon.h> +#pragma pack(push, 1)*/ +struct ip { + u_char ip_hl:4, ip_v:4; + u_char ip_tos; + u_short ip_len; + u_short ip_id; + u_short ip_off; +#define IP_RP 0x8000 +#define IP_DF 0x4000 +#define IP_MF 0x2000 +#define IP_OFFMASK 0x1fff + u_char ip_ttl; + u_char ip_p; + u_short ip_sum; + struct in_addr ip_src, ip_dst; +}; + +struct ifaddrs { + struct ifaddrs *ifa_next; + char *ifa_name; + unsigned int ifa_flags; + struct sockaddr *ifa_addr; + struct sockaddr *ifa_netmask; + struct sockaddr *ifa_dstaddr; + void *ifa_data; +}; + +struct udphdr { + uint16_t uh_sport; + uint16_t uh_dport; + uint16_t uh_ulen; + uint16_t uh_sum; +}; struct iovec { - ULONG len; - CHAR FAR *buf; + unsigned long len; + char *buf; }; #define iov_base buf #define iov_len len struct ifa_msghdr { - unsigned __int16 ifam_msglen; + uint16_t ifam_msglen; unsigned char ifam_version; unsigned char ifam_type; - __int32 ifam_addrs; - __int32 ifam_flags; - unsigned __int16 ifam_index; - __int32 ifam_metric; + uint32_t ifam_addrs; + uint32_t ifam_flags; + uint16_t ifam_index; + uint32_t ifam_metric; }; struct ifdevmtu { @@ -341,7 +396,7 @@ struct ifreq { char* ifru_data; struct ifdevmtu ifru_devmtu; struct ifkpi ifru_kpi; - unsigned __int32 ifru_wake_flags; + uint32_t ifru_wake_flags; } ifr_ifru; #define ifr_addr ifr_ifru.ifru_addr #define ifr_dstaddr ifr_ifru.ifru_dstaddr @@ -359,55 +414,6 @@ struct ifreq { #define ifr_wake_flags ifr_ifru.ifru_wake_flags }; -/*#include <packon.h> -#pragma pack(push, 1)*/ -struct ip { - u_char ip_hl:4, ip_v:4; - u_char ip_tos; - u_short ip_len; - u_short ip_id; - u_short ip_off; -#define IP_RP 0x8000 -#define IP_DF 0x4000 -#define IP_MF 0x2000 -#define IP_OFFMASK 0x1fff - u_char ip_ttl; - u_char ip_p; - u_short ip_sum; - struct in_addr ip_src, ip_dst; -}; - -struct ifaddrs { - struct ifaddrs *ifa_next; - char *ifa_name; - unsigned int ifa_flags; - struct sockaddr *ifa_addr; - struct sockaddr *ifa_netmask; - struct sockaddr *ifa_dstaddr; - void *ifa_data; -}; - -struct udphdr { - unsigned __int16 uh_sport; - unsigned __int16 uh_dport; - unsigned __int16 uh_ulen; - unsigned __int16 uh_sum; -}; - -int Win_getifaddrs(struct ifaddrs**); -#define getifaddrs(interfaces) (int)Win_getifaddrs(interfaces) -int win_if_nametoindex(const char *); -#define if_nametoindex(x) win_if_nametoindex(x) - -#else /* !defined(Userspace_os_Windows) */ -#include <sys/cdefs.h> /* needed? added from old __FreeBSD__ */ -#include <sys/socket.h> -#if defined(__Userspace_os_DragonFly) || defined(__Userspace_os_FreeBSD) || defined(__Userspace_os_Linux) || defined(__Userspace_os_NetBSD) || defined(__Userspace_os_OpenBSD) -#include <pthread.h> -#endif -typedef pthread_mutex_t userland_mutex_t; -typedef pthread_cond_t userland_cond_t; -typedef pthread_t userland_thread_t; #endif #define mtx_lock(arg1) @@ -469,7 +475,7 @@ struct sx {int dummy;}; * userspace as well? */ /* on FreeBSD, this results in a redefintion of struct route */ /* #include <net/route.h> */ -#if !defined(__Userspace_os_Windows) +#if !defined(__Userspace_os_Windows) && !defined(__Userspace_os_NaCl) #include <net/if.h> #include <netinet/in.h> #include <netinet/in_systm.h> @@ -1095,7 +1101,7 @@ sctp_get_mbuf_for_msg(unsigned int space_needed, int want_header, int how, int a /* with the current included files, this is defined in Linux but * in FreeBSD, it is behind a _KERNEL in sys/socket.h ... */ -#if defined(__Userspace_os_DragonFly) || defined(__Userspace_os_FreeBSD) || defined(__Userspace_os_OpenBSD) +#if defined(__Userspace_os_DragonFly) || defined(__Userspace_os_FreeBSD) || defined(__Userspace_os_OpenBSD) || defined(__Userspace_os_NaCl) /* stolen from /usr/include/sys/socket.h */ #define CMSG_ALIGN(n) _ALIGN(n) #elif defined(__Userspace_os_NetBSD) @@ -1153,4 +1159,12 @@ sctp_get_mbuf_for_msg(unsigned int space_needed, int want_header, int how, int a #define TAILQ_FOREACH_SAFE TAILQ_FOREACH_MUTABLE #define LIST_FOREACH_SAFE LIST_FOREACH_MUTABLE #endif + +#if defined(__Userspace_os_NaCl) +#define timercmp(tvp, uvp, cmp) \ + (((tvp)->tv_sec == (uvp)->tv_sec) ? \ + ((tvp)->tv_usec cmp (uvp)->tv_usec) : \ + ((tvp)->tv_sec cmp (uvp)->tv_sec)) +#endif + #endif diff --git a/netinet/sctp_output.c b/netinet/sctp_output.c index a305ea5..5ef7879 100755 --- a/netinet/sctp_output.c +++ b/netinet/sctp_output.c @@ -32,7 +32,7 @@ #ifdef __FreeBSD__ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: head/sys/netinet/sctp_output.c 271230 2014-09-07 18:05:37Z tuexen $"); +__FBSDID("$FreeBSD: head/sys/netinet/sctp_output.c 271670 2014-09-16 10:57:55Z tuexen $"); #endif #include <netinet/sctp_os.h> @@ -3477,7 +3477,12 @@ sctp_source_address_selection(struct sctp_inpcb *inp, if (ro->ro_rt == NULL) { return (NULL); } +#if defined(__Userspace_os_Windows) + /* On Windows the sa_family is U_SHORT or ADDRESS_FAMILY */ + fam = (sa_family_t)ro->ro_dst.sa_family; +#else fam = ro->ro_dst.sa_family; +#endif dest_is_priv = dest_is_loop = 0; /* Setup our scopes for the destination */ switch (fam) { @@ -11924,7 +11929,7 @@ sctp_send_hb(struct sctp_tcb *stcb, struct sctp_nets *net,int so_locked hb->heartbeat.hb_info.time_value_1 = now.tv_sec; hb->heartbeat.hb_info.time_value_2 = now.tv_usec; /* Did our user request this one, put it in */ - hb->heartbeat.hb_info.addr_family = net->ro._l_addr.sa.sa_family; + hb->heartbeat.hb_info.addr_family = (uint8_t)net->ro._l_addr.sa.sa_family; #ifdef HAVE_SA_LEN hb->heartbeat.hb_info.addr_len = net->ro._l_addr.sa.sa_len; #else diff --git a/netinet/sctp_pcb.c b/netinet/sctp_pcb.c index ffe8f62..9e0145e 100755 --- a/netinet/sctp_pcb.c +++ b/netinet/sctp_pcb.c @@ -32,7 +32,7 @@ #ifdef __FreeBSD__ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: head/sys/netinet/sctp_pcb.c 271230 2014-09-07 18:05:37Z tuexen $"); +__FBSDID("$FreeBSD: head/sys/netinet/sctp_pcb.c 271673 2014-09-16 14:20:33Z tuexen $"); #endif #include <netinet/sctp_os.h> @@ -7528,8 +7528,8 @@ sctp_load_addresses_from_init(struct sctp_tcb *stcb, struct mbuf *m, } got_random = 1; } else if (ptype == SCTP_HMAC_LIST) { - int num_hmacs; - int i; + uint16_t num_hmacs; + uint16_t i; if (plen > sizeof(hmacs_store)) break; diff --git a/netinet/sctp_structs.h b/netinet/sctp_structs.h index 7214d8d..eadd44e 100755 --- a/netinet/sctp_structs.h +++ b/netinet/sctp_structs.h @@ -32,7 +32,7 @@ #ifdef __FreeBSD__ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: head/sys/netinet/sctp_structs.h 269945 2014-08-13 15:50:16Z tuexen $"); +__FBSDID("$FreeBSD: head/sys/netinet/sctp_structs.h 271643 2014-09-15 19:38:34Z tuexen $"); #endif #ifndef _NETINET_SCTP_STRUCTS_H_ @@ -468,8 +468,8 @@ TAILQ_HEAD(sctpchunk_listhead, sctp_tmit_chunk); #define CHUNK_FLAGS_FRAGMENT_OK 0x0100 struct chk_id { - uint16_t id; - uint16_t can_take_data; + uint8_t id; + uint8_t can_take_data; }; diff --git a/netinet/sctp_userspace.c b/netinet/sctp_userspace.c index 7763f30..7841a89 100755 --- a/netinet/sctp_userspace.c +++ b/netinet/sctp_userspace.c @@ -35,7 +35,7 @@ #endif #include <netinet/sctp_os_userspace.h> -#ifndef _WIN32 +#if !defined(_WIN32) && !defined(__Userspace_os_NaCl) int sctp_userspace_get_mtu_from_ifn(uint32_t if_index, int af) { @@ -55,6 +55,14 @@ sctp_userspace_get_mtu_from_ifn(uint32_t if_index, int af) } #endif +#if defined(__Userspace_os_NaCl) +int +sctp_userspace_get_mtu_from_ifn(uint32_t if_index, int af) +{ + return 1280; +} +#endif + #ifdef _WIN32 int sctp_userspace_get_mtu_from_ifn(uint32_t if_index, int af) @@ -90,8 +98,8 @@ getwintimeofday(struct timeval *tv) struct timeb tb; ftime(&tb); - tv->tv_sec = tb.time; - tv->tv_usec = tb.millitm * 1000; + tv->tv_sec = (long)tb.time; + tv->tv_usec = (long)(tb.millitm) * 1000L; } int @@ -138,7 +146,7 @@ Win_getifaddrs(struct ifaddrs** interfaces) SCTPDBG(SCTP_DEBUG_USR, "Can't allocate memory\n"); return (-1); } - ifa->ifa_name = strdup(pAdapt->AdapterName); + ifa->ifa_name = _strdup(pAdapt->AdapterName); ifa->ifa_flags = pAdapt->Flags; ifa->ifa_addr = (struct sockaddr *)addr; memcpy(addr, &pAdapt->FirstUnicastAddress->Address.lpSockaddr, sizeof(struct sockaddr_in)); @@ -172,7 +180,7 @@ Win_getifaddrs(struct ifaddrs** interfaces) SCTPDBG(SCTP_DEBUG_USR, "Can't allocate memory\n"); return (-1); } - ifa->ifa_name = strdup(pAdapt->AdapterName); + ifa->ifa_name = _strdup(pAdapt->AdapterName); ifa->ifa_flags = pAdapt->Flags; ifa->ifa_addr = (struct sockaddr *)addr6; memcpy(addr6, &pAdapt->FirstUnicastAddress->Address.lpSockaddr, sizeof(struct sockaddr_in6)); @@ -215,11 +223,11 @@ win_if_nametoindex(const char *ifname) } #if WINVER < 0x0600 -/* These functions are written based on the code at +/* 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) * @@ -326,7 +334,7 @@ win_if_nametoindex(const char *ifname) * 22. http://www.dre.vanderbilt.edu/~schmidt/ * 23. http://www.cs.wustl.edu/ACE.html */ - + void InitializeXPConditionVariable(userland_cond_t *cv) { @@ -359,8 +367,7 @@ SleepXPConditionVariable(userland_cond_t *cv, userland_mutex_t *mtx) } EnterCriticalSection(&cv->waiters_count_lock); cv->waiters_count--; - last_waiter = - result == (C_SIGNAL + C_BROADCAST && (cv->waiters_count == 0)); + last_waiter = result == (C_SIGNAL + C_BROADCAST && (cv->waiters_count == 0)); LeaveCriticalSection(&cv->waiters_count_lock); if (last_waiter) ResetEvent(cv->events_[C_BROADCAST]); diff --git a/netinet/sctp_usrreq.c b/netinet/sctp_usrreq.c index 296b9f3..e04e598 100755 --- a/netinet/sctp_usrreq.c +++ b/netinet/sctp_usrreq.c @@ -32,7 +32,7 @@ #ifdef __FreeBSD__ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: head/sys/netinet/sctp_usrreq.c 271221 2014-09-07 09:06:26Z tuexen $"); +__FBSDID("$FreeBSD: head/sys/netinet/sctp_usrreq.c 271673 2014-09-16 14:20:33Z tuexen $"); #endif #include <netinet/sctp_os.h> @@ -106,7 +106,7 @@ sctp_init(void) /* Initialize and modify the sysctled variables */ sctp_init_sysctls(); #if defined(__Userspace__) -#if defined(__Userspace_os_Windows) +#if defined(__Userspace_os_Windows) || defined(__Userspace_os_NaCl) srand((unsigned int)time(NULL)); #else srandom(getpid()); /* so inp->sctp_ep.random_numbers are truly random... */ @@ -5027,13 +5027,14 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize, uint32_t i; SCTP_CHECK_AND_CAST(shmac, optval, struct sctp_hmacalgo, optsize); - if (optsize < sizeof(struct sctp_hmacalgo) + shmac->shmac_number_of_idents * sizeof(uint16_t)) { + if ((optsize < sizeof(struct sctp_hmacalgo) + shmac->shmac_number_of_idents * sizeof(uint16_t)) || + (shmac->shmac_number_of_idents > 0xffff)) { SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EINVAL); error = EINVAL; break; } - hmaclist = sctp_alloc_hmaclist(shmac->shmac_number_of_idents); + hmaclist = sctp_alloc_hmaclist((uint16_t)shmac->shmac_number_of_idents); if (hmaclist == NULL) { SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, ENOMEM); error = ENOMEM; diff --git a/netinet/sctputil.c b/netinet/sctputil.c index 87e770d..bf2d212 100755 --- a/netinet/sctputil.c +++ b/netinet/sctputil.c @@ -32,7 +32,7 @@ #ifdef __FreeBSD__ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: head/sys/netinet/sctputil.c 271221 2014-09-07 09:06:26Z tuexen $"); +__FBSDID("$FreeBSD: head/sys/netinet/sctputil.c 271674 2014-09-16 14:39:24Z tuexen $"); #endif #include <netinet/sctp_os.h> @@ -2524,8 +2524,8 @@ sctp_calculate_rto(struct sctp_tcb *stcb, /* store the current RTT in us */ net->rtt = (uint64_t)1000000 * (uint64_t)now.tv_sec + (uint64_t)now.tv_usec; - /* computer rtt in ms */ - rtt = net->rtt / 1000; + /* compute rtt in ms */ + rtt = (int32_t)(net->rtt / 1000); if ((asoc->cc_functions.sctp_rtt_calculated) && (rtt_from_sack == SCTP_RTT_FROM_DATA)) { /* Tell the CC module that a new update has just occurred from a sack */ (*asoc->cc_functions.sctp_rtt_calculated)(stcb, net, &now); diff --git a/user_route.h b/user_route.h index d0841d7..82b07d7 100755 --- a/user_route.h +++ b/user_route.h @@ -54,7 +54,7 @@ struct sctp_route { * retransmission behavior and are included in the routing structure. */ struct sctp_rt_metrics_lite { - u_long rmx_mtu; /* MTU for this path */ + 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 */ diff --git a/user_sctp_timer_iterate.c b/user_sctp_timer_iterate.c index 0a9dbce..67684fd 100755 --- a/user_sctp_timer_iterate.c +++ b/user_sctp_timer_iterate.c @@ -31,6 +31,9 @@ #include <unistd.h> #include <pthread.h> #endif +#if defined(__Userspace_os_NaCl) +#include <sys/select.h> +#endif #include <stdlib.h> #include <string.h> #include <stdio.h> diff --git a/user_socket.c b/user_socket.c index 9a0e0c7..d92aac6 100755 --- a/user_socket.c +++ b/user_socket.c @@ -1380,7 +1380,7 @@ sbreserve_locked(struct sockbuf *sb, u_long cc, struct socket *so) { SOCKBUF_LOCK_ASSERT(sb); sb->sb_mbmax = (u_int)min(cc * sb_efficiency, sb_max); - sb->sb_hiwat = cc; + sb->sb_hiwat = (u_int)cc; if (sb->sb_lowat > (int)sb->sb_hiwat) sb->sb_lowat = (int)sb->sb_hiwat; return (1); @@ -2449,7 +2449,7 @@ usrsctp_bindx(struct socket *so, struct sockaddr *addrs, int addrcnt, int flags) for (i = 0; i < addrcnt; i++) { #ifndef HAVE_SA_LEN size_t sa_len; -#endif +#endif memset(gaddrs, 0, argsz); gaddrs->sget_assoc_id = 0; #ifdef HAVE_SA_LEN @@ -2987,7 +2987,7 @@ void sctp_userspace_ip6_output(int *result, struct mbuf *o_pak, memset((void *)&dst, 0, sizeof(struct sockaddr_in6)); dst.sin6_family = AF_INET6; dst.sin6_addr = ip6->ip6_dst; -#ifdef HAVE_SIN6_LEN +#ifdef HAVE_SIN6_LEN dst.sin6_len = sizeof(struct sockaddr_in6); #endif @@ -3157,7 +3157,7 @@ usrsctp_dumppacket(void *buf, size_t len, int outbound) strncpy_s(dump_buf + pos, strlen(HEADER) + 1, HEADER, strlen(HEADER)); #else strcpy(dump_buf + pos, HEADER); -#endif +#endif pos += strlen(HEADER); packet = (char *)buf; for (i = 0; i < len; i++) { diff --git a/user_socketvar.h b/user_socketvar.h index dd4ff10..5c3d9ee 100755 --- a/user_socketvar.h +++ b/user_socketvar.h @@ -42,7 +42,7 @@ /* #include <sys/_lock.h> was 0 byte file */ /* #include <sys/_mutex.h> was 0 byte file */ /* #include <sys/_sx.h> */ /*__Userspace__ alternative?*/ -#if !defined(__Userspace_os_DragonFly) && !defined(__Userspace_os_FreeBSD) && !defined(__Userspace_os_NetBSD) && !defined(__Userspace_os_Windows) +#if !defined(__Userspace_os_DragonFly) && !defined(__Userspace_os_FreeBSD) && !defined(__Userspace_os_NetBSD) && !defined(__Userspace_os_Windows) && !defined(__Userspace_os_NaCl) #include <sys/uio.h> #endif #define SOCK_MAXADDRLEN 255 @@ -54,7 +54,7 @@ #define SS_CANTRCVMORE 0x020 #define SS_CANTSENDMORE 0x010 -#if defined(__Userspace_os_Darwin) || defined(__Userspace_os_DragonFly) || defined(__Userspace_os_FreeBSD) || defined(__Userspace_os_OpenBSD) || defined (__Userspace_os_Windows) +#if defined(__Userspace_os_Darwin) || defined(__Userspace_os_DragonFly) || defined(__Userspace_os_FreeBSD) || defined(__Userspace_os_OpenBSD) || defined (__Userspace_os_Windows) || defined(__Userspace_os_NaCl) #define UIO_MAXIOV 1024 #define ERESTART (-1) #endif |