From owner-freebsd-net@FreeBSD.ORG Wed Jan 30 16:30:46 2013 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 4BCAAEEE; Wed, 30 Jan 2013 16:30:45 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from bigwig.baldwin.cx (bigknife-pt.tunnel.tserv9.chi1.ipv6.he.net [IPv6:2001:470:1f10:75::2]) by mx1.freebsd.org (Postfix) with ESMTP id C2969718; Wed, 30 Jan 2013 16:30:45 +0000 (UTC) Received: from pakbsde14.localnet (unknown [38.105.238.108]) by bigwig.baldwin.cx (Postfix) with ESMTPSA id 2D355B911; Wed, 30 Jan 2013 11:30:45 -0500 (EST) From: John Baldwin To: freebsd-net@freebsd.org Subject: Re: [PATCH] Allow tcpdrop to use non-space separators Date: Wed, 30 Jan 2013 11:13:25 -0500 User-Agent: KMail/1.13.5 (FreeBSD/8.2-CBSD-20110714-p22; KDE/4.5.5; amd64; ; ) References: <201301291205.41301.jhb@freebsd.org> <5108572D.1090905@freebsd.org> In-Reply-To: MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <201301301113.25418.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.7 (bigwig.baldwin.cx); Wed, 30 Jan 2013 11:30:45 -0500 (EST) Cc: Andre Oppermann , Luigi Rizzo , "freebsd-net@freebsd.org" X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 30 Jan 2013 16:30:46 -0000 On Tuesday, January 29, 2013 6:17:03 pm Luigi Rizzo wrote: > On Tue, Jan 29, 2013 at 3:11 PM, Andre Oppermann wrote: > > > On 29.01.2013 18:05, John Baldwin wrote: > > > >> A common use case I have at work is to find a busted connection using > >> netstat > >> -n or sockstat and then want to tcpdrop it. However, tcpdrop requires > >> spaces > >> between the address and port so I can't simply cut and paste from one > >> terminal > >> window into another to generate the tcpdrop command. This patch adds > >> support > >> for having a decimal (netstat output) or colon (sockstat output) between > >> the > >> address and port instead of a space. It is careful to look for the last > >> of > >> these tokens to avoid parsing part of the address as the port. > >> > > > > Excellent. Can netstat be changed from decimal to colon output as well? > > The decimal output is completely outdated and probably from a time when > > not even dinosaurs were [created|evolved] yet. Colon output for port > > numbers is *the* standard all around. I'd be nervous about breaking scripts if we change the netstat output. Also, in the case of IPv6 the period is actually better than the colon for readability. > i was going to say i'd really love to have the parsing code in some kind of > library function. I find myself writing this code again and again (and > presumably > i am not the only one) each time with new bugs and features... > > i know that non-standard library functions are a pain when porting software > (see humanize_* stuff) but better than duplication. Actually, if we had a reverse version of either strspn or strpbrk then it would be trivial to write this. -- John Baldwin