From: Russell Bryant Date: Thu, 13 Jan 2005 03:00:02 +0000 (+0000) Subject: Send "405 Method Not Allowed" if a message is received outside of a call (bug #3324) X-Git-Tag: 1.0.11.1~279 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fbc3e2e3cedd31ab4a3c7e87aaca1913c2de657f;p=thirdparty%2Fasterisk.git Send "405 Method Not Allowed" if a message is received outside of a call (bug #3324) git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/v1-0@4772 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- diff --git a/channels/chan_sip.c b/channels/chan_sip.c index 7b541471ec..184af347d3 100755 --- a/channels/chan_sip.c +++ b/channels/chan_sip.c @@ -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 */