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 6945209
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T13:24:24+00:00 2026-05-27T13:24:24+00:00

Do you know any way to print in readable format an ipv6 address and

  • 0

Do you know any way to print in readable format an ipv6 address and its port from the inet_sock struct?
My question has two parts. One is which are the structure members that have this information and the second is how to print them in readable format.

Thanks!

  • 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-27T13:24:25+00:00Added an answer on May 27, 2026 at 1:24 pm

    printk has new modifiers which help printing inet addresses (I think since kernel 2.6.24). So you can try several ways, as an example:

    //destination address
    printk("%pI6 %d\n", my_inet_socket->pinet6->daddr, 
                        ntohs(my_inet_socket->inet_dport));
    //source address
    printk("%pI6 %d\n", my_inet_socket->pinet6->saddr, 
                        ntohs(my_inet_socket->inet_sport));
    

    Here’s how many modifiers you have and how they print the IPv6 address. You can check http://www.kernel.org/doc/Documentation/printk-formats.txt for more info.

    %pI6 0001:0002:0003:0004:0005:0006:0007:0008
    %pi6 00010002000300040005000600070008
    %pI6c 1:2:3:4:5:6:7:8
    

    For older kernels you need to use NIP6 like this:

    //destination address
    printk(NIP6_FMT " %d\n", NIP6(my_inet_socket->pinet6->daddr), 
                             ntohs(my_inet_socket->inet_dport));
    //source address
    printk(NIP6_FMT " %d\n", NIP6(my_inet_socket->pinet6->saddr), 
                             ntohs(my_inet_socket->inet_sport));
    

    As a last note, you can check net/ipv6/tcp_ipv6.c from the kernel itself. It has tons of examples. Hope this helps you

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

Sidebar

Related Questions

I would like to know if there is any easy way to print multiple
Does anyone know any simple way to retrieve the country from a given IP
How should i know at print server whether any client has fire any command.
What's the best way to print from MySQL using PHP when you know there's
Does anyone know of any way to convert a simple gif to xaml? E.G.
Do you know of any way to reference an object in the replacement part
Do you know any easy way to find a logging call that throws not
Do you know any elegant way to achieve this in ruby plz ? string
just curious if you know of any way to setup a drag boundary for
By default nunit tests run alphabetically. Does anyone know of any way to set

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.