[FFmpeg-devel] [PATCH/RFC] Prefer getaddrinfo over gethostbyname

Ronald S. Bultje rsbultje
Tue Jan 12 18:23:50 CET 2010


Hi,

On Tue, Jan 12, 2010 at 12:21 PM, Martin Storsj? <martin at martin.st> wrote:
> On Tue, 12 Jan 2010, Ronald S. Bultje wrote:
>> So, I think the attached would be easier. RFC-2553 defines the storage
>> size to be 128, and although it may be more because of alignment, the
>> result of the attached version would always be >=128, as defined in
>> RFC-2553.
>
> I'm not sure this is guaranteed to work. As described in the same RFC,
> sockaddr may include a member "sa_len" before the sa_family member, so the
> location within sockaddr_storage would have to match that. And the size of
> sa_family isn't necessarily 16 bit. (The same RFC says that it is 16 bit
> "on most implementations", but if sa_len is present, it probably is 8 bit
> instead, but afaik, an implementation is free to layout it in any other
> way.)
>
> So I'm really at a loss for how to provide a reliable replacement for this
> struct including the correct fields.

Mac uses ss_len, which confused me for a second. len + family should
be 16 bits, and len may be zero (unset), as is the case for FFmpeg on
Mac. That still works fine. So the above should (and does) work.

I agree that it'd be nicer to include the ss_len conditionally
depending on whether it is present in sockaddr_in, but as Mans said,
FUCK THEM BASTARDS.

;-).

Ronald



More information about the ffmpeg-devel mailing list