2 * pmap_dump - dump portmapper table in format readable by pmap_set
4 * Author: Wietse Venema (wietse@wzv.win.tue.nl), dept. of Mathematics and
5 * Computing Science, Eindhoven University of Technology, The Netherlands.
11 #include <netinet/in.h>
12 #include <rpc/rpcent.h>
17 #include <rpc/pmap_clnt.h>
18 #include <rpc/pmap_prot.h>
20 static const char *protoname(u_long proto)
22 static char buf[BUFSIZ];
30 sprintf(buf, "%lu", proto);
36 main(int argc, char **argv)
38 struct sockaddr_in addr;
39 struct pmaplist *list;
42 memset(&addr, 0, sizeof(addr));
43 addr.sin_family = AF_INET;
44 addr.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
45 addr.sin_port = htons(PMAPPORT);
47 for (list = pmap_getmaps(&addr); list; list = list->pml_next) {
48 rpc = getrpcbynumber((int) list->pml_map.pm_prog);
49 printf("%10lu %4lu %5s %6lu %s\n",
50 list->pml_map.pm_prog,
51 list->pml_map.pm_vers,
52 protoname(list->pml_map.pm_prot),
53 list->pml_map.pm_port,
54 rpc ? rpc->r_name : "");
56 return (fclose(stdout) ? (perror(argv[0]), 1) : 0);