]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
[mod_smpp] Fix use of switch_event_add_header_string with SWITCH_STACK_NODUP. 1857/head
authorAndrey Volk <andywolk@gmail.com>
Mon, 7 Nov 2022 21:43:17 +0000 (00:43 +0300)
committerAndrey Volk <andywolk@gmail.com>
Mon, 7 Nov 2022 21:43:17 +0000 (00:43 +0300)
src/mod/event_handlers/mod_smpp/mod_smpp_message.c

index a7407102bca62da9c4690076fc72fbaf0e034cd9..33b2f0ba52433b0fbee6a5efb04321138d2238e7 100644 (file)
@@ -121,46 +121,24 @@ switch_status_t mod_smpp_message_create(mod_smpp_gateway_t *gateway, switch_even
 switch_status_t mod_smpp_message_decode(mod_smpp_gateway_t *gateway, deliver_sm_t *res, switch_event_t **event)
 {
        switch_event_t *evt = NULL;
-       char *str = NULL;
 
        if (switch_event_create(&evt, SWITCH_EVENT_MESSAGE) != SWITCH_STATUS_SUCCESS) {
                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to create new event\n");
        }
 
        switch_event_add_header_string(evt, SWITCH_STACK_BOTTOM, "endpoint", "mod_smpp");
-
-       str = switch_mprintf("%d", res->sequence_number);
-       switch_event_add_header_string(evt, SWITCH_STACK_BOTTOM | SWITCH_STACK_NODUP, "sequence_number", str);
-
-       str = switch_mprintf("%d", res->command_status);
-       switch_event_add_header_string(evt, SWITCH_STACK_BOTTOM | SWITCH_STACK_NODUP, "command_status", str);
-
-       str = switch_mprintf("%d", res->command_id);
-       switch_event_add_header_string(evt, SWITCH_STACK_BOTTOM | SWITCH_STACK_NODUP, "command_id", str);
-
+       switch_event_add_header(evt, SWITCH_STACK_BOTTOM, "sequence_number", "%d", res->sequence_number);
+       switch_event_add_header(evt, SWITCH_STACK_BOTTOM, "command_status", "%d", res->command_status);
+       switch_event_add_header(evt, SWITCH_STACK_BOTTOM, "command_id", "%d", res->command_id);
        switch_event_add_header_string(evt, SWITCH_STACK_BOTTOM, "smpp_gateway", gateway->name);
        switch_event_add_header_string(evt, SWITCH_STACK_BOTTOM, "proto", "smpp");
-
-       str = switch_mprintf("%d", res->source_addr_ton);
-       switch_event_add_header_string(evt, SWITCH_STACK_BOTTOM | SWITCH_STACK_NODUP, "source_addr_ton", str);
-
-       str = switch_mprintf("%d", res->source_addr_npi);
-       switch_event_add_header_string(evt, SWITCH_STACK_BOTTOM | SWITCH_STACK_NODUP, "source_addr_npi", str);
-
+       switch_event_add_header(evt, SWITCH_STACK_BOTTOM, "source_addr_ton", "%d", res->source_addr_ton);
+       switch_event_add_header(evt, SWITCH_STACK_BOTTOM, "source_addr_npi", "%d", res->source_addr_npi);
        switch_event_add_header_string(evt, SWITCH_STACK_BOTTOM, "from_user", (const char *) res->source_addr);
-
-       str = switch_mprintf("%d", res->dest_addr_ton);
-       switch_event_add_header_string(evt, SWITCH_STACK_BOTTOM | SWITCH_STACK_NODUP, "dest_addr_ton", str);
-
-       str = switch_mprintf("%d", res->dest_addr_npi);
-       switch_event_add_header_string(evt, SWITCH_STACK_BOTTOM | SWITCH_STACK_NODUP, "dest_addr_npi", str);
-
+       switch_event_add_header(evt, SWITCH_STACK_BOTTOM, "dest_addr_ton", "%d", res->dest_addr_ton);
+       switch_event_add_header(evt, SWITCH_STACK_BOTTOM, "dest_addr_npi", "%d", res->dest_addr_npi);
        switch_event_add_header_string(evt, SWITCH_STACK_BOTTOM, "to_user", (const char *) res->destination_addr);
-
-       str = switch_mprintf("%d", res->data_coding);
-       switch_event_add_header_string(evt, SWITCH_STACK_BOTTOM | SWITCH_STACK_NODUP, "data_coding", str);
-       str = NULL;
-
+       switch_event_add_header(evt, SWITCH_STACK_BOTTOM, "data_coding", "%d", res->data_coding);
        switch_event_add_header_string(evt, SWITCH_STACK_BOTTOM, "profile", gateway->profile);
 
        switch_event_add_body(evt, "%s", (const char *) res->short_message);