diff --git a/ethermess-backend.c b/ethermess-backend.c index d9547c3..baba23b 100644 --- a/ethermess-backend.c +++ b/ethermess-backend.c @@ -28,6 +28,7 @@ #define EM_RETRANSMIT_TIME (1000 + random_byte() * 2) #define EM_MAX_RETRANSMIT 5 +// Version 0 #define EMT_SPEAK_VERSION 0 #define EMT_STATUS_REQUEST 1 #define EMT_STATUS 2 @@ -272,7 +273,7 @@ void send_frame(const unsigned char *frame, size_t frame_length) { } } -void write_headers(unsigned char frame[14], const unsigned char destination_mac[6], unsigned char packet_type) { +void write_headers(unsigned char frame[14], const unsigned char destination_mac[6], unsigned char version, unsigned char packet_type) { // Destination MAC memcpy(&frame[0], destination_mac, 6); @@ -284,7 +285,7 @@ void write_headers(unsigned char frame[14], const unsigned char destination_mac[ frame[13] = 0x7a; // Ethermess version - frame[14] = EM_PROTOCOL_VERSION; + frame[14] = version; // Ethermess packet type frame[15] = packet_type; @@ -293,7 +294,7 @@ void write_headers(unsigned char frame[14], const unsigned char destination_mac[ void send_speak_version(const unsigned char destination[6]) { unsigned char frame[14 + 2 + 1]; - write_headers(frame, destination, EMT_SPEAK_VERSION); + write_headers(frame, destination, 0, EMT_SPEAK_VERSION); // Version to speak frame[16] = EM_PROTOCOL_VERSION; @@ -304,7 +305,7 @@ void send_speak_version(const unsigned char destination[6]) { void send_status_request(const unsigned char destination[6]) { unsigned char frame[14 + 2]; - write_headers(frame, destination, EMT_STATUS_REQUEST); + write_headers(frame, destination, 0, EMT_STATUS_REQUEST); send_frame(frame, sizeof(frame)); } @@ -312,7 +313,7 @@ void send_status_request(const unsigned char destination[6]) { void send_status(const unsigned char destination[6]) { unsigned char frame[14 + 2 + 1 + 1 + own_nick_length]; - write_headers(frame, destination, EMT_STATUS); + write_headers(frame, destination, 0, EMT_STATUS); // Status frame[16] = own_status; @@ -329,7 +330,7 @@ void send_status(const unsigned char destination[6]) { void send_msgid_request(const unsigned char destination[6]) { unsigned char frame[14 + 2]; - write_headers(frame, destination, EMT_MSGID_REQUEST); + write_headers(frame, destination, 0, EMT_MSGID_REQUEST); send_frame(frame, sizeof(frame)); } @@ -337,7 +338,7 @@ void send_msgid_request(const unsigned char destination[6]) { void send_msgid(const unsigned char destination[6]) { unsigned char frame[14 + 2 + 2]; - write_headers(frame, destination, EMT_MSGID); + write_headers(frame, destination, 0, EMT_MSGID); // Look up destination in the ID cache ssize_t cache_index = msgid_cache_lookup(destination); @@ -366,7 +367,7 @@ void send_msgid(const unsigned char destination[6]) { void send_message(void) { unsigned char frame[14 + 2 + 2 + 2 + own_message_length]; - write_headers(frame, own_message_destination_mac, EMT_MESSAGE); + write_headers(frame, own_message_destination_mac, 0, EMT_MESSAGE); // Message ID frame[16] = own_message_msgid >> 8; @@ -385,7 +386,7 @@ void send_message(void) { void send_ack(const unsigned char destination[6], uint16_t msgid) { unsigned char frame[14 + 2 + 2]; - write_headers(frame, destination, EMT_ACK); + write_headers(frame, destination, 0, EMT_ACK); // Message ID frame[16] = msgid >> 8;