Permalink
Browse files

Merge pull request #24 from FREEWING-JP/feature/fix_obex_web_request_…

…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 a3cb8b3e995de2ad25edd6aab2d42dd04e0840ce
Showing with 24 additions and 3 deletions.
  1. +24 −3 InTheHand.Net.Personal/Net/ObexWebRequest.cs
@@ -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...");
}
}

0 comments on commit a3cb8b3

Please sign in to comment.