VOL-2618 added new extractors
get_metadata_from_write_metadata
get_tp_id_from_metadata
get_default_vlan
functions added. These functions will be used by openonu-adapter.
Change-Id: Ib63c40ce9545b9b25e703da0d026c7973dbe058d
diff --git a/VERSION b/VERSION
index 0e80d41..1c1ea95 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-2.3.14
+2.3.15_dev
diff --git a/pyvoltha/common/openflow/utils.py b/pyvoltha/common/openflow/utils.py
index 747ca0b..bf9c48e 100644
--- a/pyvoltha/common/openflow/utils.py
+++ b/pyvoltha/common/openflow/utils.py
@@ -319,6 +319,15 @@
# frequently used extractors:
+def get_metadata_from_write_metadata(flow):
+ for instruction in flow.instructions:
+ if instruction.type == ofp.OFPIT_WRITE_METADATA:
+ return instruction.write_metadata.metadata
+ return None
+
+def get_tp_id_from_metadata(write_metadata_value):
+ return (write_metadata_value >> 32) & 0xffff
+
def get_actions(flow):
"""Extract list of ofp_action objects from flow spec object"""
assert isinstance(flow, ofp.ofp_flow_stats)
@@ -327,6 +336,11 @@
if instruction.type == ofp.OFPIT_APPLY_ACTIONS:
return instruction.actions.actions
+def get_default_vlan(flow):
+ for field in get_ofb_fields(flow):
+ if field.type == VLAN_VID:
+ return field.vlan_vid & 0xfff
+ return 0
def get_ofb_fields(flow):
assert isinstance(flow, ofp.ofp_flow_stats)