20534c20534 < const char *mailbox = NULL; --- > const char *mailbox = NULL; 20535a20536 > char *context = "SIP_Remote"; 20538c20539,20544 < struct sip_peer *peer = find_peer(NULL, &p->recv, TRUE, FINDPEERS, FALSE, p->socket.type); --- > ast_debug(4, "Unsolicited MWI received from: %s\n", ast_sockaddr_stringify(&p->recv)); > /* note: If you intend to light unsolicited MWI lights on your phones, > they must be in the same context as the unsolicited_mailbox parameter in the format of: > default_box@context */ > > struct sip_peer *peer = find_peer(NULL, &p->recv, TRUE, FINDPEERS, FALSE, p->socket.type); 20541c20547,20595 < mailbox = ast_strdupa(peer->unsolicited_mailbox); --- > char *unsolicited_mailbox = ast_strdupa(peer->unsolicited_mailbox); > > /* If the unsolicited_mailbox parameter has an @ symbol, use that for the context, otherwise leave it at the default of SIP_Remote. */ > char *unsolicited_context = ast_strdupa(peer->unsolicited_mailbox); > if(unsolicited_context) { > unsolicited_context = strchr(unsolicited_context, '@'); > if(unsolicited_context && !ast_strlen_zero(unsolicited_context)) { > unsolicited_context++; > } > if(!ast_strlen_zero(unsolicited_context)) { > context = unsolicited_context; > } > } > > /* RFC3842 (For the Message-Account header) states: > If the Request-URI or To header in a message-summary subscription > corresponds to a group or collection of individual messaging > accounts, the notifier MUST specify to which account the message- > summary body corresponds. > > Therefore, use Message-Account from the body first, and then failback to the To header. > */ > char *specified_extension = ast_strdupa(get_body(req, "Message-Account", ':')); > if(!specified_extension || ast_strlen_zero(specified_extension)) { > specified_extension = ast_strdupa(get_header(req, "To")); > } > > if(!specified_extension || ast_strlen_zero(specified_extension)) { > mailbox = unsolicited_mailbox; /* if they didn't pass one, simply use the unsolicited mailbox */ > } > else > { > /* Get the mailbox from the format: */ > char *specified_mailbox = strchr(specified_extension, '@'); > if (specified_mailbox) { > *specified_mailbox = '\0'; > } > specified_mailbox = strchr(specified_extension, ':'); > if (specified_mailbox && !ast_strlen_zero(specified_mailbox)) { > specified_mailbox++; > > if(specified_mailbox && !ast_strlen_zero(specified_mailbox)) { > mailbox = specified_mailbox; > } > } > } > ast_debug(4, "Unsolicited MWI being delivered to: %s@%s\n", mailbox, context); > > 20543a20598,20600 > else { > ast_debug(2, "Unsolicited MWI received from an unknown peer and wont be routed: %s\n", ast_sockaddr_stringify(&p->recv)); > } 20547a20605 > 20555c20613 < AST_EVENT_IE_CONTEXT, AST_EVENT_IE_PLTYPE_STR, "SIP_Remote", --- > AST_EVENT_IE_CONTEXT, AST_EVENT_IE_PLTYPE_STR, context,