Task #1306
closedEnumerate NICs
100%
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.
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.
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)
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.
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?
Updated by Davide Pesavento over 10 years ago
Sorry, I mean static std::list<NetworkInterface*> findAllInterfaces()
or do you prefer "device" instead of "interface"?
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
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.
Updated by Davide Pesavento over 10 years ago
- Status changed from New to Code review
- % Done changed from 0 to 80
Updated by Junxiao Shi over 10 years ago
- Status changed from Code review to Closed