Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1056951
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T17:47:29+00:00 2026-05-16T17:47:29+00:00

im reading the content of the file /proc/net/tcp6 and trying to transform that notation

  • 0

im reading the content of the file /proc/net/tcp6

and trying to transform that notation of ip6 into a ‘0::1’ like

previously with ipv4 y use the next method.

struct sockaddr_in tmp_ip;
char ip_str[30];
char ipex[]='00000AF0'; /*read from the file /proc/net/tcp */
tmp_ip.sin_addr.s_addr=(int)strtoll(ipex,NULL,16);
inet_ntop(AF_INET,&tmp_ip.sin_addr,ip_str,60);
printf("ip=%s \n",ip_str);

but with ipv6 the content of /proc/net/tcp6 its bigger(33 hex chars) and maybe i need to use
sockaddr_in6, but the variable sin6_addr.s6_addr is a array, not a single log unsigned int (like sin_addr.s_addr)

so in resume. i trying to pass this

0000000000000000FFFF00001F00C80A

to something like

::ffff:10.200.0.31

edit..

mmm maybe if i decompose that ex into 16 ex digits and feed the array in sin6_addr.s_addr.
Because 1F00C80A = 10.200.0.31(passing throught ntop function)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T17:47:30+00:00Added an answer on May 16, 2026 at 5:47 pm

    thanks.
    i ended doing this.

    cont_ip6=0; 
            cont=0;
            for(i=0;i<34;i++) {
                    if (cont ==2) {
                            cont=0;
                            hex_section[2]='\0';
                                    tmp_ip6.sin6_addr.s6_addr[cont_ip6]=strtol(hex_section,NULL,16);
    
                            cont_ip6++;
                    }
    
                    hex_section[cont]=ipex[i];
                    cont++;
    
            }
    

    then inet_ntop

    i fixed it.

    you need to invert every pair of hex numbers.

    ::FFFF:10.200.0.31 ended in the array like this.

    (last elements)

    FF     |FF    |   00   | 00  :  0A | C8   |   00 | 1F
    255    |255   |   0    | 0   :  10 | 200  |   0  | 31
    
    ^       ^         ^      ^   :  ^     ^       ^     ^
    |       |         |      |      |     |       |     |
    |        ---------       |      |      -------      |
     ------------------------        -------------------
    

    so you need to swap these (in each set of numbers)

    so i do this

    tmptmp=0;
    for (i=0;i<5;i++){
        tmptmp=tmp_ip6.sin6_addr.s6_addr[i*4+3];
        tmp_ip6.sin6_addr.s6_addr[i*4+3]=tmp_ip6.sin6_addr.s6_addr[i*4];
        tmp_ip6.sin6_addr.s6_addr[i*4]=tmptmp;
    
        tmptmp=tmp_ip6.sin6_addr.s6_addr[i*4+2];
        tmp_ip6.sin6_addr.s6_addr[i*4+2]=tmp_ip6.sin6_addr.s6_addr[i*4+1];
        tmp_ip6.sin6_addr.s6_addr[i*4+1]=tmptmp;
     }
    

    this swap the sets and when you do a inet_ntop it shows ::FFFF:10.200.0.31

    (i was looking for this all the day D:, my head hurts)
    (sorry for my bad english)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to read the content of a file with a StreamReader, that receives
I am reading the contents of the file using fread into an char array.
I am trying to replace strings in a word document by reading the file
I was trying out a few file reading strategies in C++ and I came
i have a problem with reading from a file, and converting content to double.
I am using the following method for reading Csv file content: /// <summary> ///
I am reading a plist file using code below. My problem is that the
I'm reading file using java. File contains € chars but java interpret it like
I am reading a file into byte array, i have inserted some control command
Possible Duplicate: Inserting PHP array into Javascript array I'm reading a file in server

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.