Question about programming (a little off-topic)

Eddie Kohler kohler at icir.org
Wed Dec 18 01:15:38 EST 2002


> In an element I'm doing, I have a IPv4-compatible IPv6 address, but in it's hex representation,
> for example: 
> the address ::192.168.1.3 I have it in hex as ::c0a8:0103. 
> 
> c0 is 192, a8 is 168 and so on...
> 
> What I need to do i to extract the IPv4 address from that hex
> representation. THe addresses are strings. How can I convert the string for
> example, "c0" to it's decimal representation (192)?

Hey,

I would just use cp_ip6_address() to parse the hex representation (which is
a legal spelling of that address), then extract the IPv4 address using the
bool IP6Address::ip4_address(IPAddress &) function, then print the
IPAddress in the usual way (with IPAddress::unparse() or operator
<<(StringAccum&, IPAddress)).

Eddie




More information about the click mailing list