mirror of https://github.com/golang/go.git
net: Plan 9: add lookupProtocol
Needed by TestResolveIPAddr. This makes us pass tests again. R=rsc, rminnich, ality, bradfitz CC=golang-dev https://golang.org/cl/7737043
This commit is contained in:
parent
f7ad816c5c
commit
a1b2d1404b
|
|
@ -7,7 +7,6 @@ package net
|
|||
import (
|
||||
"errors"
|
||||
"os"
|
||||
"syscall"
|
||||
)
|
||||
|
||||
func query(filename, query string, bufSize int) (res []string, err error) {
|
||||
|
|
@ -70,9 +69,26 @@ func queryDNS(addr string, typ string) (res []string, err error) {
|
|||
return query("/net/dns", addr+" "+typ, 1024)
|
||||
}
|
||||
|
||||
// lookupProtocol looks up IP protocol name and returns
|
||||
// the corresponding protocol number.
|
||||
func lookupProtocol(name string) (proto int, err error) {
|
||||
// TODO: Implement this
|
||||
return 0, syscall.EPLAN9
|
||||
lines, err := query("/net/cs", "!protocol="+name, 128)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
unknownProtoError := errors.New("unknown IP protocol specified: " + name)
|
||||
if len(lines) == 0 {
|
||||
return 0, unknownProtoError
|
||||
}
|
||||
f := getFields(lines[0])
|
||||
if len(f) < 2 {
|
||||
return 0, unknownProtoError
|
||||
}
|
||||
s := f[1]
|
||||
if n, _, ok := dtoi(s, byteIndex(s, '=')+1); ok {
|
||||
return n, nil
|
||||
}
|
||||
return 0, unknownProtoError
|
||||
}
|
||||
|
||||
func lookupHost(host string) (addrs []string, err error) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue