* [9fans] Small patch to tftpd; command line announce strings.
@ 2003-01-22 22:55 Dan Cross
2003-01-23 1:22 ` geoff
0 siblings, 1 reply; 2+ messages in thread
From: Dan Cross @ 2003-01-22 22:55 UTC (permalink / raw)
To: 9fans
My new setup (which is still not on the Internet just yet, and probably
won't be for a few weeks at this point) is a little...weird. I have
two interfaces bound to a single IP stack, one exposed to the net, one
not. For a variety of reasons, this is more convenient than using
multiple stacks (in particular, I want to run services on both
interfaces, and listen doesn't seem to have a ``-x'' option, I don't
want to start everything twice, and I want to try and play some routing
tricks later where the internal interface will also answer requests
[from internal clients] for the external interface). I'm running a
DHCP and tftpd server for internal clients, but I don't want any fool
with a tftp client to start downloading kernels from me. DHCP I don't
care about since ip/dhcpd only answers for clients it knows about by
default, and the immediate subnet is pretty trustworthy. The upshot
of all this is that I modified tftpd to add a ``-A'' option which takes
an announce string, so one can specify an interface to announce on.
E.g., ``ip/tftpd -A 'udp!192.168.1.4!69' '' sort of thing. A diff in
diff -e format is below. Are there any objections for adding this to
the distribution?
- Dan C.
term% diff -e /n/sources/plan9/sys/src/cmd/ip/tftpd.c tftpd.c
102c
sprint(buf, "%s/%s", net, a);
.
60a
case 'A':
a = ARGF();
break;
.
58a
a = "udp!*!69";
.
57c
char *p, *a;
.
term%
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [9fans] Small patch to tftpd; command line announce strings.
2003-01-22 22:55 [9fans] Small patch to tftpd; command line announce strings Dan Cross
@ 2003-01-23 1:22 ` geoff
0 siblings, 0 replies; 2+ messages in thread
From: geoff @ 2003-01-23 1:22 UTC (permalink / raw)
To: 9fans
Listen doesn't need a -x; its last argument is the network directory
to use:
aux/listen -t /bin/service.auth -d /bin/service.alt /net.alt/tcp
Initialising additional interfaces isn't conveniently packaged up, so
I wrote `ifup', which does the job. I use it like this in cpurc:
# network services
aux/listen -q -t /bin/service.auth -d /bin/service tcp
ip/tftpd
ip/dhcpd
# alternate interfaces & their services
switch ($sysname) {
case cpu
ifup alt 1 $sysname external service.alt
ifup gig 2 $sysname-gig local service
timesync /net.alt/udp!^((ntp1 ntp2)^.mainecoon.com openbsd)
case cpub
ifup alt 1 $sysname external service.alt
case cpuc
ifup gig 1 $sysname-gig local service
}
The first interface (/net) is handled specially; it often is already
configured when cpurc starts.
This is ifup:
---
#!/bin/rc
# ifup mtsfx etherno sysnm ndbfile svcdir - configure /net.$mtsfx
# TODO: share a protocol stack between ether0 and gig ether
# and just add a route to the other gig host
if (! ~ $#* 5) {
echo usage: $0 mtsfx etherno sysnm ndbfile svcdir
exit usage
}
rfork e
mtsfx=$1 etherno=$2 sysnm=$3 ndbfile=$4 svcdir=$5
mtpt=/net.^$mtsfx
ndbf=/lib/ndb/^$ndbfile
# merge protocol stack and ethernet interface at mount point
bind -b '#l'^$etherno $mtpt
bind -b '#I'^$etherno $mtpt
# figure out ip, ipgw & ipmask
ipgw=dummy # in case ndb doesn't list one
for (attr in ip ipgw ipmask)
eval `{ndb/ipquery -f $ndbf sys $sysnm $attr | tr ' ' '\12' | sed 1q}
# configure interface and set up out-calling machinery
# first arg can be "ether" or "gbe" iff it can handle jumbo packets
ip/ipconfig -x .$mtsfx -g $ipgw ether $mtpt/ether$etherno $ip $ipmask
ndb/cs -x $mtpt -f $ndbf
if (! ~ $mtsfx gig)
ndb/dns -sx $mtpt -f $ndbf
# start up listeners
aux/listen -t /bin/service.auth -d /bin/^$svcdir $mtpt^/tcp
if (! ~ $mtsfx gig) {
ip/dhcpd -x $mtpt -f $ndbf # for the printer
ip/rip -x $mtpt
}
if (~ $mtsfx alt)
auth/secstored -x $mtpt
---
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2003-01-23 1:22 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-01-22 22:55 [9fans] Small patch to tftpd; command line announce strings Dan Cross
2003-01-23 1:22 ` geoff
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).