Skinny: Adds unimplemented send_data(), correct formats

- 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
This commit is contained in:
Mathieu Parent 2010-09-27 18:49:11 +02:00
parent 280e894d17
commit 85b0e1b9c9
3 changed files with 29 additions and 3 deletions

View 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 {

View 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,

View 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);