VOL-1489 Fully support tunnel_id openflow field
Change-Id: Ib148c59d79f40a2f3859a739c65fdf5eb1dcfbbd
diff --git a/.gitignore b/.gitignore
index ff89877..a5dd45e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -8,3 +8,6 @@
# python distribution related
dist
*.egg-info
+
+# ide workspace
+.idea
diff --git a/pyvoltha/common/openflow/utils.py b/pyvoltha/common/openflow/utils.py
index 27b99b5..d2a9677 100644
--- a/pyvoltha/common/openflow/utils.py
+++ b/pyvoltha/common/openflow/utils.py
@@ -309,7 +309,7 @@
def tunnel_id(_tunnel_id):
- return ofb_field(type=TUNNEL_ID, arp_tha=_tunnel_id)
+ return ofb_field(type=TUNNEL_ID, tunnel_id=_tunnel_id)
def ipv6_exthdr(_ipv6_exthdr):
@@ -358,6 +358,13 @@
return None
+def get_tunnelid(flow):
+ for field in get_ofb_fields(flow):
+ if field.type == TUNNEL_ID:
+ return field.tunnel_id
+ return None
+
+
def get_metadata(flow):
''' legacy get method (only want lower 32 bits '''
for field in get_ofb_fields(flow):
@@ -415,6 +422,20 @@
return (md >> 32) & 0xffffffff
+def get_child_port_from_tunnelid(flow):
+ """
+ Extract the child device port from a flow that contains the parent device peer port. Typically the UNI port of an
+ ONU child device. Per TST agreement this will be the lower 32 bits of tunnel id reserving upper 32 bits for later
+ use
+ """
+ tid = get_tunnelid(flow)
+
+ if tid is None:
+ return None
+
+ return int(tid & 0xffffffff)
+
+
# test and extract next table and group information
def has_next_table(flow):
return get_goto_table_id(flow) is not None