IPv[46] parsing

Guillaume Quintard guillaume at varnish-software.com
Wed Oct 28 11:15:04 CET 2015


On Wed, Oct 28, 2015 at 10:55 AM, Poul-Henning Kamp <phk at phk.freebsd.dk>
wrote:

> --------
> In message <CAJ6ZYQwjqhjpcXEV9ef2-cX4B3MdcgCSKL15EZOkpZR=zbYP=
> Q at mail.gmail.com>
> , Guillaume Quintard writes:
>
> >I'm in favor of mandatory brackets for IPv6, but would this do ?
> >- first char is [: it's IPv6
> >- if you find a letter or colon: it's IPv6
>
> Remember that it is not just numeric formats.
>
> In general this is about what we pass to the two fields of getaddrinfo(3),
> we don't convert to IP#s ourselves.
>
>
Ah, my bad, then there's the question of how much error types we want to
raise (vss_parse catches some of them, but far from all), because it could
be as simple as:

- find first colon (fc)
- find last colon (lc)
fc == lc => ipv4 with port
fc != lc
    *(lc - 1) == ']' => IPv6 with port (and check the first char is indeed
'[')
    else IPv6 without port

-- 
Guillaume Quintard
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.varnish-cache.org/lists/pipermail/varnish-dev/attachments/20151028/b8e62e50/attachment-0001.html>


More information about the varnish-dev mailing list