diff options
author | Olle Johansson <oej@edvina.net> | 2009-09-07 14:54:14 +0000 |
---|---|---|
committer | Olle Johansson <oej@edvina.net> | 2009-09-07 14:54:14 +0000 |
commit | 5afc513ae33d8528b021a369991b71e3e91163c8 (patch) | |
tree | fb41ca0d17424760a89e4c0869eca81d91b25e90 | |
parent | 008b7a4ab88eded1022c6745af807b22876cff39 (diff) |
Don't send MESSAGE with sendtext() if recepient doesn't allow MESSAGE requests
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@216769 65c4cc65-6c06-0410-ace0-fbb531ad65f3
-rw-r--r-- | channels/chan_sip.c | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/channels/chan_sip.c b/channels/chan_sip.c index abcfe9180..b9ee38130 100644 --- a/channels/chan_sip.c +++ b/channels/chan_sip.c @@ -2437,6 +2437,7 @@ static void check_pendings(struct sip_pvt *p); static void *sip_park_thread(void *stuff); static int sip_park(struct ast_channel *chan1, struct ast_channel *chan2, struct sip_request *req, int seqno); static int sip_sipredirect(struct sip_pvt *p, const char *dest); +static int is_method_allowed(unsigned int *allowed_methods, enum sipmethod method); /*--- Codec handling / SDP */ static void try_suggested_sip_codec(struct sip_pvt *p); @@ -4491,20 +4492,22 @@ static const char *sip_get_callid(struct ast_channel *chan) Called from PBX core sendtext() application */ static int sip_sendtext(struct ast_channel *ast, const char *text) { - struct sip_pvt *p = ast->tech_pvt; - int debug = sip_debug_test_pvt(p); + struct sip_pvt *dialog = ast->tech_pvt; + int debug = sip_debug_test_pvt(dialog); - if (debug) - ast_verbose("Sending text %s on %s\n", text, ast->name); - if (!p) + if (!dialog) return -1; /* NOT ast_strlen_zero, because a zero-length message is specifically * allowed by RFC 3428 (See section 10, Examples) */ if (!text) return 0; + if(!is_method_allowed(&dialog->allowed_methods, SIP_MESSAGE)) { + ast_debug(2, "Trying to send MESSAGE to device that does not support it.\n"); + return(0); + } if (debug) - ast_verbose("Really sending text %s on %s\n", text, ast->name); - transmit_message_with_text(p, text); + ast_verbose("Sending text %s on %s\n", text, ast->name); + transmit_message_with_text(dialog, text); return 0; } @@ -7724,6 +7727,7 @@ static void mark_method_unallowed(unsigned int *allowed_methods, enum sipmethod (*allowed_methods) &= ~(1 << method); } +/*! \brief Check if method is allowed for a device or a dialog */ static int is_method_allowed(unsigned int *allowed_methods, enum sipmethod method) { return ((*allowed_methods) >> method) & 1; |