unfinished work

This commit is contained in:
liuwentan
2022-11-17 05:05:35 +08:00
parent d9f62317b2
commit 2a83517894
45 changed files with 9266 additions and 104 deletions

View File

@@ -1,40 +1,75 @@
#pragma once
/*
**********************************************************************************************
* Maat: Deep Packet Inspection Policy Framework
#ifdef __cpluscplus
extern "C"
{
#endif
* Maat is the Goddess of truth and justice in ancient Egyptian concept.
* Her feather was the measure that determined whether the souls (considered
* to reside in the heart) of the departed would reach the paradise of afterlife
* successfully.
* Authors: Liu WenTan <liuwentan@geedgenetworks.com>
* Date: 2022-10-31
* Copyright: (c) 2018-2022 Geedge Networks, Inc. All rights reserved.
***********************************************************************************************
*/
#ifndef _MAAT_H_
#define _MAAT_H_
#include <stdint.h>
#include <netinet/in.h>
struct maat_feather;
/* maat instance handle */
struct maat;
/* network-order */
struct ipv4_tuple4{
uint32_t saddr; /* network order */
uint32_t daddr; /* network order */
uint16_t source; /* network order */
uint16_t dest; /* network order */
struct maat_rule {
int rule_id;
};
#define IPV6_ADDR_LEN (sizeof(struct in6_addr))
struct ipv6_tuple4
{
uint8_t saddr[IPV6_ADDR_LEN] ;
uint8_t daddr[IPV6_ADDR_LEN] ;
uint16_t source; /* network order */
uint16_t dest; /* network order */
enum ip_type {
IP_TYPE_V4,
IP_TYPE_V6
};
struct maat_scan_state;
int maat_scan_ipv4(struct maat_feather *feather, int table_id, struct maat_scan_state *state,
const struct ipv4_tuple4 *tuple4, unsigned int *matched_ids, size_t n_match_id);
struct ip_data {
enum ip_type type;
union {
uint32_t ipv4;
uint32_t ipv6[4];
};
};
struct maat_options;
struct maat_options* maat_options_new(void);
int maat_options_set_worker_thread_number(struct maat_options *opts, size_t nr_worker_threads);
struct maat *maat_new(struct maat_options options, const char* table_info_path);
void maat_free(struct maat *instance);
int maat_table_get_id(struct maat *instance, const char *table_name);
struct maat_state;
int maat_scan_integer(struct maat *instance, int table_id, int thread_id,
unsigned int intval, int results[], size_t *n_result,
struct maat_state *state);
int maat_scan_ip(struct maat *instance, int table_id, int thread_id,
const struct ip_data *ip, int results[], size_t *n_result,
struct maat_state *state);
int maat_scan_string(struct maat *instance, int table_id, int thread_id,
const char *data, size_t data_len, int results[], size_t *n_result,
struct maat_state *state);
struct maat_stream;
struct maat_stream *maat_scan_stream_open(struct maat *instance, int table_id, int thread_id);
int maat_scan_stream(struct maat_stream **stream, int thread_id, const char* data, int data_len,
int results[], size_t *n_result, struct maat_state *state);
void maat_scan_stream_close(struct maat_stream **stream);
void maat_state_reset(struct maat_state *state);
int maat_scan_string(struct maat_feather *feather, int table_id, struct maat_scan_state *state,
const char *data, size_t length);
#ifdef __cpluscplus
}
#endif