summaryrefslogtreecommitdiff
path: root/common/include/tfe_ctrl_packet.h
blob: 9c6fb1424b5ddcbf25bd6676e2c01d43f71497d0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#ifndef _TFE_CTRL_PACKET_H
#define _TFE_CTRL_PACKET_H

#ifdef __cpluscplus
extern "C"
{
#endif

#include <stdint.h>

enum session_state
{
    SESSION_STATE_OPENING = 1,
    SESSION_STATE_CLOSING = 2,
    SESSION_STATE_ACTIVE = 3,
    SESSION_STATE_RESETALL = 4,
};

struct ctrl_pkt_parser
{
    char tsync[4];
    uint64_t session_id;
    enum session_state state;
    char method[32];
    uint64_t tfe_policy_ids[32];
    int tfe_policy_id_num;
    uint64_t sce_policy_ids[32];
    int sce_policy_id_num;
    struct tfe_cmsg *cmsg;

    struct sids seq_sids;
    struct route_ctx seq_route_ctx;
    struct sids ack_sids;
    struct route_ctx ack_route_ctx;
    char *seq_header;
    int seq_len;
    char *ack_header;
    int ack_len;
    // 0x01 is_single
    // 0x02 is_tunnel
    uint8_t intercpet_data;
};

const char *session_state_to_string(enum session_state state);
void ctrl_packet_parser_init(struct ctrl_pkt_parser *handler);

// return  0 : success
// return -1 : error
int ctrl_packet_parser_parse(void *ctx, const char* data, size_t length, void *logger);
void ctrl_packet_parser_dump(struct ctrl_pkt_parser *handler, void *logger);

void ctrl_packet_cmsg_destroy(struct ctrl_pkt_parser *handler);

#ifdef __cpluscplus
}
#endif

#endif