functions for manipulating packets
This commit is contained in:
		
							parent
							
								
									6f40441dfe
								
							
						
					
					
						commit
						fed12a4c12
					
				
					 10 changed files with 82 additions and 38 deletions
				
			
		
							
								
								
									
										2
									
								
								examples/lang_c/Cargo.lock
									
										
									
										generated
									
									
									
								
							
							
						
						
									
										2
									
								
								examples/lang_c/Cargo.lock
									
										
									
										generated
									
									
									
								
							| 
						 | 
				
			
			@ -423,7 +423,7 @@ dependencies = [
 | 
			
		|||
[[package]]
 | 
			
		||||
name = "servicepoint"
 | 
			
		||||
version = "0.13.2"
 | 
			
		||||
source = "git+https://git.berlin.ccc.de/servicepoint/servicepoint/?branch=next#aafa2bc9f91c3ae7d88607bf545d9665d50fc0db"
 | 
			
		||||
source = "git+https://git.berlin.ccc.de/servicepoint/servicepoint/?branch=next#971bee5065139f220022e8108cfaa9c263b8a8a0"
 | 
			
		||||
dependencies = [
 | 
			
		||||
 "bitvec",
 | 
			
		||||
 "bzip2",
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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