Hi all,
I want to convert a received struct from network byte order to host byte order (may be with ntohs or ntohl functions), but i have a trouble to do so, my code is :
Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
typedef struct packet {
uint8_t pack_type;
uint16_t pack_crc;
uint32_t pack_src;
uint8_t pack_dest[10];
uint8_t pack_data[5];
} packet_t;
packet_t * received_buffer(char *buffer) { // buffer is received from the network
packet_t *result;
result = memcpy(result, buffer, sizeof(result));
/* I want some code here to transforme all my struct from network byte order to host
byte order.
*/
return result;
}
Thanks for your time and your help .