update pyloxi and add tcp flags support
diff --git a/src/python/loxi/of12/const.py b/src/python/loxi/of12/const.py
index 59aa4c5..0833b90 100644
--- a/src/python/loxi/of12/const.py
+++ b/src/python/loxi/of12/const.py
@@ -187,6 +187,29 @@
12: 'OFPBRC_BAD_PACKET',
}
+# Identifiers from group ofp_bsn_tcp_flag
+OFP_BSN_TCP_FLAG_FIN = 1
+OFP_BSN_TCP_FLAG_SYN = 2
+OFP_BSN_TCP_FLAG_RST = 4
+OFP_BSN_TCP_FLAG_PSH = 8
+OFP_BSN_TCP_FLAG_ACK = 16
+OFP_BSN_TCP_FLAG_URG = 32
+OFP_BSN_TCP_FLAG_ECE = 64
+OFP_BSN_TCP_FLAG_CWR = 128
+OFP_BSN_TCP_FLAG_NS = 256
+
+ofp_bsn_tcp_flag_map = {
+ 1: 'OFP_BSN_TCP_FLAG_FIN',
+ 2: 'OFP_BSN_TCP_FLAG_SYN',
+ 4: 'OFP_BSN_TCP_FLAG_RST',
+ 8: 'OFP_BSN_TCP_FLAG_PSH',
+ 16: 'OFP_BSN_TCP_FLAG_ACK',
+ 32: 'OFP_BSN_TCP_FLAG_URG',
+ 64: 'OFP_BSN_TCP_FLAG_ECE',
+ 128: 'OFP_BSN_TCP_FLAG_CWR',
+ 256: 'OFP_BSN_TCP_FLAG_NS',
+}
+
# Identifiers from group ofp_bsn_vport_l2gre_flags
OF_BSN_VPORT_L2GRE_LOCAL_MAC_IS_VALID = 1
OF_BSN_VPORT_L2GRE_DSCP_ASSIGN = 2
diff --git a/src/python/loxi/of12/oxm.py b/src/python/loxi/of12/oxm.py
index 978529a..46ec9ec 100644
--- a/src/python/loxi/of12/oxm.py
+++ b/src/python/loxi/of12/oxm.py
@@ -1161,6 +1161,98 @@
oxm.subtypes[197384] = bsn_lag_id_masked
+class bsn_tcp_flags(oxm):
+ type_len = 204802
+
+ def __init__(self, value=None):
+ if value != None:
+ self.value = value
+ else:
+ self.value = 0
+ return
+
+ def pack(self):
+ packed = []
+ packed.append(struct.pack("!L", self.type_len))
+ packed.append(struct.pack("!H", self.value))
+ return ''.join(packed)
+
+ @staticmethod
+ def unpack(reader):
+ obj = bsn_tcp_flags()
+ _type_len = reader.read("!L")[0]
+ assert(_type_len == 204802)
+ obj.value = reader.read("!H")[0]
+ return obj
+
+ def __eq__(self, other):
+ if type(self) != type(other): return False
+ if self.value != other.value: return False
+ return True
+
+ def pretty_print(self, q):
+ q.text("bsn_tcp_flags {")
+ with q.group():
+ with q.indent(2):
+ q.breakable()
+ q.text("value = ");
+ q.text("%#x" % self.value)
+ q.breakable()
+ q.text('}')
+
+oxm.subtypes[204802] = bsn_tcp_flags
+
+class bsn_tcp_flags_masked(oxm):
+ type_len = 205060
+
+ def __init__(self, value=None, value_mask=None):
+ if value != None:
+ self.value = value
+ else:
+ self.value = 0
+ if value_mask != None:
+ self.value_mask = value_mask
+ else:
+ self.value_mask = 0
+ return
+
+ def pack(self):
+ packed = []
+ packed.append(struct.pack("!L", self.type_len))
+ packed.append(struct.pack("!H", self.value))
+ packed.append(struct.pack("!H", self.value_mask))
+ return ''.join(packed)
+
+ @staticmethod
+ def unpack(reader):
+ obj = bsn_tcp_flags_masked()
+ _type_len = reader.read("!L")[0]
+ assert(_type_len == 205060)
+ obj.value = reader.read("!H")[0]
+ obj.value_mask = reader.read("!H")[0]
+ return obj
+
+ def __eq__(self, other):
+ if type(self) != type(other): return False
+ if self.value != other.value: return False
+ if self.value_mask != other.value_mask: return False
+ return True
+
+ def pretty_print(self, q):
+ q.text("bsn_tcp_flags_masked {")
+ with q.group():
+ with q.indent(2):
+ q.breakable()
+ q.text("value = ");
+ q.text("%#x" % self.value)
+ q.text(","); q.breakable()
+ q.text("value_mask = ");
+ q.text("%#x" % self.value_mask)
+ q.breakable()
+ q.text('}')
+
+oxm.subtypes[205060] = bsn_tcp_flags_masked
+
class bsn_udf0(oxm):
type_len = 200708
diff --git a/src/python/loxi/of13/const.py b/src/python/loxi/of13/const.py
index c88b084..49440e4 100644
--- a/src/python/loxi/of13/const.py
+++ b/src/python/loxi/of13/const.py
@@ -248,6 +248,7 @@
OFP_BSN_PKTIN_FLAG_TTL_EXPIRED = 128
OFP_BSN_PKTIN_FLAG_L3_MISS = 256
OFP_BSN_PKTIN_FLAG_L3_CPU = 512
+OFP_BSN_PKTIN_FLAG_INGRESS_ACL = 1024
ofp_bsn_pktin_flag_map = {
1: 'OFP_BSN_PKTIN_FLAG_PDU',
@@ -260,6 +261,7 @@
128: 'OFP_BSN_PKTIN_FLAG_TTL_EXPIRED',
256: 'OFP_BSN_PKTIN_FLAG_L3_MISS',
512: 'OFP_BSN_PKTIN_FLAG_L3_CPU',
+ 1024: 'OFP_BSN_PKTIN_FLAG_INGRESS_ACL',
}
# Identifiers from group ofp_bsn_port_counter
@@ -291,6 +293,29 @@
11: 'OFP_BSN_PORT_COUNTER_TX_ERRORS',
}
+# Identifiers from group ofp_bsn_tcp_flag
+OFP_BSN_TCP_FLAG_FIN = 1
+OFP_BSN_TCP_FLAG_SYN = 2
+OFP_BSN_TCP_FLAG_RST = 4
+OFP_BSN_TCP_FLAG_PSH = 8
+OFP_BSN_TCP_FLAG_ACK = 16
+OFP_BSN_TCP_FLAG_URG = 32
+OFP_BSN_TCP_FLAG_ECE = 64
+OFP_BSN_TCP_FLAG_CWR = 128
+OFP_BSN_TCP_FLAG_NS = 256
+
+ofp_bsn_tcp_flag_map = {
+ 1: 'OFP_BSN_TCP_FLAG_FIN',
+ 2: 'OFP_BSN_TCP_FLAG_SYN',
+ 4: 'OFP_BSN_TCP_FLAG_RST',
+ 8: 'OFP_BSN_TCP_FLAG_PSH',
+ 16: 'OFP_BSN_TCP_FLAG_ACK',
+ 32: 'OFP_BSN_TCP_FLAG_URG',
+ 64: 'OFP_BSN_TCP_FLAG_ECE',
+ 128: 'OFP_BSN_TCP_FLAG_CWR',
+ 256: 'OFP_BSN_TCP_FLAG_NS',
+}
+
# Identifiers from group ofp_bsn_udf_anchor
OFP_BSN_UDF_ANCHOR_PACKET_START = 0
OFP_BSN_UDF_ANCHOR_L3_HEADER_START = 1
diff --git a/src/python/loxi/of13/oxm.py b/src/python/loxi/of13/oxm.py
index 7372490..fa4508d 100644
--- a/src/python/loxi/of13/oxm.py
+++ b/src/python/loxi/of13/oxm.py
@@ -1165,6 +1165,98 @@
oxm.subtypes[197384] = bsn_lag_id_masked
+class bsn_tcp_flags(oxm):
+ type_len = 204802
+
+ def __init__(self, value=None):
+ if value != None:
+ self.value = value
+ else:
+ self.value = 0
+ return
+
+ def pack(self):
+ packed = []
+ packed.append(struct.pack("!L", self.type_len))
+ packed.append(struct.pack("!H", self.value))
+ return ''.join(packed)
+
+ @staticmethod
+ def unpack(reader):
+ obj = bsn_tcp_flags()
+ _type_len = reader.read("!L")[0]
+ assert(_type_len == 204802)
+ obj.value = reader.read("!H")[0]
+ return obj
+
+ def __eq__(self, other):
+ if type(self) != type(other): return False
+ if self.value != other.value: return False
+ return True
+
+ def pretty_print(self, q):
+ q.text("bsn_tcp_flags {")
+ with q.group():
+ with q.indent(2):
+ q.breakable()
+ q.text("value = ");
+ q.text("%#x" % self.value)
+ q.breakable()
+ q.text('}')
+
+oxm.subtypes[204802] = bsn_tcp_flags
+
+class bsn_tcp_flags_masked(oxm):
+ type_len = 205060
+
+ def __init__(self, value=None, value_mask=None):
+ if value != None:
+ self.value = value
+ else:
+ self.value = 0
+ if value_mask != None:
+ self.value_mask = value_mask
+ else:
+ self.value_mask = 0
+ return
+
+ def pack(self):
+ packed = []
+ packed.append(struct.pack("!L", self.type_len))
+ packed.append(struct.pack("!H", self.value))
+ packed.append(struct.pack("!H", self.value_mask))
+ return ''.join(packed)
+
+ @staticmethod
+ def unpack(reader):
+ obj = bsn_tcp_flags_masked()
+ _type_len = reader.read("!L")[0]
+ assert(_type_len == 205060)
+ obj.value = reader.read("!H")[0]
+ obj.value_mask = reader.read("!H")[0]
+ return obj
+
+ def __eq__(self, other):
+ if type(self) != type(other): return False
+ if self.value != other.value: return False
+ if self.value_mask != other.value_mask: return False
+ return True
+
+ def pretty_print(self, q):
+ q.text("bsn_tcp_flags_masked {")
+ with q.group():
+ with q.indent(2):
+ q.breakable()
+ q.text("value = ");
+ q.text("%#x" % self.value)
+ q.text(","); q.breakable()
+ q.text("value_mask = ");
+ q.text("%#x" % self.value_mask)
+ q.breakable()
+ q.text('}')
+
+oxm.subtypes[205060] = bsn_tcp_flags_masked
+
class bsn_udf0(oxm):
type_len = 200708
diff --git a/src/python/oftest/testutils.py b/src/python/oftest/testutils.py
index 57201ce..34c9f5f 100644
--- a/src/python/oftest/testutils.py
+++ b/src/python/oftest/testutils.py
@@ -80,6 +80,7 @@
ip_ttl=64,
tcp_sport=1234,
tcp_dport=80,
+ tcp_flags="S",
ip_ihl=None,
ip_options=False
):
@@ -98,7 +99,8 @@
@param ip_tos IP ToS
@param ip_ttl IP TTL
@param tcp_dport TCP destination port
- @param ip_sport TCP source port
+ @param tcp_sport TCP source port
+ @param tcp_flags TCP Control flags
Generates a simple TCP request. Users
shouldn't assume anything about this packet other than that
@@ -113,16 +115,16 @@
pkt = scapy.Ether(dst=eth_dst, src=eth_src)/ \
scapy.Dot1Q(prio=vlan_pcp, id=dl_vlan_cfi, vlan=vlan_vid)/ \
scapy.IP(src=ip_src, dst=ip_dst, tos=ip_tos, ttl=ip_ttl, ihl=ip_ihl)/ \
- scapy.TCP(sport=tcp_sport, dport=tcp_dport)
+ scapy.TCP(sport=tcp_sport, dport=tcp_dport, flags=tcp_flags)
else:
if not ip_options:
pkt = scapy.Ether(dst=eth_dst, src=eth_src)/ \
scapy.IP(src=ip_src, dst=ip_dst, tos=ip_tos, ttl=ip_ttl, ihl=ip_ihl)/ \
- scapy.TCP(sport=tcp_sport, dport=tcp_dport)
+ scapy.TCP(sport=tcp_sport, dport=tcp_dport, flags=tcp_flags)
else:
pkt = scapy.Ether(dst=eth_dst, src=eth_src)/ \
scapy.IP(src=ip_src, dst=ip_dst, tos=ip_tos, ttl=ip_ttl, ihl=ip_ihl, options=ip_options)/ \
- scapy.TCP(sport=tcp_sport, dport=tcp_dport)
+ scapy.TCP(sport=tcp_sport, dport=tcp_dport, flags=tcp_flags)
pkt = pkt/("D" * (pktlen - len(pkt)))
@@ -140,7 +142,8 @@
ipv6_hlim=64,
ipv6_fl=0,
tcp_sport=1234,
- tcp_dport=80):
+ tcp_dport=80,
+ tcp_flags="S"):
"""
Return a simple IPv6/TCP packet
@@ -158,6 +161,7 @@
@param ipv6_fl IPv6 flow label
@param tcp_dport TCP destination port
@param tcp_sport TCP source port
+ @param tcp_flags TCP Control flags
Generates a simple TCP request. Users shouldn't assume anything about this
packet other than that it is a valid ethernet/IPv6/TCP frame.
@@ -170,7 +174,7 @@
if dl_vlan_enable or vlan_vid or vlan_pcp:
pkt /= scapy.Dot1Q(vlan=vlan_vid, prio=vlan_pcp)
pkt /= scapy.IPv6(src=ipv6_src, dst=ipv6_dst, fl=ipv6_fl, tc=ipv6_tc, hlim=ipv6_hlim)
- pkt /= scapy.TCP(sport=tcp_sport, dport=tcp_dport)
+ pkt /= scapy.TCP(sport=tcp_sport, dport=tcp_dport, flags=tcp_flags)
pkt /= ("D" * (pktlen - len(pkt)))
return pkt