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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T05:55:22+00:00 2026-06-03T05:55:22+00:00

Sorry, the title maybe be confuse. For example, eth1 substitute for br100. so ipv4

  • 0

Sorry, the title maybe be confuse.
For example, eth1 substitute for br100.
so ipv4 address of the eth1 is NULL.

/etc/networks/interfaces

br100 Link encap:Ethernet HWaddr 00:0c:29:75:e2:0a
inet addr:192.168.11.249 Bcast:192.168.11.255 Mask:255.255.255.0 inet6 addr: fe80::20c:29ff:fe75:e20a/64 Scope:Link

eth1 Link encap:Ethernet HWaddr 00:0c:29:75:e2:0a
inet6 addr: fe80::20c:29ff:fe75:e20a/64 Scope:Link

How can I do to read NULL value when I getting ipv4 of the eth1?

Here is my getipv4 function:

sIPv4 = new string[giIfaceCount];
struct ifaddrs *ifAddrStruct;
struct ifaddrs *ifa;
void *tmpAddrPtr;
if (getifaddrs(&ifAddrStruct) == -1)
{
    perror("getifaddrs");
    exit(1);
}
int iFlag4 = 0;
for (ifa = ifAddrStruct; ifa != NULL; ifa = ifa->ifa_next)
{
    if (ifa->ifa_addr->sa_family == AF_INET)
    {
        tmpAddrPtr=&((struct sockaddr_in *)ifa->ifa_addr)->sin_addr;
        char addressBuffer[1024];
        if (strcmp(inet_ntop(AF_INET, tmpAddrPtr, addressBuffer, 1024),"NULL") == 0)
        {
            cout << "addressBuffer = NULL" << endl;
        }
        else
        {
            inet_ntop(AF_INET, tmpAddrPtr, addressBuffer, 1024);
            if (strcmp(ifa->ifa_name,"lo") == 0)
            {
                continue;
            }
            else
            {
                *(sIPv4+iFlag4) = addressBuffer;
                testIPv4.append(addressBuffer);
                testIPv4.append(" ");
                iFlag4 = iFlag4+1;
            }
        }
    }
}
  • 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-06-03T05:55:24+00:00Added an answer on June 3, 2026 at 5:55 am

    Thanks to guys, I have already solved my problem.

    In brief, I had combined all functions(about getIPv4, getMAC, getIPv6…) into getHostinfo function.
    Then, It one by one got host information through a for loop(Interface Count).

    Finally, I greatly appreciated all guys. ^__^

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

Sidebar

Related Questions

Sorry for the title i will put here an example of what i want
Sorry the title isn't clear enough. I don't know how to express it, but
Sorry the title is not very clear. This is a follow up to my
Sorry the title's so convoluted... I must've tried for ten minutes to get a
Sorry if the title is not clear enough, I have <a> elements with the
sorry if the title is worded oddly, not really sure how to say it.
Sorry for the title, it's a hard issue to summarise. At the moment, I
Sorry if the title is misleading, but I really couldn't think of anything better.
Sorry if the title doesn't make sense. Basically I have a series of strings
Sorry about the title, I couldn't think of a better way to describe the

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.