Davide Pesavento | 248d6bd | 2014-03-09 10:24:08 +0100 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 | /** |
Alexander Afanasyev | 9bcbc7c | 2014-04-06 19:37:37 -0700 | [diff] [blame] | 3 | * Copyright (c) 2014 Regents of the University of California, |
| 4 | * Arizona Board of Regents, |
| 5 | * Colorado State University, |
| 6 | * University Pierre & Marie Curie, Sorbonne University, |
| 7 | * Washington University in St. Louis, |
| 8 | * Beijing Institute of Technology |
| 9 | * |
| 10 | * This file is part of NFD (Named Data Networking Forwarding Daemon). |
| 11 | * See AUTHORS.md for complete list of NFD authors and contributors. |
| 12 | * |
| 13 | * NFD is free software: you can redistribute it and/or modify it under the terms |
| 14 | * of the GNU General Public License as published by the Free Software Foundation, |
| 15 | * either version 3 of the License, or (at your option) any later version. |
| 16 | * |
| 17 | * NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; |
| 18 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
| 19 | * PURPOSE. See the GNU General Public License for more details. |
| 20 | * |
| 21 | * You should have received a copy of the GNU General Public License along with |
| 22 | * NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>. |
| 23 | **/ |
Davide Pesavento | 248d6bd | 2014-03-09 10:24:08 +0100 | [diff] [blame] | 24 | |
| 25 | #ifndef NFD_CORE_NETWORK_INTERFACE_HPP |
| 26 | #define NFD_CORE_NETWORK_INTERFACE_HPP |
| 27 | |
| 28 | #include "common.hpp" |
Alexander Afanasyev | 613e2a9 | 2014-04-15 13:36:58 -0700 | [diff] [blame] | 29 | #include "ethernet.hpp" |
Davide Pesavento | 248d6bd | 2014-03-09 10:24:08 +0100 | [diff] [blame] | 30 | |
| 31 | #include <net/if.h> |
| 32 | |
| 33 | namespace nfd { |
| 34 | |
| 35 | class NetworkInterfaceInfo |
| 36 | { |
| 37 | public: |
Steve DiBenedetto | ca53ac6 | 2014-03-27 19:58:40 -0600 | [diff] [blame] | 38 | |
Davide Pesavento | 248d6bd | 2014-03-09 10:24:08 +0100 | [diff] [blame] | 39 | int index; |
| 40 | std::string name; |
| 41 | ethernet::Address etherAddress; |
| 42 | std::vector<boost::asio::ip::address_v4> ipv4Addresses; |
| 43 | std::vector<boost::asio::ip::address_v6> ipv6Addresses; |
Steve DiBenedetto | ca53ac6 | 2014-03-27 19:58:40 -0600 | [diff] [blame] | 44 | boost::asio::ip::address_v4 broadcastAddress; |
Davide Pesavento | 248d6bd | 2014-03-09 10:24:08 +0100 | [diff] [blame] | 45 | unsigned int flags; |
| 46 | |
| 47 | bool |
| 48 | isLoopback() const; |
| 49 | |
| 50 | bool |
| 51 | isMulticastCapable() const; |
| 52 | |
| 53 | bool |
Steve DiBenedetto | ca53ac6 | 2014-03-27 19:58:40 -0600 | [diff] [blame] | 54 | isBroadcastCapable() const; |
| 55 | |
| 56 | bool |
Davide Pesavento | 248d6bd | 2014-03-09 10:24:08 +0100 | [diff] [blame] | 57 | isUp() const; |
Steve DiBenedetto | ca53ac6 | 2014-03-27 19:58:40 -0600 | [diff] [blame] | 58 | |
Davide Pesavento | 248d6bd | 2014-03-09 10:24:08 +0100 | [diff] [blame] | 59 | }; |
| 60 | |
| 61 | inline bool |
| 62 | NetworkInterfaceInfo::isLoopback() const |
| 63 | { |
| 64 | return (flags & IFF_LOOPBACK) != 0; |
| 65 | } |
| 66 | |
| 67 | inline bool |
| 68 | NetworkInterfaceInfo::isMulticastCapable() const |
| 69 | { |
| 70 | return (flags & IFF_MULTICAST) != 0; |
| 71 | } |
| 72 | |
| 73 | inline bool |
Steve DiBenedetto | ca53ac6 | 2014-03-27 19:58:40 -0600 | [diff] [blame] | 74 | NetworkInterfaceInfo::isBroadcastCapable() const |
| 75 | { |
| 76 | return (flags & IFF_BROADCAST) != 0; |
| 77 | } |
| 78 | |
| 79 | inline bool |
Davide Pesavento | 248d6bd | 2014-03-09 10:24:08 +0100 | [diff] [blame] | 80 | NetworkInterfaceInfo::isUp() const |
| 81 | { |
| 82 | return (flags & IFF_UP) != 0; |
| 83 | } |
| 84 | |
| 85 | std::list< shared_ptr<NetworkInterfaceInfo> > |
| 86 | listNetworkInterfaces(); |
| 87 | |
| 88 | } // namespace nfd |
| 89 | |
| 90 | #endif // NFD_CORE_NETWORK_INTERFACE_HPP |