From owner-freebsd-net Tue Nov 6 13: 3:26 2001 Delivered-To: freebsd-net@freebsd.org Received: from khavrinen.lcs.mit.edu (khavrinen.lcs.mit.edu [18.24.4.193]) by hub.freebsd.org (Postfix) with ESMTP id 4D7E837B405 for ; Tue, 6 Nov 2001 13:03:23 -0800 (PST) Received: (from wollman@localhost) by khavrinen.lcs.mit.edu (8.11.4/8.11.4) id fA6L3II11868; Tue, 6 Nov 2001 16:03:18 -0500 (EST) (envelope-from wollman) Date: Tue, 6 Nov 2001 16:03:18 -0500 (EST) From: Garrett Wollman Message-Id: <200111062103.fA6L3II11868@khavrinen.lcs.mit.edu> To: Ian West Cc: freebsd-net@FreeBSD.ORG Subject: Re: Results from RTM_GET on route socket ? In-Reply-To: <20011106115119.L34308@rose.niw.com.au> References: <20011106075451.E34308@rose.niw.com.au> <200111052156.fA5Lutl92439@khavrinen.lcs.mit.edu> <20011106115119.L34308@rose.niw.com.au> Sender: owner-freebsd-net@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org < said: > Thanks for that, makes sense :-) More questions though, the following is > a response to a request for 192.168.20.1. The response is a general > subnet route, how should I interpret the mask field ? (It is actually > class C) I can't find a reference to a AF_ type for -1 or 255, but the > field is a bit small for a sockaddr_in. Netmasks are literally that: bit masks which indicate which bits (after the length) in an address are significant. All of the bits in the address family are significant, so the corresponding bits in the netmask are all ones. Your code must pad the mask out with an appropriate quantity of zero bits for the type of address being masked. Generally speaking, if `cp' points to the beginning of the mask, and `sa' points to the address which was just read: struct sockaddr *mask; socklen_t len = max(sa->sa_len, *cp); mask = malloc(len); assert(mask); memset(mask, '\0', len); memcpy(mask, cp, *cp); mask->sa_len = len; mask->sa_family = sa->sa_family; ...is the most general way, although a particular address family might have more specific requirements. -GAWollman To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-net" in the body of the message