2020-08-03 19:51:58 +02:00
|
|
|
#ifndef TUNNEL_H
|
|
|
|
#define TUNNEL_H
|
|
|
|
#include <stdint.h>
|
2021-11-28 14:02:34 +01:00
|
|
|
#include <netinet/in.h>
|
2023-03-29 12:09:40 +02:00
|
|
|
#include <regex.h>
|
2020-08-03 19:51:58 +02:00
|
|
|
#include "log.h"
|
|
|
|
|
|
|
|
#define MAX_CHANNEL_PATH 108
|
|
|
|
#define MAX_CHANNEL_NAME 64
|
|
|
|
|
2020-11-29 13:27:05 +01:00
|
|
|
#define MSG_MAGIC_BEGIN (uint16_t)0x414e //AN
|
|
|
|
#define MSG_MAGIC_END (uint16_t)0x5444 //TD
|
2020-08-03 19:51:58 +02:00
|
|
|
|
|
|
|
#define CHANNEL_OK (uint8_t)0x0
|
|
|
|
#define CHANNEL_ERROR (uint8_t)0x1
|
|
|
|
#define CHANNEL_OPEN (uint8_t)0x4
|
|
|
|
#define CHANNEL_CLOSE (uint8_t)0x5
|
|
|
|
#define CHANNEL_DATA (uint8_t)0x6
|
2020-08-05 20:10:44 +02:00
|
|
|
#define CHANNEL_UNSUBSCRIBE (uint8_t)0x3
|
|
|
|
#define CHANNEL_SUBSCRIBE (uint8_t)0x2
|
2020-08-06 23:17:46 +02:00
|
|
|
#define CHANNEL_CTRL (uint8_t)0x7
|
2020-08-03 19:51:58 +02:00
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
uint8_t type;
|
2020-11-29 13:27:05 +01:00
|
|
|
uint16_t channel_id;
|
|
|
|
uint16_t client_id;
|
2020-12-28 13:23:30 +01:00
|
|
|
uint32_t size;
|
2020-08-03 19:51:58 +02:00
|
|
|
} tunnel_msg_h_t;
|
|
|
|
|
|
|
|
typedef struct{
|
|
|
|
tunnel_msg_h_t header;
|
|
|
|
uint8_t* data;
|
|
|
|
} tunnel_msg_t;
|
|
|
|
|
2023-03-29 12:09:40 +02:00
|
|
|
int open_socket(char* path);
|
2020-08-03 19:51:58 +02:00
|
|
|
int msg_write(int fd, tunnel_msg_t* msg);
|
|
|
|
int msg_read(int fd, tunnel_msg_t* msg);
|
2023-03-29 12:09:40 +02:00
|
|
|
int regex_match(const char* expr,const char* search, int msize, regmatch_t* matches);
|
2020-08-03 19:51:58 +02:00
|
|
|
|
|
|
|
#endif
|