Skip to content
Extraits de code Groupes Projets
Valider aef46f82 rédigé par Samuel de Meester de Ravestein's avatar Samuel de Meester de Ravestein
Parcourir les fichiers

it compiles

parent 166153bc
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -7,8 +7,8 @@ HEADERS_DIR = -Iheaders ...@@ -7,8 +7,8 @@ HEADERS_DIR = -Iheaders
LDFLAGS = -lz LDFLAGS = -lz
# Adapt these as you want to fit with your project # Adapt these as you want to fit with your project
SENDER_SOURCES = $(wildcard src/sender.c src/log.c) SENDER_SOURCES = $(wildcard src/sender.c src/log.c src/packet_interface.c)
RECEIVER_SOURCES = $(wildcard src/receiver.c src/log.c) RECEIVER_SOURCES = $(wildcard src/receiver.c src/log.c src/packet_interface.c)
SENDER_OBJECTS = $(SENDER_SOURCES:.c=.o) SENDER_OBJECTS = $(SENDER_SOURCES:.c=.o)
RECEIVER_OBJECTS = $(RECEIVER_SOURCES:.c=.o) RECEIVER_OBJECTS = $(RECEIVER_SOURCES:.c=.o)
......
...@@ -51,14 +51,14 @@ void pkt_del(pkt_t *pkt) ...@@ -51,14 +51,14 @@ void pkt_del(pkt_t *pkt)
* @param len : The number of bytes of the buffer. * @param len : The number of bytes of the buffer.
* @return uint32_t * @return uint32_t
*/ */
uint32_t calculate_crc(char * buffer, uint32_t len) uint32_t calculate_crc(const char * buffer, uint32_t len)
{ {
return (uint32_t) crc32(0, (const void *) buffer, len); return (uint32_t) crc32(0, (const void *) buffer, len);
} }
pkt_status_code pkt_decode_data_fec(const char *data, const size_t len, pkt_t *pkt) pkt_status_code pkt_decode_data_fec(const char *data, const size_t len, pkt_t *pkt)
{ {
return pkt_set_payload(pkt, data, len); // TRASH
} }
pkt_status_code pkt_decode_ack_nack(const char *data, const size_t len, pkt_t *pkt) pkt_status_code pkt_decode_ack_nack(const char *data, const size_t len, pkt_t *pkt)
...@@ -84,8 +84,12 @@ pkt_status_code pkt_decode_ack_nack(const char *data, const size_t len, pkt_t *p ...@@ -84,8 +84,12 @@ pkt_status_code pkt_decode_ack_nack(const char *data, const size_t len, pkt_t *p
// CheckSum no need to set TR at 0 as it should be at 0 // CheckSum no need to set TR at 0 as it should be at 0
char crc[4]; char crc[4];
memcpy(crc, data+4, 4); memcpy(crc, data+4, 4);
if (calculate_crc(data, 4) != ntohl((uint32_t) crc)) if (calculate_crc(data, 4) != ntohl(*((uint32_t *) crc)))
return E_CRC; return E_CRC;
if (predict_header_length(pkt) > 1) return PKT_OK; // TRASH !!
return PKT_OK;
} }
pkt_status_code pkt_decode(const char *data, const size_t len, pkt_t *pkt) pkt_status_code pkt_decode(const char *data, const size_t len, pkt_t *pkt)
...@@ -99,7 +103,7 @@ pkt_status_code pkt_decode(const char *data, const size_t len, pkt_t *pkt) ...@@ -99,7 +103,7 @@ pkt_status_code pkt_decode(const char *data, const size_t len, pkt_t *pkt)
pkt_status_code pkt_encode(const pkt_t* pkt, char *buf, size_t *len) pkt_status_code pkt_encode(const pkt_t* pkt, char *buf, size_t *len)
{ {
/* Your code will be inserted here */ return pkt_set_payload((pkt_t *) pkt, buf, *len); // TRASH
} }
/** GETTER */ /** GETTER */
...@@ -145,7 +149,7 @@ uint32_t pkt_get_crc2(const pkt_t* pkt) ...@@ -145,7 +149,7 @@ uint32_t pkt_get_crc2(const pkt_t* pkt)
const char* pkt_get_payload(const pkt_t* pkt) const char* pkt_get_payload(const pkt_t* pkt)
{ {
return pkt->payload; return (const char *) pkt->payload;
} }
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter