match.nw_dst, like most IP addresses in POX, is an IPAddr object (as discussed in the manual and in the reference for pox.lib.addresses). You can't compare it against a string that isn't a valid IP address -- and the one you're supplying isn't (since it has the prefix size). But it appears that what you're doing will *never* be true. from_packet() creates an exact match -- not a /24 subnet match -- so the match will never have a /24 subnet match. If what you want is to see whether the match has an address that falls in that subnet, you want to use IPAddr's .in_network...
if match.nw_dst.in_network("192.168.11.0/24"): ... Of course, this assumes that nw_dst isn't None (because it wasn't an IP packet). You may well be better of using the packet object itself. Finding the IP header and using its dstip attribute instead of the one in the match object. Among other things, the one in the match may have been set when the packet is ARP as well as IP, which may not be what you wanted. Incidentally, if one *does* want to actually read the IP wildcards from a match object, doing so is described in the manual in the "Match Structure" section. -- Murphy On Mar 5, 2014, at 5:52 AM, ㄜˊ ㄋㄣˋ ㄜˊ ㄋㄣˋ <rabbi...@hotmail.com> wrote: > Hi, everyone > I want to match netmask,but it will occur error > This is my code below > > case1: > > match = of.ofp_match.from_packet(packet) > if match.nw_dst == "192.168.11.0/24": > print 'It's Work' > > The Error : > AttributeError: 'str' object has no attribute '__cmp__' > > case2: > > m = nx.nx_match() > if m.of_ip_src == "192.168.11.0/24": > print m.of_ip_src > #But print None .. > > > What should I do to match src_ip in the subnet? > How to solve this Problem? > > I will appreciate your reply ! > Thanks !