From owner-freebsd-net@FreeBSD.ORG Fri Oct 26 08:34:45 2012 Return-Path: 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 D7C56AC for ; Fri, 26 Oct 2012 08:34:45 +0000 (UTC) (envelope-from simon@comsys.ntu-kpi.kiev.ua) Received: from comsys.kpi.ua (comsys.kpi.ua [77.47.192.42]) by mx1.freebsd.org (Postfix) with ESMTP id 848A28FC0A for ; Fri, 26 Oct 2012 08:34:45 +0000 (UTC) Received: from pm513-1.comsys.kpi.ua ([10.18.52.101] helo=pm513-1.comsys.ntu-kpi.kiev.ua) by comsys.kpi.ua with esmtpsa (TLSv1:AES256-SHA:256) (Exim 4.63) (envelope-from ) id 1TRfNL-0001KA-Ex for freebsd-net@freebsd.org; Fri, 26 Oct 2012 11:34:43 +0300 Received: by pm513-1.comsys.ntu-kpi.kiev.ua (Postfix, from userid 1001) id 01C141CC1E; Fri, 26 Oct 2012 11:34:42 +0300 (EEST) Date: Fri, 26 Oct 2012 11:34:42 +0300 From: Andrey Simonenko To: freebsd-net@freebsd.org Subject: getnetent(3) return values for incorrect IPv4 network addresses Message-ID: <20121026083442.GA20882@pm513-1.comsys.ntu-kpi.kiev.ua> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-Authenticated-User: simon@comsys.ntu-kpi.kiev.ua X-Authenticator: plain X-Sender-Verify: SUCCEEDED (sender exists & accepts mail) X-Exim-Version: 4.63 (build at 28-Apr-2011 07:11:12) X-Date: 2012-10-26 11:34:43 X-Connected-IP: 10.18.52.101:48047 X-Message-Linecount: 29 X-Body-Linecount: 17 X-Message-Size: 1127 X-Body-Size: 612 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: Fri, 26 Oct 2012 08:34:45 -0000 There is one feature of getnetent(3) that is not documented and is not checked by applications that use getnetent(3) or similar functions. If an IPv4 network address is specified incorrectly in the networks(5) database, then the n_net field from the struct netent{} is set to INADDR_NONE. This is done by the inet_network(3) function that is used for network address translation. Should this property of getnetent(3) be documented in its manual page to make such behaviour of getnetent(3) official? Example: % grep abc /etc/networks abc 1. % getent networks abc abc 255.255.255.255