Errc to_view(View& v, const Stats_reply& m) { if (remaining(v) < bytes(m)) return Errc::STATS_REPLY_OVERFLOW; to_view(v, m.header); return to_view(v, m.payload, m.header.type); }
Errc to_view(View& v, const Queue_stats_request& m) { to_view(v, m.port_number); pad(v, 2); to_view(v, m.queue_id); return {}; }
Errc to_view(View& v, const Stats_header& m) { if (not is_valid(m.type)) // Required semantic check return Errc::BAD_STATS_TYPE; to_view(v, m.type); to_view(v, m.flags); return {}; }
Errc to_view(View& v, const Set_config& m) { if (remaining(v) < bytes(m)) return Errc::CONFIG_OVERFLOW; to_view(v, m.flags); to_view(v, m.miss_send_len); return {}; }
Errc to_view(View& v, const Flow_stats_request& m) { to_view(v, m.match); to_view(v, m.table_id); pad(v, 1); to_view(v, m.out_port); return {}; }
Errc to_view(View& v, const Queue_config_reply& m) { if (remaining(v) < bytes(m)) return Errc::QUEUE_CONFIG_REPLY_OVERFLOW; to_view(v, m.port); to_view(v, m.queues); return {}; }
Errc to_view(View& v, const Aggregate_stats& m) { to_view(v, m.packet_count); to_view(v, m.byte_count); to_view(v, m.flow_count); pad(v, 4); return {}; }
Errc to_view(View& v, const Vendor_stats& m) { if (remaining(v) < bytes(m)) return Errc::VENDOR_STATS_OVERFLOW; to_view(v, m.vendor_id); to_view(v, m.data); return {}; }
Errc to_view(View& v, const Port_status& m) { if (remaining(v) < bytes(m)) return Errc::PACKET_OUT_OVERFLOW; to_view(v, m.reason); pad(v, 7); to_view(v, m.port); return {}; }
Errc to_view(View& v, const Error& m) { if (remaining(v) < bytes(m)) return Errc::ERROR_OVERFLOW; to_view(v, m.type); to_view(v, m.code); to_view(v, m.data); return {}; }
Errc to_view(View& v, const Description_stats& m) { to_view(v, m.mfr_desc); to_view(v, m.hw_desc); to_view(v, m.sw_desc); to_view(v, m.serial_number); to_view(v, m.dp_desc); return {}; }
Errc to_view(View& v, const Message& m) { if (remaining(v) < bytes(m)) return Errc::MESSAGE_OVERFLOW; // FIXME: not the right code? to_view(v, m.header); // TODO: Constrain the view? return to_view(v, m.payload, m.header.type); }
Errc to_view(View& v, const Queue_stats_entry& m) { if (m.length != 32) // Required semantic check return Errc::BAD_QUEUE_STATS_LENGTH; to_view(v, m.length); pad(v, 2); to_view(v, m.tx_bytes); to_view(v, m.tx_packets); to_view(v, m.tx_errors); return {}; }
Errc to_view(View& v, const Port_mod& m) { if (remaining(v) < bytes(m)) return Errc::PORT_MOD_OVERFLOW; to_view(v, m.port); to_view(v, m.hw_addr); to_view(v, m.config); to_view(v, m.mask); to_view(v, m.advertised); return {}; }
Errc to_view(View& v, const Queue& m) { if (remaining(v) < bytes(m)) return Errc::PROPERTY_OVERFLOW; if (m.length < bytes(m)) return Errc::BAD_QUEUE_LENGTH; to_view(v, m.queue_id); to_view(v, m.length); pad(v, 2); to_view(v, m.properties); return {}; }
Errc to_view(View& v, const Packet_in& m) { if (remaining(v) < bytes(m)) return Errc::PACKET_IN_OVERFLOW; to_view(v, m.buffer_id); to_view(v, m.total_len); to_view(v, m.in_port); to_view(v, m.reason); pad(v, 1); to_view(v, m.data); return {}; }
Errc to_view(View& v, const Header& m) { if (not is_valid(m.version)) // Optional semantic check return Errc::BAD_VERSION; if (not is_valid(m.type)) // Required semantic check return Errc::BAD_MESSAGE_TYPE; if (m.length < bytes(m)) // Required semantic check return Errc::BAD_HEADER_LENGTH; to_view(v, m.version); to_view(v, m.type); to_view(v, m.length); to_view(v, m.xid); return {}; }
Error to_view(View& v, const Header& h) { if (v.remaining() < bytes(h)) return make_error_code(errc::header_overflow); // Minimum semantic checking if (h.length < bytes(h)); return make_error_code(errc::bad_header_length); to_view(v, h.version); to_view(v, h.type); to_view(v, h.length); to_view(v, h.xid); }
Errc to_view(View& v, const Flow_mod& m) { if (remaining(v) < bytes(m)) return Errc::FLOW_MOD_OVERFLOW; to_view(v, m.match); to_view(v, m.cookie); to_view(v, m.command); to_view(v, m.idle_timeout); to_view(v, m.hard_timeout); to_view(v, m.priority); to_view(v, m.buffer_id); to_view(v, m.out_port); to_view(v, m.flags); return to_view(v, m.actions); }
Errc to_view(View& v, const Echo_reply& m) { if (remaining(v) < bytes(m)) return Errc::HELLO_OVERFLOW; to_view(v, m.data); return {}; }
Errc to_view(View& v, const Property& m) { if (not is_valid(m.property)) // Requried semantic check return Errc::BAD_PROPERTY_TYPE; if (m.length < bytes(m)) // Required semantic check return Errc::BAD_PROPERTY_LENGTH; to_view(v, m.property); to_view(v, m.length); pad(v, 4); if (Constrained_view c = constrain(v, m.length - bytes(m))) return to_view(c, m.value, m.property); else return {}; }
Errc to_view(View& v, const Packet_out& m) { if (remaining(v) < bytes(m)) return Errc::PACKET_OUT_OVERFLOW; to_view(v, m.buffer_id); to_view(v, m.port); to_view(v, m.actions_len); if (Constrained_view c = constrain(v, m.actions_len)) { if (Trap err = to_view(v, m.actions)) return err.code(); } else { return Errc::PACKET_OUT_OVERFLOW; } to_view(v, m.data); return {}; }
Errc to_view(View& v, const Flow_removed& m) { if (remaining(v) < bytes(m)) return Errc::FLOW_REMOVED_OVERFLOW; to_view(v, m.match); to_view(v, m.cookie); to_view(v, m.priority); to_view(v, m.reason); pad(v, 1); to_view(v, m.duration_sec); to_view(v, m.duration_nsec); to_view(v, m.idle_timeout); pad(v, 2); to_view(v, m.packet_count); to_view(v, m.byte_count); return {}; }
Errc to_view(View& v, const Table_stats_entry& m) { to_view(v, m.table_id); pad(v, 3); to_view(v, m.name); to_view(v, m.wildcards); to_view(v, m.max_entries); to_view(v, m.active_count); to_view(v, m.lookup_count); to_view(v, m.matched_count); return {}; }
Errc to_view(View& v, const Stats_reply_payload& m, Stats_type t) { switch(t) { case STATS_DESC: return to_view(v, m.desc); case STATS_FLOW: return to_view(v, m.flow); case STATS_AGGREGATE: return to_view(v, m.aggr); case STATS_TABLE: return to_view(v, m.table); case STATS_PORT: return to_view(v, m.port); case STATS_QUEUE: return to_view(v, m.queue); case STATS_VENDOR: return to_view(v, m.vendor); default: break; } throw Errc::BAD_STATS_TYPE; }
Errc to_view(View& v, const Feature_reply& m) { if (remaining(v) < bytes(m)) return Errc::FEATURE_OVERFLOW; to_view(v, m.datapath_id); to_view(v, m.nbuffers); to_view(v, m.ntables); pad(v, 3); to_view(v, m.capabilities); to_view(v, m.actions); to_view(v, m.ports); return {}; }
Errc to_view(View& v, const Port_stats_request& m) { to_view(v, m.port_number); pad(v, 6); return {}; }
Errc to_view(View& v, const Vendor_stats_request& m) { to_view(v, m.vendor_id); return {}; }
Errc to_view(View& v, const Port_stats_entry& m) { to_view(v, m.port_number); pad(v, 6); to_view(v, m.rx_packets); to_view(v, m.tx_packets); to_view(v, m.rx_bytes); to_view(v, m.tx_bytes); to_view(v, m.rx_dropped); to_view(v, m.tx_dropped); to_view(v, m.rx_errors); to_view(v, m.tx_errors); to_view(v, m.rx_frame_err); to_view(v, m.rx_over_err); to_view(v, m.rx_crc_err); to_view(v, m.collisions); return {}; }
Errc to_view(View& v, const Flow_stats_entry& m) { if (m.length < bytes(m)) // Required semantic check return Errc::BAD_FLOW_STATS_LENGTH; to_view(v, m.length); to_view(v, m.table_id); pad(v, 1); to_view(v, m.match); to_view(v, m.duration_sec); to_view(v, m.duration_nsec); to_view(v, m.priority); to_view(v, m.idle_timeout); to_view(v, m.hard_timeout); pad(v, 6); to_view(v, m.cookie); to_view(v, m.packet_count); to_view(v, m.byte_count); if (Constrained_view c = constrain(v, m.length - bytes(m))) return to_view(c, m.actions); return Errc::FLOW_STATS_OVERFLOW; }