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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T00:10:25+00:00 2026-05-30T00:10:25+00:00

I want to convert the source & destination IP addresses from a packet captured

  • 0

I want to convert the source & destination IP addresses from a packet captured using netfilter to char *.

In my netfilter hook function, I have:

sock_buff = skb; // argument 2 of hook function

// ip_header is struct iphdr*
ip_header = (struct iphdr *)skb_network_header(sock_buff);

// now how to convert ip_header->saddr & ip_header->daddr to char *
// ip_header->saddr & ip_header->daddr are of type __be32

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-30T00:10:27+00:00Added an answer on May 30, 2026 at 12:10 am

    The kernel’s family of printf() functions has a special format specifier for IP-addresses (%pI4 for IPv4-addresses, %pI6 for IPv6).

    So with IPv4, you could use something like:

    char source[16];
    snprintf(source, 16, "%pI4", &ip_header->saddr); // Mind the &!
    

    Or write to dynamically allocated memory.

    If you simply want to print debug-output, you can also use printk(). For the many other features of %p, see this document.

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

Sidebar

Related Questions

I want to convert from char representing a hexadecimal value (in upper or lower
I have some VB source code and want to convert it to Delphi: Do
i want to convert an utf-8 encoded web page source code downloaded using InternetReadFile
Starting from a hex source, i want to convert it to a-zA-Z0-9 . base_convert()
I want to convert a std::string to lowercase. I am aware of the function
I want to convert a video to flv format. I am using ffmpeg to
I have some source code file which has mixed tabs/spaces and I want to
I have two words: Source: John ConvertTo: Jack and I want to show the
I'd like to extract the text from an HTML file using Python. I want
Download source code here: http://www.eyeClaxton.com/download/delphi/ColorSwap.zip Yes, I want to convert something mostly blue to

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.