完成流特征统计插件

This commit is contained in:
崔一鸣
2019-12-06 19:47:13 +08:00
parent 0ee4877328
commit b66d14ce67
18 changed files with 5843 additions and 9028 deletions

View File

@@ -0,0 +1,44 @@
#pragma once
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <errno.h>
#include <unistd.h>
#include <inttypes.h>
#include <arpa/inet.h>
#include <netinet/ip6.h>
#include <net/if.h>
#include <string.h>
#include <pthread.h>
#include "MESA/MESA_handle_logger.h"
#ifndef MAX
#define MAX(a, b) (((a) > (b)) ? (a) : (b))
#endif
#ifndef MIN
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
#endif
#define STRING_MAX 128
#define likely(expr) __builtin_expect((expr), 1)
#define unlikely(expr) __builtin_expect((expr), 0)
#define ALLOC(type, number) ((type *)calloc(sizeof(type), number))
#define FREE(p) {free(*p);*p=NULL;}
#define LOG_ERROR(handler, fmt, ...) \
do { \
MESA_handle_runtime_log(handler, RLOG_LV_FATAL, "kni", fmt, ##__VA_ARGS__); } while(0)
#define LOG_INFO(handler, fmt, ...) \
do { \
MESA_handle_runtime_log(handler, RLOG_LV_INFO, "kni", fmt, ##__VA_ARGS__); } while(0)
#define LOG_DEBUG(handler, fmt, ...) \
do { \
MESA_handle_runtime_log(handler, RLOG_LV_DEBUG, "kni", fmt, ##__VA_ARGS__); } while(0)

View File

@@ -0,0 +1,50 @@
#pragma once
#define EXTENSION_COUNT_MAX 128
#define CIPHER_SUITE_COUNT_MAX 256
struct cipher_suite
{
uint16_t value;
const char* name;
};
struct tls_extension{
int value;
const char* name;
};
enum chello_parse_result
{
CHELLO_PARSE_SUCCESS = 0,
CHELLO_PARSE_INVALID_FORMAT = -1,
CHELLO_PARSE_NOT_ENOUGH_BUFF = -2
};
struct ssl_version
{
uint8_t minor;
uint8_t major;
uint16_t ossl_format;
char str_format[STRING_MAX];
};
struct ssl_chello
{
struct ssl_version min_version;
struct ssl_version max_version;
int cipher_suites_count;
int extension_count;
int cipher_suite_list[CIPHER_SUITE_COUNT_MAX];
int extension_list[EXTENSION_COUNT_MAX];
char sni[STRING_MAX];
char alpn[STRING_MAX];
};
struct ssl_version_map{
int value;
const char *name;
};
void ssl_chello_parse(struct ssl_chello* _chello, const unsigned char* buff, size_t buff_len, enum chello_parse_result* result);
void ssl_chello_free(struct ssl_chello* chello);