3 This code is not copyright, and is placed in the public domain. Feel free to
4 use and modify. Please send modifications and/or suggestions + bug fixes to
6 Klas Heggemann <klas@nada.kth.se>
11 static const char rcsid[] =
12 "$FreeBSD: src/usr.sbin/bootparamd/bootparamd/main.c,v 1.9 1999/08/28 01:15:39 peter Exp $";
24 #include <rpc/pmap_clnt.h>
25 #include <sys/ioctl.h>
26 #include <sys/socket.h>
28 #include <sys/types.h>
29 #include <netinet/in.h>
30 #include <arpa/inet.h>
31 #include "bootparam_prot.h"
35 unsigned long route_addr = -1;
36 struct sockaddr_in my_addr;
37 char *bootpfile = "/etc/bootparams";
39 extern void bootparamprog_1();
40 static void usage __P((void));
53 while ((c = getopt(argc, argv,"dsr:f:")) != -1)
59 if ( isdigit( *optarg)) {
60 route_addr = inet_addr(optarg);
63 he = gethostbyname(optarg);
65 bcopy(he->h_addr, (char *)&route_addr, sizeof(route_addr));
68 errx(1, "no such host %s", argv[i]);
77 openlog("bootparamd", 0 , 0);
79 openlog("bootparamd", 0 , LOG_DAEMON);
80 setlogmask(LOG_UPTO(LOG_NOTICE));
87 if ( stat(bootpfile, &buf ) )
88 err(1, "%s", bootpfile);
90 if (route_addr == -1) {
91 get_myaddress(&my_addr);
92 bcopy(&my_addr.sin_addr.s_addr, &route_addr, sizeof (route_addr));
101 (void)pmap_unset(BOOTPARAMPROG, BOOTPARAMVERS);
103 transp = svcudp_create(RPC_ANYSOCK);
105 errx(1, "cannot create udp service");
106 if (!svc_register(transp, BOOTPARAMPROG, BOOTPARAMVERS, bootparamprog_1, IPPROTO_UDP))
107 errx(1, "unable to register (BOOTPARAMPROG, BOOTPARAMVERS, udp)");
110 errx(1, "svc_run returned");
117 "usage: bootparamd [-d] [-s] [-r router] [-f bootparmsfile]\n");