mirror of
https://github.com/faucetsdn/ryu.git
synced 2026-05-08 13:56:09 +02:00
ofctl_v1_3.py: Add get_desc_stats & get_port_stats from ofctl_v1_0.py.
ofctl_v1_3 lacks of get_desc_stats & get_port_stats methods which is available in ofctl_v1_0. I copied the code from ofctl_v1_0 and it works fine. The only change to get_port_stats in ofctl_v1_3 is using OFPP_ANY as argument to call OFPPortStatsRequest. Signed-off-by: Wei-Li Tang <alextwl@xinguard.com> Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
This commit is contained in:
parent
2da9a7cf1f
commit
805ae1f796
@ -202,6 +202,22 @@ def send_stats_request(dp, stats, waiters, msgs):
|
||||
del waiters_per_dp[stats.xid]
|
||||
|
||||
|
||||
def get_desc_stats(dp, waiters):
|
||||
stats = dp.ofproto_parser.OFPDescStatsRequest(dp, 0)
|
||||
msgs = []
|
||||
send_stats_request(dp, stats, waiters, msgs)
|
||||
|
||||
for msg in msgs:
|
||||
stats = msg.body
|
||||
s = {'mfr_desc': stats.mfr_desc,
|
||||
'hw_desc': stats.hw_desc,
|
||||
'sw_desc': stats.sw_desc,
|
||||
'serial_num': stats.serial_num,
|
||||
'dp_desc': stats.dp_desc}
|
||||
desc = {str(dp.id): s}
|
||||
return desc
|
||||
|
||||
|
||||
def get_flow_stats(dp, waiters):
|
||||
table_id = 0
|
||||
flags = 0
|
||||
@ -243,6 +259,33 @@ def get_flow_stats(dp, waiters):
|
||||
return flows
|
||||
|
||||
|
||||
def get_port_stats(dp, waiters):
|
||||
stats = dp.ofproto_parser.OFPPortStatsRequest(
|
||||
dp, 0, dp.ofproto.OFPP_ANY)
|
||||
msgs = []
|
||||
send_stats_request(dp, stats, waiters, msgs)
|
||||
|
||||
ports = []
|
||||
for msg in msgs:
|
||||
for stats in msg.body:
|
||||
s = {'port_no': stats.port_no,
|
||||
'rx_packets': stats.rx_packets,
|
||||
'tx_packets': stats.tx_packets,
|
||||
'rx_bytes': stats.rx_bytes,
|
||||
'tx_bytes': stats.tx_bytes,
|
||||
'rx_dropped': stats.rx_dropped,
|
||||
'tx_dropped': stats.tx_dropped,
|
||||
'rx_errors': stats.rx_errors,
|
||||
'tx_errors': stats.tx_errors,
|
||||
'rx_frame_err': stats.rx_frame_err,
|
||||
'rx_over_err': stats.rx_over_err,
|
||||
'rx_crc_err': stats.rx_crc_err,
|
||||
'collisions': stats.collisions}
|
||||
ports.append(s)
|
||||
ports = {str(dp.id): ports}
|
||||
return ports
|
||||
|
||||
|
||||
def mod_flow_entry(dp, flow, cmd):
|
||||
cookie = int(flow.get('cookie', 0))
|
||||
cookie_mask = int(flow.get('cookie_mask', 0))
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user