Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > Expanding IPv6 address using inet_pton

Reply
Thread Tools

Expanding IPv6 address using inet_pton

 
 
Roxy Natal
Guest
Posts: n/a
 
      12-06-2011
hello every body,

My name is roxy and i am from brazil.I want to expand IPv6 address
using inet_pton().After
that I 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.

#include "stdafx.h"
#include "string.h"
#include "stdlib.h"
#include "conio.h"
#include "arpa/inet.h"
#include "inet/ip6.h"



int main(int argc, char argv[])
{

struct in6_addr {
unsigned char s6_addr[16]; // IPv6 address
};
struct in6_addr ipv6;
char str[]="abcd:1234::ffff";
if(strcnt(str,":")>1)
{


if(inet_pton(AF_INET6,str,&ipv6.s6_addr))
printf("%s is

%0llu(IPv6)\n",str,ipv6.s6_addr);
else
printf("Error..");
}

getch();

return 0;

}
 
Reply With Quote
 
 
 
 
Ben Bacarisse
Guest
Posts: n/a
 
      12-06-2011
Roxy Natal <> writes:

> My name is roxy and i am from brazil.I want to expand IPv6 address
> using inet_pton().After
> that I increment the address by 1 using C code.


There have been a few similar questions posted here recently. Can you
tell us how this problem came up? It is in some commonly used textbook?
Some on-line tutorial?

You make quite a few of the same mistakes as the other posters, so
you could start by finding the previous threads a reading the replies
given there.

Rather the repeat lots of stuff, I'll make only one remark about your
code:

<snip>
> struct in6_addr {
> unsigned char s6_addr[16]; // IPv6 address
> };
> struct in6_addr ipv6;


<snip>
> printf("%s is
>
> %0llu(IPv6)\n",str,ipv6.s6_addr);


Where did you get the idea of printing an array of 16 unsigned chars
using the llu format?

<snip>
--
Ben.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Question : inet_pton joao C Programming 3 12-07-2011 10:48 PM
inet_pton problem in C Neha Jain C Programming 2 12-02-2011 02:35 PM
Ipv6 on a ipv4/ipv6 hostname Jesse van den Kieboom Ruby 1 06-05-2005 12:57 PM
ipv6 - which source address to use? wd VOIP 1 07-04-2003 11:12 AM
ipv6 - which source address to use? wd Cisco 1 07-04-2003 11:12 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57