[asterisk-commits] anthonyl: branch anthonyl/skinny-redux r48140 - /team/anthonyl/skinny-redux/c...

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Thu Nov 30 10:38:43 MST 2006


Author: anthonyl
Date: Thu Nov 30 11:38:42 2006
New Revision: 48140

URL: http://svn.digium.com/view/asterisk?view=rev&rev=48140
Log:
move all of the messages we handle to an enum

Modified:
    team/anthonyl/skinny-redux/channels/chan_skinny.c

Modified: team/anthonyl/skinny-redux/channels/chan_skinny.c
URL: http://svn.digium.com/view/asterisk/team/anthonyl/skinny-redux/channels/chan_skinny.c?view=diff&rev=48140&r1=48139&r2=48140
==============================================================================
--- team/anthonyl/skinny-redux/channels/chan_skinny.c (original)
+++ team/anthonyl/skinny-redux/channels/chan_skinny.c Thu Nov 30 11:38:42 2006
@@ -144,11 +144,6 @@
 /*********************
  * Protocol Messages *
  *********************/
-/* message types */
-#define KEEP_ALIVE_MESSAGE 0x0000
-/* no additional struct */
-
-#define REGISTER_MESSAGE 0x0001
 struct register_message {
 	char name[16];
 	uint32_t userId;
@@ -158,35 +153,28 @@
 	uint32_t maxStreams;
 };
 
-#define IP_PORT_MESSAGE	0x0002
-
-#define KEYPAD_BUTTON_MESSAGE 0x0003
 struct keypad_button_message {
 	uint32_t button;
 	uint32_t lineInstance;
 	uint32_t callReference;
 };
 
-#define STIMULUS_MESSAGE 0x0005
 struct stimulus_message {
 	uint32_t stimulus;
 	uint32_t stimulusInstance;
 	uint32_t unknown1;
 };
 
-#define OFFHOOK_MESSAGE 0x0006
 struct offhook_message {
 	uint32_t unknown1;
 	uint32_t unknown2;
 };
 
-#define ONHOOK_MESSAGE 0x0007
 struct onhook_message {
 	uint32_t unknown1;
 	uint32_t unknown2;
 };
 
-#define CAPABILITIES_RES_MESSAGE 0x0010
 struct station_capabilities {
 	uint32_t codec;
 	uint32_t frames;
@@ -201,22 +189,14 @@
 	struct station_capabilities caps[18];
 };
 
-#define SPEED_DIAL_STAT_REQ_MESSAGE 0x000A
 struct speed_dial_stat_req_message {
 	uint32_t speedDialNumber;
 };
 
-#define LINE_STATE_REQ_MESSAGE 0x000B
 struct line_state_req_message {
 	uint32_t lineNumber;
 };
 
-#define TIME_DATE_REQ_MESSAGE 0x000D
-#define BUTTON_TEMPLATE_REQ_MESSAGE 0x000E
-#define VERSION_REQ_MESSAGE 0x000F
-#define SERVER_REQUEST_MESSAGE 0x0012
-
-#define ALARM_MESSAGE 0x0020
 struct alarm_message {
 	uint32_t alarmSeverity;
 	char displayMessage[80];
@@ -224,7 +204,6 @@
 	uint32_t alarmParam2;
 };
 
-#define OPEN_RECEIVE_CHANNEL_ACK_MESSAGE 0x0022
 struct open_receive_channel_ack_message {
 	uint32_t status;
 	uint32_t ipAddr;
@@ -232,21 +211,12 @@
 	uint32_t passThruId;
 };
 
-#define SOFT_KEY_SET_REQ_MESSAGE 0x0025
-
-#define SOFT_KEY_EVENT_MESSAGE 0x0026
 struct soft_key_event_message {
 	uint32_t softKeyEvent;
 	uint32_t instance;
 	uint32_t reference;
 };
 
