neel_neelc.org updated this revision to Diff 68662. neel_neelc.org added a comment.
Remove testing printfs. REPOSITORY rS FreeBSD src repository CHANGES SINCE LAST UPDATE https://reviews.freebsd.org/D23788?vs=68661&id=68662 CHANGES SINCE LAST ACTION https://reviews.freebsd.org/D23788/new/ REVISION DETAIL https://reviews.freebsd.org/D23788 AFFECTED FILES sys/netgraph/ng_ksocket.c EMAIL PREFERENCES https://reviews.freebsd.org/settings/panel/emailpreferences/ To: neel_neelc.org Cc: imp, lutz_donnerhacke.de, melifaro, #contributor_reviews_base, freebsd-net-list, mmacy, kpraveen.lkml_gmail.com, marcnarc_gmail.com, simonvella_gmail.com, novice_techie.com, tommi.pernila_iki.fi
diff --git a/sys/netgraph/ng_ksocket.c b/sys/netgraph/ng_ksocket.c --- a/sys/netgraph/ng_ksocket.c +++ b/sys/netgraph/ng_ksocket.c @@ -149,6 +149,19 @@ { "encap", IPPROTO_ENCAP, PF_INET }, { "divert", IPPROTO_DIVERT, PF_INET }, { "pim", IPPROTO_PIM, PF_INET }, + { "ip6", IPPROTO_IPV6, PF_INET6 }, + { "raw6", IPPROTO_RAW, PF_INET6 }, + { "icmp6", IPPROTO_ICMPV6, PF_INET6 }, + { "igmp6", IPPROTO_IGMP, PF_INET6 }, + { "tcp6", IPPROTO_TCP, PF_INET6 }, + { "udp6", IPPROTO_UDP, PF_INET6 }, + { "gre6", IPPROTO_GRE, PF_INET6 }, + { "esp6", IPPROTO_ESP, PF_INET6 }, + { "ah6", IPPROTO_AH, PF_INET6 }, + { "swipe6", IPPROTO_SWIPE, PF_INET6 }, + { "encap6", IPPROTO_ENCAP, PF_INET6 }, + { "divert6", IPPROTO_DIVERT, PF_INET6 }, + { "pim6", IPPROTO_PIM, PF_INET6 }, { NULL, -1 }, }; @@ -294,10 +307,44 @@ break; } -#if 0 - case PF_INET6: /* XXX implement this someday */ -#endif + case PF_INET6: + { + struct sockaddr_in6 *const sin6 = (struct sockaddr_in6 *)sa; + int i = 0; + sin6->sin6_port = 0; + if (s[*off] == '[') + (*off)++; + + for (i = 0; i < 8; i++) { + u_long val; + char *eptr; + + val = strtoul(s + *off, &eptr, 16); + if (val > 0xffff || eptr == s + *off) + return (EINVAL); + *off += (eptr - (s + *off)); + sin6->sin6_addr.s6_addr16[i] = htons(val); + //sin6->sin6_addr.__u6_addr.__u6_addr16[i] = htons(val); + if (i < 7) { + if (s[*off] != ':') + return (EINVAL); + (*off)++; + } else if (s[*off] == ']') { + (*off)++; + if (s[*off] == ':') { + (*off)++; + val = strtoul(s + *off, &eptr, 10); + if (val > 0xffff || eptr == s + *off) + return (EINVAL); + *off += (eptr - (s + *off)); + sin6->sin6_port = htons(val); + } + } + } + break; + } + default: return (EINVAL); } @@ -356,9 +403,29 @@ return(0); } -#if 0 - case PF_INET6: /* XXX implement this someday */ -#endif + case PF_INET6: + { + const struct sockaddr_in6 *sin6 = (const struct sockaddr_in6 *)sa; + + slen += snprintf(cbuf, cbuflen, "inet6/[%u:%u:%u:%u:%u:%u:%u:%u]", + ((const u_int *)&sin6->sin6_addr.__u6_addr.__u6_addr16)[0], + ((const u_int *)&sin6->sin6_addr.__u6_addr.__u6_addr16)[1], + ((const u_int *)&sin6->sin6_addr.__u6_addr.__u6_addr16)[2], + ((const u_int *)&sin6->sin6_addr.__u6_addr.__u6_addr16)[3], + ((const u_int *)&sin6->sin6_addr.__u6_addr.__u6_addr16)[4], + ((const u_int *)&sin6->sin6_addr.__u6_addr.__u6_addr16)[5], + ((const u_int *)&sin6->sin6_addr.__u6_addr.__u6_addr16)[6], + ((const u_int *)&sin6->sin6_addr.__u6_addr.__u6_addr16)[7]); + if (sin6->sin6_port != 0) { + slen += snprintf(cbuf + strlen(cbuf), + cbuflen - strlen(cbuf), ":%d", + (u_int)ntohs(sin6->sin6_port)); + } + if (slen >= cbuflen) + return (ERANGE); + *off += sizeof(*sin6); + return(0); + } default: return (*ng_ksocket_generic_sockaddr_type.supertype->unparse)
_______________________________________________ freebsd-net@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/freebsd-net To unsubscribe, send any mail to "freebsd-net-unsubscr...@freebsd.org"