diff -Naur bristuff-0.4.0-test6/asterisk/channels/chan_sip.c asterisk-1.4.17/channels/chan_sip.c
--- bristuff-0.4.0-test6/asterisk/channels/chan_sip.c 2008-04-29 17:13:23.000000000 +0200
+++ asterisk-1.4.17/channels/chan_sip.c 2008-04-06 17:51:14.000000000 +0200
@@ -288,7 +288,8 @@
DIALOG_INFO_XML,
CPIM_PIDF_XML,
PIDF_XML,
- MWI_NOTIFICATION
+ MWI_NOTIFICATION,
+ DIALOG_RLMI_XML
};
static const struct cfsubscription_types {
@@ -303,7 +304,8 @@
{ CPIM_PIDF_XML, "presence", "application/cpim-pidf+xml", "cpim-pidf+xml" }, /* RFC 3863 */
{ PIDF_XML, "presence", "application/pidf+xml", "pidf+xml" }, /* RFC 3863 */
{ XPIDF_XML, "presence", "application/xpidf+xml", "xpidf+xml" }, /* Pre-RFC 3863 with MS additions */
- { MWI_NOTIFICATION, "message-summary", "application/simple-message-summary", "mwi" } /* RFC 3842: Mailbox notification */
+ { MWI_NOTIFICATION, "message-summary", "application/simple-message-summary", "mwi" }, /* RFC 3842: Mailbox notification */
+ { DIALOG_RLMI_XML, "dialog", "multipart/related;boundary=UniqueAsteriskRLMIBoundary;type=application/rlmi+xml", "application/rlmi+xml" } /* RFC 4662 */
};
/*! \brief SIP Request methods known by Asterisk */
@@ -455,7 +457,7 @@
/* RFC3329: Security agreement mechanism */
{ SIP_OPT_SEC_AGREE, NOT_SUPPORTED, "sec_agree" },
/* SIMPLE events: RFC4662 */
- { SIP_OPT_EVENTLIST, NOT_SUPPORTED, "eventlist" },
+ { SIP_OPT_EVENTLIST, SUPPORTED, "eventlist" },
/* GRUU: Globally Routable User Agent URI's */
{ SIP_OPT_GRUU, NOT_SUPPORTED, "gruu" },
/* RFC4538: Target-dialog */
@@ -898,6 +900,33 @@
enum referstatus status; /*!< REFER status */
};
+struct sip_evcalls {
+ int stateid; /*!< SUBSCRIBE: ID for devicestate subscriptions */
+ int laststate; /*!< SUBSCRIBE: Last known extension state */
+ int dialogver; /*!< SUBSCRIBE: Version for subscription dialog-info */
+ AST_DECLARE_STRING_FIELDS(
+ AST_STRING_FIELD(exten); /*!< Exten to watch */
+ AST_STRING_FIELD(name); /*!< Name of user to program */
+ AST_STRING_FIELD(uri); /*!< Original requested URI */
+ AST_STRING_FIELD(contentid); /*!< Dialogue Content ID */
+ );
+ AST_LIST_ENTRY(sip_evcalls) list; /*!< List mechanics*/
+};
+
+AST_LIST_HEAD_STATIC(calllist, sip_evcalls); /*!< List of calls */
+
+struct sip_eventlist {
+ ast_mutex_t lock; /*!< Dialog private lock */
+ AST_DECLARE_STRING_FIELDS(
+ AST_STRING_FIELD(exten); /*!< Extension to notify */
+ AST_STRING_FIELD(supported); /*!< Supported formats */
+ AST_STRING_FIELD(uri); /*!< Supported formats */
+ );
+ unsigned long version; /*! <Version number as per RFC4662 */
+ struct calllist calls;
+};
+
+
/*! \brief sip_pvt: PVT structures are used for each SIP dialog, ie. a call, a registration, a subscribe */
static struct sip_pvt {
ast_mutex_t lock; /*!< Dialog private lock */
@@ -1013,6 +1042,7 @@
struct ast_variable *chanvars; /*!< Channel variables to set for inbound call */
struct sip_pvt *next; /*!< Next dialog in chain */
struct sip_invite_param *options; /*!< Options for INVITE */
+ struct sip_eventlist *eventlist; /*!< Is this a member of a subscription list and if so deal with it correctly */
int autoframing;
} *iflist = NULL;
@@ -1477,7 +1507,7 @@
static int get_destination(struct sip_pvt *p, struct sip_request *oreq);
static int get_msg_text(char *buf, int len, struct sip_request *req);
static void free_old_route(struct sip_route *route);
-static int transmit_state_notify(struct sip_pvt *p, int state, int full, int timeout);
+static int transmit_state_notify(struct sip_pvt *p, int state, int full, int timeout, char *cid_num, char *cid_name);
/*--- Constructing requests and responses */
static void initialize_initreq(struct sip_pvt *p, struct sip_request *req);
@@ -2064,7 +2094,8 @@
/* If this is a subscription, tell the phone that we got a timeout */
if (p->subscribed) {
- transmit_state_notify(p, AST_EXTENSION_DEACTIVATED, 1, TRUE); /* Send last notification */
+ //transmit_state_notify(p, AST_EXTENSION_DEACTIVATED, 1, TRUE); /* Send last notification */
+ transmit_state_notify(p, AST_EXTENSION_DEACTIVATED, 1, TRUE, NULL, NULL); /* Send last notification */
p->subscribed = NONE;
append_history(p, "Subscribestatus", "timeout");
if (option_debug > 2)
@@ -3140,6 +3171,14 @@
ast_variables_destroy(p->chanvars);
p->chanvars = NULL;
}
+ if (p->eventlist) {
+ struct sip_evcalls *evsub = NULL;
+ AST_LIST_LOCK(&p->eventlist->calls);
+ while ((evsub = AST_LIST_REMOVE_HEAD(&p->eventlist->calls, list)))
+ free(evsub);
+ AST_LIST_UNLOCK(&p->eventlist->calls);
+ free(p->eventlist);
+ }
ast_mutex_destroy(&p->lock);
ast_string_field_free_memory(p);
@@ -3168,6 +3207,7 @@
int outgoing = ast_test_flag(&fup->flags[1], SIP_PAGE2_OUTGOING_CALL);
struct sip_user *u = NULL;
struct sip_peer *p = NULL;
+ struct ast_channel *chan;
if (option_debug > 2)
ast_log(LOG_DEBUG, "Updating call counter for %s call\n", outgoing ? "outgoing" : "incoming");
@@ -3267,7 +3307,15 @@
ast_log(LOG_ERROR, "update_call_counter(%s, %d) called with no event!\n", name, event);
}
if (p) {
- ast_device_state_changed("SIP/%s", p->name);
+ //ast_device_state_changed("SIP/%s", p->name);
+ chan = fup->owner;
+ if (!chan)
+ ast_device_state_changed("SIP/%s", p->name);
+ else {
+ if (option_debug > 0)
+ ast_log(LOG_DEBUG, "State of SIP/%s changed - Caller: %s <%s>\n", p->name, chan->cid.cid_name, chan->cid.cid_num);
+ ast_device_state_changed_with_callerid("SIP/%s", chan->cid.cid_num, chan->cid.cid_name, p->name);
+ }
ASTOBJ_UNREF(p, sip_destroy_peer);
} else /* u must be set */
ASTOBJ_UNREF(u, sip_destroy_user);
@@ -5832,6 +5880,14 @@
char contact[BUFSIZ];
snprintf(contact, sizeof(contact), "%s;expires=%d", p->our_contact, p->expiry);
add_header(resp, "Contact", contact); /* Not when we unregister */
+ if (!p->sipoptions) {
+ const char *supported = get_header(req, "Supported");
+ if (!ast_strlen_zero(supported)) {
+ parse_sip_options(p, supported);
+ if (p->sipoptions == SIP_OPT_EVENTLIST)
+ add_header(resp, "Require", "eventlist"); /* Require Eventlist */
+ }
+ }
}
} else if (msg[0] != '4' && !ast_strlen_zero(p->our_contact)) {
add_header(resp, "Contact", p->our_contact);
@@ -7091,9 +7147,10 @@
}
/*! \brief Used in the SUBSCRIBE notification subsystem */
-static int transmit_state_notify(struct sip_pvt *p, int state, int full, int timeout)
+//static int transmit_state_notify(struct sip_pvt *p, int state, int full, int timeout)
+static int transmit_state_notify(struct sip_pvt *p, int state, int full, int timeout, char *cid_num, char *cid_name)
{
- char tmp[4000], from[256], to[256];
+ char tmp[16000], from[256], to[256];
char *t = tmp, *c, *mfrom, *mto;
size_t maxbytes = sizeof(tmp);
struct sip_request req;
@@ -7103,6 +7160,10 @@
enum state { NOTIFY_OPEN, NOTIFY_INUSE, NOTIFY_CLOSED } local_state = NOTIFY_OPEN;
char *pidfstate = "--";
char *pidfnote= "Ready";
+ struct sip_eventlist *evl=p->eventlist;
+
+ if (!cid_num || ast_strlen_zero(cid_num )) cid_num = "unknown";
+ if (!cid_name || ast_strlen_zero(cid_name)) cid_name = "unknown";
memset(from, 0, sizeof(from));
memset(to, 0, sizeof(to));
@@ -7134,7 +7195,8 @@
pidfnote = "On the phone";
break;
case AST_EXTENSION_UNAVAILABLE:
- statestring = "terminated";
+ //statestring = "terminated";
+ statestring = "confirmed";
local_state = NOTIFY_CLOSED;
pidfstate = "away";
pidfnote = "Unavailable";
@@ -7150,7 +7212,8 @@
/* Default setting */
break;
}
-
+ ast_log(LOG_WARNING, "Statstring of %d is %s\n", state, statestring);
+ ast_verbose("Statstring of %d is %s\n", state, statestring );
subscriptiontype = find_subscription_type(p->subscribed);
/* Check which device/devices we are watching and if they are registered */
@@ -7209,14 +7272,142 @@
add_header(&req, "Subscription-State", "terminated;reason=noresource");
break;
default:
- if (p->expiry)
+ if ((p->expiry) || (p->eventlist))
add_header(&req, "Subscription-State", "active");
else /* Expired */
add_header(&req, "Subscription-State", "terminated;reason=timeout");
}
switch (p->subscribed) {
- case XPIDF_XML:
+ case DIALOG_RLMI_XML: /* RFC 4662 */
+ if (!evl)
+ break;
+
+ struct sip_evcalls *newcall = NULL;
+
+ add_header(&req, "Require", "eventlist");
+
+ struct ast_config *blflist_config = ast_load_realtime_multientry("blflist", "exten LIKE", "%", "peer", p->exten, NULL);
+ const char *blfpeer=NULL;
+ if (!blflist_config) {
+ ast_log(LOG_ERROR, "no blflist defined in your config (extconfig.conf).\n");
+ } else {
+ const char *blfexten;
+ char slist[4000],diapart[4000],dialist[4000];
+ char *lst = slist, *dp = diapart, *dl = dialist;
+ size_t listbytes = sizeof(slist), dpbytes = sizeof(diapart), dlbytes = sizeof(dialist);
+
+ ast_build_string(&lst, &listbytes, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
+ ast_build_string(&lst, &listbytes, "<list xmlns=\"urn:ietf:params:xml:ns:rlmi\" uri=\"%s\" version=\"%ld\" fullState=\"true\">\n",mto,evl->version++);
+ while ((blfpeer = ast_category_browse(blflist_config, blfpeer))) {
+ blfexten=ast_variable_retrieve(blflist_config, blfpeer, "exten");
+
+ AST_LIST_LOCK(&evl->calls);
+ AST_LIST_TRAVERSE_SAFE_BEGIN(&evl->calls, newcall, list) {
+ if ((newcall) && (!strcasecmp(newcall->exten, blfexten)))
+ break;
+ }
+ AST_LIST_TRAVERSE_SAFE_END
+
+ if (!newcall) {
+ newcall=ast_calloc(1,sizeof(struct sip_evcalls));
+ ast_string_field_init(newcall, 512);
+ ast_string_field_set(newcall, exten, blfexten);
+ ast_string_field_build(newcall, uri, "%s@%s", blfexten, p->fromdomain);
+ ast_string_field_set(newcall, name, ast_variable_retrieve(blflist_config, blfpeer, "name"));
+ AST_LIST_INSERT_TAIL(&evl->calls, newcall, list);
+ newcall->stateid = ast_extension_state_add(p->context, newcall->exten, cb_extensionstate, p);
+ }
+
+ ast_string_field_build(newcall, contentid, "%08lx", ast_random());
+
+
+ if (!strcasecmp(evl->exten,blfexten)) {
+ ast_log(LOG_WARNING,"Found target exten for update %s set state info/delete\n",evl->exten);
+ newcall->laststate=state;
+ }
+ switch (newcall->laststate) {
+ case (AST_EXTENSION_RINGING | AST_EXTENSION_INUSE):
+ statestring = (global_notifyringing) ? "early" : "confirmed";
+ local_state = NOTIFY_INUSE;
+ pidfstate = "busy";
+ pidfnote = "Ringing";
+ break;
+ case AST_EXTENSION_RINGING:
+ statestring = "early";
+ local_state = NOTIFY_INUSE;
+ pidfstate = "busy";
+ pidfnote = "Ringing";
+ break;
+ case AST_EXTENSION_INUSE:
+ statestring = "confirmed";
+ local_state = NOTIFY_INUSE;
+ pidfstate = "busy";
+ pidfnote = "On the phone";
+ break;
+ case AST_EXTENSION_BUSY:
+ statestring = "confirmed";
+ local_state = NOTIFY_CLOSED;
+ pidfstate = "busy";
+ pidfnote = "On the phone";
+ break;
+ case AST_EXTENSION_UNAVAILABLE:
+ statestring = "terminated";
+ local_state = NOTIFY_CLOSED;
+ pidfstate = "away";
+ pidfnote = "Unavailable";
+ break;
+ case AST_EXTENSION_ONHOLD:
+ statestring = "confirmed";
+ local_state = NOTIFY_INUSE;
+ pidfstate = "busy";
+ pidfnote = "On Hold";
+ break;
+ case AST_EXTENSION_NOT_INUSE:
+ default:
+ statestring = "terminated";
+ local_state = NOTIFY_OPEN;
+ pidfstate = "--";
+ pidfnote= "Ready";
+ /* Default setting */
+ break;
+ }
+
+ ast_build_string(&lst, &listbytes, "<resource uri=\"sip:%s\"><name>%s</name>",newcall->uri,newcall->name);
+ ast_build_string(&lst, &listbytes, "<instance id=\"%08lx\" state=\"active\" cid=\"%s\"/></resource>\n",ast_random(),newcall->contentid);
+
+ ast_build_string(&dp, &dpbytes, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
+ ast_build_string(&dp, &dpbytes, "<dialog-info xmlns=\"urn:ietf:params:xml:ns:dialog-info\" version=\"%d\" state=\"%s\" entity=\"%s\">", newcall->dialogver++, full ? "full":"partial", newcall->uri);
+ ast_build_string(&dp, &dpbytes, "<dialog id=\"%s\">", newcall->exten);
+ ast_build_string(&dp, &dpbytes, "<state>%s</state><local>", statestring);
+ if (state == AST_EXTENSION_ONHOLD) {
+ ast_build_string(&dp, &dpbytes, "<target uri=\"sip:%s\"><param pname=\"+sip.rendering\" pvalue=\"no\"></target>", newcall->uri);
+ }
+ ast_build_string(&dp, &dpbytes, "<identity display=\"%s\">sip:%s</identity>",newcall->name,newcall->uri);
+ ast_build_string(&dp, &dpbytes, "</local></dialog></dialog-info>\n");
+
+ ast_build_string(&dl, &dlbytes, "Content-Type:application/dialog-info+xml\n");
+ ast_build_string(&dl, &dlbytes, "Content-Length:%i\n",strlen(diapart));
+ ast_build_string(&dl, &dlbytes, "Content-ID:<%s>\n\n",newcall->contentid);
+ ast_build_string(&dl, &dlbytes, diapart);
+ ast_build_string(&dl, &dlbytes, "--UniqueAsteriskRLMIBoundary\n");
+ dp=diapart;
+ dpbytes=sizeof(diapart);
+
+ AST_LIST_UNLOCK(&evl->calls);
+ }
+ ast_build_string(&lst, &listbytes, "</list>\n");
+
+ ast_build_string(&t, &maxbytes, "--UniqueAsteriskRLMIBoundary\n");
+ ast_build_string(&t, &maxbytes, "Content-Type:application/rlmi+xml\n");
+ ast_build_string(&t, &maxbytes, "Content-Length:%i\n",strlen(slist));
+ ast_build_string(&t, &maxbytes, "Content-ID:<%08lx>\n\n",ast_random());
+ ast_build_string(&t, &maxbytes, slist);
+ ast_build_string(&t, &maxbytes, "--UniqueAsteriskRLMIBoundary\n");
+ ast_build_string(&t, &maxbytes, dialist);
+ }
+ break;
case CPIM_PIDF_XML:
+ case XPIDF_XML:
ast_build_string(&t, &maxbytes, "<?xml version=\"1.0\"?>\n");
ast_build_string(&t, &maxbytes, "<!DOCTYPE presence PUBLIC \"-//IETF//DTD RFCxxxx XPIDF 1.0//EN\" \"xpidf.dtd\">\n");
ast_build_string(&t, &maxbytes, "<presence>\n");
@@ -7224,12 +7415,20 @@
ast_build_string(&t, &maxbytes, "<atom id=\"%s\">\n", p->exten);
ast_build_string(&t, &maxbytes, "<address uri=\"%s;user=ip\" priority=\"0.800000\">\n", mto);
ast_build_string(&t, &maxbytes, "<status status=\"%s\" />\n", (local_state == NOTIFY_OPEN) ? "open" : (local_state == NOTIFY_INUSE) ? "inuse" : "closed");
- ast_build_string(&t, &maxbytes, "<msnsubstatus substatus=\"%s\" />\n", (local_state == NOTIFY_OPEN) ? "online" : (local_state == NOTIFY_INUSE) ? "onthephone" : "offline");
+ //ast_build_string(&t, &maxbytes, "<msnsubstatus substatus=\"%s\" />\n", (local_state == NOTIFY_OPEN) ? "online" : (local_state == NOTIFY_INUSE) ? "onthephone" : "offline");
+ if (p->subscribed == XPIDF_XML) { /* MS additions */
+ ast_build_string(&t, &maxbytes, "<msnsubstatus substatus=\"%s\" />\n", (local_state == NOTIFY_OPEN) ? "online" : (local_state == NOTIFY_INUSE) ? "onthephone" : "offline");
+ }
ast_build_string(&t, &maxbytes, "</address>\n</atom>\n</presence>\n");
break;
case PIDF_XML: /* Eyebeam supports this format */
ast_build_string(&t, &maxbytes, "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n");
- ast_build_string(&t, &maxbytes, "<presence xmlns=\"urn:ietf:params:xml:ns:pidf\" \nxmlns:pp=\"urn:ietf:params:xml:ns:pidf:person\"\nxmlns:es=\"urn:ietf:params:xml:ns:pidf:rpid:status:rpid-status\"\nxmlns:ep=\"urn:ietf:params:xml:ns:pidf:rpid:rpid-person\"\nentity=\"%s\">\n", mfrom);
+ //ast_build_string(&t, &maxbytes, "<presence xmlns=\"urn:ietf:params:xml:ns:pidf\" \nxmlns:pp=\"urn:ietf:params:xml:ns:pidf:person\"\nxmlns:es=\"urn:ietf:params:xml:ns:pidf:rpid:status:rpid-status\"\nxmlns:ep=\"urn:ietf:params:xml:ns:pidf:rpid:rpid-person\"\nentity=\"%s\">\n", mfrom);
+ ast_build_string(&t, &maxbytes, "<presence xmlns=\"urn:ietf:params:xml:ns:pidf\"\n"
+ "xmlns:pp=\"urn:ietf:params:xml:ns:pidf:person\"\n"
+ "xmlns:es=\"urn:ietf:params:xml:ns:pidf:rpid:status:rpid-status\"\n"
+ "xmlns:ep=\"urn:ietf:params:xml:ns:pidf:rpid:rpid-person\"\n"
+ "entity=\"%s\">\n", mfrom);
ast_build_string(&t, &maxbytes, "<pp:person><status>\n");
if (pidfstate[0] != '-')
ast_build_string(&t, &maxbytes, "<ep:activities><ep:%s/></ep:activities>\n", pidfstate);
@@ -7246,16 +7445,19 @@
case DIALOG_INFO_XML: /* SNOM subscribes in this format */
ast_build_string(&t, &maxbytes, "<?xml version=\"1.0\"?>\n");
ast_build_string(&t, &maxbytes, "<dialog-info xmlns=\"urn:ietf:params:xml:ns:dialog-info\" version=\"%d\" state=\"%s\" entity=\"%s\">\n", p->dialogver++, full ? "full":"partial", mto);
- if ((state & AST_EXTENSION_RINGING) && global_notifyringing)
+ if ((state & AST_EXTENSION_RINGING) && global_notifyringing){
ast_build_string(&t, &maxbytes, "<dialog id=\"%s\" direction=\"recipient\">\n", p->exten);
- else
+ ast_build_string(&t, &maxbytes, "<local><identity display=\"%s\">%s</identity><target uri=\"%s\"/></local>\n", p->exten, mto, mto);
+ ast_build_string(&t, &maxbytes, "<remote><identity display=\"%s\">%s</identity><target uri=\"sip:%s%s@%s\"/></remote>\n", cid_name, cid_num, ast_pickup_ext(), p->exten, p->fromdomain);
+ } else if (state == AST_EXTENSION_ONHOLD) {
ast_build_string(&t, &maxbytes, "<dialog id=\"%s\">\n", p->exten);
- ast_build_string(&t, &maxbytes, "<state>%s</state>\n", statestring);
- if (state == AST_EXTENSION_ONHOLD) {
ast_build_string(&t, &maxbytes, "<local>\n<target uri=\"%s\">\n"
"<param pname=\"+sip.rendering\" pvalue=\"no\">\n"
"</target>\n</local>\n", mto);
+ } else {
+ ast_build_string(&t, &maxbytes, "<dialog id=\"%s\">\n", p->exten);
}
+ ast_build_string(&t, &maxbytes, "<state>%s</state>\n", statestring);
ast_build_string(&t, &maxbytes, "</dialog>\n</dialog-info>\n");
break;
case NONE:
@@ -8465,6 +8667,17 @@
ast_mutex_lock(&p->lock);
+ if ((p->eventlist) && (p->subscribed != NONE)) {
+ ast_mutex_lock(&p->eventlist->lock);
+ ast_string_field_set(p->eventlist, exten, exten);
+ transmit_state_notify(p, state, 1, FALSE, cid_num, cid_name);
+ ast_mutex_unlock(&p->eventlist->lock);
+ if (option_verbose > 1)
+ ast_verbose(VERBOSE_PREFIX_1 "Extension Changed %s new state %s for Notify User %s\n", exten, ast_extension_state2str(state), p->username);
+ ast_mutex_unlock(&p->lock);
+ return 0;
+ }
+
switch(state) {
case AST_EXTENSION_DEACTIVATED: /* Retry after a while */
case AST_EXTENSION_REMOVED: /* Extension is gone */
@@ -8481,7 +8694,7 @@
break;
}
if (p->subscribed != NONE) /* Only send state NOTIFY if we know the format */
- transmit_state_notify(p, state, 1, FALSE);
+ transmit_state_notify(p, state, 1, FALSE, cid_num, cid_name);
if (option_verbose > 1)
ast_verbose(VERBOSE_PREFIX_1 "Extension Changed %s new state %s for Notify User %s\n", exten, ast_extension_state2str(state), p->username);
@@ -10711,6 +10924,8 @@
struct sip_pvt *cur;
int numchans = 0;
char *referstatus = NULL;
+ struct sip_eventlist *evl;
+ struct sip_evcalls *newcall;
if (argc != 3)
return RESULT_SHOWUSAGE;
@@ -10721,6 +10936,7 @@
else
ast_cli(fd, FORMAT3, "Peer", "User", "Call ID", "Extension", "Last state", "Type", "Mailbox");
for (; cur; cur = cur->next) {
+ evl = cur->eventlist;
referstatus = "";
if (cur->refer) { /* SIP transfer in progress */
referstatus = referstatus2str(cur->refer->status);
@@ -10740,16 +10956,45 @@
numchans++;
}
if (cur->subscribed != NONE && subscriptions) {
- ast_cli(fd, FORMAT3, ast_inet_ntoa(cur->sa.sin_addr),
- S_OR(cur->username, S_OR(cur->cid_num, "(None)")),
- cur->callid,
- /* the 'complete' exten/context is hidden in the refer_to field for subscriptions */
- cur->subscribed == MWI_NOTIFICATION ? "--" : cur->subscribeuri,
- cur->subscribed == MWI_NOTIFICATION ? "<none>" : ast_extension_state2str(cur->laststate),
- subscription_type2str(cur->subscribed),
- cur->subscribed == MWI_NOTIFICATION ? (cur->relatedpeer ? cur->relatedpeer->mailbox : "<none>") : "<none>"
-);
+// ast_cli(fd, FORMAT3, ast_inet_ntoa(cur->sa.sin_addr),
+// S_OR(cur->username, S_OR(cur->cid_num, "(None)")),
+// cur->callid,
+// /* the 'complete' exten/context is hidden in the refer_to field for subscriptions */
+// cur->subscribed == MWI_NOTIFICATION ? "--" : cur->subscribeuri,
+// cur->subscribed == MWI_NOTIFICATION ? "<none>" : ast_extension_state2str(cur->laststate),
+// subscription_type2str(cur->subscribed),
+// cur->subscribed == MWI_NOTIFICATION ? (cur->relatedpeer ? cur->relatedpeer->mailbox : "<none>") : "<none>"
+// );
numchans++;
+ if (! evl) {
+ ast_cli(fd, FORMAT3, ast_inet_ntoa(cur->sa.sin_addr),
+ S_OR(cur->username, S_OR(cur->cid_num, "(None)")),
+ cur->callid,
+ /* the 'complete' exten/context is hidden in the refer_to field for subscriptions */
+ cur->subscribed == MWI_NOTIFICATION ? "--" : cur->subscribeuri,
+ cur->subscribed == MWI_NOTIFICATION ? "<none>" : ast_extension_state2str(cur->laststate),
+ subscription_type2str(cur->subscribed),
+ cur->subscribed == MWI_NOTIFICATION ? (cur->relatedpeer ? cur->relatedpeer->mailbox : "<none>") : "<none>");
+ numchans++;
+ } else {
+ ast_mutex_lock(&evl->lock);
+ AST_LIST_LOCK(&evl->calls);
+ AST_LIST_TRAVERSE(&evl->calls, newcall, list) {
+ if (newcall) {
+ ast_cli(fd, FORMAT3, ast_inet_ntoa(cur->sa.sin_addr),
+ S_OR(cur->username, S_OR(cur->cid_num, "(None)")),
+ cur->callid,
+ /* the 'complete' exten/context is hidden in the refer_to field for subscriptions */
+ cur->subscribed == MWI_NOTIFICATION ? "--" : newcall->exten,
+ cur->subscribed == MWI_NOTIFICATION ? "<none>" : ast_extension_state2str(newcall->laststate),
+ subscription_type2str(cur->subscribed),
+ cur->subscribed == MWI_NOTIFICATION ? (cur->relatedpeer ? cur->relatedpeer->mailbox : "<none>") : "<none>");
+ numchans++;
+ }
+ }
+ AST_LIST_UNLOCK(&evl->calls);
+ ast_mutex_unlock(&evl->lock);
+ }
}
}
ast_mutex_unlock(&iflock);
@@ -14852,7 +15097,17 @@
/* Polycom phones only handle xpidf+xml, even if they say they can
handle pidf+xml as well
*/
- if (strstr(p->useragent, "Polycom")) {
+ if (strstr(accept, "application/rlmi+xml")) {
+ if (!p->eventlist) {
+ p->eventlist=ast_calloc(1,sizeof(struct sip_eventlist));
+ ast_mutex_init(&p->eventlist->lock);
+ p->eventlist->version=0;
+ ast_string_field_init(p->eventlist,512);
+ AST_LIST_HEAD_INIT(&p->eventlist->calls);
+ ast_string_field_set(p->eventlist, supported, accept);
+ }
+ p->subscribed = DIALOG_RLMI_XML;
+ } else if (strstr(p->useragent, "Polycom")) {
p->subscribed = XPIDF_XML;
} else if (strstr(accept, "application/pidf+xml")) {
p->subscribed = PIDF_XML; /* RFC 3863 format */
@@ -14965,7 +15220,6 @@
struct sip_pvt *p_old;
if ((firststate = ast_extension_state(NULL, p->context, p->exten)) < 0) {
-
ast_log(LOG_NOTICE, "Got SUBSCRIBE for extension %s@%s from %s, but there is no hint for that extension.\n", p->exten, p->context, ast_inet_ntoa(p->sa.sin_addr));
transmit_response(p, "404 Not found", req);
ast_set_flag(&p->flags[0], SIP_NEEDDESTROY);
@@ -14973,7 +15227,7 @@
}
transmit_response(p, "200 OK", req);
- transmit_state_notify(p, firststate, 1, FALSE); /* Send first notification */
+ transmit_state_notify(p, firststate, 1, FALSE, NULL, NULL); /* Send first notification */
append_history(p, "Subscribestatus", "%s", ast_extension_state2str(firststate));
/* hide the 'complete' exten/context in the refer_to field for later display */
ast_string_field_build(p, subscribeuri, "%s@%s", p->exten, p->context);