sp_cmd_generic_try_from_packet return struct directly
This commit is contained in:
parent
389ced492c
commit
c9d2479f5e
3 changed files with 24 additions and 8 deletions
|
@ -5,6 +5,7 @@
|
|||
#include <stdlib.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include "servicepoint.h"
|
||||
|
||||
#define DEFAULT_LISTEN_IP "127.0.0.1"
|
||||
|
@ -63,14 +64,22 @@ int main(int argc, char **argv) {
|
|||
}
|
||||
|
||||
struct Header *header = sp_packet_get_header(packet);
|
||||
done = header->command_code == COMMAND_CODE_HARD_RESET;
|
||||
|
||||
ByteSlice payload = sp_packet_get_payload(packet);
|
||||
printf("Received packet: cc=%d, a=%d, b=%d, c=%d, d=%d, payload=%p (len %zu)\n",
|
||||
header->command_code, header->a, header->b, header->c, header->d,
|
||||
payload.start, payload.length);
|
||||
|
||||
done = header->command_code == COMMAND_CODE_HARD_RESET;
|
||||
sp_packet_free(packet);
|
||||
struct Command command = sp_cmd_generic_try_from_packet(packet);
|
||||
if (command.tag == COMMAND_TAG_INVALID) {
|
||||
printf("received invalid command\n");
|
||||
continue;
|
||||
}
|
||||
|
||||
sp_cmd_generic_free(command);
|
||||
}
|
||||
|
||||
close(udp_socket);
|
||||
exit(EXIT_SUCCESS);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue