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 about the title — wasn’t sure how to word it. Basically I have
Sorry if that title didn't explain it well. Here is the table... (source: alexanderdickson.com
I am sorry for possible misleading about the title, but I have no idea
Sorry for the non-descript title, but I'm having a hard way with words right
Sorry for the confusing title. Let me explain via code: #include <string> #include <boost\function.hpp>
Sorry about the title, couldn't really think of anything else to describe the problem
Sorry the title is not very descriptive but it is a tricky problem to
Sorry the title is very vague. Basically, I'm stuck with something. I have an
So I'm sorry the title is so vague I'm not really even sure how

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.