84 lines
1.5 KiB
C
84 lines
1.5 KiB
C
#pragma once
|
|
|
|
#ifdef __cplusplus
|
|
extern "C"
|
|
{
|
|
#endif
|
|
|
|
#include "stellar/layer.h"
|
|
#include "stellar/packet.h"
|
|
|
|
#define PACKET_MAX_LAYERS 32
|
|
|
|
#define MAX_ROUTE_CTX 64
|
|
struct route_ctx
|
|
{
|
|
char data[MAX_ROUTE_CTX];
|
|
int used;
|
|
};
|
|
|
|
struct metadata
|
|
{
|
|
struct route_ctx route_ctx;
|
|
struct sids sids;
|
|
|
|
uint64_t session_id;
|
|
uint64_t domain;
|
|
uint16_t link_id;
|
|
int is_ctrl;
|
|
|
|
enum packet_direction direction;
|
|
enum packet_action action;
|
|
const void *origin_ctx;
|
|
};
|
|
|
|
struct raw_layer
|
|
{
|
|
enum layer_proto proto;
|
|
const char *hdr_ptr; // header pointer
|
|
const char *pld_ptr; // payload pointer
|
|
uint16_t hdr_offset; // header offset from data_ptr
|
|
uint16_t hdr_len; // header length
|
|
uint16_t pld_len; // payload length
|
|
};
|
|
|
|
struct packet
|
|
{
|
|
void * user_data;
|
|
struct raw_layer layers[PACKET_MAX_LAYERS];
|
|
struct raw_layer *frag_layer; // fragment layer
|
|
int8_t layers_used;
|
|
int8_t layers_size;
|
|
int8_t need_free;
|
|
|
|
const char *data_ptr;
|
|
uint16_t data_len;
|
|
uint16_t trim_len; // trim eth padding
|
|
|
|
struct metadata meta;
|
|
};
|
|
|
|
inline void packet_set_route_ctx(struct packet *pkt, const struct route_ctx *ctx)
|
|
{
|
|
pkt->meta.route_ctx = *ctx;
|
|
}
|
|
|
|
inline const struct route_ctx *packet_get_route_ctx(const struct packet *pkt)
|
|
{
|
|
return &pkt->meta.route_ctx;
|
|
}
|
|
|
|
inline void packet_set_origin_ctx(struct packet *pkt, void *ctx)
|
|
{
|
|
pkt->meta.origin_ctx = ctx;
|
|
}
|
|
|
|
inline const void *packet_get_origin_ctx(const struct packet *pkt)
|
|
{
|
|
return pkt->meta.origin_ctx;
|
|
}
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|