ZHCU938C May 2018 – January 2021 CC3100 , CC3100MOD , CC3200 , CC3200MOD
INT32 AddBeaconFilter()
{
SlrxFilterRuleType_t RuleType;
SlrxFilterID_t FilterId = 0;
SlrxFilterFlags_t FilterFlags;
SlrxFilterRule_t Rule;
SlrxFilterTrigger_t Trigger;
SlrxFilterAction_t Action;
SlrxFilterIdMask_t FiltersIdMask
char RetVal = -1;
UINT8 FrameType;
UINT8 FrameSubType;
UINT8 FrameTypeMask;
memset(FiltersIdMask, 0, sizeof(FiltersIdMask));
/*
* 第一个筛选条件是:
* if FrameType != Management --> Action == Drop
*/
/* 构建筛选参数 */
RuleType = HEADER;
FilterFlags.IntRepresentation = RX_FILTER_BINARY;
FrameType = 0; // 0-Management, 1-Control, 2-Data
FrameTypeMask = 0xFF;
Rule.HeaderType.RuleHeaderfield = FRAME_TYPE_FIELD;
memcpy(Rule.HeaderType.RuleHeaderArgsAndMask.RuleHeaderArgs.RxFilterDB1BytesRuleArgs[0],&FrameType, 1);
memcpy(Rule.HeaderType.RuleHeaderArgsAndMask.RuleHeaderArgsMask,&FrameTypeMask, 1);
Rule.HeaderType.RuleCompareFunc = COMPARE_FUNC_NOT_EQUAL_TO;
Trigger.ParentFilterID = 0;
Trigger.Trigger = NO_TRIGGER;
Trigger.TriggerArgConnectionState.IntRepresentation = RX_FILTER_CONNECTION_STATE_STA_NOT_CONNECTED;
Trigger.TriggerArgRoleStatus.IntRepresentation = RX_FILTER_ROLE_PROMISCUOUS;
Action.ActionType.IntRepresentation = RX_FILTER_ACTION_DROP;
/* Add first Filter */
RetVal = (char)sl_WlanRxFilterAdd(RuleType,FilterFlags,&Rule,&Trigger,&Action,&FilterId);
if(RetVal == 0)
printf("Filter created successfully, filter ID is %d\n",FilterId);
else
{
printf("Error creating the filter.Error number: %d.\n",RetVal);
return -1;
}
SETBIT8(FiltersIdMask,FilterId);
/*
* 第二个筛选条件是:
* if FrameType == Management --> Action == Do nothing
*/
Rule.HeaderType.RuleCompareFunc = COMPARE_FUNC_EQUAL;
Action.ActionType.IntRepresentation = RX_FILTER_ACTION_NULL;
/* Add 2nd Filter */
RetVal = (char)sl_WlanRxFilterAdd(RuleType,FilterFlags,&Rule,&Trigger,&Action,&FilterId);
if(RetVal == 0)
printf("Filter created successfully, filter ID is %d\n",FilterId);
else
{
printf("Error creating the filter.Error number: %d.\n",RetVal);
return -1;
}
SETBIT8(FiltersIdMask,FilterId);
/*
* 第三个筛选条件是:
* if Frame SubType != Beacon --> Action == Drop
*/
Trigger.ParentFilterID = FilterId; // The parent Id
Rule.HeaderType.RuleCompareFunc = COMPARE_FUNC_NOT_EQUAL_TO;
Action.ActionType.IntRepresentation = RX_FILTER_ACTION_DROP;
FrameSubType = 0x80; // Beacon Frame SubType
Rule.HeaderType.RuleHeaderfield = FRAME_SUBTYPE_FIELD;
memcpy(Rule.HeaderType.RuleHeaderArgsAndMask.RuleHeaderArgs.RxFilterDB1BytesRuleArgs[0],&FrameSubType, 1);
/* Add 3rd Filter */
RetVal = (char)sl_WlanRxFilterAdd(RuleType,FilterFlags,&Rule,&Trigger,&Action,&FilterId);
if(RetVal == 0)
printf("Filter created successfully, filter ID is %d\n",FilterId);
else
{
printf("Error creating the filter.Error number: %d.\n",RetVal);
return -1;
}
SETBIT8(FiltersIdMask,FilterId);
}