noc.core.vlanmap

Module Contents

noc.core.vlanmap.process_vlan_map(vlans, rules)
Apply VLAN translation rules for ethernet services.
`vlans` are coded by list:
* [] - untagged packet
* [inner vlan] - 802.1Q
* [outer vlan, inner vlan] - Q-in-Q
By convention top of stack is first element.

In additional to input vlan stack, internal vlan stack maintained. Internal stack populated by pop operations and can be popped by push and swap operations when vlan parameter is empty.

Rules coded as dicts each with keys: * op - operation. One of:

  • pop – Pop first tag and push to internal stack
  • push – Push vlan parameter into vlan stack.
    If vlan parameter is empty - pop it from internal stack
  • swap - If vlan is not empty - push atop internal stack.
    Swap tops of vlan stack and of internal stack
  • drop - Drop top of internal stack
  • vlan - optional VLAN parameter
Parameters:
  • vlans – List of input vlan tags.
  • rules – List of rules
Returns:

List of output vlan tags