-#define UNREGISTER_MESSAGE 0x0027
-#define SOFT_KEY_TEMPLATE_REQ_MESSAGE 0x0028
-#define HEADSET_STATUS_MESSAGE 0x002B
-#define REGISTER_AVAILABLE_LINES_MESSAGE 0x002D
-
-#define REGISTER_ACK_MESSAGE 0x0081
 struct register_ack_message {
 	uint32_t keepAlive;
 	char dateTemplate[6];
@@ -255,39 +225,31 @@
 	char res2[4];
 };
 
-#define START_TONE_MESSAGE 0x0082
 struct start_tone_message {
 	uint32_t tone;
 };
 
-#define STOP_TONE_MESSAGE 0x0083
-
-#define SET_RINGER_MESSAGE 0x0085
 struct set_ringer_message {
 	uint32_t ringerMode;
 	uint32_t unknown1; /* See notes in transmit_ringer_mode */
 	uint32_t unknown2;
 };
 
-#define SET_LAMP_MESSAGE 0x0086
 struct set_lamp_message {
 	uint32_t stimulus;
 	uint32_t stimulusInstance;
 	uint32_t deviceStimulus;
 };
 
-#define SET_SPEAKER_MESSAGE 0x0088
 struct set_speaker_message {
 	uint32_t mode;
 };
 
 /* XXX When do we need to use this? */
-#define SET_MICROPHONE_MESSAGE 0x0089
 struct set_microphone_message {
 	uint32_t mode;
 };
 
-#define START_MEDIA_TRANSMISSION_MESSAGE 0x008A
 struct media_qualifier {
 	uint32_t precedence;
 	uint32_t vad;
@@ -305,13 +267,11 @@
 	struct media_qualifier qualifier;
 };
 
-#define STOP_MEDIA_TRANSMISSION_MESSAGE 0x008B
 struct stop_media_transmission_message {
 	uint32_t conferenceId;
 	uint32_t passThruPartyId;
 };
 
-#define CALL_INFO_MESSAGE 0x008F
 struct call_info_message {
 	char callingPartyName[40];
 	char callingParty[24];
@@ -324,14 +284,12 @@
 	char originalCalledParty[24];
 };
 
-#define SPEED_DIAL_STAT_RES_MESSAGE 0x0091
 struct speed_dial_stat_res_message {
 	uint32_t speedDialNumber;
 	char speedDialDirNumber[24];
 	char speedDialDisplayName[40];
 };
 
-#define LINE_STAT_RES_MESSAGE 0x0092
 struct line_stat_res_message {
 	uint32_t lineNumber;
 	char lineDirNumber[24];
@@ -339,7 +297,6 @@
 	uint32_t space;
 };
 
-#define DEFINETIMEDATE_MESSAGE 0x0094
 struct definetimedate_message {
 	uint32_t year;	/* since 1900 */
 	uint32_t month;
@@ -352,7 +309,6 @@
 	uint32_t timestamp;
 };
 
-#define BUTTON_TEMPLATE_RES_MESSAGE 0x0097
 struct button_definition {
 	uint8_t instanceNumber;
 	uint8_t buttonDefinition;
@@ -410,34 +366,23 @@
 	struct button_definition definition[42];
 };
 
-#define VERSION_RES_MESSAGE 0x0098
 struct version_res_message {
 	char version[16];
 };
 
-#define DISPLAYTEXT_MESSAGE 0x0099
 struct displaytext_message {
 	char text[40];
 };
 
-#define CLEAR_NOTIFY_MESSAGE  0x0115
-
-#define CLEAR_PROMPT_MESSAGE  0x0113
 struct clear_prompt_message {
         uint32_t instance;
 	uint32_t callid;
 };
 
-#define CLEAR_DISPLAY_MESSAGE 0x009A
-
-#define CAPABILITIES_REQ_MESSAGE 0x009B
-
-#define REGISTER_REJ_MESSAGE 0x009D
 struct register_rej_message {
 	char errMsg[33];
 };
 
-#define SERVER_RES_MESSAGE 0x009E
 struct server_identifier {
 	char serverName[48];
 };
