Skip to content

Commit

Permalink
ofctl_v1_3.py: Add get_desc_stats & get_port_stats from ofctl_v1_0.py.
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
alextwl authored and fujita committed Nov 7, 2013
1 parent 2da9a7c commit 805ae1f
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions ryu/lib/ofctl_v1_3.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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))
Expand Down

0 comments on commit 805ae1f

Please sign in to comment.