[svn-commits] trunk r34696 - in /trunk: channels/chan_skinny.c
configs/skinny.conf.sample
svn-commits at lists.digium.com
svn-commits at lists.digium.com
Sun Jun 18 15:36:40 MST 2006
Author: north
Date: Sun Jun 18 17:36:39 2006
New Revision: 34696
URL: http://svn.digium.com/view/asterisk?rev=34696&view=rev
Log:
Finally merge chan_skinny fixes into trunk.
ready...set...GO!
Modified:
trunk/channels/chan_skinny.c
trunk/configs/skinny.conf.sample
Modified: trunk/channels/chan_skinny.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_skinny.c?rev=34696&r1=34695&r2=34696&view=diff
==============================================================================
--- trunk/channels/chan_skinny.c (original)
+++ trunk/channels/chan_skinny.c Sun Jun 18 17:36:39 2006
@@ -4,6 +4,7 @@
* Copyright (C) 1999 - 2005, Digium, Inc.
*
* chan_skinny was developed by Jeremy McNamara & Florian Overkamp
+ * chan_skinny was heavily modified/fixed by North Antara
*
* See http://www.asterisk.org for more information about
* the Asterisk project. Please do not directly contact
@@ -20,7 +21,7 @@
*
* \brief Implementation of the Skinny protocol
*
- * \author Jeremy McNamara & Florian Overkamp
+ * \author Jeremy McNamara & Florian Overkamp & North Antara
* \ingroup channel_drivers
*/
@@ -69,6 +70,7 @@
#include "asterisk/utils.h"
#include "asterisk/dsp.h"
#include "asterisk/stringfields.h"
+#include "asterisk/astobj.h"
#include "asterisk/abstract_jb.h"
/*************************************
@@ -87,11 +89,6 @@
static int keep_alive = 120;
static char date_format[6] = "D-M-Y";
static char version_id[16] = "P002F202";
-
-/* these should be in an include file, but dunno what to include */
-typedef unsigned char UINT8;
-typedef unsigned short UINT16;
-typedef unsigned int UINT32;
#if __BYTE_ORDER == __LITTLE_ENDIAN
#define letohl(x) (x)
@@ -137,127 +134,164 @@
#define REGISTER_MESSAGE 0x0001
typedef struct register_message {
char name[16];
- int userId;
- int instance;
- char ip[4];
- int type;
- int maxStreams;
+ uint32_t userId;
+ uint32_t instance;
+ uint32_t ip;
+ uint32_t type;
+ uint32_t maxStreams;
} register_message;
#define IP_PORT_MESSAGE 0x0002
#define KEYPAD_BUTTON_MESSAGE 0x0003
typedef struct keypad_button_message {
- int button;
+ uint32_t button;
+ uint32_t lineInstance;
+ uint32_t callReference;
} keypad_button_message;
#define STIMULUS_MESSAGE 0x0005
typedef struct stimulus_message {
- int stimulus;
- int stimulusInstance;
+ uint32_t stimulus;
+ uint32_t stimulusInstance;
+ uint32_t unknown1;
} stimulus_message;
#define OFFHOOK_MESSAGE 0x0006
+typedef struct offhook_message {
+ uint32_t unknown1;
+ uint32_t unknown2;
+} offhook_message;
+
#define ONHOOK_MESSAGE 0x0007
+typedef struct onhook_message {
+ uint32_t unknown1;
+ uint32_t unknown2;
+} onhook_message;
#define CAPABILITIES_RES_MESSAGE 0x0010
typedef struct station_capabilities {
- int codec;
- int frames;
+ uint32_t codec;
+ uint32_t frames;
union {
char res[8];
- long rate;
+ uint64_t rate;
} payloads;
} station_capabilities;
typedef struct capabilities_res_message {
- int count;
+ uint32_t count;
struct station_capabilities caps[18];
} capabilities_res_message;
#define SPEED_DIAL_STAT_REQ_MESSAGE 0x000A
typedef struct speed_dial_stat_req_message {
- int speedDialNumber;
+ uint32_t speedDialNumber;
} speed_dial_stat_req_message;
#define LINE_STATE_REQ_MESSAGE 0x000B
typedef struct line_state_req_message {
- int lineNumber;
+ uint32_t lineNumber;
} line_state_req_message;
#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
+typedef struct alarm_message {
+ uint32_t alarmSeverity;
+ char displayMessage[80];
+ uint32_t alarmParam1;
+ uint32_t alarmParam2;
+} alarm_message;
#define OPEN_RECEIVE_CHANNEL_ACK_MESSAGE 0x0022
typedef struct open_receive_channel_ack_message {
- int status;
- char ipAddr[4];
- int port;
- int passThruId;
+ uint32_t status;
+ uint32_t ipAddr;
+ uint32_t port;
+ uint32_t passThruId;
} open_receive_channel_ack_message;
#define SOFT_KEY_SET_REQ_MESSAGE 0x0025
+
+#define SOFT_KEY_EVENT_MESSAGE 0x0026
+typedef struct soft_key_event_message {
+ uint32_t softKeyEvent;
+ uint32_t instance;
+ uint32_t reference;
+} soft_key_event_message;
+
#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
typedef struct register_ack_message {
- int keepAlive;
+ uint32_t keepAlive;
char dateTemplate[6];
char res[2];
- int secondaryKeepAlive;
+ uint32_t secondaryKeepAlive;
char res2[4];
} register_ack_message;
#define START_TONE_MESSAGE 0x0082
typedef struct start_tone_message {
- int tone;
+ uint32_t tone;
} start_tone_message;
#define STOP_TONE_MESSAGE 0x0083
#define SET_RINGER_MESSAGE 0x0085
typedef struct set_ringer_message {
- int ringerMode;
+ uint32_t ringerMode;
+ uint32_t unknown1; /* See notes in transmit_ringer_mode */
+ uint32_t unknown2;
} set_ringer_message;
#define SET_LAMP_MESSAGE 0x0086
typedef struct set_lamp_message {
- int stimulus;
- int stimulusInstance;
- int deviceStimulus;
+ uint32_t stimulus;
+ uint32_t stimulusInstance;
+ uint32_t deviceStimulus;
} set_lamp_message;
#define SET_SPEAKER_MESSAGE 0x0088
typedef struct set_speaker_message {
- int mode;
+ uint32_t mode;
} set_speaker_message;
+
+/* XXX When do we need to use this? */
+#define SET_MICROPHONE_MESSAGE 0x0089
+typedef struct set_microphone_message {
+ uint32_t mode;
+} set_microphone_message;
#define START_MEDIA_TRANSMISSION_MESSAGE 0x008A
typedef struct media_qualifier {
- int precedence;
- int vad;
- int packets;
- int bitRate;
+ uint32_t precedence;
+ uint32_t vad;
+ uint32_t packets;
+ uint32_t bitRate;
} media_qualifier;
typedef struct start_media_transmission_message {
- int conferenceId;
- int passThruPartyId;
- char remoteIp[4];
- int remotePort;
- int packetSize;
- int payloadType;
+ uint32_t conferenceId;
+ uint32_t passThruPartyId;
+ uint32_t remoteIp;
+ uint32_t remotePort;
+ uint32_t packetSize;
+ uint32_t payloadType;
media_qualifier qualifier;
} start_media_transmission_message;
#define STOP_MEDIA_TRANSMISSION_MESSAGE 0x008B
typedef struct stop_media_transmission_message {
- int conferenceId;
- int passThruPartyId;
+ uint32_t conferenceId;
+ uint32_t passThruPartyId;
} stop_media_transmission_message;
#define CALL_INFO_MESSAGE 0x008F
@@ -266,199 +300,96 @@
char callingParty[24];
char calledPartyName[40];
char calledParty[24];
- int instance;
- int reference;
- int type;
+ uint32_t instance;
+ uint32_t reference;
+ uint32_t type;
char originalCalledPartyName[40];
char originalCalledParty[24];
} call_info_message;
#define SPEED_DIAL_STAT_RES_MESSAGE 0x0091
typedef struct speed_dial_stat_res_message {
- int speedDialNumber;
+ uint32_t speedDialNumber;
char speedDialDirNumber[24];
char speedDialDisplayName[40];
} speed_dial_stat_res_message;
#define LINE_STAT_RES_MESSAGE 0x0092
typedef struct line_stat_res_message {
- int linenumber;
+ uint32_t lineNumber;
char lineDirNumber[24];
char lineDisplayName[42];
- int space;
+ uint32_t space;
} line_stat_res_message;
#define DEFINETIMEDATE_MESSAGE 0x0094
typedef struct definetimedate_message {
- int year; /* since 1900 */
- int month;
- int dayofweek; /* monday = 1 */
- int day;
- int hour;
- int minute;
- int seconds;
- int milliseconds;
- int timestamp;
+ uint32_t year; /* since 1900 */
+ uint32_t month;
+ uint32_t dayofweek; /* monday = 1 */
+ uint32_t day;
+ uint32_t hour;
+ uint32_t minute;
+ uint32_t seconds;
+ uint32_t milliseconds;
+ uint32_t timestamp;
} definetimedate_message;
#define BUTTON_TEMPLATE_RES_MESSAGE 0x0097
-
typedef struct buttondefinition {
- UINT8 instanceNumber;
- UINT8 buttonDefinition;
+ uint8_t instanceNumber;
+ uint8_t buttonDefinition;
} button_definition;
-#define STIMULUS_REDIAL 0x01
-#define STIMULUS_SPEEDDIAL 0x02
-#define STIMULUS_HOLD 0x03
-#define STIMULUS_TRANSFER 0x04
-#define STIMULUS_FORWARDALL 0x05
-#define STIMULUS_FORWARDBUSY 0x06
-#define STIMULUS_FORWARDNOANSWER 0x07
-#define STIMULUS_DISPLAY 0x08
-#define STIMULUS_LINE 0x09
-#define STIMULUS_VOICEMAIL 0x0F
-#define STIMULUS_AUTOANSWER 0x11
-#define STIMULUS_CONFERENCE 0x7D
-#define STIMULUS_CALLPARK 0x7E
-#define STIMULUS_CALLPICKUP 0x7F
-#define STIMULUS_NONE 0xFF
-
-button_definition button_def_30vip[] = {
- { 1, STIMULUS_LINE }, /* Line 1 */
- { 2, STIMULUS_LINE }, /* Line 2 */
- { 3, STIMULUS_LINE }, /* Line 3 */
- { 4, STIMULUS_LINE }, /* Line 4 */
- { 1, STIMULUS_CALLPARK }, /* Call Park */
- { 0, STIMULUS_NONE },
- { 1, STIMULUS_SPEEDDIAL }, /* Speeddial 1 */
- { 2, STIMULUS_SPEEDDIAL }, /* Speeddial 2 */
- { 3, STIMULUS_SPEEDDIAL }, /* Speeddial 3 */
- { 4, STIMULUS_SPEEDDIAL }, /* Speeddial 4 */
- { 5, STIMULUS_SPEEDDIAL }, /* Speeddial 5 */
- { 6, STIMULUS_SPEEDDIAL }, /* Speeddial 6 */
- { 1, STIMULUS_VOICEMAIL }, /* Voicemail */
- { 1, STIMULUS_FORWARDALL }, /* Forward All */
- { 1, STIMULUS_CONFERENCE }, /* Conference */
- { 0, STIMULUS_NONE },
- { 0, STIMULUS_NONE },
- { 0, STIMULUS_NONE },
- { 0, STIMULUS_NONE },
- { 0, STIMULUS_NONE },
- { 7, STIMULUS_SPEEDDIAL }, /* Speeddial 7 */
- { 8, STIMULUS_SPEEDDIAL }, /* Speeddial 8 */
- { 9, STIMULUS_SPEEDDIAL }, /* Speeddial 9 */
- { 10, STIMULUS_SPEEDDIAL } /* Speeddial 10 */
-};
-
-button_definition button_def_12sp[] = {
- { 1, STIMULUS_LINE }, /* Line 1 */
- { 1, STIMULUS_LINE }, /* Line 1 */
- { 1, STIMULUS_SPEEDDIAL }, /* Speeddial 1 */
- { 2, STIMULUS_SPEEDDIAL }, /* Speeddial 2 */
- { 3, STIMULUS_SPEEDDIAL }, /* Speeddial 3 */
- { 4, STIMULUS_SPEEDDIAL }, /* Speeddial 4 */
- { 1, STIMULUS_VOICEMAIL }, /* Voicemail */
- { 5, STIMULUS_SPEEDDIAL }, /* Speeddial 5 */
- { 6, STIMULUS_SPEEDDIAL }, /* Speeddial 6 */
- { 7, STIMULUS_SPEEDDIAL }, /* Speeddial 7 */
- { 8, STIMULUS_SPEEDDIAL }, /* Speeddial 8 */
- { 9, STIMULUS_SPEEDDIAL } /* Speeddial 9 */
-};
-
-button_definition button_def_7902[] = {
- { 1, STIMULUS_LINE }, /* Line 1 */
- { 1, STIMULUS_HOLD }, /* Hold */
- { 1, STIMULUS_TRANSFER },
- { 1, STIMULUS_DISPLAY },
- { 1, STIMULUS_VOICEMAIL },
- { 1, STIMULUS_CONFERENCE },
- { 1, STIMULUS_FORWARDALL },
- { 1, STIMULUS_SPEEDDIAL }, /* Speeddial 1 */
- { 2, STIMULUS_SPEEDDIAL }, /* Speeddial 2 */
- { 3, STIMULUS_SPEEDDIAL }, /* Speeddial 3 */
- { 4, STIMULUS_SPEEDDIAL }, /* Speeddial 4 */
- { 1, STIMULUS_REDIAL }
-};
-
-button_definition button_def_7910[] = {
- { 1, STIMULUS_LINE }, /* Line 1 */
- { 1, STIMULUS_HOLD }, /* Hold */
- { 1, STIMULUS_TRANSFER },
- { 1, STIMULUS_DISPLAY },
- { 1, STIMULUS_VOICEMAIL },
- { 1, STIMULUS_CONFERENCE },
- { 1, STIMULUS_FORWARDALL },
- { 1, STIMULUS_SPEEDDIAL }, /* Speeddial 1 */
- { 2, STIMULUS_SPEEDDIAL }, /* Speeddial 2 */
- { 1, STIMULUS_REDIAL }
-};
-
-button_definition button_def_7920[] = {
- { 1, STIMULUS_LINE }, /* Line 1 */
- { 2, STIMULUS_LINE }, /* Line 2 */
- { 1, STIMULUS_SPEEDDIAL }, /* Speeddial 1 */
- { 2, STIMULUS_SPEEDDIAL }, /* Speeddial 2 */
- { 3, STIMULUS_SPEEDDIAL }, /* Speeddial 3 */
- { 4, STIMULUS_SPEEDDIAL } /* Speeddial 4 */
-};
-
-button_definition button_def_7935[] = {
- { 1, STIMULUS_LINE }, /* Line 1 */
- { 2, STIMULUS_LINE } /* Line 2 */
-};
-
-button_definition button_def_7940[] = {
- { 1, STIMULUS_LINE }, /* Line 1 */
- { 2, STIMULUS_LINE } /* Line 2 */
-};
-
-button_definition button_def_7960[] = {
- { 1, STIMULUS_LINE }, /* Line 1 */
- { 2, STIMULUS_LINE }, /* Line 2 */
- { 3, STIMULUS_LINE }, /* Line 3 */
- { 1, STIMULUS_SPEEDDIAL }, /* Speeddial 1 */
- { 2, STIMULUS_SPEEDDIAL }, /* Speeddial 2 */
- { 3, STIMULUS_SPEEDDIAL } /* Speeddial 3 */
-};
-
-button_definition button_def_7970[] = {
- { 1, STIMULUS_LINE }, /* Line 1 */
- { 2, STIMULUS_LINE }, /* Line 2 */
- { 3, STIMULUS_LINE }, /* Line 3 */
- { 1, STIMULUS_SPEEDDIAL }, /* Speeddial 1 */
- { 2, STIMULUS_SPEEDDIAL }, /* Speeddial 2 */
- { 3, STIMULUS_SPEEDDIAL }, /* Speeddial 3 */
- { 4, STIMULUS_SPEEDDIAL }, /* Speeddial 4 */
- { 5, STIMULUS_SPEEDDIAL } /* Speeddial 5 */
-};
-
-button_definition button_def_none = { 0, STIMULUS_NONE };
-
-typedef struct button_defs {
- char *type;
- int num_buttons;
- button_definition *button_def;
-} button_defs_t;
-
-button_defs_t button_defs[] = {
- { "12SP", 12, button_def_12sp }, /* First one is used if
- there's no match */
- { "30VIP", 26, button_def_30vip },
- { "7902", 12, button_def_7902 },
- { "7910", 10, button_def_7910 },
- { "7920", 6, button_def_7920 },
- { "7935", 2, button_def_7935 },
- { "7940", 2, button_def_7940 },
- { "7960", 6, button_def_7960 },
- { "7970", 8, button_def_7970 },
- { NULL, 0, NULL }
-};
+typedef struct buttondefinitiontemplate {
+ uint8_t buttonDefinition;
+ /* for now, anything between 0xB0 and 0xCF is custom */
+ /*int custom;*/
+} button_definition_template;
+
+#define STIMULUS_REDIAL 0x01
+#define STIMULUS_SPEEDDIAL 0x02
+#define STIMULUS_HOLD 0x03
+#define STIMULUS_TRANSFER 0x04
+#define STIMULUS_FORWARDALL 0x05
+#define STIMULUS_FORWARDBUSY 0x06
+#define STIMULUS_FORWARDNOANSWER 0x07
+#define STIMULUS_DISPLAY 0x08
+#define STIMULUS_LINE 0x09
+#define STIMULUS_VOICEMAIL 0x0F
+#define STIMULUS_AUTOANSWER 0x11
+#define STIMULUS_CONFERENCE 0x7D
+#define STIMULUS_CALLPARK 0x7E
+#define STIMULUS_CALLPICKUP 0x7F
+#define STIMULUS_NONE 0xFF
+
+/* Button types */
+#define BT_REDIAL STIMULUS_REDIAL
+#define BT_SPEEDDIAL STIMULUS_SPEEDDIAL
+#define BT_HOLD STIMULUS_HOLD
+#define BT_TRANSFER STIMULUS_TRANSFER
+#define BT_FORWARDALL STIMULUS_FORWARDALL
+#define BT_FORWARDBUSY STIMULUS_FORWARDBUSY
+#define BT_FORWARDNOANSWER STIMULUS_FORWARDNOANSWER
+#define BT_DISPLAY STIMULUS_DISPLAY
+#define BT_LINE STIMULUS_LINE
+#define BT_VOICEMAIL STIMULUS_VOICEMAIL
+#define BT_AUTOANSWER STIMULUS_AUTOANSWER
+#define BT_CONFERENCE STIMULUS_CONFERENCE
+#define BT_CALLPARK STIMULUS_CALLPARK
+#define BT_CALLPICKUP STIMULUS_CALLPICKUP
+#define BT_NONE 0x00
+
+/* Custom button types - add our own between 0xB0 and 0xCF.
+ This may need to be revised in the future,
+ if stimuluses are ever added in this range. */
+#define BT_CUST_LINESPEEDDIAL 0xB0 /* line or speeddial */
+#define BT_CUST_HINT 0xB1 /* pipe dream */
typedef struct button_template_res_message {
- UINT32 buttonOffset;
- UINT32 buttonCount;
- UINT32 totalButtonCount;
+ uint32_t buttonOffset;
+ uint32_t buttonCount;
+ uint32_t totalButtonCount;
button_definition definition[42];
} button_template_res_message;
@@ -487,195 +418,302 @@
typedef struct server_res_message {
server_identifier server[5];
- int serverListenPort[5];
- int serverIpAddr[5];
+ uint32_t serverListenPort[5];
+ uint32_t serverIpAddr[5];
} server_res_message;
+
+#define RESET_MESSAGE 0x009F
+typedef struct reset_message {
+ uint32_t resetType;
+} reset_message;
#define KEEP_ALIVE_ACK_MESSAGE 0x0100
#define OPEN_RECEIVE_CHANNEL_MESSAGE 0x0105
typedef struct open_receive_channel_message {
- int conferenceId;
- int partyId;
- int packets;
- int capability;
- int echo;
- int bitrate;
+ uint32_t conferenceId;
+ uint32_t partyId;
+ uint32_t packets;
+ uint32_t capability;
+ uint32_t echo;
+ uint32_t bitrate;
} open_receive_channel_message;
#define CLOSE_RECEIVE_CHANNEL_MESSAGE 0x0106
typedef struct close_receive_channel_message {
- int conferenceId;
- int partyId;
+ uint32_t conferenceId;
+ uint32_t partyId;
} close_receive_channel_message;
#define SOFT_KEY_TEMPLATE_RES_MESSAGE 0x0108
typedef struct soft_key_template_definition {
char softKeyLabel[16];
- int softKeyEvent;
+ uint32_t softKeyEvent;
} soft_key_template_definition;
+#define KEYDEF_ONHOOK 0
+#define KEYDEF_CONNECTED 1
+#define KEYDEF_ONHOLD 2
+#define KEYDEF_RINGIN 3
+#define KEYDEF_OFFHOOK 4
+#define KEYDEF_CONNWITHTRANS 5
+#define KEYDEF_DADFD 6 /* Digits After Dialing First Digit */
+#define KEYDEF_CONNWITHCONF 7
+#define KEYDEF_RINGOUT 8
+#define KEYDEF_OFFHOOKWITHFEAT 9
+#define KEYDEF_UNKNOWN 10
+
+#define SOFTKEY_NONE 0x00
+#define SOFTKEY_REDIAL 0x01
+#define SOFTKEY_NEWCALL 0x02
+#define SOFTKEY_HOLD 0x03
+#define SOFTKEY_TRNSFER 0x04
+#define SOFTKEY_CFWDALL 0x05
+#define SOFTKEY_CFWDBUSY 0x06
+#define SOFTKEY_CFWDNOANSWER 0x07
+#define SOFTKEY_BKSPC 0x08
+#define SOFTKEY_ENDCALL 0x09
+#define SOFTKEY_RESUME 0x0A
+#define SOFTKEY_ANSWER 0x0B
+#define SOFTKEY_INFO 0x0C
+#define SOFTKEY_CONFRN 0x0D
+#define SOFTKEY_PARK 0x0E
+#define SOFTKEY_JOIN 0x0F
+#define SOFTKEY_MEETME 0x10
+#define SOFTKEY_PICKUP 0x11
+#define SOFTKEY_GPICKUP 0x12
+
soft_key_template_definition soft_key_template_default[] = {
- { "Redial", 1 },
- { "NewCall", 2 },
- { "Hold", 3 },
- { "Trnsfer", 4 },
- { "CFwdAll", 5 },
- { "CFwdBusy", 6 },
- { "CFwdNoAnswer", 7 },
- { "<<", 8 },
- { "EndCall", 9 },
- { "Resume", 10 },
- { "Answer", 11 },
- { "Info", 12 },
- { "Confrn", 13 },
- { "Park", 14 },
- { "Join", 15 },
- { "MeetMe", 16 },
- { "PickUp", 17 },
- { "GPickUp", 18 },
+ { "Redial", 0x01 },
+ { "NewCall", 0x02 },
+ { "Hold", 0x03 },
+ { "Trnsfer", 0x04 },
+ { "CFwdAll", 0x05 },
+ { "CFwdBusy", 0x06 },
+ { "CFwdNoAnswer", 0x07 },
+ { "<<", 0x08 },
+ { "EndCall", 0x09 },
+ { "Resume", 0x0A },
+ { "Answer", 0x0B },
+ { "Info", 0x0C },
+ { "Confrn", 0x0D },
+ { "Park", 0x0E },
+ { "Join", 0x0F },
+ { "MeetMe", 0x10 },
+ { "PickUp", 0x11 },
+ { "GPickUp", 0x12 },
};
-typedef struct soft_key_template {
- int softKeyOffset;
- int softKeyCount;
- int totalSoftKeyCount;
+typedef struct soft_key_definitions {
+ const uint8_t mode;
+ const uint8_t *defaults;
+ const int count;
+} soft_key_definitions;
+
+static const uint8_t soft_key_default_onhook[] = {
+ SOFTKEY_REDIAL,
+ SOFTKEY_CFWDALL,
+ SOFTKEY_CFWDBUSY,
+ SOFTKEY_GPICKUP,
+ SOFTKEY_CONFRN,
+};
+
+static const uint8_t soft_key_default_connected[] = {
+ SOFTKEY_HOLD,
+ SOFTKEY_ENDCALL,
+ SOFTKEY_TRNSFER,
+ SOFTKEY_PARK,
+ SOFTKEY_CFWDALL,
+ SOFTKEY_CFWDBUSY,
+};
+
+static const uint8_t soft_key_default_onhold[] = {
+ SOFTKEY_RESUME,
+ SOFTKEY_NEWCALL,
+ SOFTKEY_ENDCALL,
+ SOFTKEY_TRNSFER,
+};
+
+static const uint8_t soft_key_default_ringin[] = {
+ SOFTKEY_ANSWER,
+ SOFTKEY_ENDCALL,
+ SOFTKEY_TRNSFER,
+};
+
+static const uint8_t soft_key_default_offhook[] = {
+ SOFTKEY_REDIAL,
+ SOFTKEY_ENDCALL,
+ SOFTKEY_CFWDALL,
+ SOFTKEY_CFWDBUSY,
+ SOFTKEY_GPICKUP,
+};
+
+static const uint8_t soft_key_default_connwithtrans[] = {
+ SOFTKEY_HOLD,
+ SOFTKEY_ENDCALL,
+ SOFTKEY_TRNSFER,
+ SOFTKEY_PARK,
+ SOFTKEY_CFWDALL,
+ SOFTKEY_CFWDBUSY,
+};
+
+static const uint8_t soft_key_default_dadfd[] = {
+ SOFTKEY_BKSPC,
+ SOFTKEY_ENDCALL,
+};
+
+static const uint8_t soft_key_default_connwithconf[] = {
+ SOFTKEY_NONE,
+};
+
+static const uint8_t soft_key_default_ringout[] = {
+ SOFTKEY_ENDCALL,
+ SOFTKEY_TRNSFER,
+ SOFTKEY_CFWDALL,
+ SOFTKEY_CFWDBUSY,
+};
+
+static const uint8_t soft_key_default_offhookwithfeat[] = {
+ SOFTKEY_REDIAL,
+ SOFTKEY_ENDCALL,
+};
+
+static const uint8_t soft_key_default_unknown[] = {
+ SOFTKEY_NONE,
+};
+
+static const soft_key_definitions soft_key_default_definitions[] = {
+ {KEYDEF_ONHOOK, soft_key_default_onhook, sizeof(soft_key_default_onhook) / sizeof(uint8_t)},
+ {KEYDEF_CONNECTED, soft_key_default_connected, sizeof(soft_key_default_connected) / sizeof(uint8_t)},
+ {KEYDEF_ONHOLD, soft_key_default_onhold, sizeof(soft_key_default_onhold) / sizeof(uint8_t)},
+ {KEYDEF_RINGIN, soft_key_default_ringin, sizeof(soft_key_default_ringin) / sizeof(uint8_t)},
+ {KEYDEF_OFFHOOK, soft_key_default_offhook, sizeof(soft_key_default_offhook) / sizeof(uint8_t)},
+ {KEYDEF_CONNWITHTRANS, soft_key_default_connwithtrans, sizeof(soft_key_default_connwithtrans) / sizeof(uint8_t)},
+ {KEYDEF_DADFD, soft_key_default_dadfd, sizeof(soft_key_default_dadfd) / sizeof(uint8_t)},
+ {KEYDEF_CONNWITHCONF, soft_key_default_connwithconf, sizeof(soft_key_default_connwithconf) / sizeof(uint8_t)},
+ {KEYDEF_RINGOUT, soft_key_default_ringout, sizeof(soft_key_default_ringout) / sizeof(uint8_t)},
+ {KEYDEF_OFFHOOKWITHFEAT, soft_key_default_offhookwithfeat, sizeof(soft_key_default_offhookwithfeat) / sizeof(uint8_t)},
+ {KEYDEF_UNKNOWN, soft_key_default_unknown, sizeof(soft_key_default_unknown) / sizeof(uint8_t)}
+};
+
+typedef struct soft_key_template_res_message {
+ uint32_t softKeyOffset;
+ uint32_t softKeyCount;
+ uint32_t totalSoftKeyCount;
soft_key_template_definition softKeyTemplateDefinition[32];
-} soft_key_template;
+} soft_key_template_res_message;
#define SOFT_KEY_SET_RES_MESSAGE 0x0109
-static const char *soft_key_set_hack = {
- "\x01\x02\x05\x03\x09\x0a\x0b\x10\x11\x12\x04\x0e\x0d\x00\x00\x00"
- "\x2d\x01\x2e\x01\x31\x01\x2f\x01\x35\x01\x36\x01\x37\x01\x3c\x01"
- "\x3d\x01\x3e\x01\x30\x01\x3a\x01\x39\x01\x00\x00\x00\x00\x00\x00"
- "\x03\x09\x04\x0e\x0d\x13\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
- "\x2f\x01\x35\x01\x30\x01\x3a\x01\x39\x01\x3f\x01\x00\x00\x00\x00"
- "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
- "\x0a\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
- "\x36\x01\x2e\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
- "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
- "\x0b\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
- "\x37\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
- "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
- "\x01\x09\x05\x10\x11\x12\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
- "\x2d\x01\x35\x01\x31\x01\x3c\x01\x3d\x01\x3e\x01\x00\x00\x00\x00"
- "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
- "\x00\x09\x04\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
- "\x00\x00\x35\x01\x30\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
- "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
- "\x08\x09\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
- "\x34\x01\x35\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
- "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
- "\x00\x09\x0d\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
- "\x00\x00\x35\x01\x39\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
- "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
- "\x00\x09\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
- "\x00\x00\x35\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
- "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
- "\x01\x09\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
- "\x2d\x01\x35\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
- "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
- "\x15\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
- "\x41\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
- "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
-};
typedef struct soft_key_set_definition {
- UINT8 softKeyTemplateIndex[16];
- UINT16 softKeyInfoIndex[16];
+ uint8_t softKeyTemplateIndex[16];
+ uint16_t softKeyInfoIndex[16];
} soft_key_set_definition;
-typedef struct soft_key_sets {
- UINT32 softKeySetOffset;
- UINT32 softKeySetCount;
- UINT32 totalSoftKeySetCount;
+typedef struct soft_key_set_res_message {
+ uint32_t softKeySetOffset;
+ uint32_t softKeySetCount;
+ uint32_t totalSoftKeySetCount;
soft_key_set_definition softKeySetDefinition[16];
- UINT32 res;
-} soft_key_sets;
+ uint32_t res;
+} soft_key_set_res_message;
#define SELECT_SOFT_KEYS_MESSAGE 0x0110
typedef struct select_soft_keys_message {
- int instance;
- int reference;
- int softKeySetIndex;
- int validKeyMask;
+ uint32_t instance;
+ uint32_t reference;
+ uint32_t softKeySetIndex;
+ uint32_t validKeyMask;
} select_soft_keys_message;
#define CALL_STATE_MESSAGE 0x0111
typedef struct call_state_message {
- int callState;
- int lineInstance;
- int callReference;
+ uint32_t callState;
+ uint32_t lineInstance;
+ uint32_t callReference;
} call_state_message;
#define DISPLAY_PROMPT_STATUS_MESSAGE 0x0112
typedef struct display_prompt_status_message {
- int messageTimeout;
+ uint32_t messageTimeout;
char promptMessage[32];
- int lineInstance;
- int callReference;
+ uint32_t lineInstance;
+ uint32_t callReference;
} display_prompt_status_message;
#define DISPLAY_NOTIFY_MESSAGE 0x0114
typedef struct display_notify_message {
- int displayTimeout;
+ uint32_t displayTimeout;
char displayMessage[100];
} display_notify_message;
#define ACTIVATE_CALL_PLANE_MESSAGE 0x0116
typedef struct activate_call_plane_message {
- int lineInstance;
+ uint32_t lineInstance;
} activate_call_plane_message;
#define DIALED_NUMBER_MESSAGE 0x011D
typedef struct dialed_number_message {
char dialedNumber[24];
- int lineInstance;
- int callReference;
+ uint32_t lineInstance;
+ uint32_t callReference;
} dialed_number_message;
+
+typedef union {
+ alarm_message alarm;
+ speed_dial_stat_req_message speeddialreq;
+ register_message reg;
+ register_ack_message regack;
+ register_rej_message regrej;
+ capabilities_res_message caps;
+ version_res_message version;
+ button_template_res_message buttontemplate;
+ displaytext_message displaytext;
+ display_prompt_status_message displaypromptstatus;
+ definetimedate_message definetimedate;
+ start_tone_message starttone;
+ speed_dial_stat_res_message speeddial;
+ line_state_req_message line;
+ line_stat_res_message linestat;
+ soft_key_set_res_message softkeysets;
+ soft_key_template_res_message softkeytemplate;
+ server_res_message serverres;
+ reset_message reset;
+ set_lamp_message setlamp;
+ set_ringer_message setringer;
+ call_state_message callstate;
+ keypad_button_message keypad;
+ select_soft_keys_message selectsoftkey;
+ activate_call_plane_message activatecallplane;
+ stimulus_message stimulus;
+ offhook_message offhook;
+ onhook_message onhook;
+ set_speaker_message setspeaker;
+ set_microphone_message setmicrophone;
+ call_info_message callinfo;
+ start_media_transmission_message startmedia;
+ stop_media_transmission_message stopmedia;
+ open_receive_channel_message openreceivechannel;
+ open_receive_channel_ack_message openreceivechannelack;
+ close_receive_channel_message closereceivechannel;
+ display_notify_message displaynotify;
+ dialed_number_message dialednumber;
+ soft_key_event_message softkeyeventmessage;
+} skinny_data;
/* packet composition */
typedef struct {
int len;
int res;
int e;
- union {
- speed_dial_stat_req_message speeddialreq;
- register_message reg;
- register_ack_message regack;
- register_rej_message regrej;
- capabilities_res_message caps;
- version_res_message version;
- button_template_res_message buttontemplate;
- displaytext_message displaytext;
- display_prompt_status_message displaypromptstatus;
- definetimedate_message definetimedate;
- start_tone_message starttone;
- speed_dial_stat_res_message speeddial;
- line_state_req_message line;
- line_stat_res_message linestat;
- soft_key_sets softkeysets;
- soft_key_template softkeytemplate;
- server_res_message serverres;
- set_lamp_message setlamp;
- set_ringer_message setringer;
- call_state_message callstate;
- keypad_button_message keypad;
- select_soft_keys_message selectsoftkey;
- activate_call_plane_message activatecallplane;
- stimulus_message stimulus;
- set_speaker_message setspeaker;
- call_info_message callinfo;
- start_media_transmission_message startmedia;
- stop_media_transmission_message stopmedia;
- open_receive_channel_message openreceivechannel;
- open_receive_channel_ack_message openreceivechannelack;
- close_receive_channel_message closereceivechannel;
- display_notify_message displaynotify;
- dialed_number_message dialednumber;
- } data;
+ skinny_data data;
} skinny_req;
+
+/* XXX This is the combined size of the variables above. (len, res, e)
+ If more are added, this MUST change.
+ (sizeof(skinny_req) - sizeof(skinny_data)) DOES NOT WORK on all systems (amd64?). */
+int skinny_header_size = 12;
/*****************************
* Asterisk specific globals *
@@ -688,7 +726,8 @@
static char ourhost[256];
static int ourport;
static struct in_addr __ourip;
-struct ast_hostent ahp; struct hostent *hp;
+struct ast_hostent ahp;
+struct hostent *hp;
static int skinnysock = -1;
static pthread_t tcp_thread;
static pthread_t accept_t;
@@ -715,12 +754,40 @@
static int amaflags = 0;
static int callnums = 1;
-#define SUB_REAL 0
-#define SUB_ALT 1
-#define MAX_SUBS 2
+#define SKINNY_DEVICE_UNKNOWN -1
+#define SKINNY_DEVICE_NONE 0
+#define SKINNY_DEVICE_30SPPLUS 1
+#define SKINNY_DEVICE_12SPPLUS 2
+#define SKINNY_DEVICE_12SP 3
+#define SKINNY_DEVICE_12 4
+#define SKINNY_DEVICE_30VIP 5
+#define SKINNY_DEVICE_7910 6
+#define SKINNY_DEVICE_7960 7
+#define SKINNY_DEVICE_7940 8
+#define SKINNY_DEVICE_7935 9
+#define SKINNY_DEVICE_ATA186 12 /* Cisco ATA-186 */
+#define SKINNY_DEVICE_7941 115
+#define SKINNY_DEVICE_7971 119
+#define SKINNY_DEVICE_7985 302
+#define SKINNY_DEVICE_7911 307
+#define SKINNY_DEVICE_7961GE 308
+#define SKINNY_DEVICE_7941GE 309
+#define SKINNY_DEVICE_7905 20000
+#define SKINNY_DEVICE_7920 30002
+#define SKINNY_DEVICE_7970 30006
+#define SKINNY_DEVICE_7912 30007
+#define SKINNY_DEVICE_7902 30008
+#define SKINNY_DEVICE_CIPC 30016 /* Cisco IP Communicator */
+#define SKINNY_DEVICE_7961 30018
+#define SKINNY_DEVICE_7936 30019
+#define SKINNY_DEVICE_SCCPGATEWAY_AN 30027 /* ??? */
+#define SKINNY_DEVICE_SCCPGATEWAY_BRI 30028 /* ??? */
#define SKINNY_SPEAKERON 1
#define SKINNY_SPEAKEROFF 2
+
+#define SKINNY_MICON 1
+#define SKINNY_MICOFF 2
#define SKINNY_OFFHOOK 1
#define SKINNY_ONHOOK 2
@@ -814,26 +881,27 @@
struct skinny_subchannel {
ast_mutex_t lock;
+ struct ast_channel *owner;
+ struct ast_rtp *rtp;
+ struct ast_rtp *vrtp;
unsigned int callid;
- struct ast_channel *owner;
- struct skinny_line *parent;
- struct ast_rtp *rtp;
- time_t lastouttime;
+ /* time_t lastouttime; */ /* Unused */
int progress;
int ringing;
- int lastout;
+ /* int lastout; */ /* Unused */
int cxmode;
int nat;
int outgoing;
int alreadygone;
+
struct skinny_subchannel *next;
+ struct skinny_line *parent;
};
struct skinny_line {
ast_mutex_t lock;
char name[80];
char label[42]; /* Label that shows next to the line buttons */
- struct skinny_subchannel *sub; /* pointer to our current connection, channel and stuff */
char accountcode[AST_MAX_ACCOUNT_CODE];
char exten[AST_MAX_EXTENSION]; /* Extension where to start */
char context[AST_MAX_CONTEXT];
@@ -844,6 +912,7 @@
char call_forward[AST_MAX_EXTENSION];
char mailbox[AST_MAX_EXTENSION];
char musicclass[MAX_MUSICCLASS];
+ char lastnumberdialed[AST_MAX_EXTENSION]; /* Last number that was dialed - used for redial */
int curtone; /* Current tone being played */
ast_group_t callgroup;
ast_group_t pickupgroup;
@@ -864,11 +933,31 @@
int capability;
int nonCodecCapability;
int onhooktime;
- int msgstate; /* voicemail message state */
+ int msgstate; /* voicemail message state */
int immediate;
int hookstate;
- int progress;
+ int nat;
+
+ struct skinny_subchannel *sub;
struct skinny_line *next;
+ struct skinny_device *parent;
+};
+
+struct skinny_speeddial {
+ ast_mutex_t lock;
+ char label[42];
+ char exten[AST_MAX_EXTENSION];
+ int instance;
+
+ struct skinny_speeddial *next;
+ struct skinny_device *parent;
+};
+
+struct skinny_addon {
+ ast_mutex_t lock;
+ char type[10];
+
+ struct skinny_addon *next;
struct skinny_device *parent;
};
@@ -879,10 +968,13 @@
char version_id[16];
int type;
int registered;
- char model[6];
+ int lastlineinstance;
+ int lastcallreference;
struct sockaddr_in addr;
struct in_addr ourip;
struct skinny_line *lines;
+ struct skinny_speeddial *speeddials;
+ struct skinny_addon *addons;
struct ast_ha *ha;
struct skinnysession *session;
struct skinny_device *next;
@@ -901,6 +993,7 @@
struct sockaddr_in sin;
int fd;
char inbuf[SKINNY_MAX_PACKET];
+ char outbuf[SKINNY_MAX_PACKET];
struct skinny_device *device;
struct skinnysession *next;
} *sessions = NULL;
@@ -932,25 +1025,151 @@
/* .bridge = ast_rtp_bridge, */
};
-static skinny_req *req_alloc(size_t size)
+static void *get_button_template(struct skinnysession *s, button_definition_template *btn)
+{
+ struct skinny_device *d = s->device;
+ struct skinny_addon *a = d->addons;
+ int i;
+
+ switch (d->type) {
+ case SKINNY_DEVICE_30SPPLUS:
+ case SKINNY_DEVICE_30VIP:
+ /* 13 rows, 2 columns */
+ for (i = 0; i < 4; i++)
+ (btn++)->buttonDefinition = BT_LINE;
+ (btn++)->buttonDefinition = BT_REDIAL;
+ (btn++)->buttonDefinition = BT_VOICEMAIL;
+ (btn++)->buttonDefinition = BT_CALLPARK;
+ (btn++)->buttonDefinition = BT_FORWARDALL;
+ (btn++)->buttonDefinition = BT_CONFERENCE;
+ for (i = 0; i < 4; i++)
+ (btn++)->buttonDefinition = BT_NONE;
+ for (i = 0; i < 13; i++)
+ (btn++)->buttonDefinition = BT_SPEEDDIAL;
+
+ break;
+ case SKINNY_DEVICE_12SPPLUS:
+ case SKINNY_DEVICE_12SP:
+ case SKINNY_DEVICE_12:
+ /* 6 rows, 2 columns */
+ for (i = 0; i < 2; i++)
+ (btn++)->buttonDefinition = BT_LINE;
+ (btn++)->buttonDefinition = BT_REDIAL;
+ for (i = 0; i < 3; i++)
+ (btn++)->buttonDefinition = BT_SPEEDDIAL;
+ (btn++)->buttonDefinition = BT_HOLD;
+ (btn++)->buttonDefinition = BT_TRANSFER;
+ (btn++)->buttonDefinition = BT_FORWARDALL;
+ (btn++)->buttonDefinition = BT_CALLPARK;
+ (btn++)->buttonDefinition = BT_VOICEMAIL;
+ (btn++)->buttonDefinition = BT_CONFERENCE;
+ break;
+ case SKINNY_DEVICE_7910:
+ (btn++)->buttonDefinition = BT_LINE;
+ (btn++)->buttonDefinition = BT_HOLD;
+ (btn++)->buttonDefinition = BT_TRANSFER;
+ (btn++)->buttonDefinition = BT_DISPLAY;
+ (btn++)->buttonDefinition = BT_VOICEMAIL;
+ (btn++)->buttonDefinition = BT_CONFERENCE;
+ (btn++)->buttonDefinition = BT_FORWARDALL;
+ for (i = 0; i < 2; i++)
+ (btn++)->buttonDefinition = BT_SPEEDDIAL;
+ (btn++)->buttonDefinition = BT_REDIAL;
+ break;
+ case SKINNY_DEVICE_7960:
+ case SKINNY_DEVICE_7961:
+ case SKINNY_DEVICE_7961GE:
+ for (i = 0; i < 6; i++)
+ (btn++)->buttonDefinition = BT_CUST_LINESPEEDDIAL;
+ break;
+ case SKINNY_DEVICE_7940:
+ case SKINNY_DEVICE_7941:
+ case SKINNY_DEVICE_7941GE:
+ for (i = 0; i < 2; i++)
+ (btn++)->buttonDefinition = BT_CUST_LINESPEEDDIAL;
+ break;
+ case SKINNY_DEVICE_7935:
+ case SKINNY_DEVICE_7936:
+ for (i = 0; i < 2; i++)
+ (btn++)->buttonDefinition = BT_LINE;
+ break;
+ case SKINNY_DEVICE_ATA186:
+ (btn++)->buttonDefinition = BT_LINE;
+ break;
+ case SKINNY_DEVICE_7970:
+ case SKINNY_DEVICE_7971:
+ case SKINNY_DEVICE_CIPC:
+ for (i = 0; i < 8; i++)
+ (btn++)->buttonDefinition = BT_CUST_LINESPEEDDIAL;
+ break;
+ case SKINNY_DEVICE_7985:
+ /* XXX I have no idea what the buttons look like on these. */
+ ast_log(LOG_WARNING, "Unsupported device type '%d (7985)' found.\n", d->type);
+ break;
+ case SKINNY_DEVICE_7912:
+ case SKINNY_DEVICE_7911:
+ case SKINNY_DEVICE_7905:
+ (btn++)->buttonDefinition = BT_LINE;
+ (btn++)->buttonDefinition = BT_HOLD;
+ break;
+ case SKINNY_DEVICE_7920:
+ /* XXX I don't know if this is right. */
+ for (i = 0; i < 4; i++)
+ (btn++)->buttonDefinition = BT_CUST_LINESPEEDDIAL;
+ break;
+ case SKINNY_DEVICE_7902:
+ ast_log(LOG_WARNING, "Unsupported device type '%d (7902)' found.\n", d->type);
+ break;
+ case SKINNY_DEVICE_SCCPGATEWAY_AN:
+ case SKINNY_DEVICE_SCCPGATEWAY_BRI:
+ ast_log(LOG_WARNING, "Unsupported device type '%d (SCCP gateway)' found.\n", d->type);
+ break;
+ default:
+ ast_log(LOG_WARNING, "Unknown device type '%d' found.\n", d->type);
+ break;
+ }
+
+ for (a = d->addons; a; a = a->next) {
+ if (!strcasecmp(a->type, "7914")) {
+ for (i = 0; i < 14; i++)
+ (btn++)->buttonDefinition = BT_CUST_LINESPEEDDIAL;
+ } else {
+ ast_log(LOG_WARNING, "Unknown addon type '%s' found. Skipping.\n", a->type);
+ }
+ }
+
+ return btn;
+}
+
+static skinny_req *req_alloc(size_t size, int response_message)
{
skinny_req *req;
- req = malloc(size+12);
- if (!req) {
+
+ if (!(req = ast_calloc(1, skinny_header_size + size + 4)))
return NULL;
- }
- memset(req, 0, size+12);
+
+ req->len = htolel(size+4);
+ req->e = htolel(response_message);
+
return req;
}
-static struct skinny_subchannel *find_subchannel_by_line(struct skinny_line *l)
-{
- /* XXX Need to figure out how to determine which sub we want */
- struct skinny_subchannel *sub = l->sub;
- return sub;
-}
-
-static struct skinny_subchannel *find_subchannel_by_name(const char *dest)
+static struct skinny_line *find_line_by_instance(struct skinny_device *d, int instance)
+{
+ struct skinny_line *l;
+
+ for (l = d->lines; l; l = l->next) {
+ if (l->instance == instance)
+ break;
+ }
+
+ if (!l) {
+ ast_log(LOG_WARNING, "Could not find line with instance '%d' on device '%s'\n", instance, d->name);
+ }
+ return l;
+}
+
+static struct skinny_line *find_line_by_name(const char *dest)
{
struct skinny_line *l;
struct skinny_device *d;
@@ -969,15 +1188,14 @@
ast_mutex_lock(&devicelock);
for (d = devices; d; d = d->next) {
if (!strcasecmp(d->name, device)) {
- if (skinnydebug) {
+ if (skinnydebug)
ast_verbose("Found device: %s\n", d->name);
- }
/* Found the device */
for (l = d->lines; l; l = l->next) {
/* Search for the right line */
if (!strcasecmp(l->name, line)) {
ast_mutex_unlock(&devicelock);
- return l->sub;
+ return l;
}
}
}
@@ -987,18 +1205,82 @@
return NULL;
}
+/* It's quicker/easier to find the subchannel when we know the instance number too */
+static struct skinny_subchannel *find_subchannel_by_instance_reference(struct skinny_device *d, int instance, int reference)
+{
+ struct skinny_line *l = find_line_by_instance(d, instance);
+ struct skinny_subchannel *sub;
+
+ if (!l) {
+ return NULL;
+ }
+
+ for (sub = l->sub; sub; sub = sub->next) {
+ if (sub->callid == reference)
+ break;
+ }
+
+ if (!sub) {
+ ast_log(LOG_WARNING, "Could not find subchannel with reference '%d' on '%s'\n", reference, d->name);
+ }
+ return sub;
+}
+
+/* Find the subchannel when we only have the callid - this shouldn't happen often */
+static struct skinny_subchannel *find_subchannel_by_reference(struct skinny_device *d, int reference)
+{
+ struct skinny_line *l;
+ struct skinny_subchannel *sub = NULL;
+
+ for (l = d->lines; l; l = l->next) {
+ for (sub = l->sub; sub; sub = sub->next) {
+ if (sub->callid == reference)
+ break;
+ }
+ if (sub)
+ break;
+ }
+
+ if (!l) {
+ ast_log(LOG_WARNING, "Could not find any lines that contained a subchannel with reference '%d' on device '%s'\n", reference, d->name);
+ } else {
+ if (!sub) {
+ ast_log(LOG_WARNING, "Could not find subchannel with reference '%d' on '%s@%s'\n", reference, l->name, d->name);
+ }
+ }
+ return sub;
+}
+
+static struct skinny_speeddial *find_speeddial_by_instance(struct skinny_device *d, int instance)
+{
+ struct skinny_speeddial *sd;
+
+ for (sd = d->speeddials; sd; sd = sd->next) {
+ if (sd->instance == instance)
+ break;
+ }
+
+ if (!sd) {
+ ast_log(LOG_WARNING, "Could not find speeddial with instance '%d' on device '%s'\n", instance, d->name);
+ }
+ return sd;
+}
+
static int transmit_response(struct skinnysession *s, skinny_req *req)
{
int res = 0;
ast_mutex_lock(&s->lock);
#if 0
- if (skinnydebug) {
+ if (skinnydebug)
ast_verbose("writing packet type %04X (%d bytes) to socket %d\n", letohl(req->e), letohl(req->len)+8, s->fd);
- }
#endif
- res = write(s->fd, req, letohl(req->len)+8);
+ memset(s->outbuf,0,sizeof(s->outbuf));
+ memcpy(s->outbuf, req, skinny_header_size);
+ memcpy(s->outbuf+skinny_header_size, &req->data, sizeof(skinny_data));
+
+ res = write(s->fd, s->outbuf, letohl(req->len)+8);
[... 3409 lines stripped ...]
More information about the svn-commits
mailing list