@@ -448,14 +393,10 @@
 	uint32_t serverIpAddr[5];
 };
 
-#define RESET_MESSAGE 0x009F
 struct reset_message {
 	uint32_t resetType;
 };
 
-#define KEEP_ALIVE_ACK_MESSAGE 0x0100
-
-#define OPEN_RECEIVE_CHANNEL_MESSAGE 0x0105
 struct open_receive_channel_message {
 	uint32_t conferenceId;
 	uint32_t partyId;
@@ -465,13 +406,10 @@
 	uint32_t bitrate;
 };
 
-#define CLOSE_RECEIVE_CHANNEL_MESSAGE 0x0106
 struct close_receive_channel_message {
 	uint32_t conferenceId;
 	uint32_t partyId;
 };
-
-#define SOFT_KEY_TEMPLATE_RES_MESSAGE 0x0108
 
 struct soft_key_template_definition {
 	char softKeyLabel[16];
@@ -630,7 +568,6 @@
 	struct soft_key_template_definition softKeyTemplateDefinition[32];
 };
 
-#define SOFT_KEY_SET_RES_MESSAGE 0x0109
 
 struct soft_key_set_definition {
 	uint8_t softKeyTemplateIndex[16];
@@ -645,7 +582,6 @@
 	uint32_t res;
 };
 
-#define SELECT_SOFT_KEYS_MESSAGE 0x0110
 struct select_soft_keys_message {
 	uint32_t instance;
 	uint32_t reference;
@@ -653,14 +589,12 @@
 	uint32_t validKeyMask;
 };
 
-#define CALL_STATE_MESSAGE 0x0111
 struct call_state_message {
 	uint32_t callState;
 	uint32_t lineInstance;
 	uint32_t callReference;
 };
 
-#define DISPLAY_PROMPT_STATUS_MESSAGE 0x0112
 struct display_prompt_status_message {
 	uint32_t messageTimeout;
 	char promptMessage[32];
@@ -668,24 +602,22 @@
 	uint32_t callReference;
 };
 
-#define DISPLAY_NOTIFY_MESSAGE 0x0114
 struct display_notify_message {
 	uint32_t displayTimeout;
 	char displayMessage[100];
 };
 
-#define ACTIVATE_CALL_PLANE_MESSAGE 0x0116
 struct activate_call_plane_message {
 	uint32_t lineInstance;
 };
 
-#define DIALED_NUMBER_MESSAGE 0x011D
 struct dialed_number_message {
 	char dialedNumber[24];
 	uint32_t lineInstance;
 	uint32_t callReference;
 };
 
