openbcm

Git mirror of https://github.com/Broadcom-Network-Switching-Software/OpenBCM
git clone git://git.finwo.net/mirror/broadcom/openbcm
Log | Files | Refs | README

acl_util.h (3517B)


      1 /*
      2  * 
      3  * This license is set out in https://raw.githubusercontent.com/Broadcom-Network-Switching-Software/OpenBCM/master/Legal/LICENSE file.
      4  * 
      5  * Copyright 2007-2019 Broadcom Inc. All rights reserved.
      6  *
      7  * File:        acl_util.h
      8  *     
      9  * Purpose:     
     10  *     Access Control List (ACL) utility functions. These
     11  *     are intended primarily to provide additional support for the CLI code.
     12  *     and API prototypes.
     13  */
     14 
     15 #ifndef   _ACL_UTIL_H_
     16 #define   _ACL_UTIL_H_
     17 
     18 #if defined(INCLUDE_ACL)
     19 
     20 #include <sal/core/sync.h>
     21 #include <appl/acl/acl.h>
     22 
     23 #define ACL_MASK_ETHERTYPE      (0xffff)
     24 #define ACL_MASK_IPPROTOCOL     (0xff)
     25 
     26 /*
     27  * Typedef: _acl_rule_link_t
     28  *
     29  * Purpose:
     30  *     Linked-list wrapper for public bcma_acl_rule_t type.
     31  *
     32  * Fields:
     33  *     rule  - Public rule parameters
     34  *     *next - Link to next node rule
     35  */
     36 typedef struct _acl_rule_link_s {
     37     bcma_acl_rule_t          *rule;     /* Public rule parameters     */
     38     uint32                   entries;   /* Number of physical entries */
     39     struct _acl_rule_link_s  *next;     /* Link to next node rule     */
     40 } _acl_rule_link_t;
     41 
     42 /*
     43  * Typedef: _acl_link_t
     44  *
     45  * Purpose:
     46  *     Linked-list wrapper for public bcma_acl_t type.
     47  *
     48  * Fields:
     49  *     - <bcma_acl_t> list Public data for this list node
     50  *     - <_acl_rule_link_t> *rules Linked list of rules
     51  *     - <_acl_rule_link_t> *cur Current rule, used for iterating through list
     52  *     - <_acl_link_t> *next    Link to next list node
     53  */
     54 typedef struct _acl_link_s {
     55     bcma_acl_t               *list;     /* This list node public data */
     56     _acl_rule_link_t         *rules;    /* Linked list of rules       */
     57     _acl_rule_link_t         *cur;      /* Current rule               */
     58     struct _acl_link_s       *prev;     /* Link to previous list node */
     59     struct _acl_link_s       *next;     /* Link to next list node     */
     60 } _acl_link_t;
     61 
     62 /*
     63  * Typedef: _acl_control_t
     64  *
     65  * Purpose:
     66  *    System-wide ACL data.
     67  *
     68  * Fields:
     69  *    - <_acl_link_t> *lists     Linked-list of ACLs
     70  *    - <_acl_link_t> *cur       Current ACL; used for iterating over lists
     71  *    - sal_mutex_t acl_lock     System lock
     72  */
     73 typedef struct _acl_control_s {
     74     _acl_link_t         head;           /* Linked-list of ACLs              */
     75     _acl_link_t         *cur;           /* Current ACL                      */
     76     sal_mutex_t         acl_lock;       /* System lock                      */
     77 }_acl_control_t;
     78 
     79 /*
     80  * Typedef: acl_node_t
     81  *
     82  * Purpose:
     83  *     Single element in a list of nodes that make up a range. For instance, if
     84  *     someone qualifies on a range of VLAN IDs, this will get implemented as a
     85  *     list of data/mask pairs that cover the requested range.
     86  *
     87  * Fields:
     88  *     data -
     89  *     mask -
     90  */
     91 typedef struct acl_node_s {
     92     uint16              data;
     93     uint16              mask;
     94     struct acl_node_s   *next;
     95 } acl_node_t;
     96 
     97 #define _BCMA_ACL_MAC_ALL_ONES {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}
     98 
     99 /* Prototypes  */
    100 extern _acl_link_t      *_acl_first(_acl_control_t *control);
    101 extern _acl_link_t      *_acl_next(_acl_control_t *control);
    102 extern bcma_acl_rule_t  *_acl_rule_first(_acl_link_t *list_link);
    103 extern bcma_acl_rule_t  *_acl_rule_next(_acl_link_t *list_link);
    104 extern _acl_rule_link_t *_acl_rule_link_find(bcma_acl_rule_id_t rid);
    105 
    106 extern int acl_range_to_list(uint16 min, uint16 max, acl_node_t **list,
    107                              int *count);
    108 extern int acl_range_destroy(acl_node_t *list, int count);
    109 
    110 #endif /* INCLUDE_ACL */
    111 
    112 #endif /* _ACL_UTIL_H_ */