Project

General

Profile

Actions

Task #1306

closed

Enumerate NICs

Added by Junxiao Shi over 10 years ago. Updated over 10 years ago.

Status:
Closed
Priority:
High
Category:
Faces
Target version:
Start date:
Due date:
% Done:

100%

Estimated time:
3.00 h

Description

Develop a function to enumerate Network Interface Cards (NICs) on a system.

This function should return a collection of records each representing an NIC, which contains:

  • NIC name, such as "eth0" or "en0"
  • zero or more IPv4 addresses
  • zero or more IPv6 addresses
  • zero or one Ethernet address
  • whether the NIC is multicast capable
  • whether the NIC is up/active

This function must not rely on libpcap.


Related issues 1 (0 open1 closed)

Blocks NFD - Task #1195: FaceManagerClosed

Actions
Actions #1

Updated by Davide Pesavento over 10 years ago

Junxiao Shi wrote:

  • zero or one Ethernet address

zero? are you referring to the loopback interface? do you want to enumerate that one too? if so, I think there should be a flag indicating whether an interface is loopback or not.

Actions #2

Updated by Junxiao Shi over 10 years ago

  • Category set to Faces
  • Assignee set to Davide Pesavento
  • Target version set to v0.1
  • Start date deleted (02/28/2014)
Actions #3

Updated by Junxiao Shi over 10 years ago

  • Priority changed from Normal to High

Every NIC should be returned. It's FaceManager's decision on how to use the results.

Actions #4

Updated by Davide Pesavento over 10 years ago

What's the method signature? something like static std::list findAllInterfaces() ?
What class does it belong to?

Actions #5

Updated by Davide Pesavento over 10 years ago

Sorry, I mean static std::list<NetworkInterface*> findAllInterfaces()

or do you prefer "device" instead of "interface"?

Actions #6

Updated by Junxiao Shi over 10 years ago

I suggest:

class NicInfo
{
public:
  std::string m_name;
  std::vector<boost::asio::ip::address_v4> m_ipv4Addresses;
  std::vector<boost::asio::ip::address_v6> m_ipv6Addresses;
  std::vector<uint8_t[6]> m_etherAddresses;
  bool m_isMulticastCapable;
  bool m_isUp;
};
std::list<NicInfo> listNetworkInterfaceCards();

"NIC" is a common acronym similar to "DVD" example in rule 9, and is not a violation of rule 27.

class NicInfo is a pure data structure so it's fine to have public fields, which is an exemption permitted in rule 48.

The function listNetworkInterfaceCards is a free function that doesn't belong to any class. "list" is a verb, so the function name doesn't violate rule 7.

@Alex should decide which type to use for addresses:

  • sockaddr_in, sockaddr_in6, sockaddr_ll
    • sockaddr_ll is not available on OS X but could be declared in code
  • string
  • boost::asio address for IP, uint8_t[6] for Ethernet
Actions #7

Updated by Davide Pesavento over 10 years ago

I don't like the term "card" in NIC because it somewhat implies a physical piece of hardware, while an interface could be virtual. As a matter of fact, Linux uses the term "netdev".

Btw, for MAC addresses we already have nfd::ethernet::Address.

Actions #8

Updated by Davide Pesavento over 10 years ago

  • Status changed from New to Code review
  • % Done changed from 0 to 80
Actions #9

Updated by Davide Pesavento over 10 years ago

  • % Done changed from 80 to 100
Actions #10

Updated by Junxiao Shi over 10 years ago

  • Status changed from Code review to Closed
Actions

Also available in: Atom PDF