functions for manipulating packets
This commit is contained in:
parent
cf9877ce7b
commit
38633f0b6b
9 changed files with 81 additions and 37 deletions
|
@ -1908,7 +1908,11 @@ Packet *sp_packet_from_parts(Header header,
|
|||
const uint8_t *payload,
|
||||
size_t payload_len);
|
||||
|
||||
Header sp_packet_get_header(const Packet *packet);
|
||||
Header *sp_packet_get_header(Packet *packet);
|
||||
|
||||
SPByteSlice sp_packet_get_payload(Packet *packet);
|
||||
|
||||
void sp_packet_set_payload(Packet *packet, SPByteSlice data);
|
||||
|
||||
/**
|
||||
* Tries to load a [SPPacket] from the passed array with the specified length.
|
||||
|
@ -1931,6 +1935,8 @@ Header sp_packet_get_header(const Packet *packet);
|
|||
Packet *sp_packet_try_load(const uint8_t *data,
|
||||
size_t length);
|
||||
|
||||
void sp_packet_write_to(const Packet *packet, SPByteSlice buffer);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif // __cplusplus
|
||||
|
|
|
@ -16,7 +16,12 @@ int main(void) {
|
|||
if (command == NULL)
|
||||
return 1;
|
||||
|
||||
sp_connection_send_command(connection, command);
|
||||
Packet *packet = sp_packet_from_command(command);
|
||||
|
||||
Header *header = sp_packet_get_header(packet);
|
||||
printf("[%d, %d, %d, %d, %d]\n", header->command_code, header->a, header->b, header->c, header->d);
|
||||
|
||||
sp_connection_send_packet(connection, packet);
|
||||
|
||||
sp_connection_free(connection);
|
||||
return 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue