forked from voipmonitor/sniffer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
skinny.cpp
8344 lines (7444 loc) · 257 KB
/
skinny.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
#include <sys/ioctl.h>
#include <net/if.h>
#include <fcntl.h>
#include <netdb.h>
#include <arpa/inet.h>
#include <sys/signal.h>
#include <signal.h>
#include <ctype.h>
#include <pcap.h>
#include <syslog.h>
#include <sys/param.h>
#include <string.h>
#include "flags.h"
#include "codecs.h"
#include "calltable.h"
#include "sniff.h"
#include "voipmonitor.h"
#include "filter_mysql.h"
#include "hash.h"
#include "rtp.h"
#include "rtcp.h"
#include "md5.h"
#include "tools.h"
#include "mirrorip.h"
#include "ipaccount.h"
#include "sql_db.h"
#include "rtp.h"
#include "skinny.h"
extern Calltable *calltable;
extern volatile int calls_counter;
extern int opt_saveSIP; // save SIP packets to pcap file?
extern int opt_saveRTP; // save RTP packets to pcap file?
extern int opt_saveRTCP; // save RTCP packets to pcap file?
extern int opt_saveRAW;
extern int opt_saveWAV;
extern int opt_packetbuffered; // Make .pcap files writing ‘‘packet-buffered’’
extern int opt_rtcp; // Make .pcap files writing ‘‘packet-buffered’’
extern int verbosity;
extern int opt_rtp_firstleg;
extern int opt_sip_register;
extern int opt_norecord_header;
extern int opt_convert_dlt_sll_to_en10;
extern char *sipportmatrix;
extern pcap_t *global_pcap_handle;
extern pcap_t *global_pcap_handle_dead_EN10MB;
extern rtp_read_thread *rtp_threads;
extern int opt_norecord_dtmf;
extern int opt_onlyRTPheader;
extern int opt_sipoverlap;
extern int readend;
extern int opt_dup_check;
extern char opt_match_header[128];
extern int opt_domainport;
extern int opt_mirrorip;
extern int opt_mirrorall;
extern int opt_mirroronly;
extern char opt_scanpcapdir[2048];
extern int opt_ipaccount;
extern int rtp_threaded;
extern int opt_rtpnosip;
extern char opt_cachedir[1024];
extern int opt_savewav_force;
extern int opt_saveudptl;
extern nat_aliases_t nat_aliases;
extern pcap_packet *qring;
extern volatile unsigned int readit;
extern volatile unsigned int writeit;
extern unsigned int qringmax;
extern int opt_id_sensor;
extern int global_pcap_dlink;
extern int opt_udpfrag;
extern int global_livesniffer;
extern int opt_pcap_split;
extern int opt_newdir;
extern int opt_callslimit;
extern int opt_skiprtpdata;
extern char opt_silencedmtfseq[16];
extern int opt_skinny;
extern unsigned int opt_skinny_ignore_rtpip;
extern int opt_saverfc2833;
extern IPfilter *ipfilter;
/* Skinny debugging only available if asterisk configured with --enable-dev-mode */
#define AST_DEVMODE 1
#ifdef AST_DEVMODE
static int skinnydebug = 0;
char dbgcli_buf[256];
char dbgreg_buf[256];
char dbgsub_buf[256];
#define DEBUG_GENERAL (1 << 1)
#define DEBUG_SUB (1 << 2)
#define DEBUG_PACKET (1 << 3)
#define DEBUG_AUDIO (1 << 4)
#define DEBUG_LOCK (1 << 5)
#define DEBUG_TEMPLATE (1 << 6)
#define DEBUG_THREAD (1 << 7)
#define DEBUG_HINT (1 << 8)
#define SKINNY_DEBUG(type, verb_level, text, ...) \
do{ \
if (skinnydebug) { \
syslog(LOG_NOTICE, text, ##__VA_ARGS__); \
} \
}while(0)
#else
#define SKINNY_DEBUG(type, verb_level, text, ...)
#endif
/*************************************
* Skinny/Asterisk Protocol Settings *
*************************************/
static const char tdesc[] = "Skinny Client Control Protocol (Skinny)";
static const char config[] = "skinny.conf";
enum skinny_codecs {
SKINNY_CODEC_ALAW = 2,
SKINNY_CODEC_ULAW = 4,
SKINNY_CODEC_G723_1 = 9,
SKINNY_CODEC_G729A = 12,
SKINNY_CODEC_G726_32 = 82, /* XXX Which packing order does this translate to? */
SKINNY_CODEC_H261 = 100,
SKINNY_CODEC_H263 = 101
};
#define DEFAULT_SKINNY_PORT 2000
#define DEFAULT_SKINNY_BACKLOG 2
#define SKINNY_MAX_PACKET 2000
#define DEFAULT_AUTH_TIMEOUT 30
#define DEFAULT_AUTH_LIMIT 50
/*
static struct {
unsigned int tos;
unsigned int tos_audio;
unsigned int tos_video;
unsigned int cos;
unsigned int cos_audio;
unsigned int cos_video;
} qos = { 0, 0, 0, 0, 0, 0 };
*/
#if __BYTE_ORDER == __LITTLE_ENDIAN
#define letohl(x) (x)
#define letohs(x) (x)
#define htolel(x) (x)
#define htoles(x) (x)
#else
#if defined(HAVE_BYTESWAP_H)
#include <byteswap.h>
#define letohl(x) bswap_32(x)
#define letohs(x) bswap_16(x)
#define htolel(x) bswap_32(x)
#define htoles(x) bswap_16(x)
#elif defined(HAVE_SYS_ENDIAN_SWAP16)
#include <sys/endian.h>
#define letohl(x) __swap32(x)
#define letohs(x) __swap16(x)
#define htolel(x) __swap32(x)
#define htoles(x) __swap16(x)
#elif defined(HAVE_SYS_ENDIAN_BSWAP16)
#include <sys/endian.h>
#define letohl(x) bswap32(x)
#define letohs(x) bswap16(x)
#define htolel(x) bswap32(x)
#define htoles(x) bswap16(x)
#else
#define __bswap_16(x) \
((((x) & 0xff00) >> 8) | \
(((x) & 0x00ff) << 8))
#define __bswap_32(x) \
((((x) & 0xff000000) >> 24) | \
(((x) & 0x00ff0000) >> 8) | \
(((x) & 0x0000ff00) << 8) | \
(((x) & 0x000000ff) << 24))
#define letohl(x) __bswap_32(x)
#define letohs(x) __bswap_16(x)
#define htolel(x) __bswap_32(x)
#define htoles(x) __bswap_16(x)
#endif
#endif
#ifdef AST_DEVMODE
//AST_THREADSTORAGE(message2str_threadbuf);
#define MESSAGE2STR_BUFSIZE 35
#endif
//AST_THREADSTORAGE(device2str_threadbuf);
#define DEVICE2STR_BUFSIZE 15
//AST_THREADSTORAGE(control2str_threadbuf);
#define CONTROL2STR_BUFSIZE 100
//AST_THREADSTORAGE(substate2str_threadbuf);
#define SUBSTATE2STR_BUFSIZE 15
//AST_THREADSTORAGE(callstate2str_threadbuf);
#define CALLSTATE2STR_BUFSIZE 15
/*********************
* 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;
uint32_t instance;
uint32_t ip;
uint32_t type;
uint32_t maxStreams;
uint32_t space;
uint8_t protocolVersion;
/*! \brief space2 is used for newer version of skinny */
char space2[3];
};
#define IP_PORT_MESSAGE 0x0002
#define KEYPAD_BUTTON_MESSAGE 0x0003
struct keypad_button_message {
uint32_t button;
uint32_t lineInstance;
uint32_t callReference;
};
#define ENBLOC_CALL_MESSAGE 0x0004
struct enbloc_call_message {
char calledParty[24];
};
#define STIMULUS_MESSAGE 0x0005
struct stimulus_message {
uint32_t stimulus;
uint32_t stimulusInstance;
uint32_t callreference;
};
#define OFFHOOK_MESSAGE 0x0006
struct offhook_message {
uint32_t instance;
uint32_t reference;
};
#define ONHOOK_MESSAGE 0x0007
struct onhook_message {
uint32_t instance;
uint32_t reference;
};
#define CAPABILITIES_RES_MESSAGE 0x0010
struct station_capabilities {
uint32_t codec; /* skinny codec, not ast codec */
uint32_t frames;
union {
char res[8];
uint32_t rate;
} payloads;
};
#define SKINNY_MAX_CAPABILITIES 18
struct capabilities_res_message {
uint32_t count;
struct station_capabilities caps[SKINNY_MAX_CAPABILITIES];
};
#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];
uint32_t alarmParam1;
uint32_t alarmParam2;
};
#define OPEN_RECEIVE_CHANNEL_ACK_MESSAGE 0x0022
struct open_receive_channel_ack_message_ip4_ver {
uint32_t status;
uint32_t ipVer;
uint32_t ipAddr;
char garbage[12];
uint32_t port;
uint32_t callReference;
};
struct open_receive_channel_ack_message_ip4 {
uint32_t status;
uint32_t ipAddr;
uint32_t port;
uint32_t callReference;
};
struct open_receive_channel_ack_message_ip6 {
uint32_t status;
uint32_t space;
char ipAddr[16];
uint32_t port;
uint32_t callReference;
};
#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 callreference;
};
#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];
char res[2];
uint32_t secondaryKeepAlive;
char res2[4];
};
#define START_TONE_MESSAGE 0x0082
struct start_tone_message {
uint32_t tone;
uint32_t space;
uint32_t instance;
uint32_t reference;
};
#define STOP_TONE_MESSAGE 0x0083
struct stop_tone_message {
uint32_t instance;
uint32_t reference;
uint32_t space;
};
#define SET_RINGER_MESSAGE 0x0085
struct set_ringer_message {
uint32_t ringerMode;
uint32_t unknown1; /* See notes in transmit_ringer_mode */
uint32_t unknown2;
uint32_t space[2];
};
#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;
uint32_t packets;
uint32_t bitRate;
};
struct start_media_transmission_message_ip4 {
uint32_t conferenceId;
uint32_t passThruPartyId;
uint32_t remoteIp;
uint32_t remotePort;
uint32_t packetSize;
uint32_t payloadType;
struct media_qualifier qualifier;
uint32_t space[19];
};
struct CM7_start_media_transmission_message_ip4 {
uint32_t conferenceId;
uint32_t passThruPartyId;
uint32_t ipVersion;
uint32_t remoteIp;
char garbage[12];
uint32_t remotePort;
uint32_t packetSize;
uint32_t payloadType;
};
struct start_media_transmission_message_ip6 {
uint32_t conferenceId;
uint32_t passThruPartyId;
uint32_t space;
char remoteIp[16];
uint32_t remotePort;
uint32_t packetSize;
uint32_t payloadType;
struct media_qualifier qualifier;
/*! \brief space2 is used for newer version of skinny */
uint32_t space2[19];
};
#define STOP_MEDIA_TRANSMISSION_MESSAGE 0x008B
struct stop_media_transmission_message {
uint32_t conferenceId;
uint32_t passThruPartyId;
uint32_t space[3];
};
#define CM5CALL_INFO_MESSAGE 0x014A
struct cm5call_info_message {
uint32_t instance;
uint32_t reference;
uint32_t type;
char unknown[20];
#if 0
char callingParty[5];
char calledParty[5];
char originalCalledParty[5];
char lastRedirectingParty[5];
char callingPartyVoiceMailbox[5];
char calledPartyVoiceMailbox[5];
char originalCalledPartyVoiceMailbox[5];
char lastRedirectingVoiceMailbox[5];
char callingPartyName[1];
char calledPartyName[14];
char originalCalledPartyName[14];
char lastRedirectingPartyName[14];
#endif
/*
uint32_t originalCalledPartyRedirectReason;
uint32_t lastRedirectingReason;
uint32_t space[3];
*/
};
#define CALL_INFO_MESSAGE 0x008F
struct call_info_message {
char callingPartyName[40];
char callingParty[24];
char calledPartyName[40];
char calledParty[24];
uint32_t instance;
uint32_t reference;
uint32_t type;
char originalCalledPartyName[40];
char originalCalledParty[24];
char lastRedirectingPartyName[40];
char lastRedirectingParty[24];
uint32_t originalCalledPartyRedirectReason;
uint32_t lastRedirectingReason;
char callingPartyVoiceMailbox[24];
char calledPartyVoiceMailbox[24];
char originalCalledPartyVoiceMailbox[24];
char lastRedirectingVoiceMailbox[24];
uint32_t space[3];
};
#define FORWARD_STAT_MESSAGE 0x0090
struct forward_stat_message {
uint32_t activeforward;
uint32_t lineNumber;
uint32_t fwdall;
char fwdallnum[24];
uint32_t fwdbusy;
char fwdbusynum[24];
uint32_t fwdnoanswer;
char fwdnoanswernum[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];
char lineDisplayName[24];
uint32_t space[15];
};
#define DEFINETIMEDATE_MESSAGE 0x0094
struct definetimedate_message {
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;
};
#define BUTTON_TEMPLATE_RES_MESSAGE 0x0097
struct button_definition {
uint8_t instanceNumber;
uint8_t buttonDefinition;
};
struct button_definition_template {
uint8_t buttonDefinition;
/* for now, anything between 0xB0 and 0xCF is custom */
/*int custom;*/
};
#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_DND 0x3F
#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_DND STIMULUS_DND
#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 with/without hint */
#define BT_CUST_LINE 0xB1 /* line or speeddial with hint only */
struct button_template_res_message {
uint32_t buttonOffset;
uint32_t buttonCount;
uint32_t totalButtonCount;
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_DISPLAY_MESSAGE 0x009A
struct clear_display_message {
uint32_t space;
};
#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];
};
struct server_res_message {
struct server_identifier server[5];
uint32_t serverListenPort[5];
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;
uint32_t packets;
uint32_t capability;
uint32_t echo;
uint32_t bitrate;
uint32_t space[36];
};
#define CLOSE_RECEIVE_CHANNEL_MESSAGE 0x0106
struct close_receive_channel_message {
uint32_t conferenceId;
uint32_t partyId;
uint32_t space[2];
};
#define SOFT_KEY_TEMPLATE_RES_MESSAGE 0x0108
struct soft_key_template_definition {
char softKeyLabel[16];
uint32_t softKeyEvent;
};
#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 KEYDEF_SLAHOLD 11
#define KEYDEF_SLACONNECTEDNOTACTIVE 12
#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
#define SOFTKEY_DND 0x13
#define SOFTKEY_IDIVERT 0x14
/*
static struct soft_key_template_definition soft_key_template_default[] = {
{ "\200\001", SOFTKEY_REDIAL },
{ "\200\002", SOFTKEY_NEWCALL },
{ "\200\003", SOFTKEY_HOLD },
{ "\200\004", SOFTKEY_TRNSFER },
{ "\200\005", SOFTKEY_CFWDALL },
{ "\200\006", SOFTKEY_CFWDBUSY },
{ "\200\007", SOFTKEY_CFWDNOANSWER },
{ "\200\010", SOFTKEY_BKSPC },
{ "\200\011", SOFTKEY_ENDCALL },
{ "\200\012", SOFTKEY_RESUME },
{ "\200\013", SOFTKEY_ANSWER },
{ "\200\014", SOFTKEY_INFO },
{ "\200\015", SOFTKEY_CONFRN },
{ "\200\016", SOFTKEY_PARK },
{ "\200\017", SOFTKEY_JOIN },
{ "\200\020", SOFTKEY_MEETME },
{ "\200\021", SOFTKEY_PICKUP },
{ "\200\022", SOFTKEY_GPICKUP },
{ "\200\077", SOFTKEY_DND },
{ "\200\120", SOFTKEY_IDIVERT },
};
*/
/* Localized message "codes" (in octal)
Below is en_US (taken from a 7970)
\200\xxx
\000: ???
\001: Redial
\002: New Call
\003: Hold
\004: Transfer
\005: CFwdALL
\006: CFwdBusy
\007: CFwdNoAnswer
\010: <<
\011: EndCall
\012: Resume
\013: Answer
\014: Info
\015: Confrn
\016: Park
\017: Join
\020: MeetMe
\021: PickUp
\022: GPickUp
\023: Your current options
\024: Off Hook
\025: On Hook
\026: Ring out
\027: From
\030: Connected
\031: Busy
\032: Line In Use
\033: Call Waiting
\034: Call Transfer
\035: Call Park
\036: Call Proceed
\037: In Use Remote
\040: Enter number
\041: Call park At
\042: Primary Only
\043: Temp Fail
\044: You Have VoiceMail
\045: Forwarded to
\046: Can Not Complete Conference
\047: No Conference Bridge
\050: Can Not Hold Primary Control
\051: Invalid Conference Participant
\052: In Conference Already
\053: No Participant Info
\054: Exceed Maximum Parties
\055: Key Is Not Active
\056: Error No License
\057: Error DBConfig
\060: Error Database
\061: Error Pass Limit
\062: Error Unknown
\063: Error Mismatch
\064: Conference
\065: Park Number
\066: Private
\067: Not Enough Bandwidth
\070: Unknown Number
\071: RmLstC
\072: Voicemail
\073: ImmDiv
\074: Intrcpt
\075: SetWtch
\076: TrnsfVM
\077: DND
\100: DivAll
\101: CallBack
\102: Network congestion,rerouting
\103: Barge
\104: Failed to setup Barge
\105: Another Barge exists
\106: Incompatible device type
\107: No Park Number Available
\110: CallPark Reversion
\111: Service is not Active
\112: High Traffic Try Again Later
\113: QRT
\114: MCID
\115: DirTrfr
\116: Select
\117: ConfList
\120: iDivert
\121: cBarge
\122: Can Not Complete Transfer
\123: Can Not Join Calls
\124: Mcid Successful
\125: Number Not Configured
\126: Security Error
\127: Video Bandwidth Unavailable
\130: VidMode
\131: Max Call Duration Timeout
\132: Max Hold Duration Timeout
\133: OPickUp
\134: ???
\135: ???
\136: ???
\137: ???
\140: ???
\141: External Transfer Restricted
\142: ???
\143: ???
\144: ???
\145: Mac Address
\146: Host Name
\147: Domain Name
\150: IP Address
\151: Subnet Mask
\152: TFTP Server 1
\153: Default Router 1
\154: Default Router 2
\155: Default Router 3
\156: Default Router 4
\157: Default Router 5
\160: DNS Server 1
\161: DNS Server 2
\162: DNS Server 3
\163: DNS Server 4
\164: DNS Server 5
\165: Operational VLAN Id
\166: Admin. VLAN Id
\167: CallManager 1
\170: CallManager 2
\171: CallManager 3
\172: CallManager 4
\173: CallManager 5
\174: Information URL
\175: Directories URL
\176: Messages URL
\177: Services URL
*/
struct soft_key_definitions {
const uint8_t mode;
const uint8_t *defaults;
const int count;
};
static const uint8_t soft_key_default_onhook[] = {
SOFTKEY_REDIAL,
SOFTKEY_NEWCALL,
SOFTKEY_CFWDALL,
SOFTKEY_CFWDBUSY,
SOFTKEY_DND,
/*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_NONE,
SOFTKEY_ENDCALL,
};
static const uint8_t soft_key_default_offhookwithfeat[] = {
SOFTKEY_REDIAL,
SOFTKEY_ENDCALL,
SOFTKEY_TRNSFER,
};
static const uint8_t soft_key_default_unknown[] = {
SOFTKEY_NONE,
};
static const uint8_t soft_key_default_SLAhold[] = {
SOFTKEY_REDIAL,
SOFTKEY_NEWCALL,
SOFTKEY_RESUME,
};
static const uint8_t soft_key_default_SLAconnectednotactive[] = {
SOFTKEY_REDIAL,
SOFTKEY_NEWCALL,
SOFTKEY_JOIN,
};
static const struct 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)},
{KEYDEF_SLAHOLD, soft_key_default_SLAhold, sizeof(soft_key_default_SLAhold) / sizeof(uint8_t)},
{KEYDEF_SLACONNECTEDNOTACTIVE, soft_key_default_SLAconnectednotactive, sizeof(soft_key_default_SLAconnectednotactive) / sizeof(uint8_t)}
};
struct soft_key_template_res_message {
uint32_t softKeyOffset;
uint32_t softKeyCount;
uint32_t totalSoftKeyCount;
struct soft_key_template_definition softKeyTemplateDefinition[32];
};
#define SOFT_KEY_SET_RES_MESSAGE 0x0109
struct soft_key_set_definition {
uint8_t softKeyTemplateIndex[16];
uint16_t softKeyInfoIndex[16];
};
struct soft_key_set_res_message {
uint32_t softKeySetOffset;
uint32_t softKeySetCount;
uint32_t totalSoftKeySetCount;
struct soft_key_set_definition softKeySetDefinition[16];
uint32_t res;
};
#define SELECT_SOFT_KEYS_MESSAGE 0x0110
struct select_soft_keys_message {
uint32_t instance;
uint32_t reference;
uint32_t softKeySetIndex;
uint32_t validKeyMask;
};
#define CALL_STATE_MESSAGE 0x0111
struct call_state_message {
uint32_t callState;
uint32_t lineInstance;
uint32_t callReference;
uint32_t space[3];
};
#define DISPLAY_PROMPT_STATUS_MESSAGE 0x0112
struct display_prompt_status_message {
uint32_t messageTimeout;
char promptMessage[32];
uint32_t lineInstance;