callbootd.c (74462) | callbootd.c (116598) |
---|---|
1/* 2 3This code is not copyright, and is placed in the public domain. Feel free to 4use and modify. Please send modifications and/or suggestions + bug fixes to 5 6 Klas Heggemann <klas@nada.kth.se> 7 8*/ 9 10#ifndef lint 11static const char rcsid[] = | 1/* 2 3This code is not copyright, and is placed in the public domain. Feel free to 4use and modify. Please send modifications and/or suggestions + bug fixes to 5 6 Klas Heggemann <klas@nada.kth.se> 7 8*/ 9 10#ifndef lint 11static const char rcsid[] = |
12 "$FreeBSD: head/usr.sbin/bootparamd/callbootd/callbootd.c 74462 2001-03-19 12:50:13Z alfred $"; | 12 "$FreeBSD: head/usr.sbin/bootparamd/callbootd/callbootd.c 116598 2003-06-20 04:54:27Z jmg $"; |
13#endif /* not lint */ 14 15#include "bootparam_prot.h" 16#include <rpc/rpc.h> 17#include <sys/types.h> 18#include <sys/socket.h> 19#include <netinet/in.h> 20#include <arpa/inet.h> 21#include <err.h> 22#include <netdb.h> | 13#endif /* not lint */ 14 15#include "bootparam_prot.h" 16#include <rpc/rpc.h> 17#include <sys/types.h> 18#include <sys/socket.h> 19#include <netinet/in.h> 20#include <arpa/inet.h> 21#include <err.h> 22#include <netdb.h> |
23#include <stdlib.h> |
|
23 24 25/* #define bp_address_u bp_address */ 26#include <stdio.h> 27#include <string.h> 28 29int broadcast; 30 31char cln[MAX_MACHINE_NAME+1]; 32char dmn[MAX_MACHINE_NAME+1]; 33char path[MAX_PATH_LEN+1]; 34extern char *inet_ntoa(); 35static void usage __P((void)); 36int printgetfile __P((bp_getfile_res *)); 37int printwhoami __P((bp_whoami_res *)); 38 | 24 25 26/* #define bp_address_u bp_address */ 27#include <stdio.h> 28#include <string.h> 29 30int broadcast; 31 32char cln[MAX_MACHINE_NAME+1]; 33char dmn[MAX_MACHINE_NAME+1]; 34char path[MAX_PATH_LEN+1]; 35extern char *inet_ntoa(); 36static void usage __P((void)); 37int printgetfile __P((bp_getfile_res *)); 38int printwhoami __P((bp_whoami_res *)); 39 |
39int | 40bool_t |
40eachres_whoami(resultp, raddr) 41bp_whoami_res *resultp; 42struct sockaddr_in *raddr; 43{ 44 struct hostent *he; 45 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)); 48 printwhoami(resultp); 49 printf("\n"); 50 return(0); 51} 52 | 41eachres_whoami(resultp, raddr) 42bp_whoami_res *resultp; 43struct sockaddr_in *raddr; 44{ 45 struct hostent *he; 46 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)); 49 printwhoami(resultp); 50 printf("\n"); 51 return(0); 52} 53 |
54bool_t |
|
53eachres_getfile(resultp, raddr) 54bp_getfile_res *resultp; 55struct sockaddr_in *raddr; 56{ 57 struct hostent *he; 58 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)); --- 29 unchanged lines hidden (view full) --- 90 if (argc < 3) 91 usage(); 92 93 server = argv[1]; 94 if ( ! strcmp(server , "all") ) broadcast = 1; 95 96 if ( ! broadcast ) { 97 clnt = clnt_create(server,BOOTPARAMPROG, BOOTPARAMVERS, "udp"); | 55eachres_getfile(resultp, raddr) 56bp_getfile_res *resultp; 57struct sockaddr_in *raddr; 58{ 59 struct hostent *he; 60 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)); --- 29 unchanged lines hidden (view full) --- 92 if (argc < 3) 93 usage(); 94 95 server = argv[1]; 96 if ( ! strcmp(server , "all") ) broadcast = 1; 97 98 if ( ! broadcast ) { 99 clnt = clnt_create(server,BOOTPARAMPROG, BOOTPARAMVERS, "udp"); |
100 if ( clnt == NULL ) 101 errx(1, "could not contact bootparam server on host %s", server); |
|
98 } 99 | 102 } 103 |
100 if ( clnt == NULL ) 101 errx(1, "could not contact bootparam server on host %s", server); 102 | |
103 switch (argc) { 104 case 3: 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); 110 111 if (! broadcast ) { 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); 116 } else 117 exit(0); 118 } else { 119 clnt_stat=clnt_broadcast(BOOTPARAMPROG, BOOTPARAMVERS, 120 BOOTPARAMPROC_WHOAMI, | 104 switch (argc) { 105 case 3: 106 whoami_arg.client_address.address_type = IP_ADDR_TYPE; 107 the_inet_addr = inet_addr(argv[2]); 108 if ( the_inet_addr == -1) 109 errx(2, "bogus addr %s", argv[2]); 110 bcopy(&the_inet_addr,&whoami_arg.client_address.bp_address_u.ip_addr,4); 111 112 if (! broadcast ) { 113 whoami_res = bootparamproc_whoami_1(&whoami_arg, clnt); 114 printf("Whoami returning:\n"); 115 if (printwhoami(whoami_res)) { 116 errx(1, "bad answer returned from server %s", server); 117 } else 118 exit(0); 119 } else { 120 clnt_stat=clnt_broadcast(BOOTPARAMPROG, BOOTPARAMVERS, 121 BOOTPARAMPROC_WHOAMI, |
121 (xdrproc_t)xdr_bp_whoami_arg, (char *)&whoami_arg, 122 xdr_bp_whoami_res, (char *)&stat_whoami_res, | 122 (xdrproc_t)xdr_bp_whoami_arg, 123 (char *)&whoami_arg, 124 (xdrproc_t)xdr_bp_whoami_res, 125 (char *)&stat_whoami_res, |
123 (resultproc_t)eachres_whoami); 124 exit(0); 125 } 126 127 case 4: 128 129 getfile_arg.client_name = argv[2]; 130 getfile_arg.file_id = argv[3]; 131 132 if (! broadcast ) { 133 getfile_res = bootparamproc_getfile_1(&getfile_arg,clnt); 134 printf("getfile returning:\n"); 135 if (printgetfile(getfile_res)) { 136 errx(1, "bad answer returned from server %s", server); 137 } else 138 exit(0); 139 } else { 140 clnt_stat=clnt_broadcast(BOOTPARAMPROG, BOOTPARAMVERS, 141 BOOTPARAMPROC_GETFILE, | 126 (resultproc_t)eachres_whoami); 127 exit(0); 128 } 129 130 case 4: 131 132 getfile_arg.client_name = argv[2]; 133 getfile_arg.file_id = argv[3]; 134 135 if (! broadcast ) { 136 getfile_res = bootparamproc_getfile_1(&getfile_arg,clnt); 137 printf("getfile returning:\n"); 138 if (printgetfile(getfile_res)) { 139 errx(1, "bad answer returned from server %s", server); 140 } else 141 exit(0); 142 } else { 143 clnt_stat=clnt_broadcast(BOOTPARAMPROG, BOOTPARAMVERS, 144 BOOTPARAMPROC_GETFILE, |
142 xdr_bp_getfile_arg, (char *)&getfile_arg, 143 xdr_bp_getfile_res, (char *)&stat_getfile_res, | 145 (xdrproc_t)xdr_bp_getfile_arg, 146 (char *)&getfile_arg, 147 (xdrproc_t)xdr_bp_getfile_res, 148 (char *)&stat_getfile_res, |
144 (resultproc_t)eachres_getfile); 145 exit(0); 146 } 147 148 default: 149 150 usage(); 151 } --- 49 unchanged lines hidden --- | 149 (resultproc_t)eachres_getfile); 150 exit(0); 151 } 152 153 default: 154 155 usage(); 156 } --- 49 unchanged lines hidden --- |