Signed-off-by: YAMAMOTO Takashi <[email protected]>
---
ryu/ofproto/ofproto_v1_3_parser.py | 32 ++++++++++++++++++++++++++++----
1 file changed, 28 insertions(+), 4 deletions(-)
diff --git a/ryu/ofproto/ofproto_v1_3_parser.py
b/ryu/ofproto/ofproto_v1_3_parser.py
index 390a303..b311fb3 100644
--- a/ryu/ofproto/ofproto_v1_3_parser.py
+++ b/ryu/ofproto/ofproto_v1_3_parser.py
@@ -349,7 +349,7 @@ class FlowWildcards(object):
class OFPMatch(StringifyMixin):
- def __init__(self, fields=[], type_=None, **kwargs):
+ def __init__(self, fields=[], type_=None, _normalize=False, **kwargs):
super(OFPMatch, self).__init__()
self._wc = FlowWildcards()
self._flow = Flow()
@@ -382,8 +382,12 @@ class OFPMatch(StringifyMixin):
# eg.
# OFPMatch(eth_src=('ff:ff:ff:00:00:00'), eth_type=0x800,
# ipv4_src='10.0.0.1')
- self._fields2 = dict(ofproto_v1_3.oxm_normalize_user(k, uv) for (k, uv)
- in kwargs.iteritems())
+ if _normalize:
+ self._fields2 = dict(ofproto_v1_3.oxm_normalize_user(k, uv)
+ for (k, uv)
+ in kwargs.iteritems())
+ else:
+ self._fields2 = kwargs
def __getitem__(self, key):
return self._fields2[key]
@@ -415,13 +419,33 @@ class OFPMatch(StringifyMixin):
@classmethod
def from_jsondict(cls, dict_):
- o = super(OFPMatch, cls).from_jsondict(dict_, lambda x: x)
+ # XXX old api compat
+ # the following _normalize=False is a compat hack.
+ # see test_parser_v12.
+ o = super(OFPMatch, cls).from_jsondict(dict_, lambda x: x,
+ _normalize=False)
# XXX old api compat
# serialize and parse to fill OFPMatch.fields
buf = bytearray()
o.serialize(buf, 0)
return OFPMatch.parser(str(buf), 0)
+ def __str__(self):
+ # XXX old api compat
+ if self._composed_with_old_api():
+ # copy object first because serialize_old is destructive
+ o2 = OFPMatch()
+ o2.fields = self.fields[:]
+ # serialize and parse to fill OFPMatch._fields2
+ buf = bytearray()
+ o2.serialize(buf, 0)
+ o = OFPMatch.parser(str(buf), 0)
+ else:
+ o = self
+ return super(OFPMatch, o).__str__()
+
+ __repr__ = __str__
+
def append_field(self, header, value, mask=None):
self.fields.append(OFPMatchField.make(header, value, mask))
--
1.8.1.5
------------------------------------------------------------------------------
See everything from the browser to the database with AppDynamics
Get end-to-end visibility with application monitoring from AppDynamics
Isolate bottlenecks and diagnose root cause in seconds.
Start your free trial of AppDynamics Pro today!
http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk
_______________________________________________
Ryu-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ryu-devel