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: |
Steve DiBenedetto | ca53ac6 | 2014-03-27 19:58:40 -0600 | [diff] [blame] | 20 | |
Davide Pesavento | 248d6bd | 2014-03-09 10:24:08 +0100 | [diff] [blame] | 21 | int index; |
| 22 | std::string name; |
| 23 | ethernet::Address etherAddress; |
| 24 | std::vector<boost::asio::ip::address_v4> ipv4Addresses; |
| 25 | std::vector<boost::asio::ip::address_v6> ipv6Addresses; |
Steve DiBenedetto | ca53ac6 | 2014-03-27 19:58:40 -0600 | [diff] [blame] | 26 | boost::asio::ip::address_v4 broadcastAddress; |
Davide Pesavento | 248d6bd | 2014-03-09 10:24:08 +0100 | [diff] [blame] | 27 | unsigned int flags; |
| 28 | |
| 29 | bool |
| 30 | isLoopback() const; |
| 31 | |
| 32 | bool |
| 33 | isMulticastCapable() const; |
| 34 | |
| 35 | bool |
Steve DiBenedetto | ca53ac6 | 2014-03-27 19:58:40 -0600 | [diff] [blame] | 36 | isBroadcastCapable() const; |
| 37 | |
| 38 | bool |
Davide Pesavento | 248d6bd | 2014-03-09 10:24:08 +0100 | [diff] [blame] | 39 | isUp() const; |
Steve DiBenedetto | ca53ac6 | 2014-03-27 19:58:40 -0600 | [diff] [blame] | 40 | |
Davide Pesavento | 248d6bd | 2014-03-09 10:24:08 +0100 | [diff] [blame] | 41 | }; |
| 42 | |
| 43 | inline bool |
| 44 | NetworkInterfaceInfo::isLoopback() const |
| 45 | { |
| 46 | return (flags & IFF_LOOPBACK) != 0; |
| 47 | } |
| 48 | |
| 49 | inline bool |
| 50 | NetworkInterfaceInfo::isMulticastCapable() const |
| 51 | { |
| 52 | return (flags & IFF_MULTICAST) != 0; |
| 53 | } |
| 54 | |
| 55 | inline bool |
Steve DiBenedetto | ca53ac6 | 2014-03-27 19:58:40 -0600 | [diff] [blame] | 56 | NetworkInterfaceInfo::isBroadcastCapable() const |
| 57 | { |
| 58 | return (flags & IFF_BROADCAST) != 0; |
| 59 | } |
| 60 | |
| 61 | inline bool |
Davide Pesavento | 248d6bd | 2014-03-09 10:24:08 +0100 | [diff] [blame] | 62 | NetworkInterfaceInfo::isUp() const |
| 63 | { |
| 64 | return (flags & IFF_UP) != 0; |
| 65 | } |
| 66 | |
| 67 | std::list< shared_ptr<NetworkInterfaceInfo> > |
| 68 | listNetworkInterfaces(); |
| 69 | |
| 70 | } // namespace nfd |
| 71 | |
| 72 | #endif // NFD_CORE_NETWORK_INTERFACE_HPP |