diff options
Diffstat (limited to 'appl/cmd/ip')
| -rw-r--r-- | appl/cmd/ip/ping.b | 25 | ||||
| -rw-r--r-- | appl/cmd/ip/rip.b | 11 |
2 files changed, 15 insertions, 21 deletions
diff --git a/appl/cmd/ip/ping.b b/appl/cmd/ip/ping.b index a148c1e6..d0547390 100644 --- a/appl/cmd/ip/ping.b +++ b/appl/cmd/ip/ping.b @@ -16,6 +16,9 @@ include "timers.m"; include "rand.m"; rand: Rand; +include "dial.m"; + dial: Dial; + include "arg.m"; Ping: module @@ -74,6 +77,7 @@ init(nil: ref Draw->Context, args: list of string) sys = load Sys Sys->PATH; rand = load Rand Rand->PATH; timers = load Timers Timers->PATH; + dial = load Dial Dial->PATH; ip = load IP IP->PATH; ip->init(); @@ -117,9 +121,9 @@ init(nil: ref Draw->Context, args: list of string) opentime(); rand->init(int(nsec()/big 1000)); - addr := netmkaddr(hd args, "icmp", "1"); - (ok, c) := sys->dial(addr, nil); - if(ok < 0){ + addr := dial->netmkaddr(hd args, "icmp", "1"); + c := dial->dial(addr, nil); + if(c == nil){ sys->fprint(sys->fildes(2), "ip/ping: can't dial %s: %r\n", addr); raise "fail:dial"; } @@ -333,21 +337,6 @@ Icmp.unpack(b: array of byte): ref Icmp return ic; } -netmkaddr(addr, net, svc: string): string -{ - if(net == nil) - net = "net"; - (n, l) := sys->tokenize(addr, "!"); - if(n <= 1){ - if(svc== nil) - return sys->sprint("%s!%s", net, addr); - return sys->sprint("%s!%s!%s", net, addr, svc); - } - if(svc == nil || n > 2) - return addr; - return sys->sprint("%s!%s", addr, svc); -} - timefd: ref Sys->FD; opentime() diff --git a/appl/cmd/ip/rip.b b/appl/cmd/ip/rip.b index 90c1b6ce..81dfca58 100644 --- a/appl/cmd/ip/rip.b +++ b/appl/cmd/ip/rip.b @@ -15,6 +15,10 @@ include "bufio.m"; include "daytime.m"; daytime: Daytime; +include "dial.m"; + dial: Dial; + + include "ip.m"; ip: IP; IPaddr, Ifcaddr, Udphdr: import ip; @@ -105,6 +109,7 @@ init(nil: ref Draw->Context, args: list of string) sys = load Sys Sys->PATH; bufio = load Bufio Bufio->PATH; daytime = load Daytime Daytime->PATH; + dial = load Dial Dial->PATH; ip = load IP IP->PATH; ip->init(); @@ -420,7 +425,7 @@ sendroutes(ifc: ref Ifcaddr, dst: IPaddr, op: int, changes: int) buf[o+2] = byte 0; buf[o+3] = byte 0; o += Riphdrlen; - rips := buf[IP->Udphdrlen+Riphdrlen:]; +# rips := buf[IP->Udphdrlen+Riphdrlen:]; if(op == OpRequest){ buf[o:] = zeroentry; ip->put4(buf, o+Ometric, HopLimit); @@ -602,8 +607,8 @@ Gateway.contains(g: self ref Gateway, a: IPaddr): int riplisten(): ref Sys->FD { addr := sys->sprint("%s/udp!*!rip", netdir); - (ok, c) := sys->announce(addr); - if(ok < 0) + c := dial->announce(addr); + if(c == nil) fatal(sys->sprint("can't announce %s: %r", addr)); if(sys->fprint(c.cfd, "headers") < 0) fatal(sys->sprint("can't set udp headers: %r")); |
