# Enable/Disable firewall

This sample application demonstrates how to enable/disable firewall.

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();
    Copy to clipboard

2. Get the FirewallManager instances

std::unique_lock<std::mutex> lck(mtx);
    auto dataFwMgr  = dataFactory.getFirewallManager(opType, initCb);
    Copy to clipboard

3. Wait for FirewallManager initialization to be complete

initCv.wait(lck);
    Copy to clipboard

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) {
       // Go to step 4
    }
    else {
       //Go to step 2 for another initialization attempt
    }
    Copy to clipboard

4. Implement callback for setting firewall

auto respCb = [](telux::common::ErrorCode error) {
       std::cout << std::endl << std::endl;
       std::cout << "CALLBACK: "
                   << "setFirewall Response"
                   << (error == telux::common::ErrorCode::SUCCESS ? " is successful" : " failed");
    };
    Copy to clipboard

5. set firewall mode based on profileId, enable/disable and allow/drop packets

dataFwMgr->setFirewall(profileId,fwEnable, allowPackets, respCb);
    Copy to clipboard

Now, response callback will be called for the setFirewall response.

Last Published: May 20, 2026

[Previous Topic
Remove data filter mode](https://docs.qualcomm.com/bundle/publicresource/80-PF458-7/topics/remove_data_filters.md) [Next Topic
Create firewall DMZ](https://docs.qualcomm.com/bundle/publicresource/80-PF458-7/topics/create_firewall_dmz.md)