Does this incoming message want to be processed by this dialog? NOTE: This is temporary until we fully support SipTransactions, in which case this will be used only for in-dialog requests, and in that case both to- and from-tags must match. This may not be correct for group calls - we may want to search each of several possible matching dialogs for the transaction matching the via-branch.
| 1262 | // This may not be correct for group calls - we may want to search each of several possible |
| 1263 | // matching dialogs for the transaction matching the via-branch. |
| 1264 | bool SipBase::matchMessage(SipMessage *msg) |
| 1265 | { |
| 1266 | // The caller already checked the callid, but lets do it again in case someone modifies the code later. |
| 1267 | if (msg->smGetCallId() != this->callId()) { return false; } |
| 1268 | // This code could be simplified by combining logic, but I left it verbose for clarity |
| 1269 | if (msg->isRequest()) { |
| 1270 | // If it is a request sent by the peer, the remote tag must match. Both empty is ok. |
| 1271 | if (msg->smGetRemoteTag() != this->dsRemoteTag()) { return false; } |
| 1272 | // The local tag in the message is either empty (meaning the peer has not received it yet) or matches. |
| 1273 | string msgLocalTag = msg->smGetLocalTag(); |
| 1274 | if (! msgLocalTag.empty()) { |
| 1275 | if (msgLocalTag != this->dsLocalTag()) { return false; } |
| 1276 | } |
| 1277 | } else { |
| 1278 | // If it is a reply, it means the original request was sent by us. The local tags must match. Both empty is ok. |
| 1279 | if (msg->smGetLocalTag() != this->dsLocalTag()) { return false; } |
| 1280 | // The remote tag in the dialog is either empty (has not been set yet, will probably be set by this message), or matches. |
| 1281 | string remoteTag = dsRemoteTag(); |
| 1282 | if (! remoteTag.empty()) { |
| 1283 | if (remoteTag != msg->smGetRemoteTag()) { return false; } |
| 1284 | } |
| 1285 | } |
| 1286 | return true; // Good enough. |
| 1287 | } |
| 1288 | |
| 1289 | |
| 1290 | // 17.2.3 tells how to match requests to server transactions, but that does not apply to this. |
nothing calls this directly
no test coverage detected