[FFmpeg-devel] [RFC] libavformat: URL reassembly with IPv6 addresses
Martin Storsjö
martin
Fri Feb 26 20:24:07 CET 2010
Hi,
On Fri, 26 Feb 2010, Ronald S. Bultje wrote:
> On Fri, Feb 26, 2010 at 12:49 PM, Martin Storsj? <martin at martin.st> wrote:
> > 3) Add a separate function for appending a properly escaped hostname to a
> > URL. This feels the cleanest to me, but requires a bit more changes to all
> > the current occurrances of snprintf assembly of URLs, splitting out the
> > "append the hostname" part from each case. The function could look
> > something like this:
> >
> > void url_host_cat(char *str, int size, const char *hostname)
> > {
> > ? ?if (strchr(hostname, ':')) {
>
> You can use getaddrinfo() with a flag of NUMERICONLY and then check
> the return value's address type here. This is only defined for IPv6
> addresses, not for anything else crazy like people adding random input
> into this function. In fact, we should error out here.
Ah, good idea.
> > ? ? ? ?av_strlcat(str, "[", size);
> > ? ? ? ?av_strlcat(str, hostname, size);
> > ? ? ? ?av_strlcat(str, "]", size);
> > ? ?} else {
> > ? ? ? ?av_strlcat(str, hostname, size);
> > ? ?}
> > }
>
> I'd favour this, and then use it only in places where it matters.
Ok, so what about the attached patch? Is using the url_ prefix good
enough, or should we add av_ to new public functions like this one? Or
should it go into some libavformat-internal header (network.h or something
similar?), with an ff_ prefix?
> Oh, and yes, I fixed url_split() for this years ago, and then tried
> gradually adding IPv6 support into FFmpeg and failed miserably, so
> thanks again for taking over successfully. :-).
Ah, I see. Actually, there isn't very much left for making it work
properly for most protocols. :-)
// Martin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: url_host_cat.patch
Type: text/x-diff
Size: 2028 bytes
Desc:
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20100226/a52cb54e/attachment.patch>
More information about the ffmpeg-devel
mailing list