137 lines
3.2 KiB
Text
137 lines
3.2 KiB
Text
$NetBSD: patch-ad,v 1.6 2006/06/22 15:00:51 joerg Exp $
|
|
|
|
--- nettestd.c.orig 1992-11-05 21:52:58.000000000 +0000
|
|
+++ nettestd.c
|
|
@@ -42,6 +42,7 @@ char copyright[] =
|
|
|
|
#include <errno.h>
|
|
#include <signal.h>
|
|
+#include <stdlib.h>
|
|
#ifdef WAIT3CODE
|
|
#include <sys/wait.h>
|
|
#endif
|
|
@@ -79,7 +80,7 @@ int ipoptions = 0;
|
|
int mesghdr = 0;
|
|
#define debug(x) if(dflag>1)fprintf x
|
|
int verbose;
|
|
-int daemon = 0; /* are we running in daemon mode? */
|
|
+int is_daemon = 0; /* are we running in daemon mode? */
|
|
|
|
#ifdef TCP_WINSHIFT
|
|
int winshift;
|
|
@@ -107,7 +108,12 @@ union {
|
|
} name;
|
|
int namesize;
|
|
|
|
-int read(), recv();
|
|
+int read();
|
|
+#if defined(sgi) && _NO_XOPEN4 && _NO_XOPEN5
|
|
+int recv();
|
|
+#else
|
|
+ssize_t recv();
|
|
+#endif
|
|
int (*rfunc)() = read;
|
|
|
|
main(argc, argv)
|
|
@@ -139,7 +145,7 @@ char **argv;
|
|
"-v flag ignored when -b flag is used\n");
|
|
verbose = 0;
|
|
}
|
|
- daemon++;
|
|
+ is_daemon++;
|
|
break;
|
|
case 'd': /* turn on socket level debugging */
|
|
++dflag;
|
|
@@ -204,7 +210,7 @@ char **argv;
|
|
#endif
|
|
|
|
case 'v': /* print out errors in sequenced data */
|
|
- if (daemon) {
|
|
+ if (is_daemon) {
|
|
fprintf(stderr,
|
|
"-v flag ignored when -b flag is used\n");
|
|
verbose = 0;
|
|
@@ -270,8 +276,12 @@ char **argv;
|
|
# endif
|
|
# endif
|
|
#endif
|
|
- if (daemon) {
|
|
+ if (is_daemon) {
|
|
+#ifdef NONVOID_SETPGRP
|
|
+ if (setpgrp(0, getpid()) < 0)
|
|
+#else
|
|
if (setpgrp() < 0)
|
|
+#endif
|
|
perror("setpgrp");
|
|
if ((c = open(_PATH_TTY, O_RDWR)) >= 0) {
|
|
(void)ioctl(c, TIOCNOTTY, (char *)0);
|
|
@@ -416,7 +426,7 @@ char **argv;
|
|
)
|
|
error("setsockopt (IP_OPTIONS)");
|
|
#endif
|
|
- if (bind(s, (char *)&name, namesize) < 0) {
|
|
+ if (bind(s, (struct sockaddr *)&name, namesize) < 0) {
|
|
error("bind");
|
|
exit(1);
|
|
}
|
|
@@ -447,12 +457,11 @@ register int s;
|
|
#endif
|
|
listen(s, 5);
|
|
|
|
- signal(SIGCHLD, dochild);
|
|
+ signal(SIGCHLD, (void *)dochild);
|
|
for (;;) {
|
|
namesize = sizeof(name);
|
|
- s2 = accept(s, (char *)&name, &namesize);
|
|
+ s2 = accept(s, (struct sockaddr *)&name, &namesize);
|
|
if (s2 < 0) {
|
|
- extern int errno;
|
|
if (errno == EINTR)
|
|
continue;
|
|
error("accept");
|
|
@@ -516,7 +525,7 @@ register in, out;
|
|
{
|
|
register int i, t, offset = 0;
|
|
register char *cp, *data;
|
|
- char buf[128], *malloc();
|
|
+ char buf[128];
|
|
int chunks = 0, chunksize = 0, fullbuf = 0, kbufsize = 0;
|
|
int tos = 0, nodelay = 0, seqdata = 0, waitall = 0;
|
|
register unsigned long hival, loval;
|
|
@@ -684,7 +693,7 @@ int s;
|
|
register int t, t2;
|
|
register char *cp, *data;
|
|
register struct hostent *hp;
|
|
- char *inet_ntoa(), *malloc();
|
|
+ char *inet_ntoa();
|
|
register char *errmsg;
|
|
#ifdef CMSG_DATA
|
|
struct msghdr inmsg;
|
|
@@ -707,7 +716,9 @@ int s;
|
|
inmsg.msg_iovlen = 1;
|
|
inmsg.msg_name = (caddr_t)&name.d_inet;
|
|
inmsg.msg_control = (caddr_t)control;
|
|
+#ifndef sgi
|
|
inmsg.msg_flags = 0;
|
|
+#endif
|
|
errmsg = "recvmsg";
|
|
} else
|
|
#endif /* CMSG_DATA */
|
|
@@ -723,7 +734,7 @@ int s;
|
|
#endif
|
|
{
|
|
namesize = sizeof(name.d_inet);
|
|
- t = recvfrom(s, data, MAXSIZE, 0, (char *)&name.d_inet,
|
|
+ t = recvfrom(s, data, MAXSIZE, 0, (struct sockaddr *)&name.d_inet,
|
|
&namesize);
|
|
}
|
|
if (t < 0) {
|
|
@@ -758,7 +769,7 @@ usage()
|
|
error(string)
|
|
char *string;
|
|
{
|
|
- if (daemon)
|
|
+ if (is_daemon)
|
|
syslog(LOG_ERR, "nettestd: %s %m", string);
|
|
else
|
|
perror(string);
|