Sat Nov 1 06:28:30 2008

Asterisk developer's documentation


chan_skinny.c

Go to the documentation of this file.
00001 /*
00002  * Asterisk -- An open source telephony toolkit.
00003  *
00004  * Copyright (C) 1999 - 2005, Digium, Inc.
00005  *
00006  * chan_skinny was developed by Jeremy McNamara & Florian Overkamp
00007  * chan_skinny was heavily modified/fixed by North Antara
00008  *
00009  * See http://www.asterisk.org for more information about
00010  * the Asterisk project. Please do not directly contact
00011  * any of the maintainers of this project for assistance;
00012  * the project provides a web site, mailing lists and IRC
00013  * channels for your use.
00014  *
00015  * This program is free software, distributed under the terms of
00016  * the GNU General Public License Version 2. See the LICENSE file
00017  * at the top of the source tree.
00018  */
00019 
00020 /*! \file
00021  *
00022  * \brief Implementation of the Skinny protocol
00023  *
00024  * \author Jeremy McNamara & Florian Overkamp & North Antara
00025  * \ingroup channel_drivers
00026  */
00027 
00028 
00029 #include "asterisk.h"
00030 
00031 ASTERISK_FILE_VERSION(__FILE__, "$Revision: 136062 $")
00032 
00033 #include <stdio.h>
00034 #include <stdlib.h>
00035 #include <string.h>
00036 #include <unistd.h>
00037 #include <sys/socket.h>
00038 #include <netinet/in.h>
00039 #include <netinet/tcp.h>
00040 #include <sys/ioctl.h>
00041 #include <net/if.h>
00042 #include <errno.h>
00043 #include <fcntl.h>
00044 #include <netdb.h>
00045 #include <arpa/inet.h>
00046 #include <sys/signal.h>
00047 #include <signal.h>
00048 #include <ctype.h>
00049 
00050 #include "asterisk/lock.h"
00051 #include "asterisk/channel.h"
00052 #include "asterisk/config.h"
00053 #include "asterisk/logger.h"
00054 #include "asterisk/module.h"
00055 #include "asterisk/pbx.h"
00056 #include "asterisk/options.h"
00057 #include "asterisk/lock.h"
00058 #include "asterisk/sched.h"
00059 #include "asterisk/io.h"
00060 #include "asterisk/rtp.h"
00061 #include "asterisk/acl.h"
00062 #include "asterisk/callerid.h"
00063 #include "asterisk/cli.h"
00064 #include "asterisk/say.h"
00065 #include "asterisk/cdr.h"
00066 #include "asterisk/astdb.h"
00067 #include "asterisk/features.h"
00068 #include "asterisk/app.h"
00069 #include "asterisk/musiconhold.h"
00070 #include "asterisk/utils.h"
00071 #include "asterisk/dsp.h"
00072 #include "asterisk/stringfields.h"
00073 #include "asterisk/astobj.h"
00074 #include "asterisk/abstract_jb.h"
00075 #include "asterisk/threadstorage.h"
00076 
00077 /*************************************
00078  * Skinny/Asterisk Protocol Settings *
00079  *************************************/
00080 static const char tdesc[] = "Skinny Client Control Protocol (Skinny)";
00081 static const char config[] = "skinny.conf";
00082 
00083 static int default_capability = AST_FORMAT_ULAW | AST_FORMAT_ALAW;
00084 static struct ast_codec_pref default_prefs;
00085 
00086 enum skinny_codecs {
00087    SKINNY_CODEC_ALAW = 2,
00088    SKINNY_CODEC_ULAW = 4,
00089    SKINNY_CODEC_G723_1 = 9,
00090    SKINNY_CODEC_G729A = 12,
00091    SKINNY_CODEC_G726_32 = 82, /* XXX Which packing order does this translate to? */
00092    SKINNY_CODEC_H261 = 100,
00093    SKINNY_CODEC_H263 = 101
00094 };
00095 
00096 #define DEFAULT_SKINNY_PORT   2000
00097 #define DEFAULT_SKINNY_BACKLOG   2
00098 #define SKINNY_MAX_PACKET  1000
00099 
00100 static int keep_alive = 120;
00101 static char date_format[6] = "D-M-Y";
00102 static char version_id[16] = "P002F202";
00103 
00104 #if __BYTE_ORDER == __LITTLE_ENDIAN
00105 #define letohl(x) (x)
00106 #define letohs(x) (x)
00107 #define htolel(x) (x)
00108 #define htoles(x) (x)
00109 #else
00110 #if defined(SOLARIS) || defined(__Darwin__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__FreeBSD__)
00111 #define __bswap_16(x) \
00112    ((((x) & 0xff00) >> 8) | \
00113     (((x) & 0x00ff) << 8))
00114 #define __bswap_32(x) \
00115    ((((x) & 0xff000000) >> 24) | \
00116     (((x) & 0x00ff0000) >>  8) | \
00117     (((x) & 0x0000ff00) <<  8) | \
00118     (((x) & 0x000000ff) << 24))
00119 #else
00120 #include <bits/byteswap.h>
00121 #endif
00122 #define letohl(x) __bswap_32(x)
00123 #define letohs(x) __bswap_16(x)
00124 #define htolel(x) __bswap_32(x)
00125 #define htoles(x) __bswap_16(x)
00126 #endif
00127 
00128 /*! Global jitterbuffer configuration - by default, jb is disabled */
00129 static struct ast_jb_conf default_jbconf =
00130 {
00131    .flags = 0,
00132    .max_size = -1,
00133    .resync_threshold = -1,
00134    .impl = ""
00135 };
00136 static struct ast_jb_conf global_jbconf;
00137 
00138 AST_THREADSTORAGE(device2str_threadbuf, device2str_threadbuf_init);
00139 #define DEVICE2STR_BUFSIZE   15
00140 
00141 AST_THREADSTORAGE(control2str_threadbuf, control2str_threadbuf_init);
00142 #define CONTROL2STR_BUFSIZE   100
00143 
00144 /*********************
00145  * Protocol Messages *
00146  *********************/
00147 /* message types */
00148 #define KEEP_ALIVE_MESSAGE 0x0000
00149 /* no additional struct */
00150 
00151 #define REGISTER_MESSAGE 0x0001
00152 struct register_message {
00153    char name[16];
00154    uint32_t userId;
00155    uint32_t instance;
00156    uint32_t ip;
00157    uint32_t type;
00158    uint32_t maxStreams;
00159 };
00160 
00161 #define IP_PORT_MESSAGE 0x0002
00162 
00163 #define KEYPAD_BUTTON_MESSAGE 0x0003
00164 struct keypad_button_message {
00165    uint32_t button;
00166    uint32_t lineInstance;
00167    uint32_t callReference;
00168 };
00169 
00170 
00171 #define ENBLOC_CALL_MESSAGE 0x0004
00172 struct enbloc_call_message {
00173        char calledParty[24];
00174 };
00175 
00176 #define STIMULUS_MESSAGE 0x0005
00177 struct stimulus_message {
00178    uint32_t stimulus;
00179    uint32_t stimulusInstance;
00180    uint32_t callreference;
00181 };
00182 
00183 #define OFFHOOK_MESSAGE 0x0006
00184 struct offhook_message {
00185    uint32_t unknown1;
00186    uint32_t unknown2;
00187 };
00188 
00189 #define ONHOOK_MESSAGE 0x0007
00190 struct onhook_message {
00191    uint32_t unknown1;
00192    uint32_t unknown2;
00193 };
00194 
00195 #define CAPABILITIES_RES_MESSAGE 0x0010
00196 struct station_capabilities {
00197    uint32_t codec;
00198    uint32_t frames;
00199    union {
00200       char res[8];
00201       uint32_t rate;
00202    } payloads;
00203 };
00204 
00205 #define SKINNY_MAX_CAPABILITIES 18
00206 
00207 struct capabilities_res_message {
00208    uint32_t count;
00209    struct station_capabilities caps[SKINNY_MAX_CAPABILITIES];
00210 };
00211 
00212 #define SPEED_DIAL_STAT_REQ_MESSAGE 0x000A
00213 struct speed_dial_stat_req_message {
00214    uint32_t speedDialNumber;
00215 };
00216 
00217 #define LINE_STATE_REQ_MESSAGE 0x000B
00218 struct line_state_req_message {
00219    uint32_t lineNumber;
00220 };
00221 
00222 #define TIME_DATE_REQ_MESSAGE 0x000D
00223 #define BUTTON_TEMPLATE_REQ_MESSAGE 0x000E
00224 #define VERSION_REQ_MESSAGE 0x000F
00225 #define SERVER_REQUEST_MESSAGE 0x0012
00226 
00227 #define ALARM_MESSAGE 0x0020
00228 struct alarm_message {
00229    uint32_t alarmSeverity;
00230    char displayMessage[80];
00231    uint32_t alarmParam1;
00232    uint32_t alarmParam2;
00233 };
00234 
00235 #define OPEN_RECEIVE_CHANNEL_ACK_MESSAGE 0x0022
00236 struct open_receive_channel_ack_message {
00237    uint32_t status;
00238    uint32_t ipAddr;
00239    uint32_t port;
00240    uint32_t passThruId;
00241 };
00242 
00243 #define SOFT_KEY_SET_REQ_MESSAGE 0x0025
00244 
00245 #define SOFT_KEY_EVENT_MESSAGE 0x0026
00246 struct soft_key_event_message {
00247    uint32_t softKeyEvent;
00248    uint32_t instance;
00249    uint32_t callreference;
00250 };
00251 
00252 #define UNREGISTER_MESSAGE 0x0027
00253 #define SOFT_KEY_TEMPLATE_REQ_MESSAGE 0x0028
00254 #define HEADSET_STATUS_MESSAGE 0x002B
00255 #define REGISTER_AVAILABLE_LINES_MESSAGE 0x002D
00256 
00257 #define REGISTER_ACK_MESSAGE 0x0081
00258 struct register_ack_message {
00259    uint32_t keepAlive;
00260    char dateTemplate[6];
00261    char res[2];
00262    uint32_t secondaryKeepAlive;
00263    char res2[4];
00264 };
00265 
00266 #define START_TONE_MESSAGE 0x0082
00267 struct start_tone_message {
00268    uint32_t tone;
00269    uint32_t space;
00270    uint32_t instance;
00271    uint32_t reference;
00272 };
00273 
00274 #define STOP_TONE_MESSAGE 0x0083
00275 struct stop_tone_message {
00276    uint32_t instance;
00277    uint32_t reference;
00278 };
00279 
00280 #define SET_RINGER_MESSAGE 0x0085
00281 struct set_ringer_message {
00282    uint32_t ringerMode;
00283    uint32_t unknown1; /* See notes in transmit_ringer_mode */
00284    uint32_t unknown2;
00285    uint32_t space[2];
00286 };
00287 
00288 #define SET_LAMP_MESSAGE 0x0086
00289 struct set_lamp_message {
00290    uint32_t stimulus;
00291    uint32_t stimulusInstance;
00292    uint32_t deviceStimulus;
00293 };
00294 
00295 #define SET_SPEAKER_MESSAGE 0x0088
00296 struct set_speaker_message {
00297    uint32_t mode;
00298 };
00299 
00300 /* XXX When do we need to use this? */
00301 #define SET_MICROPHONE_MESSAGE 0x0089
00302 struct set_microphone_message {
00303    uint32_t mode;
00304 };
00305 
00306 #define START_MEDIA_TRANSMISSION_MESSAGE 0x008A
00307 struct media_qualifier {
00308    uint32_t precedence;
00309    uint32_t vad;
00310    uint16_t packets;
00311    uint32_t bitRate;
00312 };
00313 
00314 struct start_media_transmission_message {
00315    uint32_t conferenceId;
00316    uint32_t passThruPartyId;
00317    uint32_t remoteIp;
00318    uint32_t remotePort;
00319    uint32_t packetSize;
00320    uint32_t payloadType;
00321    struct media_qualifier qualifier;
00322    uint32_t space[16];
00323 };
00324 
00325 #define STOP_MEDIA_TRANSMISSION_MESSAGE 0x008B
00326 struct stop_media_transmission_message {
00327    uint32_t conferenceId;
00328    uint32_t passThruPartyId;
00329    uint32_t space[3];
00330 };
00331 
00332 #define CALL_INFO_MESSAGE 0x008F
00333 struct call_info_message {
00334    char callingPartyName[40];
00335    char callingParty[24];
00336    char calledPartyName[40];
00337    char calledParty[24];
00338    uint32_t instance;
00339    uint32_t reference;
00340    uint32_t type;
00341    char originalCalledPartyName[40];
00342    char originalCalledParty[24];
00343    char lastRedirectingPartyName[40];
00344    char lastRedirectingParty[24];
00345    uint32_t originalCalledPartyRedirectReason;
00346    uint32_t lastRedirectingReason;
00347    char callingPartyVoiceMailbox[24];
00348    char calledPartyVoiceMailbox[24];
00349    char originalCalledPartyVoiceMailbox[24];
00350    char lastRedirectingVoiceMailbox[24];
00351    uint32_t space[3];
00352 };
00353 
00354 #define SPEED_DIAL_STAT_RES_MESSAGE 0x0091
00355 struct speed_dial_stat_res_message {
00356    uint32_t speedDialNumber;
00357    char speedDialDirNumber[24];
00358    char speedDialDisplayName[40];
00359 };
00360 
00361 #define LINE_STAT_RES_MESSAGE 0x0092
00362 struct line_stat_res_message {
00363    uint32_t lineNumber;
00364    char lineDirNumber[24];
00365    char lineDisplayName[24];
00366    uint32_t space[15];
00367 };
00368 
00369 #define DEFINETIMEDATE_MESSAGE 0x0094
00370 struct definetimedate_message {
00371    uint32_t year; /* since 1900 */
00372    uint32_t month;
00373    uint32_t dayofweek;  /* monday = 1 */
00374    uint32_t day;
00375    uint32_t hour;
00376    uint32_t minute;
00377    uint32_t seconds;
00378    uint32_t milliseconds;
00379    uint32_t timestamp;
00380 };
00381 
00382 #define BUTTON_TEMPLATE_RES_MESSAGE 0x0097
00383 struct button_definition {
00384    uint8_t instanceNumber;
00385    uint8_t buttonDefinition;
00386 };
00387 
00388 struct button_definition_template {
00389    uint8_t buttonDefinition;
00390    /* for now, anything between 0xB0 and 0xCF is custom */
00391    /*int custom;*/
00392 };
00393 
00394 #define STIMULUS_REDIAL       0x01
00395 #define STIMULUS_SPEEDDIAL    0x02
00396 #define STIMULUS_HOLD         0x03
00397 #define STIMULUS_TRANSFER     0x04
00398 #define STIMULUS_FORWARDALL      0x05
00399 #define STIMULUS_FORWARDBUSY     0x06
00400 #define STIMULUS_FORWARDNOANSWER 0x07
00401 #define STIMULUS_DISPLAY      0x08
00402 #define STIMULUS_LINE         0x09
00403 #define STIMULUS_VOICEMAIL    0x0F
00404 #define STIMULUS_AUTOANSWER      0x11
00405 #define STIMULUS_CONFERENCE      0x7D
00406 #define STIMULUS_CALLPARK     0x7E
00407 #define STIMULUS_CALLPICKUP      0x7F
00408 #define STIMULUS_NONE         0xFF
00409 
00410 /* Button types */
00411 #define BT_REDIAL       STIMULUS_REDIAL
00412 #define BT_SPEEDDIAL       STIMULUS_SPEEDDIAL
00413 #define BT_HOLD            STIMULUS_HOLD
00414 #define BT_TRANSFER        STIMULUS_TRANSFER
00415 #define BT_FORWARDALL         STIMULUS_FORWARDALL
00416 #define BT_FORWARDBUSY        STIMULUS_FORWARDBUSY
00417 #define BT_FORWARDNOANSWER    STIMULUS_FORWARDNOANSWER
00418 #define BT_DISPLAY         STIMULUS_DISPLAY
00419 #define BT_LINE            STIMULUS_LINE
00420 #define BT_VOICEMAIL       STIMULUS_VOICEMAIL
00421 #define BT_AUTOANSWER         STIMULUS_AUTOANSWER
00422 #define BT_CONFERENCE         STIMULUS_CONFERENCE
00423 #define BT_CALLPARK        STIMULUS_CALLPARK
00424 #define BT_CALLPICKUP         STIMULUS_CALLPICKUP
00425 #define BT_NONE            0x00
00426 
00427 /* Custom button types - add our own between 0xB0 and 0xCF.
00428    This may need to be revised in the future,
00429    if stimuluses are ever added in this range. */
00430 #define BT_CUST_LINESPEEDDIAL    0xB0  /* line or speeddial */
00431 #define BT_CUST_HINT       0xB1  /* pipe dream */
00432 
00433 struct button_template_res_message {
00434    uint32_t buttonOffset;
00435    uint32_t buttonCount;
00436    uint32_t totalButtonCount;
00437    struct button_definition definition[42];
00438 };
00439 
00440 #define VERSION_RES_MESSAGE 0x0098
00441 struct version_res_message {
00442    char version[16];
00443 };
00444 
00445 #define DISPLAYTEXT_MESSAGE 0x0099
00446 struct displaytext_message {
00447    char text[40];
00448 };
00449 
00450 #define CLEAR_NOTIFY_MESSAGE  0x0115
00451 #define CLEAR_DISPLAY_MESSAGE 0x009A
00452 
00453 #define CAPABILITIES_REQ_MESSAGE 0x009B
00454 
00455 #define REGISTER_REJ_MESSAGE 0x009D
00456 struct register_rej_message {
00457    char errMsg[33];
00458 };
00459 
00460 #define SERVER_RES_MESSAGE 0x009E
00461 struct server_identifier {
00462    char serverName[48];
00463 };
00464 
00465 struct server_res_message {
00466    struct server_identifier server[5];
00467    uint32_t serverListenPort[5];
00468    uint32_t serverIpAddr[5];
00469 };
00470 
00471 #define RESET_MESSAGE 0x009F
00472 struct reset_message {
00473    uint32_t resetType;
00474 };
00475 
00476 #define KEEP_ALIVE_ACK_MESSAGE 0x0100
00477 
00478 #define OPEN_RECEIVE_CHANNEL_MESSAGE 0x0105
00479 struct open_receive_channel_message {
00480    uint32_t conferenceId;
00481    uint32_t partyId;
00482    uint32_t packets;
00483    uint32_t capability;
00484    uint32_t echo;
00485    uint32_t bitrate;
00486    uint32_t space[16];
00487 };
00488 
00489 #define CLOSE_RECEIVE_CHANNEL_MESSAGE 0x0106
00490 struct close_receive_channel_message {
00491    uint32_t conferenceId;
00492    uint32_t partyId;
00493    uint32_t space[2];
00494 };
00495 
00496 #define SOFT_KEY_TEMPLATE_RES_MESSAGE 0x0108
00497 
00498 struct soft_key_template_definition {
00499    char softKeyLabel[16];
00500    uint32_t softKeyEvent;
00501 };
00502 
00503 #define KEYDEF_ONHOOK         0
00504 #define KEYDEF_CONNECTED      1
00505 #define KEYDEF_ONHOLD         2
00506 #define KEYDEF_RINGIN         3
00507 #define KEYDEF_OFFHOOK        4
00508 #define KEYDEF_CONNWITHTRANS     5
00509 #define KEYDEF_DADFD       6 /* Digits After Dialing First Digit */
00510 #define KEYDEF_CONNWITHCONF      7
00511 #define KEYDEF_RINGOUT        8
00512 #define KEYDEF_OFFHOOKWITHFEAT      9
00513 #define KEYDEF_UNKNOWN        10
00514 
00515 #define SOFTKEY_NONE       0x00
00516 #define SOFTKEY_REDIAL        0x01
00517 #define SOFTKEY_NEWCALL       0x02
00518 #define SOFTKEY_HOLD       0x03
00519 #define SOFTKEY_TRNSFER       0x04
00520 #define SOFTKEY_CFWDALL       0x05
00521 #define SOFTKEY_CFWDBUSY      0x06
00522 #define SOFTKEY_CFWDNOANSWER     0x07
00523 #define SOFTKEY_BKSPC         0x08
00524 #define SOFTKEY_ENDCALL       0x09
00525 #define SOFTKEY_RESUME        0x0A
00526 #define SOFTKEY_ANSWER        0x0B
00527 #define SOFTKEY_INFO       0x0C
00528 #define SOFTKEY_CONFRN        0x0D
00529 #define SOFTKEY_PARK       0x0E
00530 #define SOFTKEY_JOIN       0x0F
00531 #define SOFTKEY_MEETME        0x10
00532 #define SOFTKEY_PICKUP        0x11
00533 #define SOFTKEY_GPICKUP       0x12
00534 
00535 struct soft_key_template_definition soft_key_template_default[] = {
00536    { "Redial",    0x01 },
00537    { "NewCall",      0x02 },
00538    { "Hold",      0x03 },
00539    { "Trnsfer",      0x04 },
00540    { "CFwdAll",      0x05 },
00541    { "CFwdBusy",     0x06 },
00542    { "CFwdNoAnswer", 0x07 },
00543    { "<<",        0x08 },
00544    { "EndCall",      0x09 },
00545    { "Resume",    0x0A },
00546    { "Answer",    0x0B },
00547    { "Info",      0x0C },
00548    { "Confrn",    0x0D },
00549    { "Park",      0x0E },
00550    { "Join",      0x0F },
00551    { "MeetMe",    0x10 },
00552    { "PickUp",    0x11 },
00553    { "GPickUp",      0x12 },
00554 };
00555 
00556 struct soft_key_definitions {
00557    const uint8_t mode;
00558    const uint8_t *defaults;
00559    const int count;
00560 };
00561 
00562 static const uint8_t soft_key_default_onhook[] = {
00563    SOFTKEY_REDIAL,
00564    SOFTKEY_NEWCALL,
00565    SOFTKEY_CFWDALL,
00566    SOFTKEY_CFWDBUSY,
00567    /*SOFTKEY_GPICKUP,
00568    SOFTKEY_CONFRN,*/
00569 };
00570 
00571 static const uint8_t soft_key_default_connected[] = {
00572    SOFTKEY_HOLD,
00573    SOFTKEY_ENDCALL,
00574    SOFTKEY_TRNSFER,
00575    SOFTKEY_PARK,
00576    SOFTKEY_CFWDALL,
00577    SOFTKEY_CFWDBUSY,
00578 };
00579 
00580 static const uint8_t soft_key_default_onhold[] = {
00581    SOFTKEY_RESUME,
00582    SOFTKEY_NEWCALL,
00583    SOFTKEY_ENDCALL,
00584    SOFTKEY_TRNSFER,
00585 };
00586 
00587 static const uint8_t soft_key_default_ringin[] = {
00588    SOFTKEY_ANSWER,
00589    SOFTKEY_ENDCALL,
00590    SOFTKEY_TRNSFER,
00591 };
00592 
00593 static const uint8_t soft_key_default_offhook[] = {
00594    SOFTKEY_REDIAL,
00595    SOFTKEY_ENDCALL,
00596    SOFTKEY_CFWDALL,
00597    SOFTKEY_CFWDBUSY,
00598    /*SOFTKEY_GPICKUP,*/
00599 };
00600 
00601 static const uint8_t soft_key_default_connwithtrans[] = {
00602    SOFTKEY_HOLD,
00603    SOFTKEY_ENDCALL,
00604    SOFTKEY_TRNSFER,
00605    SOFTKEY_PARK,
00606    SOFTKEY_CFWDALL,
00607    SOFTKEY_CFWDBUSY,
00608 };
00609 
00610 static const uint8_t soft_key_default_dadfd[] = {
00611    SOFTKEY_BKSPC,
00612    SOFTKEY_ENDCALL,
00613 };
00614 
00615 static const uint8_t soft_key_default_connwithconf[] = {
00616    SOFTKEY_NONE,
00617 };
00618 
00619 static const uint8_t soft_key_default_ringout[] = {
00620    SOFTKEY_NONE,
00621    SOFTKEY_ENDCALL,
00622 };
00623 
00624 static const uint8_t soft_key_default_offhookwithfeat[] = {
00625    SOFTKEY_REDIAL,
00626    SOFTKEY_ENDCALL,
00627 };
00628 
00629 static const uint8_t soft_key_default_unknown[] = {
00630    SOFTKEY_NONE,
00631 };
00632 
00633 static const struct soft_key_definitions soft_key_default_definitions[] = {
00634    {KEYDEF_ONHOOK, soft_key_default_onhook, sizeof(soft_key_default_onhook) / sizeof(uint8_t)},
00635    {KEYDEF_CONNECTED, soft_key_default_connected, sizeof(soft_key_default_connected) / sizeof(uint8_t)},
00636    {KEYDEF_ONHOLD, soft_key_default_onhold, sizeof(soft_key_default_onhold) / sizeof(uint8_t)},
00637    {KEYDEF_RINGIN, soft_key_default_ringin, sizeof(soft_key_default_ringin) / sizeof(uint8_t)},
00638    {KEYDEF_OFFHOOK, soft_key_default_offhook, sizeof(soft_key_default_offhook) / sizeof(uint8_t)},
00639    {KEYDEF_CONNWITHTRANS, soft_key_default_connwithtrans, sizeof(soft_key_default_connwithtrans) / sizeof(uint8_t)},
00640    {KEYDEF_DADFD, soft_key_default_dadfd, sizeof(soft_key_default_dadfd) / sizeof(uint8_t)},
00641    {KEYDEF_CONNWITHCONF, soft_key_default_connwithconf, sizeof(soft_key_default_connwithconf) / sizeof(uint8_t)},
00642    {KEYDEF_RINGOUT, soft_key_default_ringout, sizeof(soft_key_default_ringout) / sizeof(uint8_t)},
00643    {KEYDEF_OFFHOOKWITHFEAT, soft_key_default_offhookwithfeat, sizeof(soft_key_default_offhookwithfeat) / sizeof(uint8_t)},
00644    {KEYDEF_UNKNOWN, soft_key_default_unknown, sizeof(soft_key_default_unknown) / sizeof(uint8_t)}
00645 };
00646 
00647 struct soft_key_template_res_message {
00648    uint32_t softKeyOffset;
00649    uint32_t softKeyCount;
00650    uint32_t totalSoftKeyCount;
00651    struct soft_key_template_definition softKeyTemplateDefinition[32];
00652 };
00653 
00654 #define SOFT_KEY_SET_RES_MESSAGE 0x0109
00655 
00656 struct soft_key_set_definition {
00657    uint8_t softKeyTemplateIndex[16];
00658    uint16_t softKeyInfoIndex[16];
00659 };
00660 
00661 struct soft_key_set_res_message {
00662    uint32_t softKeySetOffset;
00663    uint32_t softKeySetCount;
00664    uint32_t totalSoftKeySetCount;
00665    struct soft_key_set_definition softKeySetDefinition[16];
00666    uint32_t res;
00667 };
00668 
00669 #define SELECT_SOFT_KEYS_MESSAGE 0x0110
00670 struct select_soft_keys_message {
00671    uint32_t instance;
00672    uint32_t reference;
00673    uint32_t softKeySetIndex;
00674    uint32_t validKeyMask;
00675 };
00676 
00677 #define CALL_STATE_MESSAGE 0x0111
00678 struct call_state_message {
00679    uint32_t callState;
00680    uint32_t lineInstance;
00681    uint32_t callReference;
00682    uint32_t space[3];
00683 };
00684 
00685 #define DISPLAY_PROMPT_STATUS_MESSAGE 0x0112
00686 struct display_prompt_status_message {
00687    uint32_t messageTimeout;
00688    char promptMessage[32];
00689    uint32_t lineInstance;
00690    uint32_t callReference;
00691 };
00692 
00693 #define CLEAR_PROMPT_MESSAGE  0x0113
00694 struct clear_prompt_message {
00695        uint32_t lineInstance;
00696        uint32_t callReference;
00697 };
00698 
00699 #define DISPLAY_NOTIFY_MESSAGE 0x0114
00700 struct display_notify_message {
00701    uint32_t displayTimeout;
00702    char displayMessage[100];
00703 };
00704 
00705 #define ACTIVATE_CALL_PLANE_MESSAGE 0x0116
00706 struct activate_call_plane_message {
00707    uint32_t lineInstance;
00708 };
00709 
00710 #define DIALED_NUMBER_MESSAGE 0x011D
00711 struct dialed_number_message {
00712    char dialedNumber[24];
00713    uint32_t lineInstance;
00714    uint32_t callReference;
00715 };
00716 
00717 union skinny_data {
00718    struct alarm_message alarm;
00719    struct speed_dial_stat_req_message speeddialreq;
00720    struct register_message reg;
00721    struct register_ack_message regack;
00722    struct register_rej_message regrej;
00723    struct capabilities_res_message caps;
00724    struct version_res_message version;
00725    struct button_template_res_message buttontemplate;
00726    struct displaytext_message displaytext;
00727    struct display_prompt_status_message displaypromptstatus;
00728    struct clear_prompt_message clearpromptstatus;
00729    struct definetimedate_message definetimedate;
00730    struct start_tone_message starttone;
00731    struct stop_tone_message stoptone;
00732    struct speed_dial_stat_res_message speeddial;
00733    struct line_state_req_message line;
00734    struct line_stat_res_message linestat;
00735    struct soft_key_set_res_message softkeysets;
00736    struct soft_key_template_res_message softkeytemplate;
00737    struct server_res_message serverres;
00738    struct reset_message reset;
00739    struct set_lamp_message setlamp;
00740    struct set_ringer_message setringer;
00741    struct call_state_message callstate;
00742    struct keypad_button_message keypad;
00743    struct select_soft_keys_message selectsoftkey;
00744    struct activate_call_plane_message activatecallplane;
00745    struct stimulus_message stimulus;
00746    struct offhook_message offhook;
00747    struct onhook_message onhook;
00748    struct set_speaker_message setspeaker;
00749    struct set_microphone_message setmicrophone;
00750    struct call_info_message callinfo;
00751    struct start_media_transmission_message startmedia;
00752    struct stop_media_transmission_message stopmedia;
00753    struct open_receive_channel_message openreceivechannel;
00754    struct open_receive_channel_ack_message openreceivechannelack;
00755    struct close_receive_channel_message closereceivechannel;
00756    struct display_notify_message displaynotify;
00757    struct dialed_number_message dialednumber;
00758    struct soft_key_event_message softkeyeventmessage;
00759    struct enbloc_call_message enbloccallmessage;
00760 };
00761 
00