Subject: deqnad
To: None <port-vax@NetBSD.ORG>
From: Paul A Vixie <paul@vix.com>
List: port-vax
Date: 04/22/1998 22:18:30
when i worked at digital, the deqna lockup problem was well known, and the
following trivial program was run out of every machine's /etc/rc.local using
something like

	deqnad -h `hostname`

i asked a friend who still works at digital and he had no objection to posting
it here.  it depends on sendto() actually touching the local network card if
sending packets to the local host's address.  if that's not true, then you'd
have to pick some real host elsewhere on the network.  cheesy but effective.

later versions of the deqna and later versions of the ultrix driver for the
deqna made this problem go away.  so the program below was only ever run on
ultrix 1.2 on microvax II GPX systems.

#! /bin/sh
# This is a shell archive.  Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file".  To overwrite existing
# files, type "sh file -c".  You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g..  If this archive is complete, you
# will see the following message at the end:
#		"End of shell archive."
# Contents:  deqnad.c
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'deqnad.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'deqnad.c'\"
else
echo shar: Extracting \"'deqnad.c'\" \(3544 characters\)
sed "s/^X//" >'deqnad.c' <<'END_OF_FILE'
X/*
X       Copyright 1988, 1998 Digital Equipment Corporation
X                        All Rights Reserved
X
XPermission to use, copy, and modify this software and its documentation is
Xhereby granted only under the following terms and conditions.  Both the
Xabove copyright notice and this permission notice must appear in all copies
Xof the software, derivative works or modified versions, and any portions
Xthereof, and both notices must appear in supporting documentation.
X
XUsers of this software agree to the terms and conditions set forth herein,
Xand hereby grant back to Digital a non-exclusive, unrestricted, royalty-
Xfree right and license under any changes, enhancements or extensions 
Xmade to the core functions of the software, including but not limited to 
Xthose affording compatibility with other hardware or software 
Xenvironments, but excluding applications which incorporate this software.
XUsers further agree to use their best efforts to return to Digital any
Xsuch changes, enhancements or extensions that they make and inform Digital
Xof noteworthy uses of this software.  Correspondence should be provided
Xto Digital at:
X
X                      Director of Licensing
X                      Western Research Laboratory
X                      Digital Equipment Corporation
X                      250 University Avenue
X                      Palo Alto, California  94301
X
XThis software may be distributed (but not offered for sale or transferred
Xfor compensation) to third parties, provided such third parties agree to
Xabide by the terms and conditions of this notice.
X
XTHE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
XWARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
XOF MERCHANTABILITY AND FITNESS.   IN NO EVENT SHALL DIGITAL EQUIPMENT
XCORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
XDAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
XPROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
XACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
XSOFTWARE.
X */
X
X#include <sys/types.h>
X#include <sys/ioctl.h>
X#include <sys/socket.h>
X#include <netinet/in.h>
X#include <stdio.h>
X#include <netdb.h>
X
Xint delay = 30;
X
Xchar *dest = "packet-sink";
X
Xmain(argc, argv)
X	int argc;
X	char *argv[];
X{
X	struct sockaddr_in sin;
X	struct hostent *hp;
X	struct servent *sp;
X	int s;
X
X	sp = getservbyname("discard", "udp");
X	if (sp == NULL) {
X		fprintf(stderr,"Bombed in getservbyname\n");
X		exit(1);
X	}
X
X	while (argc > 1 && *argv[1] == '-') {
X		switch (argv[1][1]) {
X			case 'h':
X				dest = argv[2];
X				break;
X			case 'd':
X				delay = atoi(argv[2]);
X				break;
X		}
X		argc -=2;
X		argv +=2;
X	}
X
X	bzero((char *)&sin, sizeof(sin));
X	sin.sin_port = sp->s_port;
X	sin.sin_addr.s_addr = inet_addr(dest);
X	if ( (sin.sin_addr.s_addr = inet_addr(dest)) != -1) {
X		sin.sin_family = AF_INET;
X	} else {
X		hp = gethostbyname(dest);
X		if (hp) {
X			sin.sin_family = hp->h_addrtype;
X			bcopy(hp->h_addr, (caddr_t)&sin.sin_addr,hp->h_length);
X		} else {
X			fprintf(stderr, "Host %s unknown\n", dest);
X			exit(1);
X		}
X	}
X	if (fork())
X		exit(0);
X	for (s=0; s<10; s++)
X		(void) close(s);
X	(void) open("/", 0);
X	(void) dup2(0, 1);
X	(void) dup2(0, 2);
X	s = open("/dev/tty", 2);
X	if (s >= 0) {
X		ioctl(s, TIOCNOTTY, 0);
X		(void) close(s);
X	}
X
X	s = socket(AF_INET, SOCK_DGRAM, 0);
X	if (s < 0) {
X		perror("socket");
X		exit(1);
X	}
X
X	while (1) {
X		if (sendto(s, "", 0, 0, &sin, sizeof(sin)) < 0) {
X			perror("sendto");
X			exit(1);
X		}
X		sleep(delay);
X	}
X
X}
END_OF_FILE
if test 3544 -ne `wc -c <'deqnad.c'`; then
    echo shar: \"'deqnad.c'\" unpacked with wrong size!
fi
# end of 'deqnad.c'
fi
echo shar: End of shell archive.
exit 0