From 99cbabe66ba1ea5b03b350d4ad902fd2ed6421ff Mon Sep 17 00:00:00 2001 From: t00fcxen Date: Mon, 15 Sep 2014 16:04:36 +0000 Subject: Whitespace change. git-svn-id: http://sctp-refimpl.googlecode.com/svn/trunk/KERN/usrsctp/usrsctplib@9006 9df1edf5-d72c-5b5f-11c0-5f5209eb73f7 --- user_socket.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/user_socket.c b/user_socket.c index 9a0e0c7..99e148e 100755 --- a/user_socket.c +++ b/user_socket.c @@ -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++) { -- cgit v1.2.3 From 620b2cf00fb70ba85099ff8ad9da9b93db73958a Mon Sep 17 00:00:00 2001 From: t00fcxen Date: Mon, 15 Sep 2014 16:15:38 +0000 Subject: Address a warning reported by Peter Kasting from Google. While there, remove trailing whitespaces. git-svn-id: http://sctp-refimpl.googlecode.com/svn/trunk/KERN/usrsctp/usrsctplib@9007 9df1edf5-d72c-5b5f-11c0-5f5209eb73f7 --- netinet/sctp_userspace.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/netinet/sctp_userspace.c b/netinet/sctp_userspace.c index 7763f30..5d315b0 100755 --- a/netinet/sctp_userspace.c +++ b/netinet/sctp_userspace.c @@ -90,8 +90,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 @@ -215,11 +215,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 +326,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 +359,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]); -- cgit v1.2.3 From 58a1039166dfad5165ca37edfc339c280e92c60b Mon Sep 17 00:00:00 2001 From: t00fcxen Date: Mon, 15 Sep 2014 16:20:17 +0000 Subject: Use _strdup() instead of strdup(). git-svn-id: http://sctp-refimpl.googlecode.com/svn/trunk/KERN/usrsctp/usrsctplib@9008 9df1edf5-d72c-5b5f-11c0-5f5209eb73f7 --- netinet/sctp_userspace.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/netinet/sctp_userspace.c b/netinet/sctp_userspace.c index 5d315b0..e6d01a9 100755 --- a/netinet/sctp_userspace.c +++ b/netinet/sctp_userspace.c @@ -91,7 +91,7 @@ getwintimeofday(struct timeval *tv) ftime(&tb); tv->tv_sec = (long)tb.time; - tv->tv_usec = (long)(tb.millitm) * 1000L; + tv->tv_usec = (long)(tb.millitm) * 1000L; } int @@ -138,7 +138,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 +172,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)); -- cgit v1.2.3 From c4b680b9c86f7b3eab9ade3e2aea2efd25f2993b Mon Sep 17 00:00:00 2001 From: t00fcxen Date: Mon, 15 Sep 2014 17:41:11 +0000 Subject: Use _strdup() instead of strdup() on Windows. git-svn-id: http://sctp-refimpl.googlecode.com/svn/trunk/KERN/usrsctp/usrsctplib@9009 9df1edf5-d72c-5b5f-11c0-5f5209eb73f7 --- netinet/sctp_bsd_addr.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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. */ -- cgit v1.2.3 From 72763447253b6717a74000292fe80a0718b26961 Mon Sep 17 00:00:00 2001 From: t00fcxen Date: Mon, 15 Sep 2014 21:42:05 +0000 Subject: Sync with Mavericks. git-svn-id: http://sctp-refimpl.googlecode.com/svn/trunk/KERN/usrsctp/usrsctplib@9012 9df1edf5-d72c-5b5f-11c0-5f5209eb73f7 --- netinet/sctp_structs.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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 -__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; }; -- cgit v1.2.3 From 2b35fa3b07cbbf058a0790e5b1fa446f4b4e2a42 Mon Sep 17 00:00:00 2001 From: t00fcxen Date: Tue, 16 Sep 2014 08:53:24 +0000 Subject: The MTU is a 32-bit entity within the SCTP stack. This issue was reported by Peter Kasting from Google. git-svn-id: http://sctp-refimpl.googlecode.com/svn/trunk/KERN/usrsctp/usrsctplib@9013 9df1edf5-d72c-5b5f-11c0-5f5209eb73f7 --- user_route.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 */ -- cgit v1.2.3 From 699b67ddda6fc054cce33ea39182313e01667c4b Mon Sep 17 00:00:00 2001 From: t00fcxen Date: Tue, 16 Sep 2014 11:01:08 +0000 Subject: Sync with Mavericks sources. git-svn-id: http://sctp-refimpl.googlecode.com/svn/trunk/KERN/usrsctp/usrsctplib@9017 9df1edf5-d72c-5b5f-11c0-5f5209eb73f7 --- netinet/sctp_output.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) 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 -__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 @@ -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 -- cgit v1.2.3 From 970c7e801c8a672b25793da4c3b06c47b21a2099 Mon Sep 17 00:00:00 2001 From: t00fcxen Date: Tue, 16 Sep 2014 13:52:52 +0000 Subject: Sync with Mavericks sources. git-svn-id: http://sctp-refimpl.googlecode.com/svn/trunk/KERN/usrsctp/usrsctplib@9020 9df1edf5-d72c-5b5f-11c0-5f5209eb73f7 --- netinet/sctp_cc_functions.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) 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 -__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 @@ -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) { -- cgit v1.2.3 From c5fe9aa6ae8b12577aa961421b64104d82964e6a Mon Sep 17 00:00:00 2001 From: t00fcxen Date: Tue, 16 Sep 2014 14:25:27 +0000 Subject: Sync with Mavericks sources. git-svn-id: http://sctp-refimpl.googlecode.com/svn/trunk/KERN/usrsctp/usrsctplib@9023 9df1edf5-d72c-5b5f-11c0-5f5209eb73f7 --- netinet/sctp_auth.c | 8 ++++---- netinet/sctp_auth.h | 4 ++-- netinet/sctp_pcb.c | 6 +++--- netinet/sctp_usrreq.c | 7 ++++--- 4 files changed, 13 insertions(+), 12 deletions(-) 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 -__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 @@ -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 -__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_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 -__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 @@ -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_usrreq.c b/netinet/sctp_usrreq.c index 296b9f3..3c134f8 100755 --- a/netinet/sctp_usrreq.c +++ b/netinet/sctp_usrreq.c @@ -32,7 +32,7 @@ #ifdef __FreeBSD__ #include -__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 @@ -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; -- cgit v1.2.3 From 734dec3f6718d39b6c05ceb258906afdadf474cb Mon Sep 17 00:00:00 2001 From: t00fcxen Date: Tue, 16 Sep 2014 14:41:52 +0000 Subject: SYnc with Mavericks sources. git-svn-id: http://sctp-refimpl.googlecode.com/svn/trunk/KERN/usrsctp/usrsctplib@9026 9df1edf5-d72c-5b5f-11c0-5f5209eb73f7 --- netinet/sctputil.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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 -__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 @@ -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); -- cgit v1.2.3 From 765c98d9d6d70fc648514745b832a311f9b8454c Mon Sep 17 00:00:00 2001 From: t00fcxen Date: Tue, 16 Sep 2014 14:56:37 +0000 Subject: Silence a warning reported by Peter Kasting from Google. While there, remove some trailing white spaces. git-svn-id: http://sctp-refimpl.googlecode.com/svn/trunk/KERN/usrsctp/usrsctplib@9027 9df1edf5-d72c-5b5f-11c0-5f5209eb73f7 --- user_socket.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/user_socket.c b/user_socket.c index 99e148e..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 -- cgit v1.2.3 From 00e26b77903bfb859552f0924b2ba07e02215d8e Mon Sep 17 00:00:00 2001 From: t00fcxen Date: Tue, 16 Sep 2014 14:59:24 +0000 Subject: Report warnings as errors. git-svn-id: http://sctp-refimpl.googlecode.com/svn/trunk/KERN/usrsctp/usrsctplib@9028 9df1edf5-d72c-5b5f-11c0-5f5209eb73f7 --- Makefile.nmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 -- cgit v1.2.3 From d5685d4cc67d1fba57b7cb0024fc9065971e5ac1 Mon Sep 17 00:00:00 2001 From: t00fcxen Date: Wed, 1 Oct 2014 19:54:29 +0000 Subject: Add support for Native Client used for Chrome Remote Desktop. The patch is provided by Sergey Ulanov from Google. git-svn-id: http://sctp-refimpl.googlecode.com/svn/trunk/KERN/usrsctp/usrsctplib@9029 9df1edf5-d72c-5b5f-11c0-5f5209eb73f7 --- netinet/sctp_os_userspace.h | 152 ++++++++++++++++++++++++-------------------- netinet/sctp_userspace.c | 10 ++- netinet/sctp_usrreq.c | 2 +- user_sctp_timer_iterate.c | 3 + user_socketvar.h | 4 +- 5 files changed, 98 insertions(+), 73 deletions(-) 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 /* needed? added from old __FreeBSD__ */ +#include +#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 +#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 +#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 -#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 /* needed? added from old __FreeBSD__ */ -#include -#if defined(__Userspace_os_DragonFly) || defined(__Userspace_os_FreeBSD) || defined(__Userspace_os_Linux) || defined(__Userspace_os_NetBSD) || defined(__Userspace_os_OpenBSD) -#include -#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 */ -#if !defined(__Userspace_os_Windows) +#if !defined(__Userspace_os_Windows) && !defined(__Userspace_os_NaCl) #include #include #include @@ -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_userspace.c b/netinet/sctp_userspace.c index e6d01a9..7841a89 100755 --- a/netinet/sctp_userspace.c +++ b/netinet/sctp_userspace.c @@ -35,7 +35,7 @@ #endif #include -#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) diff --git a/netinet/sctp_usrreq.c b/netinet/sctp_usrreq.c index 3c134f8..e04e598 100755 --- a/netinet/sctp_usrreq.c +++ b/netinet/sctp_usrreq.c @@ -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... */ 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 #include #endif +#if defined(__Userspace_os_NaCl) +#include +#endif #include #include #include 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 was 0 byte file */ /* #include was 0 byte file */ /* #include */ /*__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 #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 -- cgit v1.2.3 From 90de5e54132eaa4a447964f8466208a401022dfa Mon Sep 17 00:00:00 2001 From: t00fcxen Date: Sun, 5 Oct 2014 20:36:33 +0000 Subject: Sync with Mavericks sources. git-svn-id: http://sctp-refimpl.googlecode.com/svn/trunk/KERN/usrsctp/usrsctplib@9032 9df1edf5-d72c-5b5f-11c0-5f5209eb73f7 --- netinet/sctp_output.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/netinet/sctp_output.c b/netinet/sctp_output.c index 5ef7879..9502cc6 100755 --- a/netinet/sctp_output.c +++ b/netinet/sctp_output.c @@ -32,7 +32,7 @@ #ifdef __FreeBSD__ #include -__FBSDID("$FreeBSD: head/sys/netinet/sctp_output.c 271670 2014-09-16 10:57:55Z tuexen $"); +__FBSDID("$FreeBSD: head/sys/netinet/sctp_output.c 272571 2014-10-05 20:30:49Z tuexen $"); #endif #include @@ -7200,13 +7200,6 @@ sctp_sendall_completes(void *ptr, uint32_t val SCTP_UNUSED) SCTP_FREE(ca, SCTP_M_COPYAL); } - -#define MC_ALIGN(m, len) do { \ - SCTP_BUF_RESV_UF(m, ((MCLBYTES - (len)) & ~(sizeof(long) - 1)); \ -} while (0) - - - static struct mbuf * sctp_copy_out_all(struct uio *uio, int len) { -- cgit v1.2.3 From dfd687bb8ef6224a1e3c38a7de9e79e854b142ad Mon Sep 17 00:00:00 2001 From: t00fcxen Date: Mon, 6 Oct 2014 21:00:47 +0000 Subject: Fix a warning showing up on Windows. Thanks to Segery Ulanov from Google for providing the fix. git-svn-id: http://sctp-refimpl.googlecode.com/svn/trunk/KERN/usrsctp/usrsctplib@9033 9df1edf5-d72c-5b5f-11c0-5f5209eb73f7 --- netinet/sctp_os_userspace.h | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/netinet/sctp_os_userspace.h b/netinet/sctp_os_userspace.h index e8de92f..a8d1f08 100755 --- a/netinet/sctp_os_userspace.h +++ b/netinet/sctp_os_userspace.h @@ -270,11 +270,6 @@ typedef char* caddr_t; #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 /* needed? added from old __FreeBSD__ */ #include @@ -416,6 +411,13 @@ struct ifreq { #endif +#if defined(__Userspace_os_Windows) +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) +#endif + #define mtx_lock(arg1) #define mtx_unlock(arg1) #define mtx_assert(arg1,arg2) -- cgit v1.2.3 From 957547f99b6422e0ca40b8595e5cddef2e34b9d5 Mon Sep 17 00:00:00 2001 From: t00fcxen Date: Wed, 8 Oct 2014 15:35:22 +0000 Subject: Sync with Mavericks sources. git-svn-id: http://sctp-refimpl.googlecode.com/svn/trunk/KERN/usrsctp/usrsctplib@9037 9df1edf5-d72c-5b5f-11c0-5f5209eb73f7 --- netinet/sctp_output.c | 12 ++++++++++-- netinet/sctp_output.h | 6 +++--- netinet/sctp_usrreq.c | 8 +++++++- 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/netinet/sctp_output.c b/netinet/sctp_output.c index 9502cc6..ecbceed 100755 --- a/netinet/sctp_output.c +++ b/netinet/sctp_output.c @@ -32,7 +32,7 @@ #ifdef __FreeBSD__ #include -__FBSDID("$FreeBSD: head/sys/netinet/sctp_output.c 272571 2014-10-05 20:30:49Z tuexen $"); +__FBSDID("$FreeBSD: head/sys/netinet/sctp_output.c 272751 2014-10-08 15:30:59Z tuexen $"); #endif #include @@ -12498,7 +12498,7 @@ sctp_add_an_in_stream(struct sctp_tmit_chunk *chk, int sctp_send_str_reset_req(struct sctp_tcb *stcb, - int number_entries, uint16_t *list, + uint16_t number_entries, uint16_t *list, uint8_t send_out_req, uint8_t send_in_req, uint8_t send_tsn_req, @@ -12531,6 +12531,14 @@ sctp_send_str_reset_req(struct sctp_tcb *stcb, SCTP_LTRACE_ERR_RET(NULL, stcb, NULL, SCTP_FROM_SCTP_OUTPUT, EINVAL); return (EINVAL); } + if (number_entries > (MCLBYTES - + SCTP_MIN_OVERHEAD - + sizeof(struct sctp_chunkhdr) - + sizeof(struct sctp_stream_reset_out_request)) / + sizeof(uint16_t)) { + SCTP_LTRACE_ERR_RET(NULL, stcb, NULL, SCTP_FROM_SCTP_OUTPUT, ENOMEM); + return (ENOMEM); + } sctp_alloc_a_chunk(stcb, chk); if (chk == NULL) { SCTP_LTRACE_ERR_RET(NULL, stcb, NULL, SCTP_FROM_SCTP_OUTPUT, ENOMEM); diff --git a/netinet/sctp_output.h b/netinet/sctp_output.h index 808af1b..d03bead 100755 --- a/netinet/sctp_output.h +++ b/netinet/sctp_output.h @@ -32,7 +32,7 @@ #ifdef __FreeBSD__ #include -__FBSDID("$FreeBSD: head/sys/netinet/sctp_output.h 246595 2013-02-09 17:26:14Z tuexen $"); +__FBSDID("$FreeBSD: head/sys/netinet/sctp_output.h 272751 2014-10-08 15:30:59Z tuexen $"); #endif #ifndef _NETINET_SCTP_OUTPUT_H_ @@ -208,8 +208,8 @@ sctp_add_stream_reset_result_tsn(struct sctp_tmit_chunk *, uint32_t, uint32_t, uint32_t, uint32_t); int -sctp_send_str_reset_req(struct sctp_tcb *, int , uint16_t *, uint8_t, uint8_t, - uint8_t, uint8_t, uint16_t, uint16_t, uint8_t); +sctp_send_str_reset_req(struct sctp_tcb *, uint16_t , uint16_t *, uint8_t, + uint8_t, uint8_t, uint8_t, uint16_t, uint16_t, uint8_t); void sctp_send_abort(struct mbuf *, int, struct sockaddr *, struct sockaddr *, diff --git a/netinet/sctp_usrreq.c b/netinet/sctp_usrreq.c index e04e598..1eee82f 100755 --- a/netinet/sctp_usrreq.c +++ b/netinet/sctp_usrreq.c @@ -32,7 +32,7 @@ #ifdef __FreeBSD__ #include -__FBSDID("$FreeBSD: head/sys/netinet/sctp_usrreq.c 271673 2014-09-16 14:20:33Z tuexen $"); +__FBSDID("$FreeBSD: head/sys/netinet/sctp_usrreq.c 272750 2014-10-08 15:29:49Z tuexen $"); #endif #include @@ -5252,6 +5252,12 @@ sctp_setopt(struct socket *so, int optname, void *optval, size_t optsize, SCTP_TCB_UNLOCK(stcb); break; } + if (sizeof(struct sctp_reset_streams) + + strrst->srs_number_streams * sizeof(uint16_t) > optsize) { + error = EINVAL; + SCTP_TCB_UNLOCK(stcb); + break; + } if (stcb->asoc.stream_reset_outstanding) { SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EALREADY); error = EALREADY; -- cgit v1.2.3 From eea8542346d09e6dcefdaddeaa2757570ae24222 Mon Sep 17 00:00:00 2001 From: t00fcxen Date: Thu, 9 Oct 2014 18:30:53 +0000 Subject: Retire user_sctp_timer_iterate.c from the build. git-svn-id: http://sctp-refimpl.googlecode.com/svn/trunk/KERN/usrsctp/usrsctplib@9039 9df1edf5-d72c-5b5f-11c0-5f5209eb73f7 --- Makefile.am | 1 - Makefile.nmake | 4 ---- 2 files changed, 5 deletions(-) diff --git a/Makefile.am b/Makefile.am index d7f4f4a..85240b7 100644 --- a/Makefile.am +++ b/Makefile.am @@ -42,7 +42,6 @@ libusrsctp_la_SOURCES = user_atomic.h \ user_queue.h \ user_recv_thread.c user_recv_thread.h \ user_route.h \ - user_sctp_timer_iterate.c \ user_socket.c \ user_socketvar.h \ user_uma.h \ diff --git a/Makefile.nmake b/Makefile.nmake index 9be1077..48d2bd1 100644 --- a/Makefile.nmake +++ b/Makefile.nmake @@ -41,7 +41,6 @@ usrsctp_OBJECTS = \ user_environment.obj \ user_mbuf.obj \ user_recv_thread.obj \ - user_sctp_timer_iterate.obj \ user_socket.obj \ sctp_asconf.obj \ sctp_auth.obj \ @@ -115,9 +114,6 @@ user_mbuf.obj : user_mbuf.c $(usrsctp_HEADERS) user_recv_thread.obj: user_recv_thread.c $(usrsctp_HEADERS) cl $(CVARSDLL) $(CFLAGS) -c user_recv_thread.c -user_sctp_timer_iterate.obj : user_sctp_timer_iterate.c $(usrsctp_HEADERS) - cl $(CVARSDLL) $(CFLAGS) -c user_sctp_timer_iterate.c - user_socket.obj : user_socket.c $(usrsctp_HEADERS) cl $(CVARSDLL) $(CFLAGS) -c user_socket.c -- cgit v1.2.3 From ba7640eaabc07546e82d493c0bc8ca5cd0fc8b19 Mon Sep 17 00:00:00 2001 From: t00fcxen Date: Thu, 9 Oct 2014 18:34:54 +0000 Subject: This file is not needed anymore. git-svn-id: http://sctp-refimpl.googlecode.com/svn/trunk/KERN/usrsctp/usrsctplib@9040 9df1edf5-d72c-5b5f-11c0-5f5209eb73f7 --- user_sctp_timer_iterate.c | 122 ---------------------------------------------- 1 file changed, 122 deletions(-) delete mode 100755 user_sctp_timer_iterate.c diff --git a/user_sctp_timer_iterate.c b/user_sctp_timer_iterate.c deleted file mode 100755 index 67684fd..0000000 --- a/user_sctp_timer_iterate.c +++ /dev/null @@ -1,122 +0,0 @@ -/*- - * Copyright (c) 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. - * - */ - -#include -#if !defined (__Userspace_os_Windows) -#include -#include -#include -#endif -#if defined(__Userspace_os_NaCl) -#include -#endif -#include -#include -#include -#include -#include -#include -#include "netinet/sctp_callout.h" - -/* This is the polling time of callqueue in milliseconds - * 10ms seems to work well. 1ms was giving erratic behavior - */ -#define TIMEOUT_INTERVAL 10 - -extern int ticks; - -void * -user_sctp_timer_iterate(void *arg) -{ - sctp_os_timer_t *c; - void (*c_func)(void *); - void *c_arg; - sctp_os_timer_t *sctp_os_timer_next; - /* - * The MSEC_TO_TICKS conversion depends on hz. The to_ticks in - * sctp_os_timer_start also depends on hz. E.g. if hz=1000 then - * for multiple INIT the to_ticks is 2000, 4000, 8000, 16000, 32000, 60000 - * and further to_ticks level off at 60000 i.e. 60 seconds. - * If hz=100 then for multiple INIT the to_ticks are 200, 400, 800 and so-on. - */ - for (;;) { -#if defined (__Userspace_os_Windows) - Sleep(TIMEOUT_INTERVAL); -#else - struct timeval timeout; - - timeout.tv_sec = 0; - timeout.tv_usec = 1000 * TIMEOUT_INTERVAL; - select(0, NULL, NULL, NULL, &timeout); -#endif - if (SCTP_BASE_VAR(timer_thread_should_exit)) { - break; - } - SCTP_TIMERQ_LOCK(); - /* update our tick count */ - ticks += MSEC_TO_TICKS(TIMEOUT_INTERVAL); - c = TAILQ_FIRST(&SCTP_BASE_INFO(callqueue)); - while (c) { - if (c->c_time <= ticks) { - 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_TIMERQ_UNLOCK(); - } - return (NULL); -} - -void -sctp_start_timer(void) -{ - /* - * No need to do SCTP_TIMERQ_LOCK_INIT(); - * here, it is being done in sctp_pcb_init() - */ -#if defined (__Userspace_os_Windows) - if ((SCTP_BASE_VAR(timer_thread) = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)user_sctp_timer_iterate, NULL, 0, NULL)) == NULL) { - SCTP_PRINTF("ERROR; Creating ithread failed\n"); - } -#else - int rc; - - rc = pthread_create(&SCTP_BASE_VAR(timer_thread), NULL, user_sctp_timer_iterate, NULL); - if (rc) { - SCTP_PRINTF("ERROR; return code from pthread_create() is %d\n", rc); - } -#endif -} -- cgit v1.2.3 From 95cbc98a53e7001dcc7f3bfba072b367ec060ee5 Mon Sep 17 00:00:00 2001 From: t00fcxen Date: Thu, 9 Oct 2014 18:45:38 +0000 Subject: Sync with Mavericks sources. git-svn-id: http://sctp-refimpl.googlecode.com/svn/trunk/KERN/usrsctp/usrsctplib@9042 9df1edf5-d72c-5b5f-11c0-5f5209eb73f7 --- netinet/sctp_callout.c | 89 +++++++++++++++++++++++++++++++++++++++++--------- netinet/sctp_callout.h | 6 +++- netinet/sctp_usrreq.c | 4 ++- 3 files changed, 81 insertions(+), 18 deletions(-) diff --git a/netinet/sctp_callout.c b/netinet/sctp_callout.c index 67b7566..3174e3f 100755 --- a/netinet/sctp_callout.c +++ b/netinet/sctp_callout.c @@ -30,9 +30,27 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ +#if defined(__Userspace__) +#include +#if !defined (__Userspace_os_Windows) +#include +#include +#include +#endif +#if defined(__Userspace_os_NaCl) +#include +#endif +#include +#include +#include +#include +#include +#include +#else #include #include #include +#endif /* * Callout/Timer routines for OS that doesn't have them @@ -46,10 +64,8 @@ extern int ticks; /* * SCTP_TIMERQ_LOCK protects: * - SCTP_BASE_INFO(callqueue) - * - sctp_os_timer_current: current timer in process * - sctp_os_timer_next: next timer to check */ -static sctp_os_timer_t *sctp_os_timer_current = NULL; static sctp_os_timer_t *sctp_os_timer_next = NULL; void @@ -117,24 +133,16 @@ sctp_os_timer_stop(sctp_os_timer_t *c) return (1); } -#if defined(__APPLE__) -/* - * For __APPLE__, use a single main timer at a faster resolution than - * fastim. The timer just calls this existing callout infrastructure. - */ -#endif -void -sctp_timeout(void *arg SCTP_UNUSED) +static void +sctp_handle_tick(int delta) { sctp_os_timer_t *c; void (*c_func)(void *); void *c_arg; SCTP_TIMERQ_LOCK(); -#if defined(__APPLE__) /* update our tick count */ - ticks += SCTP_BASE_VAR(sctp_main_timer_ticks); -#endif + ticks += delta; c = TAILQ_FIRST(&SCTP_BASE_INFO(callqueue)); while (c) { if (c->c_time <= ticks) { @@ -143,11 +151,9 @@ sctp_timeout(void *arg SCTP_UNUSED) c_func = c->c_func; c_arg = c->c_arg; c->c_flags &= ~SCTP_CALLOUT_PENDING; - sctp_os_timer_current = c; SCTP_TIMERQ_UNLOCK(); c_func(c_arg); SCTP_TIMERQ_LOCK(); - sctp_os_timer_current = NULL; c = sctp_os_timer_next; } else { c = TAILQ_NEXT(c, tqe); @@ -155,9 +161,60 @@ sctp_timeout(void *arg SCTP_UNUSED) } sctp_os_timer_next = NULL; SCTP_TIMERQ_UNLOCK(); +} #if defined(__APPLE__) - /* restart the main timer */ +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) +{ + for (;;) { +#if defined (__Userspace_os_Windows) + Sleep(TIMEOUT_INTERVAL); +#else + struct timeval timeout; + + timeout.tv_sec = 0; + timeout.tv_usec = 1000 * TIMEOUT_INTERVAL; + select(0, NULL, NULL, NULL, &timeout); +#endif + if (SCTP_BASE_VAR(timer_thread_should_exit)) { + break; + } + sctp_handle_tick(MSEC_TO_TICKS(TIMEOUT_INTERVAL)); + } + return (NULL); } + +void +sctp_start_timer(void) +{ + /* + * No need to do SCTP_TIMERQ_LOCK_INIT(); + * here, it is being done in sctp_pcb_init() + */ +#if defined (__Userspace_os_Windows) + if ((SCTP_BASE_VAR(timer_thread) = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)user_sctp_timer_iterate, NULL, 0, NULL)) == NULL) { + SCTP_PRINTF("ERROR; Creating ithread failed\n"); + } +#else + int rc; + + rc = pthread_create(&SCTP_BASE_VAR(timer_thread), NULL, user_sctp_timer_iterate, NULL); + if (rc) { + SCTP_PRINTF("ERROR; return code from pthread_create() is %d\n", rc); + } +#endif +} + +#endif diff --git a/netinet/sctp_callout.h b/netinet/sctp_callout.h index 2782945..c53c5a4 100755 --- a/netinet/sctp_callout.h +++ b/netinet/sctp_callout.h @@ -64,7 +64,6 @@ __FBSDID("$FreeBSD$"); #endif extern int ticks; -extern void sctp_start_timer(); #endif TAILQ_HEAD(calloutlist, sctp_callout); @@ -94,6 +93,11 @@ int sctp_os_timer_stop(sctp_os_timer_t *); #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(void); +#endif +#if defined(__APPLE__) void sctp_timeout(void *); +#endif #endif diff --git a/netinet/sctp_usrreq.c b/netinet/sctp_usrreq.c index 1eee82f..362d353 100755 --- a/netinet/sctp_usrreq.c +++ b/netinet/sctp_usrreq.c @@ -56,7 +56,9 @@ __FBSDID("$FreeBSD: head/sys/netinet/sctp_usrreq.c 272750 2014-10-08 15:29:49Z t #include #include #include -#if !defined(__Userspace__) +#if defined(__Userspace__) +#include +#else #include #endif -- cgit v1.2.3 From a11b3c55b730332ac33e9a81d053aca3bf813b93 Mon Sep 17 00:00:00 2001 From: t00fcxen Date: Thu, 9 Oct 2014 20:15:05 +0000 Subject: Sync with Mavericks sources. git-svn-id: http://sctp-refimpl.googlecode.com/svn/trunk/KERN/usrsctp/usrsctplib@9045 9df1edf5-d72c-5b5f-11c0-5f5209eb73f7 --- netinet/sctp_input.c | 4 +++- netinet/sctp_output.c | 53 +++++++++++++++++++++++++++------------------------ 2 files changed, 31 insertions(+), 26 deletions(-) diff --git a/netinet/sctp_input.c b/netinet/sctp_input.c index cb7968f..5302582 100755 --- a/netinet/sctp_input.c +++ b/netinet/sctp_input.c @@ -32,7 +32,7 @@ #ifdef __FreeBSD__ #include -__FBSDID("$FreeBSD: head/sys/netinet/sctp_input.c 271230 2014-09-07 18:05:37Z tuexen $"); +__FBSDID("$FreeBSD: head/sys/netinet/sctp_input.c 272841 2014-10-09 20:08:12Z tuexen $"); #endif #include @@ -4202,8 +4202,10 @@ sctp_handle_stream_reset(struct sctp_tcb *stcb, struct mbuf *m, int offset, if (chk == NULL) { return (ret_code); } + chk->copy_by_ref = 0; chk->rec.chunk_id.id = SCTP_STREAM_RESET; chk->rec.chunk_id.can_take_data = 0; + chk->flags = 0; chk->asoc = &stcb->asoc; chk->no_fr_allowed = 0; chk->book_size = chk->send_size = sizeof(struct sctp_chunkhdr); diff --git a/netinet/sctp_output.c b/netinet/sctp_output.c index ecbceed..07ae932 100755 --- a/netinet/sctp_output.c +++ b/netinet/sctp_output.c @@ -32,7 +32,7 @@ #ifdef __FreeBSD__ #include -__FBSDID("$FreeBSD: head/sys/netinet/sctp_output.c 272751 2014-10-08 15:30:59Z tuexen $"); +__FBSDID("$FreeBSD: head/sys/netinet/sctp_output.c 272841 2014-10-09 20:08:12Z tuexen $"); #endif #include @@ -9370,16 +9370,11 @@ sctp_queue_op_err(struct sctp_tcb *stcb, struct mbuf *op_err) return; } chk->send_size = 0; - mat = op_err; - while (mat != NULL) { + for (mat = op_err; mat != NULL; mat = SCTP_BUF_NEXT(mat)) { chk->send_size += SCTP_BUF_LEN(mat); - mat = SCTP_BUF_NEXT(mat); } - chk->rec.chunk_id.id = SCTP_OPERATION_ERROR; - chk->rec.chunk_id.can_take_data = 1; chk->sent = SCTP_DATAGRAM_UNSENT; chk->snd_count = 0; - chk->flags = 0; chk->asoc = &stcb->asoc; chk->data = op_err; chk->whoTo = NULL; @@ -9467,12 +9462,12 @@ sctp_send_cookie_echo(struct mbuf *m, return (-5); } chk->copy_by_ref = 0; - chk->send_size = plen; chk->rec.chunk_id.id = SCTP_COOKIE_ECHO; chk->rec.chunk_id.can_take_data = 0; + chk->flags = CHUNK_FLAGS_FRAGMENT_OK; + chk->send_size = plen; chk->sent = SCTP_DATAGRAM_UNSENT; chk->snd_count = 0; - chk->flags = CHUNK_FLAGS_FRAGMENT_OK; chk->asoc = &stcb->asoc; chk->data = cookie; chk->whoTo = net; @@ -9535,12 +9530,12 @@ sctp_send_heartbeat_ack(struct sctp_tcb *stcb, return; } chk->copy_by_ref = 0; - chk->send_size = chk_length; chk->rec.chunk_id.id = SCTP_HEARTBEAT_ACK; chk->rec.chunk_id.can_take_data = 1; + chk->flags = 0; + chk->send_size = chk_length; chk->sent = SCTP_DATAGRAM_UNSENT; chk->snd_count = 0; - chk->flags = 0; chk->asoc = &stcb->asoc; chk->data = outchain; chk->whoTo = net; @@ -9572,12 +9567,12 @@ sctp_send_cookie_ack(struct sctp_tcb *stcb) return; } chk->copy_by_ref = 0; - chk->send_size = sizeof(struct sctp_chunkhdr); chk->rec.chunk_id.id = SCTP_COOKIE_ACK; chk->rec.chunk_id.can_take_data = 1; + chk->flags = 0; + chk->send_size = sizeof(struct sctp_chunkhdr); chk->sent = SCTP_DATAGRAM_UNSENT; chk->snd_count = 0; - chk->flags = 0; chk->asoc = &stcb->asoc; chk->data = cookie_ack; if (chk->asoc->last_control_chunk_from != NULL) { @@ -9618,9 +9613,10 @@ sctp_send_shutdown_ack(struct sctp_tcb *stcb, struct sctp_nets *net) return; } chk->copy_by_ref = 0; - chk->send_size = sizeof(struct sctp_chunkhdr); chk->rec.chunk_id.id = SCTP_SHUTDOWN_ACK; chk->rec.chunk_id.can_take_data = 1; + chk->flags = 0; + chk->send_size = sizeof(struct sctp_chunkhdr); chk->sent = SCTP_DATAGRAM_UNSENT; chk->snd_count = 0; chk->flags = 0; @@ -9661,9 +9657,10 @@ sctp_send_shutdown(struct sctp_tcb *stcb, struct sctp_nets *net) return; } chk->copy_by_ref = 0; - chk->send_size = sizeof(struct sctp_shutdown_chunk); chk->rec.chunk_id.id = SCTP_SHUTDOWN; chk->rec.chunk_id.can_take_data = 1; + chk->flags = 0; + chk->send_size = sizeof(struct sctp_shutdown_chunk); chk->sent = SCTP_DATAGRAM_UNSENT; chk->snd_count = 0; chk->flags = 0; @@ -9717,13 +9714,13 @@ sctp_send_asconf(struct sctp_tcb *stcb, struct sctp_nets *net, int addr_locked) } chk->copy_by_ref = 0; - chk->data = m_asconf; - chk->send_size = len; chk->rec.chunk_id.id = SCTP_ASCONF; chk->rec.chunk_id.can_take_data = 0; + chk->flags = CHUNK_FLAGS_FRAGMENT_OK; + chk->data = m_asconf; + chk->send_size = len; chk->sent = SCTP_DATAGRAM_UNSENT; chk->snd_count = 0; - chk->flags = CHUNK_FLAGS_FRAGMENT_OK; chk->asoc = &stcb->asoc; chk->whoTo = net; if (chk->whoTo) { @@ -9813,7 +9810,9 @@ sctp_send_asconf_ack(struct sctp_tcb *stcb) return; } chk->copy_by_ref = 0; - + chk->rec.chunk_id.id = SCTP_ASCONF_ACK; + chk->rec.chunk_id.can_take_data = 1; + chk->flags = CHUNK_FLAGS_FRAGMENT_OK; chk->whoTo = net; if (chk->whoTo) { atomic_add_int(&chk->whoTo->ref_count, 1); @@ -9822,11 +9821,8 @@ sctp_send_asconf_ack(struct sctp_tcb *stcb) chk->send_size = 0; /* Get size */ chk->send_size = ack->len; - chk->rec.chunk_id.id = SCTP_ASCONF_ACK; - chk->rec.chunk_id.can_take_data = 1; chk->sent = SCTP_DATAGRAM_UNSENT; chk->snd_count = 0; - chk->flags |= CHUNK_FLAGS_FRAGMENT_OK; /* XXX */ chk->asoc = &stcb->asoc; TAILQ_INSERT_TAIL(&chk->asoc->control_send_queue, chk, sctp_next); @@ -10739,6 +10735,7 @@ send_forward_tsn(struct sctp_tcb *stcb, chk->copy_by_ref = 0; chk->rec.chunk_id.id = SCTP_FORWARD_CUM_TSN; chk->rec.chunk_id.can_take_data = 0; + chk->flags = 0; chk->asoc = asoc; chk->whoTo = NULL; chk->data = sctp_get_mbuf_for_msg(MCLBYTES, 0, M_NOWAIT, 1, MT_DATA); @@ -10972,6 +10969,7 @@ sctp_send_sack(struct sctp_tcb *stcb, int so_locked /* Clear our pkt counts */ asoc->data_pkts_seen = 0; + a_chk->flags = 0; a_chk->asoc = asoc; a_chk->snd_count = 0; a_chk->send_size = 0; /* fill in later */ @@ -11895,6 +11893,7 @@ sctp_send_hb(struct sctp_tcb *stcb, struct sctp_nets *net,int so_locked chk->copy_by_ref = 0; chk->rec.chunk_id.id = SCTP_HEARTBEAT_REQUEST; chk->rec.chunk_id.can_take_data = 1; + chk->flags = 0; chk->asoc = &stcb->asoc; chk->send_size = sizeof(struct sctp_heartbeat_chunk); @@ -12025,10 +12024,11 @@ sctp_send_ecn_echo(struct sctp_tcb *stcb, struct sctp_nets *net, if (chk == NULL) { return; } - chk->copy_by_ref = 0; SCTP_STAT_INCR(sctps_queue_upd_ecne); + chk->copy_by_ref = 0; chk->rec.chunk_id.id = SCTP_ECN_ECHO; chk->rec.chunk_id.can_take_data = 0; + chk->flags = 0; chk->asoc = &stcb->asoc; chk->send_size = sizeof(struct sctp_ecne_chunk); chk->data = sctp_get_mbuf_for_msg(chk->send_size, 0, M_NOWAIT, 1, MT_HEADER); @@ -12088,6 +12088,9 @@ sctp_send_packet_dropped(struct sctp_tcb *stcb, struct sctp_nets *net, return; } chk->copy_by_ref = 0; + chk->rec.chunk_id.id = SCTP_PACKET_DROPPED; + chk->rec.chunk_id.can_take_data = 1; + chk->flags = 0; len -= iphlen; chk->send_size = len; /* Validate that we do not have an ABORT in here. */ @@ -12173,8 +12176,6 @@ jump_out: } else { chk->whoTo = NULL; } - chk->rec.chunk_id.id = SCTP_PACKET_DROPPED; - chk->rec.chunk_id.can_take_data = 1; drp->ch.chunk_type = SCTP_PACKET_DROPPED; drp->ch.chunk_length = htons(chk->send_size); spc = SCTP_SB_LIMIT_RCV(stcb->sctp_socket); @@ -12236,6 +12237,7 @@ sctp_send_cwr(struct sctp_tcb *stcb, struct sctp_nets *net, uint32_t high_tsn, u chk->copy_by_ref = 0; chk->rec.chunk_id.id = SCTP_ECN_CWR; chk->rec.chunk_id.can_take_data = 1; + chk->flags = 0; chk->asoc = &stcb->asoc; chk->send_size = sizeof(struct sctp_cwr_chunk); chk->data = sctp_get_mbuf_for_msg(chk->send_size, 0, M_NOWAIT, 1, MT_HEADER); @@ -12547,6 +12549,7 @@ sctp_send_str_reset_req(struct sctp_tcb *stcb, chk->copy_by_ref = 0; chk->rec.chunk_id.id = SCTP_STREAM_RESET; chk->rec.chunk_id.can_take_data = 0; + chk->flags = 0; chk->asoc = &stcb->asoc; chk->book_size = sizeof(struct sctp_chunkhdr); chk->send_size = SCTP_SIZE32(chk->book_size); -- cgit v1.2.3 From 7accb99da6264405fd546d98af91e4f2969002c5 Mon Sep 17 00:00:00 2001 From: t00fcxen Date: Thu, 16 Oct 2014 15:42:43 +0000 Subject: Sync with Mavericks sources. git-svn-id: http://sctp-refimpl.googlecode.com/svn/trunk/KERN/usrsctp/usrsctplib@9048 9df1edf5-d72c-5b5f-11c0-5f5209eb73f7 --- netinet/sctp_header.h | 8 ++++++-- netinet/sctp_input.c | 35 +++++++++++++++++++---------------- netinet/sctp_input.h | 4 ++-- 3 files changed, 27 insertions(+), 20 deletions(-) diff --git a/netinet/sctp_header.h b/netinet/sctp_header.h index a860c18..f62181f 100755 --- a/netinet/sctp_header.h +++ b/netinet/sctp_header.h @@ -32,7 +32,7 @@ #ifdef __FreeBSD__ #include -__FBSDID("$FreeBSD: head/sys/netinet/sctp_header.h 269376 2014-08-01 12:42:37Z tuexen $"); +__FBSDID("$FreeBSD: head/sys/netinet/sctp_header.h 273168 2014-10-16 15:36:04Z tuexen $"); #endif #ifndef _NETINET_SCTP_HEADER_H_ @@ -468,6 +468,11 @@ struct sctp_pktdrop_chunk { /**********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 */ @@ -482,7 +487,6 @@ struct sctp_stream_reset_in_request { 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; diff --git a/netinet/sctp_input.c b/netinet/sctp_input.c index 5302582..da9c625 100755 --- a/netinet/sctp_input.c +++ b/netinet/sctp_input.c @@ -32,7 +32,7 @@ #ifdef __FreeBSD__ #include -__FBSDID("$FreeBSD: head/sys/netinet/sctp_input.c 272841 2014-10-09 20:08:12Z tuexen $"); +__FBSDID("$FreeBSD: head/sys/netinet/sctp_input.c 273168 2014-10-16 15:36:04Z tuexen $"); #endif #include @@ -3626,12 +3626,12 @@ sctp_reset_out_streams(struct sctp_tcb *stcb, uint32_t number_entries, uint16_t } -struct sctp_stream_reset_out_request * +struct sctp_stream_reset_request * sctp_find_stream_reset(struct sctp_tcb *stcb, uint32_t seq, struct sctp_tmit_chunk **bchk) { struct sctp_association *asoc; struct sctp_chunkhdr *ch; - struct sctp_stream_reset_out_request *r; + struct sctp_stream_reset_request *r; struct sctp_tmit_chunk *chk; int len, clen; @@ -3654,7 +3654,7 @@ sctp_find_stream_reset(struct sctp_tcb *stcb, uint32_t seq, struct sctp_tmit_chu } clen = chk->send_size; ch = mtod(chk->data, struct sctp_chunkhdr *); - r = (struct sctp_stream_reset_out_request *)(ch + 1); + r = (struct sctp_stream_reset_request *)(ch + 1); if (ntohl(r->request_seq) == seq) { /* found it */ return (r); @@ -3662,7 +3662,7 @@ sctp_find_stream_reset(struct sctp_tcb *stcb, uint32_t seq, struct sctp_tmit_chu len = SCTP_SIZE32(ntohs(r->ph.param_length)); if (clen > (len + (int)sizeof(struct sctp_chunkhdr))) { /* move to the next one, there can only be a max of two */ - r = (struct sctp_stream_reset_out_request *)((caddr_t)r + len); + r = (struct sctp_stream_reset_request *)((caddr_t)r + len); if (ntohl(r->request_seq) == seq) { return (r); } @@ -3706,7 +3706,9 @@ sctp_handle_stream_reset_response(struct sctp_tcb *stcb, int lparm_len; struct sctp_association *asoc = &stcb->asoc; struct sctp_tmit_chunk *chk; - struct sctp_stream_reset_out_request *srparam; + struct sctp_stream_reset_request *req_param; + struct sctp_stream_reset_out_request *req_out_param; + struct sctp_stream_reset_in_request *req_in_param; uint32_t number_entries; if (asoc->stream_reset_outstanding == 0) { @@ -3714,35 +3716,36 @@ sctp_handle_stream_reset_response(struct sctp_tcb *stcb, return (0); } if (seq == stcb->asoc.str_reset_seq_out) { - srparam = sctp_find_stream_reset(stcb, seq, &chk); - if (srparam) { + req_param = sctp_find_stream_reset(stcb, seq, &chk); + if (req_param != NULL) { stcb->asoc.str_reset_seq_out++; - type = ntohs(srparam->ph.param_type); - lparm_len = ntohs(srparam->ph.param_length); + type = ntohs(req_param->ph.param_type); + lparm_len = ntohs(req_param->ph.param_length); if (type == SCTP_STR_RESET_OUT_REQUEST) { + req_out_param = (struct sctp_stream_reset_out_request *)req_param; number_entries = (lparm_len - sizeof(struct sctp_stream_reset_out_request)) / sizeof(uint16_t); asoc->stream_reset_out_is_outstanding = 0; if (asoc->stream_reset_outstanding) asoc->stream_reset_outstanding--; if (action == SCTP_STREAM_RESET_RESULT_PERFORMED) { /* do it */ - sctp_reset_out_streams(stcb, number_entries, srparam->list_of_streams); + sctp_reset_out_streams(stcb, number_entries, req_out_param->list_of_streams); } else if (action == SCTP_STREAM_RESET_RESULT_DENIED) { - sctp_ulp_notify(SCTP_NOTIFY_STR_RESET_DENIED_OUT, stcb, number_entries, srparam->list_of_streams, SCTP_SO_NOT_LOCKED); + sctp_ulp_notify(SCTP_NOTIFY_STR_RESET_DENIED_OUT, stcb, number_entries, req_out_param->list_of_streams, SCTP_SO_NOT_LOCKED); } else { - sctp_ulp_notify(SCTP_NOTIFY_STR_RESET_FAILED_OUT, stcb, number_entries, srparam->list_of_streams, SCTP_SO_NOT_LOCKED); + sctp_ulp_notify(SCTP_NOTIFY_STR_RESET_FAILED_OUT, stcb, number_entries, req_out_param->list_of_streams, SCTP_SO_NOT_LOCKED); } } else if (type == SCTP_STR_RESET_IN_REQUEST) { - /* Answered my request */ + req_in_param = (struct sctp_stream_reset_in_request *)req_param; number_entries = (lparm_len - sizeof(struct sctp_stream_reset_in_request)) / sizeof(uint16_t); if (asoc->stream_reset_outstanding) asoc->stream_reset_outstanding--; if (action == SCTP_STREAM_RESET_RESULT_DENIED) { sctp_ulp_notify(SCTP_NOTIFY_STR_RESET_DENIED_IN, stcb, - number_entries, srparam->list_of_streams, SCTP_SO_NOT_LOCKED); + number_entries, req_in_param->list_of_streams, SCTP_SO_NOT_LOCKED); } else if (action != SCTP_STREAM_RESET_RESULT_PERFORMED) { sctp_ulp_notify(SCTP_NOTIFY_STR_RESET_FAILED_IN, stcb, - number_entries, srparam->list_of_streams, SCTP_SO_NOT_LOCKED); + number_entries, req_in_param->list_of_streams, SCTP_SO_NOT_LOCKED); } } else if (type == SCTP_STR_RESET_ADD_OUT_STREAMS) { /* Ok we now may have more streams */ diff --git a/netinet/sctp_input.h b/netinet/sctp_input.h index 4756780..5d45fef 100755 --- a/netinet/sctp_input.h +++ b/netinet/sctp_input.h @@ -32,7 +32,7 @@ #ifdef __FreeBSD__ #include -__FBSDID("$FreeBSD: head/sys/netinet/sctp_input.h 240198 2012-09-07 13:36:42Z tuexen $"); +__FBSDID("$FreeBSD: head/sys/netinet/sctp_input.h 273168 2014-10-16 15:36:04Z tuexen $"); #endif #ifndef _NETINET_SCTP_INPUT_H_ @@ -52,7 +52,7 @@ sctp_common_input_processing(struct mbuf **, int, int, int, #endif uint32_t, uint16_t); -struct sctp_stream_reset_out_request * +struct sctp_stream_reset_request * sctp_find_stream_reset(struct sctp_tcb *stcb, uint32_t seq, struct sctp_tmit_chunk **bchk); -- cgit v1.2.3 From 190c8cbfcf8fd810aa09e0fab4ca62a8ce724e14 Mon Sep 17 00:00:00 2001 From: t00fcxen Date: Sat, 25 Oct 2014 09:28:48 +0000 Subject: Sync with Mavericks sources. git-svn-id: http://sctp-refimpl.googlecode.com/svn/trunk/KERN/usrsctp/usrsctplib@9051 9df1edf5-d72c-5b5f-11c0-5f5209eb73f7 --- netinet/sctp_output.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/netinet/sctp_output.c b/netinet/sctp_output.c index 07ae932..57cc8c6 100755 --- a/netinet/sctp_output.c +++ b/netinet/sctp_output.c @@ -32,7 +32,7 @@ #ifdef __FreeBSD__ #include -__FBSDID("$FreeBSD: head/sys/netinet/sctp_output.c 272841 2014-10-09 20:08:12Z tuexen $"); +__FBSDID("$FreeBSD: head/sys/netinet/sctp_output.c 273634 2014-10-25 09:25:29Z tuexen $"); #endif #include @@ -7165,9 +7165,10 @@ sctp_sendall_iterator(struct sctp_inpcb *inp, struct sctp_tcb *stcb, void *ptr, if (do_chunk_output) sctp_chunk_output(inp, stcb, SCTP_OUTPUT_FROM_USR_SEND, SCTP_SO_NOT_LOCKED); else if (added_control) { - int num_out = 0, reason = 0, now_filled = 0; + int num_out, reason, now_filled = 0; struct timeval now; int frag_point; + frag_point = sctp_get_frag_point(stcb, &stcb->asoc); (void)sctp_med_chunk_output(inp, stcb, &stcb->asoc, &num_out, &reason, 1, 1, &now, &now_filled, frag_point, SCTP_SO_NOT_LOCKED); @@ -8247,6 +8248,7 @@ sctp_med_chunk_output(struct sctp_inpcb *inp, } #endif *num_out = 0; + *reason_code = 0; auth_keyid = stcb->asoc.authinfo.active_keyid; if ((asoc->state & SCTP_STATE_SHUTDOWN_PENDING) || (asoc->state & SCTP_STATE_SHUTDOWN_RECEIVED) || @@ -10405,7 +10407,7 @@ sctp_chunk_output (struct sctp_inpcb *inp, */ struct sctp_association *asoc; struct sctp_nets *net; - int error = 0, num_out = 0, tot_out = 0, ret = 0, reason_code = 0; + int error = 0, num_out, tot_out = 0, ret = 0, reason_code; unsigned int burst_cnt = 0; struct timeval now; int now_filled = 0; -- cgit v1.2.3