23 #ifndef APPSERVICESRDKPLUGIN_H
24 #define APPSERVICESRDKPLUGIN_H
26 #include <Netfilter.h>
27 #include <RdkPluginBase.h>
29 #include <sys/types.h>
30 #include <netinet/in.h>
50 const std::shared_ptr<DobbyRdkPluginUtils> &utils,
51 const std::string &rootfsPath);
54 inline std::string
name()
const override
70 enum LocalServicesPort : in_port_t
72 LocalServicesNone = 0,
73 LocalServicesInvalid = 1,
75 LocalServices1Port = 9001,
76 LocalServices2Port = 9002,
77 LocalServices3Port = 9003,
78 LocalServices4Port = 9004,
79 LocalServices5Port = 9009,
88 bool setupLocalhostMasquerade(Netfilter::RuleSet& ruleSet);
90 void addRulesForPort(
const std::string &containerIp,
const std::string &vethName,
92 std::list<std::string>& acceptRules, std::list<std::string>& natRules)
const;
95 in_port_t port)
const;
97 const std::string &vethName,
99 uint32_t connLimit)
const;
101 const std::string &vethName,
102 in_port_t port)
const;
108 const std::string mName;
109 std::shared_ptr<rt_dobby_schema> mContainerConfig;
110 const std::shared_ptr<DobbyRdkPluginUtils> mUtils;
111 const std::string mRootfsPath;
114 const rt_defs_plugins_app_services_rdk_data* mPluginConfig;
115 std::shared_ptr<Netfilter> mNetfilter;
116 const bool mEnableConnLimit;
Plugin just used to map in access for AS services.
Definition: AppServicesRdkPlugin.h:47
bool postInstallation() override
Dobby Hook - run in host namespace once when container bundle is downloaded Updates the /etc/services...
Definition: AppServicesRdkPlugin.cpp:88
void addRulesForPort(const std::string &containerIp, const std::string &vethName, in_port_t port, std::list< std::string > &acceptRules, std::list< std::string > &natRules) const
Adds the ACCEPT, DNAT and CONNLIMIT iptables rules for the given port to the given rule sets.
Definition: AppServicesRdkPlugin.cpp:401
std::string constructACCEPTRule(const std::string &containerIp, const std::string &vethName, in_port_t port) const
Constructs a INPUT ACCEPT rule to allow packets from the container over the dobby0 bridge to localhos...
Definition: AppServicesRdkPlugin.cpp:547
std::string constructCONNLIMITRule(const std::string &containerIp, const std::string &vethName, in_port_t port, uint32_t connLimit) const
Constructs an INPUT REJECT rule to reject connection if exceed the limit.
Definition: AppServicesRdkPlugin.cpp:505
std::vector< std::string > getDependencies() const override
Should return the names of the plugins this plugin depends on.
Definition: AppServicesRdkPlugin.cpp:278
std::string createMasqueradeDnatRule(const in_port_t &port) const
Constructs an OUTPUT DNAT rule to forward packets from 127.0.0.1 inside the container to the bridge d...
Definition: AppServicesRdkPlugin.cpp:625
LocalServicesPort getAsPort() const
Gets the AS port based on the "setMenu" config setting.
Definition: AppServicesRdkPlugin.cpp:298
std::set< in_port_t > getAllPorts() const
Get all the ports we need to forward.
Definition: AppServicesRdkPlugin.cpp:354
Netfilter::RuleSet constructMasqueradeRules() const
Constructs rules to forward requests to AS ports on the container localhost interface to the host.
Definition: AppServicesRdkPlugin.cpp:583
Netfilter::RuleSet constructRules() const
Creates the required iptables rules based on the container and plugin config.
Definition: AppServicesRdkPlugin.cpp:423
std::string name() const override
Should return the name of the plugin.
Definition: AppServicesRdkPlugin.h:54
std::string createMasqueradeSnatRule(const std::string &ipAddress) const
Constructs an POSTROUTING SNAT rule so that the source address is changed to the veth0 inside the con...
Definition: AppServicesRdkPlugin.cpp:665
unsigned hookHints() const override
Set the bit flags for which hooks we're going to use.
Definition: AppServicesRdkPlugin.cpp:59
bool postHalt() override
Dobby Hook - Run in host namespace when container terminates. We hook this point so we can delete the...
Definition: AppServicesRdkPlugin.cpp:230
std::string constructDNATRule(const std::string &containerIp, in_port_t port) const
Constructs a DNAT PREROUTING rule to send anything from the container on the given port to localhost ...
Definition: AppServicesRdkPlugin.cpp:467
bool createRuntime() override
OCI Hook - Run in host namespace. Adds the two iptables firewall rules to enable port forwarding.
Definition: AppServicesRdkPlugin.cpp:143
Basic object that provides the default overrides for a plugin.
Definition: RdkPluginBase.h:34