44#if defined(__CYGWIN__) || defined(__NetBSD__)
83#define DEFAULTCONTEXT "default"
84#define DEFAULTCALLERID "Unknown"
85#define DEFAULTCALLERNAME " "
86#define DEFAULTHEIGHT 3
87#define USTM_LOG_DIR "unistimHistory"
88#define USTM_LANG_DIR "unistimLang"
91#define MAX_BUF_SIZE 64
93#define MAX_BUF_NUMBER 150
95#define MAX_SCREEN_NUMBER 15
97#define MONTH_LABEL_SIZE 3
99#define NB_MAX_RETRANSMIT 8
101#define IDLE_WAIT 1000
103#define RETRANSMIT_TIMER 2000
105#define TIMER_MWI 5000
107#define DEFAULT_INTERDIGIT_TIMER 4000
110#define DEFAULT_CODEC 0x00
111#define SIZE_PAGE 4096
112#define DEVICE_NAME_LEN 16
113#define AST_CONFIG_MAX_PATH 255
114#define MAX_ENTRY_LOG 30
118#define SUB_THREEWAY 2
138#define OUTPUT_HANDSET 0xC0
139#define OUTPUT_HEADPHONE 0xC1
140#define OUTPUT_SPEAKER 0xC2
142#define VOLUME_LOW 0x01
143#define VOLUME_LOW_SPEAKER 0x03
144#define VOLUME_NORMAL 0x02
145#define VOLUME_INSANELY_LOUD 0x07
149#define MUTE_ON_DISCRET 0xCE
151#define LED_BAR_OFF 0x00
152#define LED_BAR_ON 0x01
153#define LED_BAR_P2 0x02
154#define LED_BAR_P3 0x03
155#define LED_BAR_P4 0x04
156#define LED_BAR_P5 0x05
157#define LED_BAR_P6 0x06
158#define LED_BAR_P7 0x07
159#define LED_SPEAKER_OFF 0x08
160#define LED_SPEAKER_ON 0x09
161#define LED_HEADPHONE_OFF 0x010
162#define LED_HEADPHONE_ON 0x011
163#define LED_MUTE_OFF 0x018
164#define LED_MUTE_ON 0x019
165#define LED_MUTE_BLINK 0x1A
168#define SIZE_MAC_ADDR 17
169#define TEXT_LENGTH_MAX 24
170#define TEXT_LINE0 0x00
171#define TEXT_LINE1 0x20
172#define TEXT_LINE2 0x40
173#define TEXT_NORMAL 0x05
174#define TEXT_INVERSE 0x25
175#define STATUS_LENGTH_MAX 28
177#define FAV_ICON_NONE 0x00
178#define FAV_ICON_ONHOOK_BLACK 0x20
179#define FAV_ICON_ONHOOK_WHITE 0x21
180#define FAV_ICON_SPEAKER_ONHOOK_BLACK 0x22
181#define FAV_ICON_SPEAKER_ONHOOK_WHITE 0x23
182#define FAV_ICON_OFFHOOK_BLACK 0x24
183#define FAV_ICON_OFFHOOK_WHITE 0x25
184#define FAV_ICON_ONHOLD_BLACK 0x26
185#define FAV_ICON_ONHOLD_WHITE 0x27
186#define FAV_ICON_SPEAKER_OFFHOOK_BLACK 0x28
187#define FAV_ICON_SPEAKER_OFFHOOK_WHITE 0x29
188#define FAV_ICON_PHONE_BLACK 0x2A
189#define FAV_ICON_PHONE_WHITE 0x2B
190#define FAV_ICON_SPEAKER_ONHOLD_BLACK 0x2C
191#define FAV_ICON_SPEAKER_ONHOLD_WHITE 0x2D
192#define FAV_ICON_HEADPHONES 0x2E
193#define FAV_ICON_HEADPHONES_ONHOLD 0x2F
194#define FAV_ICON_HOME 0x30
195#define FAV_ICON_CITY 0x31
196#define FAV_ICON_SHARP 0x32
197#define FAV_ICON_PAGER 0x33
198#define FAV_ICON_CALL_CENTER 0x34
199#define FAV_ICON_FAX 0x35
200#define FAV_ICON_MAILBOX 0x36
201#define FAV_ICON_REFLECT 0x37
202#define FAV_ICON_COMPUTER 0x38
203#define FAV_ICON_FORWARD 0x39
204#define FAV_ICON_LOCKED 0x3A
205#define FAV_ICON_TRASH 0x3B
206#define FAV_ICON_INBOX 0x3C
207#define FAV_ICON_OUTBOX 0x3D
208#define FAV_ICON_MEETING 0x3E
209#define FAV_ICON_BOX 0x3F
211#define FAV_BLINK_FAST 0x20
212#define FAV_BLINK_SLOW 0x40
214#define FAV_MAX_LENGTH 0x0A
218#define FAV_LINE_ICON FAV_ICON_ONHOOK_BLACK
231 .resync_threshold = 1000,
241#define DEBUG_TIMER dummy
345static const int dtmf_row[] = { 697, 770, 852, 941 };
346static const float dtmf_col[] = { 1209, 1336, 1477, 1633 };
458#define MAX_PHONE_NUMBER_LENGTH (AST_MAX_EXTENSION - 1)
509 { 0xff, 0xff, 0xff, 0xff, 0x02, 0x02, 0xff, 0xff, 0xff, 0xff, 0x9e, 0x03, 0x08 };
511 { 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 };
514 { 0x00, 0x00, 0x00, 0x13, 0x9a, 0x0a, 0x02 };
516 { 0x00, 0x00, 0x00, 0x13, 0x9a, 0x04, 0x03 };
518 { 0x00, 0x00, 0x00, 0x13, 0x99, 0x04, 0x00 };
520 { 0x00, 0x00, 0x00, 0x13, 0x99, 0x03, 0x04 };
522 { 0x00, 0x00, 0x00, 0x13, 0x99, 0x03, 0x03 };
523static const unsigned char packet_recv_r2[] = { 0x00, 0x00, 0x00, 0x13, 0x96, 0x03, 0x03 };
527 { 0x00, 0x00, 0x00, 0x13, 0x89, 0x04, 0x59 };
531 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20 };
536 { 0xff, 0xff, 0xff, 0xff, 0x9e, 0x03, 0x08 };
538 { 0xff, 0xff, 0xff, 0xff, 0x9a, 0x0d, 0x07 };
541 { 0x11, 0x09, 0x02, 0x02, 0x05, 0x06, 0x07,
545 { 0x11, 0x09, 0x02, 0x0a, 0x05, 0x06, 0x07,
5460x08, 0x32, 0x17, 0x04, 0x24, 0x07, 0x19,
547 0x04, 0x07, 0x00, 0x19, 0x05, 0x09, 0x3e, 0x0f, 0x16, 0x05, 0x00, 0x80, 0x00, 0x1e,
548 0x05, 0x12, 0x00, 0x78
552 { 0x16, 0x04, 0x1a, 0x00, 0x16, 0x04, 0x11, 0x00 };
554 { 0x16, 0x04, 0x1a, 0x00, 0x16, 0x04, 0x11, 0x00, 0x16, 0x06, 0x32, 0xdf, 0x00, 0xff,
5550x16, 0x05, 0x1c, 0x00, 0x00, 0x17, 0x05,
556 0x0b, 0x00, 0x00, 0x19, 0x04, 0x00, 0x00, 0x19, 0x04, 0x00, 0x08, 0x19, 0x04, 0x00,
557 0x10, 0x19, 0x04, 0x00, 0x18, 0x16, 0x05,
558 0x31, 0x00, 0x00, 0x16, 0x05, 0x04, 0x00, 0x00
561 { 0x16, 0x04, 0x1a, 0x00, 0x16, 0x04, 0x11, 0x00, 0x16, 0x06, 0x32, 0xdf,
562 0x00, 0xff, 0x16, 0x05, 0x1c, 0x00, 0x00, 0x16, 0x0a, 0x38, 0x00, 0x12, 0xca, 0x03,
563 0xc0, 0xc3, 0xc5, 0x16, 0x16, 0x30, 0x00,
564 0x00, 0x12, 0x12, 0x01, 0x5c, 0x00,
565 0x0f, 0xa0, 0x9c, 0x41,
566 0x0f, 0xa0, 0x9c, 0x41, 0x0a, 0x01,
570 { 0x16, 0x05, 0x1c, 0x00, 0x00 };
574static const unsigned char packet_send_CloseAudioStreamRX[] = { 0x16, 0x05, 0x31, 0x00, 0xff };
575static const unsigned char packet_send_CloseAudioStreamTX[] = { 0x16, 0x05, 0x31, 0xff, 0x00 };
578 { 0x16, 0x06, 0x1b, 0x00, 0x00, 0x05 };
580 { 0x16, 0x06, 0x1d, 0x00, 0x01, 0xb8 };
582 { 0x16, 0x08, 0x1d, 0x00, 0x01, 0xb8, 0x01, 0x5e };
584 { 0x16, 0x06, 0x32, 0xc0, 0x01, 0x00 };
587 { 0x16, 0x06, 0x32, 0xdf, 0x00, 0xff, 0x16, 0x05, 0x1c, 0x00, 0x00, 0x16,
588 0x04, 0x1a, 0x01, 0x16, 0x05, 0x12, 0x13 , 0x18, 0x16, 0x04, 0x18,
589 0x20, 0x16, 0x04, 0x10, 0x00
595 { 0x16, 0x06, 0x32, 0xdf, 0x00, 0xff, 0x16, 0x05, 0x31, 0x00, 0x00, 0x16, 0x04, 0x37, 0x10 };
597 { 0x16, 0x06, 0x32, 0xdf, 0x00, 0xff, 0x19, 0x04, 0x00, 0x10, 0x16, 0x05, 0x1c, 0x00,
600 { 0x16, 0x08, 0x38, 0x00, 0x00, 0xe0, 0x00, 0xa0 };
602 { 0x16, 0x0e, 0x3a, 0x00, 0x02, 0x04, 0x00, 0x00,
604 0x00, 0x00, 0x3e, 0x80
611 { 0x16, 0x1a, 0x30, 0x00, 0xff, 0x00, 0x00, 0x01, 0x00, 0xb8, 0xb8, 0x0e,
6120x0e, 0x01, 0x14, 0x50, 0x00,
613 0x00, 0x14, 0x50, 0x00, 0x00, 0x0a, 0x93, 0x69, 0x05
616 { 0x16, 0x1a, 0x30, 0xff, 0x00, 0x00, 0x00, 0x01, 0x00, 0xb8, 0xb8, 0x0e,
6170x0e, 0x01, 0x14, 0x50,
618 0x00, 0x00, 0x14, 0x50, 0x00, 0x00, 0x0a, 0x93, 0x69, 0x05
622 { 0x16, 0x1a, 0x30, 0x00, 0xff, 0x00, 0x00, 0x02, 0x01, 0xb8, 0xb8, 0x06,
6230x06, 0x81, 0x14, 0x50,
625 0x51, 0x14, 0x50, 0x00, 0x00, 0x0a, 0x93,
629 { 0x16, 0x1a, 0x30, 0xff, 0x00, 0x00, 0x00, 0x02, 0x01, 0xb8, 0xb8, 0x06,
6300x06, 0x81, 0x14, 0x50,
631 0x00, 0x00, 0x14, 0x50, 0x00, 0x00,
632 0x0a, 0x93, 0x69, 0x05
638 0x06, 0x07, 0x08, 0x32
641 { 0x17, 0x04, 0x24, 0x08 };
643 { 0x17, 0x05, 0x0b, 0x05, 0x00, 0x17, 0x08, 0x16,
644 'T',
'i',
'm',
'e',
'r' };
647static const unsigned char packet_send_S7[] = { 0x17, 0x06, 0x0f, 0x30, 0x07, 0x07 };
649 { 0x17, 0x06, 0x10, 0x81, 0x04, 0x20 };
652 {
'J',
'a',
'n',
'F',
'e',
'b',
'M',
'a',
'r',
'A',
'p',
'r',
'M',
'a',
'y',
'J',
'u',
'n',
653 'J',
'u',
'l',
'A',
'u',
'g',
'S',
'e',
'p',
'O',
'c',
't',
'N',
'o',
'v',
'D',
'e',
'c' };
655 { 0x17, 0x0a, 0x15,
'-',
'-',
'-',
'-',
'-',
'-', 0x20 };
657 { 0x17, 0x0f, 0x19, 0x10, 0x01, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
6580x20, 0x20, 0x20, 0x20, 0x19,
659 0x05, 0x0f, 0x01, 0x00
662 { 0x17, 0x10, 0x19, 0x02, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
6630x20, 0x20, 0x20, 0x20 };
665 { 0x17, 0x1e, 0x1b, 0x04, 0x00, 0x25, 0x20, 0x20,
6660x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
667 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
668 0x17, 0x04, 0x10, 0x87
671 { 0x17, 0x20, 0x19, 0x08, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
6720x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
673 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20
676 { 0x17, 0x0b, 0x19, 0x00, 0x20, 0x20, 0x20, 0x20,
682 { 0x17, 0x08, 0x21, 0x1b, 0x2d, 0x41, 0x1b, 0x00 };
685 { 0x17, 0x08, 0x21, 0x1b, 0x2d, 0x42, 0x1b, 0x00 };
688 { 0x17, 0x08, 0x21, 0x1b, 0x2d, 0x44, 0x1b, 0x00 };
691 { 0x17, 0x08, 0x21, 0x1b, 0x2d, 0x4c, 0x1b, 0x00 };
694 { 0x17, 0x08, 0x21, 0x1b, 0x29, 0x49, 0x1b, 0x7e };
701static const unsigned char packet_send_S1[] = { 0x1a, 0x07, 0x07, 0x00, 0x00, 0x00, 0x13 };
704 { 0x1e, 0x05, 0x12, 0x00, 0x78 };
706#define BUFFSEND unsigned char buffsend[64] = { 0x00, 0x00, 0xaa, 0xbb, 0x02, 0x01 }
708static const char tdesc[] =
"UNISTIM Channel Driver";
720 const char *dest,
int *cause);
731 unsigned int duration);
740 .description =
tdesc,
817 char tmp[1024], *p, *p_orig =
NULL, *p_trans =
NULL;
833 while (fgets(tmp,
sizeof(tmp), f)) {
834 if (!(p = strchr(tmp,
'\n'))) {
839 if (!(p = strchr(tmp,
'"'))) {
842 if (tmp == strstr(tmp,
"msgid")) {
844 p = strchr(p_orig,
'"');
845 }
else if (tmp == strstr(tmp,
"msgstr")) {
847 p = strchr(p_trans,
'"');
852 if (!p_trans || !p_orig) {
901 return (now.tv_sec * 1000) + (now.tv_usec / 1000);
905static void send_raw_client(
int size,
const unsigned char *data,
struct sockaddr_in *addr_to,
906 const struct sockaddr_in *addr_ourip)
909 struct iovec msg_iov;
911 char buffer[CMSG_SPACE(
sizeof(
struct in_pktinfo))];
912 struct cmsghdr *ip_msg = (
struct cmsghdr *) buffer;
913 struct in_pktinfo *pki = (
struct in_pktinfo *) CMSG_DATA(ip_msg);
920 msg_iov.iov_base = (
char *) data;
921 msg_iov.iov_len = size;
923 msg.msg_name = addr_to;
924 msg.msg_namelen =
sizeof(
struct sockaddr_in);
925 msg.msg_iov = &msg_iov;
927 msg.msg_control = ip_msg;
928 msg.msg_controllen =
sizeof(buffer);
931 ip_msg->cmsg_len = CMSG_LEN(
sizeof(*pki));
932 ip_msg->cmsg_level = IPPROTO_IP;
933 ip_msg->cmsg_type = IP_PKTINFO;
934 pki->ipi_ifindex = 0;
935 pki->ipi_spec_dst.s_addr = addr_ourip->sin_addr.s_addr;
941 ast_verb(0,
"\n**> From %s sending %d bytes to %s ***\n",
944 for (tmp = 0; tmp < size; tmp++)
946 ast_verb(0,
"\n******************************************\n");
955 if (sendto(
unistimsock, data, size, 0, (
struct sockaddr *) addr_to,
sizeof(*addr_to))
975 memcpy((
void *)data +
sizeof(
unsigned short), (
void *)&
seq,
sizeof(
unsigned short));
984 ast_verb(0,
"Sending data with seq #0x%04x Using slot #%d :\n", (
unsigned)pte->
seq_server, buf_pos);
1009 struct cmsghdr *cmsg;
1010 struct sockaddr_in peeraddr;
1011 struct in_addr addr;
1012 struct msghdr mh = {
1013 .msg_name = &peeraddr,
1014 .msg_namelen =
sizeof(peeraddr),
1015 .msg_control = cmbuf,
1016 .msg_controllen =
sizeof(cmbuf),
1018 memset(&addr, 0,
sizeof(addr));
1020 err = recvmsg(fd, &mh, MSG_PEEK);
1025 for(cmsg = CMSG_FIRSTHDR(&mh);
1027 cmsg = CMSG_NXTHDR(&mh, cmsg))
1029 if (cmsg->cmsg_level == IPPROTO_IP && cmsg->cmsg_type == IP_PKTINFO) {
1030 struct in_pktinfo *pkt = (
struct in_pktinfo*)CMSG_DATA(cmsg);
1031 addr = pkt->ipi_addr;
1037 memcpy(&toAddr->sin_addr, &addr,
sizeof(
struct in_addr));
1040 memcpy(toAddr, &
public_ip,
sizeof(*toAddr));
1056 memcpy(&s->
sin, addr_from,
sizeof(
struct sockaddr_in));
1061 s->
sout.sin_family = AF_INET;
1063 ast_verb(0,
"Creating a new entry for the phone from %s received via server ip %s\n",
1094 unsigned int tick = 0;
1108 ast_verb(0,
"Our single packet was ACKed.\n");
1117 ast_verb(0,
"Our send queue is completely ACKed.\n");
1124 ast_verb(0,
"We still have packets in our send queue\n");
1133 ast_verb(0,
"Sending start timer\n");
1143 ast_verb(0,
"Sending stop timer\n");
1153 ast_verb(0,
"Sending icon pos %d with status 0x%02hhx\n", pos,
status);
1173 ast_verb(0,
"Sending expansion icon pos %d with status 0x%02hhx\n", pos,
status);
1187 ast_log(
LOG_ERROR,
"[expansion] Asked to display NULL text (pos %d)\n", pos);
1191 ast_verb(0,
"[expansion] Sending text at pos %d\n", pos);
1199 memcpy(buffsend + 11,
text, i);
1208 ast_verb(0,
"Sending Stream Based Tone Off\n");
1221 ast_verb(0,
"Sending Stream Based Tone Frequency Component List Download %d %d\n", tone1, tone2);
1241 ast_verb(0,
"Sending Stream Based Tone On\n");
1282 ast_verb(0,
"Sending favorite pos %d with status 0x%02hhx\n", pos,
status);
1317 if(
d->height == 1 && num % 3 == 2) {
1325 unsigned char i = 0;
1331 ast_verb(0,
"Refreshing all favorite\n");
1333 for (i = 0; i <
FAVNUM; i++) {
1348 for (i = 0; i <
EXPNUM; i++) {
1356 if ((fav < 0) || (fav >=
FAVNUM)) {
1359 if (
d->sline[fav]) {
1362 if (
d->softkeynumber[fav][0] ==
'\0') {
1370 if ((fav < 0) || (fav >=
FAVNUM)) {
1373 if (!
d->sline[fav]) {
1394 for (i = 0; i <
FAVNUM; i++) {
1409 ast_verb(0,
"Found softkey %d for device %s\n", i,
name);
1427 if (softkeylinepos != -1) {
1433 for (i = 0; i <
FAVNUM; i++) {
1434 if (
d->sp[i] == pte->
device) {
1435 if (
d->softkeyicon[i] !=
status) {
1452 ast_verb(0,
"Trying to register extension '%s' into context '%s' to %s\n",
1464 ast_verb(0,
"Trying to unregister extension '%s' context '%s'\n",
1490 ast_verb(0,
"close_client session %p device %p\n", s, s->
device);
1522 ast_verb(0,
"Freeing an unregistered client\n");
1547 ast_verb(0,
"Too many retransmit - freeing client\n");
1559 "Asked to retransmit an ACKed slot ! last_buf_available=%d, seq_server = #0x%04x last_seq_ack = #0x%04x\n",
1565 unsigned short *sbuf = (
unsigned short *) pte->
wsabufsend[i].
buf;
1568 seq = ntohs(sbuf[1]);
1569 ast_verb(0,
"Retransmit slot #%d (seq=#0x%04x), last ack was #0x%04x\n", i,
1586 ast_log(
LOG_ERROR,
"Asked to display NULL text (pos %d, inverse flag %d)\n", pos, inverse);
1593 ast_verb(0,
"Sending text at pos %d, inverse flag %d\n", pos, inverse);
1597 buffsend[11] = inverse;
1602 memcpy(buffsend + 12,
text, i);
1611 ast_verb(0,
"Sending status text\n");
1615 int n = strlen(
text);
1618 for (i = 0, j = 0; i < 4; i++, j += 7) {
1619 int pos = 0x08 + (i * 0x20);
1624 memcpy(buffsend + 10, (j < n) ? (
text + j) :
" ", 7);
1636 memcpy(buffsend + 10,
text, i);
1645 ast_verb(0,
"Sending led_update (%x)\n", (
unsigned)led);
1660 ast_verb(0,
"Sending mute packet (%x)\n", (
unsigned)mute);
1678 ast_verb(0,
"Sending select output packet output=%x volume=%x mute=%x\n",
1679 (
unsigned)output, (
unsigned)
volume, (
unsigned)mute);
1683 buffsend[9] = output;
1691 buffsend[11] = mute;
1713 if (mute_icon != -1) {
1725 ast_verb(0,
"Sending ring packet\n");
1728 buffsend[24] = style + 0x10;
1729 buffsend[29] =
volume * 0x10;
1737 ast_verb(0,
"Sending no ring packet\n");
1748 ast_verb(0,
"Sending title text\n");
1755 memcpy(buffsend + 10,
text, i);
1770 ast_verb(0,
"Sending Month Labels\n");
1779 month = (month + 1)%12;
1790 struct ast_tm atm = { 0, };
1793 ast_verb(0,
"Sending Time & Date\n");
1797 buffsend[10] = (
unsigned char) atm.
tm_mon + 1;
1798 buffsend[11] = (
unsigned char) atm.
tm_mday;
1799 buffsend[12] = (
unsigned char) atm.
tm_hour;
1800 buffsend[13] = (
unsigned char) atm.
tm_min;
1809 struct ast_tm atm = { 0, };
1812 ast_verb(0,
"Sending Time & Date #2\n");
1821 buffsend[14] = (
unsigned char) atm.
tm_mon + 1;
1822 buffsend[15] = (
unsigned char) atm.
tm_mday;
1823 buffsend[16] = (
unsigned char) atm.
tm_hour;
1824 buffsend[17] = (
unsigned char) atm.
tm_min;
1832 struct ast_tm atm = { 0, };
1835 ast_verb(0,
"Sending Time & Date #3\n");
1839 buffsend[10] = (
unsigned char) atm.
tm_mon + 1;
1840 buffsend[11] = (
unsigned char) atm.
tm_mday;
1841 buffsend[12] = (
unsigned char) atm.
tm_hour;
1842 buffsend[13] = (
unsigned char) atm.
tm_min;
1850 ast_verb(0,
"Sending set blink\n");
1862 ast_verb(0,
"Sending set cursor position\n");
1873 const unsigned char* packet_send_charset;
1877 ast_verb(0,
"Sending set default charset\n");
1904 memcpy(buffsend +
SIZE_HEADER, packet_send_charset, packet_size);
1913 ast_verb(0,
"ResumeConnectionWithServer received\n");
1914 ast_verb(0,
"Sending packet_send_query_mac_address\n");
1929 if (!strcasecmp(s->
macaddr,
d->id)) {
1952 memcpy(dst, src,
sizeof(*dst));
1983 ast_debug(1,
"Released sub %u of channel %s@%s\n",
sub->subtype,
sub->parent->name,
sub->parent->parent->name);
1998 ast_verb(3,
"Allocating UNISTIM subchannel #%d on %s ptr=%p\n", x,
d->
name,
sub);
2060 return "SELECTOPTION";
2062 return "SELECTCODEC";
2064 return "SELECTLANGUAGE";
2080 sprintf(&addrmac[i],
"%02hhx",
buf[tmp]);
2084 ast_verb(0,
"MAC Address received: %s\n", addrmac);
2086 strcpy(pte->
macaddr, addrmac);
2099 ast_verb(0,
"New phone, autoprovisioning on\n");
2105 if (strcasecmp(
d->
name,
"template")) {
2114 memcpy(newd,
d,
sizeof(*newd));
2116 newd->lines.first =
NULL;
2117 newd->lines.last =
NULL;
2127 newl->
name, newd->name);
2128 snprintf(l->name,
sizeof(l->name),
"%d", atoi(l->name) + 1);
2148 newd->session = pte;
2149 newd->language[0] =
'\0';
2150 newd->to_delete = -1;
2186 ast_log(
LOG_ERROR,
"Subchannel lost sice reboot. Hanged channel may appear!\n");
2245 ast_verb(0,
"Sending query_basic_manager_04\n");
2252 ast_verb(0,
"Sending query_basic_manager_10\n");
2264 if (fwrite(&
c, 1, 1, f) != 1) {
2287 char count = 0, *histbuf;
2291 struct ast_tm atm = { 0, };
2321 snprintf(line1,
sizeof(line1),
"%04d/%02d/%02d %02d:%02d:%02d %s",
2327 if ((f = fopen(tmp,
"r"))) {
2328 struct stat bufstat;
2330 if (stat(tmp, &bufstat)) {
2336 if (bufstat.st_size != size) {
2338 "History file %s has an incorrect size (%d instead of %d). It will be replaced by a new one.",
2339 tmp, (
int) bufstat.st_size, size);
2351 if ((
errno != ENOENT) && (count == 0)) {
2355 f = fopen(tmp,
"w");
2378 if (fread(&count, 1, 1, f) != 1) {
2391 if (!(f2 = fopen(tmp2,
"w"))) {
2412 if (fread(histbuf, size, 1, f) != 1) {
2419 if (fwrite(histbuf, size, 1, f2) != 1) {
2436 if (rename(tmp2, tmp)) {
2488 size = strlen(callerid);
2492 memcpy(data, callerid, size);
2540 ast_verb(0,
"Starting silence generator\n");
2551 ast_verb(0,
"Stopping silence generator\n");
2614 sub->alreadygone = 1;
2618 ast_verb(0,
"attempt_transfer failed.\n");
2625 if (sub_transf->
owner) {
2631 ast_verb(0,
"USTM(%s@%s-%d) channel already destroyed\n",
sub->parent->name,
2692 struct sockaddr_in us = { 0, };
2702 if (htons(us.sin_port)) {
2703 rtp_start = htons(us.sin_port) + 1;
2717 struct sockaddr_in public = { 0, };
2718 struct sockaddr_in us = { 0, };
2719 struct sockaddr_in sin = { 0, };
2731 memcpy(&
public, &us,
sizeof(
public));
2733 memcpy(&
public, &
public_ip,
sizeof(
public));
2736 ast_verb(0,
"RTP started : Our IP/port is : %s:%hd with codec %s\n",
2739 ast_verb(0,
"Starting phone RTP stack. Our public IP is %s\n",
2743 pte =
sub->parent->parent->session;
2749 ast_verb(0,
"Sending packet_send_rtp_packet_size for codec %d\n", codec);
2753 buffsend[10] = (int) codec & 0xffffffffLL;
2757 ast_verb(0,
"Sending Jitter Buffer Parameters Configuration\n");
2763 uint16_t rtcpsin_port = ntohs(us.sin_port) + 1;
2776 memcpy(buffsend + 28, &
public.sin_addr,
sizeof(
public.sin_addr));
2782 memcpy(buffsend + 23, &
public.sin_addr,
sizeof(
public.sin_addr));
2786 buffsend[11] = codec;
2787 buffsend[12] = codec;
2791 ast_verb(0,
"Sending OpenAudioStreamRX\n");
2801 memcpy(buffsend + 28, &
public.sin_addr,
sizeof(
public.sin_addr));
2807 memcpy(buffsend + 23, &
public.sin_addr,
sizeof(
public.sin_addr));
2811 buffsend[11] = codec;
2812 buffsend[12] = codec;
2815 uint16_t rtcpsin_port = htons(us.sin_port) + 1;
2818 ast_verb(0,
"Sending packet_send_call default method\n");
2822 memcpy(buffsend + 53, &
public.sin_addr,
sizeof(
public.sin_addr));
2828 buffsend[40] = codec;
2829 buffsend[41] = codec;
2851 struct sockaddr_in sin = { 0, };
2852 struct sockaddr_in sout = { 0, };
2865 if (!
sub->parent->parent) {
2869 if (!
sub->parent->parent->session) {
2877 sout =
sub->parent->parent->session->sout;
2899 sin.sin_family = AF_INET;
2901 memcpy(&sin.sin_addr, &
sub->parent->parent->session->sin.sin_addr,
2902 sizeof(sin.sin_addr));
2913 "Our read/writeformat has been changed to something incompatible: %s, using %s best codec from %s\n",
2939 ast_verb(0,
"Country code found (%s), freq1=%u freq2=%u\n",
2949 const char *tmp_number =
ustmtext(
"Number:", pte);
2950 int line, tmp_copy, offset = 0, i;
2955 if (offset > strlen(tmp_number)) {
2956 offset = strlen(tmp_number);
2958 tmp_copy = strlen(tmp_number) - offset + 1;
2959 if (tmp_copy >
sizeof(tmp)) {
2960 tmp_copy =
sizeof(tmp);
2962 memcpy(tmp, tmp_number + offset, tmp_copy);
2971 offset = strlen(tmp);
3038 if ((!
a->owner) || (!
b->owner)) {
3040 "Attempted to swap subchannels with a null owner : sub #%p=%p sub #%p=%p\n",
3041 a,
a->owner,
b,
b->owner);
3066 if (!
sub || !
sub->owner) {
3090 if (!
sub || !
sub->owner) {
3096 ast_verb(0,
"Transfer canceled, hangup our threeway channel\n");
3170 ast_verb(0,
"Started three way call on channel %p (%s) subchan %u\n",
3177 if (softkey == -1) {
3191 sub->softkey = softkey;
3194 ast_verb(0,
"Using softkey %d, line %p\n",
sub->softkey,
sub->parent);
3200 const char *pickupexten;
3210 ast_log(
LOG_ERROR,
"Unable to retrieve pickup configuration options. Unable to detect call pickup extension\n");
3213 pickupexten =
ast_strdupa(pickup_cfg->pickupexten);
3219 ast_verb(0,
"Try to pickup in unistim_new\n");
3278 for (i = 0; i <
FAVNUM; i++) {
3288 if (
sub->softkey == i) {
3291 if (
sub->softkey < 0) {
3298 if (
sub->softkey < 0) {
3306 ast_verb(0,
"Handle Call Incoming for %s@%s\n",
sub->parent->name,
3339 row = (
digit -
'1') % 3;
3340 col = (
digit -
'1' - row) / 3;
3345 }
else if (
digit ==
'*') {
3347 }
else if (
digit ==
'0') {
3349 }
else if (
digit ==
'#') {
3364 if (!
sub || !
sub->owner ||
sub->alreadygone) {
3394 ast_verb(0,
"Handle line w/o sub - dialpage\n");
3404 ast_verb(0,
"Handle favorite w/o sub - dialing\n");
3737#define SELECTCODEC_START_ENTRY_POS 15
3738#define SELECTCODEC_MAX_LENGTH 2
3739#define SELECTCODEC_MSG "Codec number : .."
3742 char buf[30], buf2[6];
3748 strcat(
buf,
" (G711u=0,");
3770 if ((keycode >=
KEY_0) && (keycode <=
KEY_9)) {
3777 while (i < pte->size_buff_entry) {
3829 char tmp_language[40];
3881#define SELECTEXTENSION_START_ENTRY_POS 0
3882#define SELECTEXTENSION_MAX_LENGTH 10
3883#define SELECTEXTENSION_MSG ".........."
3908 if ((keycode >=
KEY_0) && (keycode <=
KEY_9)) {
3915 while (i < pte->size_buff_entry) {
3941 if (
d->id[0] ==
'T') {
4003 line[
sizeof(line) - 1] =
'\0';
4017 line[
sizeof(line) - 1] =
'\0';
4033 line[
sizeof(line) - 1] =
'\0';
4043 snprintf(line,
sizeof(line),
"%s %03d/%03d",
ustmtext(
"Call", pte), pte->
buff_entry[2],
4073 *f = fopen(tmp,
"r");
4078 if (fread(&count, 1, 1, *f) != 1) {
4140 char tmp_field[100];
4187 strcpy(tmpbuf,
"IP : ");
4263 ast_log(
LOG_ERROR,
"Unable to retrieve pickup configuration options. Unable to detect call pickup extension\n");
4378 if (fseek(f, offset, SEEK_CUR)) {
4428 ast_verb(0,
"Sending init language\n");
4441 for (i = 1; i <
FAVNUM; i++) {
4446 strcpy(tmp,
"MAC = ");
4489 ast_verb(0,
"Got the firmware version : '%s'\n",
buf + 13);
4522 ast_verb(0,
"Request not authorized in this state\n");
4527 char keycode =
buf[13];
4530 ast_verb(0,
"Expansion key pressed: keycode = 0x%02hhx - current state: %s\n", (
unsigned char)keycode,
4535 char keycode =
buf[13];
4538 ast_verb(0,
"Key pressed: keycode = 0x%02hhx - current state: %s\n", (
unsigned char)keycode,
4544 switch (pte->
state) {
4547 ast_verb(0,
"No keys allowed in the init state\n");
4552 ast_verb(0,
"No keys allowed in authdeny state\n");
4634 strcat(tmpbuf,
" Unknown request packet\n");
4642 struct sockaddr_in *addr_from)
4644 unsigned short *sbuf = (
unsigned short *)
buf;
4658 if (sbuf[0] == 0xffff) {
4664 ast_verb(0,
"Discovery packet received - Sending Discovery ACK\n");
4669 ast_verb(1,
"Duplicated Discovery packet\n");
4696 ast_verb(0,
"%s Not a discovery packet from an unknown source : ignoring\n", tmpbuf);
4709 seq = ntohs(sbuf[1]);
4713 ast_verb(0,
"ACK received for packet #0x%04x\n", (
unsigned)
seq);
4725 ast_verb(0,
"ACK at 0xffff, restarting counter.\n");
4729 "%s Warning : ACK received for an already ACKed packet : #0x%04x we are at #0x%04x\n",
4737 "%s Error : ACK received for a non-existent packet : #0x%04x\n",
4743 ast_verb(0,
"%s ACK gap : Received ACK #0x%04x, previous was #0x%04x\n",
4767 "%s Warning : received a retransmitted packet : #0x%04x (we are at #0x%04x)\n",
4777 "%s Warning : we lost a packet : received #0x%04x (we are at #0x%04x)\n",
4785 "%s Error : received a request for an already ACKed packet : #0x%04x\n",
4791 "%s Error : received a request for a non-existent packet : #0x%04x\n",
4798 ast_log(
LOG_NOTICE,
"%s Unknown request : got 0x%02hhx expected 0x00,0x01 or 0x02\n", tmpbuf,
buf[4]);
4819 if (!
sub->parent->parent) {
4824 if (!
sub->parent->parent->session) {
4830 return sub->parent->parent->session;
4848 if (strlen(cidnum_str) == 0) {
4858 if (strlen(cidname_str) == 0) {
4864 snprintf(tmpstr,
sizeof(tmpstr),
"%s %s", cidnum_str,
ustmtext(cidname_str, pte));
4880 signed char ringstyle, ringvolume;
4905 ringstyle =
session->device->cwstyle;
4906 ringvolume =
session->device->cwvolume;
4908 ringstyle = (
sub->ringstyle == -1) ?
session->device->ringstyle :
sub->ringstyle;
4909 ringvolume = (
sub->ringvolume == -1) ?
session->device->ringvolume :
sub->ringvolume;
4914 for (i = 0; i <
FAVNUM; i++) {
4918 if (
session->device->ssub[i]) {
4923 ast_verb(0,
"Found softkey %d for line %s\n", i,
sub->parent->name);
4939 sub->alreadygone = 0;
4942 ast_verb(0,
"Destroying RTP session\n");
4966 ast_debug(1,
"Asked to hangup channel not connected\n");
4975 if (sub_trans && (sub_trans->owner) && (
sub->subtype ==
SUB_REAL)) {
4977 ast_verb(0,
"Threeway call disconnected, switching to real call\n");
4991 ast_verb(0,
"Real call disconnected, stay in call\n");
5003 for (i = 0; i <
FAVNUM; i++) {
5007 if (
d->ssub[i] !=
sub) {
5008 if (
d->ssub[i] !=
NULL) {
5024 if (
sub->softkey >= 0) {
5028 for (i = 0; i <
FAVNUM; i++) {
5029 if (
d->ssub[i] ==
sub) {
5099 struct sockaddr_in addr_from = { 0, };
5102 int dw_num_bytes_rcvd;
5103 unsigned int size_addr_from;
5105 int dw_num_bytes_rcvdd;
5108 size_addr_from =
sizeof(addr_from);
5112 if (dw_num_bytes_rcvd == -1) {
5113 if (
errno == EAGAIN) {
5115 }
else if (
errno != ECONNREFUSED) {
5125 if (cur->
sin.sin_addr.s_addr == addr_from.sin_addr.s_addr) {
5135 ast_verb(0,
"\n*** Dump %d bytes from %s - phone_table[%d] ***\n",
5137 for (dw_num_bytes_rcvdd = 0; dw_num_bytes_rcvdd < dw_num_bytes_rcvd;
5138 dw_num_bytes_rcvdd++)
5140 ast_verb(0,
"\n******************************************\n");
5145 ast_verb(0,
"Received a packet from an unknown source\n");
5147 parsing(dw_num_bytes_rcvd,
buff,
NULL, (
struct sockaddr_in *) &addr_from);
5150 parsing(dw_num_bytes_rcvd,
buff, cur, (
struct sockaddr_in *) &addr_from);
5191 "Oooh, format changed from %s to %s\n",
5240 "Asked to transmit frame type %s, while native formats is %s (read/write = (%s/%s)\n",
5267 ast_debug(1,
"New owner for channel USTM/%s@%s-%u is %s\n", l->
name,
5270 if (p->
owner != oldchan) {
5289 return "Other end has hungup";
5291 return "Local ring";
5293 return "Remote end is ringing";
5295 return "Remote end has answered";
5297 return "Remote end is busy";
5299 return "Make it go off hook";
5301 return "Line is off hook";
5303 return "Congestion (circuits busy)";
5305 return "Flash hook";
5309 return "Set a low-level option";
5313 return "Un-Key Radio";
5315 return "Remote end changed";
5317 return "RTP source updated";
5319 return "Source of media changed";
5327 const char *indication)
5346 ast_verb(3,
"Asked to indicate '%s' (%d) condition on channel %s\n",
5368 sub->alreadygone = 1;
5381 sub->alreadygone = 1;
5437 at = strchr(line,
'@');
5447 at = strchr(device,
'/');
5452 if (!strcasecmp(
d->
name, device)) {
5460 if (!strcasecmp(l->
name, line)) {
5473 sub->ringvolume = -1;
5474 sub->ringstyle = -1;
5479 if ((*at <
'0') || (*at >
'7')) {
5482 signed char ring_volume = -1;
5483 signed char ring_style = *at -
'0';
5485 if ((*at >=
'0') && (*at <=
'3')) {
5486 ring_volume = *at -
'0';
5489 ast_verb(0,
"Distinctive ring: style #%d volume %d\n",
5490 ring_style, ring_volume);
5492 sub->ringvolume = ring_volume;
5493 sub->ringstyle = ring_style;
5534 ast_verb(0,
"Send Digit off %c (duration %d)\n",
digit, duration);
5549 ast_verb(0,
"unistim_sendtext called\n");
5560 size = strlen(
text);
5561 if (
text[0] ==
'@') {
5562 int pos = 0, i = 1, tok = 0, sz = 0;
5568 memset(label, 0, 11);
5574 if ((cur <
'0') && (cur >
'5')) {
5576 "sendtext failed : position must be a number between 0 and 5\n");
5590 if ((cur <
'3') && (cur >
'6')) {
5592 "sendtext failed : icon must be a number between 32 and 63 (first digit invalid)\n");
5595 icon = (cur -
'0') * 10;
5599 if ((cur <
'0') && (cur >
'9')) {
5601 "sendtext failed : icon must be a number between 32 and 63 (second digit invalid)\n");
5604 icon += (cur -
'0');
5610 "sendtext failed : icon must be a number between 32 and 63 (too many digits)\n");
5630 "sendtext failed : extension too long = %d (15 car max)\n",
5666 tmp[
sizeof(tmp) - 1] =
'\0';
5672 tmp[
sizeof(tmp) - 1] =
'\0';
5675 tmp[
sizeof(tmp) - 1] =
'\0';
5693 ast_debug(3,
"MWI Status for mailbox %s is %d, lastmsgsent:%d\n",
5735 ast_verb(0,
"unistim_new sub=%u (%p) chan=%p line=%s\n",
sub->subtype,
sub, tmp, l->
name);
5760 ast_verb(0,
"Best codec = %s from nativeformats %s (line cap=%s global=%s)\n",
5766 if ((
sub->rtp) && (
sub->subtype == 0)) {
5768 ast_verb(0,
"New unistim channel with a previous rtp handle ?\n");
5801 char *
name, *loc, *instr;
5821 ast_verb(0,
"Starting pbx in unistim_new\n");
5844 unsigned int dw_timeout = 0;
5858 dw_timeout = UINT_MAX;
5861 DEBUG_TIMER(
"checking timeout for session %p with tick = %u\n", cur, tick);
5863 DEBUG_TIMER(
"checking timeout for session %p timeout = %u\n", cur,
5873 DEBUG_TIMER(
"The chained link was modified, restarting...\n");
5875 dw_timeout = UINT_MAX;
5880 if (dw_timeout > cur->
timeout - tick) {
5881 dw_timeout = cur->
timeout - tick;
5917 ast_verb(1,
"Reloading unistim.conf...\n");
5920 pthread_testcancel();
5929 pthread_attr_t attr;
5947 pthread_attr_init(&attr);
5948 pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
5974 "Asked to get a channel of unsupported format %s while capability is %s\n",
5991 d =
sub->parent->parent;
6000 if (sub_ring || sub_trans) {
6002 ast_verb(0,
"Can't create channel, request already in progress: Busy!\n");
6010 ast_verb(0,
"Can't create channel, user on dialpage: Busy!\n");
6019 ast_verb(0,
"Can't create channel for line %s, all lines busy\n",
sub->parent->name);
6034 ast_verb(0,
"unistim_request owner = %p\n",
sub->owner);
6051 e->
command =
"unistim show info";
6053 "Usage: unistim show info\n"
6054 " Dump internal structures.\n\n"
6065 if (
a->argc != e->
args) {
6068 ast_cli(
a->fd,
"Dumping internal structures:\n");
6073 ast_cli(
a->fd,
"\nname=%s id=%s ha=%p sess=%p device=%p selected=%d height=%d\n",
6079 "->name=%s fullname=%s exten=%s callid=%s cap=%s line=%p\n",
6091 "-->subtype=%s chan=%p rtp=%p line=%p alreadygone=%d softkey=%d\n",
6093 sub->alreadygone,
sub->softkey);
6097 for (i = 0; i <
FAVNUM; i++) {
6101 ast_cli(
a->fd,
"==> %d. dev=%s icon=%#-4x label=%-10s number=%-5s sub=%p line=%p\n",
6105 device = device->
next;
6113 "sin=%s timeout=%d state=%s macaddr=%s device=%p session=%p\n",
6129 e->
command =
"unistim show devices";
6131 "Usage: unistim show devices\n"
6132 " Lists all known Unistim devices.\n";
6138 if (
a->argc != e->
args)
6141 ast_cli(
a->fd,
"%-20.20s %-20.20s %-15.15s %-15.15s %s\n",
"Name/username",
"MAC",
"Host",
"Firmware",
"Status");
6144 ast_cli(
a->fd,
"%-20.20s %-20.20s %-15.15s %-15.15s %s\n",
6145 device->
name, device->
id,
6148 (!device->
session) ?
"UNKNOWN" :
"OK");
6149 device = device->
next;
6161 unsigned char c, cc;
6166 e->
command =
"unistim send packet";
6168 "Usage: unistim send packet USTM/line@name hexa\n"
6169 " unistim send packet USTM/1000@hans 19040004\n";
6179 if (strlen(
a->argv[3]) < 9) {
6182 len = strlen(
a->argv[4]);
6189 ast_cli(
a->fd,
"Can't find '%s'\n", tmp);
6192 if (!
sub->parent->parent->session) {
6193 ast_cli(
a->fd,
"'%s' is not connected\n", tmp);
6196 ast_cli(
a->fd,
"Sending '%s' to %s (%p)\n",
a->argv[4], tmp,
sub->parent->parent->session);
6197 for (i = 0; i <
len; i++) {
6211 tmp[j++] = (
c << 4) | cc;
6222 e->
command =
"unistim set debug {on|off}";
6224 "Usage: unistim set debug\n"
6225 " Display debug messages.\n";
6232 if (
a->argc != e->
args) {
6235 if (!strcasecmp(
a->argv[3],
"on")) {
6237 ast_cli(
a->fd,
"UNISTIM Debugging Enabled\n");
6238 }
else if (!strcasecmp(
a->argv[3],
"off")) {
6240 ast_cli(
a->fd,
"UNISTIM Debugging Disabled\n");
6255 e->
command =
"unistim reload";
6257 "Usage: unistim reload\n"
6258 " Reloads UNISTIM configuration from unistim.conf\n";
6265 if (e &&
a &&
a->argc != e->
args) {
6283 int len = strlen(src);
6287 if ((
len > 1) && src[0] ==
'\"') {
6292 if (maxlen >
len - 1) {
6295 memcpy(
out, src, maxlen);
6296 ((
char *)
out)[maxlen] =
'\0';
6298 memcpy(
out, src, maxlen);
6314 if ((
len > 2) && (line[1] ==
'@')) {
6316 if ((p >=
'0') && (p <=
'5')) {
6320 "Invalid position for bookmark : must be between 0 and 5\n");
6323 if (
d->softkeyicon[p] != 0) {
6327 memmove(line, line + 2,
sizeof(line) - 2);
6330 for (p = 0; p <
FAVNUM; p++) {
6331 if (!
d->softkeyicon[p]) {
6340 at = strchr(line,
'@');
6348 at = strchr(at,
'@');
6358 at = strchr(
number,
'@');
6369 if (strncmp(icon,
"USTM/", 5)) {
6370 d->softkeyicon[p] = atoi(icon);
6372 d->softkeyicon[p] = 1;
6379 ast_verb(0,
"New bookmark at pos %d label='%s' number='%s' icon=%#x\n",
6380 p,
d->softkeylabel[p],
d->softkeynumber[p], (
unsigned)
d->softkeyicon[p]);
6392 for (i = 0; i < 6; i++) {
6393 if (
d->softkeyicon[i] == 1) {
6396 if (!strcmp(
d->softkeydevice[i], d2->
name)) {
6398 d->softkeyicon[i] = 0;
6403 if (
d->sp[i] ==
NULL) {
6405 d->softkeydevice[i]);
6442 "Device '%s' was not deleted : a call is in progress. Try again later.\n",
6450 "Device '%s' with threeway call subchannels allocated, aborting.\n",
6478 if (s->
next ==
d->session) {
6493 if (d2->
next ==
d) {
6512 int nbsoftkey,
dateformat, timeformat, callhistory, sharpdial, linecnt;
6514 signed char ringvolume, ringstyle, cwvolume, cwstyle;
6521 if (!strcmp(
d->
name, cat)) {
6566 memset(
d->softkeylabel, 0,
sizeof(
d->softkeylabel));
6567 memset(
d->softkeynumber, 0,
sizeof(
d->softkeynumber));
6568 memset(
d->softkeyicon, 0,
sizeof(
d->softkeyicon));
6569 memset(
d->softkeydevice, 0,
sizeof(
d->softkeydevice));
6570 memset(
d->ssub, 0,
sizeof(
d->ssub));
6571 memset(
d->sline, 0,
sizeof(
d->sline));
6572 memset(
d->sp, 0,
sizeof(
d->sp));
6574 linelabel[0] =
'\0';
6585 d->dtmfduration = 0;
6587 if (!strcasecmp(v->
name,
"rtp_port")) {
6588 d->rtp_port = atoi(v->
value);
6589 }
else if (!strcasecmp(v->
name,
"rtp_method")) {
6590 d->rtp_method = atoi(v->
value);
6591 }
else if (!strcasecmp(v->
name,
"status_method")) {
6592 d->status_method = atoi(v->
value);
6593 }
else if (!strcasecmp(v->
name,
"device")) {
6595 }
else if (!strcasecmp(v->
name,
"tn")) {
6597 }
else if (!strcasecmp(v->
name,
"permit") || !strcasecmp(v->
name,
"deny")) {
6601 ast_log(
LOG_ERROR,
"Invalid ACL '%s' specified for device '%s' on line %d. Deleting device\n",
6606 }
else if (!strcasecmp(v->
name,
"context")) {
6608 }
else if (!strcasecmp(v->
name,
"maintext0")) {
6610 }
else if (!strcasecmp(v->
name,
"maintext1")) {
6612 }
else if (!strcasecmp(v->
name,
"maintext2")) {
6614 }
else if (!strcasecmp(v->
name,
"titledefault")) {
6616 }
else if (!strcasecmp(v->
name,
"dateformat")) {
6618 }
else if (!strcasecmp(v->
name,
"timeformat")) {
6619 timeformat = atoi(v->
value);
6620 }
else if (!strcasecmp(v->
name,
"contrast")) {
6621 d->contrast = atoi(v->
value);
6622 if ((
d->contrast < 0) || (
d->contrast > 15)) {
6626 }
else if (!strcasecmp(v->
name,
"nat")) {
6628 }
else if (!strcasecmp(v->
name,
"hasexp")) {
6630 }
else if (!strcasecmp(v->
name,
"ringvolume")) {
6631 ringvolume = atoi(v->
value);
6632 }
else if (!strcasecmp(v->
name,
"ringstyle")) {
6633 ringstyle = atoi(v->
value);
6634 }
else if (!strcasecmp(v->
name,
"cwvolume")) {
6635 cwvolume = atoi(v->
value);
6636 }
else if (!strcasecmp(v->
name,
"cwstyle")) {
6637 cwstyle = atoi(v->
value);
6638 }
else if (!strcasecmp(v->
name,
"callhistory")) {
6639 callhistory = atoi(v->
value);
6640 }
else if (!strcasecmp(v->
name,
"sharpdial")) {
6642 }
else if (!strcasecmp(v->
name,
"interdigit_timer")) {
6643 d->interdigit_timer = atoi(v->
value);
6644 }
else if (!strcasecmp(v->
name,
"dtmf_duration")) {
6645 d->dtmfduration = atoi(v->
value);
6646 if (
d->dtmfduration > 150) {
6647 d->dtmfduration = 150;
6649 }
else if (!strcasecmp(v->
name,
"callerid")) {
6650 if (!strcasecmp(v->
value,
"asreceived")) {
6651 lt->cid_num[0] =
'\0';
6655 }
else if (!strcasecmp(v->
name,
"language")) {
6657 }
else if (!strcasecmp(v->
name,
"country")) {
6659 }
else if (!strcasecmp(v->
name,
"accountcode")) {
6661 }
else if (!strcasecmp(v->
name,
"amaflags")) {
6670 }
else if (!strcasecmp(v->
name,
"musiconhold")) {
6672 }
else if (!strcasecmp(v->
name,
"callgroup")) {
6674 }
else if (!strcasecmp(v->
name,
"pickupgroup")) {
6676 }
else if (!strcasecmp(v->
name,
"mailbox")) {
6678 }
else if (!strcasecmp(v->
name,
"parkinglot")) {
6680 }
else if (!strcasecmp(v->
name,
"linelabel")) {
6682 }
else if (!strcasecmp(v->
name,
"extension")) {
6683 if (!strcasecmp(v->
value,
"none")) {
6685 }
else if (!strcasecmp(v->
value,
"ask")) {
6687 }
else if (!strcasecmp(v->
value,
"line")) {
6692 }
else if (!strcasecmp(v->
name,
"bookmark")) {
6693 if (nbsoftkey > 5) {
6695 "More than 6 softkeys defined. Ignoring new entries.\n");
6701 }
else if (!strcasecmp(v->
name,
"line")) {
6702 int len = strlen(linelabel);
6703 int create_line = 0;
6713 memcpy(l, lt,
sizeof(*l));
6720 d->sline[nbsoftkey] = l;
6725 int softkeylinepos = 0;
6726 if ((
len > 2) && (linelabel[1] ==
'@')) {
6727 softkeylinepos = linelabel[0];
6728 if ((softkeylinepos >=
'0') && (softkeylinepos <=
'5')) {
6729 softkeylinepos -=
'0';
6733 "Invalid position for linelabel : must be between 0 and 5\n");
6736 sizeof(
d->softkeylabel[softkeylinepos]));
6740 sizeof(
d->softkeylabel[nbsoftkey]));
6760 }
else if (!strcasecmp(v->
name,
"height")) {
6763 d->height = atoi(v->
value);
6775 d->ringvolume = ringvolume;
6776 d->ringstyle = ringstyle;
6777 d->cwvolume = cwvolume;
6778 d->cwstyle = cwstyle;
6779 d->callhistory = callhistory;
6780 d->sharp_dial = sharpdial;
6787 d->datetimeformat += timeformat;
6793 "tn= and device= can't be used together. Ignoring device= entry\n");
6797 d->extension_number[0] =
'\0';
6799 if (strcmp(
d->
name,
"template")) {
6807 strcpy(
d->id,
"000000000000");
6811 d->rtp_port = 10000;
6813 if (
d->contrast == -1) {
6817 strcpy(
d->maintext1,
d->
name);
6820 struct ast_tm tm = { 0, };
6828 strcpy(
d->titledefault,
"TimeZone ");
6829 strcat(
d->titledefault, tm.
tm_zone);
6830 }
else if (strlen(tm.
tm_zone) < 9) {
6831 strcpy(
d->titledefault,
"TZ ");
6832 strcat(
d->titledefault, tm.
tm_zone);
6856 struct sockaddr_in
bindaddr = { 0, };
6857 char *
config =
"unistim.conf";
6860 const int reuseFlag = 1;
6885 if (!strcasecmp(v->
name,
"keepalive")) {
6887 }
else if (!strcasecmp(v->
name,
"port")) {
6889 }
else if (!strcasecmp(v->
name,
"tos")) {
6893 }
else if (!strcasecmp(v->
name,
"tos_audio")) {
6897 }
else if (!strcasecmp(v->
name,
"cos")) {
6901 }
else if (!strcasecmp(v->
name,
"cos_audio")) {
6905 }
else if (!strcasecmp(v->
name,
"debug")) {
6906 if (!strcasecmp(v->
value,
"no")) {
6908 }
else if (!strcasecmp(v->
value,
"yes")) {
6911 }
else if (!strcasecmp(v->
name,
"autoprovisioning")) {
6912 if (!strcasecmp(v->
value,
"no")) {
6914 }
else if (!strcasecmp(v->
value,
"yes")) {
6916 }
else if (!strcasecmp(v->
value,
"tn")) {
6921 }
else if (!strcasecmp(v->
name,
"public_ip")) {
6952 if (
d->to_delete >= 0) {
6961 if (strcasecmp(cat,
"general")) {
6997 bindaddr.sin_addr.s_addr = INADDR_ANY;
7007 const int pktinfoFlag = 1;
7008 setsockopt(
unistimsock, IPPROTO_IP, IP_PKTINFO, &pktinfoFlag,
7009 sizeof(pktinfoFlag));
7014 "Your OS does not support IP_PKTINFO, you must set public_ip.\n");
7019 setsockopt(
unistimsock, SOL_SOCKET, SO_REUSEADDR, (
const char *) &reuseFlag,
7046 *instance =
sub->rtp;
7054 struct sockaddr_in them = { 0, };
7055 struct sockaddr_in us = { 0, };
7128 goto chanreg_failed;
void ast_jb_configure(struct ast_channel *chan, const struct ast_jb_conf *conf)
Configures a jitterbuffer on a channel.
int ast_jb_read_conf(struct ast_jb_conf *conf, const char *varname, const char *value)
Sets jitterbuffer configuration property.
Access Control of various sorts.
int ast_str2tos(const char *value, unsigned int *tos)
Convert a string to the appropriate TOS value.
int ast_str2cos(const char *value, unsigned int *cos)
Convert a string to the appropriate COS value.
struct ast_ha * ast_append_ha(const char *sense, const char *stuff, struct ast_ha *path, int *error)
Add a new rule to a list of HAs.
void ast_cli_unregister_multiple(void)
static const struct adsi_event events[]
static volatile unsigned int seq
Persistent data storage (akin to *doze registry)
int ast_db_get(const char *family, const char *key, char *value, int valuelen)
Get key value specified by family/key.
char * strsep(char **str, const char *delims)
Asterisk main include file. File version handling, generic pbx functions.
static struct ast_mansession session
#define ast_strdup(str)
A wrapper for strdup()
#define ast_strdupa(s)
duplicate a string in memory from the stack
#define ast_calloc(num, len)
A wrapper for calloc()
#define ast_malloc(len)
A wrapper for malloc()
#define ao2_link(container, obj)
Add an object to a container.
@ AO2_ALLOC_OPT_LOCK_MUTEX
#define ao2_find(container, arg, flags)
#define ao2_ref(o, delta)
Reference/unreference an object and return the old refcount.
#define ao2_alloc(data_size, destructor_fn)
#define ao2_container_alloc_hash(ao2_options, container_options, n_buckets, hash_fn, sort_fn, cmp_fn)
Allocate and initialize a hash container with the desired number of buckets.
@ AST_BRIDGE_TRANSFER_NOT_PERMITTED
@ AST_BRIDGE_TRANSFER_SUCCESS
@ AST_BRIDGE_TRANSFER_INVALID
@ AST_BRIDGE_TRANSFER_FAIL
enum ast_transfer_result ast_bridge_transfer_attended(struct ast_channel *to_transferee, struct ast_channel *to_transfer_target)
Attended transfer.
CallerID (and other GR30) management and generation Includes code and algorithms from the Zapata libr...
int ast_callerid_parse(char *instr, char **name, char **location)
Destructively parse inbuf into name and location (or number)
Internal Asterisk hangup causes.
#define AST_CAUSE_SWITCH_CONGESTION
#define AST_CAUSE_CONGESTION
#define AST_CAUSE_CALL_REJECTED
#define AST_CAUSE_NETWORK_OUT_OF_ORDER
#define AST_CAUSE_ANSWERED_ELSEWHERE
#define AST_CAUSE_NORMAL_CLEARING
struct ast_sockaddr bindaddr
static const char config[]
static char * unistim_show_info(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
static struct unistim_subchannel * get_sub_holding(struct unistim_device *device, int type, int holding)
static const unsigned char packet_recv_pressed_key[]
static void key_ringing(struct unistimsession *pte, char keycode)
static ast_mutex_t unistim_reload_lock
static struct unistimsession * sessions
static void transfer_call_step1(struct unistimsession *pte)
static void send_client(int size, const unsigned char *data, struct unistimsession *pte)
static void handle_select_option(struct unistimsession *pte)
static void set_ping_timer(struct unistimsession *pte)
static int get_avail_softkey(struct unistimsession *pte, const char *name)
static const unsigned char packet_send_date_time3[]
#define MAX_PHONE_NUMBER_LENGTH
static const unsigned char packet_recv_resume_connection_with_server[]
static void init_phone_step2(struct unistimsession *pte)
static void show_history(struct unistimsession *pte, char way)
static void in_band_indication(struct ast_channel *ast, const struct ast_tone_zone *tz, const char *indication)
static const char * subtype_tostr(const int type)
static const unsigned char packet_send_expansion_icon[]
static int unistim_call(struct ast_channel *ast, const char *dest, int timeout)
static void handle_call_incoming(struct unistimsession *s)
static struct ast_channel * unistim_new(struct unistim_subchannel *sub, int state, const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor)
static void send_led_update(struct unistimsession *pte, unsigned char led)
static const unsigned char packet_send_discovery_ack[]
static const unsigned char packet_send_expansion_next[]
static struct unistim_line * find_line_by_number(struct unistim_device *d, const char *val)
static void * unistim_ss(void *data)
static void handle_call_outgoing(struct unistimsession *s)
static void sub_stop_silence(struct unistimsession *pte, struct unistim_subchannel *sub)
static void send_ring(struct unistimsession *pte, signed char volume, signed char style)
static const unsigned char packet_send_date_time2[]
static int find_rtp_port(struct unistim_subchannel *s)
static void key_select_language(struct unistimsession *pte, char keycode)
static void handle_select_codec(struct unistimsession *)
static const unsigned char packet_send_s4[]
static void sub_unhold(struct unistimsession *pte, struct unistim_subchannel *sub)
static struct ast_frame * unistim_rtp_read(const struct ast_channel *ast, const struct unistim_subchannel *sub)
static enum autoprovision autoprovisioning
static const unsigned char packet_send_arrow[]
static void unistim_line_copy(struct unistim_line *dst, struct unistim_line *src)
static struct ast_frame * unistim_read(struct ast_channel *ast)
static struct unistim_line * unistim_line_destroy(struct unistim_line *l)
static void key_call(struct unistimsession *pte, char keycode)
static void send_dial_tone(struct unistimsession *pte)
static void send_callerid_screen(struct unistimsession *, struct unistim_subchannel *)
static struct ast_jb_conf default_jbconf
Global jitterbuffer configuration - by default, jb is disabled.
static void check_send_queue(struct unistimsession *pte)
static void key_history(struct unistimsession *pte, char keycode)
static void send_text(unsigned char pos, unsigned char inverse, struct unistimsession *pte, const char *text)
static const unsigned char packet_recv_it_type[]
static const unsigned char packet_send_end_call[]
static struct unistim_line * unistim_line_alloc(void)
static int unistim_keepalive
static void key_select_option(struct unistimsession *pte, char keycode)
static struct ast_sched_context * sched
static struct unistim_device * devices
#define STATUS_LENGTH_MAX
static int register_extension(const struct unistimsession *pte)
static const unsigned char packet_send_start_timer[]
static char * unistim_sp(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
static void send_idle_clock(struct unistimsession *pte)
static void sub_hold(struct unistimsession *pte, struct unistim_subchannel *sub)
static const unsigned char packet_send_charset_iso_2022_jp[]
static char * unistim_show_devices(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
static const unsigned char packet_send_s9[]
static void handle_select_language(struct unistimsession *)
static void key_select_codec(struct unistimsession *pte, char keycode)
static struct ast_cli_entry unistim_cli[]
#define SELECTEXTENSION_MAX_LENGTH
static void show_entry_history(struct unistimsession *pte, FILE **f)
static int unistim_senddigit_begin(struct ast_channel *ast, char digit)
static char * unistim_do_debug(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
static void send_raw_client(int size, const unsigned char *data, struct sockaddr_in *addr_to, const struct sockaddr_in *addr_ourip)
static void send_charset_update(struct unistimsession *pte, int charset)
static void send_blink_cursor(struct unistimsession *pte)
static ast_mutex_t devicelock
static void start_rtp(struct unistim_subchannel *sub)
#define FAV_ICON_SPEAKER_ONHOOK_BLACK
static void delete_device(struct unistim_device *d)
static struct unistimsession * channel_to_session(struct ast_channel *ast)
static void send_mute(struct unistimsession *pte, unsigned char mute)
static const unsigned char packet_send_mute[]
static void send_tone(struct unistimsession *pte, uint16_t tone1, uint16_t tone2)
#define FAV_ICON_SPEAKER_ONHOOK_WHITE
static void send_date_time(struct unistimsession *pte)
static struct unistim_subchannel * find_subchannel_by_name(const char *dest)
static int load_module(void)
static const unsigned char packet_send_S7[]
#define FAV_ICON_SPEAKER_ONHOLD_BLACK
static const char * ptestate_tostr(const int type)
static int is_key_line(struct unistim_device *d, int fav)
static void send_end_call(struct unistimsession *pte)
static int attempt_transfer(struct unistim_subchannel *p1, struct unistim_subchannel *p2)
static struct unistimsession * create_client(const struct sockaddr_in *addr_from)
static unsigned int get_tick_count(void)
static int write_entry_history(struct unistimsession *pte, FILE *f, char c, char *line1)
static char open_history(struct unistimsession *pte, char way, FILE **f)
#define SELECTCODEC_MAX_LENGTH
static void key_main_page(struct unistimsession *pte, char keycode)
static void process_request(int size, unsigned char *buf, struct unistimsession *pte)
static int lang_hash_fn(const void *obj, const int flags)
static void show_extension_page(struct unistimsession *pte)
static void send_expansion_text(unsigned char pos, struct unistimsession *pte, const char *text)
static const unsigned char packet_send_query_basic_manager_04[]
#define FAV_ICON_HEADPHONES
static int unistim_senddigit_end(struct ast_channel *ast, char digit, unsigned int duration)
static struct ast_channel_tech unistim_tech
static void send_favorite_short(unsigned char pos, unsigned char status, struct unistimsession *pte)
static const unsigned char packet_send_expansion_text[]
static void send_date_time2(struct unistimsession *pte)
static const char * ustmtext(const char *str, struct unistimsession *pte)
static void swap_subs(struct unistim_subchannel *a, struct unistim_subchannel *b)
static int unistim_reloading
static const char tdesc[]
static int is_key_favorite(struct unistim_device *d, int fav)
static int unistim_set_rtp_peer(struct ast_channel *chan, struct ast_rtp_instance *rtp, struct ast_rtp_instance *vrtp, struct ast_rtp_instance *trtp, const struct ast_format_cap *codecs, int nat_active)
static const unsigned char packet_send_ring[]
static void * do_monitor(void *data)
static int unistim_unalloc_sub(struct unistim_device *d, struct unistim_subchannel *sub)
#define FAV_ICON_OFFHOOK_BLACK
static void show_main_page(struct unistimsession *pte)
static const unsigned char packet_send_call[]
static int unistim_hangup(struct ast_channel *ast)
static int unistim_write(struct ast_channel *ast, struct ast_frame *frame)
static void send_favorite(unsigned char pos, unsigned char status, struct unistimsession *pte, const char *text)
static const unsigned char packet_send_charset_iso_8859_5[]
static void display_last_error(const char *sz_msg)
#define SELECTEXTENSION_START_ENTRY_POS
static void send_ping(struct unistimsession *pte)
static int unistimsock_read(int *id, int fd, short events, void *ignore)
static int write_history(struct unistimsession *pte, char way, char ismissed)
static int restart_monitor(void)
static void send_select_output(struct unistimsession *pte, unsigned char output, unsigned char volume, unsigned char mute)
static const unsigned char packet_send_query_basic_manager_10[]
static char * control2str(int ind)
static int find_language(const char *)
static const unsigned char packet_send_stop_timer[]
#define FAV_ICON_CALL_CENTER
static const unsigned char packet_rcv_discovery[]
#define FAV_ICON_PHONE_BLACK
static const unsigned char packet_recv_hangup[]
static void handle_dial_page(struct unistimsession *pte)
#define SELECTEXTENSION_MSG
#define DEFAULTCALLERNAME
#define AST_CONFIG_MAX_PATH
static void send_favorite_selected(unsigned char status, struct unistimsession *pte)
static const unsigned char packet_send_open_audio_stream_tx[]
static const unsigned char packet_send_charset_iso_8859_4[]
static int lang_cmp_fn(void *obj, void *arg, int flags)
static int get_to_address(int fd, struct sockaddr_in *toAddr)
static int get_active_softkey(struct unistimsession *pte)
static const unsigned char packet_send_stream_based_tone_on[]
static const unsigned char packet_send_charset_iso_8859_2[]
static const unsigned char packet_send_open_audio_stream_tx3[]
static void unistim_set_owner(struct unistim_subchannel *sub, struct ast_channel *chan)
static void handle_key_fav(struct unistimsession *pte, char keycode)
static const unsigned char packet_send_led_update[]
static const unsigned char packet_recv_pick_up[]
static const unsigned char packet_send_set_pos_cursor[]
static int send_retransmit(struct unistimsession *pte)
static unsigned char packet_send_ping[]
static const unsigned char packet_send_text[]
static struct ast_channel * unistim_request(const char *type, struct ast_format_cap *cap, const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor, const char *dest, int *cause)
#define FAV_ICON_SPEAKER_OFFHOOK_BLACK
#define VOLUME_LOW_SPEAKER
static const unsigned char packet_send_S1[]
static int send_dtmf_tone(struct unistimsession *pte, char digit)
static int unistim_register(struct unistimsession *s)
static unsigned char packet_send_monthlabels_download[]
static const unsigned char packet_send_rtp_packet_size[]
static void key_select_extension(struct unistimsession *pte, char keycode)
static void close_client(struct unistimsession *s)
static char ustm_strcopy[1024]
static const unsigned char packet_send_jitter_buffer_conf[]
static void finish_bookmark(void)
static struct unistim_languages options_languages[]
static void close_call(struct unistimsession *pte)
static const char channel_type[]
static void send_text_status(struct unistimsession *pte, const char *text)
#define NB_MAX_RETRANSMIT
static int unistim_send_mwi_to_peer(struct unistim_line *peer, unsigned int tick)
static void send_stop_timer(struct unistimsession *pte)
static ast_mutex_t monlock
static void show_phone_number(struct unistimsession *pte)
#define DEFAULT_INTERDIGIT_TIMER
static int reload_config(void)
static void refresh_all_favorite(struct unistimsession *pte)
static void transfer_cancel_step2(struct unistimsession *pte)
static void send_date_time3(struct unistimsession *pte)
static int unistim_sendtext(struct ast_channel *ast, const char *text)
#define FAV_ICON_HEADPHONES_ONHOLD
#define FAV_ICON_ONHOLD_BLACK
static const unsigned char packet_send_title[]
static void send_texttitle(struct unistimsession *pte, const char *text)
static char * unistim_reload(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
— unistim_reload: Force reload of module from cli — Runs in the asterisk main thread,...
static void send_start_timer(struct unistimsession *pte)
static struct ast_jb_conf global_jbconf
static struct unistim_menu_item options_menu[]
static void dummy(char *unused,...)
static void key_dial_page(struct unistimsession *pte, char keycode)
static void send_expansion_short(unsigned char pos, unsigned char status, struct unistimsession *pte)
static struct io_context * io
static const unsigned char packet_send_favorite[]
static void key_favorite(struct unistimsession *, char)
static void send_start_rtp(struct unistim_subchannel *)
static const unsigned char packet_send_Contrast[]
#define SELECTCODEC_START_ENTRY_POS
static const unsigned char packet_send_blink_cursor[]
static const unsigned char packet_recv_firm_version[]
static const unsigned char packet_send_icon[]
static struct sockaddr_in public_ip
static const unsigned char packet_send_stream_based_tone_dual_freq[]
static void microphone_mute_toggle(struct unistimsession *pte)
static struct unistim_device * build_device(const char *cat, const struct ast_variable *v)
static const unsigned char packet_send_status[]
static void parsing(int size, unsigned char *buf, struct unistimsession *pte, struct sockaddr_in *addr_from)
static void change_callerid(struct unistimsession *pte, int type, char *callerid)
static unsigned char monthlabels[]
static void change_favorite_icon(struct unistimsession *pte, unsigned char status)
static void send_expansion_icon(unsigned char pos, unsigned char status, struct unistimsession *pte)
static int unload_module(void)
static int parse_bookmark(const char *text, struct unistim_device *d)
static const unsigned char packet_send_open_audio_stream_rx3[]
static struct unistim_subchannel * get_sub(struct unistim_device *device, int type)
static const unsigned char packet_send_charset_iso_8859_1[]
#define MAX_SCREEN_NUMBER
static int unistim_fixup(struct ast_channel *oldchan, struct ast_channel *newchan)
static void send_month_labels(struct unistimsession *pte, int month)
static const unsigned char packet_send_status2[]
static void rcv_mac_addr(struct unistimsession *pte, const unsigned char *buf)
static void ignore_call(struct unistimsession *pte)
static const unsigned char packet_send_stream_based_tone_single_freq[]
static struct unistim_subchannel * unistim_alloc_sub(struct unistim_device *d, int x)
static void sub_start_silence(struct unistimsession *pte, struct unistim_subchannel *sub)
static const float dtmf_col[]
static void send_expansion_next(struct unistimsession *pte)
static const unsigned char packet_send_select_output[]
static ast_mutex_t sessionlock
static const unsigned char packet_recv_mac_addr[]
static void rcv_resume_connection_with_server(struct unistimsession *pte)
static void send_cursor_pos(struct unistimsession *pte, unsigned char pos)
static const unsigned char packet_send_open_audio_stream_rx[]
struct ast_format_cap * global_cap
static int unistim_hangup_clean(struct ast_channel *ast, struct unistim_subchannel *sub)
static void discard_call(struct unistimsession *pte)
static int soft_key_visible(struct unistim_device *d, unsigned char num)
static int unistim_indicate(struct ast_channel *ast, int ind, const void *data, size_t datalen)
static int unistim_answer(struct ast_channel *ast)
static const unsigned char packet_recv_r2[]
static const int dtmf_row[]
static void send_no_ring(struct unistimsession *pte)
#define LED_HEADPHONE_OFF
static void send_icon(unsigned char pos, unsigned char status, struct unistimsession *pte)
static const unsigned char packet_send_date_time[]
static int unistim_free_sub(struct unistim_subchannel *)
static void unquote(char *out, const char *src, int maxlen)
static unsigned char * buff
static enum ast_rtp_glue_result unistim_get_rtp_peer(struct ast_channel *chan, struct ast_rtp_instance **instance)
static struct ast_rtp_glue unistim_rtp_glue
static const unsigned char packet_send_stream_based_tone_off[]
static int unregister_extension(const struct unistimsession *pte)
static int unistim_do_senddigit(struct unistimsession *pte, char digit)
static pthread_t monitor_thread
static const unsigned char packet_recv_expansion_pressed_key[]
static const unsigned char packet_send_query_mac_address[]
static const unsigned char packet_send_no_ring[]
General Asterisk PBX channel definitions.
void ast_channel_exten_set(struct ast_channel *chan, const char *value)
const char * ast_channel_name(const struct ast_channel *chan)
void ast_channel_rings_set(struct ast_channel *chan, int value)
void * ast_channel_tech_pvt(const struct ast_channel *chan)
void ast_hangup(struct ast_channel *chan)
Hang up a channel.
#define ast_channel_alloc(needqueue, state, cid_num, cid_name, acctcode, exten, context, assignedids, requestor, amaflag,...)
Create a channel structure.
int ast_queue_hangup(struct ast_channel *chan)
Queue a hangup frame.
void ast_channel_nativeformats_set(struct ast_channel *chan, struct ast_format_cap *value)
int ast_channel_fdno(const struct ast_channel *chan)
#define ast_channel_lock(chan)
struct ast_format_cap * ast_channel_nativeformats(const struct ast_channel *chan)
void ast_channel_unregister(const struct ast_channel_tech *tech)
Unregister a channel technology.
struct ast_silence_generator * ast_channel_start_silence_generator(struct ast_channel *chan)
Starts a silence generator on the given channel.
int ast_queue_control(struct ast_channel *chan, enum ast_control_frame_type control)
Queue a control frame without payload.
unsigned long long ast_group_t
void ast_channel_stop_silence_generator(struct ast_channel *chan, struct ast_silence_generator *state)
Stops a previously-started silence generator on the given channel.
#define ast_channel_ref(c)
Increase channel reference count.
struct ast_party_connected_line * ast_channel_connected(struct ast_channel *chan)
int ast_queue_frame(struct ast_channel *chan, struct ast_frame *f)
Queue one or more frames to a channel's frame queue.
const char * ast_channel_uniqueid(const struct ast_channel *chan)
int ast_channel_fd(const struct ast_channel *chan, int which)
int ast_set_read_format(struct ast_channel *chan, struct ast_format *format)
Sets read format on channel chan.
void ast_channel_internal_fd_set(struct ast_channel *chan, int which, int value)
int ast_queue_hangup_with_cause(struct ast_channel *chan, int cause)
Queue a hangup frame with hangupcause set.
void ast_channel_set_rawreadformat(struct ast_channel *chan, struct ast_format *format)
void ast_channel_tech_pvt_set(struct ast_channel *chan, void *value)
void ast_channel_callgroup_set(struct ast_channel *chan, ast_group_t value)
int ast_channel_hangupcause(const struct ast_channel *chan)
void ast_channel_set_rawwriteformat(struct ast_channel *chan, struct ast_format *format)
#define AST_MAX_ACCOUNT_CODE
int ast_queue_unhold(struct ast_channel *chan)
Queue an unhold frame.
int ast_queue_hold(struct ast_channel *chan, const char *musicclass)
Queue a hold frame.
void ast_channel_set_readformat(struct ast_channel *chan, struct ast_format *format)
int ast_channel_register(const struct ast_channel_tech *tech)
Register a channel technology (a new channel driver) Called by a channel module to register the kind ...
#define ast_channel_unref(c)
Decrease channel reference count.
struct ast_format * ast_channel_writeformat(struct ast_channel *chan)
int ast_set_write_format(struct ast_channel *chan, struct ast_format *format)
Sets write format on channel chan.
int ast_softhangup_nolock(struct ast_channel *chan, int cause)
Softly hangup up a channel (no channel lock)
enum ama_flags ast_channel_string2amaflag(const char *flag)
Convert a string to a detail record AMA flag.
@ AST_CHAN_TP_WANTSJITTER
Channels have this property if they can accept input with jitter; i.e. most VoIP channels.
@ AST_CHAN_TP_CREATESJITTER
Channels have this property if they can create jitter; i.e. most VoIP channels.
const char * ast_channel_call_forward(const struct ast_channel *chan)
struct ast_party_caller * ast_channel_caller(struct ast_channel *chan)
void ast_channel_priority_set(struct ast_channel *chan, int value)
void ast_channel_hangupcause_set(struct ast_channel *chan, int value)
void ast_channel_pickupgroup_set(struct ast_channel *chan, ast_group_t value)
void ast_channel_adsicpe_set(struct ast_channel *chan, enum ast_channel_adsicpe value)
ast_group_t ast_get_group(const char *s)
void ast_channel_tech_set(struct ast_channel *chan, const struct ast_channel_tech *value)
#define ast_channel_unlock(chan)
#define AST_MAX_EXTENSION
void ast_channel_set_writeformat(struct ast_channel *chan, struct ast_format *format)
struct ast_format * ast_channel_readformat(struct ast_channel *chan)
ast_channel_state
ast_channel states
int ast_setstate(struct ast_channel *chan, enum ast_channel_state)
Change the state of a channel.
Standard Command Line Interface.
#define AST_CLI_DEFINE(fn, txt,...)
void ast_cli(int fd, const char *fmt,...)
#define ast_cli_register_multiple(e, len)
Register multiple commands.
static struct ao2_container * codecs
Registered codecs.
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
void ast_channel_stage_snapshot_done(struct ast_channel *chan)
Clear flag to indicate channel snapshot is being staged, and publish snapshot.
void ast_channel_stage_snapshot(struct ast_channel *chan)
Set flag to indicate channel snapshot is being staged.
Application convenience functions, designed to give consistent look and feel to Asterisk apps.
int ast_app_has_voicemail(const char *mailboxes, const char *folder)
Determine if a given mailbox has any voicemail If folder is NULL, defaults to "INBOX"....
Configuration File Parser.
#define ast_config_load(filename, flags)
Load a config file.
char * ast_category_browse(struct ast_config *config, const char *prev_name)
Browse categories.
#define CONFIG_STATUS_FILEINVALID
void ast_config_destroy(struct ast_config *cfg)
Destroys a config.
struct ast_variable * ast_variable_browse(const struct ast_config *config, const char *category_name)
struct ast_features_pickup_config * ast_get_chan_features_pickup_config(struct ast_channel *chan)
Get the pickup configuration options for a channel.
@ AST_CONTROL_RADIO_UNKEY
@ AST_CONTROL_TAKEOFFHOOK
@ AST_CONTROL_CONNECTED_LINE
@ AST_CONTROL_MASQUERADE_NOTIFY
@ AST_CONTROL_PVT_CAUSE_CODE
@ AST_CONTROL_UPDATE_RTP_PEER
struct ast_frame ast_null_frame
#define ast_debug(level,...)
Log a DEBUG message.
#define ast_verb(level,...)
static struct ast_tone_zone_sound * ast_tone_zone_sound_unref(struct ast_tone_zone_sound *ts)
Release a reference to an ast_tone_zone_sound.
int ast_playtones_start(struct ast_channel *chan, int vol, const char *tonelist, int interruptible)
Start playing a list of tones on a channel.
int ast_tone_zone_part_parse(const char *s, struct ast_tone_zone_part *tone_data)
Parse a tone part.
void ast_playtones_stop(struct ast_channel *chan)
Stop playing tones on a channel.
struct ast_tone_zone_sound * ast_get_indication_tone(const struct ast_tone_zone *zone, const char *indication)
Locate a tone zone sound.
static struct ast_tone_zone * ast_tone_zone_unref(struct ast_tone_zone *tz)
Release a reference to an ast_tone_zone.
struct ast_tone_zone * ast_get_indication_zone(const char *country)
locate ast_tone_zone
struct io_context * io_context_create(void)
Creates a context Create a context for I/O operations Basically mallocs an IO structure and sets up s...
int * ast_io_add(struct io_context *ioc, int fd, ast_io_cb callback, short events, void *data)
Adds an IO context.
void io_context_destroy(struct io_context *ioc)
Destroys a context.
int ast_io_wait(struct io_context *ioc, int howlong)
Waits for IO.
#define AST_LIST_TRAVERSE(head, var, field)
Loops over (traverses) the entries in a list.
#define AST_LIST_INSERT_TAIL(head, elm, field)
Appends a list entry to the tail of a list.
#define AST_LIST_ENTRY(type)
Declare a forward link structure inside a list entry.
#define AST_LIST_TRAVERSE_SAFE_END
Closes a safe loop traversal block.
#define AST_LIST_LOCK(head)
Locks a list.
#define AST_LIST_TRAVERSE_SAFE_BEGIN(head, var, field)
Loops safely over (traverses) the entries in a list.
#define AST_LIST_REMOVE_CURRENT(field)
Removes the current entry from a list during a traversal.
#define AST_LIST_UNLOCK(head)
Attempts to unlock a list.
#define AST_LIST_HEAD(name, type)
Defines a structure to be used to hold a list of specified type.
#define AST_LIST_FIRST(head)
Returns the first entry contained in a list.
struct ast_tm * ast_localtime(const struct timeval *timep, struct ast_tm *p_tm, const char *zone)
Timezone-independent version of localtime_r(3).
#define AST_PTHREADT_NULL
#define ast_mutex_init(pmutex)
#define AST_PTHREADT_STOP
#define ast_mutex_unlock(a)
#define ast_mutex_destroy(a)
#define ast_mutex_lock(a)
#define AST_MUTEX_DEFINE_STATIC(mutex)
static char dateformat[256]
Asterisk module definitions.
void ast_update_use_count(void)
Notify when usecount has been changed.
#define AST_MODULE_INFO(keystr, flags_to_set, desc, fields...)
@ AST_MODULE_SUPPORT_EXTENDED
#define ASTERISK_GPL_KEY
The text the key() function should return.
@ AST_MODULE_LOAD_SUCCESS
@ AST_MODULE_LOAD_DECLINE
Module has failed to load, may be in an inconsistent state.
int ast_moh_start(struct ast_channel *chan, const char *mclass, const char *interpclass)
Turn on music on hold on a given channel.
void ast_moh_stop(struct ast_channel *chan)
Turn off music on hold on a given channel.
struct stasis_message_type * ast_mwi_state_type(void)
Get the Stasis Message Bus API message type for MWI messages.
struct stasis_cache * ast_mwi_state_cache(void)
Backend cache for ast_mwi_topic_cached().
int ast_sockaddr_resolve_first_af(struct ast_sockaddr *addr, const char *name, int flag, int family)
Return the first entry from ast_sockaddr_resolve filtered by address family.
int ast_set_qos(int sockfd, int tos, int cos, const char *desc)
Set type of service.
#define ast_sockaddr_to_sin(addr, sin)
Converts a struct ast_sockaddr to a struct sockaddr_in.
#define ast_sockaddr_from_sin(addr, sin)
Converts a struct sockaddr_in to a struct ast_sockaddr.
Wrapper for network related headers, masking differences between various operating systems....
const char * ast_inet_ntoa(struct in_addr ia)
thread-safe replacement for inet_ntoa().
Asterisk file paths, configured in asterisk.conf.
const char * ast_config_AST_VAR_DIR
const char * ast_config_AST_LOG_DIR
Core PBX routines and definitions.
int ast_add_extension(const char *context, int replace, const char *extension, int priority, const char *label, const char *callerid, const char *application, void *data, void(*datad)(void *), const char *registrar)
Add and extension to an extension context.
enum ast_pbx_result ast_pbx_run(struct ast_channel *c)
Execute the PBX in the current thread.
int ast_exists_extension(struct ast_channel *c, const char *context, const char *exten, int priority, const char *callerid)
Determine whether an extension exists.
int ast_context_remove_extension(const char *context, const char *extension, int priority, const char *registrar)
Simply remove extension from context.
enum ast_pbx_result ast_pbx_start(struct ast_channel *c)
Create a new thread and start the PBX.
int ast_matchmore_extension(struct ast_channel *c, const char *context, const char *exten, int priority, const char *callerid)
Looks to see if adding anything to this extension might match something. (exists ^ canmatch)
int ast_pickup_call(struct ast_channel *chan)
Pickup a call.
static struct stasis_subscription * sub
Statsd channel stats. Exmaple of how to subscribe to Stasis events.
Pluggable RTP Architecture.
int ast_rtp_instance_destroy(struct ast_rtp_instance *instance)
Destroy an RTP instance.
struct ast_rtp_instance * ast_rtp_instance_new(const char *engine_name, struct ast_sched_context *sched, const struct ast_sockaddr *sa, void *data)
Create a new RTP instance.
void ast_rtp_instance_stop(struct ast_rtp_instance *instance)
Stop an RTP instance.
@ AST_RTP_GLUE_RESULT_LOCAL
@ AST_RTP_GLUE_RESULT_FORBID
#define ast_rtp_instance_get_remote_address(instance, address)
Get the address of the remote endpoint that we are sending RTP to.
struct ast_frame * ast_rtp_instance_read(struct ast_rtp_instance *instance, int rtcp)
Receive a frame over RTP.
void ast_rtp_instance_set_prop(struct ast_rtp_instance *instance, enum ast_rtp_property property, int value)
Set the value of an RTP instance property.
void ast_rtp_instance_get_local_address(struct ast_rtp_instance *instance, struct ast_sockaddr *address)
Get the local address that we are expecting RTP on.
int ast_rtp_codecs_payload_code_tx(struct ast_rtp_codecs *codecs, int asterisk_format, const struct ast_format *format, int code)
Retrieve a tx mapped payload type based on whether it is an Asterisk format and the code.
int ast_rtp_instance_write(struct ast_rtp_instance *instance, struct ast_frame *frame)
Send a frame out over RTP.
#define ast_rtp_instance_set_remote_address(instance, address)
Set the address of the remote endpoint that we are sending RTP to.
int ast_rtp_instance_set_qos(struct ast_rtp_instance *instance, int tos, int cos, const char *desc)
Set QoS parameters on an RTP session.
void ast_rtp_instance_set_channel_id(struct ast_rtp_instance *instance, const char *uniqueid)
Set the channel that owns this RTP instance.
#define ast_rtp_glue_register(glue)
void ast_rtp_instance_change_source(struct ast_rtp_instance *instance)
Indicate a new source of audio has dropped in and the ssrc should change.
struct ast_rtp_codecs * ast_rtp_instance_get_codecs(struct ast_rtp_instance *instance)
Get the codecs structure of an RTP instance.
int ast_rtp_instance_fd(struct ast_rtp_instance *instance, int rtcp)
Get the file descriptor for an RTP session (or RTCP)
int ast_rtp_glue_unregister(struct ast_rtp_glue *glue)
Unregister RTP glue.
void ast_sched_context_destroy(struct ast_sched_context *c)
destroys a schedule context
struct ast_sched_context * ast_sched_context_create(void)
Create a scheduler context.
void * stasis_message_data(const struct stasis_message *msg)
Get the data contained in a message.
struct stasis_message * stasis_cache_get(struct stasis_cache *cache, struct stasis_message_type *type, const char *id)
Retrieve an item from the cache for the ast_eid_default entity.
static force_inline int attribute_pure ast_str_hash(const char *str)
Compute a hash value on a string.
int attribute_pure ast_true(const char *val)
Make sure something is true. Determine if a string containing a boolean value is "true"....
#define S_COR(a, b, c)
returns the equivalent of logic or for strings, with an additional boolean check: second one if not e...
static force_inline int attribute_pure ast_strlen_zero(const char *s)
#define ast_str_alloca(init_len)
char * ast_trim_blanks(char *str)
Trims trailing whitespace characters from a string.
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Structure to pass both assignedid values to channel drivers.
Structure to describe a channel "technology", ie a channel driver See for examples:
struct ast_format_cap * capabilities
Main Channel structure associated with a channel.
descriptor for a cli entry.
int args
This gets set in ast_cli_register()
Configuration relating to call pickup.
Structure used to handle boolean flags.
struct ast_format * format
Data structure associated with a single frame of data.
struct ast_frame_subclass subclass
enum ast_frame_type frametype
union ast_frame::@237 data
internal representation of ACL entries In principle user applications would have no need for this,...
General jitterbuffer configuration.
unsigned int flags
Combination of the AST_JB_ENABLED, AST_JB_FORCED and AST_JB_LOG flags.
Structure for mutex and tracking information.
The structure that contains MWI state.
struct ast_party_id id
Caller party ID.
struct ast_party_id id
Connected party ID.
struct ast_party_name name
Subscriber name.
struct ast_party_number number
Subscriber phone number.
unsigned char valid
TRUE if the name information is valid/present.
char * str
Subscriber name (Malloced)
unsigned char valid
TRUE if the number information is valid/present.
char * str
Subscriber phone number (Malloced)
Socket address structure.
Support for dynamic strings.
A description of a part of a tone.
const char * data
Description of a tone.
A set of tones for a given locale.
char country[MAX_TONEZONE_COUNTRY]
Country code that this set of tones is for.
Structure for variables, used for configurations and for channel variables.
struct ast_variable * next
Global IO variables are now in a struct in order to be made threadsafe.
A device containing one or more lines.
char softkeynumber[FAVNUM][AST_MAX_EXTENSION]
char redial_number[AST_MAX_EXTENSION]
enum autoprov_extn extension
char softkeylabel[FAVNUM][11]
char expsoftkeylabel[EXPNUM][11]
char context[AST_MAX_EXTENSION]
struct unistim_device::@137 subs
struct unistim_subchannel * ssub[FAVNUM]
struct unistim_device * sp[FAVNUM]
char call_forward[AST_MAX_EXTENSION]
char lst_cid[TEXT_LENGTH_MAX]
struct ast_silence_generator * silence_generator
struct unistim_line * sline[FAVNUM]
char name[DEVICE_NAME_LEN]
char softkeydevice[FAVNUM][16]
struct ast_tone_zone * tz
char extension_number[11]
struct unistimsession * session
struct unistim_device * next
struct unistim_device::@138 lines
char language[MAX_LANGUAGE]
char lst_cnm[TEXT_LENGTH_MAX]
char phone_number[AST_MAX_EXTENSION]
struct ao2_container * trans
struct unistim_line * next
char cid_num[AST_MAX_EXTENSION]
char parkinglot[AST_MAX_CONTEXT]
char exten[AST_MAX_EXTENSION]
struct ast_format_cap * cap
struct unistim_device * parent
char musicclass[MAX_MUSICCLASS]
char mailbox[AST_MAX_EXTENSION]
char accountcode[AST_MAX_ACCOUNT_CODE]
struct unistim_line::@136 list
struct unistim_line * parent
struct ast_rtp_instance * rtp
struct ast_channel * owner
struct unistim_subchannel::@135 list
unsigned char buf[MAX_BUF_NUMBER][MAX_BUF_SIZE]
struct wsabuf wsabufsend[MAX_BUF_NUMBER]
unsigned short seq_server
unsigned short last_seq_ack
struct unistim_device * device
unsigned long tick_next_ping
struct unistimsession * next
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
Handle unaligned data access.
static void put_unaligned_uint16(void *p, unsigned short datum)
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
#define ast_pthread_create(a, b, c, d)
int ast_mkdir(const char *path, int mode)
Recursively create directory path.