From owner-freebsd-net@FreeBSD.ORG Sat Feb 10 22:57:17 2007 Return-Path: X-Original-To: net@FreeBSD.org Delivered-To: freebsd-net@FreeBSD.ORG Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 3977516A406 for ; Sat, 10 Feb 2007 22:57:17 +0000 (UTC) (envelope-from bms@incunabulum.net) Received: from out5.smtp.messagingengine.com (out5.smtp.messagingengine.com [66.111.4.29]) by mx1.freebsd.org (Postfix) with ESMTP id 2365113C4A3 for ; Sat, 10 Feb 2007 22:57:15 +0000 (UTC) (envelope-from bms@incunabulum.net) Received: from out1.internal (unknown [10.202.2.149]) by out1.messagingengine.com (Postfix) with ESMTP id 14F451787FD for ; Sat, 10 Feb 2007 17:57:14 -0500 (EST) Received: from heartbeat1.messagingengine.com ([10.202.2.160]) by out1.internal (MEProxy); Sat, 10 Feb 2007 17:57:14 -0500 X-Sasl-enc: V3mgNr9pyLuUaXS4w5aBoWObAIkhdbCSByxjB0SdMyln 1171148233 Received: from [192.168.123.18] (82-35-112-254.cable.ubr07.dals.blueyonder.co.uk [82.35.112.254]) by mail.messagingengine.com (Postfix) with ESMTP id 5252617B8E for ; Sat, 10 Feb 2007 17:57:13 -0500 (EST) Message-ID: <45CE4DC9.4050605@incunabulum.net> Date: Sat, 10 Feb 2007 22:57:13 +0000 From: Bruce M Simpson User-Agent: Thunderbird 1.5.0.9 (X11/20070125) MIME-Version: 1.0 To: net@FreeBSD.org Content-Type: multipart/mixed; boundary="------------050407040501050603060107" Cc: Subject: [PATCH] netstat(1) should print CIDR prefixes X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 10 Feb 2007 22:57:17 -0000 This is a multi-part message in MIME format. --------------050407040501050603060107 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Hi, This is a POLA violating 'let's move with the times' patch that gets rid of the special treatment of classful IPv4 network prefixes in 'netstat -rn' output. Comments please! Rgards, BMS --------------050407040501050603060107 Content-Type: text/x-patch; name="route-cidr-pola.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="route-cidr-pola.diff" Index: route.c =================================================================== RCS file: /home/ncvs/src/usr.bin/netstat/route.c,v retrieving revision 1.76 diff -u -p -r1.76 route.c --- route.c 13 May 2005 16:31:10 -0000 1.76 +++ route.c 10 Feb 2007 22:55:50 -0000 @@ -865,32 +865,7 @@ netname(u_long in, u_long mask) strncpy(line, cp, sizeof(line) - 1); line[sizeof(line) - 1] = '\0'; } else { - switch (dmask) { - case IN_CLASSA_NET: - if ((i & IN_CLASSA_HOST) == 0) { - sprintf(line, "%lu", C(i >> 24)); - break; - } - /* FALLTHROUGH */ - case IN_CLASSB_NET: - if ((i & IN_CLASSB_HOST) == 0) { - sprintf(line, "%lu.%lu", - C(i >> 24), C(i >> 16)); - break; - } - /* FALLTHROUGH */ - case IN_CLASSC_NET: - if ((i & IN_CLASSC_HOST) == 0) { - sprintf(line, "%lu.%lu.%lu", - C(i >> 24), C(i >> 16), C(i >> 8)); - break; - } - /* FALLTHROUGH */ - default: - sprintf(line, "%lu.%lu.%lu.%lu", - C(i >> 24), C(i >> 16), C(i >> 8), C(i)); - break; - } + inet_ntop(AF_INET, (char *)&in, line, sizeof(line) - 1); } domask(line + strlen(line), i, mask); return (line); --------------050407040501050603060107--