2 * pmap_set - set portmapper table from data produced by pmap_dump
4 * Author: Wietse Venema (wietse@wzv.win.tue.nl), dept. of Mathematics and
5 * Computing Science, Eindhoven University of Technology, The Netherlands.
9 * @(#) pmap_set.c 1.1 92/06/11 22:53:16
10 * $FreeBSD: src/usr.sbin/portmap/pmap_set/pmap_set.c,v 1.6 2000/01/15 23:08:30 brian Exp $
11 * $DragonFly: src/usr.sbin/portmap/pmap_set/pmap_set.c,v 1.4 2004/03/30 02:59:00 cpressey Exp $
14 #include <sys/types.h>
16 #include <netinet/in.h>
19 #include <rpc/pmap_clnt.h>
24 static int parse_line(char *, u_long *, u_long *, int *, unsigned *);
27 main(int argc, char **argv)
29 struct sockaddr_in addr;
38 while (fgets(buf, sizeof(buf), stdin)) {
39 if (parse_line(buf, &prog, &vers, &prot, &port) == 0) {
40 warnx("malformed line: %s", buf);
43 if (pmap_set(prog, vers, prot, (unsigned short)port) == 0)
44 warnx("not registered: %s", buf);
49 /* parse_line - convert line to numbers */
52 parse_line(char *buf, u_long *prog, u_long *vers, int *prot,
55 char proto_name[BUFSIZ];
57 if (sscanf(buf, "%lu %lu %s %u", prog, vers, proto_name, port) != 4) {
60 if (strcmp(proto_name, "tcp") == 0) {
64 if (strcmp(proto_name, "udp") == 0) {
68 if (sscanf(proto_name, "%d", prot) == 1) {