]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Send "405 Method Not Allowed" if a message is received outside of a call (bug #3324)
authorRussell Bryant <russell@russellbryant.com>
Thu, 13 Jan 2005 03:00:02 +0000 (03:00 +0000)
committerRussell Bryant <russell@russellbryant.com>
Thu, 13 Jan 2005 03:00:02 +0000 (03:00 +0000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/v1-0@4772 65c4cc65-6c06-0410-ace0-fbb531ad65f3

channels/chan_sip.c

index 7b541471ec3208ccef7206acd877284497124816..184af347d35c56af08136aa22d5f0ed2ba5ea079 100755 (executable)
@@ -7510,12 +7510,17 @@ static int handle_request(struct sip_pvt *p, struct sip_request *req, struct soc
                        p->needdestroy = 1;
                transmit_response(p, "200 OK", req);
        } else if (!strcasecmp(cmd, "MESSAGE")) {
-               if (!ignore) {
-                       if (debug)
-                               ast_verbose("Receiving message!\n");
-                       receive_message(p, req);
+               if (p->lastinvite) {
+                       if (!ignore) {
+                               if (debug)
+                                       ast_verbose("Receiving message!\n");
+                               receive_message(p, req);
+                       }
+                       transmit_response(p, "200 OK", req);
+               } else {
+                       transmit_response(p, "405 Method Not Allowed", req);
+                       p->needdestroy = 1;
                }
-               transmit_response(p, "200 OK", req);
        } else if (!strcasecmp(cmd, "SUBSCRIBE")) {
                if (!ignore) {
                        /* Use this as the basis */