enum wps_process_res wps_enrollee_process_msg(struct wps_data *wps,
                          enum wsc_op_code op_code,
                          const struct wpabuf *msg)
{

    wpa_printf(MSG_DEBUG, "WPS: Processing received message (len=%lu "
           "op_code=%d)",
           (unsigned long) wpabuf_len(msg), op_code);

    switch (op_code) {
    case WSC_MSG:
    case WSC_UPnP:
        return wps_process_wsc_msg(wps, msg);
    case WSC_ACK:
        return wps_process_wsc_ack(wps, msg);
    case WSC_NACK:
        return wps_process_wsc_nack(wps, msg);
    default:
        wpa_printf(MSG_DEBUG, "WPS: Unsupported op_code %d", op_code);
        return WPS_FAILURE;
    }
}
Esempio n. 2
0
enum wps_process_res wps_enrollee_process_msg(struct wps_data *wps,
					      enum wsc_op_code op_code,
					      const struct wpabuf *msg)
{

	wpa_printf(MSG_DEBUG, "WPS: Processing received message (len=%lu "
		   "op_code=%d)",
		   (unsigned long) wpabuf_len(msg), op_code);

	if (op_code == WSC_UPnP) {
		/* Determine the OpCode based on message type attribute */
		struct wps_parse_attr attr;
		if (wps_parse_msg(msg, &attr) == 0 && attr.msg_type) {
			if (*attr.msg_type == WPS_WSC_ACK)
				op_code = WSC_ACK;
			else if (*attr.msg_type == WPS_WSC_NACK)
				op_code = WSC_NACK;
		}
	}

	switch (op_code) {
	case WSC_MSG:
	case WSC_UPnP:
		return wps_process_wsc_msg(wps, msg);
	case WSC_ACK:
		if (wps_validate_wsc_ack(msg) < 0)
			return WPS_FAILURE;
		return wps_process_wsc_ack(wps, msg);
	case WSC_NACK:
		if (wps_validate_wsc_nack(msg) < 0)
			return WPS_FAILURE;
		return wps_process_wsc_nack(wps, msg);
	default:
		wpa_printf(MSG_DEBUG, "WPS: Unsupported op_code %d", op_code);
		return WPS_FAILURE;
	}
}