LCOV - code coverage report
Current view: top level - plugins/snort - snort.h (source / functions) Hit Total Coverage
Test: coverage-filtered.info Lines: 4 4 100.0 %
Date: 2023-10-26 01:39:38 Functions: 1 1 100.0 %

          Line data    Source code
       1             : /* SPDX-License-Identifier: Apache-2.0
       2             :  * Copyright(c) 2021 Cisco Systems, Inc.
       3             :  */
       4             : 
       5             : #ifndef __snort_snort_h__
       6             : #define __snort_snort_h__
       7             : 
       8             : #include <vppinfra/error.h>
       9             : #include <vppinfra/socket.h>
      10             : #include <vlib/vlib.h>
      11             : #include <snort/daq_vpp.h>
      12             : 
      13             : typedef struct
      14             : {
      15             :   CLIB_CACHE_LINE_ALIGN_MARK (cacheline0);
      16             :   u8 log2_queue_size;
      17             :   daq_vpp_desc_t *descriptors;
      18             :   volatile u32 *enq_head;
      19             :   volatile u32 *deq_head;
      20             :   volatile u32 *enq_ring;
      21             :   volatile u32 *deq_ring;
      22             :   u32 next_desc;
      23             :   int enq_fd, deq_fd;
      24             :   u32 deq_fd_file_index;
      25             :   u32 *buffer_indices;
      26             :   u16 *next_indices;
      27             :   u32 *freelist;
      28             :   u32 ready;
      29             : 
      30             :   /* temporary storeage used by enqueue node */
      31             :   u32 n_pending;
      32             :   u16 pending_nexts[VLIB_FRAME_SIZE];
      33             :   u32 pending_buffers[VLIB_FRAME_SIZE];
      34             :   daq_vpp_desc_t pending_descs[VLIB_FRAME_SIZE];
      35             : } snort_qpair_t;
      36             : 
      37             : typedef struct
      38             : {
      39             :   u32 index;
      40             :   u32 client_index;
      41             :   void *shm_base;
      42             :   u32 shm_size;
      43             :   int shm_fd;
      44             :   snort_qpair_t *qpairs;
      45             :   u8 *name;
      46             :   u8 drop_on_disconnect;
      47             : } snort_instance_t;
      48             : 
      49             : typedef struct
      50             : {
      51             :   daq_vpp_msg_t msg;
      52             :   int fds[2];
      53             :   int n_fds;
      54             : } snort_client_msg_queue_elt;
      55             : 
      56             : typedef struct
      57             : {
      58             :   clib_socket_t socket;
      59             :   u32 instance_index;
      60             :   u32 file_index;
      61             :   snort_client_msg_queue_elt *msg_queue;
      62             : } snort_client_t;
      63             : 
      64             : typedef struct
      65             : {
      66             :   /* per-instance dequeue interrupts */
      67             :   void *interrupts;
      68             : } snort_per_thread_data_t;
      69             : 
      70             : typedef struct
      71             : {
      72             :   clib_socket_t *listener;
      73             :   snort_client_t *clients;
      74             :   snort_instance_t *instances;
      75             :   uword *instance_by_name;
      76             :   u32 *instance_by_sw_if_index;
      77             :   u8 **buffer_pool_base_addrs;
      78             :   snort_per_thread_data_t *per_thread_data;
      79             :   u32 input_mode;
      80             :   u8 *socket_name;
      81             : } snort_main_t;
      82             : 
      83             : extern snort_main_t snort_main;
      84             : extern vlib_node_registration_t snort_enq_node;
      85             : extern vlib_node_registration_t snort_deq_node;
      86             : 
      87             : typedef enum
      88             : {
      89             :   SNORT_ENQ_NEXT_DROP,
      90             :   SNORT_ENQ_N_NEXT_NODES,
      91             : } snort_enq_next_t;
      92             : 
      93             : typedef enum
      94             : {
      95             :   SNORT_INPUT = 1,
      96             :   SNORT_OUTPUT = 2,
      97             :   SNORT_INOUT = 3
      98             : } snort_attach_dir_t;
      99             : 
     100             : #define SNORT_ENQ_NEXT_NODES                                                  \
     101             :   {                                                                           \
     102             :     [SNORT_ENQ_NEXT_DROP] = "error-drop",                                     \
     103             :   }
     104             : 
     105             : /* functions */
     106             : clib_error_t *snort_instance_create (vlib_main_t *vm, char *name,
     107             :                                      u8 log2_queue_sz, u8 drop_on_disconnect);
     108             : clib_error_t *snort_interface_enable_disable (vlib_main_t *vm,
     109             :                                               char *instance_name,
     110             :                                               u32 sw_if_index, int is_enable,
     111             :                                               snort_attach_dir_t dir);
     112             : clib_error_t *snort_set_node_mode (vlib_main_t *vm, u32 mode);
     113             : 
     114             : always_inline void
     115           2 : snort_freelist_init (u32 *fl)
     116             : {
     117          34 :   for (int j = 0; j < vec_len (fl); j++)
     118          32 :     fl[j] = j;
     119           2 : }
     120             : 
     121             : #endif /* __snort_snort_h__ */

Generated by: LCOV version 1.14