BSD 4_3_Net_2 release
[unix-history] / usr / src / usr.sbin / named / ns_main.c
index 8539e5f..82d91e6 100644 (file)
@@ -2,19 +2,33 @@
  * Copyright (c) 1986, 1989, 1990 Regents of the University of California.
  * All rights reserved.
  *
  * Copyright (c) 1986, 1989, 1990 Regents of the University of California.
  * All rights reserved.
  *
- * Redistribution and use in source and binary forms are permitted provided
- * that: (1) source distributions retain this entire copyright notice and
- * comment, and (2) distributions including binaries display the following
- * acknowledgement:  ``This product includes software developed by the
- * University of California, Berkeley and its contributors'' in the
- * documentation or other materials provided with the distribution and in
- * all advertising materials mentioning features or use of this software.
- * Neither the name of the University nor the names of its contributors may
- * be used to endorse or promote products derived from this software without
- * specific prior written permission.
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *     This product includes software developed by the University of
+ *     California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
  */
 
 #ifndef lint
  */
 
 #ifndef lint
@@ -24,7 +38,7 @@ char copyright[] =
 #endif /* not lint */
 
 #ifndef lint
 #endif /* not lint */
 
 #ifndef lint
-static char sccsid[] = "@(#)ns_main.c  4.50 (Berkeley) 6/29/90";
+static char sccsid[] = "@(#)ns_main.c  4.55 (Berkeley) 7/1/91";
 #endif /* not lint */
 
 /*
 #endif /* not lint */
 
 /*
@@ -174,10 +188,10 @@ main(argc, argv, envp)
 
        struct timeval t, *tp;
        struct qstream *candidate = QSTREAM_NULL;
 
        struct timeval t, *tp;
        struct qstream *candidate = QSTREAM_NULL;
-       extern VOID onintr(), maint_alarm(), endxfer();
-       extern VOID setdumpflg(), onhup();
-       extern VOID setIncrDbgFlg(), setNoDbgFlg(), sigprof();
-       extern VOID setchkptflg(), setstatsflg();
+       extern SIG_FN onintr(), maint_alarm(), endxfer();
+       extern SIG_FN setdumpflg(), onhup();
+       extern SIG_FN setIncrDbgFlg(), setNoDbgFlg(), sigprof();
+       extern SIG_FN setchkptflg(), setstatsflg();
        extern int loadxfer();
        extern struct qstream *sqadd();
        extern struct qinfo *qhead; 
        extern int loadxfer();
        extern struct qstream *sqadd();
        extern struct qinfo *qhead; 
@@ -567,7 +581,7 @@ main(argc, argv, envp)
                                syslog(LOG_WARNING, "accept: %m");
                                continue;
                        }
                                syslog(LOG_WARNING, "accept: %m");
                                continue;
                        }
-                       (void) fcntl(rfd, F_SETFL, FNDELAY);
+                       (void) fcntl(rfd, F_SETFL, O_NONBLOCK);
                        (void) setsockopt(rfd, SOL_SOCKET, SO_KEEPALIVE,
                                (char *)&on, sizeof(on));
                        if ((sp = sqadd()) == QSTREAM_NULL) {
                        (void) setsockopt(rfd, SOL_SOCKET, SO_KEEPALIVE,
                                (char *)&on, sizeof(on));
                        if ((sp = sqadd()) == QSTREAM_NULL) {
@@ -742,7 +756,8 @@ getnetconf()
                        cp += sizeof (ifr->ifr_name) + size(ifr->ifr_addr)) {
 #undef size
                ifr = (struct ifreq *)cp;
                        cp += sizeof (ifr->ifr_name) + size(ifr->ifr_addr)) {
 #undef size
                ifr = (struct ifreq *)cp;
-               if (ifr->ifr_addr.sa_family != AF_INET)
+               if (ifr->ifr_addr.sa_family != AF_INET ||
+                  ((struct sockaddr_in *)&ifr->ifr_addr)->sin_addr.s_addr == 0)
                        continue;
                ifreq = *ifr;
                /*
                        continue;
                ifreq = *ifr;
                /*
@@ -957,7 +972,7 @@ opensocket(dqp)
        (void)setsockopt(dqp->dq_dfd, SOL_SOCKET, SO_RCVBUF,
            (char *)&rbufsize, sizeof(rbufsize));
 #endif SO_RCVBUF
        (void)setsockopt(dqp->dq_dfd, SOL_SOCKET, SO_RCVBUF,
            (char *)&rbufsize, sizeof(rbufsize));
 #endif SO_RCVBUF
-       (void) fcntl(dqp->dq_dfd, F_SETFL, FNDELAY);
+       (void) fcntl(dqp->dq_dfd, F_SETFL, O_NONBLOCK);
        /*
         *   NOTE: Some versions of SunOS have problems with the following
         *   call to bind.  Bind still seems to function on these systems
        /*
         *   NOTE: Some versions of SunOS have problems with the following
         *   call to bind.  Bind still seems to function on these systems
@@ -981,7 +996,7 @@ opensocket(dqp)
 ** structure at the time.
 */
 
 ** structure at the time.
 */
 
