of13: Add experimenter property to table features request unit test

Signed-off-by: Simon Horman <horms@verge.net.au>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
This commit is contained in:
Simon Horman 2014-02-27 09:06:53 +09:00 committed by FUJITA Tomonori
parent 22a7078dcb
commit 9aafc0eb56
4 changed files with 47 additions and 13 deletions

View File

@ -5126,7 +5126,7 @@ class OFPTableFeaturePropOxm(OFPTableFeatureProp):
@OFPTableFeatureProp.register_type(ofproto.OFPTFPT_EXPERIMENTER_MISS)
class OFPTableFeaturePropExperimenter(OFPTableFeatureProp):
_DATA_ELEMENT_PACK_STR = '!I'
_PACK_STR = '!II'
_BODY_PACK_STR = '!II'
def __init__(self, type_, experimenter=None, exp_type=None,
data=None, length=None):
@ -5138,13 +5138,14 @@ class OFPTableFeaturePropExperimenter(OFPTableFeatureProp):
@classmethod
def _parse_prop(cls, buf):
(experimenter, exp_type) = struct.unpack_from(cls._PACK_STR, buf, 0)
(experimenter, exp_type) = struct.unpack_from(cls._BODY_PACK_STR,
buf, 0)
# Parse trailing data, a list of 4-byte words
length = len(buf)
data = []
pack_size = struct.calcsize(cls._DATA_ELEMENT_PACK_STR)
offset = struct.calcsize(cls._PACK_STR)
offset = struct.calcsize(cls._BODY_PACK_STR)
while offset < length:
(word,) = struct.unpack_from(cls._DATA_ELEMENT_PACK_STR,
buf, offset)
@ -5160,19 +5161,13 @@ class OFPTableFeaturePropExperimenter(OFPTableFeatureProp):
def _serialize_prop(self):
# experimenter, exp_type
buf = bytearray()
msg_pack_into(self._PACK_STR, buf, 0, self.experimenter,
msg_pack_into(self._BODY_PACK_STR, buf, 0, self.experimenter,
self.exp_type)
# data
if len(self.data):
ofproto_parser.msg_pack_into('!%dI' % len(self.data),
data_buf, len(buf), *self.data)
# pad
length = super(OFPTableFeaturePropExperimenter, self)._PACK_STR
length += len(buf)
pad_len = utils.round_up(length, 8) - length
ofproto_parser.msg_pack_into("%dx" % pad_len, buf, len(buf))
buf, len(buf), *self.data)
return buf

View File

@ -800,7 +800,19 @@ x() ->
arp_tha,ipv6_src,ipv6_dst,ipv6_flabel,
icmpv6_type,icmpv6_code,ipv6_nd_target,
ipv6_nd_sll,ipv6_nd_tll,mpls_label,mpls_tc,
mpls_bos,pbb_isid]}]},
mpls_bos,pbb_isid]},
#ofp_table_feature_prop_experimenter{
experimenter = 101,
exp_type = 0,
data = <<>>},
#ofp_table_feature_prop_experimenter{
experimenter = 101,
exp_type = 1,
data = <<1:32>>},
#ofp_table_feature_prop_experimenter{
experimenter = 101,
exp_type = 2,
data = <<1:32,2:32>>}]},
#ofp_table_features{
table_id = 1,name = <<"Flow Table 0x01">>,
metadata_match = <<"\377\377\377\377\377\377\377\377">>,

View File

@ -4,7 +4,7 @@
{
"OFPTableFeaturesStats": {
"config": 0,
"length": 1112,
"length": 1168,
"max_entries": 16777216,
"metadata_match": 18446744073709551615,
"metadata_write": 18446744073709551615,
@ -1591,6 +1591,33 @@
],
"type": 14
}
},
{
"OFPTableFeaturePropExperimenter": {
"length": 12,
"type": 65534,
"exp_type": 0,
"experimenter": 101,
"data": []
}
},
{
"OFPTableFeaturePropExperimenter": {
"length": 16,
"type": 65534,
"exp_type": 1,
"experimenter": 101,
"data": [1]
}
},
{
"OFPTableFeaturePropExperimenter": {
"length": 20,
"type": 65534,
"exp_type": 2,
"experimenter": 101,
"data": [1, 2]
}
}
],
"table_id": 0