@startuml
participant Controller
participant "ApAutoConfigurationTask (BH)" as AC
participant "traffic_separation (BH)" as TS
participant "System" as SYS

== 1. Handle Multi AP Policy ==
Controller -> AC: MULTI_AP_POLICY_CONFIG_REQUEST_MESSAGE

AC -> AC: handle_multi_ap_policy_config_request()\n
AC -> Controller: ACK_MESSAGE
AC -> AC: Set primary_vlan_id, default_pcp
note left: handle_profile2_default_802dotq_settings_tlv

alt No tlvProfile2TrafficSeparationPolicy received
    AC -> AC: Clear all Traffic Separation settings in DB
else Traffic Separation Policy received
    AC -> AC: Save new TS policy to DB
    note left: handle_profile2_traffic_separation_policy_tlv
end

== 2. Apply TS policy on radio(s) ==
alt Radio configured
    AC -> TS: apply_policy(radio_iface)
    TS -> SYS: ip link set ... bridge vlan_filtering ...\n(set_vlan_filtering)
    TS -> SYS: bridge vlan ...\n(set_vlan_policy for bridge, WAN, LAN)
    alt WAN configured
        TS -> SYS: bridge vlan ...\n(set_vlan_policy for WAN)
    end
    loop For each LAN port
        TS -> SYS: bridge vlan ...\n(set_vlan_policy for LAN)
    end
    alt Wireless backhaul present
        TS -> SYS: bridge vlan ...\n(set_vlan_policy for backhaul radio)
    end
    loop For each VAP (BSS)
        alt fronthaul BSS only
            TS -> SYS: bridge vlan ...\n(set_vlan_policy for untagged port, VID from ssid_vid_mapping)
        else backhaul BSS only
            TS -> SYS: bridge vlan ...\n(set_vlan_policy for tagged/untagged, according to profile)
        else combined BSS
            TS -> SYS: bridge vlan ...\n(set_vlan_policy for untagged port, primary VLAN)
        end
    end
    alt Secondary VLANs present
        loop For each secondary VID
            TS -> SYS: ip link add ... type vlan id <vid> (create_vlan_interface)
            TS -> SYS: ip link set ... up
        end
    end

    alt Local GW
        TS -> SYS: Restart/Configure DHCP (dnsmasq)
    else Not GW
        TS -> SYS: Assign IP via DHCP client
    end
else No radio configured
    AC -> AC: Do nothing, autoconfiguration procedure is not completed yet
end

@enduml
