Ratan Gupta | 233524c | 2017-05-27 11:47:31 +0530 | [diff] [blame] | 1 | #pragma once |
Ratan Gupta | 233524c | 2017-05-27 11:47:31 +0530 | [diff] [blame] | 2 | #include <linux/netlink.h> |
3 | |||||
Ratan Gupta | 233524c | 2017-05-27 11:47:31 +0530 | [diff] [blame] | 4 | #include <map> |
Patrick Venture | 189d44e | 2018-07-09 12:30:59 -0700 | [diff] [blame] | 5 | #include <string> |
William A. Kennington III | e0b8fd6 | 2021-10-23 14:35:08 -0700 | [diff] [blame] | 6 | #include <string_view> |
Ratan Gupta | 233524c | 2017-05-27 11:47:31 +0530 | [diff] [blame] | 7 | |
8 | namespace phosphor | ||||
9 | { | ||||
10 | namespace network | ||||
11 | { | ||||
12 | namespace route | ||||
13 | { | ||||
Ratan Gupta | 233524c | 2017-05-27 11:47:31 +0530 | [diff] [blame] | 14 | class Table |
15 | { | ||||
Gunnar Mills | 57d9c50 | 2018-09-14 14:42:34 -0500 | [diff] [blame] | 16 | public: |
William A. Kennington III | e056484 | 2021-10-23 16:02:22 -0700 | [diff] [blame] | 17 | /** @brief Rebuilds the routing table from the kernel */ |
18 | void refresh(); | ||||
Ratan Gupta | 233524c | 2017-05-27 11:47:31 +0530 | [diff] [blame] | 19 | |
Gunnar Mills | 57d9c50 | 2018-09-14 14:42:34 -0500 | [diff] [blame] | 20 | /** |
William A. Kennington III | d3c249c | 2019-02-01 21:12:02 -0800 | [diff] [blame] | 21 | * @brief gets the default v4 gateway. |
Gunnar Mills | 57d9c50 | 2018-09-14 14:42:34 -0500 | [diff] [blame] | 22 | * |
Ravi Teja | a5a0944 | 2020-07-17 00:57:33 -0500 | [diff] [blame] | 23 | * @returns the default v4 gateway list. |
Gunnar Mills | 57d9c50 | 2018-09-14 14:42:34 -0500 | [diff] [blame] | 24 | */ |
William A. Kennington III | e056484 | 2021-10-23 16:02:22 -0700 | [diff] [blame] | 25 | inline const auto& getDefaultGateway() const |
Gunnar Mills | 57d9c50 | 2018-09-14 14:42:34 -0500 | [diff] [blame] | 26 | { |
27 | return defaultGateway; | ||||
William A. Kennington III | e056484 | 2021-10-23 16:02:22 -0700 | [diff] [blame] | 28 | } |
Ratan Gupta | 233524c | 2017-05-27 11:47:31 +0530 | [diff] [blame] | 29 | |
Gunnar Mills | 57d9c50 | 2018-09-14 14:42:34 -0500 | [diff] [blame] | 30 | /** |
William A. Kennington III | d3c249c | 2019-02-01 21:12:02 -0800 | [diff] [blame] | 31 | * @brief gets the default v6 gateway. |
32 | * | ||||
Ravi Teja | a5a0944 | 2020-07-17 00:57:33 -0500 | [diff] [blame] | 33 | * @returns the default v6 gateway list. |
William A. Kennington III | d3c249c | 2019-02-01 21:12:02 -0800 | [diff] [blame] | 34 | */ |
William A. Kennington III | e056484 | 2021-10-23 16:02:22 -0700 | [diff] [blame] | 35 | inline const auto& getDefaultGateway6() const |
William A. Kennington III | d3c249c | 2019-02-01 21:12:02 -0800 | [diff] [blame] | 36 | { |
37 | return defaultGateway6; | ||||
38 | }; | ||||
39 | |||||
Gunnar Mills | 57d9c50 | 2018-09-14 14:42:34 -0500 | [diff] [blame] | 40 | private: |
41 | /** | ||||
Gunnar Mills | 57d9c50 | 2018-09-14 14:42:34 -0500 | [diff] [blame] | 42 | * @brief Parse the route and add it to the route list. |
43 | * | ||||
44 | * @param[in] nlHdr - net link message header. | ||||
45 | */ | ||||
William A. Kennington III | e0b8fd6 | 2021-10-23 14:35:08 -0700 | [diff] [blame] | 46 | void parseRoutes(const struct nlmsghdr& nlHdr, std::string_view msg); |
Ratan Gupta | 233524c | 2017-05-27 11:47:31 +0530 | [diff] [blame] | 47 | |
Ravi Teja | a5a0944 | 2020-07-17 00:57:33 -0500 | [diff] [blame] | 48 | std::map<std::string, std::string> defaultGateway; // default gateway list |
49 | std::map<std::string, std::string> defaultGateway6; // default gateway list | ||||
Ratan Gupta | 233524c | 2017-05-27 11:47:31 +0530 | [diff] [blame] | 50 | }; |
51 | |||||
Gunnar Mills | 57d9c50 | 2018-09-14 14:42:34 -0500 | [diff] [blame] | 52 | } // namespace route |
53 | } // namespace network | ||||
54 | } // namespace phosphor |