]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
chan_sip: Reject calls without prior SDP on 200 OK
authorJonathan Rose <jrose@digium.com>
Wed, 11 Sep 2013 19:46:39 +0000 (19:46 +0000)
committerJonathan Rose <jrose@digium.com>
Wed, 11 Sep 2013 19:46:39 +0000 (19:46 +0000)
If we receive a 200 OK without SDP, we will now check to see if
the remote address has been established for that channel's RTP
session and if the to tag for that channel has changed from
the most recent to tag in a response less than 200.
If either a change has been made since the last to-tag was
received or the remote address is unset, then we will drop
the call.

(closes issue ASTERISK-22424)
Reported by: Jonathan Rose
Review: https://reviewboard.asterisk.org/r/2827/diff/#index_header
........

Merged revisions 398835 from http://svn.asterisk.org/svn/asterisk/branches/1.8

git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/11@398836 65c4cc65-6c06-0410-ace0-fbb531ad65f3

channels/chan_sip.c
channels/sip/include/sip.h

index db48ca1d8369c440b12718d1c678536c295e51ab..ee8c9c38ffb0dfeb8b58832ccaa1772b33c9f26a 100644 (file)
@@ -22788,6 +22788,15 @@ static void handle_response_invite(struct sip_pvt *p, int resp, const char *rest
                                        ast_set_flag(&p->flags[0], SIP_PENDINGBYE);
                                }
                        ast_rtp_instance_activate(p->rtp);
+               } else if (!reinvite) {
+                       struct ast_sockaddr remote_address = {{0,}};
+
+                       ast_rtp_instance_get_remote_address(p->rtp, &remote_address);
+                       if (ast_sockaddr_isnull(&remote_address) || (!ast_strlen_zero(p->theirprovtag) && strcmp(p->theirtag, p->theirprovtag))) {
+                               ast_log(LOG_WARNING, "Received response: \"200 OK\" from '%s' without SDP\n", p->relatedpeer->name);
+                               ast_set_flag(&p->flags[0], SIP_PENDINGBYE);
+                               ast_rtp_instance_activate(p->rtp);
+                       }
                }
 
                if (!req->ignore && p->owner) {
@@ -23710,7 +23719,11 @@ static void handle_response(struct sip_pvt *p, int resp, const char *rest, struc
 
                gettag(req, "To", tag, sizeof(tag));
                ast_string_field_set(p, theirtag, tag);
+       } else {
+               /* Store theirtag to track for changes when 200 responses to invites are received without SDP */
+               ast_string_field_set(p, theirprovtag, p->theirtag);
        }
+
        /* This needs to be configurable on a channel/peer level,
           not mandatory for all communication. Sadly enough, NAT implementations
           are not so stable so we can always rely on these headers.
index 073f5f4d6ad45c871482877f11811b4c6125d090..d8bee122ed486bae4619671e651f571160b1a2a7 100644 (file)
@@ -1038,6 +1038,7 @@ struct sip_pvt {
                AST_STRING_FIELD(rdnis);        /*!< Referring DNIS */
                AST_STRING_FIELD(redircause);   /*!< Referring cause */
                AST_STRING_FIELD(theirtag);     /*!< Their tag */
+               AST_STRING_FIELD(theirprovtag); /*!< Provisional their tag, used when evaluating responses to invites */
                AST_STRING_FIELD(tag);          /*!< Our tag for this session */
                AST_STRING_FIELD(username);     /*!< [user] name */
                AST_STRING_FIELD(peername);     /*!< [peer] name, not set if [user] */