[FFmpeg-devel] [PATCH] IPv6 support v.2

Nicolas George nicolas.george
Thu Nov 8 19:41:33 CET 2007


L'octidi 18 brumaire, an CCXVI, Ronald S. Bultje a ?crit?:
> I added flags to force that already, see AV_RESOLVE_IPV[46]ONLY.

I do not like that interface: that means that the caller has to set the
correct AV_* flag according to the AF_* value. Which implies it knows the
mapping between all possible AF_* and AV_RESOLVE_*ONLY. That breaks protocol
independence.

> No, the offset is the same for IPv4 and IPv6.

There is absolutely no guarantee of that in any standard that I know.
Relying on it would make the code quite fragile.

Something like:

	*(a->family == AF_INET ?
	  &((struct sockaddr_in *) a->addr)->sin_port :
	  &((struct sockaddr_in6 *) a->addr)->sin6_port)

would probably be much more reliable.

But doing it as a macro would require that the caller has all the necessary
headers. I think I would be more at ease with get_port and set_port macros.

> The offset of the address from the data in the sockaddr_in and sockaddr_in6
> struct. In both cases, there's a 16-bit port number, but after that, the
> address follows directly in the sockaddr_in structure, whereas there's
> another 32 bits in between for sockaddr_in6. Hence the different offset for
> IPv4 and IPv6.

Again, hardcoding the offset of a structure member does not seem a sane way
of coding to me.

But I am wondering: what could the caller possibly do with just the address,
like that? To do something useful with the address, it would require at
least its size, and again, that breaks protocol independence.

Regards,

-- 
  Nicolas George




More information about the ffmpeg-devel mailing list