mirror of
https://github.com/golang/go
synced 2024-11-15 00:20:30 -07:00
4d00937cec
Regression from Go 1.6 to Go 1.7rc1: we had broken the ability for users to vendor "golang.org/x/net/http2" or "golang.org/x/net/route" because we were vendoring them ourselves and cmd/go and cmd/compile do not understand multiple vendor directories across multiple GOPATH workspaces (e.g. user's $GOPATH and default $GOROOT). As a short-term fix, since fixing cmd/go and cmd/compile is too invasive at this point in the cycle, just rename "golang.org" to "golang_org" for the standard library's vendored copy. Fixes #16333 Change-Id: I9bfaed91e9f7d4ca6bab07befe80d71d437a21af Reviewed-on: https://go-review.googlesource.com/24902 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
54 lines
1.3 KiB
Go
54 lines
1.3 KiB
Go
// Copyright 2011 The Go Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
package net
|
|
|
|
import (
|
|
"syscall"
|
|
|
|
"golang_org/x/net/route"
|
|
)
|
|
|
|
func interfaceMessages(ifindex int) ([]route.Message, error) {
|
|
rib, err := route.FetchRIB(syscall.AF_UNSPEC, syscall.NET_RT_IFLIST, ifindex)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return route.ParseRIB(syscall.NET_RT_IFLIST, rib)
|
|
}
|
|
|
|
// interfaceMulticastAddrTable returns addresses for a specific
|
|
// interface.
|
|
func interfaceMulticastAddrTable(ifi *Interface) ([]Addr, error) {
|
|
rib, err := route.FetchRIB(syscall.AF_UNSPEC, syscall.NET_RT_IFLIST2, ifi.Index)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
msgs, err := route.ParseRIB(syscall.NET_RT_IFLIST2, rib)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
ifmat := make([]Addr, 0, len(msgs))
|
|
for _, m := range msgs {
|
|
switch m := m.(type) {
|
|
case *route.InterfaceMulticastAddrMessage:
|
|
if ifi.Index != m.Index {
|
|
continue
|
|
}
|
|
var ip IP
|
|
switch sa := m.Addrs[syscall.RTAX_IFA].(type) {
|
|
case *route.Inet4Addr:
|
|
ip = IPv4(sa.IP[0], sa.IP[1], sa.IP[2], sa.IP[3])
|
|
case *route.Inet6Addr:
|
|
ip = make(IP, IPv6len)
|
|
copy(ip, sa.IP[:])
|
|
}
|
|
if ip != nil {
|
|
ifmat = append(ifmat, &IPAddr{IP: ip})
|
|
}
|
|
}
|
|
}
|
|
return ifmat, nil
|
|
}
|