From owner-freebsd-bugs Mon May 27 19:01:24 1996 Return-Path: owner-bugs Received: (from root@localhost) by freefall.freebsd.org (8.7.5/8.7.3) id TAA20435 for bugs-outgoing; Mon, 27 May 1996 19:01:24 -0700 (PDT) Received: (from gnats@localhost) by freefall.freebsd.org (8.7.5/8.7.3) id TAA20306; Mon, 27 May 1996 19:00:03 -0700 (PDT) Resent-Date: Mon, 27 May 1996 19:00:03 -0700 (PDT) Resent-Message-Id: <199605280200.TAA20306@freefall.freebsd.org> Resent-From: gnats (GNATS Management) Resent-To: freebsd-bugs Resent-Reply-To: FreeBSD-gnats@freefall.FreeBSD.org, nash@mcs.com Received: from zen.nash.org (nash.pr.mcs.net [204.95.47.72]) by freefall.freebsd.org (8.7.5/8.7.3) with ESMTP id SAA19809; Mon, 27 May 1996 18:50:42 -0700 (PDT) Received: (from alex@localhost) by zen.nash.org (8.7.5/8.6.12) id UAA00814; Mon, 27 May 1996 20:50:12 -0500 (CDT) Message-Id: <199605280150.UAA00814@zen.nash.org> Date: Mon, 27 May 1996 20:50:12 -0500 (CDT) From: Alex Nash Reply-To: nash@mcs.com To: FreeBSD-gnats-submit@freebsd.org Cc: phk@freebsd.org X-Send-Pr-Version: 3.2 Subject: bin/1266: IPFW: Resolve service names with -N option Sender: owner-bugs@freebsd.org X-Loop: FreeBSD.org Precedence: bulk >Number: 1266 >Category: bin >Synopsis: IPFW: Resolve service names with -N option >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Class: change-request >Submitter-Id: current-users >Arrival-Date: Mon May 27 19:00:02 PDT 1996 >Last-Modified: >Originator: Alex Nash >Organization: >Release: FreeBSD 2.1-STABLE i386 >Environment: 2.1.0-STABLE/CURRENT running IPFW. >Description: The -N option to ipfw resolves host names but not service names (perhaps this is intentional?). >How-To-Repeat: # ipfw -N l >Fix: NOTE: These diffs are against those submitted in bin/1220. The version numbers do not correspond to those in the FreeBSD CVS tree. Index: ipfw.c =================================================================== RCS file: /home/alex/cvs/ipfw/ipfw.c,v retrieving revision 1.4 retrieving revision 1.5 diff -c -r1.4 -r1.5 *** ipfw.c 1996/05/19 18:28:45 1.4 --- ipfw.c 1996/05/28 01:16:42 1.5 *************** *** 15,21 **** * * NEW command line interface for IP firewall facility * ! * $Id: ipfw.c,v 1.4 1996/05/19 18:28:45 alex Exp $ * */ --- 15,21 ---- * * NEW command line interface for IP firewall facility * ! * $Id: ipfw.c,v 1.5 1996/05/28 01:16:42 alex Exp $ * */ *************** *** 65,70 **** --- 65,104 ---- } void + print_port(port, comma, flg) + u_short port,flg; + const char *comma; + { + int printed = 0; + + if (do_resolv) { + struct servent *se; + const char *protocol; + + switch (flg & IP_FW_F_KIND) { + case IP_FW_F_TCP: + protocol = "tcp"; + break; + case IP_FW_F_UDP: + protocol = "udp"; + break; + default: + protocol = NULL; + break; + } + + se = getservbyport(htons(port), protocol); + + if (se) { + printf("%s%s", comma, se->s_name); + printed = 1; + } + } + if (!printed) + printf("%s%d",comma,port); + } + + void show_ipfw(chain) struct ip_fw *chain; { *************** *** 73,78 **** --- 107,114 ---- struct hostent *he; int i,mb; + if (do_resolv) + setservent(1/*stayopen*/); printf("%05u ", chain->fw_number); *************** *** 152,158 **** comma = " "; for (i=0;ifw_nsp; i++ ) { ! printf("%s%d",comma,chain->fw_pts[i]); if (i==0 && (chain->fw_flg & IP_FW_F_SRNG)) comma = "-"; else --- 188,194 ---- comma = " "; for (i=0;ifw_nsp; i++ ) { ! print_port(chain->fw_pts[i], comma, chain->fw_flg); if (i==0 && (chain->fw_flg & IP_FW_F_SRNG)) comma = "-"; else *************** *** 190,196 **** comma = " "; for (i=0;ifw_ndp;i++) { ! printf("%s%d",comma,chain->fw_pts[chain->fw_nsp+i]); if (i==0 && (chain->fw_flg & IP_FW_F_DRNG)) comma = "-"; else --- 226,232 ---- comma = " "; for (i=0;ifw_ndp;i++) { ! print_port(chain->fw_pts[chain->fw_nsp+i], comma, chain->fw_flg); if (i==0 && (chain->fw_flg & IP_FW_F_DRNG)) comma = "-"; else *************** *** 272,277 **** --- 308,316 ---- } } printf("\n"); + + if (do_resolv) + endservent(); } void >Audit-Trail: >Unformatted: