On Mon, Apr 22, 2013 at 04:50:26PM +0800, Can Zhang wrote: > Signed-off-by: Can Zhang <[email protected]> > --- > ryu/ofproto/ofproto_v1_0_parser.py | 45 > ++++++++++++++++++++++++-------------- > 1 file changed, 28 insertions(+), 17 deletions(-) > > diff --git a/ryu/ofproto/ofproto_v1_0_parser.py > b/ryu/ofproto/ofproto_v1_0_parser.py > index 7945888..a9520aa 100644 > --- a/ryu/ofproto/ofproto_v1_0_parser.py > +++ b/ryu/ofproto/ofproto_v1_0_parser.py > @@ -90,25 +90,36 @@ class OFPPhyPort(collections.namedtuple('OFPPhyPort', ( > return cls(*port) > > > -class OFPMatch(collections.namedtuple('OFPMatchBase', ( > - 'wildcards', 'in_port', 'dl_src', 'dl_dst', 'dl_vlan', > - 'dl_vlan_pcp', 'dl_type', 'nw_tos', 'nw_proto', > - 'nw_src', 'nw_dst', 'tp_src', 'tp_dst'))): > - > - def __new__(cls, *args): > - # for convenience when dl_src/dl_dst are wildcard > - if args[2] != 0 and args[3] != 0: > - return super(cls, OFPMatch).__new__(cls, *args) > - > - tmp = list(args) > - if tmp[2] == 0: > - tmp[2] = mac.DONTCARE > - if tmp[3] == 0: > - tmp[3] = mac.DONTCARE > - return super(cls, OFPMatch).__new__(cls, *tmp) > +class OFPMatch(object): > + def __init__(self, wildcards, in_port, dl_src, dl_dst, dl_vlan, > + dl_vlan_pcp, dl_type, nw_tos, nw_proto, nw_src, > + nw_dst, tp_src, tp_dst):
please put super().__init__(). Otherwise looks good. thanks, > + self.wildcards = wildcards > + self.in_port = in_port > + if dl_src == 0: > + self.dl_src = mac.DONTCARE > + else: > + self.dl_src = dl_src > + if dl_dst == 0: > + self.dl_dst = mac.DONTCARE > + else: > + self.dl_dst = dl_dst > + self.dl_vlan = dl_vlan > + self.dl_vlan_pcp = dl_vlan_pcp > + self.dl_type = dl_type > + self.nw_tos = nw_tos > + self.nw_proto = nw_proto > + self.nw_src = nw_src > + self.nw_dst = nw_dst > + self.tp_src = tp_src > + self.tp_dst = tp_dst > > def serialize(self, buf, offset): > - msg_pack_into(ofproto_v1_0.OFP_MATCH_PACK_STR, buf, offset, *self) > + msg_pack_into(ofproto_v1_0.OFP_MATCH_PACK_STR, buf, offset, > + self.wildcards, self.in_port, self.dl_src, > + self.dl_dst, self.dl_vlan, self.dl_vlan_pcp, > + self.dl_type, self.nw_tos, self.nw_proto, > + self.nw_src, self.nw_dst, self.tp_src, self.tp_dst) > > @classmethod > def parse(cls, buf, offset): > -- > 1.7.11.1 > > > ------------------------------------------------------------------------------ > Precog is a next-generation analytics platform capable of advanced > analytics on semi-structured data. The platform includes APIs for building > apps and a phenomenal toolset for data science. Developers can use > our toolset for easy data analysis & visualization. Get a free account! > http://www2.precog.com/precogplatform/slashdotnewsletter > _______________________________________________ > Ryu-devel mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/ryu-devel > -- yamahata ------------------------------------------------------------------------------ Try New Relic Now & We'll Send You this Cool Shirt New Relic is the only SaaS-based application performance monitoring service that delivers powerful full stack analytics. Optimize and monitor your browser, app, & servers with just a few lines of code. Try New Relic and get this awesome Nerd Life shirt! http://p.sf.net/sfu/newrelic_d2d_apr _______________________________________________ Ryu-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/ryu-devel
