more packet version refactoring

This commit is contained in:
Stephen Birarda 2013-07-08 15:14:18 -07:00
parent b482f479b6
commit aaaba9c42e
2 changed files with 9 additions and 2 deletions

View file

@ -2891,7 +2891,7 @@ void* Application::networkReceive(void* args) {
app->_packetCount++;
app->_bytesCount += bytesReceived;
if (app->_incomingPacket[1] == versionForPacketType(app->_incomingPacket[0])) {
if (packetVersionMatch(app->_incomingPacket)) {
// only process this packet if we have a match on the packet version
switch (app->_incomingPacket[0]) {
case PACKET_TYPE_TRANSMITTER_DATA_V2:

View file

@ -6,6 +6,8 @@
// Copyright (c) 2013 HighFidelity, Inc. All rights reserved.
//
#include <stdio.h>
#include "PacketHeaders.h"
PACKET_VERSION versionForPacketType(PACKET_TYPE type) {
@ -19,7 +21,12 @@ PACKET_VERSION versionForPacketType(PACKET_TYPE type) {
bool packetVersionMatch(unsigned char* packetHeader) {
// currently this just checks if the version in the packet matches our return from versionForPacketType
// may need to be expanded in the future for types and versions that take > than 1 byte
return packetHeader[1] == versionForPacketType(packetHeader[0]);
if (packetHeader[1] == versionForPacketType(packetHeader[0])) {
return true;
} else {
printf("There is a packet version mismatch for packet with header %c\n", packetHeader[0]);
return false;
}
}
int populateTypeAndVersion(unsigned char* destinationHeader, PACKET_TYPE type) {