Currently, ofproto_v1_0_parser does not support query with a match field name like ofproto_v1_[2345]_parser support. This patch adds __getitem__ method in order to get the match value witch a match field name.
Signed-off-by: IWASE Yusuke <[email protected]> --- ryu/ofproto/ofproto_v1_0_parser.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/ryu/ofproto/ofproto_v1_0_parser.py b/ryu/ofproto/ofproto_v1_0_parser.py index 4001b07..9f0e4ff 100644 --- a/ryu/ofproto/ofproto_v1_0_parser.py +++ b/ryu/ofproto/ofproto_v1_0_parser.py @@ -205,6 +205,27 @@ class OFPMatch(StringifyMixin): else: self.wildcards = wildcards + def __getitem__(self, name): + if not isinstance(name, str): + raise KeyError(name) + elif name == 'nw_src_mask': + _m = 32 - ((self.wildcards & ofproto.OFPFW_NW_SRC_MASK) >> + ofproto.OFPFW_NW_SRC_SHIFT) + return 0 if _m < 0 else _m + elif name == 'nw_dst_mask': + _m = 32 - ((self.wildcards & ofproto.OFPFW_NW_DST_MASK) >> + ofproto.OFPFW_NW_DST_SHIFT) + return 0 if _m < 0 else _m + elif name == 'wildcards': + return self.wildcards + + wc_name = 'OFPFW_' + name.upper() + wc = getattr(ofproto, wc_name, ofproto.OFPFW_ALL) + if self.wildcards & ~wc: + return getattr(self, name) + else: + raise KeyError(name) + def serialize(self, buf, offset): msg_pack_into(ofproto.OFP_MATCH_PACK_STR, buf, offset, self.wildcards, self.in_port, self.dl_src, -- 1.9.1 ------------------------------------------------------------------------------ Monitor Your Dynamic Infrastructure at Any Scale With Datadog! Get real-time metrics from all of your servers, apps and tools in one place. SourceForge users - Click here to start your Free Trial of Datadog now! http://pubads.g.doubleclick.net/gampad/clk?id=241902991&iu=/4140 _______________________________________________ Ryu-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/ryu-devel
