blob: 0265461ca8345b8f844f36be88532bd7a7e5995a [file] [log] [blame]
Davide Pesavento248d6bd2014-03-09 10:24:08 +01001/* -*- 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
15namespace nfd {
16
17class NetworkInterfaceInfo
18{
19public:
Steve DiBenedettoca53ac62014-03-27 19:58:40 -060020
Davide Pesavento248d6bd2014-03-09 10:24:08 +010021 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 DiBenedettoca53ac62014-03-27 19:58:40 -060026 boost::asio::ip::address_v4 broadcastAddress;
Davide Pesavento248d6bd2014-03-09 10:24:08 +010027 unsigned int flags;
28
29 bool
30 isLoopback() const;
31
32 bool
33 isMulticastCapable() const;
34
35 bool
Steve DiBenedettoca53ac62014-03-27 19:58:40 -060036 isBroadcastCapable() const;
37
38 bool
Davide Pesavento248d6bd2014-03-09 10:24:08 +010039 isUp() const;
Steve DiBenedettoca53ac62014-03-27 19:58:40 -060040
Davide Pesavento248d6bd2014-03-09 10:24:08 +010041};
42
43inline bool
44NetworkInterfaceInfo::isLoopback() const
45{
46 return (flags & IFF_LOOPBACK) != 0;
47}
48
49inline bool
50NetworkInterfaceInfo::isMulticastCapable() const
51{
52 return (flags & IFF_MULTICAST) != 0;
53}
54
55inline bool
Steve DiBenedettoca53ac62014-03-27 19:58:40 -060056NetworkInterfaceInfo::isBroadcastCapable() const
57{
58 return (flags & IFF_BROADCAST) != 0;
59}
60
61inline bool
Davide Pesavento248d6bd2014-03-09 10:24:08 +010062NetworkInterfaceInfo::isUp() const
63{
64 return (flags & IFF_UP) != 0;
65}
66
67std::list< shared_ptr<NetworkInterfaceInfo> >
68listNetworkInterfaces();
69
70} // namespace nfd
71
72#endif // NFD_CORE_NETWORK_INTERFACE_HPP