software/drivers/sd8887/src/wlan/mapp/wifidirectutl/wifi_display.c
/*
ss and send ie config command
 *  @param ie_index              A pointer to the IE buffer index
 *  @param data_len_wifidisplay  Length of Wifidisplay data
 *  @param buf                   Pointer to buffer to set.
 *  @return                      SUCCESS--success, FAILURE--fail
 */
ss and send ie config command
@param ie_index              A pointer to the IE buffer index
@param data_len_wifidisplay  Length of Wifidisplay data
@param buf                   Pointer to buffer to set.
@return                      SUCCESS--success, FAILURE--fail
ss and send ie config command @param ie_index A pointer to the IE buffer index @param data_len_wifidisplay Length of Wifidisplay data @param buf Pointer to buffer to set . @return SUCCESS -- success FAILURE -- fail
static int
wifiDisplay_ie_config(t_s16 *ie_index, t_u16 data_len_wifidisplay, t_u8 *buf)
{
	struct iwreq iwr;
	t_s32 sockfd;
	int i, ret = SUCCESS;
	tlvbuf_custom_ie *tlv = NULL;
	custom_ie *ie_ptr = NULL;
	tlv = (tlvbuf_custom_ie *)buf;
	tlv->tag = MRVL_MGMT_IE_LIST_TLV_ID;
	ie_ptr = (custom_ie *)(tlv->ie_data);
	if (data_len_wifidisplay) {
#define DISPLAY_MASK 0xFFFF
		ie_ptr->mgmt_subtype_mask = DISPLAY_MASK;
		tlv->length = sizeof(custom_ie) + data_len_wifidisplay;
		ie_ptr->ie_length = data_len_wifidisplay;
		ie_ptr->ie_index = *ie_index;
	} else {
		tlv->length = 0;
	}
	ie_ptr = (custom_ie *)((t_u8 *)(tlv->ie_data) + sizeof(custom_ie) +
			       data_len_wifidisplay);
	memset(&iwr, 0, sizeof(iwr));
	strncpy(iwr.ifr_name, (char *)dev_name, IFNAMSIZ);
	iwr.u.data.pointer = (void *)buf;
	iwr.u.data.length =
		((2 * sizeof(custom_ie)) + sizeof(tlvbuf_custom_ie) +
		 data_len_wifidisplay);
	iwr.u.data.flags = 0;
	if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
		printf("Cannot open socket.\n");
		ret = FAILURE;
		goto _exit_;
	}
	if (ioctl(sockfd, CUSTOM_IE, &iwr)) {
		perror("ioctl[CUSTOM_IE]");
		printf("Failed to set/get/clear the IE buffer\n");
		ret = FAILURE;
		close(sockfd);
		goto _exit_;
	}
	close(sockfd);
	if (!data_len_wifidisplay) {
		tlv = (tlvbuf_custom_ie *)buf;
		*ie_index = -1;
		if (tlv->tag == MRVL_MGMT_IE_LIST_TLV_ID) {
			ie_ptr = (custom_ie *)(tlv->ie_data);
			for (i = 0; i < MAX_MGMT_IE_INDEX; i++) {
				if ((ie_ptr->mgmt_subtype_mask == DISPLAY_MASK)
				    && (ie_ptr->ie_length) && (i != 0) &&
				    (i != 1)) {
					*ie_index = ie_ptr->ie_index;
					break;
				}
				if (i < (MAX_MGMT_IE_INDEX - 1))
					ie_ptr = (custom_ie *)((t_u8 *)ie_ptr +
							       sizeof(custom_ie)
							       +
							       ie_ptr->
							       ie_length);
			}
		}
		if (*ie_index == -1) {
			printf("\nNo free IE buffer available\n");
			ret = FAILURE;
		}
	}
_exit_:
	return ret;
}
static int wifiDisplay_ie_config ( t_s16 * ie_index , t_u16 data_len_wifidisplay , t_u8 * buf ) { struct iwreq iwr ; t_s32 sockfd ; int i , ret = SUCCESS ; tlvbuf_custom_ie * tlv = NULL ; custom_ie * ie_ptr = NULL ; tlv = ( tlvbuf_custom_ie * ) buf ; tlv -> tag = MRVL_MGMT_IE_LIST_TLV_ID ; ie_ptr = ( custom_ie * ) ( tlv -> ie_data ) ; if ( data_len_wifidisplay ) { #define DISPLAY_MASK  0xFFFF ie_ptr -> mgmt_subtype_mask = DISPLAY_MASK ; tlv -> length = sizeof ( custom_ie ) + data_len_wifidisplay ; ie_ptr -> ie_length = data_len_wifidisplay ; ie_ptr -> ie_index = * ie_index ; } else { tlv -> length = 0 ; } ie_ptr = ( custom_ie * ) ( ( t_u8 * ) ( tlv -> ie_data ) + sizeof ( custom_ie ) + data_len_wifidisplay ) ; memset ( & iwr , 0 , sizeof ( iwr ) ) ; strncpy ( iwr . ifr_name , ( char * ) dev_name , IFNAMSIZ ) ; iwr . u . data . pointer = ( void * ) buf ; iwr . u . data . length = ( ( 2 * sizeof ( custom_ie ) ) + sizeof ( tlvbuf_custom_ie ) + data_len_wifidisplay ) ; iwr . u . data . flags = 0 ; if ( ( sockfd = socket ( AF_INET , SOCK_STREAM , 0 ) ) < 0 ) { printf ( " \n " ) ; ret = FAILURE ; goto _exit_ ; } if ( ioctl ( sockfd , CUSTOM_IE , & iwr ) ) { perror ( " " ) ; printf ( " \n " ) ; ret = FAILURE ; close ( sockfd ) ; goto _exit_ ; } close ( sockfd ) ; if ( ! data_len_wifidisplay ) { tlv = ( tlvbuf_custom_ie * ) buf ; * ie_index = -1 ; if ( tlv -> tag == MRVL_MGMT_IE_LIST_TLV_ID ) { ie_ptr = ( custom_ie * ) ( tlv -> ie_data ) ; for ( i = 0 ; i < MAX_MGMT_IE_INDEX ; i ++ ) { if ( ( ie_ptr -> mgmt_subtype_mask == DISPLAY_MASK ) && ( ie_ptr -> ie_length ) && ( i != 0 ) && ( i != 1 ) ) { * ie_index = ie_ptr -> ie_index ; break ; } if ( i < ( MAX_MGMT_IE_INDEX - 1 ) ) ie_ptr = ( custom_ie * ) ( ( t_u8 * ) ie_ptr + sizeof ( custom_ie ) + ie_ptr -> ie_length ) ; } } if ( * ie_index == -1 ) { printf ( " \n \n " ) ; ret = FAILURE ; } } _exit_ : return ret ; }
ss and send ie config command
  @param ie_index              A pointer to the IE buffer index
  @param data_len_wifidisplay  Length of Wifidisplay data
  @param buf                   Pointer to buffer to set.
ss and send ie config command @param ie_index A pointer to the IE buffer index @param data_len_wifidisplay Length of Wifidisplay data @param buf Pointer to buffer to set .
/* Locate headers */ /* Set TLV fields : WFD IE parameters */ /* Set IE */ /* Get WPS IE */ /* Locate headers */ /*
	 *      * create a socket
	 *           */ /* Get the IE buffer index number for MGMT_IE_LIST_TLV */ // Index 0 and 1 are reserved for WFD in current implementation