Global (non _KERNEL) place for sockaddr_union?

Bruce M Simpson bms at spc.org
Tue Sep 21 03:02:26 PDT 2004


On Mon, Sep 20, 2004 at 02:50:40AM +0200, Max Laier wrote:
> My question now is, what would be a good place to define this? Are there any 
> fromal standarts that might define it already? (Couldn't find anything) Is 
> there anything else that I must consider?

I think Brooks' recommendation is sound and should probably be followed
as it's fairly close to my original recommendation to you in private.

The problem is that the definition of the union depends on what you wish
to use it for, and which address families are visible to the application
or kernel module which is using the definition.

You may find that such a definition has to have conditionalized members.
This is usually not a problem so long as they are all the same size. And
a sockaddr union embedded in a struct probably should have a member with
type 'struct sockaddr_storage' if it's to support all address families
in future, although this commits more storage in the enclosing struct
and may waste space in some cases.

As you point out, you cannot do this in pf, as it defeats the intent of
keeping larger members out of the table in the first place, and the union
is there to make some casts go away.

If it's any consolation, I'm going through very similar pain with XORP's
new firewall manager right now with respect to address families (and
templatized C++ classes).

Regards,
BMS
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 167 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-hackers/attachments/20040921/08485b8b/attachment.bin


More information about the freebsd-hackers mailing list