ofl_err ofl_exp_msg_unpack(struct ofp_header *oh, size_t *len, struct ofl_msg_experimenter **msg) { struct ofp_experimenter_header *exp; if (*len < sizeof(struct ofp_experimenter_header)) { OFL_LOG_WARN(LOG_MODULE, "Received EXPERIMENTER message is shorter than ofp_experimenter_header."); return ofl_error(OFPET_BAD_REQUEST, OFPBRC_BAD_LEN); } exp = (struct ofp_experimenter_header *)oh; switch (htonl(exp->experimenter)) { case (OPENFLOW_VENDOR_ID): { return ofl_exp_openflow_msg_unpack(oh, len, msg); } /* Acrescentado pelo FRESDWN case (NX_VENDOR_ID): { return ofl_exp_nicira_msg_unpack(oh, len, msg); } */ case (NX_VENDOR_ID): { return ofl_exp_nicira_msg_unpack(oh, len, msg); } case (FRESDWN_VENDOR_ID): { return ofl_exp_fresdwn_msg_unpack(oh, len, msg); } default: { OFL_LOG_WARN(LOG_MODULE, "Trying to unpack unknown EXPERIMENTER message (%u).", htonl(exp->experimenter)); return ofl_error(OFPET_BAD_REQUEST, OFPBRC_BAD_EXPERIMENTER); } } }
ofl_err ofl_exp_msg_unpack(struct ofp_header const *oh, size_t *len, struct ofl_msg_experimenter **msg, struct ofl_exp const * ofl_exp) { struct ofp_experimenter_header *exp; if (*len < sizeof(struct ofp_experimenter_header)) { OFL_LOG_WARN(LOG_MODULE, "Received EXPERIMENTER message is shorter than ofp_experimenter_header."); return ofl_error(OFPET_BAD_REQUEST, OFPBRC_BAD_LEN); } exp = (struct ofp_experimenter_header *)oh; switch (ntohl(exp->experimenter)) { case (OPENFLOW_VENDOR_ID): { return ofl_exp_openflow_msg_unpack(oh, len, msg); } case (NX_VENDOR_ID): { return ofl_exp_nicira_msg_unpack(oh, len, msg); } case (BEBA_VENDOR_ID): { return ofl_exp_beba_msg_unpack(oh, len, msg, ofl_exp); } default: { OFL_LOG_WARN(LOG_MODULE, "Trying to unpack unknown EXPERIMENTER message (%u).", ntohl(exp->experimenter)); return ofl_error(OFPET_BAD_REQUEST, OFPBRC_BAD_EXPERIMENTER); } } }