From owner-freebsd-net Tue Nov 6 14: 2:48 2001 Delivered-To: freebsd-net@freebsd.org Received: from prism.flugsvamp.com (cb58709-a.mdsn1.wi.home.com [24.17.241.9]) by hub.freebsd.org (Postfix) with ESMTP id DF72E37B8B4 for ; Tue, 6 Nov 2001 13:57:50 -0800 (PST) Received: (from jlemon@localhost) by prism.flugsvamp.com (8.11.0/8.11.0) id fA6LvWl99029; Tue, 6 Nov 2001 15:57:32 -0600 (CST) (envelope-from jlemon) Date: Tue, 6 Nov 2001 15:57:32 -0600 (CST) From: Jonathan Lemon Message-Id: <200111062157.fA6LvWl99029@prism.flugsvamp.com> To: wollman@khavrinen.lcs.mit.edu, net@freebsd.org Subject: Re: Results from RTM_GET on route socket ? X-Newsgroups: local.mail.freebsd-net In-Reply-To: References: Organization: Cc: 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 In article you write: >< 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. On a related tangent, are there any address families that still use discontiguous netmasks, or have these gone the way of the dodo and ethernet trailer encapsulation? -- Jonathan To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-net" in the body of the message