# Add Firewall Entry Please follow below steps to create and add Firewall Entry 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 lock(mtx); status_ = status; initCv.notify_all(); }; auto &dataFactory = telux::data::DataFactory::getInstance(); Copy to clipboard 2. Get the FirewallManager instances std::unique_lock 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. Get firewall Entry instance std::shared_ptr fwEntry = dataFactory.getNewFirewallEntry(proto, fwDir, ipFamType); Copy to clipboard 5. Get pointer to Ip Filter std::shared_ptr ipFilter = fwEntry->getIProtocolFilter(); Copy to clipboard 6. Populate Ip Filter based on Ip Family type switch (ipFamType) { case telux::data::IpFamilyType::IPV4: { telux::data::IPv4Info info; info.srcAddr = srcAddr; info.destAddr = destAddr; info.srcSubnetMask = configParser->getValue(std::string("IPV4_SRC_SUBNET_MASK")); info.destSubnetMask = configParser->getValue(std::string("IPV4_DEST_SUBNET_MASK")); info.value = (uint8_t)std::atoi( configParser->getValue(std::string("IPV4_SERVICE_TYPE")).c_str()); info.mask = (uint8_t)std::atoi( configParser->getValue(std::string("IPV4_SERVICE_TYPE_MASK")).c_str()); info.nextProtoId = proto; ipFilter->setIPv4Info(info); } break; case telux::data::IpFamilyType::IPV6: { telux::data::IPv6Info info; info.srcAddr = srcAddr; info.destAddr = destAddr; info.nextProtoId = proto; info.val = (uint8_t)std::atoi( configParser->getValue(std::string("IPV6_TRAFFIC_CLASS")).c_str()); info.mask = (uint8_t)std::atoi( configParser->getValue(std::string("IPV6_TRAFFIC_CLASS_MASK")).c_str()); info.flowLabel = (uint32_t)std::atoi( configParser->getValue(std::string("IPV6_FLOW_LABEL")).c_str()); ipFilter->setIPv6Info(info); } break; default: { std::cout <<"Error: Unrecognized Ip Family used .. exiting app" <(ipFilter); if(tcpFilter) { tcpFilter->setTcpInfo(tcpInfo); } } break; case 17: { //UDP telux::data::UdpInfo info; info.src.port = (uint16_t)protSrcPort; info.src.range = (uint16_t)protSrcRange; info.dest.port = (uint16_t)protDestPort; info.dest.range = (uint16_t)protDestRange; auto udpFilter = std::dynamic_pointer_cast(ipFilter); if(udpFilter) { udpFilter->setUdpInfo(info); } } break; default: { } break; } Copy to clipboard 8. Instantiate add firewall entry callback instance - this is optional auto respCb = [](telux::common::ErrorCode error) { std::cout << std::endl << std::endl; std::cout << "CALLBACK: " << "addFirewallEntry Response" << (error == telux::common::ErrorCode::SUCCESS ? " is successful" : " failed") << ". ErrorCode: " << static_cast(error) << std::endl; promise.set_value(1); }; std::future future = promise.get_future(); dataFwMgr->addFirewallEntry(profileId, fwEntry, respCb); Copy to clipboard Last Published: Jun 24, 2026 [Previous Topic Create firewall DMZ](https://docs.qualcomm.com/bundle/publicresource/80-PF458-1/topics/create_firewall_dmz.md) [Next Topic Adding a software bridge and enable its management](https://docs.qualcomm.com/bundle/publicresource/80-PF458-1/topics/add_enable_software_bridge.md)