blob: 69b8d7f8931ad011c55e395af1683eace30d12a7 [file] [log] [blame]
Davide Pesavento248d6bd2014-03-09 10:24:08 +01001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
Alexander Afanasyev9bcbc7c2014-04-06 19:37:37 -07003 * 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 Pesavento248d6bd2014-03-09 10:24:08 +010024
25#ifndef NFD_CORE_NETWORK_INTERFACE_HPP
26#define NFD_CORE_NETWORK_INTERFACE_HPP
27
28#include "common.hpp"
29#include "face/ethernet.hpp"
30
31#include <net/if.h>
32
33namespace nfd {
34
35class NetworkInterfaceInfo
36{
37public:
Steve DiBenedettoca53ac62014-03-27 19:58:40 -060038
Davide Pesavento248d6bd2014-03-09 10:24:08 +010039 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 DiBenedettoca53ac62014-03-27 19:58:40 -060044 boost::asio::ip::address_v4 broadcastAddress;
Davide Pesavento248d6bd2014-03-09 10:24:08 +010045 unsigned int flags;
46
47 bool
48 isLoopback() const;
49
50 bool
51 isMulticastCapable() const;
52
53 bool
Steve DiBenedettoca53ac62014-03-27 19:58:40 -060054 isBroadcastCapable() const;
55
56 bool
Davide Pesavento248d6bd2014-03-09 10:24:08 +010057 isUp() const;
Steve DiBenedettoca53ac62014-03-27 19:58:40 -060058
Davide Pesavento248d6bd2014-03-09 10:24:08 +010059};
60
61inline bool
62NetworkInterfaceInfo::isLoopback() const
63{
64 return (flags & IFF_LOOPBACK) != 0;
65}
66
67inline bool
68NetworkInterfaceInfo::isMulticastCapable() const
69{
70 return (flags & IFF_MULTICAST) != 0;
71}
72
73inline bool
Steve DiBenedettoca53ac62014-03-27 19:58:40 -060074NetworkInterfaceInfo::isBroadcastCapable() const
75{
76 return (flags & IFF_BROADCAST) != 0;
77}
78
79inline bool
Davide Pesavento248d6bd2014-03-09 10:24:08 +010080NetworkInterfaceInfo::isUp() const
81{
82 return (flags & IFF_UP) != 0;
83}
84
85std::list< shared_ptr<NetworkInterfaceInfo> >
86listNetworkInterfaces();
87
88} // namespace nfd
89
90#endif // NFD_CORE_NETWORK_INTERFACE_HPP