LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 06-19-2006, 12:01 AM   #1
hegdeshashi
Member
 
Registered: Dec 2005
Posts: 73
Blog Entries: 3

Rep: Reputation: 15
IPv6 address ?????????


Hi,


To check IPv4 address, we are having inet_addr().
For IPv6 address ?

I want to check IPv6 address ,after entring manually....

any help?????????
 
Old 06-19-2006, 01:04 AM   #2
elluva
Member
 
Registered: Aug 2003
Location: Belguim, Ostend and Ghent
Distribution: Ubuntu
Posts: 600

Rep: Reputation: 30
This comes from the libc manual,
Code:
#include <arpa/inet.h>

  -- Function: int inet_pton (int AF, const char *CP, void *BUF)
      This function converts an Internet address (either IPv4 or IPv6)
      from presentation (textual) to network (binary) format.  AF should
      be either `AF_INET' or `AF_INET6', as appropriate for the type of
      address being converted.  CP is a pointer to the input string, and
      BUF is a pointer to a buffer for the result.  It is the caller's
      responsibility to make sure the buffer is large enough.
 
Old 06-19-2006, 01:38 AM   #3
hegdeshashi
Member
 
Registered: Dec 2005
Posts: 73

Original Poster
Blog Entries: 3

Rep: Reputation: 15
Hi,


I am entring ipv6 address manually...

I want to check like inet_addr(ipaddr)...


how can I use this one?
 
Old 06-19-2006, 03:13 AM   #4
elluva
Member
 
Registered: Aug 2003
Location: Belguim, Ostend and Ghent
Distribution: Ubuntu
Posts: 600

Rep: Reputation: 30
Just like the docs say, I included a minimal example. When all goes well, 0 is returned, else -1 is returned.

Code:
struct in6_addr output;
char* input;

// READ THE INPUTSTRING INTO INPUT

if(inet_pton(AF_INET6, input, &output)) //Parse input to a binary IPv6 address in output.
{
  perror(0);
  exit(1);
}; 
// use your binary IPv6 address called output
 
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
problem with 1111::xxxx ipv6 address fssengg Linux - Networking 0 09-01-2005 03:29 AM
getting IPv6 address lacitpo Linux - Networking 1 03-18-2005 11:09 AM
Can't assign a static IPv6 address guzo Linux - Networking 0 02-11-2005 06:22 AM
how to get ipv6 address from socketaddr_in6? walkant Linux - Networking 0 11-07-2004 08:47 PM
IPv6 anycast address assignment harpal Linux - Networking 0 04-27-2003 12:47 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:22 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration