Update Stellar export header and add stellar_get_current_thread_index() function

This commit is contained in:
luwenpeng
2024-04-22 20:01:15 +08:00
parent 8a41a79f06
commit 74f0504d3d
59 changed files with 134 additions and 87 deletions

86
src/packet/packet_priv.h Normal file
View File

@@ -0,0 +1,86 @@
#ifndef _PACKET_PRIV_H
#define _PACKET_PRIV_H
#ifdef __cplusplus
extern "C"
{
#endif
#include <stdint.h>
#include <stdio.h>
#include "log.h"
#include "stellar/tuple.h"
#include "stellar/packet.h"
#define PACKET_MAX_LAYERS 32
#define PACKET_LOG_ERROR(format, ...) LOG_ERROR("packet", format, ##__VA_ARGS__)
#define PACKET_LOG_DEBUG(format, ...) void(0)
//#define PACKET_LOG_DEBUG(format, ...) LOG_DEBUG("packet", format, ##__VA_ARGS__)
enum ldbc_method
{
LDBC_METHOD_HASH_INT_IP = 1,
LDBC_METHOD_HASH_EXT_IP = 2,
LDBC_METHOD_HASH_INT_IP_AND_EXT_IP = 3,
LDBC_METHOD_HASH_INNERMOST_INT_IP = 4,
LDBC_METHOD_HASH_INNERMOST_EXT_IP = 5,
};
enum packet_origin
{
PACKET_ORIGIN_MARSIO = 0x1,
PACKET_ORIGIN_DUMPFILE = 0x2,
PACKET_ORIGIN_USER = 0x3,
};
struct packet
{
struct packet_layer layers[PACKET_MAX_LAYERS];
struct packet_layer *frag_layer; // fragment layer
int8_t layers_used;
int8_t layers_size;
const char *data_ptr;
uint16_t data_len;
int need_drop;
void *io_ctx;
enum packet_origin origin;
};
// return innermost payload
const char *packet_parse(struct packet *pkt, const char *data, uint16_t len);
void packet_print(const struct packet *pkt);
// direction 1: E2I
// direction 0: I2E
uint64_t packet_get_hash(const struct packet *pkt, enum ldbc_method method, int direction);
/******************************************************************************
* Utils
******************************************************************************/
void packet_set_origin(struct packet *pkt, enum packet_origin origin);
enum packet_origin packet_get_origin(const struct packet *pkt);
void packet_set_io_ctx(struct packet *pkt, void *ctx);
void *packet_get_io_ctx(const struct packet *pkt);
int packet_is_fragment(const struct packet *pkt);
struct packet *packet_new(uint16_t pkt_len);
void packet_free(struct packet *pkt);
struct packet *packet_dup(const struct packet *pkt);
void packet_set_domain(struct packet *pkt, uint64_t domain);
uint64_t packet_get_domain(const struct packet *pkt);
void packet_set_route_ctx(struct packet *pkt, const char *route, int len);
int packet_get_route_ctx(const struct packet *pkt, char *buff, int size); // return len of route ctx
#ifdef __cplusplus
}
#endif
#endif