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/callbootd/callbootd.c,v 1.8 1999/08/28 01:15:40 peter Exp $";
15 #include "bootparam_prot.h"
17 #include <sys/types.h>
18 #include <sys/socket.h>
19 #include <netinet/in.h>
20 #include <arpa/inet.h>
25 /* #define bp_address_u bp_address */
31 char cln[MAX_MACHINE_NAME+1];
32 char dmn[MAX_MACHINE_NAME+1];
33 char path[MAX_PATH_LEN+1];
34 extern char *inet_ntoa();
35 static void usage __P((void));
36 int printgetfile __P((bp_getfile_res *));
37 int printwhoami __P((bp_whoami_res *));
40 eachres_whoami(resultp, raddr)
41 bp_whoami_res *resultp;
42 struct sockaddr_in *raddr;
46 he = gethostbyaddr((char *)&raddr->sin_addr.s_addr,4,AF_INET);
47 printf("%s answered:\n", he ? he->h_name : inet_ntoa(raddr->sin_addr));
53 eachres_getfile(resultp, raddr)
54 bp_getfile_res *resultp;
55 struct sockaddr_in *raddr;
59 he = gethostbyaddr((char *)&raddr->sin_addr.s_addr,4,AF_INET);
60 printf("%s answered:\n", he ? he->h_name : inet_ntoa(raddr->sin_addr));
61 printgetfile(resultp);
74 bp_whoami_arg whoami_arg;
75 bp_whoami_res *whoami_res, stat_whoami_res;
76 bp_getfile_arg getfile_arg;
77 bp_getfile_res *getfile_res, stat_getfile_res;
82 enum clnt_stat clnt_stat;
84 stat_whoami_res.client_name = cln;
85 stat_whoami_res.domain_name = dmn;
87 stat_getfile_res.server_name = cln;
88 stat_getfile_res.server_path = path;
94 if ( ! strcmp(server , "all") ) broadcast = 1;
97 clnt = clnt_create(server,BOOTPARAMPROG, BOOTPARAMVERS, "udp");
101 errx(1, "could not contact bootparam server on host %s", server);
105 whoami_arg.client_address.address_type = IP_ADDR_TYPE;
106 the_inet_addr = inet_addr(argv[2]);
107 if ( the_inet_addr == -1)
108 errx(2, "bogus addr %s", argv[2]);
109 bcopy(&the_inet_addr,&whoami_arg.client_address.bp_address_u.ip_addr,4);
112 whoami_res = bootparamproc_whoami_1(&whoami_arg, clnt);
113 printf("Whoami returning:\n");
114 if (printwhoami(whoami_res)) {
115 errx(1, "bad answer returned from server %s", server);
119 clnt_stat=clnt_broadcast(BOOTPARAMPROG, BOOTPARAMVERS,
120 BOOTPARAMPROC_WHOAMI,
121 xdr_bp_whoami_arg, &whoami_arg,
122 xdr_bp_whoami_res, &stat_whoami_res, eachres_whoami);
128 getfile_arg.client_name = argv[2];
129 getfile_arg.file_id = argv[3];
132 getfile_res = bootparamproc_getfile_1(&getfile_arg,clnt);
133 printf("getfile returning:\n");
134 if (printgetfile(getfile_res)) {
135 errx(1, "bad answer returned from server %s", server);
139 clnt_stat=clnt_broadcast(BOOTPARAMPROG, BOOTPARAMVERS,
140 BOOTPARAMPROC_GETFILE,
141 xdr_bp_getfile_arg, &getfile_arg,
142 xdr_bp_getfile_res, &stat_getfile_res,eachres_getfile);
158 "usage: callbootd server procnum (IP-addr | host fileid)\n");
167 printf("client_name:\t%s\ndomain_name:\t%s\n",
168 res->client_name, res->domain_name);
169 printf("router:\t%d.%d.%d.%d\n",
170 255 & res->router_address.bp_address_u.ip_addr.net,
171 255 & res->router_address.bp_address_u.ip_addr.host,
172 255 & res->router_address.bp_address_u.ip_addr.lh,
173 255 & res->router_address.bp_address_u.ip_addr.impno);
176 warnx("null answer!!!");
189 printf("server_name:\t%s\nserver_address:\t%s\npath:\t%s\n",
191 inet_ntoa(*(struct in_addr *)&res->server_address.bp_address_u.ip_addr),
195 warnx("null answer!!!");