software/drivers/sd8887/src/wlan/mapp/wifidirectutl/wifi_display.c
/**
 *  @brief Wifi display update custom ie command
 *
 *  $return         N/A
*/
@brief Wifi display update custom ie command
$return         N/A
@brief Wifi display update custom ie command $return N / A
void
wifidisplay_update_custom_ie(int argc, char *argv[])
{
	t_s16 display_ie_index = -1;
	t_u8 *buf;
	int opt;
	tlvbuf_custom_ie *tlv = NULL;
	custom_ie *ie_ptr = NULL;
	t_u16 len = 0, ie_len_wfd_org, ie_len_wfd, i = 0, new_wfd_dev_info = 0;
	t_u8 *wfd_ptr;
	while ((opt = getopt_long(argc, argv, "+", cmd_options, NULL)) != -1) {
		switch (opt) {
		default:
			printf("ERR:Incorrect arguments.\n");
			return;
		}
	}
	argc -= optind;
	argv += optind;
	if (argc < 2) {
		printf("ERR:wrong arguments.\n");
		return;
	}
	if (argc == 3) {
		if (ISDIGIT(argv[2]) == 0) {
			printf("ERR:Illegal wfd mode %s. Must not be '0'.\n",
			       argv[2]);
			return;
		}
		new_wfd_dev_info = (t_u16)atoi(argv[2]);
	}
	buf = (t_u8 *)malloc(MRVDRV_SIZE_OF_CMD_BUFFER);
	if (!buf) {
		printf("ERR:Cannot allocate memory!\n");
		return;
	}
	wifiDisplay_ie_config(&display_ie_index, 0, buf);
	if (display_ie_index < 0) {
		free(buf);
		return;
	}
	if (display_ie_index < (MAX_MGMT_IE_INDEX - 1)) {
		tlv = (tlvbuf_custom_ie *)buf;
		if (tlv->tag == MRVL_MGMT_IE_LIST_TLV_ID) {
			ie_ptr = (custom_ie *)(tlv->ie_data);
			for (i = 0; i < display_ie_index; i++) {
				ie_ptr = (custom_ie *)((t_u8 *)ie_ptr +
						       sizeof(custom_ie) +
						       ie_ptr->ie_length);
			}
			ie_len_wfd_org = ie_ptr->ie_length;
			wfd_ptr = ie_ptr->ie_buffer;
			ie_len_wfd = *(wfd_ptr + 1);
			wfd_ptr += sizeof(t_u8) + sizeof(t_u8);
			wfd_ptr += (WIFIDISPLAY_OUI_LEN + WIFIDISPLAY_OUI_TYPE);
			while (ie_len_wfd > WFD_IE_HEADER_LEN) {
				memcpy(&len, wfd_ptr + 1, sizeof(t_u16));
				len = ntohs(len);
				if (*wfd_ptr ==
				    TLV_TYPE_WIFIDISPLAY_DEVICE_INFO) {
					tlvbuf_wfdisplay_device_info *wfd_tlv =
						(tlvbuf_wfdisplay_device_info *)
						wfd_ptr;
					new_wfd_dev_info =
						ntohs(new_wfd_dev_info);
					memcpy((t_u8 *)&wfd_tlv->
					       display_device_info,
					       (t_u8 *)&new_wfd_dev_info,
					       sizeof(t_u16));
					break;
				}
				wfd_ptr += len + WFD_IE_HEADER_LEN;
				ie_len_wfd -= len + WFD_IE_HEADER_LEN;
			}
			wifiDisplay_ie_config((t_s16 *)&display_ie_index,
					      ie_len_wfd_org,
					      (t_u8 *)ie_ptr -
					      sizeof(tlvbuf_custom_ie));
		}
	}
	return;
}
void wifidisplay_update_custom_ie ( int argc , char * argv [ ] ) { t_s16 display_ie_index = -1 ; t_u8 * buf ; int opt ; tlvbuf_custom_ie * tlv = NULL ; custom_ie * ie_ptr = NULL ; t_u16 len = 0 , ie_len_wfd_org , ie_len_wfd , i = 0 , new_wfd_dev_info = 0 ; t_u8 * wfd_ptr ; while ( ( opt = getopt_long ( argc , argv , " " , cmd_options , NULL ) ) != -1 ) { switch ( opt ) { default : printf ( " \n " ) ; return ; } } argc -= optind ; argv += optind ; if ( argc < 2 ) { printf ( " \n " ) ; return ; } if ( argc == 3 ) { if ( ISDIGIT ( argv [ 2 ] ) == 0 ) { printf ( " \n " , argv [ 2 ] ) ; return ; } new_wfd_dev_info = ( t_u16 ) atoi ( argv [ 2 ] ) ; } buf = ( t_u8 * ) malloc ( MRVDRV_SIZE_OF_CMD_BUFFER ) ; if ( ! buf ) { printf ( " \n " ) ; return ; } wifiDisplay_ie_config ( & display_ie_index , 0 , buf ) ; if ( display_ie_index < 0 ) { free ( buf ) ; return ; } if ( display_ie_index < ( MAX_MGMT_IE_INDEX - 1 ) ) { tlv = ( tlvbuf_custom_ie * ) buf ; if ( tlv -> tag == MRVL_MGMT_IE_LIST_TLV_ID ) { ie_ptr = ( custom_ie * ) ( tlv -> ie_data ) ; for ( i = 0 ; i < display_ie_index ; i ++ ) { ie_ptr = ( custom_ie * ) ( ( t_u8 * ) ie_ptr + sizeof ( custom_ie ) + ie_ptr -> ie_length ) ; } ie_len_wfd_org = ie_ptr -> ie_length ; wfd_ptr = ie_ptr -> ie_buffer ; ie_len_wfd = * ( wfd_ptr + 1 ) ; wfd_ptr += sizeof ( t_u8 ) + sizeof ( t_u8 ) ; wfd_ptr += ( WIFIDISPLAY_OUI_LEN + WIFIDISPLAY_OUI_TYPE ) ; while ( ie_len_wfd > WFD_IE_HEADER_LEN ) { memcpy ( & len , wfd_ptr + 1 , sizeof ( t_u16 ) ) ; len = ntohs ( len ) ; if ( * wfd_ptr == TLV_TYPE_WIFIDISPLAY_DEVICE_INFO ) { tlvbuf_wfdisplay_device_info * wfd_tlv = ( tlvbuf_wfdisplay_device_info * ) wfd_ptr ; new_wfd_dev_info = ntohs ( new_wfd_dev_info ) ; memcpy ( ( t_u8 * ) & wfd_tlv -> display_device_info , ( t_u8 * ) & new_wfd_dev_info , sizeof ( t_u16 ) ) ; break ; } wfd_ptr += len + WFD_IE_HEADER_LEN ; ie_len_wfd -= len + WFD_IE_HEADER_LEN ; } wifiDisplay_ie_config ( ( t_s16 * ) & display_ie_index , ie_len_wfd_org , ( t_u8 * ) ie_ptr - sizeof ( tlvbuf_custom_ie ) ) ; } } return ; }
@brief Wifi display update custom ie command
  $return         N/A
@brief Wifi display update custom ie command $return N / A
/* Check arguments */ /* Clear WPS IE */ /* Goto appropriate Ie Index */ /* check capability type */ /* Update New IE now */