software/drivers/sd8887/src/wlan/mapp/mlan2040coex/mlan2040coex.c
/**
 *  @brief              This function parses for NETLINK events
 *
 *  @param nlh          Pointer to Netlink message header
 *  @param bytes_read   Number of bytes to be read
 *  @param evt_conn     A pointer to a output buffer. It sets TRUE when it gets
 *  					the event CUS_EVT_OBSS_SCAN_PARAM, otherwise FALSE
 *  @return             MLAN_STATUS_SUCCESS or MLAN_STATUS_FAILURE
 */
@brief              This function parses for NETLINK events
@param nlh          Pointer to Netlink message header
@param bytes_read   Number of bytes to be read
@param evt_conn     A pointer to a output buffer. It sets TRUE when it gets
the event CUS_EVT_OBSS_SCAN_PARAM, otherwise FALSE
@return             MLAN_STATUS_SUCCESS or MLAN_STATUS_FAILURE
@brief This function parses for NETLINK events @param nlh Pointer to Netlink message header @param bytes_read Number of bytes to be read @param evt_conn A pointer to a output buffer . It sets TRUE when it gets the event CUS_EVT_OBSS_SCAN_PARAM otherwise FALSE @return MLAN_STATUS_SUCCESS or MLAN_STATUS_FAILURE
static int
drv_nlevt_handler(struct nlmsghdr *nlh, int bytes_read, int *evt_conn)
{
	int len, plen;
	t_u8 *buffer = NULL;
	t_u32 event_id = 0;
	event_header *event = NULL;
	char if_name[IFNAMSIZ + 1];
	buffer = (t_u8 *)malloc(NL_MAX_PAYLOAD);
	if (!buffer) {
		printf("ERR: Could not alloc buffer\n");
		return MLAN_STATUS_FAILURE;
	}
	memset(buffer, 0, NL_MAX_PAYLOAD);
	*evt_conn = FALSE;
	while ((unsigned int)bytes_read >= NLMSG_HDRLEN) {
		len = nlh->nlmsg_len;	
		plen = len - NLMSG_HDRLEN;
		if (len > bytes_read || plen < 0) {
			free(buffer);
			return MLAN_STATUS_FAILURE;
		}
		if ((unsigned int)len > NLMSG_SPACE(NL_MAX_PAYLOAD)) {
			printf("ERR:Buffer overflow!\n");
			free(buffer);
			return MLAN_STATUS_FAILURE;
		}
		memset(buffer, 0, NL_MAX_PAYLOAD);
		memcpy(buffer, NLMSG_DATA(nlh), plen);
		if (NLMSG_OK(nlh, len)) {
			memcpy(&event_id, buffer, sizeof(event_id));
			if (((event_id & 0xFF000000) == 0x80000000) ||
			    ((event_id & 0xFF000000) == 0)) {
				event = (event_header *)buffer;
			} else {
				memset(if_name, 0, IFNAMSIZ + 1);
				memcpy(if_name, buffer, IFNAMSIZ);
				event = (event_header *)(buffer + IFNAMSIZ);
			}
		}
		if (event)
			print_event(event, bytes_read, evt_conn, if_name);
		len = NLMSG_ALIGN(len);
		bytes_read -= len;
		nlh = (struct nlmsghdr *)((char *)nlh + len);
	}
	free(buffer);
	return MLAN_STATUS_SUCCESS;
}
static int drv_nlevt_handler ( struct nlmsghdr * nlh , int bytes_read , int * evt_conn ) { int len , plen ; t_u8 * buffer = NULL ; t_u32 event_id = 0 ; event_header * event = NULL ; char if_name [ IFNAMSIZ + 1 ] ; buffer = ( t_u8 * ) malloc ( NL_MAX_PAYLOAD ) ; if ( ! buffer ) { printf ( " \n " ) ; return MLAN_STATUS_FAILURE ; } memset ( buffer , 0 , NL_MAX_PAYLOAD ) ; * evt_conn = FALSE ; while ( ( unsigned int ) bytes_read >= NLMSG_HDRLEN ) { len = nlh -> nlmsg_len ; plen = len - NLMSG_HDRLEN ; if ( len > bytes_read || plen < 0 ) { free ( buffer ) ; return MLAN_STATUS_FAILURE ; } if ( ( unsigned int ) len > NLMSG_SPACE ( NL_MAX_PAYLOAD ) ) { printf ( " \n " ) ; free ( buffer ) ; return MLAN_STATUS_FAILURE ; } memset ( buffer , 0 , NL_MAX_PAYLOAD ) ; memcpy ( buffer , NLMSG_DATA ( nlh ) , plen ) ; if ( NLMSG_OK ( nlh , len ) ) { memcpy ( & event_id , buffer , sizeof ( event_id ) ) ; if ( ( ( event_id & 0xFF000000 ) == 0x80000000 ) || ( ( event_id & 0xFF000000 ) == 0 ) ) { event = ( event_header * ) buffer ; } else { memset ( if_name , 0 , IFNAMSIZ + 1 ) ; memcpy ( if_name , buffer , IFNAMSIZ ) ; event = ( event_header * ) ( buffer + IFNAMSIZ ) ; } } if ( event ) print_event ( event , bytes_read , evt_conn , if_name ) ; len = NLMSG_ALIGN ( len ) ; bytes_read -= len ; nlh = ( struct nlmsghdr * ) ( ( char * ) nlh + len ) ; } free ( buffer ) ; return MLAN_STATUS_SUCCESS ; }
@brief              This function parses for NETLINK events
  @param nlh          Pointer to Netlink message header
  @param bytes_read   Number of bytes to be read
  @param evt_conn     A pointer to a output buffer.
@brief This function parses for NETLINK events @param nlh Pointer to Netlink message header @param bytes_read Number of bytes to be read @param evt_conn A pointer to a output buffer .
/* Initialize receive buffer */ /* Length of message including header */ /* malformed netlink message */