Line data Source code
1 : // Copyright (c) 2012-2021 Made to Order Software Corp. All Rights Reserved
2 : //
3 : // https://snapwebsites.org/project/libaddr
4 : //
5 : // Permission is hereby granted, free of charge, to any person obtaining a
6 : // copy of this software and associated documentation files (the
7 : // "Software"), to deal in the Software without restriction, including
8 : // without limitation the rights to use, copy, modify, merge, publish,
9 : // distribute, sublicense, and/or sell copies of the Software, and to
10 : // permit persons to whom the Software is furnished to do so, subject to
11 : // the following conditions:
12 : //
13 : // The above copyright notice and this permission notice shall be included
14 : // in all copies or substantial portions of the Software.
15 : //
16 : // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17 : // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18 : // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19 : // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20 : // CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21 : // TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22 : // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 : #pragma once
24 :
25 : /** \file
26 : * \brief The various libaddr classes.
27 : *
28 : * This header includes the base addr class used to handle one binary
29 : * address.
30 : */
31 :
32 : // addr library
33 : //
34 : #include "libaddr/addr.h"
35 :
36 :
37 :
38 : namespace addr
39 : {
40 :
41 :
42 0 : class iface_index_name
43 : {
44 : public:
45 : typedef std::vector<iface_index_name> vector_t;
46 :
47 : iface_index_name(int index, std::string const & name);
48 :
49 : int get_index() const;
50 : std::string const & get_name() const;
51 :
52 : private:
53 : int f_index;
54 : std::string f_name;
55 : };
56 :
57 : iface_index_name::vector_t get_interface_name_index();
58 :
59 :
60 2842 : class iface
61 : {
62 : public:
63 : typedef std::shared_ptr<iface> pointer_t;
64 : typedef std::vector<iface> vector_t;
65 :
66 : static iface::vector_t get_local_addresses();
67 :
68 : std::string get_name() const;
69 : unsigned int get_flags() const;
70 : addr const & get_address() const;
71 : addr const & get_broadcast_address() const;
72 : addr const & get_destination_address() const;
73 :
74 : bool has_broadcast_address() const;
75 : bool has_destination_address() const;
76 :
77 : private:
78 : std::string f_name = std::string();
79 : unsigned int f_flags = 0;
80 : addr f_address = addr();
81 : addr f_broadcast_address = addr();
82 : addr f_destination_address = addr();
83 : };
84 :
85 :
86 :
87 : iface::pointer_t find_addr_interface(addr const & a, bool allow_default_destination = true);
88 :
89 :
90 :
91 : }
92 : // namespace addr
93 : // vim: ts=4 sw=4 et
|