Date: Sun, 29 Apr 2012 18:28:59 +0000 (UTC) From: Michael Tuexen <tuexen@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org Subject: svn commit: r234804 - stable/8/sys/netinet Message-ID: <201204291828.q3TISxxx026410@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: tuexen Date: Sun Apr 29 18:28:58 2012 New Revision: 234804 URL: http://svn.freebsd.org/changeset/base/234804 Log: MFC r233311: Small cleanup of the code. No functional change (in FreeBSD kernel). Modified: stable/8/sys/netinet/sctputil.c Directory Properties: stable/8/sys/ (props changed) Modified: stable/8/sys/netinet/sctputil.c ============================================================================== --- stable/8/sys/netinet/sctputil.c Sun Apr 29 17:12:33 2012 (r234803) +++ stable/8/sys/netinet/sctputil.c Sun Apr 29 18:28:58 2012 (r234804) @@ -5443,28 +5443,31 @@ found_one: } #endif if (fromlen && from) { - struct sockaddr *to; - + cp_len = min((size_t)fromlen, (size_t)control->whoFrom->ro._l_addr.sa.sa_len); + switch (control->whoFrom->ro._l_addr.sa.sa_family) { +#ifdef INET6 + case AF_INET6: + ((struct sockaddr_in6 *)from)->sin6_port = control->port_from; + break; +#endif #ifdef INET - cp_len = min((size_t)fromlen, (size_t)control->whoFrom->ro._l_addr.sin.sin_len); - memcpy(from, &control->whoFrom->ro._l_addr, cp_len); - ((struct sockaddr_in *)from)->sin_port = control->port_from; -#else - /* No AF_INET use AF_INET6 */ - cp_len = min((size_t)fromlen, (size_t)control->whoFrom->ro._l_addr.sin6.sin6_len); - memcpy(from, &control->whoFrom->ro._l_addr, cp_len); - ((struct sockaddr_in6 *)from)->sin6_port = control->port_from; + case AF_INET: + ((struct sockaddr_in *)from)->sin_port = control->port_from; + break; #endif + default: + break; + } + memcpy(from, &control->whoFrom->ro._l_addr, cp_len); - to = from; #if defined(INET) && defined(INET6) if ((sctp_is_feature_on(inp, SCTP_PCB_FLAGS_NEEDS_MAPPED_V4)) && - (to->sa_family == AF_INET) && + (from->sa_family == AF_INET) && ((size_t)fromlen >= sizeof(struct sockaddr_in6))) { struct sockaddr_in *sin; struct sockaddr_in6 sin6; - sin = (struct sockaddr_in *)to; + sin = (struct sockaddr_in *)from; bzero(&sin6, sizeof(sin6)); sin6.sin6_family = AF_INET6; sin6.sin6_len = sizeof(struct sockaddr_in6); @@ -5473,15 +5476,15 @@ found_one: &sin6.sin6_addr.s6_addr32[3], sizeof(sin6.sin6_addr.s6_addr32[3])); sin6.sin6_port = sin->sin_port; - memcpy(from, (caddr_t)&sin6, sizeof(sin6)); + memcpy(from, &sin6, sizeof(struct sockaddr_in6)); } #endif #if defined(INET6) { - struct sockaddr_in6 lsa6, *to6; + struct sockaddr_in6 lsa6, *from6; - to6 = (struct sockaddr_in6 *)to; - sctp_recover_scope_mac(to6, (&lsa6)); + from6 = (struct sockaddr_in6 *)from; + sctp_recover_scope_mac(from6, (&lsa6)); } #endif }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201204291828.q3TISxxx026410>