version 1.11, 2000/09/26 01:15:49 |
version 1.12, 2000/09/26 02:51:22 |
|
|
x = 1; |
x = 1; |
rr = setsockopt(nnetfd, SOL_SOCKET, SO_REUSEADDR, &x, sizeof(x)); |
rr = setsockopt(nnetfd, SOL_SOCKET, SO_REUSEADDR, &x, sizeof(x)); |
if (rr == -1) |
if (rr == -1) |
warn("nnetfd reuseaddr failed"); /* ??? */ |
errx(1, NULL); |
|
|
/* fill in all the right sockaddr crud */ |
/* fill in all the right sockaddr crud */ |
lclend->sin_family = AF_INET; |
lclend->sin_family = AF_INET; |
|
|
strcat(bigbuf_net, "any"); |
strcat(bigbuf_net, "any"); |
strcat(bigbuf_net, "] %d ..."); |
strcat(bigbuf_net, "] %d ..."); |
z = ntohs(lclend->sin_port); |
z = ntohs(lclend->sin_port); |
warn(bigbuf_net, z); |
warn("%s %d", bigbuf_net, z); |
} /* verbose -- whew!! */ |
} /* verbose -- whew!! */ |
/* |
/* |
* UDP is a speeeeecial case -- we have to do I/O *and* get the |
* UDP is a speeeeecial case -- we have to do I/O *and* get the |
|
|
cp = &bigbuf_net[32]; |
cp = &bigbuf_net[32]; |
x = sizeof(struct sockaddr); |
x = sizeof(struct sockaddr); |
rr = getsockname(nnetfd, (struct sockaddr *) lclend, &x); |
rr = getsockname(nnetfd, (struct sockaddr *) lclend, &x); |
if (rr < 0) |
if (rr < 0 && o_verbose) |
warn("post-rcv getsockname failed"); |
warn("post-rcv getsockname failed"); |
strcpy(cp, inet_ntoa(lclend->sin_addr)); |
strcpy(cp, inet_ntoa(lclend->sin_addr)); |
|
|
|
|
errx(1, "invalid connection to [%s] from %s [%s] %d", |
errx(1, "invalid connection to [%s] from %s [%s] %d", |
cp, whozis->name, whozis->addrs[0], z); |
cp, whozis->name, whozis->addrs[0], z); |
} |
} |
warn("connect to [%s] from %s [%s] %d", |
if (o_verbose) { |
cp, whozis->name, whozis->addrs[0], z); |
warn("connect to [%s] from %s [%s] %d", |
|
cp, whozis->name, whozis->addrs[0], z); |
|
} |
return (nnetfd); |
return (nnetfd); |
|
|
dol_tmo: |
dol_tmo: |
|
|
int rr; |
int rr; |
|
|
rr = write(fd, bigbuf_in, 1); |
rr = write(fd, bigbuf_in, 1); |
if (rr != 1) |
if (rr != 1 && o_verbose) |
warn("udptest first write failed?! errno %d", errno); |
warn("udptest first write failed?! errno %d", errno); |
if (o_wait) |
if (o_wait) |
sleep(o_wait); |
sleep(o_wait); |
|
|
netretry--; /* we actually try a coupla |
netretry--; /* we actually try a coupla |
* times. */ |
* times. */ |
if (!netretry) { |
if (!netretry) { |
if (o_verbose > 1) /* normally we don't |
if (o_verbose) /* normally we don't |
* care */ |
* care */ |
warn("net timeout"); |
warn("net timeout"); |
close(fd); |
close(fd); |
|
|
shovel: |
shovel: |
/* sanity check. Works because they're both unsigned... */ |
/* sanity check. Works because they're both unsigned... */ |
if ((rzleft > 8200) || (rnleft > 8200)) { |
if ((rzleft > 8200) || (rnleft > 8200)) { |
warn("Bogus buffers: %d, %d", rzleft, rnleft); |
|
rzleft = rnleft = 0; |
rzleft = rnleft = 0; |
} |
} |
/* net write retries sometimes happen on UDP connections */ |
/* net write retries sometimes happen on UDP connections */ |
|
|
netfd = dolisten(themaddr, curport, ouraddr, o_lport); |
netfd = dolisten(themaddr, curport, ouraddr, o_lport); |
if (netfd > 0) { |
if (netfd > 0) { |
x = readwrite(netfd); |
x = readwrite(netfd); |
if (o_verbose > 1) |
if (o_verbose) |
warn("Sent %i Rcvd %i", wrote_net, wrote_out); |
warn("Sent %i Rcvd %i", wrote_net, wrote_out); |
exit(x); |
exit(x); |
} else |
} else |