|
From: Chad M. <cmm...@us...> - 2005-05-16 23:04:40
|
Update of /cvsroot/seq/showeq/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14670/src Modified Files: Tag: pre_5_0_beta packetstream.cpp Log Message: Handle app opcodes less than 00 ff. Previously these were treated as protocol opcodes, causing problems. It turns out when the opcode is 00 00, this seems to be signalling 3 byte opcodes, which are app opcodes where you drop the initial 00, and byte 2 and byte 3 form the app opcode to dispatch. Handle this on OP_Packet, OP_Oversized, OP_AppCombined, and OP_Combined. Probably don't need it on OP_Combined, but it shouldn't hurt anything. Also fixed opcode for OP_DenyResponse (0x3c00). Index: packetstream.cpp =================================================================== RCS file: /cvsroot/seq/showeq/src/packetstream.cpp,v retrieving revision 1.1.6.9 retrieving revision 1.1.6.10 diff -u -d -r1.1.6.9 -r1.1.6.10 --- packetstream.cpp 15 May 2005 16:06:25 -0000 1.1.6.9 +++ packetstream.cpp 16 May 2005 23:04:16 -0000 1.1.6.10 @@ -564,7 +564,25 @@ #endif // Opcode is next. Net opcode or app opcode? - if (IS_NET_OPCODE(subOpCode)) + if (subOpCode == 0) + { + // App opcode < 0x00ff. Skip the first byte and dispatch the app + // opcode appropriately + subpacket++; + + subOpCode = *(uint16_t*)subpacket; + +#if defined(PACKET_PROCESS_DIAG) && (PACKET_PROCESS_DIAG > 2) + seqDebug("EQPacket: processing unrolled special app opcode, length %d bytes from combined packet on stream %s (%d). Opcode %04x", + subpacketLength-3, EQStreamStr[m_streamid], m_streamid, subOpCode); +#endif + + // App opcode. Dispatch it, skipping opcode. + dispatchPacket(&subpacket[2], subpacketLength-2, + subOpCode, m_opcodeDB.find(subOpCode)); + + } + else if (IS_NET_OPCODE(subOpCode)) { #if defined(PACKET_PROCESS_DIAG) && (PACKET_PROCESS_DIAG > 2) seqDebug("EQPacket: processing unrolled net opcode, length %d bytes from combined packet on stream %s (%d). Opcode %04x", @@ -616,6 +634,15 @@ // Dispatch app op code using given packet length. Net order! uint16_t subOpCode = *(uint16_t*)(subpacket); + // Handle 3 byte opcodes properly + if (subOpCode == 0) + { + // 3 byte opcode. Drop the first byte, opcode is byte 2 and 3 + subpacket++; + subpacketLength--; + subOpCode = *(uint16_t*)(subpacket); + } + #if defined(PACKET_PROCESS_DIAG) && (PACKET_PROCESS_DIAG > 2) seqDebug("EQPacket: unrolling length %d bytes from combined packet on stream %s (%d). Opcode %04x", subpacketLength, EQStreamStr[m_streamid], m_streamid, subOpCode); @@ -641,6 +668,15 @@ // OpCode next. Net order for op codes. uint16_t subOpCode = *(uint16_t*)subpacket; + + // Handle 3 byte opcodes properly + if (subOpCode == 0) + { + // 3 byte opcode. Drop the first byte, opcode is byte 2 and 3 + subpacket++; + longOne--; + subOpCode = *(uint16_t*)(subpacket); + } #if defined(PACKET_PROCESS_DIAG) && (PACKET_PROCESS_DIAG > 2) seqDebug("EQPacket: unrolling length %d bytes from combined packet on stream %s (%d). Opcode %04x", @@ -681,8 +717,24 @@ packet.getNetOpCode(), subOpCode); #endif - // App opcode or net opcode? - if (IS_NET_OPCODE(subOpCode)) + // Opcode is next. Net opcode or app opcode? + if (subOpCode == 0) + { + // App opcode < 0x00ff. Skip the first byte and dispatch the app + // opcode appropriately + subOpCode = *(uint16_t*)&packet.payload()[1]; + +#if defined(PACKET_PROCESS_DIAG) && (PACKET_PROCESS_DIAG > 1) + seqDebug("EQPacket: special app opcode extracted for opcode 0000 on stream %s (%d). Opcode %04x", + EQStreamStr[m_streamid], m_streamid, subOpCode); +#endif + + // App opcode. Dispatch it, skipping opcode. + dispatchPacket(&packet.payload()[3], packet.payloadLength()-3, + subOpCode, m_opcodeDB.find(subOpCode)); + + } + else if (IS_NET_OPCODE(subOpCode)) { // Net opcode. false = no copy. true = subpacket. EQProtocolPacket spacket(packet.payload(), @@ -754,8 +806,24 @@ #endif // dispatch fragment. Skip opcode. - dispatchPacket(&m_fragment.data()[2], m_fragment.size()-2, - fragOpCode, m_opcodeDB.find(fragOpCode)); + if (fragOpCode == 0) + { + // Special app opcode. Skip first byte and op is byte 2 and 3. + fragOpCode = *(uint16_t*)(&m_fragment.data()[1]); + +#if defined(PACKET_PROCESS_DIAG) && (PACKET_PROCESS_DIAG > 1) + seqDebug("EQPacket: special app opcode on completed fragment for opcode 0000 on stream %s (%d). Opcode %04x", + EQStreamStr[m_streamid], m_streamid, fragOpCode); +#endif + + dispatchPacket(&m_fragment.data()[3], m_fragment.size()-3, + fragOpCode, m_opcodeDB.find(fragOpCode)); + } + else + { + dispatchPacket(&m_fragment.data()[2], m_fragment.size()-2, + fragOpCode, m_opcodeDB.find(fragOpCode)); + } m_fragment.reset(); } |