Perhaps what you need is backtracking (i.e. you cannot deal with this using
just one character of lookhead - instead you need to guess the path to
follow and backtrack if the guess is wrong). Antlr has an architected way to
deal with such things (it is called syntactic lookhead on non-terminal
symbols).
Regards
Ranga.
--
M. Ranganathan
National Institute of Standards and Technology
Advanced Networking Technologies Division
100 Bureau Drive, Stop 8920,
Gaithersburg, MD 20899, U.S.A.
Tel:(301)975-3664 Fax:(301)590-0932
Advanced Networking Technologies For the People!
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]]On Behalf Of Jonathan
Lennox
Sent: Thursday, March 29, 2001 7:36 AM
To: [EMAIL PROTECTED]
Subject: [Sip-implementors] Parsing IPv6 addresses
Some folks here at the bakeoff have started using IPv6. While actually
*supporting* IPv6 is probably a fair ways off for us, I'd like to at least
be able to handle them correctly in placs like URIs and Via headers.
The particular URI I ran into (in a Contact header) was:
<sip:ppessi@[3ffe::200:86ff:fe46:9616]:5066;maddr=[3ffe::200:86ff:fe46:9616]
>
When we parsed it, we mangled it into
<sip:ppessi@[3ffe;maddr=%5B3ffe::200:86ff:fe46:9616%5D>
The URI-quoting in the parameter is easy enough to deal with. (RFC 2732
moves the [] characters from 'unwise' to 'reserved', so they can go in
parameters when we're printing.)
The harder part is the mangling in the 'host' part of the URI. What's
happening is that we're seeing the first : in the address, thinking it ends
the host and starts the port. We then interpret ":200:86ff:fe46:9616]:5066"
as a port, and atoi returns 0 on it.
The way the syntax works, of course, the [] encloses the IPv6 address, and
it's terminated by the closing bracket.
I can't quite figure out the best way to add this to the Parse_URI
state machine in uri.c. Somehow, I need to tell it that if you see a [
right after entering the 'host' state, then 'host' is terminated by ], not
by :. (Though for robustness it should probably still be terminated by the
other things that end a host.)
Any thoughts?
-jonathan
_______________________________________________
Sip-implementors mailing list
[EMAIL PROTECTED]
http://lists.cs.columbia.edu/mailman/listinfo/sip-implementors
_______________________________________________
Sip-implementors mailing list
[EMAIL PROTECTED]
http://lists.cs.columbia.edu/mailman/listinfo/sip-implementors