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 char *protoname(u_long proto
);
23 main(int argc
, char **argv
)
25 struct sockaddr_in addr
;
26 struct pmaplist
*list
;
29 memset(&addr
, 0, sizeof(addr
));
30 addr
.sin_family
= AF_INET
;
31 addr
.sin_addr
.s_addr
= htonl(INADDR_LOOPBACK
);
32 addr
.sin_port
= htons(PMAPPORT
);
34 for (list
= pmap_getmaps(&addr
); list
; list
= list
->pml_next
) {
35 rpc
= getrpcbynumber((int) list
->pml_map
.pm_prog
);
36 printf("%10lu %4lu %5s %6lu %s\n",
37 list
->pml_map
.pm_prog
,
38 list
->pml_map
.pm_vers
,
39 protoname(list
->pml_map
.pm_prot
),
40 list
->pml_map
.pm_port
,
41 rpc
? rpc
->r_name
: "");
43 return (fclose(stdout
) ? (perror(argv
[0]), 1) : 0);
46 static char *protoname(u_long proto
)
48 static char buf
[BUFSIZ
];
56 sprintf(buf
, "%lu", proto
);