mirror of
git://git.9front.org/plan9front/plan9front
synced 2025-01-12 11:10:06 +00:00
ip/*: sprint() -> snprint() in a bunch of old copy-pasted network announce routines.
This commit is contained in:
parent
c7fd84937c
commit
1e7d5833ab
8 changed files with 23 additions and 19 deletions
|
@ -24,7 +24,7 @@ getremote(char *dir)
|
|||
char remfile[256];
|
||||
static char buf[256];
|
||||
|
||||
sprint(remfile, "%s/remote", dir);
|
||||
snprint(remfile, sizeof(remfile), "%s/remote", dir);
|
||||
fd = open(remfile, OREAD);
|
||||
if(fd < 0)
|
||||
return nil;
|
||||
|
|
|
@ -120,7 +120,7 @@ openlisten(char *net)
|
|||
Ipifc *ifc;
|
||||
Iplifc *lifc;
|
||||
|
||||
sprint(data, "%s/udp!*!dhcp6s", net);
|
||||
snprint(data, sizeof(data), "%s/udp!*!dhcp6s", net);
|
||||
cfd = announce(data, devdir);
|
||||
if(cfd < 0)
|
||||
sysfatal("can't announce: %r");
|
||||
|
@ -139,7 +139,7 @@ openlisten(char *net)
|
|||
}
|
||||
}
|
||||
|
||||
sprint(data, "%s/data", devdir);
|
||||
snprint(data, sizeof(data), "%s/data", devdir);
|
||||
fd = open(data, ORDWR);
|
||||
if(fd < 0)
|
||||
sysfatal("open udp data: %r");
|
||||
|
|
|
@ -1326,14 +1326,14 @@ openlisten(char *net)
|
|||
int fd, cfd;
|
||||
char data[128], devdir[40];
|
||||
|
||||
sprint(data, "%s/udp!*!bootp", net);
|
||||
snprint(data, sizeof(data), "%s/udp!*!bootp", net);
|
||||
cfd = announce(data, devdir);
|
||||
if(cfd < 0)
|
||||
fatal("can't announce: %r");
|
||||
if(fprint(cfd, "headers") < 0)
|
||||
fatal("can't set header mode: %r");
|
||||
fprint(cfd, "ignoreadvice");
|
||||
sprint(data, "%s/data", devdir);
|
||||
snprint(data, sizeof(data), "%s/data", devdir);
|
||||
fd = open(data, ORDWR);
|
||||
if(fd < 0)
|
||||
fatal("open udp data: %r");
|
||||
|
|
|
@ -1187,13 +1187,13 @@ port(void)
|
|||
int port;
|
||||
|
||||
/* get a channel to listen on, let kernel pick the port number */
|
||||
sprint(buf, "%s!*!0", net);
|
||||
snprint(buf, sizeof(buf), "%s!*!0", net);
|
||||
listenfd = announce(buf, netdir);
|
||||
if(listenfd < 0)
|
||||
return seterr("can't announce");
|
||||
|
||||
/* get the local address and port number */
|
||||
sprint(buf, "%s/local", netdir);
|
||||
snprint(buf, sizeof(buf), "%s/local", netdir);
|
||||
fd = open(buf, OREAD);
|
||||
if(fd < 0)
|
||||
return seterr("opening %s: %r", buf);
|
||||
|
@ -1205,8 +1205,10 @@ port(void)
|
|||
ptr = strchr(buf, ' ');
|
||||
if(ptr)
|
||||
*ptr = 0;
|
||||
ptr = strchr(buf, '!')+1;
|
||||
port = atoi(ptr);
|
||||
ptr = strchr(buf, '!');
|
||||
if(ptr == 0)
|
||||
return seterr("no port in address: %s", buf);
|
||||
port = atoi(ptr+1);
|
||||
|
||||
memset(ipaddr, 0, IPaddrlen);
|
||||
if (*net){
|
||||
|
@ -1218,8 +1220,10 @@ port(void)
|
|||
}
|
||||
|
||||
/* tell remote side */
|
||||
sprint(buf, "PORT %d,%d,%d,%d,%d,%d", ipaddr[IPv4off+0], ipaddr[IPv4off+1],
|
||||
ipaddr[IPv4off+2], ipaddr[IPv4off+3], port>>8, port&0xff);
|
||||
snprint(buf, sizeof(buf), "PORT %d,%d,%d,%d,%d,%d",
|
||||
ipaddr[IPv4off+0], ipaddr[IPv4off+1],
|
||||
ipaddr[IPv4off+2], ipaddr[IPv4off+3],
|
||||
port>>8, port&0xff);
|
||||
sendrequest(buf, nil);
|
||||
if(getreply(&ctlin, msg, sizeof(msg), 0) != Success)
|
||||
return seterr(msg);
|
||||
|
@ -1254,7 +1258,7 @@ active(int mode, Biobuf **bpp, char *cmda, char *cmdb)
|
|||
close(listenfd);
|
||||
|
||||
/* open it's data connection and close the control connection */
|
||||
sprint(datafile, "%s/data", newdir);
|
||||
snprint(datafile, sizeof(datafile), "%s/data", newdir);
|
||||
dfd = open(datafile, ORDWR);
|
||||
close(cfd);
|
||||
if(dfd < 0)
|
||||
|
|
|
@ -55,8 +55,8 @@ main(int argc, char *argv[])
|
|||
uchar buf[2048];
|
||||
long n;
|
||||
Rarp *rp;
|
||||
char ebuf[16];
|
||||
char ipbuf[64];
|
||||
char ebuf[128];
|
||||
char file[128];
|
||||
int arp;
|
||||
char *p, *ndbfile;
|
||||
|
@ -102,7 +102,7 @@ main(int argc, char *argv[])
|
|||
|
||||
if(myipaddr(myip, net) < 0)
|
||||
error("can't get my ip address");
|
||||
sprint(ebuf, "%s/%s", net, device);
|
||||
snprint(ebuf, sizeof(ebuf), "%s/%s", net, device);
|
||||
if(myetheraddr(myether, ebuf) < 0)
|
||||
error("can't get my ether address");
|
||||
|
||||
|
@ -138,7 +138,7 @@ main(int argc, char *argv[])
|
|||
syslog(debug, rlog, "rcv se %E si %V te %E ti %V",
|
||||
rp->sha, rp->spa, rp->tha, rp->tpa);
|
||||
|
||||
sprint(ebuf, "%E", rp->tha);
|
||||
snprint(ebuf, sizeof(ebuf), "%E", rp->tha);
|
||||
if(lookup("ether", ebuf, "ip", ipbuf, sizeof ipbuf) == nil){
|
||||
syslog(debug, rlog, "client lookup failed: %s", ebuf);
|
||||
continue;
|
||||
|
|
|
@ -333,7 +333,7 @@ openport(void)
|
|||
if(fprint(ripctl, "headers") < 0)
|
||||
fatal(1, "can't set header mode");
|
||||
|
||||
sprint(data, "%s/data", devdir);
|
||||
snprint(data, sizeof(data), "%s/data", devdir);
|
||||
rip = open(data, ORDWR);
|
||||
if(rip < 0)
|
||||
fatal(1, "open udp data");
|
||||
|
|
|
@ -60,7 +60,7 @@ csquery(DS *ds, char *clone, char *dest)
|
|||
/*
|
||||
* ask connection server to translate
|
||||
*/
|
||||
sprint(buf, "%s!%s", ds->proto, ds->rem);
|
||||
snprint(buf, sizeof(buf), "%s!%s", ds->proto, ds->rem);
|
||||
if(write(fd, buf, strlen(buf)) < 0){
|
||||
close(fd);
|
||||
return -1;
|
||||
|
|
|
@ -23,14 +23,14 @@ main(int argc, char **argv)
|
|||
break;
|
||||
}ARGEND;
|
||||
|
||||
sprint(data, "%s/udp!*!echo", net);
|
||||
snprint(data, sizeof(data), "%s/udp!*!echo", net);
|
||||
cfd = announce(data, devdir);
|
||||
if(cfd < 0)
|
||||
sysfatal("can't announce %s: %r", data);
|
||||
if(fprint(cfd, "headers") < 0)
|
||||
sysfatal("can't set header mode: %r");
|
||||
|
||||
sprint(data, "%s/data", devdir);
|
||||
snprint(data, sizeof(data), "%s/data", devdir);
|
||||
fd = open(data, ORDWR);
|
||||
if(fd < 0)
|
||||
sysfatal("open %s: %r", data);
|
||||
|
|
Loading…
Reference in a new issue