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 extern char *inet_ntoa();
36 static void usage(void);
37 int printgetfile(bp_getfile_res *);
38 int printwhoami(bp_whoami_res *);
41 eachres_whoami(resultp, raddr)
42 bp_whoami_res *resultp;
43 struct sockaddr_in *raddr;
47 he = gethostbyaddr((char *)&raddr->sin_addr.s_addr,4,AF_INET);
48 printf("%s answered:\n", he ? he->h_name : inet_ntoa(raddr->sin_addr));
55 eachres_getfile(resultp, raddr)
56 bp_getfile_res *resultp;
57 struct sockaddr_in *raddr;
61 he = gethostbyaddr((char *)&raddr->sin_addr.s_addr,4,AF_INET);
62 printf("%s answered:\n", he ? he->h_name : inet_ntoa(raddr->sin_addr));
63 printgetfile(resultp);
76 bp_whoami_arg whoami_arg;
77 bp_whoami_res *whoami_res, stat_whoami_res;
78 bp_getfile_arg getfile_arg;
79 bp_getfile_res *getfile_res, stat_getfile_res;
85 stat_whoami_res.client_name = cln;
86 stat_whoami_res.domain_name = dmn;
88 stat_getfile_res.server_name = cln;
89 stat_getfile_res.server_path = path;
95 if ( ! strcmp(server , "all") ) broadcast = 1;
98 clnt = clnt_create(server,BOOTPARAMPROG, BOOTPARAMVERS, "udp");
100 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 (void)clnt_broadcast(BOOTPARAMPROG, BOOTPARAMVERS,
120 BOOTPARAMPROC_WHOAMI,
121 (xdrproc_t)xdr_bp_whoami_arg,
123 (xdrproc_t)xdr_bp_whoami_res,
124 (char *)&stat_whoami_res,
125 (resultproc_t)eachres_whoami);
131 getfile_arg.client_name = argv[2];
132 getfile_arg.file_id = argv[3];
135 getfile_res = bootparamproc_getfile_1(&getfile_arg,clnt);
136 printf("getfile returning:\n");
137 if (printgetfile(getfile_res)) {
138 errx(1, "bad answer returned from server %s", server);
142 (void)clnt_broadcast(BOOTPARAMPROG, BOOTPARAMVERS,
143 BOOTPARAMPROC_GETFILE,
144 (xdrproc_t)xdr_bp_getfile_arg,
145 (char *)&getfile_arg,
146 (xdrproc_t)xdr_bp_getfile_res,
147 (char *)&stat_getfile_res,
148 (resultproc_t)eachres_getfile);
164 "usage: callbootd server procnum (IP-addr | host fileid)\n");
173 printf("client_name:\t%s\ndomain_name:\t%s\n",
174 res->client_name, res->domain_name);
175 printf("router:\t%d.%d.%d.%d\n",
176 255 & res->router_address.bp_address_u.ip_addr.net,
177 255 & res->router_address.bp_address_u.ip_addr.host,
178 255 & res->router_address.bp_address_u.ip_addr.lh,
179 255 & res->router_address.bp_address_u.ip_addr.impno);
182 warnx("null answer!!!");
195 printf("server_name:\t%s\nserver_address:\t%s\npath:\t%s\n",
197 inet_ntoa(*(struct in_addr *)&res->server_address.bp_address_u.ip_addr),
201 warnx("null answer!!!");