]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
Skinny: Adds unimplemented send_data(), correct formats
authorMathieu Parent <math.parent@gmail.com>
Mon, 27 Sep 2010 16:49:11 +0000 (18:49 +0200)
committerMathieu Parent <math.parent@gmail.com>
Mon, 27 Sep 2010 16:49:11 +0000 (18:49 +0200)
- send_data() (only defined in .h-file - never implemented)
- Adds correct formats when adding message body.

Thanks to Peter Olsson for spotting this in FS-2737

src/mod/endpoints/mod_skinny/skinny_api.c
src/mod/endpoints/mod_skinny/skinny_protocol.c
src/mod/endpoints/mod_skinny/skinny_server.c

index 9f527f544c6e81da68862d4a07a2ee087709996e..7bbb27afd334f0a51c14ea5db3c4b4bf9a3697ea 100644 (file)
@@ -408,7 +408,7 @@ static switch_status_t skinny_api_cmd_profile_device_send_data(const char *profi
                                        */
                                }
                        }
-                       switch_event_add_body(event, body);
+                       switch_event_add_body(event, "%s", body);
                        switch_event_fire(&event);
                        stream->write_function(stream, "+OK\n");
            } else {
index 5486f0833d5773c66837e91836967c75f518b5d6..743514d98ca2943af165fd3667e3781f30295616 100644 (file)
@@ -902,6 +902,32 @@ switch_status_t send_reset(listener_t *listener, uint32_t reset_type)
        return skinny_send_reply(listener, message);
 }
 
+switch_status_t send_data(listener_t *listener, uint32_t message_type,
+       uint32_t application_id,
+       uint32_t line_instance,
+       uint32_t call_id,
+       uint32_t transaction_id,
+       uint32_t data_length,
+       const char *data)
+{
+       skinny_message_t *message;
+       switch_assert(data_length == strlen(data));
+       /* data_length should be a multiple of 4 */
+       if ((data_length % 4) != 0) {
+               data_length = (data_length / 4 + 1) * 4;
+       }
+       message = switch_core_alloc(listener->pool, 12+sizeof(message->data.data)+data_length-1);
+       message->type = message_type;
+       message->length = 4 + sizeof(message->data.data)+data_length-1;
+       message->data.data.application_id = application_id;
+       message->data.data.line_instance = line_instance;
+       message->data.data.call_id = call_id;
+       message->data.data.transaction_id = transaction_id;
+       message->data.data.data_length = data_length;
+       strncpy(message->data.data.data, data, data_length);
+       return skinny_send_reply(listener, message);
+}
+
 switch_status_t send_extended_data(listener_t *listener, uint32_t message_type,
        uint32_t application_id,
        uint32_t line_instance,
index bd2d6795e5d0cc30660cc104236a654409a02a0b..cfafea6f01d65e83d9f71b9df5e10b46f4c106c4 100644 (file)
@@ -1884,7 +1884,7 @@ switch_status_t skinny_handle_data_message(listener_t *listener, skinny_message_
        tmp = malloc(request->data.data.data_length + 1);
        memcpy(tmp, request->data.data.data, request->data.data.data_length);
        tmp[request->data.data.data_length] = '\0';
-       switch_event_add_body(event, tmp);
+       switch_event_add_body(event, "%s", tmp);
        switch_safe_free(tmp);
        switch_event_fire(&event);
 
@@ -1956,7 +1956,7 @@ switch_status_t skinny_handle_extended_data_message(listener_t *listener, skinny
        tmp = malloc(request->data.data.data_length + 1);
        memcpy(tmp, request->data.data.data, request->data.data.data_length);
        tmp[request->data.data.data_length] = '\0';
-       switch_event_add_body(event, tmp);
+       switch_event_add_body(event, "%s", tmp);
        switch_safe_free(tmp);
        switch_event_fire(&event);