diff options
author | Robby Zambito <contact@robbyzambito.me> | 2025-04-23 07:26:39 -0400 |
---|---|---|
committer | Robby Zambito <contact@robbyzambito.me> | 2025-04-23 07:26:41 -0400 |
commit | 89bfbe485454ee87712364fab05024cec305aad4 (patch) | |
tree | d8c063d2e6c697108ede31a64199bc14151aa8ce /include/zaprus.h | |
parent | fe26cb002db4b7bd9a53265690aba19a54ebe50f (diff) |
successfully build c interface
Diffstat (limited to 'include/zaprus.h')
-rw-r--r-- | include/zaprus.h | 38 |
1 files changed, 32 insertions, 6 deletions
diff --git a/include/zaprus.h b/include/zaprus.h index 31fe97c..b442753 100644 --- a/include/zaprus.h +++ b/include/zaprus.h @@ -1,24 +1,50 @@ // client +#include<stdint.h> +#include<stdlib.h> + int zaprus_init(void); int zaprus_deinit(void); -int zaprus_send_relay(const char* payload, usize len, char[4] dest); +int zaprus_send_relay(const char* payload, size_t len, char dest[4]); -int zaprus_send_initial_connection(const char* payload, usize len, uint16_t initial_port); +int zaprus_send_initial_connection(const char* payload, size_t len, uint16_t initial_port); -struct SaprusMessage* zaprus_connect(const char* payload, usize len); +struct SaprusMessage* zaprus_connect(const char* payload, size_t len); // message +#define SAPRUS_RELAY_MESSAGE_TYPE 0x003C +#define SAPRUS_FILE_TRANSFER_MESSAGE_TYPE 0x8888 +#define SAPRUS_CONNECTION_MESSAGE_TYPE 0x00E9 + struct SaprusMessage { - + uint16_t packet_type; + union { + struct { + struct { + char dest[4]; + }; + char *payload; + } relay; + struct { + struct { + uint16_t src_port; + uint16_t dest_port; + uint32_t seq_num; + uint32_t msg_id; + char _reserved; + char options; + }; + char *payload; + } connection; + }; }; // ptr should be freed by the caller. -int zaprus_message_to_bytes(struct SaprusMessage msg, char** ptr, usize* len); +int zaprus_message_to_bytes(struct SaprusMessage msg, char** ptr, size_t* len); // Return value should be destroyed with zaprus_message_deinit. -struct SaprusMessage* zaprus_message_from_bytes(const char* bytes, usize len); +struct SaprusMessage* zaprus_message_from_bytes(const char* bytes, size_t len); void zaprus_message_deinit(struct SaprusMessage* msg); |