summaryrefslogtreecommitdiff
path: root/src/pkg/net/lookup_plan9.go
diff options
context:
space:
mode:
authorMichael Stapelberg <michael@stapelberg.de>2013-03-23 11:29:06 +0100
committerMichael Stapelberg <michael@stapelberg.de>2013-03-23 11:29:06 +0100
commitcc71238f4c5d23ee2ebffd0d6c307e308ea163c1 (patch)
treedd0b57254871fac715258385f5485ba136d6b62a /src/pkg/net/lookup_plan9.go
parentb32e37d71adab0e2a2b7c4433e7bad169a9a4f98 (diff)
parentb39e15dde5ec7b96c15da9faf4ab5892501c1aae (diff)
downloadgolang-cc71238f4c5d23ee2ebffd0d6c307e308ea163c1.tar.gz
Merge tag 'upstream/1.1_hg20130323' into debian-sid
Upstream version 1.1~hg20130323
Diffstat (limited to 'src/pkg/net/lookup_plan9.go')
-rw-r--r--src/pkg/net/lookup_plan9.go22
1 files changed, 19 insertions, 3 deletions
diff --git a/src/pkg/net/lookup_plan9.go b/src/pkg/net/lookup_plan9.go
index ae7cf7942..94c553328 100644
--- a/src/pkg/net/lookup_plan9.go
+++ b/src/pkg/net/lookup_plan9.go
@@ -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) {