-VOID
+SIG_FN
 onhup()
 {
 #if defined(SYSV)
 onhup()
 {
 #if defined(SYSV)
@@ -996,7 +1011,7 @@ onhup()
 ** structure at the time.
 */
 
 ** structure at the time.
 */
 
-VOID
+SIG_FN
 maint_alarm()
 {
 #if defined(SYSV)
 maint_alarm()
 {
 #if defined(SYSV)
@@ -1011,7 +1026,7 @@ maint_alarm()
  * Signal handler to schedule shutdown.  Just set flag, to ensure a consistent
  * state during dump.
  */
  * Signal handler to schedule shutdown.  Just set flag, to ensure a consistent
  * state during dump.
  */
-VOID
+SIG_FN
 onintr()
 {
         needToExit = 1;
 onintr()
 {
         needToExit = 1;
@@ -1024,7 +1039,7 @@ onintr()
  * (due to updates), and to avoid long disk I/O delays at signal-handler
  * level
  */
  * (due to updates), and to avoid long disk I/O delays at signal-handler
  * level
  */
-VOID
+SIG_FN
 setdumpflg()
 {
 #if defined(SYSV)
 setdumpflg()
 {
 #if defined(SYSV)
@@ -1073,7 +1088,7 @@ int code;
 ** Handy for looking in on long running name servers.
 */
 
 ** Handy for looking in on long running name servers.
 */
 
-VOID
+SIG_FN
 setIncrDbgFlg()
 {
 #if defined(SYSV)
 setIncrDbgFlg()
 {
 #if defined(SYSV)
@@ -1095,7 +1110,7 @@ setIncrDbgFlg()
 ** Catch a special signal to turn off debugging
 */
 
 ** Catch a special signal to turn off debugging
 */
 
-VOID
+SIG_FN
 setNoDbgFlg()
 {
 #if defined(SYSV)
 setNoDbgFlg()
 {
 #if defined(SYSV)
@@ -1107,7 +1122,7 @@ setNoDbgFlg()
 /*
 ** Set flag for statistics dump
 */
 /*
 ** Set flag for statistics dump
 */
-VOID
+SIG_FN
 setstatsflg()
 {
 #if defined(SYSV)
 setstatsflg()
 {
 #if defined(SYSV)
@@ -1116,7 +1131,7 @@ setstatsflg()
        needStatsDump = 1;
 }
 
        needStatsDump = 1;
 }
 
-VOID
+SIG_FN
 setchkptflg()
 {
 #if defined(SYSV)
 setchkptflg()
 {
 #if defined(SYSV)
@@ -1132,7 +1147,7 @@ setchkptflg()
 **   and keep the server running
 */
 
 **   and keep the server running
 */
 
-VOID
+SIG_FN
 sigprof()
 {
 #if defined(SYSV)
 sigprof()
 {
 #if defined(SYSV)