diff options
author | watanabe.fumitaka <watanabe.fumitaka@nttcom.co.jp> | 2013-03-21 18:02:19 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2013-03-25 06:48:03 +0900 |
commit | b4424c92d9d47ea07e4cb86339f47cd989835422 (patch) | |
tree | 331ffadf0500ce7acc3c60ffc52e47a5dc2da984 | |
parent | 90b084a6eb6c05c7c1ea985e51e6bb6a1891edc5 (diff) |
update ofctl_v1_0 library
This patch contains the update for ofctl_v1_0 library.
Signed-off-by: WATANABE Fumitaka <watanabe.fumitaka@nttcom.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
-rw-r--r-- | ryu/lib/ofctl_v1_0.py | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/ryu/lib/ofctl_v1_0.py b/ryu/lib/ofctl_v1_0.py index 1184b9b5..ad474705 100644 --- a/ryu/lib/ofctl_v1_0.py +++ b/ryu/lib/ofctl_v1_0.py @@ -101,7 +101,7 @@ def to_match(dp, attrs): wildcards &= ~ofp.OFPFW_IN_PORT elif key == 'dl_src': dl_src = haddr_to_bin(value) - wildcards &= ~ofp.OFPFW_DL_DST + wildcards &= ~ofp.OFPFW_DL_SRC elif key == 'dl_dst': dl_dst = haddr_to_bin(value) wildcards &= ~ofp.OFPFW_DL_DST @@ -163,13 +163,35 @@ def match_to_str(m): 'dl_vlan': m.dl_vlan, 'dl_vlan_pcp': m.dl_vlan_pcp, 'in_port': m.in_port, - 'nw_dst': socket.inet_ntoa(struct.pack('!I', m.nw_dst)), + 'nw_dst': nw_dst_to_str(m.wildcards, m.nw_dst), 'nw_proto': m.nw_proto, - 'nw_src': socket.inet_ntoa(struct.pack('!I', m.nw_src)), + 'nw_src': nw_src_to_str(m.wildcards, m.nw_src), 'tp_src': m.tp_src, 'tp_dst': m.tp_dst} +def nw_src_to_str(wildcards, addr): + ip = socket.inet_ntoa(struct.pack('!I', addr)) + mask = 32 - ((wildcards & ofproto_v1_0.OFPFW_NW_SRC_MASK) + >> ofproto_v1_0.OFPFW_NW_SRC_SHIFT) + if mask == 32: + mask = 0 + if mask: + ip += '/%d' % mask + return ip + + +def nw_dst_to_str(wildcards, addr): + ip = socket.inet_ntoa(struct.pack('!I', addr)) + mask = 32 - ((wildcards & ofproto_v1_0.OFPFW_NW_DST_MASK) + >> ofproto_v1_0.OFPFW_NW_DST_SHIFT) + if mask == 32: + mask = 0 + if mask: + ip += '/%d' % mask + return ip + + def send_stats_request(dp, stats, waiters, msgs): dp.set_xid(stats) waiters_per_dp = waiters.setdefault(dp.id, {}) |