From mboxrd@z Thu Jan 1 00:00:00 1970 From: Joe Perches Subject: Re: [PATCH net-2.6.25 1/4] include - Convert IP4 address class macros to inline functions Date: Wed, 14 Nov 2007 18:09:41 -0800 Message-ID: <1195092581.27113.9.camel@localhost> References: <1195091645.27053.1.camel@localhost> Mime-Version: 1.0 Content-Type: text/plain Content-Transfer-Encoding: 7bit Cc: "Fred L. Templin" , David Miller , James Morris , Patrick McHardy , Alexey Kuznetsov , netdev , netdev-owner@vger.kernel.org, "Pekka Savola (ipv6)" , Hideaki YOSHIFUJI To: David Stevens Return-path: Received: from DSL022.labridge.com ([206.117.136.22]:2009 "EHLO perches.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751779AbXKOCLU (ORCPT ); Wed, 14 Nov 2007 21:11:20 -0500 In-Reply-To: <1195091645.27053.1.camel@localhost> Sender: netdev-owner@vger.kernel.org List-Id: netdev.vger.kernel.org Sorry, evolution died sending my mail and I didn't fully read the "recovered" mail before hitting send. Here's a more readable one. --------- On Wed, 2007-11-14 at 08:53 -0800, David Stevens wrote: > Maybe I'm more used to hex, but I personally don't think those are > more readable. It replaces 1-line macroes with 4-line functions, and > I think more vgrepping to pick out the relevant constant data. The rfcs generally use decimal octets. To me htonl(0xC0586300) isn't as readable as ip4_addr_octets(192,88,99,0) is_ip4_multicast(addr) more intelligible than MULTICAST(x). I hope to eliminate the current use of macros for ip address tests and have no new macros added. The existing macros are just for compatibility until the current code uses are converted. Fred Templin has some patches that add several more macros to in.h. I just forwarded my patches to him too. http://marc.info/?l=linux-netdev&m=119490504022261&w=2 His patch adds: +#define PRIVATE_10(x) (((x) & htonl(0xff000000)) == htonl(0x0A000000)) +#define LINKLOCAL_169(x) (((x) & htonl(0xffff0000)) == htonl(0xA9FE0000)) +#define PRIVATE_172(x) (((x) & htonl(0xfff00000)) == htonl(0xAC100000)) +#define TEST_192(x) (((x) & htonl(0xffffff00)) == htonl(0xC0000200)) +#define ANYCAST_6TO4(x) (((x) & htonl(0xffffff00)) == htonl(0xC0586300)) +#define PRIVATE_192(x) (((x) & htonl(0xffff0000)) == htonl(0xC0A80000)) +#define TEST_198(x) (((x) & htonl(0xfffe0000)) == htonl(0xC6120000)) cheers, Joe