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[] =
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>
26 /* #define bp_address_u bp_address */
32 char cln[MAX_MACHINE_NAME+1];
33 char dmn[MAX_MACHINE_NAME+1];
34 char path[MAX_PATH_LEN+1];
35 static void usage(void);
36 int printgetfile(bp_getfile_res *);
37 int printwhoami(bp_whoami_res *);
40 eachres_whoami(bp_whoami_res *resultp, struct sockaddr_in *raddr)
44 he = gethostbyaddr((char *)&raddr->sin_addr.s_addr,4,AF_INET);
45 printf("%s answered:\n", he ? he->h_name : inet_ntoa(raddr->sin_addr));
52 eachres_getfile(bp_getfile_res *resultp, struct sockaddr_in *raddr)
56 he = gethostbyaddr((char *)&raddr->sin_addr.s_addr,4,AF_INET);
57 printf("%s answered:\n", he ? he->h_name : inet_ntoa(raddr->sin_addr));
58 printgetfile(resultp);
65 main(int argc, char **argv)
69 bp_whoami_arg whoami_arg;
70 bp_whoami_res *whoami_res, stat_whoami_res;
71 bp_getfile_arg getfile_arg;
72 bp_getfile_res *getfile_res, stat_getfile_res;
78 stat_whoami_res.client_name = cln;
79 stat_whoami_res.domain_name = dmn;
81 stat_getfile_res.server_name = cln;
82 stat_getfile_res.server_path = path;
88 if ( ! strcmp(server , "all") ) broadcast = 1;
91 clnt = clnt_create(server,BOOTPARAMPROG, BOOTPARAMVERS, "udp");
93 errx(1, "could not contact bootparam server on host %s", server);
98 whoami_arg.client_address.address_type = IP_ADDR_TYPE;
99 the_inet_addr = inet_addr(argv[2]);
100 if ( the_inet_addr == INADDR_NONE)
101 errx(2, "bogus addr %s", argv[2]);
102 bcopy(&the_inet_addr,&whoami_arg.client_address.bp_address_u.ip_addr,4);
105 whoami_res = bootparamproc_whoami_1(&whoami_arg, clnt);
106 printf("Whoami returning:\n");
107 if (printwhoami(whoami_res)) {
108 errx(1, "bad answer returned from server %s", server);
112 (void)clnt_broadcast(BOOTPARAMPROG, BOOTPARAMVERS,
113 BOOTPARAMPROC_WHOAMI,
114 (xdrproc_t)xdr_bp_whoami_arg,
116 (xdrproc_t)xdr_bp_whoami_res,
117 (char *)&stat_whoami_res,
118 (resultproc_t)eachres_whoami);
124 getfile_arg.client_name = argv[2];
125 getfile_arg.file_id = argv[3];
128 getfile_res = bootparamproc_getfile_1(&getfile_arg,clnt);
129 printf("getfile returning:\n");
130 if (printgetfile(getfile_res)) {
131 errx(1, "bad answer returned from server %s", server);
135 (void)clnt_broadcast(BOOTPARAMPROG, BOOTPARAMVERS,
136 BOOTPARAMPROC_GETFILE,
137 (xdrproc_t)xdr_bp_getfile_arg,
138 (char *)&getfile_arg,
139 (xdrproc_t)xdr_bp_getfile_res,
140 (char *)&stat_getfile_res,
141 (resultproc_t)eachres_getfile);
157 "usage: callbootd server procnum (IP-addr | host fileid)\n");
166 printf("client_name:\t%s\ndomain_name:\t%s\n",
167 res->client_name, res->domain_name);
168 printf("router:\t%d.%d.%d.%d\n",
169 255 & res->router_address.bp_address_u.ip_addr.net,
170 255 & res->router_address.bp_address_u.ip_addr.host,
171 255 & res->router_address.bp_address_u.ip_addr.lh,
172 255 & res->router_address.bp_address_u.ip_addr.impno);
175 warnx("null answer!!!");
188 printf("server_name:\t%s\nserver_address:\t%s\npath:\t%s\n",
190 inet_ntoa(*(struct in_addr *)&res->server_address.bp_address_u.ip_addr),
194 warnx("null answer!!!");