#pragma once #ifdef __cplusplus extern "C" { #endif #include #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); 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 *imitate_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 *imitate_udp_packet(const struct packet *origin_pkt, const char *udp_payload, uint16_t udp_payload_len); struct packet *craft_packet_from_scratch(const struct layer larers[], uint16_t layer_count, const char *payload, uint16_t payload_len); #ifdef __cplusplus } #endif