Add FBSDID. udp/bootps -> bootps/udp. Use err(3).

This commit is contained in:
Philippe Charnier 2003-02-05 13:45:25 +00:00
parent efe2778852
commit 538015aa3b
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=110395
4 changed files with 41 additions and 46 deletions

View File

@ -19,8 +19,6 @@ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
SOFTWARE.
$FreeBSD$
************************************************************************/
/*
@ -39,7 +37,8 @@ SOFTWARE.
* See ./ToDo
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#include <sys/types.h>
#include <sys/param.h>
@ -443,7 +442,7 @@ main(argc, argv)
} else {
bootps_port = (u_short) IPPORT_BOOTPS;
report(LOG_ERR,
"udp/bootps: unknown service -- assuming port %d",
"bootps/udp: unknown service -- using port %d",
bootps_port);
}
@ -469,7 +468,7 @@ main(argc, argv)
bootpc_port = ntohs(servp->s_port);
} else {
report(LOG_ERR,
"udp/bootpc: unknown service -- assuming port %d",
"bootpc/udp: unknown service -- using port %d",
IPPORT_BOOTPC);
bootpc_port = (u_short) IPPORT_BOOTPC;
}

View File

@ -25,13 +25,14 @@ ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
SOFTWARE.
************************************************************************/
/* $FreeBSD$ */
/*
* BOOTPGW is typically used to forward BOOTP client requests from
* one subnet to a BOOTP server on a different subnet.
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#include <sys/types.h>
#include <sys/param.h>
#include <sys/socket.h>
@ -49,6 +50,7 @@ SOFTWARE.
#include <unistd.h>
#endif
#include <err.h>
#include <stdlib.h>
#include <signal.h>
#include <stdio.h>
@ -217,10 +219,8 @@ main(argc, argv)
stmp = NULL;
timeout = &actualtimeout;
if (uname(&my_uname) < 0) {
fprintf(stderr, "bootpgw: can't get hostname\n");
exit(1);
}
if (uname(&my_uname) < 0)
errx(1, "can't get hostname");
hostname = my_uname.nodename;
hep = gethostbyname(hostname);
@ -254,8 +254,7 @@ main(argc, argv)
stmp = argv[0];
}
if (!stmp || (sscanf(stmp, "%d", &n) != 1) || (n < 0)) {
fprintf(stderr,
"%s: invalid debug level\n", progname);
warnx("invalid debug level");
break;
}
debug = n;
@ -272,8 +271,7 @@ main(argc, argv)
if (!stmp || (sscanf(stmp, "%d", &n) != 1) ||
(n < 0) || (n > 16))
{
fprintf(stderr,
"bootpgw: invalid hop count limit\n");
warnx("invalid hop count limit");
break;
}
maxhops = (u_char)n;
@ -296,8 +294,7 @@ main(argc, argv)
stmp = argv[0];
}
if (!stmp || (sscanf(stmp, "%d", &n) != 1) || (n < 0)) {
fprintf(stderr,
"%s: invalid timeout specification\n", progname);
warnx("invalid timeout specification");
break;
}
actualtimeout.tv_sec = (int32) (60 * n);
@ -320,16 +317,14 @@ main(argc, argv)
if (!stmp || (sscanf(stmp, "%d", &n) != 1) ||
(n < 0) || (n > 60))
{
fprintf(stderr,
"bootpgw: invalid wait time\n");
warnx("invalid wait time");
break;
}
minwait = (u_int)n;
break;
default:
fprintf(stderr, "%s: unknown switch: -%c\n",
progname, argv[0][1]);
warnx("unknown switch: -%c", argv[0][1]);
usage();
break;
@ -339,7 +334,7 @@ main(argc, argv)
/* Make sure server name argument is suplied. */
servername = argv[0];
if (!servername) {
fprintf(stderr, "bootpgw: missing server name\n");
warnx("missing server name");
usage();
}
/*
@ -349,10 +344,8 @@ main(argc, argv)
server_ipa = inet_addr(servername);
else {
hep = gethostbyname(servername);
if (!hep) {
fprintf(stderr, "bootpgw: can't get addr for %s\n", servername);
exit(1);
}
if (!hep)
errx(1, "can't get addr for %s", servername);
bcopy(hep->h_addr, (char *)&server_ipa, sizeof(server_ipa));
}
@ -407,7 +400,7 @@ main(argc, argv)
} else {
bootps_port = (u_short) IPPORT_BOOTPS;
report(LOG_ERR,
"udp/bootps: unknown service -- assuming port %d",
"bootps/udp: unknown service -- using port %d",
bootps_port);
}
@ -432,7 +425,7 @@ main(argc, argv)
bootpc_port = ntohs(servp->s_port);
} else {
report(LOG_ERR,
"udp/bootpc: unknown service -- assuming port %d",
"bootpc/udp: unknown service -- using port %d",
IPPORT_BOOTPC);
bootpc_port = (u_short) IPPORT_BOOTPC;
}

View File

@ -39,9 +39,11 @@
/*
* from arp.c 8.2 (Berkeley) 1/2/94
* $FreeBSD$
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#include <sys/param.h>
/*
* Verify that we are at least 4.4 BSD
@ -65,6 +67,7 @@
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <syslog.h>
#include <unistd.h>

View File

@ -31,9 +31,11 @@
* 09/28/93 Released version 1.0
* 09/93 Original developed by Gordon W. Ross <gwr@mc.com>
*
* $FreeBSD$
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
char *usage = "bootptest [-h] server-name [vendor-data-template-file]";
#include <sys/types.h>
@ -52,6 +54,7 @@ char *usage = "bootptest [-h] server-name [vendor-data-template-file]";
#include <unistd.h>
#endif
#include <err.h>
#include <stdlib.h>
#include <signal.h>
#include <stdio.h>
@ -163,10 +166,8 @@ main(argc, argv)
*/
assert(sizeof(struct bootp) == BP_MINPKTSZ);
if (uname(&my_uname) < 0) {
fprintf(stderr, "%s: can't get hostname\n", argv[0]);
exit(1);
}
if (uname(&my_uname) < 0)
errx(1, "can't get hostname");
hostname = my_uname.nodename;
sndbuf = malloc(BUFLEN);
@ -244,7 +245,7 @@ main(argc, argv)
if (sep) {
bootps_port = ntohs((u_short) sep->s_port);
} else {
fprintf(stderr, "udp/bootps: unknown service -- using port %d\n",
warnx("bootps/udp: unknown service -- using port %d",
IPPORT_BOOTPS);
bootps_port = (u_short) IPPORT_BOOTPS;
}
@ -257,10 +258,8 @@ main(argc, argv)
server_addr = inet_addr(servername);
else {
hep = gethostbyname(servername);
if (!hep) {
fprintf(stderr, "%s: unknown host\n", servername);
exit(1);
}
if (!hep)
errx(1, "%s: unknown host", servername);
bcopy(hep->h_addr, &server_addr, sizeof(server_addr));
}
} else {
@ -279,7 +278,7 @@ main(argc, argv)
if (sep) {
bootpc_port = ntohs(sep->s_port);
} else {
fprintf(stderr, "udp/bootpc: unknown service -- using port %d\n",
warnx("bootpc/udp: unknown service -- using port %d",
IPPORT_BOOTPC);
bootpc_port = (u_short) IPPORT_BOOTPC;
}
@ -295,10 +294,12 @@ main(argc, argv)
* Bind client socket to BOOTPC port.
*/
if (bind(s, (struct sockaddr *) &sin_client, sizeof(sin_client)) < 0) {
perror("bind BOOTPC port");
if (errno == EACCES)
fprintf(stderr, "You need to run this as root\n");
exit(1);
if (errno == EACCES) {
warn("bind BOOTPC port");
errx(1, "you need to run this as root");
}
else
err(1, "bind BOOTPC port");
}
/*
* Build a request.
@ -437,8 +438,7 @@ main(argc, argv)
* will now listen for one second after a response.
*/
}
fprintf(stderr, "no response from %s\n", servername);
exit(1);
errx(1, "no response from %s", servername);
}
static void