This sample application demonstrates how to create firewall DMZ.
1. Implement initialization callback and get the DataFactory instances
Optionally initialization callback can be provided with get manager instance. Data factory will call callback when manager initialization is complete.
auto initCb = [&](telux::common::ServiceStatus status) {
std::lock_guard<std::mutex> lock(mtx);
status_ = status;
initCv.notify_all();
};
auto &dataFactory = telux::data::DataFactory::getInstance();
2. Get the FirewallManager instances
std::unique_lock<std::mutex> lck(mtx);
auto dataFwMgr = dataFactory.getFirewallManager(opType, initCb);
3. Wait for FirewallManager initialization to be complete
3.1 Check FirewallManager initialization state
If FirewallManager initialization failed, new initialization attempt can be accomplished by calling step 2. If FirewallManager initialization succeed, proceed to step 4.
if (status_ == telux::common::ServiceStatus::SERVICE_AVAILABLE) {
}
else {
}
4. Implement a callback for create DMZ
auto respCb = [](telux::common::ErrorCode error) {
std::cout << std::endl << std::endl;
std::cout << "CALLBACK: "
<< "addDmz Response"
<< (error == telux::common::ErrorCode::SUCCESS ? " is successful" : " failed");
};
5. Create DMZ based on profile id and local ip address
dataFwMgr->enableDmz(profileId,ipAddr, respCb);
Now, response callback will be called for the addDmz response.