Skinny: Event skinny::xml_alarm

This commit is contained in:
Mathieu Parent 2010-12-19 22:16:09 +01:00
parent 1c4c84fc0f
commit 709c4e5f97
4 changed files with 30 additions and 2 deletions

View File

@ -42,6 +42,7 @@
#define SKINNY_EVENT_UNREGISTER "skinny::unregister"
#define SKINNY_EVENT_EXPIRE "skinny::expire"
#define SKINNY_EVENT_ALARM "skinny::alarm"
#define SKINNY_EVENT_XML_ALARM "skinny::xml_alarm"
#define SKINNY_EVENT_CALL_STATE "skinny::call_state"
#define SKINNY_EVENT_USER_TO_DEVICE "skinny::user_to_device"
#define SKINNY_EVENT_DEVICE_TO_USER "skinny::device_to_user"

View File

@ -627,8 +627,7 @@ union skinny_data {
struct extended_data_message extended_data;
uint16_t as_uint16;
char as_char;
void *raw;
char as_char[1];
};
/*

View File

@ -1963,6 +1963,26 @@ switch_status_t skinny_handle_extended_data_message(listener_t *listener, skinny
return SWITCH_STATUS_SUCCESS;
}
switch_status_t skinny_handle_xml_alarm(listener_t *listener, skinny_message_t *request)
{
switch_event_t *event = NULL;
char *tmp = NULL;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO,
"Received XML alarm.\n");
/* skinny::xml_alarm event */
skinny_device_event(listener, &event, SWITCH_EVENT_CUSTOM, SKINNY_EVENT_XML_ALARM);
/* Ensure that the body is null-terminated */
tmp = malloc(request->length - 4 + 1);
memcpy(tmp, request->data.as_char, request->length - 4);
tmp[request->length - 4] = '\0';
switch_event_add_body(event, "%s", tmp);
switch_safe_free(tmp);
switch_event_fire(&event);
return SWITCH_STATUS_SUCCESS;
}
switch_status_t skinny_handle_request(listener_t *listener, skinny_message_t *request)
{
if (listener->profile->debug >= 10 || request->type != KEEP_ALIVE_MESSAGE) {
@ -2032,6 +2052,8 @@ switch_status_t skinny_handle_request(listener_t *listener, skinny_message_t *re
return skinny_handle_extended_data_message(listener, request);
case DEVICE_TO_USER_DATA_RESPONSE_VERSION1_MESSAGE:
return skinny_handle_extended_data_message(listener, request);
case XML_ALARM_MESSAGE:
return skinny_handle_xml_alarm(listener, request);
default:
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
"Unhandled request %s (type=%x,length=%d).\n", skinny_message_type2str(request->type), request->type, request->length);

View File

@ -34,6 +34,12 @@ if(!$socket) {
exit 1;
}
# =============================================================================
$socket->send_raw(
XML_ALARM_MESSAGE,
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\x0a<x-cisco-alarm>\x0a<Alarm Name=\"LastOutOfServiceInformation\">\x0a<ParameterList>\x0a<String name=\"DeviceName\">SEP002699438F62</String>\x0a<String name=\"DeviceIPv4Address\">192.168.3.201/24</String>\x0a<String name=\"IPv4DefaultGateway\">192.168.3.254</String>\x0a<String name=\"DeviceIPv6Address\"></String>\x0a<String name=\"IPv6DefaultGateway\"></String>\x0a<String name=\"ModelNumber\">CP-7961G</String>\x0a<String name=\"NeighborIPv4Address\">192.168.0.253</String>\x0a<String name=\"NeighborIPv6Address\"></String>\x0a<String name=\"NeighborDeviceID\">sw2.wvds.local</String>\x0a<String name=\"NeighborPortID\">3</String>\x0a<Enum name=\"DHCPv4Status\">1</Enum>\x0a<Enum name=\"DHCPv6Status\">0</Enum>\x0a<Enum name=\"TFTPCfgStatus\">0</Enum>\x0a<Enum name=\"DNSStatusUnifiedCM1\">0</Enum>\x0a<Enum name=\"DNSStatusUnifiedCM2\">0</Enum>\x0a<Enum name=\"DNSStatusUnifiedCM3\">0</Enum>\x0a<String name=\"VoiceVLAN\">4095</String>\x0a<String name=\"UnifiedCMIPAddress\"><not open></String>\x0a<String name=\"LocalPort\">-1</String>\x0a<String name=\"TimeStamp\">1289313813826</String>\x0a<Enum name=\"ReasonForOutOfService\"></Enum>\x0a<String name=\"LastProtocolEventSent\">1:Register</String>\x0a<String name=\"LastProtocolEventReceived\">129:RegisterAck</String>\x0a</ParameterList>\x0a</Alarm>\x0a</x-cisco-alarm>\x0a"
);
$socket->sleep(20);
exit;
$socket->send_message(
REGISTER_MESSAGE,
device_name => $device_name,