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.2 2003/06/17 04:30:00 dillon Exp $
15 #include <sys/types.h>
17 #include <netinet/in.h>
20 #include <rpc/pmap_clnt.h>
22 static int parse_line __P((char *, u_long *, u_long *, int *, unsigned *));
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(buf, prog, vers, prot, port)
58 char proto_name[BUFSIZ];
60 if (sscanf(buf, "%lu %lu %s %u", prog, vers, proto_name, port) != 4) {
63 if (strcmp(proto_name, "tcp") == 0) {
67 if (strcmp(proto_name, "udp") == 0) {
71 if (sscanf(proto_name, "%d", prot) == 1) {