Davide Pesavento | 248d6bd | 2014-03-09 10:24:08 +0100 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 | /** |
| 3 | * Copyright (C) 2014 Named Data Networking Project |
| 4 | * See COPYING for copyright and distribution information. |
| 5 | */ |
| 6 | |
| 7 | #ifndef NFD_CORE_NETWORK_INTERFACE_HPP |
| 8 | #define NFD_CORE_NETWORK_INTERFACE_HPP |
| 9 | |
| 10 | #include "common.hpp" |
| 11 | #include "face/ethernet.hpp" |
| 12 | |
| 13 | #include <net/if.h> |
| 14 | |
| 15 | namespace nfd { |
| 16 | |
| 17 | class NetworkInterfaceInfo |
| 18 | { |
| 19 | public: |
| 20 | int index; |
| 21 | std::string name; |
| 22 | ethernet::Address etherAddress; |
| 23 | std::vector<boost::asio::ip::address_v4> ipv4Addresses; |
| 24 | std::vector<boost::asio::ip::address_v6> ipv6Addresses; |
| 25 | unsigned int flags; |
| 26 | |
| 27 | bool |
| 28 | isLoopback() const; |
| 29 | |
| 30 | bool |
| 31 | isMulticastCapable() const; |
| 32 | |
| 33 | bool |
| 34 | isUp() const; |
| 35 | }; |
| 36 | |
| 37 | inline bool |
| 38 | NetworkInterfaceInfo::isLoopback() const |
| 39 | { |
| 40 | return (flags & IFF_LOOPBACK) != 0; |
| 41 | } |
| 42 | |
| 43 | inline bool |
| 44 | NetworkInterfaceInfo::isMulticastCapable() const |
| 45 | { |
| 46 | return (flags & IFF_MULTICAST) != 0; |
| 47 | } |
| 48 | |
| 49 | inline bool |
| 50 | NetworkInterfaceInfo::isUp() const |
| 51 | { |
| 52 | return (flags & IFF_UP) != 0; |
| 53 | } |
| 54 | |
| 55 | std::list< shared_ptr<NetworkInterfaceInfo> > |
| 56 | listNetworkInterfaces(); |
| 57 | |
| 58 | } // namespace nfd |
| 59 | |
| 60 | #endif // NFD_CORE_NETWORK_INTERFACE_HPP |