mirror of
https://github.com/faucetsdn/ryu.git
synced 2026-05-08 22:06:10 +02:00
of13: new match field parser
add a new match field parser which fills OFPMatch attributes used by the new api. the old parser which fills match.fields is kept for now but will be removed later. Signed-off-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp> Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
This commit is contained in:
parent
b7075a1e26
commit
8aa8fca868
@ -664,14 +664,43 @@ class OFPMatch(StringifyMixin):
|
||||
# ofp_match adjustment
|
||||
offset += 4
|
||||
length -= 4
|
||||
|
||||
# XXXcompat
|
||||
cls.parser_old(match, buf, offset, length)
|
||||
|
||||
fields = {}
|
||||
while length > 0:
|
||||
hdr_pack_str = '!I'
|
||||
(header, ) = struct.unpack_from(hdr_pack_str, buf, offset)
|
||||
hdr_len = struct.calcsize(hdr_pack_str)
|
||||
oxm_type = header >> 9 # class|field
|
||||
oxm_hasmask = ofproto_v1_3.oxm_tlv_header_extract_hasmask(header)
|
||||
value_len = ofproto_v1_3.oxm_tlv_header_extract_length(header)
|
||||
value_pack_str = '!%ds' % value_len
|
||||
assert struct.calcsize(value_pack_str) == value_len
|
||||
(value, ) = struct.unpack_from(value_pack_str, buf,
|
||||
offset + hdr_len)
|
||||
if oxm_hasmask:
|
||||
(mask, ) = struct.unpack_from(value_pack_str, buf,
|
||||
offset + hdr_len + value_len)
|
||||
else:
|
||||
mask = None
|
||||
k, uv = ofproto_v1_3.oxm_to_user(oxm_type, value, mask)
|
||||
fields[k] = uv
|
||||
field_len = hdr_len + (header & 0xff)
|
||||
offset += field_len
|
||||
length -= field_len
|
||||
match._fields2 = fields
|
||||
return match
|
||||
|
||||
@staticmethod
|
||||
def parser_old(match, buf, offset, length):
|
||||
while length > 0:
|
||||
field = OFPMatchField.parser(buf, offset)
|
||||
offset += field.length
|
||||
length -= field.length
|
||||
match.fields.append(field)
|
||||
|
||||
return match
|
||||
|
||||
def set_in_port(self, port):
|
||||
self._wc.ft_set(ofproto_v1_3.OFPXMT_OFB_IN_PORT)
|
||||
self._flow.in_port = port
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user