This repository has been archived on 2025-09-14. You can view files and clone it, but cannot push or open issues or pull requests.
Files
stellar-stellar/include/stellar/packet.h

53 lines
1.7 KiB
C
Raw Normal View History

#pragma once
2024-04-21 11:30:41 +08:00
#ifdef __cplusplus
extern "C"
{
#endif
#include <stdint.h>
#define MAX_SIDS 8
struct sids
{
uint16_t sid[MAX_SIDS];
int used;
};
void packet_prepend_sids(struct packet *pkt, const struct sids *sids);
enum packet_direction
{
PACKET_DIRECTION_OUTGOING = 0, // Internal -> External: 0
PACKET_DIRECTION_INCOMING = 1, // External -> Internal: 1
};
enum packet_direction packet_get_direction(const struct packet *pkt);
enum packet_action
{
PACKET_ACTION_FORWARD = 0,
PACKET_ACTION_DROP = 1,
};
void packet_set_action(struct packet *pkt, enum packet_action action);
enum packet_action packet_get_action(const struct packet *pkt);
const char *packet_get_raw_data(const struct packet *pkt);
uint16_t packet_get_raw_len(const struct packet *pkt);
2024-04-11 19:44:02 +08:00
const char *packet_get_payload(const struct packet *pkt);
uint16_t packet_get_payload_len(const struct packet *pkt);
/*
* tcp_seq: the sequence number of the new TCP packet (in host byte order)
* tcp_ack: the acknowledgment number of the new TCP packet (in host byte order)
* tcp_options_len: the length of the options (must be a multiple of 4)
*/
struct packet *craft_tcp_packet(const struct packet *origin_pkt, uint32_t tcp_seq, uint32_t tcp_ack, uint8_t tcp_flags,
const char *tcp_options, uint16_t tcp_options_len,
const char *tcp_payload, uint16_t tcp_payload_len);
struct packet *craft_udp_packet(const struct packet *origin_pkt, const char *udp_payload, uint16_t udp_payload_len);
2024-06-28 16:08:40 +08:00
struct packet *craft_packet_from_scratch(const struct layer larers[], uint16_t layer_count, const char *payload, uint16_t payload_len);
2024-06-27 15:07:54 +08:00
2024-04-21 11:30:41 +08:00
#ifdef __cplusplus
}
#endif