+/* this needs to be removed and replaced with something much better */
 union skinny_data {
 	struct alarm_message alarm;
 	struct speed_dial_stat_req_message speeddialreq;
@@ -1054,6 +986,66 @@
 	.send_digit_begin = skinny_senddigit_begin,
 	.send_digit_end = skinny_senddigit_end,
 /*	.bridge = ast_rtp_bridge, */
+};
+
+/* contains all of the messages we support */
+enum skinny_messages {
+	KEEP_ALIVE_MESSAGE		= 0x0000,
+	REGISTER_MESSAGE		= 0x0001,
+	IP_PORT_MESSAGE			= 0x0002,
+	KEYPAD_BUTTON_MESSAGE 		= 0x0003,
+	STIMULUS_MESSAGE 		= 0x0005,
+	OFFHOOK_MESSAGE			= 0x0006,
+	ONHOOK_MESSAGE 			= 0x0007,
+	CAPABILITIES_RES_MESSAGE 	= 0x0010,
+	SPEED_DIAL_STAT_REQ_MESSAGE 	= 0x000A,
+	LINE_STATE_REQ_MESSAGE 		= 0x000B,
+	TIME_DATE_REQ_MESSAGE 		= 0x000D,
+	BUTTON_TEMPLATE_REQ_MESSAGE 	= 0x000E,
+	VERSION_REQ_MESSAGE 		= 0x000F,
+	SERVER_REQUEST_MESSAGE 		= 0x0012,
+	ALARM_MESSAGE 			= 0x0020,
+	OPEN_RECEIVE_CHANNEL_ACK_MESSAGE = 0x0022,
+	SOFT_KEY_SET_REQ_MESSAGE	 = 0x0025,
+	SOFT_KEY_EVENT_MESSAGE 		 = 0x0026,
+	UNREGISTER_MESSAGE 		 = 0x0027,
+	SOFT_KEY_TEMPLATE_REQ_MESSAGE 	 = 0x0028,
+	HEADSET_STATUS_MESSAGE 		 = 0x002B,
+	REGISTER_AVAILABLE_LINES_MESSAGE = 0x002D,
+	REGISTER_ACK_MESSAGE 		 = 0x0081,
+	START_TONE_MESSAGE 		 = 0x0082,
+	STOP_TONE_MESSAGE	 	 = 0x0083,
+	SET_RINGER_MESSAGE 		 = 0x0085,
+	SET_LAMP_MESSAGE  		 = 0x0086,
+	SET_SPEAKER_MESSAGE 		 = 0x0088,
+	SET_MICROPHONE_MESSAGE 		 = 0x0089,
+	START_MEDIA_TRANSMISSION_MESSAGE = 0x008A,
+	STOP_MEDIA_TRANSMISSION_MESSAGE  = 0x008B,
+	CALL_INFO_MESSAGE                = 0x008F,
+	SPEED_DIAL_STAT_RES_MESSAGE      = 0x0091,
+	LINE_STAT_RES_MESSAGE            = 0x0092,
+	DEFINETIMEDATE_MESSAGE           = 0x0094,
+	BUTTON_TEMPLATE_RES_MESSAGE      = 0x0097,
+	VERSION_RES_MESSAGE              = 0x0098,
+	DISPLAYTEXT_MESSAGE              = 0x0099,
+	CLEAR_PROMPT_MESSAGE             = 0x0113,
+	CLEAR_NOTIFY_MESSAGE             = 0x0115,
+	CLEAR_DISPLAY_MESSAGE            = 0x009A,
+	CAPABILITIES_REQ_MESSAGE         = 0x009B,
+	REGISTER_REJ_MESSAGE             = 0x009D,
+	SERVER_RES_MESSAGE               = 0x009E,
+	RESET_MESSAGE                    = 0x009F,
+	KEEP_ALIVE_ACK_MESSAGE           = 0x0100,
+	OPEN_RECEIVE_CHANNEL_MESSAGE     = 0x0105,
+	CLOSE_RECEIVE_CHANNEL_MESSAGE    = 0x0106,
+	SOFT_KEY_TEMPLATE_RES_MESSAGE    = 0x0108,
+	SOFT_KEY_SET_RES_MESSAGE         = 0x0109,
+	SELECT_SOFT_KEYS_MESSAGE         = 0x0110,
+	CALL_STATE_MESSAGE               = 0x0111,
+	DISPLAY_PROMPT_STATUS_MESSAGE    = 0x0112,
+	DISPLAY_NOTIFY_MESSAGE           = 0x0114,
+	ACTIVATE_CALL_PLANE_MESSAGE      = 0x0116,
+	DIALED_NUMBER_MESSAGE            = 0x011D,
 };
 
 static void *get_button_template(struct skinnysession *s, struct button_definition_template *btn)
@@ -1400,6 +1392,10 @@
 		ast_verbose("writing packet type %04X (%d bytes) to socket %d\n", letohl(req->e), letohl(req->len)+8, s->fd);
 #endif
 
+	if (!req) {
+		return -1;
+	}
+	
 	memset(s->outbuf,0,sizeof(s->outbuf));
 	memcpy(s->outbuf, req, skinny_header_size);
 	memcpy(s->outbuf+skinny_header_size, &req->data, letohl(req->len));
@@ -1417,6 +1413,7 @@
 	}
 	
 	ast_mutex_unlock(&s->lock);
+	
 	return 1;
 }
 



More information about the asterisk-commits mailing list