]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
res_pjsip: Add ActionID to events created as a result of PJSIP AMI actions
authorMatthew Jordan <mjordan@digium.com>
Fri, 27 Jun 2014 13:48:12 +0000 (13:48 +0000)
committerMatthew Jordan <mjordan@digium.com>
Fri, 27 Jun 2014 13:48:12 +0000 (13:48 +0000)
A number of various PJSIP AMI actions were failing to parse out and place the
ActionID into their responses. This patch updates the various PJSIP actions
such that the passed in ActionID is emitted on any event list complete events,
as well as any intermediate events created as a result of the action.

ASTERISK-23947 #close
Reported by: Mark Michelson

Review: https://reviewboard.asterisk.org/r/3675/

git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/12@417460 65c4cc65-6c06-0410-ace0-fbb531ad65f3

include/asterisk/res_pjsip.h
res/res_pjsip/pjsip_configuration.c
res/res_pjsip_outbound_registration.c
res/res_pjsip_pubsub.c
res/res_pjsip_registrar.c

index b5a00837dc625ed85358a9621e5ddb5b830c4d3c..6d6c001622675d9d8efbc15387f039a44001f6c0 100644 (file)
@@ -1722,6 +1722,8 @@ struct ast_sip_ami {
        struct mansession *s;
        /*! Manager message */
        const struct message *m;
+       /*! Manager Action ID */
+       const char *action_id;
        /*! user specified argument data */
        void *arg;
 };
index ee22ad8a47881ddb733e615f1fd0c454b074c19d..9b5cfcb62b79ee95c8419f79a6f3b29e5f23446b 100644 (file)
@@ -1029,6 +1029,9 @@ struct ast_str *ast_sip_create_ami_event(const char *event, struct ast_sip_ami *
        }
 
        ast_str_set(&buf, 0, "Event: %s\r\n", event);
+       if (!ast_strlen_zero(ami->action_id)) {
+               ast_str_append(&buf, 0, "ActionID: %s\r\n", ami->action_id);
+       }
        return buf;
 }
 
@@ -1109,7 +1112,7 @@ static int format_ami_endpoint(const struct ast_sip_endpoint *endpoint,
 
 static int ami_show_endpoint(struct mansession *s, const struct message *m)
 {
-       struct ast_sip_ami ami = { .s = s, .m = m };
+       struct ast_sip_ami ami = { .s = s, .m = m, .action_id = astman_get_header(m, "ActionID"), };
        RAII_VAR(struct ast_sip_endpoint *, endpoint, NULL, ao2_cleanup);
        const char *endpoint_name = astman_get_header(m, "Endpoint");
        int count = 0;
@@ -1141,9 +1144,11 @@ static int ami_show_endpoint(struct mansession *s, const struct message *m)
                        endpoint_name);
        }
 
-       astman_append(s,
-                     "Event: EndpointDetailComplete\r\n"
-                     "EventList: Complete\r\n"
+       astman_append(s, "Event: EndpointDetailComplete\r\n");
+       if (!ast_strlen_zero(ami.action_id)) {
+               astman_append(s, "ActionID: %s\r\n", ami.action_id);
+       }
+       astman_append(s, "EventList: Complete\r\n"
                      "ListItems: %d\r\n\r\n", count + 1);
        return 0;
 }
