Skip to content

Commit

Permalink
Merge pull request #24 from FREEWING-JP/feature/fix_obex_web_request_…
Browse files Browse the repository at this point in the history
…final_ok_packet

add OBEX EndOfBody in Final OK packet for fix assert of unused headers
  • Loading branch information
peterfoot committed Apr 14, 2018
2 parents ff86461 + 427037a commit a3cb8b3
Showing 1 changed file with 24 additions and 3 deletions.
27 changes: 24 additions & 3 deletions InTheHand.Net.Personal/Net/ObexWebRequest.cs
Expand Up @@ -831,9 +831,30 @@ private bool CheckResponse(ref ObexStatusCode status, bool isConnectResponse)
if (len > 0) {
byte[] receivePacket2 = new byte[len];
StreamReadBlockMust(ns, receivePacket2, 0, len);
if (len == 5 && ((ObexHeader)receivePacket2[0] == ObexHeader.ConnectionID)) {
// ignore ConnectionId
} else {
bool validObexHeader = false;
if ((ObexHeader)receivePacket2[0] == ObexHeader.ConnectionID) {
if (len == 5) {
// ignore ConnectionId
validObexHeader = true;
} else
if (len >= 8 && ((ObexHeader)receivePacket2[5] == ObexHeader.EndOfBody)) {
// End of Body Header
short eobLen = (short)(IPAddress.NetworkToHostOrder(BitConverter.ToInt16(receivePacket2, 6)));
Debug.Assert(len >= 3, "not got eobLen!");

// ex. len = 8, eobLen = 3
if (eobLen != (len - 5)) {
// receive packet length and End-of-Body length are mismatch
Debug.Fail("invalid packet length...");
// return false;
}

// ignore ConnectionId and EndOfBody
validObexHeader = true;
}
}

if (!validObexHeader) {
Debug.Fail("unused headers...");
}
}
Expand Down

0 comments on commit a3cb8b3

Please sign in to comment.