David Fletcher
/
cc3100_Test_mqtt_CM4F
TI's MQTT Demo with freertos CM4F
Embed:
(wiki syntax)
Show/hide line numbers
cc3100_wlan_rx_filters.h
00001 /* 00002 * wlan_rx_filters.h - CC31xx/CC32xx Host Driver Implementation 00003 * 00004 * Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com/ 00005 * 00006 * 00007 * Redistribution and use in source and binary forms, with or without 00008 * modification, are permitted provided that the following conditions 00009 * are met: 00010 * 00011 * Redistributions of source code must retain the above copyright 00012 * notice, this list of conditions and the following disclaimer. 00013 * 00014 * Redistributions in binary form must reproduce the above copyright 00015 * notice, this list of conditions and the following disclaimer in the 00016 * documentation and/or other materials provided with the 00017 * distribution. 00018 * 00019 * Neither the name of Texas Instruments Incorporated nor the names of 00020 * its contributors may be used to endorse or promote products derived 00021 * from this software without specific prior written permission. 00022 * 00023 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 00024 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 00025 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 00026 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 00027 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 00028 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 00029 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 00030 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 00031 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00032 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 00033 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00034 * 00035 */ 00036 00037 00038 /*****************************************************************************/ 00039 /* Include files */ 00040 /*****************************************************************************/ 00041 #include "cc3100_simplelink.h" 00042 00043 #ifndef RX_FILTERS_PREPROCESSOR_CLI_IF_H_ 00044 #define RX_FILTERS_PREPROCESSOR_CLI_IF_H_ 00045 00046 #include "cc3100_driver.h" 00047 00048 /*****************************************************************************/ 00049 /* Macro declarations */ 00050 /*****************************************************************************/ 00051 00052 /*! 00053 * \def SL_RX_FILTER_MAX_FILTERS 00054 * The Max number of filters for 64 filters 00055 */ 00056 #define SL_RX_FILTER_MAX_FILTERS 64 00057 00058 /*! 00059 * \def SL_RX_FILTER_MAX_PRE_PREPARED_FILTERS_SETS 00060 * The Max number of software filters 00061 */ 00062 #define SL_RX_FILTER_MAX_PRE_PREPARED_FILTERS_SETS (32) 00063 /*! 00064 * \def SL_RX_FILTER_NUM_OF_FILTER_HEADER_ARGS 00065 * 00066 */ 00067 #define SL_RX_FILTER_NUM_OF_FILTER_HEADER_ARGS (2) 00068 /*! 00069 * \def SL_RX_FILTER_NUM_OF_FILTER_PAYLOAD_ARGS 00070 * 00071 */ 00072 #define SL_RX_FILTER_NUM_OF_FILTER_PAYLOAD_ARGS (2) 00073 /*! 00074 * \def SL_RX_FILTER_NUM_OF_FILTER_PAYLOAD_ARGS 00075 * 00076 */ 00077 #define SL_RX_FILTER_NUM_OF_COMBINATION_TYPE_ARGS (2) 00078 /*! 00079 * \def SL_RX_FILTER_LENGTH_OF_REGX_PATTERN_LENGTH 00080 * 00081 */ 00082 #define SL_RX_FILTER_LENGTH_OF_REGX_PATTERN_LENGTH (32) 00083 00084 00085 /* List of possible error numbers */ 00086 #define RXFL_OK (0) /* O.K */ 00087 #define RXFL_OUTPUT_OR_INPUT_BUFFER_LENGTH_TOO_SMALL (76) /* ! The output buffer length is smaller than required for that operation */ 00088 #define RXFL_DEPENDENT_FILTER_SOFTWARE_FILTER_NOT_FIT (75) /* Node filter can't be child of software filter and vice_versa */ 00089 #define RXFL_DEPENDENCY_IS_NOT_PERSISTENT (74) /* Dependency filter is not persistent */ 00090 #define RXFL_SYSTEM_STATE_NOT_SUPPORTED_FOR_THIS_FILTER (72) /* System state is not supported */ 00091 #define RXFL_TRIGGER_USE_REG5_TO_REG8 (71) /* Only counters 5 - 8 are allowed, for Tigger */ 00092 #define RXFL_TRIGGER_USE_REG1_TO_REG4 (70) /* Only counters 1 - 4 are allowed, for trigger */ 00093 #define RXFL_ACTION_USE_REG5_TO_REG8 (69) /* Only counters 5 - 8 are allowed, for action */ 00094 #define RXFL_ACTION_USE_REG1_TO_REG4 (68) /* Only counters 1 - 4 are allowed, for action */ 00095 #define RXFL_FIELD_SUPPORT_ONLY_EQUAL_AND_NOTEQUAL (67) /* Rule compare function Id is out of range */ 00096 #define RXFL_WRONG_MULTICAST_BROADCAST_ADDRESS (66) /* The address should be of type mutlicast or broadcast */ 00097 #define RXFL_THE_FILTER_IS_NOT_OF_HEADER_TYPE (65) /* The filter should be of header type */ 00098 #define RXFL_WRONG_COMPARE_FUNC_FOR_BROADCAST_ADDRESS (64) /* The compare funcion is not suitable for broadcast address */ 00099 #define RXFL_WRONG_MULTICAST_ADDRESS (63) /* The address should be of muticast type */ 00100 #define RXFL_DEPENDENT_FILTER_IS_NOT_PERSISTENT (62) /* The dependency filter is not persistent */ 00101 #define RXFL_DEPENDENT_FILTER_IS_NOT_ENABLED (61) /* The dependency filter is not enabled */ 00102 #define RXFL_FILTER_HAS_CHILDS (60) /* The filter has childs and can't be removed */ 00103 #define RXFL_CHILD_IS_ENABLED (59) /* Can't disable filter while the child is enabled */ 00104 #define RXFL_DEPENDENCY_IS_DISABLED (58) /* Can't enable filetr in case its depndency filter is disabled */ 00105 #define RXFL_NUMBER_OF_CONNECTION_POINTS_EXCEEDED (52) /* Number of connection points exceeded */ 00106 #define RXFL_DEPENDENT_FILTER_DEPENDENCY_ACTION_IS_DROP (51) /* The dependent filter has Drop action, thus the filter can't be created */ 00107 #define RXFL_FILTER_DO_NOT_EXISTS (50) /* The filter doesn't exists */ 00108 #define RXFL_DEPEDENCY_NOT_ON_THE_SAME_LAYER (49) /* The filter and its dependency must be on the same layer */ 00109 #define RXFL_NUMBER_OF_ARGS_EXCEEDED (48) /* Number of arguments excceded */ 00110 #define RXFL_ACTION_NO_REG_NUMBER (47) /* Action require counter number */ 00111 #define RXFL_DEPENDENT_FILTER_LAYER_DO_NOT_FIT (46) /* the filter and its dependency should be from the same layer */ 00112 #define RXFL_DEPENDENT_FILTER_SYSTEM_STATE_DO_NOT_FIT (45) /* The filter and its dependency system state don't fit */ 00113 #define RXFL_DEPENDENT_FILTER_DO_NOT_EXIST_2 (44) /* The parent filter don't exist */ 00114 #define RXFL_DEPENDENT_FILTER_DO_NOT_EXIST_1 (43) /* The parent filter is null */ 00115 #define RXFL_RULE_HEADER_ACTION_TYPE_NOT_SUPPORTED (42) /* The action type is not supported */ 00116 #define RXFL_RULE_HEADER_TRIGGER_COMPARE_FUNC_OUT_OF_RANGE (41) /* The Trigger comparision function is out of range */ 00117 #define RXFL_RULE_HEADER_TRIGGER_OUT_OF_RANGE (40) /* The Trigger is out of range */ 00118 #define RXFL_RULE_HEADER_COMPARE_FUNC_OUT_OF_RANGE (39) /* The rule compare function is out of range */ 00119 #define RXFL_FRAME_TYPE_NOT_SUPPORTED (38) /* ASCII frame type string is illegal */ 00120 #define RXFL_RULE_FIELD_ID_NOT_SUPPORTED (37) /* Rule field ID is out of range */ 00121 #define RXFL_RULE_HEADER_FIELD_ID_ASCII_NOT_SUPPORTED (36) /* This ASCII field ID is not supported */ 00122 #define RXFL_RULE_HEADER_NOT_SUPPORTED (35) /* The header rule is not supported on current release */ 00123 #define RXFL_RULE_HEADER_OUT_OF_RANGE (34) /* The header rule is out of range */ 00124 #define RXFL_RULE_HEADER_COMBINATION_OPERATOR_OUT_OF_RANGE (33) /* Combination function Id is out of ramge */ 00125 #define RXFL_RULE_HEADER_FIELD_ID_OUT_OF_RANGE (32) /* rule field Id is out of range */ 00126 #define RXFL_UPDATE_NOT_SUPPORTED (31) /* Update not supported */ 00127 #define RXFL_NO_FILTERS_ARE_DEFINED (24) /* No filters are defined in the system */ 00128 #define RXFL_NUMBER_OF_FILTER_EXCEEDED (23) /* Number of max filters excceded */ 00129 00130 00131 /******************************************************************************/ 00132 /* Type declarations */ 00133 /******************************************************************************/ 00134 00135 /*! 00136 00137 00138 * \typedef SlrxFilterID_t 00139 * Unique filter ID which is allocated by the system , negative number means error 00140 */ 00141 typedef int8_t SlrxFilterID_t; 00142 00143 00144 /*! 00145 * \typedef SlrxFilterCompareMask_t 00146 * The mask is used for the rule comparison function 00147 */ 00148 typedef uint8_t SlrxFilterCompareMask_t; 00149 00150 /*! 00151 * \typedef SlrxFilterIdMask_t 00152 * Representation of filters Id as a bit field 00153 * The bit field is used to declare which filters are involved 00154 * in operation. Number of filter can be up to 128 filters. i.e. 128 bits are needed. 00155 * On the current release, up to 64 filters can be defined. 00156 */ 00157 typedef uint8_t SlrxFilterIdMask_t[128/8]; 00158 00159 /*! 00160 * \typedef SlrxFilterPrePreparedFilters_t 00161 * Describes the supported software filter sets, 00162 */ 00163 typedef uint8_t SlrxFilterPrePreparedFilters_t; 00164 #define SL_ARP_AUTO_REPLY_PRE_PREPARED_FILTERS (0) 00165 #define SL_MULTICASTSIPV4_DROP_PREPREPARED_FILTERS (1) 00166 #define SL_MULTICASTSIPV6_DROP_PREPREPARED_FILTERS (2) 00167 #define SL_MULTICASTSWIFI_DROP_PREPREPARED_FILTERS (3) 00168 00169 00170 00171 /*! 00172 * \typedef SlrxFilterPrePreparedFiltersMask_t 00173 * Describes the supported software filter sets, 00174 * each bit represents different software filter set 00175 * The filter sets are defined at SlrxFilterPrePreparedFilters_t 00176 */ 00177 typedef uint8_t SlrxFilterPrePreparedFiltersMask_t[SL_RX_FILTER_MAX_PRE_PREPARED_FILTERS_SETS/8]; 00178 00179 00180 /*! \typedef SlrxFilterRegxPattern_t 00181 * The struct contains the regular expression pattern which is used in case of payload rule. 00182 * Not supported in the current release 00183 */ 00184 typedef struct SlrxFilterRegxPattern_t { 00185 uint8_t x[SL_RX_FILTER_LENGTH_OF_REGX_PATTERN_LENGTH]; 00186 } SlrxFilterRegxPattern_t; 00187 00188 00189 /*! \typedef SlrxFilterAsciiArg_t 00190 * The buffer is used to provide container for ASCII argument, which may be used in case of HEADER rule. 00191 * example for ASCII argument can be : IP = 256.0.67.1 00192 */ 00193 typedef uint8_t SlrxFilterAsciiArg_t; 00194 00195 00196 /*! \typedef SlrxFilterBinaryArg_t 00197 * The buffer provides container for binary argument, which may be used in case of HEADER rule 00198 */ 00199 typedef uint8_t SlrxFilterBinaryArg_t ; 00200 00201 00202 /*! \typedef SlrxFilterActionArg_t 00203 * Provides container for the filter action argument. 00204 * for example: in case action is to send automatic response , the argument is the template to be used for the automatic response. 00205 * 00206 * 00207 */ 00208 typedef uint8_t SlrxFilterActionArg_t ; 00209 00210 00211 00212 /*! \typedef SlrxFilterOffset_t 00213 * The offset relative to the packet payload start location. 00214 * Not supported on current release 00215 */ 00216 typedef uint32_t SlrxFilterOffset_t; 00217 00218 00219 00220 /*! \typedef SlrxFilterRuleType_t 00221 * Enumerates the different filter types. 00222 * On the current release only HEADER and COMBINATION are supported. 00223 */ 00224 typedef uint8_t SlrxFilterRuleType_t; 00225 /* possible values for SlrxFilterRuleType_t */ 00226 #define HEADER (0) 00227 #define COMBINATION (1) 00228 #define EXACT_PATTERN (2) 00229 #define LIKELIHOOD_PATTERN (3) 00230 #define ALWAYS_TRUE (4) 00231 #define NUM_OF_FILTER_TYPES (5) 00232 00233 00234 /*! \typedef SlrxFilterFlags_t 00235 * Bit field which sets the behaviour of the RX filter 00236 * 00237 */ 00238 00239 #define RX_FILTER_BINARY (0x1) 00240 #define RX_FILTER_PERSISTENT (0x8) 00241 #define RX_FILTER_ENABLE (0x10) 00242 00243 typedef union SlrxFilterFlags_t { 00244 00245 /* struct 00246 { */ 00247 /*! 00248 * The filter argument can be set as binary argument or ASCII arguments. 00249 * When the bit is on the argument are binary. 00250 */ 00251 /* uint8_t Binary: 1; */ 00252 /*! 00253 * 00254 */ 00255 /* uint8_t AutoSort : 1; */ 00256 /*! 00257 * 00258 */ 00259 /* uint8_t AutoFaultDetect : 1; */ 00260 /*! 00261 * When the bit is on it means the the node is enabled . 00262 */ 00263 /* uint8_t Enabled : 1; */ 00264 /* uint8_t padding : 3; */ 00265 /* 00266 };*/ 00267 00268 uint8_t IntRepresentation; 00269 00270 } SlrxFilterFlags_t; 00271 00272 /*! \typedef SlrxFilterCompareFunction_t 00273 * Used as comparison function for the header type arguments 00274 * 00275 */ 00276 typedef uint8_t SlrxFilterCompareFunction_t; 00277 /* Possible values for SlrxFilterCompareFunction_t */ 00278 #define COMPARE_FUNC_IN_BETWEEN (0) 00279 #define COMPARE_FUNC_EQUAL (1) 00280 #define COMPARE_FUNC_NOT_EQUAL_TO (2) 00281 #define COMPARE_FUNC_NOT_IN_BETWEEN (3) 00282 #define COMPARE_FUNC_NUM_OF_FILTER_COMPARE_FUNC (4) 00283 00284 /*! \typedef SlrxFilterCompareFunction_t 00285 * Used as comparison function for the header type arguments 00286 * 00287 */ 00288 typedef uint8_t SlrxTriggerCompareFunction_t; 00289 /* Possible values for SlrxTriggerCompareFunction_t */ 00290 #define TRIGGER_COMPARE_FUNC_EQUAL (0) 00291 /* arg1 == protocolVal ,not supported in current release */ 00292 #define TRIGGER_COMPARE_FUNC_NOT_EQUAL_TO (1) 00293 /* arg1 == protocolVal */ 00294 #define TRIGGER_COMPARE_FUNC_SMALLER_THAN (2) 00295 /* arg1 == protocolVal */ 00296 #define TRIGGER_COMPARE_FUNC_BIGGER_THAN (3) 00297 /* definition */ 00298 #define TRIGGER_COMPARE_FUNC_NUM_OF_FILTER_COMPARE_FUNC (4) 00299 00300 00301 /*! \typedef SlrxFilterHdrField_t 00302 * Provides list of possible header types which may be defined as part of the rule 00303 * 00304 */ 00305 typedef uint8_t SlrxFilterHdrField_t; 00306 /* Possible values for SlrxFilterHdrField_t */ 00307 #define NULL_FIELD_ID_TYPE (0) 00308 /* 802.11 control\data\management */ 00309 #define FRAME_TYPE_FIELD (1) 00310 /* 802.11 beacon\probe\.. */ 00311 #define FRAME_SUBTYPE_FIELD (2) 00312 /* 802.11 bssid type */ 00313 #define BSSID_FIELD (3) 00314 /* */ 00315 #define MAC_SRC_ADDRESS_FIELD (4) 00316 /* */ 00317 #define MAC_DST_ADDRESS_FIELD (5) 00318 /* */ 00319 #define FRAME_LENGTH_FIELD (6) 00320 /* */ 00321 #define PROTOCOL_TYPE_FIELD (7) 00322 /* */ 00323 #define IP_VERSION_FIELD (8) 00324 /* TCP / UDP */ 00325 #define IP_PROTOCOL_FIELD (9) 00326 /* */ 00327 #define IPV4_SRC_ADRRESS_FIELD (10) 00328 /* */ 00329 #define IPV4_DST_ADDRESS_FIELD (11) 00330 /* */ 00331 #define IPV6_SRC_ADRRESS_FIELD (12) 00332 /* */ 00333 #define IPV6_DST_ADDRESS_FIELD (13) 00334 /* */ 00335 #define SRC_PORT_FIELD (14) 00336 /* */ 00337 #define DST_PORT_FIELD (15) 00338 /* Definition */ 00339 #define NUM_OF_FIELD_NAME_FIELD (16) 00340 00341 /*! \union SlrxFilterHeaderArg_t 00342 * The structure holds the header ARGS which are used in case of HDR rule. 00343 */ 00344 /* -- 36 bytes */ 00345 typedef union SlrxFilterHeaderArg_t { 00346 /*----------------------------- Large size ---------------------------------*/ 00347 /*! buffer for binary arguments, number of argument may be up to SL_RX_FILTER_NUM_OF_FILTER_HEADER_ARGS 00348 * example : IPV6 16 bytes, 39 characters 00349 * ipv6 Ascii address: 2001:0db8:3c4d:0015:0000:0000:abcd:ef12 00350 */ 00351 00352 SlrxFilterBinaryArg_t RxFilterDB16BytesRuleArgs [SL_RX_FILTER_NUM_OF_FILTER_HEADER_ARGS][16 ]; /* Binary Values for comparition */ 00353 /*! buffer for ASCII arguments, number of argument may be up to SL_RX_FILTER_NUM_OF_FILTER_HEADER_ARGS 00354 * example : IPV6 16 bytes, 39 characters 00355 * ipv6 Ascii address: 2001:0db8:3c4d:0015:0000:0000:abcd:ef12 00356 * Ascii format for ipV6 is not supported 00357 */ 00358 /*----------------------------- Medium size ---------------------------------*/ 00359 /*! buffer for binary arguments, number of argument may be up to SL_RX_FILTER_NUM_OF_FILTER_HEADER_ARGS 00360 * MAC address: 6 bytes, 17 chars 00361 */ 00362 SlrxFilterBinaryArg_t RxFilterDB6BytesRuleArgs [SL_RX_FILTER_NUM_OF_FILTER_HEADER_ARGS][6]; /* Binary Values for comparition */ 00363 /*! 00364 * ! buffer for ASCII arguments, number of argument may be up to SL_RX_FILTER_NUM_OF_FILTER_HEADER_ARGS 00365 * IP address: 4 bytes, 15 chars 00366 * 2 bytes are added for padding 00367 */ 00368 SlrxFilterAsciiArg_t RxFilterDB18BytesAsciiRuleArgs [SL_RX_FILTER_NUM_OF_FILTER_HEADER_ARGS][18]; /* Ascii Values for comparison */ 00369 /*----------------------------- Small size ---------------------------------*/ 00370 /*! buffer for binary arguments, number of argument may be up to SL_RX_FILTER_NUM_OF_FILTER_HEADER_ARGS 00371 * IP address: 4 bytes, 15 chars 00372 * Port: 2 bytes, chars: 5 chars 00373 */ 00374 SlrxFilterBinaryArg_t RxFilterDB4BytesRuleArgs [SL_RX_FILTER_NUM_OF_FILTER_HEADER_ARGS][4]; /* Binary Values for comparison */ 00375 /*! buffer for ASCII arguments, number of argument may be up to SL_RX_FILTER_NUM_OF_FILTER_HEADER_ARGS 00376 * Port: 2 bytes, chars: 5 chars 00377 */ 00378 SlrxFilterAsciiArg_t RxFilterDB5BytesRuleAsciiArgs [SL_RX_FILTER_NUM_OF_FILTER_HEADER_ARGS][5]; /* Ascii Values for comparison */ 00379 /*----------------------------- 1 byte size ---------------------------------*/ 00380 /*! buffer for binary arguments, number of argument may be up to SL_RX_FILTER_NUM_OF_FILTER_HEADER_ARGS 00381 */ 00382 SlrxFilterBinaryArg_t RxFilterDB1BytesRuleArgs [SL_RX_FILTER_NUM_OF_FILTER_HEADER_ARGS][1]; /* Binary Values for comparison */ 00383 } SlrxFilterHeaderArg_t ; 00384 00385 00386 00387 /*! \typedef SlrxFilterRuleHeaderArgsAndMask_t 00388 * Structure which defines the Header Args and mask 00389 */ 00390 /* -- 52 bytes */ 00391 typedef struct SlrxFilterRuleHeaderArgsAndMask_t { 00392 /*! Argument for the comparison function */ 00393 /* -- 36 byte */ 00394 SlrxFilterHeaderArg_t RuleHeaderArgs; 00395 00396 /*! the mask is used in order to enable partial comparison, 00397 * Use the 0xFFFFFFFF in case you don't want to use mask 00398 */ 00399 /* -- 16 bytes */ 00400 SlrxFilterCompareMask_t RuleHeaderArgsMask[16]; 00401 00402 } SlrxFilterRuleHeaderArgsAndMask_t; 00403 00404 /*! \typedef SlrxFilterHeaderType_t 00405 * Structure which defines the Header rule 00406 * The header rule defines compare function on the protocol header 00407 * For example destMacAddre is between ( 12:6::78:77, 12:6::78:90 ) 00408 * 00409 */ 00410 /* -- 56 byte */ 00411 typedef struct SlrxFilterHeaderType_t { 00412 /*! see :: SlrxFilterRuleHeaderArgsAndMask_t */ 00413 /* -- 52 bytes */ 00414 SlrxFilterRuleHeaderArgsAndMask_t RuleHeaderArgsAndMask; 00415 00416 /*! Packet HDR field which will be compared to the argument */ 00417 /* -- 1 byte */ 00418 SlrxFilterHdrField_t RuleHeaderfield; 00419 00420 /* -- 1 byte */ 00421 /*! type of the comparison function 00422 * see :: SlrxFilterCompareFunction_t 00423 */ 00424 SlrxFilterCompareFunction_t RuleCompareFunc; 00425 00426 /*! padding */ 00427 /* -- 2 bytes */ 00428 uint8_t RulePadding[2]; 00429 00430 } SlrxFilterHeaderType_t; 00431 00432 /*! \typedef SlrxFilterPayloadType_t 00433 * Structure which defines payload rule. 00434 * Not supported on current release. 00435 */ 00436 /* -- 40 byte */ 00437 typedef struct SlrxFilterPayloadType_t { 00438 /*! Not supported on current release */ 00439 /* -- 32 byte */ 00440 SlrxFilterRegxPattern_t RegxPattern; 00441 /*! Not supported on current release */ 00442 /* -- 4 byte */ 00443 SlrxFilterOffset_t LowerOffset; 00444 /*! Not supported on current release */ 00445 /* -- 4 byte */ 00446 SlrxFilterOffset_t UpperOffset; 00447 } SlrxFilterPayloadType_t; 00448 00449 /*! \typedef SlrxFilterCombinationTypeOperator_t 00450 * Enumerate the optional operators for the combination type 00451 * filterID1 is located in the first arg , filterId2 is the second arg,see ::SlrxFilterCombinationType_t.CombinationFilterId 00452 */ 00453 typedef uint8_t SlrxFilterCombinationTypeOperator_t; 00454 /* Possible values for SlrxFilterCombinationTypeOperator_t */ 00455 /*! !filterID1 */ 00456 #define COMBINED_FUNC_NOT (0) 00457 /*! filterID1 && filterID2 */ 00458 #define COMBINED_FUNC_AND (1) 00459 /*! filterID1 && filterID2 */ 00460 #define COMBINED_FUNC_OR (2) 00461 00462 /*! \typedef SlrxFilterCombinationType_t 00463 * Defines the structure which define the combination type filter 00464 * The combined filter enable to make operation on one or two filter, 00465 * for example !filterId1 or and(filterId2,filterId3). 00466 * 00467 */ 00468 /* -- 4 byte */ 00469 typedef struct SlrxFilterCombinationType_t { 00470 /* ! combination operator */ 00471 /* -- 1 byte */ 00472 SlrxFilterCombinationTypeOperator_t CombinationTypeOperator; 00473 /* ! filterID, may be one or two depends on the combination operator type */ 00474 /* -- 2 byte */ 00475 SlrxFilterID_t CombinationFilterId[SL_RX_FILTER_NUM_OF_COMBINATION_TYPE_ARGS]; 00476 /* ! Padding */ 00477 /* -- 1 byte */ 00478 uint8_t Padding; 00479 } SlrxFilterCombinationType_t; 00480 00481 00482 /*! \typedef SlrxFilterRule_t 00483 * Rule structure composed of behavioral flags and the filter rule definitions 00484 * 00485 */ 00486 /* -- 56 byte */ 00487 typedef union SlrxFilterRule_t { 00488 /* ! Header type rule , see explanation on the ::SlrxFilterHeaderType_t structure */ 00489 /* -- 56 byte */ 00490 SlrxFilterHeaderType_t HeaderType; 00491 /* ! Payload rule, not supported in current release */ 00492 /* -- 40 byte */ 00493 SlrxFilterPayloadType_t PayLoadHeaderType; /* future for exact pattern or like hood pattern */ 00494 /* ! Combined type rule , see explanation in ::SlrxFilterCombinationType_t structure */ 00495 /* -- 4 byte */ 00496 SlrxFilterCombinationType_t CombinationType; 00497 } SlrxFilterRule_t; 00498 00499 /*! \typedef SlrxFilterTriggerRoles_t 00500 * Bit field which represents the roleId possible values 00501 * In the current release only Station/AP roles are supported. 00502 */ 00503 #define RX_FILTER_ROLE_AP (1) 00504 #define RX_FILTER_ROLE_STA (2) 00505 #define RX_FILTER_ROLE_PROMISCUOUS (4) 00506 #define RX_FILTER_ROLE_NULL (0) 00507 00508 typedef union SlrxFilterTriggerRoles_t { 00509 /* struct */ 00510 /* { */ 00511 /* uint8_t RoleAP :1; */ 00512 /* uint8_t RoleStation :1; */ 00513 /* The filter is activated only in Promiscuous mode */ 00514 /* uint8_t PromiscuousMode :1; */ 00515 /* uint8_t RoleReserved :5; */ 00516 /* }; */ 00517 /* ! Bit fiels of the Filter role */ 00518 uint8_t IntRepresentation; 00519 00520 } SlrxFilterTriggerRoles_t; 00521 00522 /*! \typedef SlrxFilterTriggerConnectionStates_t 00523 * Bit field representing the possible values of the When section of the rule 00524 * 00525 */ 00526 #define RX_FILTER_CONNECTION_STATE_STA_CONNECTED (1) 00527 #define RX_FILTER_CONNECTION_STATE_STA_NOT_CONNECTED (2) 00528 #define RX_FILTER_CONNECTION_STATE_STA_HAS_IP (4) 00529 #define RX_FILTER_CONNECTION_STATE_STA_HAS_NO_IP (8) 00530 00531 typedef union SlrxFilterTriggerConnectionStates_t { 00532 /* struct */ 00533 /* { */ 00534 /* uint8_t RoleStationWiFiConnected :1; */ 00535 /* uint8_t RoleStationWiFiDisconneted:1; */ 00536 /* uint8_t RoleStationWiFiHasIp:1; */ 00537 /* uint8_t RoleStationWiFiHasNoIp:1; */ 00538 /* uint8_t RoleStationWiFiSocketOpened:1; */ 00539 /* uint8_t RoleStationWiFiSocketclosed:1; */ 00540 /* }; */ 00541 /* */ 00542 /* ! */ 00543 uint8_t IntRepresentation; 00544 00545 } SlrxFilterTriggerConnectionStates_t; 00546 00547 /*! \typedef SlrxFilterDBTriggerArg_t 00548 * Provides container for entering the filter 'when' argument. 00549 * The current release support 'When rules' which has no arguments. 00550 * For example : 00551 * When connect to specific AP -- the AP bssid is the argument. 00552 * 00553 */ 00554 typedef uint32_t SlrxFilterDBTriggerArg_t; 00555 00556 00557 00558 /*! \typedef SlrxFilterCounterId_t 00559 * the counter ID we have 4 counters 00560 */ 00561 typedef uint8_t SlrxFilterCounterId_t; 00562 /* Possible values for SlrxFilterCounterId_t */ 00563 #define NO_TRIGGER (0) 00564 #define RX_FILTER_COUNTER1 (1) 00565 #define RX_FILTER_COUNTER2 (2) 00566 #define RX_FILTER_COUNTER3 (3) 00567 #define RX_FILTER_COUNTER4 (4) 00568 #define RX_FILTER_COUNTER5 (5) 00569 #define RX_FILTER_COUNTER6 (6) 00570 #define RX_FILTER_COUNTER7 (7) 00571 #define RX_FILTER_COUNTER8 (8) 00572 #define MAX_RX_FILTER_COUNTER (9) 00573 00574 00575 00576 /*! \typedef SlrxFilterActionArgs_t 00577 * Possible value for filter action args 00578 * 00579 */ 00580 00581 typedef uint8_t SlrxFilterActionArgs_t; 00582 /* Possible values for SlrxFilterActionArgs_t */ 00583 #define ACTION_ARG_REG_1_4 (0) 00584 /* ! Can be use as counter */ 00585 #define ACTION_ARG_TEMPLATE (1) 00586 /* ! Can be use as counter */ 00587 #define ACTION_ARG_EVENT (2) 00588 00589 /* ! GPIO number */ 00590 #define ACTION_ARG_GPIO (4) 00591 /*! 00592 * \def SL_RX_FILTER_NUM_OF_BYTES_FOR_ACTIONS_ARGS 00593 * 00594 */ 00595 #define SL_RX_FILTER_NUM_OF_BYTES_FOR_ACTIONS_ARGS (5) 00596 00597 00598 00599 00600 /*! \typedef SlrxFilterTrigger_t 00601 * The filter trigger, determine when the filter is triggered, 00602 * The filter is triggered in the following condition :\n 00603 * 1. The filter parent is triggered\n 00604 * 2. The requested connection type exists, i.e. wlan_connect\n 00605 * 3. The filter role is the same as the system role\n 00606 * 00607 */ 00608 /* -- 12 byte */ 00609 typedef struct SlrxFilterTrigger_t { 00610 /*! The parent filter ID, this is the way to build filter tree. */ 00611 /* NULL value means tree root. 00612 */ 00613 /* -- 1 byte */ 00614 SlrxFilterID_t ParentFilterID; 00615 /* ! See ::SlrxFilterCounterId_t explanation */ 00616 /* -- 1 byte */ 00617 SlrxFilterCounterId_t Trigger; 00618 /* ! See :: SlrxFilterTriggerConnectionStates_t */ 00619 /* -- 1 byte */ 00620 SlrxFilterTriggerConnectionStates_t TriggerArgConnectionState; 00621 /* ! See ::SlrxFilterTriggerRoles_t */ 00622 /* -- 1 byte */ 00623 SlrxFilterTriggerRoles_t TriggerArgRoleStatus; 00624 /* ! The Trigger arguments are in the same order as the Trigger bit field order. */ 00625 /* -- 4 byte */ 00626 SlrxFilterDBTriggerArg_t TriggerArg; 00627 /** The compare function which will be operate for each bit that is turned on in the ::SlrxFilterTrigger_t.Trigger field, 00628 * for example , in case the second bit in the Trigger function is on the second function in the list will be executed. 00629 * 00630 */ 00631 /* -- 1 byte */ 00632 SlrxTriggerCompareFunction_t TriggerCompareFunction; 00633 00634 /* ! padding */ 00635 /* -- 3 byte */ 00636 uint8_t Padding[3]; 00637 } SlrxFilterTrigger_t; 00638 00639 /*! \typedef SlrxFilterActionType_t 00640 * The actions are executed only if the filter is matched,\n 00641 * In case of false match the packet is transfered to the HOST. \n 00642 * The action is composed of bit field structure, 00643 * up to 2 actions can be defined per filter. 00644 * 00645 */ 00646 #define RX_FILTER_ACTION_NULL (0x0) 00647 #define RX_FILTER_ACTION_DROP (0x1) 00648 #define RX_FILTER_ACTION_GPIO (0x2) 00649 #define RX_FILTER_ACTION_ON_REG_INCREASE (0x4) 00650 #define RX_FILTER_ACTION_ON_REG_DECREASE (0x8) 00651 #define RX_FILTER_ACTION_ON_REG_RESET (0x10) 00652 #define RX_FILTER_ACTION_SEND_TEMPLATE (0x20) /* unsupported */ 00653 #define RX_FILTER_ACTION_EVENT_TO_HOST (0x40) /* unsupported */ 00654 00655 typedef union SlrxFilterActionType_t { 00656 /* struct */ 00657 /* { */ 00658 /* ! No action to execute the packet is dropped,drop is always on leaf. */ 00659 /* ! If not dropped ,The packet is passed to the next filter or in case it is the last filter to the host */ 00660 /* uint8_t ActionDrop : 1; */ 00661 /* ! Not Supported in the current release */ 00662 /* uint8_t ActionGpio : 1; */ 00663 /*! action can increase counter registers. 00664 * 1 = Increase 00665 * 2 = decrease 00666 * 3 = reset 00667 */ 00668 /* uint8_t ActionOnREGIncrease : 1; */ 00669 /* uint8_t ActionOnREGDecrease : 1; */ 00670 /* uint8_t ActionOnREGReset : 1; */ 00671 00672 /* ! Not Supported in the current release */ 00673 /* uint8_t ActionSendTemplate : 1; */ 00674 /* ! Not Supported in the current release */ 00675 /* uint8_t ActionEventToHost: 1; */ 00676 /* uint8_t padding: 1; */ 00677 /* }; */ 00678 00679 uint8_t IntRepresentation; 00680 00681 } SlrxFilterActionType_t; 00682 00683 /*! \typedef SlrxFilterAction_t 00684 * Several actions can be defined,\n 00685 * The action is executed in case the filter rule is matched. 00686 */ 00687 /* -- 8 byte */ 00688 typedef struct SlrxFilterAction_t { 00689 /* -- 1 byte */ 00690 /* ! Determine which actions are supported */ 00691 SlrxFilterActionType_t ActionType; 00692 /* ! Buffer for the action arguments */ 00693 /** 00694 * <b>location 0</b> - The counter to increase 00695 * In case the action is of type "increase" the arg will contain the counter number, 00696 * The counter number values are as in ::SlrxFilterCounterId_t.\n 00697 * <b>location 1</b> - The template arg.\n 00698 * <b>location 2</b> - The event arg.\n 00699 * 00700 */ 00701 /* -- 5 byte */ 00702 SlrxFilterActionArg_t ActionArg[SL_RX_FILTER_NUM_OF_BYTES_FOR_ACTIONS_ARGS]; 00703 00704 /* ! Padding */ 00705 /* - 2 Bytes */ 00706 uint8_t Padding[2]; 00707 00708 } SlrxFilterAction_t; 00709 00710 00711 /*! \struct _WlanRxFilterOperationCommandBuff_t 00712 * The structure is used for the interface HOST NWP.\n 00713 * The supported operation : \n 00714 * ::ENABLE_DISABLE_RX_FILTER,\n 00715 * ::REMOVE_RX_FILTER,\n 00716 * 00717 */ 00718 /* 20 bytes */ 00719 typedef struct _WlanRxFilterOperationCommandBuff_t { 00720 /* -- 16 bytes */ 00721 SlrxFilterIdMask_t FilterIdMask; 00722 /* 4 bytes */ 00723 uint8_t Padding[4]; 00724 } _WlanRxFilterOperationCommandBuff_t ; 00725 00726 00727 00728 /* -- 56 bytes */ 00729 typedef struct _WlanRxFilterUpdateArgsCommandBuff_t { 00730 /* -- 1 bytes */ 00731 uint8_t FilterId; 00732 00733 /* -- 1 bytes */ 00734 /* ! the args representation */ 00735 uint8_t BinaryRepresentation; 00736 00737 /* -- 52 byte */ 00738 SlrxFilterRuleHeaderArgsAndMask_t FilterRuleHeaderArgsAndMask; 00739 00740 /* -- 2 bytes */ 00741 uint8_t Padding[2]; 00742 } _WlanRxFilterUpdateArgsCommandBuff_t; 00743 00744 00745 /*! \typedef _WlanRxFilterRetrieveEnableStatusCommandResponseBuff_t 00746 * The structure is used for the interface HOST NWP.\n 00747 * 00748 */ 00749 /* -- 16 bytes */ 00750 typedef struct _WlanRxFilterRetrieveEnableStatusCommandResponseBuff_t { 00751 00752 /* ! the filter set bit map */ 00753 /* -- 16 bytes */ 00754 SlrxFilterIdMask_t FilterIdMask; 00755 00756 } _WlanRxFilterRetrieveEnableStatusCommandResponseBuff_t; 00757 00758 00759 /*! \struct _WlanRxFilterPrePreparedFiltersCommandBuff_t 00760 * The function enables to perform operations on pre-prepared filters 00761 * 00762 */ 00763 typedef struct _WlanRxFilterPrePreparedFiltersCommandBuff_t { 00764 /* ! the filter set bit map */ 00765 /* -- 4 bytes */ 00766 SlrxFilterPrePreparedFiltersMask_t FilterPrePreparedFiltersMask; 00767 00768 } _WlanRxFilterPrePreparedFiltersCommandBuff_t ; 00769 00770 00771 /*! \typedef sl_protocol_WlanRxFilterPrePreparedFiltersCommandResponseBuff_t 00772 * 00773 */ 00774 /*-- 4 bytes */ 00775 typedef struct _WlanRxFilterPrePreparedFiltersCommandResponseBuff_t { 00776 /* -- 4 bytes */ 00777 /* ! the filter set bit map */ 00778 SlrxFilterPrePreparedFiltersMask_t FilterPrePreparedFiltersMask; 00779 00780 } _WlanRxFilterPrePreparedFiltersCommandResponseBuff_t; 00781 00782 00783 00784 typedef uint8_t SLrxFilterOperation_t; 00785 #define SL_ENABLE_DISABLE_RX_FILTER (0) 00786 #define SL_REMOVE_RX_FILTER (1) 00787 #define SL_STORE_RX_FILTERS (2) 00788 #define SL_UPDATE_RX_FILTER_ARGS (3) 00789 #define SL_FILTER_RETRIEVE_ENABLE_STATE (4) 00790 #define SL_FILTER_PRE_PREPARED_RETRIEVE_CREATE_REMOVE_STATE (5) 00791 #define SL_FILTER_PRE_PREPARED_SET_CREATE_REMOVE_STATE (6) 00792 00793 00794 /* Bit manipulation for 8 bit */ 00795 #define ISBITSET8(x,i) ((x[i>>3] & (0x80>>(i&7)))!=0) /* < Is bit set, 8 bit unsigned numbers = x , location = i */ 00796 #define SETBIT8(x,i) x[i>>3]|=(0x80>>(i&7)); /* < Set bit,8 bit unsigned numbers = x , location = i */ 00797 #define CLEARBIT8(x,i) x[i>>3]&=(0x80>>(i&7))^0xFF; /* < Clear bit,8 bit unsigned numbers = x , location = i */ 00798 00799 namespace mbed_cc3100 { 00800 00801 /* ******************************************************************************/ 00802 /* RX filters - Start */ 00803 /* ******************************************************************************/ 00804 /* -- 80 bytes */ 00805 typedef struct _WlanRxFilterAddCommand_t { 00806 /* -- 1 byte */ 00807 SlrxFilterRuleType_t RuleType; 00808 /* -- 1 byte */ 00809 SlrxFilterFlags_t FilterFlags; 00810 /* -- 1 byte */ 00811 SlrxFilterID_t FilterId; 00812 /* -- 1 byte */ 00813 uint8_t Padding; 00814 /* -- 56 byte */ 00815 SlrxFilterRule_t Rule; 00816 /* -- 12 byte ( 3 padding ) */ 00817 SlrxFilterTrigger_t Trigger; 00818 /* -- 8 byte */ 00819 SlrxFilterAction_t Action; 00820 } _WlanRxFilterAddCommand_t; 00821 00822 00823 00824 /* -- 4 bytes */ 00825 typedef struct l_WlanRxFilterAddCommandReponse_t { 00826 /* -- 1 byte */ 00827 SlrxFilterID_t FilterId; 00828 /* -- 1 Byte */ 00829 uint8_t Status; 00830 /* -- 2 byte */ 00831 uint8_t Padding[2]; 00832 00833 } _WlanRxFilterAddCommandReponse_t; 00834 00835 00836 00837 /* 00838 * \struct _WlanRxFilterSetCommand_t 00839 */ 00840 typedef struct _WlanRxFilterSetCommand_t { 00841 uint16_t InputBufferLength; 00842 /* 1 byte */ 00843 SLrxFilterOperation_t RxFilterOperation; 00844 uint8_t Padding[1]; 00845 } _WlanRxFilterSetCommand_t; 00846 00847 /** 00848 * \struct _WlanRxFilterSetCommandReponse_t 00849 */ 00850 typedef struct _WlanRxFilterSetCommandReponse_t { 00851 /* 1 byte */ 00852 uint8_t Status; 00853 /* 3 bytes */ 00854 uint8_t Padding[3]; 00855 00856 } _WlanRxFilterSetCommandReponse_t; 00857 00858 /** 00859 * \struct _WlanRxFilterGetCommand_t 00860 */ 00861 typedef struct _WlanRxFilterGetCommand_t { 00862 uint16_t OutputBufferLength; 00863 /* 1 byte */ 00864 SLrxFilterOperation_t RxFilterOperation; 00865 uint8_t Padding[1]; 00866 } _WlanRxFilterGetCommand_t; 00867 00868 /** 00869 * \struct _WlanRxFilterGetCommandReponse_t 00870 */ 00871 typedef struct _WlanRxFilterGetCommandReponse_t { 00872 /* 1 byte */ 00873 uint8_t Status; 00874 /* 1 bytes */ 00875 uint8_t Padding; 00876 /* 2 byte */ 00877 uint16_t OutputBufferLength; 00878 00879 } _WlanRxFilterGetCommandReponse_t; 00880 00881 00882 00883 /* ******************************************************************************/ 00884 /* RX filters -- End */ 00885 /* ******************************************************************************/ 00886 00887 class cc3100_driver; 00888 00889 class cc3100_wlan_rx_filters 00890 { 00891 00892 public: 00893 00894 cc3100_wlan_rx_filters(cc3100_driver &driver); 00895 00896 ~cc3100_wlan_rx_filters(); 00897 00898 00899 /*********************************************************************************************/ 00900 /* Function prototypes */ 00901 /*********************************************************************************************/ 00902 00903 /*! 00904 00905 \addtogroup wlan 00906 @{ 00907 00908 */ 00909 00910 00911 /*! 00912 \brief Adds new filter rule to the system 00913 00914 \param[in] RuleType The rule type 00915 \param[in] FilterFlags Flags which set the type of header rule Args and sets the persistent flag 00916 \param[in] pRule Determine the filter rule logic 00917 \param[in] pTrigger Determine when the rule is triggered also sets rule parent. 00918 \param[in] pAction Sets the action to be executed in case the match functions pass 00919 \param[out] pFilterId The filterId which was created 00920 00921 \return On success, zero is returned. Otherwise error code is returned 00922 */ 00923 #if _SL_INCLUDE_FUNC(sl_WlanRxFilterAdd) 00924 SlrxFilterID_t sl_WlanRxFilterAdd( SlrxFilterRuleType_t RuleType, 00925 SlrxFilterFlags_t FilterFlags, 00926 const SlrxFilterRule_t* const Rule, 00927 const SlrxFilterTrigger_t* const Trigger, 00928 const SlrxFilterAction_t* const Action, 00929 SlrxFilterID_t* pFilterId); 00930 00931 #endif 00932 00933 00934 00935 00936 00937 /*! 00938 \brief Sets parameters to Rx filters 00939 00940 \param[in] RxFilterOperation 00941 possible operations : 00942 - SL_ENABLE_DISABLE_RX_FILTER - Enables\disables filter in a filter list 00943 - SL_REMOVE_RX_FILTER - Removes filter from memory ( to remove from flash call SL_STORE_RX_FILTERS after this command) 00944 - SL_STORE_RX_FILTERS - Save the filters for persistent 00945 - SL_UPDATE_RX_FILTER_ARGS - Update the arguments of existing filter 00946 - SL_FILTER_PRE_PREPARED_SET_CREATE_REMOVE_STATE - Change the default creation of the pre-prepared filters 00947 00948 \param[in] pInputBuffer options: 00949 The buffer input is _WlanRxFilterOperationCommandBuff_t: 00950 - SL_ENABLE_DISABLE_RX_FILTER 00951 - SL_REMOVE_RX_FILTER 00952 - SL_STORE_RX_FILTERS 00953 The buffer input is _WlanRxFilterUpdateArgsCommandBuff_t: 00954 - SL_UPDATE_RX_FILTER_ARGS 00955 The buffer input is _WlanRxFilterPrePreparedFiltersCommandBuff_t: 00956 - SL_FILTER_PRE_PREPARED_SET_CREATE_REMOVE_STATE 00957 00958 \param[in] InputbufferLength The length in byte of the input buffer 00959 00960 \return On success, zero is returned. Otherwise error code is returned 00961 */ 00962 00963 #if _SL_INCLUDE_FUNC(sl_WlanRxFilterSet) 00964 int16_t sl_WlanRxFilterSet( const SLrxFilterOperation_t RxFilterOperation, 00965 const uint8_t* const pInputBuffer, 00966 uint16_t InputbufferLength); 00967 #endif 00968 00969 /*! 00970 \brief Gets parameters of Rx filters 00971 00972 \param[in] RxFilterOperation 00973 possible operations : 00974 - SL_FILTER_RETRIEVE_ENABLE_STATE - Retrieves the enable disable status 00975 - SL_FILTER_PRE_PREPARED_RETRIEVE_CREATE_REMOVE_STATE - Retrieves the pre-prepared filters creation status 00976 00977 \param[in] pOutputBuffer 00978 The buffer input is _WlanRxFilterRetrieveEnableStatusCommandResponseBuff_t: 00979 - SL_FILTER_RETRIEVE_ENABLE_STATE 00980 The buffer input is _WlanRxFilterPrePreparedFiltersCommandResponseBuff_t: 00981 - SL_FILTER_PRE_PREPARED_RETRIEVE_CREATE_REMOVE_STATE 00982 00983 \param[in] OutputbufferLength The length in byte of the output buffer 00984 00985 \return On success, zero is returned. Otherwise error code is returned 00986 */ 00987 00988 #if _SL_INCLUDE_FUNC(sl_WlanRxFilterGet) 00989 int16_t sl_WlanRxFilterGet(const SLrxFilterOperation_t RxFilterOperation, 00990 uint8_t* pOutputBuffer, 00991 uint16_t OutputbufferLength); 00992 #endif 00993 00994 private: 00995 00996 cc3100_driver &_driver; 00997 00998 00999 /*! 01000 01001 Close the Doxygen group. 01002 @} 01003 01004 */ 01005 };//class 01006 01007 }//namespace mbed_cc3100 01008 01009 #endif /* RX_FILTERS_PREPROCESSOR_CLI_IF_H_ */ 01010 01011 01012
Generated on Wed Jul 13 2022 09:55:38 by 1.7.2