# Create VLAN And bind it to a PDN

This sample application demonstrates how to create VLAN and bind it to a PDN.

1. Implement initialization callback and get the DataFactory instance

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 VlanManager instances

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

3. Wait for VlanManager initialization to be complete

initCv.wait(lck);
    Copy to clipboard

3.1 Check VlanManager initialization state

If VlanManager initialization failed, new initialization attempt can be accomplished
by calling step 2. If VlanManager 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 create VLAN

auto respCbCreate = [](bool isAccelerated, telux::common::ErrorCode error) {
       std::cout << std::endl << std::endl;
       std::cout << "CALLBACK: "
                   << "createVlan Response"
                   << (error == telux::common::ErrorCode::SUCCESS ? " is successful" : " failed")
                   << ". ErrorCode: " << static_cast<int>(error);
       std::cout << " Acceleration " << (isAccelerated ? "is allowed" : "is not allowed") << "\n";
    };
    Copy to clipboard

5. Create Vlan based on interface type, acceleration, and assigned id

telux::data::VlanConfig config;
    config.iface = infType;
    config.vlanId = vlanId;
    config.isAccelerated = isAccelerated;
    dataVlanMgr->createVlan(config, respCbCreate);
    Copy to clipboard

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

6. Implement callback for bindWithprofile reponse

auto respCbBind = [](telux::common::ErrorCode error) {
       std::cout << std::endl << std::endl;
       std::cout << "CALLBACK: "
                   << "bindWithProfile Response"
                   << (error == telux::common::ErrorCode::SUCCESS ? " is successful" : " failed")
                   << ". ErrorCode: " << static_cast<int>(error) << std::endl;
    };
    Copy to clipboard

7. Bind created Vlan with user provided profile id

dataVlanMgr->bindWithProfile(profileId, vlanId, respCbBind);
    Copy to clipboard

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

Last Published: Apr 14, 2026

[Previous Topic
Remove a software bridge and its management](https://docs.qualcomm.com/bundle/publicresource/80-PF458-1/topics/remove_disable_software_bridge.md) [Next Topic
Create static NAT entry](https://docs.qualcomm.com/bundle/publicresource/80-PF458-1/topics/create_snat_entry.md)