Thread: Expanding IPv6 address using inet_pton

  1. #1
    Registered User
    Join Date
    Dec 2011
    Posts
    4

    Expanding IPv6 address using inet_pton

    hello every body,
    My name is roxy and i am from brazil.I want to expand IPv6 address using inet_pton().After that increment the address by 1 using C code.If my address is - 1234:12::ffff then after expand it will be 1234:0012:0000:0000:0000:0000:0000:ffff
    When I increment the address it will display - 1234:0012:0000:0000:0000:0000:0001:0000
    Whenever it will reaches ffff it just put 0x0000 and increment the next value by 1.
    I already done some code part(not the increment part).Please help me in this matter.
    Please find the attach docs.
    Attached Files Attached Files

  2. #2
    Registered User
    Join Date
    Oct 2011
    Location
    Denmark
    Posts
    80
    First I really doubt that you are using Linux because of the "conio.h", but well. Then why are you redefining the "struct in6_addr"?

    For expanding the IPV6 address, after some googling you should find that :

    Code:
    sprintf(buf, "%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x",
                     (int)ipv6.s6_addr[0], (int)ipv6.s6_addr[1],
                     (int)ipv6.s6_addr[2], (int)ipv6.s6_addr[3],
                     (int)ipv6.s6_addr[4], (int)ipv6.s6_addr[5],
                     (int)ipv6.s6_addr[6], (int)ipv6.s6_addr[7],
                     (int)ipv6.s6_addr[8], (int)ipv6.s6_addr[9],
                     (int)ipv6.s6_addr[10], (int)ipv6.s6_addr[11],
                     (int)ipv6.s6_addr[12], (int)ipv6.s6_addr[13],
                     (int)ipv6.s6_addr[14], (int)ipv6.s6_addr[15]);
    I guess that then for the incrementation you can use the in6_addr struct also, for example you start by incrementing the last part of the address, and if it gives 0 then you increment the next one...

  3. #3
    Registered User
    Join Date
    Dec 2011
    Posts
    4

    Expanding IPv6 address using inet_pton

    where is inet_pton() related function?
    My IPv6 address is -

    2001:db8:8714:3a90::ff.I want to increment by 1,so the resultant is 2001:db8:8714:3a90::0001:0000

    My code is attach with this mail.

    But shows an error - add_ipv6.c:11:25: error: âaddress_stringâ undeclared (first use in this function)

    Can any body help me?
    Attached Files Attached Files

  4. #4
    Registered User
    Join Date
    Dec 2011
    Posts
    4

    Expanding IPv6 address using inet_pton

    Thanks every body....Solve the problem.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Expanding IPv6 address using inet_pton
    By roxynatal in forum C Programming
    Replies: 3
    Last Post: 12-07-2011, 03:23 AM
  2. IPv6 address increment
    By JNeha in forum C Programming
    Replies: 2
    Last Post: 11-30-2011, 11:42 AM
  3. error C2065: 'inet_pton' : undeclared identifier - ipv6
    By WeberGer in forum Networking/Device Communication
    Replies: 2
    Last Post: 01-14-2010, 11:38 AM
  4. IPv6 Address
    By sarathius in forum Networking/Device Communication
    Replies: 8
    Last Post: 03-02-2008, 05:52 AM
  5. Replies: 1
    Last Post: 04-05-2003, 08:39 AM