From fa74c6b5cf20bf83ae7fe9dadbdf1c726a49e812 Mon Sep 17 00:00:00 2001 From: brian Date: Fri, 25 Jul 1997 03:13:46 +0000 Subject: Allow service names as the divert/tee arg. --- sbin/ipfw/ipfw.c | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) (limited to 'sbin') diff --git a/sbin/ipfw/ipfw.c b/sbin/ipfw/ipfw.c index 5c66255..802e5c6 100644 --- a/sbin/ipfw/ipfw.c +++ b/sbin/ipfw/ipfw.c @@ -16,7 +16,7 @@ * * NEW command line interface for IP firewall facility * - * $Id: ipfw.c,v 1.44 1997/06/13 06:27:12 charnier Exp $ + * $Id: ipfw.c,v 1.45 1997/06/23 22:32:13 julian Exp $ * */ @@ -807,15 +807,29 @@ add(ac,av) if (!ac) show_usage("missing divert port"); rule.fw_divert_port = strtoul(*av, NULL, 0); av++; ac--; - if (rule.fw_divert_port == 0) - show_usage("illegal divert port"); + if (rule.fw_divert_port == 0) { + struct servent *s; + setservent(1); + s = getservbyname(av[-1], "divert"); + if (s != NULL) + rule.fw_divert_port = ntohs(s->s_port); + else + show_usage("illegal divert port"); + } } else if (!strncmp(*av,"tee",strlen(*av))) { rule.fw_flg |= IP_FW_F_TEE; av++; ac--; if (!ac) show_usage("missing divert port"); rule.fw_divert_port = strtoul(*av, NULL, 0); av++; ac--; - if (rule.fw_divert_port == 0) - show_usage("illegal divert port"); + if (rule.fw_divert_port == 0) { + struct servent *s; + setservent(1); + s = getservbyname(av[-1], "divert"); + if (s != NULL) + rule.fw_divert_port = ntohs(s->s_port); + else + show_usage("illegal divert port"); + } } else if (!strncmp(*av,"skipto",strlen(*av))) { rule.fw_flg |= IP_FW_F_SKIPTO; av++; ac--; if (!ac) -- cgit v1.1