Packet Bypass Mode (RAW) Questions

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

My customer asks:

I need to further understand the “RAW” functionality that is available in the WICED SDK and would like flow diagrams of the SDK’s APIs for “Packet Bypass Mode (RAW)” functionality.

Please see below for my actual question where I give a simple example of how our packet is laid out.

>>>>>>>>>

New Command:  (Note this is a suggestion and use as example to show what is expected in the command arguments, for WICED SDK, I am ok with different AT command and different arguments no matter it is a complex arguments or need few AT commands for setting up packet bypassing)

AT+NRAW=<state>
<state> = { NONE, ETH, ALL }

NONE         = serial-send no RAW packets

        NON_SNAP = serial-send only packets with non-SNAP 802.2 LLC Headers

ALL             = serial-send ALL RAW frames

So, for my application, I will do the following:

  • (1)Send via uart for the AT command for packet bypassing

AT+NRAW=ALL

  • (2) Upon receiving every single returned packet, just once, in the RAW mode (when upper layer callback function executed upon get from data from generic RAW “socket”)

I will filter on application callback function side, and process per my BACnet Ethernet/IP requirements:

        (2.1) (R.<EtherType> == 0x0000) && (LLC.DSAP == 0x82)

=> BACnet/Ethernet frame

(2.2) (R.<EtherType> == 0x0800) && (UDP.DstPort == [ 0xBAC0 ... 0xBACF ])

=> BACnet/IP datagram

(2.3) (R.<EtherType> == 0x86DD)

=> IPv6 Packet

(2.4) Anything Else

=> Ignore

Note: The above example is just a suggestion of one possible solution and we are open to others.

This may require some further discussion to see if WICED can meet to our specific BACnet/IP (http://www.bacnet.org/Tutorial/index.html) application or not.

From my previous WICED support, I understand that the AT Command Packet Bypass Mode (RAW) functionality is available in the SDK itself:

“In SDK2.4.1 the functions that support this functionality are the following…

In wwd_wifi.c

wiced_result_t wiced_wifi_enable_monitor_mode( void )

{

    wiced_buffer_t buffer;

    uint32_t* data;

    /* Enable allmulti mode */

    data = wiced_get_iovar_buffer(&buffer, 4, "allmulti");

    *data = 1;

    if (wiced_send_iovar(SDPCM_SET, buffer, NULL, SDPCM_STA_INTERFACE) != WICED_SUCCESS)

    {

return WICED_ERROR;

    }

This function can then be paired with the wiced_wifi_**_packet_filter() functions also found in the wwd_wifi.c file.  A few of these are shown below…

wiced_result_t wiced_wifi_set_packet_filter_mode( wiced_packet_filter_mode_t mode )

{

    wiced_buffer_t buffer;

    uint32_t* data = (uint32_t*)wiced_get_iovar_buffer( &buffer, sizeof(uint32_t), IOVAR_STR_PKT_FILTER_MODE );

    CHECK_IOCTL_BUFFER( data );

    *data = (uint32_t)mode;

    return wiced_send_iovar( SDPCM_SET, buffer, NULL, SDPCM_STA_INTERFACE );

}

wiced_result_t wiced_wifi_add_packet_filter( uint8_t filter_id, const wiced_packet_filter_settings_t* settings )

{

    wl_pkt_filter_t* packet_filter;

    wiced_buffer_t buffer;

    uint32_t buffer_length = ( 2 * (uint32_t)settings->pattern_list[0].mask_size ) + WL_PKT_FILTER_FIXED_LEN + WL_PKT_FILTER_PATTERN_FIXED_LEN;

    /* Pattern list currently isn't supported */

    if ( settings->pattern_count > 1 )

    {

return WICED_UNSUPPORTED;

    }

    packet_filter = (wl_pkt_filter_t*) wiced_get_iovar_buffer( &buffer, (uint16_t)buffer_length , IOVAR_STR_PKT_FILTER_ADD );

    CHECK_IOCTL_BUFFER( packet_filter );

    /* Copy filter entries */

    packet_filter->id = filter_id;

    packet_filter->type = 0;

    packet_filter->negate_match = settings->rule;

    packet_filter->u.pattern.offset = (uint32_t)settings->pattern_list[0].offset;

    packet_filter->u.pattern.size_bytes = settings->pattern_list[0].mask_size;

    /* Copy mask */

    memcpy( packet_filter->u.pattern.mask_and_pattern, settings->pattern_list[0].mask, settings->pattern_list[0].mask_size );

    /* Copy filter pattern */

    memcpy( packet_filter->u.pattern.mask_and_pattern + settings->pattern_list[0].mask_size, settings->pattern_list[0].pattern, settings->pattern_list[0].mask_size );

    return wiced_send_iovar( SDPCM_SET, buffer, NULL, SDPCM_STA_INTERFACE );

}

wiced_result_t wiced_wifi_remove_packet_filter( uint8_t filter_id )

{

    wiced_buffer_t buffer;

    uint32_t* data = (uint32_t*)wiced_get_iovar_buffer( &buffer, sizeof(uint32_t), IOVAR_STR_PKT_FILTER_DELETE );

    CHECK_IOCTL_BUFFER( data );

    *data = (uint32_t)filter_id;

    return wiced_send_iovar( SDPCM_SET, buffer, NULL, SDPCM_STA_INTERFACE );

}

wiced_result_t wiced_wifi_enable_packet_filter( uint8_t filter_id )

{

    return wiced_wifi_toggle_packet_filter( filter_id, WICED_TRUE );

}

wiced_result_t wiced_wifi_disable_packet_filter( uint8_t filter_id )

{

    return wiced_wifi_toggle_packet_filter( filter_id, WICED_FALSE );

}

wiced_result_t wiced_wifi_toggle_packet_filter( uint8_t filter_id, wiced_bool_t enable )

{

    wiced_buffer_t buffer;

    wl_pkt_filter_enable_t* data = wiced_get_iovar_buffer( &buffer, sizeof(wl_pkt_filter_enable_t), IOVAR_STR_PKT_FILTER_ENABLE );

    CHECK_IOCTL_BUFFER( data );

    data->id = (uint32_t)filter_id;

    data->enable = (uint32_t)enable;

    return wiced_send_iovar( SDPCM_SET, buffer, NULL, SDPCM_STA_INTERFACE );

}

0 Likes
1 Solution
Anonymous
Not applicable

Monitor mode can be used when not associated to an AP and will pass up to the application all Ethernet frames it sees on the medium (Note: No LLC information is available). As you've noted this mode is most useful when paired with some packet filters to restrict the frames to the type you are most interested in. There is an snippet app called "packet_filter" that demonstrate how to use packet_filters without monitor mode.

The WICED SDK also comes with a proprietary configuration method called Cooee that uses both monitor mode and packet filters to sniff multicast packets and the implementation of that can be found in WICED/internal/wiced_cooee.c

View solution in original post

2 Replies
GregG_16
Employee
Employee
50 sign-ins 25 sign-ins 25 comments on KBA

Hello,

Please  give us some time to look into this. We will get back to you.

Nicholas Von Huben

0 Likes
Anonymous
Not applicable

Monitor mode can be used when not associated to an AP and will pass up to the application all Ethernet frames it sees on the medium (Note: No LLC information is available). As you've noted this mode is most useful when paired with some packet filters to restrict the frames to the type you are most interested in. There is an snippet app called "packet_filter" that demonstrate how to use packet_filters without monitor mode.

The WICED SDK also comes with a proprietary configuration method called Cooee that uses both monitor mode and packet filters to sniff multicast packets and the implementation of that can be found in WICED/internal/wiced_cooee.c