void ofperr_msg_format(struct ds *string, enum ofperr error, const struct ofpbuf *payload, const struct ofputil_port_map *port_map, const struct ofputil_table_map *table_map) { ds_put_format(string, " %s\n", ofperr_get_name(error)); if (error == OFPERR_OFPHFC_INCOMPATIBLE || error == OFPERR_OFPHFC_EPERM) { ds_put_printable(string, payload->data, payload->size); } else { char *s = ofp_to_string(payload->data, payload->size, port_map, table_map, 1); ds_put_cstr(string, s); free(s); } }
void ofputil_format_bundle_add(struct ds *s, const struct ofputil_bundle_add_msg *badd, const struct ofputil_port_map *port_map, const struct ofputil_table_map *table_map, int verbosity) { ds_put_char(s, '\n'); ds_put_format(s, " bundle_id=%#"PRIx32, badd->bundle_id); ds_put_cstr(s, " flags="); ofp_print_bit_names(s, badd->flags, bundle_flags_to_name, ' '); ds_put_char(s, '\n'); char *msg = ofp_to_string(badd->msg, ntohs(badd->msg->length), port_map, table_map, verbosity); ds_put_and_free_cstr(s, msg); }
/* Processes 'msg', which should be an OpenFlow received on 'rconn', according * to the learning switch state in 'sw'. The most likely result of processing * is that flow-setup and packet-out OpenFlow messages will be sent out on * 'rconn'. */ static void lswitch_process_packet(struct lswitch *sw, const struct ofpbuf *msg) { enum ofptype type; struct ofpbuf b; b = *msg; if (ofptype_pull(&type, &b)) { return; } if (sw->state == S_FEATURES_REPLY && type != OFPTYPE_ECHO_REQUEST && type != OFPTYPE_FEATURES_REPLY) { return; } if (type == OFPTYPE_ECHO_REQUEST) { process_echo_request(sw, msg->data); } else if (type == OFPTYPE_FEATURES_REPLY) { if (sw->state == S_FEATURES_REPLY) { if (!process_switch_features(sw, msg->data)) { sw->state = S_SWITCHING; } else { rconn_disconnect(sw->rconn); } } } else if (type == OFPTYPE_PACKET_IN) { process_packet_in(sw, msg->data); } else if (type == OFPTYPE_FLOW_REMOVED) { /* Nothing to do. */ } else if (VLOG_IS_DBG_ENABLED()) { char *s = ofp_to_string(msg->data, msg->size, 2); VLOG_DBG_RL(&rl, "%016llx: OpenFlow packet ignored: %s", sw->datapath_id, s); free(s); } }