summaryrefslogtreecommitdiff
path: root/appl/cmd/ip
diff options
context:
space:
mode:
authorcharles forsyth <charles.forsyth@gmail.com>2015-06-13 16:34:09 +0100
committercharles forsyth <charles.forsyth@gmail.com>2015-06-13 16:34:09 +0100
commit62d7827bc358c000db9ff48fe61bd28ac352a884 (patch)
tree3369436e1f4ccfabd4bd5a58632d26934b868688 /appl/cmd/ip
parent15cdcc9295cbd45a03f77559b9de402033858a41 (diff)
mkfiles/mkfile-Linux-386
Diffstat (limited to 'appl/cmd/ip')
-rw-r--r--appl/cmd/ip/bootpd.b18
-rw-r--r--appl/cmd/ip/tftpd.b18
2 files changed, 24 insertions, 12 deletions
diff --git a/appl/cmd/ip/bootpd.b b/appl/cmd/ip/bootpd.b
index 71fea6f6..789c3e8a 100644
--- a/appl/cmd/ip/bootpd.b
+++ b/appl/cmd/ip/bootpd.b
@@ -18,6 +18,9 @@ include "attrdb.m";
attrdb: Attrdb;
Attr, Db, Dbentry, Tuples: import attrdb;
+include "dial.m";
+ dial: Dial;
+
include "ip.m";
ip: IP;
IPaddr, Udphdr: import ip;
@@ -63,6 +66,9 @@ init(nil: ref Draw->Context, args: list of string)
if(attrdb == nil)
loadfail(Attrdb->PATH);
attrdb->init();
+ dial = load Dial Dial->PATH;
+ if(dial == nil)
+ loadfail(Dial->PATH);
ip = load IP IP->PATH;
if(ip == nil)
loadfail(IP->PATH);
@@ -120,8 +126,8 @@ init(nil: ref Draw->Context, args: list of string)
addr = net+"/udp!*!499";
if(debug)
sys->fprint(stderr, "bootpd: announcing %s\n", addr);
- (ok, c) := sys->announce(addr);
- if(ok < 0)
+ c := dial->announce(addr);
+ if(c == nil)
error(sys->sprint("can't announce %s: %r", addr));
if(sys->fprint(c.cfd, "headers") < 0)
error(sys->sprint("can't set headers mode: %r"));
@@ -146,7 +152,7 @@ error(s: string)
raise "fail:error";
}
-server(c: Sys->Connection)
+server(c: ref Sys->Connection)
{
buf := array[2048] of byte;
badread := 0;
@@ -298,12 +304,12 @@ send(hdr: ref Udphdr, msg: array of byte)
lport := "67";
if(testing)
lport = "499";
- (n, c) := sys->dial(replyaddr, lport);
- if(n < 0) {
+ c := dial->dial(replyaddr, lport);
+ if(c == nil) {
sys->fprint(stderr, "bootpd: can't dial %s for reply: %r\n", replyaddr);
return;
}
- n = sys->write(c.dfd, msg, len msg);
+ n := sys->write(c.dfd, msg, len msg);
if(n != len msg)
sys->fprint(stderr, "bootpd: udp write error: %r\n");
}
diff --git a/appl/cmd/ip/tftpd.b b/appl/cmd/ip/tftpd.b
index c7edef4e..57d80cd5 100644
--- a/appl/cmd/ip/tftpd.b
+++ b/appl/cmd/ip/tftpd.b
@@ -8,6 +8,9 @@ include "draw.m";
include "arg.m";
+include "dial.m";
+ dial: Dial;
+
include "ip.m";
ip: IP;
IPaddr, Udphdr: import ip;
@@ -34,7 +37,7 @@ port := 69;
Udphdrsize: con IP->Udphdrlen;
-tftpcon: Sys->Connection;
+tftpcon: ref Sys->Connection;
tftpreq: ref Sys->FD;
dokill(pid: int, scope: string)
@@ -152,6 +155,10 @@ init(nil: ref Draw->Context, args: list of string)
sys->pctl(Sys->NEWPGRP|Sys->FORKFD|Sys->FORKNS, nil);
stderr = sys->fildes(2);
+ dial = load Dial Dial->PATH;
+ if(dial == nil)
+ fatal("can't load Dial");
+
arg := load Arg Arg->PATH;
if(arg == nil)
fatal("can't load Arg");
@@ -206,8 +213,8 @@ mainthing()
raddr := sys->sprint("%s/udp!%s!%d", net, hdr.raddr.text(), hdr.rport);
DBG(sys->sprint("raddr=%s", raddr));
- (err, cx) := sys->dial(raddr, nil);
- if(err < 0)
+ cx := dial->dial(raddr, nil);
+ if(cx == nil)
fatal("dialing "+raddr);
# showbuf("bigbuf", bigbuf[0:dlen]);
@@ -492,9 +499,8 @@ fatal(msg: string)
openlisten()
{
name := net+"/udp!*!" + string port;
- err := 0;
- (err, tftpcon) = sys->announce(name);
- if(err < 0)
+ tftpcon = dial->announce(name);
+ if(tftpcon == nil)
fatal("can't announce "+name);
if(sys->fprint(tftpcon.cfd, "headers") < 0)
fatal("can't set header mode");