Line data Source code
1 : // Network Address -- classes functions to ease handling IP addresses
2 : // Copyright (c) 2012-2019 Made to Order Software Corp. All Rights Reserved
3 : //
4 : // https://snapwebsites.org/project/libaddr
5 : //
6 : // Permission is hereby granted, free of charge, to any person obtaining a
7 : // copy of this software and associated documentation files (the
8 : // "Software"), to deal in the Software without restriction, including
9 : // without limitation the rights to use, copy, modify, merge, publish,
10 : // distribute, sublicense, and/or sell copies of the Software, and to
11 : // permit persons to whom the Software is furnished to do so, subject to
12 : // the following conditions:
13 : //
14 : // The above copyright notice and this permission notice shall be included
15 : // in all copies or substantial portions of the Software.
16 : //
17 : // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 : // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 : // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20 : // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21 : // CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22 : // TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23 : // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 : //
25 : #pragma once
26 :
27 : /** \file
28 : * \brief The various route class.
29 : *
30 : * This header includes the route class used to handle routes as found
31 : * in the routing tables of the kernel.
32 : */
33 :
34 : // addr lib
35 : //
36 : #include "libaddr/addr.h"
37 :
38 :
39 :
40 : namespace addr
41 : {
42 :
43 :
44 :
45 84 : class route
46 : {
47 : public:
48 : typedef std::shared_ptr<route> pointer_t;
49 : typedef std::vector<pointer_t> vector_t;
50 :
51 : static vector_t get_ipv4_routes();
52 :
53 : std::string const & get_interface_name() const;
54 : addr const & get_destination_address() const;
55 : addr const & get_gateway_address() const;
56 : int get_flags() const;
57 : std::string flags_to_string() const;
58 : int get_reference_count() const;
59 : int get_use() const;
60 : int get_metric() const;
61 : int get_mtu() const;
62 : int get_window() const;
63 : int get_irtt() const;
64 :
65 : private:
66 : std::string f_interface_name = std::string();
67 : addr f_destination_address = addr(); // Destination + Mask
68 : addr f_gateway_address = addr();
69 : int f_flags = 0;
70 : int f_reference_count = 0;
71 : int f_use = 0;
72 : int f_metric = 0;
73 : int f_mtu = 0;
74 : int f_window = 0;
75 : int f_irtt = 0;
76 : };
77 :
78 :
79 : route::pointer_t find_default_route(route::vector_t const & routes);
80 :
81 :
82 : }
83 : // addr namespace
84 : // vim: ts=4 sw=4 et
|