[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Converting a string into an IPv6 address



Have a look at this. It's from /proc/net/tcp6

 54: 0180FE3F10000600FF03010229A040FE:0016 00000000000000000000000001000000:D8A6 01 00000000:00000000 02:00702712 00000000     0        0 4718609 2 fffffc000b1 9a6a0 209 40 29 2 -1          

It's basically saying the same thing as this:
tcp        0      0 3ffe:8001:6:10:201:3:22 ::1:55462 ESTABLISHED 

That's on an alpha, here is what an intel looks like:

  24: 0180FE3F10000600FF2980025921E4FE:0050 0180FE3F10000600FF03010229A040FE:D8C6 01 00000000:00000000 02:000AFB7B 00000000    33        0 3578239 2 c3d6e1a0 300 0 0 2 -1                    

What I need to do is scanf the top line to get something like the second
line.  The ports are easy, they're %x but what are the addresses?

You used to be able to use %lx but that's now gone with IPv6 addresses
and the days of using a ulong to store addresses.

The left address in the first line is supposed to be the same as the 
right address in the second, and they are despite the different
architectures.

Is there an easy way of scanf'ing this and manipulating it into a real
and useable IPv6 address?  Essentially I need to be able to go from
a IPv6 address in text form, eg "3ffe:8001:6:10:201:3" and match it
to a line.  I'm thinking inet_ntop and inet_pton could help, but
not sure how.
  
   - Craig

-- 
Craig Small VK2XLZ  GnuPG:1C1B D893 1418 2AF4 45EE  95CB C76C E5AC 12CA DFA5
Eye-Net Consulting http://www.eye-net.com.au/        <csmall@eye-net.com.au>
MIEEE <csmall@ieee.org>                 Debian developer <csmall@debian.org>



Reply to: