Correct PPTP server firewall rules chain.
[tomato/davidwu.git] / release / src / router / portmap / pmap_dump.c
blob333f41d3e9312d25772820b737fc3e6d8dae3f6b
1 /*
2 * pmap_dump - dump portmapper table in format readable by pmap_set
3 *
4 * Author: Wietse Venema (wietse@wzv.win.tue.nl), dept. of Mathematics and
5 * Computing Science, Eindhoven University of Technology, The Netherlands.
6 */
8 #include <stdio.h>
9 #include <sys/types.h>
10 #ifdef SYSV40
11 #include <netinet/in.h>
12 #include <rpc/rpcent.h>
13 #else
14 #include <netdb.h>
15 #endif
16 #include <rpc/rpc.h>
17 #include <rpc/pmap_clnt.h>
18 #include <rpc/pmap_prot.h>
20 static char *protoname(u_long proto);
22 int
23 main(int argc, char **argv)
25 struct sockaddr_in addr;
26 struct pmaplist *list;
27 struct rpcent *rpc;
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];
50 switch (proto) {
51 case IPPROTO_UDP:
52 return ("udp");
53 case IPPROTO_TCP:
54 return ("tcp");
55 default:
56 sprintf(buf, "%lu", proto);
57 return (buf);