Path: utzoo!attcan!uunet!lll-winken!csd4.milw.wisc.edu!mailrus!tut.cis.ohio-state.edu!bloom-beacon!bu-cs!budd From: budd@bu-cs.BU.EDU (Philip Budne) Newsgroups: comp.protocols.appletalk Subject: Re: UNIX programs for reloading KFPS4s Summary: code to get NIT interface name Message-ID: <29629@bu-cs.BU.EDU> Date: 14 Apr 89 22:06:46 GMT References: <8904101849.AA00680@laotse.santafe.edu> <1358@muddy.ldgo.columbia.edu> <38612@bbn.COM> <38662@bbn.COM> Reply-To: budd@buit2.bu.edu (Phil Budne) Followup-To: comp.protocols.appletalk Organization: Boston University Lines: 76 In article <38662@bbn.COM> tappan@BBN.COM (Dan Tappan) writes: >In article <38612@bbn.COM> tappan@BBN.COM (Dan Tappan) writes: >>This is the second report I've heard of a crash. I suspect a bug in >>early versions of the NIT driver. I gave you the first report. The kernel dies in sendto(). >..... >The reason for this is that the 'nitlib' has hardwired into it to use >the 'le0' ethernet interface. The 100/200 machines use a 'ie0' >interface and, if you access 'le0' on them, rather than returning an >error NIT crashes the machine with a bus error. > >The fix is: in nitlib.c change the line >char *nit_interface = "le0"; >to >char *nit_interface = "ie0"; Here's a fix to get the default interface name. Of course you still get stuck when you have both an ie0 and an ie1. Perhaps both aarpd and kboot need "-i" flags? *** nitlib.c.orig Sun Mar 12 02:02:56 1989 --- nitlib.c Fri Apr 14 17:57:31 1989 *************** *** 35,41 **** /* Global variables */ /* The name of the interface to NIT on */ ! char *nit_interface = "le0"; /* The packet types to receive */ int nit_type = NT_ALLTYPES; --- 35,41 ---- /* Global variables */ /* The name of the interface to NIT on */ ! char *nit_interface = NULL; /* budd - perhaps have -i iface? */ /* The packet types to receive */ int nit_type = NT_ALLTYPES; *************** *** 91,97 **** --- 91,100 ---- int fd; struct ifreq ifr; struct hostent *hp; + struct ifconf ifc; /* budd */ + char ifbuf[ 100 ]; /* budd */ + if (getuid() != 0) { fprintf(stderr, "must run as root\n"); exit(1); *************** *** 105,110 **** --- 108,127 ---- return(0); } + /* budd... */ + ifc.ifc_len = sizeof( ifbuf ); + ifc.ifc_buf = ifbuf; + + if( nit_interface == NULL ) { + /* get default interface name */ + if( ioctl(nit_socket, SIOCGIFCONF, (char *)&ifc) < 0 ) { + perror( "nit ifconf ioctl"); + return( 0 ); + } + nit_interface = ifc.ifc_req->ifr_name; + printf("Using interface %s\n", nit_interface ); + } + /* ...budd */ strncpy(nit_sockaddr.snit_ifname, nit_interface, sizeof(nit_sockaddr.snit_ifname)); if (bind(nit_socket,