diff options
author | Jun-ichiro itojun Hagino <itojun@cvs.openbsd.org> | 2000-06-13 10:12:02 +0000 |
---|---|---|
committer | Jun-ichiro itojun Hagino <itojun@cvs.openbsd.org> | 2000-06-13 10:12:02 +0000 |
commit | 2a1a93444daf975435e69cd08e072311261d6354 (patch) | |
tree | e24d1167c9ba5ddb40875ccc4cb13b25338966fb /sys/netinet/udp_usrreq.c | |
parent | f43a60883364695d1eb6ee3d262e4313aa44ff4f (diff) |
allow link-local IPv6 addres in in6_pcbbind.
Diffstat (limited to 'sys/netinet/udp_usrreq.c')
-rw-r--r-- | sys/netinet/udp_usrreq.c | 55 |
1 files changed, 13 insertions, 42 deletions
diff --git a/sys/netinet/udp_usrreq.c b/sys/netinet/udp_usrreq.c index d82d9134635..bd091091eab 100644 --- a/sys/netinet/udp_usrreq.c +++ b/sys/netinet/udp_usrreq.c @@ -1,4 +1,4 @@ -/* $OpenBSD: udp_usrreq.c,v 1.40 2000/04/09 17:43:02 angelos Exp $ */ +/* $OpenBSD: udp_usrreq.c,v 1.41 2000/06/13 10:12:00 itojun Exp $ */ /* $NetBSD: udp_usrreq.c,v 1.28 1996/03/16 23:54:03 christos Exp $ */ /* @@ -859,55 +859,26 @@ udp_output(m, va_alist) struct udphdr *uh = (struct udphdr *)(mtod(m, caddr_t) + sizeof(struct ip6_hdr)); int payload = sizeof(struct ip6_hdr); - struct in6_addr *faddr; struct in6_addr *laddr; struct ifnet *oifp = NULL; + struct sockaddr_in6 tmp; ipv6->ip6_flow = htonl(0x60000000) | (inp->inp_ipv6.ip6_flow & htonl(0x0fffffff)); ipv6->ip6_nxt = IPPROTO_UDP; - ipv6->ip6_dst = inp->inp_faddr6; - /* - * If the scope of the destination is link-local, - * embed the interface - * index in the address. - * - * XXX advanced-api value overrides sin6_scope_id - */ - faddr = &ipv6->ip6_dst; - if (IN6_IS_ADDR_LINKLOCAL(faddr) || - IN6_IS_ADDR_MC_LINKLOCAL(faddr)) { - struct ip6_pktopts *optp = inp->inp_outputopts6; - struct in6_pktinfo *pi = NULL; - struct ip6_moptions *mopt = NULL; - - /* - * XXX Boundary check is assumed to be already done in - * ip6_setpktoptions(). - */ - if (optp && (pi = optp->ip6po_pktinfo) && - pi->ipi6_ifindex) { - faddr->s6_addr16[1] = htons(pi->ipi6_ifindex); - oifp = ifindex2ifnet[pi->ipi6_ifindex]; - } - else if (IN6_IS_ADDR_MULTICAST(faddr) && - (mopt = inp->inp_moptions6) && - mopt->im6o_multicast_ifp) { - oifp = mopt->im6o_multicast_ifp; - faddr->s6_addr16[1] = oifp->if_index; - } else if (sin6 && sin6->sin6_scope_id) { - /* boundary check */ - if (sin6->sin6_scope_id < 0 - || if_index < sin6->sin6_scope_id) { - error = ENXIO; /* XXX EINVAL? */ - goto release; - } - /* XXX */ - faddr->s6_addr16[1] = - htons(sin6->sin6_scope_id & 0xffff); - } + if (sin6) + tmp = *sin6; + else { + bzero(&tmp, sizeof(tmp)); + tmp.sin6_family = AF_INET6; + tmp.sin6_len = sizeof(struct sockaddr_in6); + tmp.sin6_addr = inp->inp_faddr6; } + /* KAME hack: embed scopeid */ + if (in6_embedscope(&ipv6->ip6_dst, &tmp, inp, NULL) != 0) + return EINVAL; + ipv6->ip6_hlim = in6_selecthlim(inp, oifp); if (sin6) { /*XXX*/ laddr = in6_selectsrc(sin6, inp->inp_outputopts6, |