Date: Tue, 6 Nov 2001 15:57:32 -0600 (CST) From: Jonathan Lemon <jlemon@flugsvamp.com> To: wollman@khavrinen.lcs.mit.edu, net@freebsd.org Subject: Re: Results from RTM_GET on route socket ? Message-ID: <200111062157.fA6LvWl99029@prism.flugsvamp.com> In-Reply-To: <local.mail.freebsd-net/200111062103.fA6L3II11868@khavrinen.lcs.mit.edu> References: <local.mail.freebsd-net/20011106075451.E34308@rose.niw.com.au> <local.mail.freebsd-net/200111052156.fA5Lutl92439@khavrinen.lcs.mit.edu> <local.mail.freebsd-net/20011106115119.L34308@rose.niw.com.au>
next in thread | previous in thread | raw e-mail | index | archive | help
In article <local.mail.freebsd-net/200111062103.fA6L3II11868@khavrinen.lcs.mit.edu> you write: ><<On Tue, 6 Nov 2001 11:51:20 +1030, Ian West <ian@niw.com.au> 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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200111062157.fA6LvWl99029>