2020-09-24 00:28:38 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <unordered_map>
|
|
|
|
#include <string>
|
2021-02-16 15:59:18 +00:00
|
|
|
#include <memory>
|
2020-09-24 00:28:38 +00:00
|
|
|
#include <net/net_int.hpp>
|
|
|
|
|
|
|
|
namespace llarp
|
|
|
|
{
|
|
|
|
struct AbstractRouter;
|
|
|
|
|
|
|
|
struct RoutePoker
|
|
|
|
{
|
|
|
|
void
|
|
|
|
AddRoute(huint32_t ip);
|
|
|
|
|
|
|
|
void
|
|
|
|
DelRoute(huint32_t ip);
|
|
|
|
|
2020-10-20 09:15:39 +00:00
|
|
|
void
|
|
|
|
Init(AbstractRouter* router, bool enable = false);
|
|
|
|
|
2020-09-24 00:28:38 +00:00
|
|
|
~RoutePoker();
|
|
|
|
|
|
|
|
void
|
2020-10-20 09:15:39 +00:00
|
|
|
Update();
|
|
|
|
|
|
|
|
// sets stored routes and causes AddRoute to actually
|
|
|
|
// set routes rather than just storing them
|
|
|
|
void
|
|
|
|
Enable();
|
|
|
|
|
|
|
|
// unsets stored routes, and causes AddRoute to simply
|
|
|
|
// remember the desired routes rather than setting them.
|
|
|
|
void
|
|
|
|
Disable();
|
2020-09-24 00:28:38 +00:00
|
|
|
|
2021-02-16 15:59:18 +00:00
|
|
|
/// explicitly put routes up
|
|
|
|
void
|
|
|
|
Up();
|
|
|
|
|
|
|
|
/// explicitly put routes down
|
|
|
|
void
|
|
|
|
Down();
|
|
|
|
|
2020-09-24 00:28:38 +00:00
|
|
|
private:
|
2020-10-20 09:15:39 +00:00
|
|
|
void
|
|
|
|
DeleteAllRoutes();
|
|
|
|
|
|
|
|
void
|
|
|
|
DisableAllRoutes();
|
|
|
|
|
|
|
|
void
|
|
|
|
EnableAllRoutes();
|
|
|
|
|
|
|
|
void
|
|
|
|
EnableRoute(huint32_t ip, huint32_t gateway);
|
|
|
|
|
|
|
|
void
|
|
|
|
DisableRoute(huint32_t ip, huint32_t gateway);
|
|
|
|
|
2020-09-24 00:28:38 +00:00
|
|
|
std::optional<huint32_t>
|
2020-10-20 09:15:39 +00:00
|
|
|
GetDefaultGateway() const;
|
2020-09-24 00:28:38 +00:00
|
|
|
|
|
|
|
std::unordered_map<huint32_t, huint32_t> m_PokedRoutes;
|
|
|
|
huint32_t m_CurrentGateway;
|
2020-10-20 09:15:39 +00:00
|
|
|
|
|
|
|
bool m_Enabled = false;
|
|
|
|
bool m_Enabling = false;
|
|
|
|
|
|
|
|
AbstractRouter* m_Router = nullptr;
|
2021-02-08 12:44:01 +00:00
|
|
|
|
|
|
|
bool m_HasNetwork = true;
|
2020-09-24 00:28:38 +00:00
|
|
|
};
|
|
|
|
} // namespace llarp
|