Rich Lane | 374942e | 2014-10-10 16:25:36 -0700 | [diff] [blame] | 1 | -- binary |
| 2 | 05 13 # version/type |
| 3 | 00 d8 # length |
| 4 | 00 00 00 05 # xid |
| 5 | 00 04 # stats_type |
| 6 | 00 00 # flags |
| 7 | 00 00 00 00 # pad |
| 8 | 00 78 # entries[0].length |
| 9 | 00 00 # pad |
| 10 | 00 00 00 01 # entries[0].port_no |
| 11 | 00 00 00 00 # entries[0].duration_sec |
| 12 | 00 00 00 00 # entries[0].duration_nsec |
| 13 | 00 00 00 00 00 00 00 01 # entries[0].rx_packets |
| 14 | 00 00 00 00 00 00 00 00 # entries[0].tx_packets |
| 15 | 00 00 00 00 00 00 00 00 # entries[0].rx_bytes |
| 16 | 00 00 00 00 00 00 00 00 # entries[0].tx_bytes |
| 17 | 00 00 00 00 00 00 00 00 # entries[0].rx_dropped |
| 18 | 00 00 00 00 00 00 00 00 # entries[0].tx_dropped |
| 19 | 00 00 00 00 00 00 00 00 # entries[0].rx_errors |
| 20 | 00 00 00 00 00 00 00 02 # entries[0].tx_errors |
| 21 | 00 00 # entries[0].properties[0].type (ethernet) |
| 22 | 00 28 # entries[0].properties[0].length |
| 23 | 00 00 00 00 # pad |
| 24 | 00 00 00 00 00 00 00 01 # entries[0].properties[0].rx_frame_err |
| 25 | 00 00 00 00 00 00 00 02 # entries[0].properties[0].rx_over_err |
| 26 | 00 00 00 00 00 00 00 03 # entries[0].properties[0].rx_crc_err |
| 27 | 00 00 00 00 00 00 00 04 # entries[0].properties[0].collisions |
| 28 | 00 50 # entries[1].length |
| 29 | 00 00 # pad |
| 30 | ff ff ff fe # entries[1].port_no |
| 31 | 00 00 00 00 # entries[1].duration_sec |
| 32 | 00 00 00 00 # entries[1].duration_nsec |
| 33 | 00 00 00 00 00 00 00 03 # entries[1].rx_packets |
| 34 | 00 00 00 00 00 00 00 00 # entries[1].tx_packets |
| 35 | 00 00 00 00 00 00 00 00 # entries[1].rx_bytes |
| 36 | 00 00 00 00 00 00 00 00 # entries[1].tx_bytes |
| 37 | 00 00 00 00 00 00 00 00 # entries[1].rx_dropped |
| 38 | 00 00 00 00 00 00 00 00 # entries[1].tx_dropped |
| 39 | 00 00 00 00 00 00 00 00 # entries[1].rx_errors |
| 40 | 00 00 00 00 00 00 00 04 # entries[1].tx_errors |
| 41 | -- python |
| 42 | ofp.message.port_stats_reply( |
| 43 | xid=5, flags=0, entries=[ |
| 44 | ofp.port_stats_entry(port_no=1, rx_packets=1, tx_errors=2, |
| 45 | properties=[ |
| 46 | ofp.port_stats_prop.ethernet( |
| 47 | rx_frame_err=1, |
| 48 | rx_over_err=2, |
| 49 | rx_crc_err=3, |
| 50 | collisions=4)]), |
| 51 | ofp.port_stats_entry(port_no=ofp.OFPP_LOCAL, rx_packets=3, tx_errors=4)]) |
| 52 | -- c |
| 53 | obj = of_port_stats_reply_new(OF_VERSION_1_4); |
| 54 | { |
| 55 | of_object_t list; |
| 56 | of_port_stats_reply_entries_bind(obj, &list); |
| 57 | { |
| 58 | of_object_t *obj = of_port_stats_entry_new(OF_VERSION_1_4); |
| 59 | of_port_stats_entry_port_no_set(obj, 1); |
| 60 | of_port_stats_entry_rx_packets_set(obj, 1); |
| 61 | of_port_stats_entry_tx_packets_set(obj, 0); |
| 62 | of_port_stats_entry_rx_bytes_set(obj, 0); |
| 63 | of_port_stats_entry_tx_bytes_set(obj, 0); |
| 64 | of_port_stats_entry_rx_dropped_set(obj, 0); |
| 65 | of_port_stats_entry_tx_dropped_set(obj, 0); |
| 66 | of_port_stats_entry_rx_errors_set(obj, 0); |
| 67 | of_port_stats_entry_tx_errors_set(obj, 2); |
Rich Lane | 244fdce | 2014-10-14 12:01:36 -0700 | [diff] [blame] | 68 | |
| 69 | /* Append property */ |
| 70 | { |
| 71 | of_object_t list; |
| 72 | of_port_stats_entry_properties_bind(obj, &list); |
| 73 | { |
| 74 | of_object_t *obj = of_port_stats_prop_ethernet_new(OF_VERSION_1_4); |
| 75 | of_port_stats_prop_ethernet_rx_frame_err_set(obj, 1); |
| 76 | of_port_stats_prop_ethernet_rx_over_err_set(obj, 2); |
| 77 | of_port_stats_prop_ethernet_rx_crc_err_set(obj, 3); |
| 78 | of_port_stats_prop_ethernet_collisions_set(obj, 4); |
| 79 | of_list_append(&list, obj); |
| 80 | of_object_delete(obj); |
| 81 | } |
| 82 | } |
| 83 | |
| 84 | |
Rich Lane | 374942e | 2014-10-10 16:25:36 -0700 | [diff] [blame] | 85 | of_list_append(&list, obj); |
| 86 | of_object_delete(obj); |
| 87 | } |
| 88 | { |
| 89 | of_object_t *obj = of_port_stats_entry_new(OF_VERSION_1_4); |
| 90 | of_port_stats_entry_port_no_set(obj, OF_PORT_DEST_LOCAL); |
| 91 | of_port_stats_entry_rx_packets_set(obj, 3); |
| 92 | of_port_stats_entry_tx_packets_set(obj, 0); |
| 93 | of_port_stats_entry_rx_bytes_set(obj, 0); |
| 94 | of_port_stats_entry_tx_bytes_set(obj, 0); |
| 95 | of_port_stats_entry_rx_dropped_set(obj, 0); |
| 96 | of_port_stats_entry_tx_dropped_set(obj, 0); |
| 97 | of_port_stats_entry_rx_errors_set(obj, 0); |
| 98 | of_port_stats_entry_tx_errors_set(obj, 4); |
| 99 | of_list_append(&list, obj); |
| 100 | of_object_delete(obj); |
| 101 | } |
| 102 | } |
| 103 | of_port_stats_reply_flags_set(obj, 0); |
| 104 | of_port_stats_reply_xid_set(obj, 5); |