DeepCover Embedded Security in IoT: Public-key Secured Data Paths

Dependencies:   MaximInterface

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers wlan_rx_filters.h Source File

wlan_rx_filters.h

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