Make a few debug outputs only happen when debugging.

This commit is contained in:
martin 2007-10-01 13:15:06 +00:00
parent c51526f373
commit db90818494
2 changed files with 48 additions and 28 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: bootp.c,v 1.29 2006/05/20 19:40:46 mrg Exp $ */
/* $NetBSD: bootp.c,v 1.30 2007/10/01 13:15:06 martin Exp $ */
/*
* Copyright (c) 1992 Regents of the University of California.
@ -250,16 +250,20 @@ bootp(sock)
gateip.s_addr = 0;
}
printf("net_open: client addr: %s\n", inet_ntoa(myip));
#ifdef BOOTP_DEBUG
if (debug) {
printf("client addr: %s\n", inet_ntoa(myip));
if (smask)
printf("net_open: subnet mask: %s\n", intoa(smask));
printf("subnet mask: %s\n", intoa(smask));
if (gateip.s_addr != 0)
printf("net_open: net gateway: %s\n", inet_ntoa(gateip));
printf("net_open: server addr: %s\n", inet_ntoa(rootip));
printf("net gateway: %s\n", inet_ntoa(gateip));
printf("server addr: %s\n", inet_ntoa(rootip));
if (rootpath[0] != '\0')
printf("net_open: server path: %s\n", rootpath);
printf("server path: %s\n", rootpath);
if (bootfile[0] != '\0')
printf("net_open: file name: %s\n", bootfile);
printf("file name: %s\n", bootfile);
}
#endif
/* Bump xid so next request will be unique. */
++d->xid;

View File

@ -1,4 +1,4 @@
/* $NetBSD: dev_net.c,v 1.19 2002/03/17 05:46:37 gmcgarry Exp $ */
/* $NetBSD: dev_net.c,v 1.20 2007/10/01 13:15:06 martin Exp $ */
/*-
* Copyright (c) 1997 The NetBSD Foundation, Inc.
@ -95,7 +95,7 @@ net_open(struct open_file *f, ...)
#ifdef NETIF_DEBUG
if (debug)
printf("net_open: %s\n", devname);
printf("%s\n", devname);
#endif
/* On first open, do netif open, mount, etc. */
@ -104,12 +104,12 @@ net_open(struct open_file *f, ...)
if (netdev_sock < 0) {
netdev_sock = netif_open(devname);
if (netdev_sock < 0) {
printf("net_open: netif_open() failed\n");
printf("netif_open() failed\n");
return (ENXIO);
}
#ifdef NETIF_DEBUG
if (debug)
printf("net_open: netif_open() succeeded\n");
printf("netif_open() succeeded\n");
#endif
}
if (rootip.s_addr == 0) {
@ -122,7 +122,7 @@ net_open(struct open_file *f, ...)
/* Get the NFS file handle (mountd). */
error = nfs_mount(netdev_sock, rootip, rootpath);
if (error) {
printf("net_open: NFS mount error=%d\n", error);
printf("NFS mount error=%d\n", error);
rootip.s_addr = 0;
fail:
netif_close(netdev_sock);
@ -131,7 +131,7 @@ net_open(struct open_file *f, ...)
}
#ifdef NETIF_DEBUG
if (debug)
printf("net_open: NFS mount succeeded\n");
printf("NFS mount succeeded\n");
#endif
}
}
@ -229,7 +229,7 @@ net_getparams(sock)
return (0);
#ifdef NETIF_DEBUG
if (debug)
printf("net_open: BOOTP failed, trying RARP/RPC...\n");
printf("BOOTP failed, trying RARP/RPC...\n");
#endif
#endif
@ -238,17 +238,23 @@ net_getparams(sock)
* netmask to the "natural" default for our address.
*/
if (rarp_getipaddress(sock)) {
printf("net_open: RARP failed\n");
printf("RARP failed\n");
return (EIO);
}
printf("net_open: client addr: %s\n", inet_ntoa(myip));
#ifdef NETIF_DEBUG
if (debug)
printf("client addr: %s\n", inet_ntoa(myip));
#endif
/* Get our hostname, server IP address, gateway. */
if (bp_whoami(sock)) {
printf("net_open: bootparam/whoami RPC failed\n");
printf("bootparam/whoami RPC failed\n");
return (EIO);
}
printf("net_open: client name: %s\n", hostname);
#ifdef NETIF_DEBUG
if (debug)
printf("client name: %s\n", hostname);
#endif
/*
* Ignore the gateway from whoami (unreliable).
@ -264,19 +270,29 @@ net_getparams(sock)
}
if (smask) {
netmask = smask;
printf("net_open: subnet mask: %s\n", intoa(netmask));
#ifdef NETIF_DEBUG
if (debug)
printf("subnet mask: %s\n", intoa(netmask));
#endif
}
#ifdef NETIF_DEBUG
if (debug)
if (gateip.s_addr)
printf("net_open: net gateway: %s\n", inet_ntoa(gateip));
printf("net gateway: %s\n", inet_ntoa(gateip));
#endif
/* Get the root server and pathname. */
if (bp_getfile(sock, "root", &rootip, rootpath)) {
printf("net_open: bootparam/getfile RPC failed\n");
printf("bootparam/getfile RPC failed\n");
return (EIO);
}
printf("net_open: server addr: %s\n", inet_ntoa(rootip));
printf("net_open: server path: %s\n", rootpath);
#ifdef NETIF_DEBUG
if (debug) {
printf("server addr: %s\n", inet_ntoa(rootip));
printf("server path: %s\n", rootpath);
}
#endif
return (0);
}