software/drivers/sd8887/src/wlan/mapp/mlanevent/mlanevent.c
/**
 *  @brief Parse and print WIFIDIRECT generic event data
 *
 *  @param buffer   Pointer to received buffer
 *  @param size     Length of the received event data
 *  @return         N/A
 */
@brief Parse and print WIFIDIRECT generic event data
@param buffer   Pointer to received buffer
@param size     Length of the received event data
@return         N/A
@brief Parse and print WIFIDIRECT generic event data @param buffer Pointer to received buffer @param size Length of the received event data @return N / A
void
print_event_wifidirect_generic(t_u8 *buffer, t_u16 size)
{
	const t_u8 wifi_oui[3] = { 0x50, 0x6F, 0x9A };
	const t_u8 wps_oui[3] = { 0x00, 0x50, 0xF2 };
	apeventbuf_wifidirect_generic *wifidirect_event;
	wifidirect_ie_header *wifidirect_wps_header;
	t_u16 wifidirect_wps_len = 0, type, sub_type;
	printf("EVENT: WIFIDIRECT \n");
	wifidirect_event = (apeventbuf_wifidirect_generic *)(buffer);
	printf("Event length = %d\n",
	       uap_le16_to_cpu(wifidirect_event->event_length));
	printf("Event Type = ");
	type = uap_le16_to_cpu(wifidirect_event->event_type);
	switch (type) {
	case 0:
		printf("Negotiation Request\n");
		break;
	case 1:
		printf("Negotiation Response\n");
		break;
	case 2:
		printf("Negotiation Result\n");
		break;
	case 3:
		printf("Invitation Request\n");
		break;
	case 4:
		printf("Invitation Response\n");
		break;
	case 5:
		printf("Discoverability Request\n");
		break;
	case 6:
		printf("Discoverability Response\n");
		break;
	case 7:
		printf("Provision Discovery Request\n");
		break;
	case 8:
		printf("Provision Discovery Response\n");
		break;
	case 9:
		printf("GO Negotiation response Tx Event\n");
		break;
	case 10:
		printf("GO Negotiation confirm Tx Event\n");
		break;
	case 14:
		printf("Peer Detected event\n");
		break;
	case 15:
		printf("Client associated event\n");
		break;
	case 16:
		printf("FW debug event: %s\n",
		       wifidirect_event->entire_ie_list);
		return;
	default:
		printf("Unknown\n");
		break;
	}
	sub_type = uap_le16_to_cpu(wifidirect_event->event_sub_type);
	if (type == 2) {
		switch (sub_type) {
		case 0:
			printf("Event SubType = No Role\n");
			break;
		case 1:
			printf("Event SubType = Group Owner Role\n");
			break;
		case 2:
			printf("Event SubType = Client Role\n");
			break;
		default:
			printf("Event SubType = %d\n", sub_type);
			break;
		}
	} else if (type == 3 || type == 4) {
		switch (sub_type & 0x03) {	
		case 0:
			printf("Event SubType = No Role\n");
			break;
		case 1:
			printf("Event SubType = Group Owner Role\n");
			break;
		case 2:
			printf("Event SubType = Client Role\n");
			break;
		}
		switch ((sub_type & 0x1C) >> 2) {	
		case 0:
			printf("Packet processing state = None\n");
			break;
		case 1:
			printf("Packet processing state = Processing\n");
			break;
		case 2:
			printf("Packet processing state = Insufficient information, Dropped\n");
			break;
		case 3:
			printf("Packet processing state = Success\n");
			break;
		case 4:
			printf("Packet processing state = Fail\n");
			break;
		default:
			printf("Event SubType = %d\n", sub_type);
			break;
		}
	} else if (type == 7 || type == 8) {
		switch (sub_type) {
		case 0:
			printf("Event SubType = No Config Method\n");
			break;
		case 8:
			printf("Event SubType = Config Method Display\n");
			break;
		case 0x80:
			printf("Event SubType = Config Method Push Button\n");
			break;
		case 0x100:
			printf("Event SubType = Config Method Keypad\n");
			break;
		default:
			printf("Event SubType = %d\n", sub_type);
			break;
		}
	}
	printf("Peer Mac Address - ");
	print_mac(wifidirect_event->peer_mac_addr);
	printf("\n");
	wifidirect_wps_header =
		(wifidirect_ie_header *)(wifidirect_event->entire_ie_list);
	wifidirect_wps_len = uap_le16_to_cpu(wifidirect_event->event_length)
		- sizeof(apeventbuf_wifidirect_generic);
	while (wifidirect_wps_len >= sizeof(wifidirect_ie_header)) {
		if (!memcmp
		    (wifidirect_wps_header->oui, wifi_oui, sizeof(wifi_oui)) ||
		    !(memcmp
		      (wifidirect_wps_header->oui, wps_oui, sizeof(wps_oui)))) {
			switch (wifidirect_wps_header->oui_type) {
			case WIFIDIRECT_OUI_TYPE:
				print_wifidirect_ie_elements
					(wifidirect_wps_header->ie_list,
					 wifidirect_wps_header->ie_length -
					 sizeof(wifidirect_wps_header->oui)
					 -
					 sizeof(wifidirect_wps_header->
						oui_type));
				printf("\n");
				break;
			case WIFI_WPS_OUI_TYPE:
				print_wifi_wps_ie_elements
					(wifidirect_wps_header->ie_list,
					 wifidirect_wps_header->ie_length -
					 sizeof(wifidirect_wps_header->oui)
					 -
					 sizeof(wifidirect_wps_header->
						oui_type));
				printf("\n");
				break;
			}
		}
		wifidirect_wps_len -=
			wifidirect_wps_header->ie_length + IE_HEADER_LEN;
		wifidirect_wps_header =
			(wifidirect_ie_header *)(((t_u8 *)wifidirect_wps_header)
						 +
						 wifidirect_wps_header->
						 ie_length + IE_HEADER_LEN);
	}
}
void print_event_wifidirect_generic ( t_u8 * buffer , t_u16 size ) { const t_u8 wifi_oui [ 3 ] = { 0x50 , 0x6F , 0x9A } ; const t_u8 wps_oui [ 3 ] = { 0x00 , 0x50 , 0xF2 } ; apeventbuf_wifidirect_generic * wifidirect_event ; wifidirect_ie_header * wifidirect_wps_header ; t_u16 wifidirect_wps_len = 0 , type , sub_type ; printf ( " \n " ) ; wifidirect_event = ( apeventbuf_wifidirect_generic * ) ( buffer ) ; printf ( " \n " , uap_le16_to_cpu ( wifidirect_event -> event_length ) ) ; printf ( " " ) ; type = uap_le16_to_cpu ( wifidirect_event -> event_type ) ; switch ( type ) { case 0 : printf ( " \n " ) ; break ; case 1 : printf ( " \n " ) ; break ; case 2 : printf ( " \n " ) ; break ; case 3 : printf ( " \n " ) ; break ; case 4 : printf ( " \n " ) ; break ; case 5 : printf ( " \n " ) ; break ; case 6 : printf ( " \n " ) ; break ; case 7 : printf ( " \n " ) ; break ; case 8 : printf ( " \n " ) ; break ; case 9 : printf ( " \n " ) ; break ; case 10 : printf ( " \n " ) ; break ; case 14 : printf ( " \n " ) ; break ; case 15 : printf ( " \n " ) ; break ; case 16 : printf ( " \n " , wifidirect_event -> entire_ie_list ) ; return ; default : printf ( " \n " ) ; break ; } sub_type = uap_le16_to_cpu ( wifidirect_event -> event_sub_type ) ; if ( type == 2 ) { switch ( sub_type ) { case 0 : printf ( " \n " ) ; break ; case 1 : printf ( " \n " ) ; break ; case 2 : printf ( " \n " ) ; break ; default : printf ( " \n " , sub_type ) ; break ; } } else if ( type == 3 || type == 4 ) { switch ( sub_type & 0x03 ) { case 0 : printf ( " \n " ) ; break ; case 1 : printf ( " \n " ) ; break ; case 2 : printf ( " \n " ) ; break ; } switch ( ( sub_type & 0x1C ) >> 2 ) { case 0 : printf ( " \n " ) ; break ; case 1 : printf ( " \n " ) ; break ; case 2 : printf ( " \n " ) ; break ; case 3 : printf ( " \n " ) ; break ; case 4 : printf ( " \n " ) ; break ; default : printf ( " \n " , sub_type ) ; break ; } } else if ( type == 7 || type == 8 ) { switch ( sub_type ) { case 0 : printf ( " \n " ) ; break ; case 8 : printf ( " \n " ) ; break ; case 0x80 : printf ( " \n " ) ; break ; case 0x100 : printf ( " \n " ) ; break ; default : printf ( " \n " , sub_type ) ; break ; } } printf ( " " ) ; print_mac ( wifidirect_event -> peer_mac_addr ) ; printf ( " \n " ) ; wifidirect_wps_header = ( wifidirect_ie_header * ) ( wifidirect_event -> entire_ie_list ) ; wifidirect_wps_len = uap_le16_to_cpu ( wifidirect_event -> event_length ) - sizeof ( apeventbuf_wifidirect_generic ) ; while ( wifidirect_wps_len >= sizeof ( wifidirect_ie_header ) ) { if ( ! memcmp ( wifidirect_wps_header -> oui , wifi_oui , sizeof ( wifi_oui ) ) || ! ( memcmp ( wifidirect_wps_header -> oui , wps_oui , sizeof ( wps_oui ) ) ) ) { switch ( wifidirect_wps_header -> oui_type ) { case WIFIDIRECT_OUI_TYPE : print_wifidirect_ie_elements ( wifidirect_wps_header -> ie_list , wifidirect_wps_header -> ie_length - sizeof ( wifidirect_wps_header -> oui ) - sizeof ( wifidirect_wps_header -> oui_type ) ) ; printf ( " \n " ) ; break ; case WIFI_WPS_OUI_TYPE : print_wifi_wps_ie_elements ( wifidirect_wps_header -> ie_list , wifidirect_wps_header -> ie_length - sizeof ( wifidirect_wps_header -> oui ) - sizeof ( wifidirect_wps_header -> oui_type ) ) ; printf ( " \n " ) ; break ; } } wifidirect_wps_len -= wifidirect_wps_header -> ie_length + IE_HEADER_LEN ; wifidirect_wps_header = ( wifidirect_ie_header * ) ( ( ( t_u8 * ) wifidirect_wps_header ) + wifidirect_wps_header -> ie_length + IE_HEADER_LEN ) ; } }
@brief Parse and print WIFIDIRECT generic event data
  @param buffer   Pointer to received buffer
  @param size     Length of the received event data
  @return         N/A
@brief Parse and print WIFIDIRECT generic event data @param buffer Pointer to received buffer @param size Length of the received event data @return N / A
/* lower 2 bits */ /* next 3 bits */ /* Print rest of IE elements */