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 * $FreeBSD: src/usr.sbin/bootparamd/bootparamd/main.c,v 1.9 1999/08/28 01:15:39 peter Exp $
12 * $DragonFly: src/usr.sbin/bootparamd/bootparamd/main.c,v 1.5.14.1 2008/09/19 18:49:09 swildner Exp $
23 #include <rpc/pmap_clnt.h>
24 #include <sys/ioctl.h>
25 #include <sys/socket.h>
27 #include <sys/types.h>
28 #include <netinet/in.h>
29 #include <arpa/inet.h>
30 #include "bootparam_prot.h"
34 unsigned long route_addr
= -1;
35 struct sockaddr_in my_addr
;
36 char *bootpfile
= "/etc/bootparams";
38 extern void bootparamprog_1();
39 static void usage(void);
42 main(int argc
, char **argv
)
49 while ((c
= getopt(argc
, argv
,"dsr:f:")) != -1)
55 if ( isdigit( *optarg
)) {
56 route_addr
= inet_addr(optarg
);
59 he
= gethostbyname(optarg
);
61 bcopy(he
->h_addr
, (char *)&route_addr
, sizeof(route_addr
));
64 errx(1, "no such host %s", optarg
);
73 openlog("bootparamd", 0 , 0);
75 openlog("bootparamd", 0 , LOG_DAEMON
);
76 setlogmask(LOG_UPTO(LOG_NOTICE
));
83 if ( stat(bootpfile
, &buf
) )
84 err(1, "%s", bootpfile
);
86 if (route_addr
== -1) {
87 get_myaddress(&my_addr
);
88 bcopy(&my_addr
.sin_addr
.s_addr
, &route_addr
, sizeof (route_addr
));
97 pmap_unset(BOOTPARAMPROG
, BOOTPARAMVERS
);
99 transp
= svcudp_create(RPC_ANYSOCK
);
101 errx(1, "cannot create udp service");
102 if (!svc_register(transp
, BOOTPARAMPROG
, BOOTPARAMVERS
, bootparamprog_1
, IPPROTO_UDP
))
103 errx(1, "unable to register (BOOTPARAMPROG, BOOTPARAMVERS, udp)");
106 errx(1, "svc_run returned");
113 "usage: bootparamd [-d] [-s] [-r router] [-f bootparmsfile]\n");