void PacketRecord::determineAppProtocol()
{
if (ipProtocol == IP_PROTO_UDP)
{
std::istringstream ss(udpData);
std::string line;
if (getline(ss, line) && (line.find("SIP/2.0") != std::string::npos))
{
appProtocol = APP_PROTO_SIP;
}
else
{
appProtocol == APP_PROTO_RTP;
}
}
else
{
appProtocol = APP_PROTO_UNKNOWN;
}
}
If the inner if statement fails to evaluate to true, I would expect the else block to be executed (appProtocol set to APP_PROTO_RTP). However, this does not happen. Instead, it seems the else statement is completely ignored. I can't fathom why this is the case.
As you can see from my gdb session, the first time the if statement works and appProtocol is set to APP_PROTO_SIP (as expected). the second time through, the if fails but instead of going into the else and setting appProtocol to APP_PROTO_RTP, it returns out of the function completely without setting appProtocol. appProtocol remains set to APP_PROTO_INVALID (the value it is initialized with in the PacketRecord ctor).
Breakpoint 1, PacketRecord::determineAppProtocol (this=0x805c6c8) at PacketRecord.cpp:156
156 if (ipProtocol == IP_PROTO_UDP)
(gdb) step
158 std::istringstream ss(udpData);
(gdb)
159 std::string line;
(gdb)
160 if (getline(ss, line) && (line.find("SIP/2.0") != std::string::npos))
(gdb)
162 appProtocol = APP_PROTO_SIP;
(gdb)
167 }
(gdb)
173 }
(gdb) continue
Continuing.
Breakpoint 1, PacketRecord::determineAppProtocol (this=0x8065388) at PacketRecord.cpp:156
156 if (ipProtocol == IP_PROTO_UDP)
(gdb) step
158 std::istringstream ss(udpData);
(gdb)
159 std::string line;
(gdb)
160 if (getline(ss, line) && (line.find("SIP/2.0") != std::string::npos))
(gdb)
167 }
(gdb)
173 }
(gdb)