@@ -1202,7 +1207,7 @@ static int format_ami_endpoints(void *obj, void *arg, int flags)
 
 static int ami_show_endpoints(struct mansession *s, const struct message *m)
 {
-       struct ast_sip_ami ami = { .s = s, .m = m };
+       struct ast_sip_ami ami = { .s = s, .m = m, .action_id = astman_get_header(m, "ActionID"), };
        RAII_VAR(struct ao2_container *, endpoints, NULL, ao2_cleanup);
        int num;
 
@@ -1221,9 +1226,11 @@ static int ami_show_endpoints(struct mansession *s, const struct message *m)
 
        ao2_callback(endpoints, OBJ_NODATA, format_ami_endpoints, &ami);
 
-       astman_append(s,
-                     "Event: EndpointListComplete\r\n"
-                     "EventList: Complete\r\n"
+       astman_append(s, "Event: EndpointListComplete\r\n");
+       if (!ast_strlen_zero(ami.action_id)) {
+               astman_append(s, "ActionID: %s\r\n", ami.action_id);
+       }
+       astman_append(s, "EventList: Complete\r\n"
                      "ListItems: %d\r\n\r\n", num);
        return 0;
 }
index 09750ef8096f6209cf80ddb3def8063af5de21e3..ccd50557901fa9a94126ff15cc77c81f4f05d88e 100644 (file)
@@ -1104,7 +1104,7 @@ static int ami_outbound_registration_detail(void *obj, void *arg, int flags)
 static int ami_show_outbound_registrations(struct mansession *s,
                                           const struct message *m)
 {
-       struct ast_sip_ami ami = { .s = s, .m = m };
+       struct ast_sip_ami ami = { .s = s, .m = m, .action_id = astman_get_header(m, "ActionID"), };
        struct sip_ami_outbound ami_outbound = { .ami = &ami };
        RAII_VAR(struct ao2_container *, regs, ast_sorcery_retrieve_by_fields(
                         ast_sip_get_sorcery(), "registration", AST_RETRIEVE_FLAG_MULTIPLE |
@@ -1121,9 +1121,11 @@ static int ami_show_outbound_registrations(struct mansession *s,
 
        ao2_callback(regs, OBJ_NODATA, ami_outbound_registration_detail, &ami_outbound);
 
-       astman_append(s,
-                     "Event: OutboundRegistrationDetailComplete\r\n"
-                     "EventList: Complete\r\n"
+       astman_append(s, "Event: OutboundRegistrationDetailComplete\r\n");
+       if (!ast_strlen_zero(ami.action_id)) {
+               astman_append(s, "ActionID: %s\r\n", ami.action_id);
+       }
+       astman_append(s, "EventList: Complete\r\n"
                      "Registered: %d\r\n"
                      "NotRegistered: %d\r\n\r\n",
                      ami_outbound.registered,
@@ -1261,7 +1263,7 @@ static int load_module(void)
        sip_outbound_registration_perform_all();
 
        ast_manager_register_xml("PJSIPUnregister", EVENT_FLAG_SYSTEM | EVENT_FLAG_REPORTING, ami_unregister);
-       ast_manager_register_xml("PJSIPShowRegistrationsOutbound", EVENT_FLAG_SYSTEM | EVENT_FLAG_REPORTING,ami_show_outbound_registrations);
+       ast_manager_register_xml("PJSIPShowRegistrationsOutbound", EVENT_FLAG_SYSTEM | EVENT_FLAG_REPORTING, ami_show_outbound_registrations);
 
        cli_formatter = ao2_alloc(sizeof(struct ast_sip_cli_formatter_entry), NULL);
        if (!cli_formatter) {
index dfca643bc17d315e6e46330dc76b9e5c633a3f9a..be97991baa94a7b80b6b0e7cdc1175b69c7e40a9 100644 (file)
@@ -1775,7 +1775,7 @@ static int ami_subscription_detail_outbound(struct ast_sip_subscription *sub, vo
 
 static int ami_show_subscriptions_inbound(struct mansession *s, const struct message *m)
 {
-       struct ast_sip_ami ami = { .s = s, .m = m };
+       struct ast_sip_ami ami = { .s = s, .m = m, .action_id = astman_get_header(m, "ActionID"), };
        int num;
 
        astman_send_listack(s, m, "Following are Events for "
@@ -1783,16 +1783,18 @@ static int ami_show_subscriptions_inbound(struct mansession *s, const struct mes
 
        num = for_each_subscription(ami_subscription_detail_inbound, &ami);
 
-       astman_append(s,
-                     "Event: InboundSubscriptionDetailComplete\r\n"
-                     "EventList: Complete\r\n"
+       astman_append(s, "Event: InboundSubscriptionDetailComplete\r\n");
+       if (!ast_strlen_zero(ami.action_id)) {
+               astman_append(s, "ActionID: %s\r\n", ami.action_id);
+       }
+       astman_append(s, "EventList: Complete\r\n"
                      "ListItems: %d\r\n\r\n", num);
        return 0;
 }
 
 static int ami_show_subscriptions_outbound(struct mansession *s, const struct message *m)
 {
-       struct ast_sip_ami ami = { .s = s, .m = m };
+       struct ast_sip_ami ami = { .s = s, .m = m, .action_id = astman_get_header(m, "ActionID"), };
        int num;
 
        astman_send_listack(s, m, "Following are Events for "
@@ -1800,9 +1802,11 @@ static int ami_show_subscriptions_outbound(struct mansession *s, const struct me
 
        num = for_each_subscription(ami_subscription_detail_outbound, &ami);
 
-       astman_append(s,
-                     "Event: OutboundSubscriptionDetailComplete\r\n"
-                     "EventList: Complete\r\n"
+       astman_append(s, "Event: OutboundSubscriptionDetailComplete\r\n");
+       if (!ast_strlen_zero(ami.action_id)) {
+               astman_append(s, "ActionID: %s\r\n", ami.action_id);
+       }
+       astman_append(s, "EventList: Complete\r\n"
                      "ListItems: %d\r\n\r\n", num);
        return 0;
 }
index 962895b6086593400a8e7b3603f3f9d4f823143e..f7d082c18db1e156f50505d1b830656217ed3483 100644 (file)
@@ -765,15 +765,17 @@ static int ami_registrations_endpoints(void *arg)
 static int ami_show_registrations(struct mansession *s, const struct message *m)
 {
        int count = 0;
-       struct ast_sip_ami ami = { .s = s, .m = m, .arg = &count };
+       struct ast_sip_ami ami = { .s = s, .m = m, .arg = &count, .action_id = astman_get_header(m, "ActionID"), };
        astman_send_listack(s, m, "Following are Events for each Inbound "
                            "registration", "start");
 
        ami_registrations_endpoints(&ami);
 
-       astman_append(s,
-                     "Event: InboundRegistrationDetailComplete\r\n"
-                     "EventList: Complete\r\n"
+       astman_append(s, "Event: InboundRegistrationDetailComplete\r\n");
+       if (!ast_strlen_zero(ami.action_id)) {
+               astman_append(s, "ActionID: %s\r\n", ami.action_id);
+       }
+       astman_append(s, "EventList: Complete\r\n"
                      "ListItems: %d\r\n\r\n", count);
        return 0;
 }