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 };
507 { 0xff, 0xff, 0xff, 0xff, 0x02, 0x02, 0xff, 0xff, 0xff, 0xff, 0x9e, 0x03, 0x08 };
509 { 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 };
512 { 0x00, 0x00, 0x00, 0x13, 0x9a, 0x0a, 0x02 };
514 { 0x00, 0x00, 0x00, 0x13, 0x9a, 0x04, 0x03 };
516 { 0x00, 0x00, 0x00, 0x13, 0x99, 0x04, 0x00 };
518 { 0x00, 0x00, 0x00, 0x13, 0x99, 0x03, 0x04 };
520 { 0x00, 0x00, 0x00, 0x13, 0x99, 0x03, 0x03 };
521static const unsigned char packet_recv_r2[] = { 0x00, 0x00, 0x00, 0x13, 0x96, 0x03, 0x03 };
525 { 0x00, 0x00, 0x00, 0x13, 0x89, 0x04, 0x59 };
529 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20 };
534 { 0xff, 0xff, 0xff, 0xff, 0x9e, 0x03, 0x08 };
536 { 0xff, 0xff, 0xff, 0xff, 0x9a, 0x0d, 0x07 };
539 { 0x11, 0x09, 0x02, 0x02, 0x05, 0x06, 0x07,
543 { 0x11, 0x09, 0x02, 0x0a, 0x05, 0x06, 0x07,
5440x08, 0x32, 0x17, 0x04, 0x24, 0x07, 0x19,
545 0x04, 0x07, 0x00, 0x19, 0x05, 0x09, 0x3e, 0x0f, 0x16, 0x05, 0x00, 0x80, 0x00, 0x1e,
546 0x05, 0x12, 0x00, 0x78
550 { 0x16, 0x04, 0x1a, 0x00, 0x16, 0x04, 0x11, 0x00 };
552 { 0x16, 0x04, 0x1a, 0x00, 0x16, 0x04, 0x11, 0x00, 0x16, 0x06, 0x32, 0xdf, 0x00, 0xff,
5530x16, 0x05, 0x1c, 0x00, 0x00, 0x17, 0x05,
554 0x0b, 0x00, 0x00, 0x19, 0x04, 0x00, 0x00, 0x19, 0x04, 0x00, 0x08, 0x19, 0x04, 0x00,
555 0x10, 0x19, 0x04, 0x00, 0x18, 0x16, 0x05,
556 0x31, 0x00, 0x00, 0x16, 0x05, 0x04, 0x00, 0x00
559 { 0x16, 0x04, 0x1a, 0x00, 0x16, 0x04, 0x11, 0x00, 0x16, 0x06, 0x32, 0xdf,
560 0x00, 0xff, 0x16, 0x05, 0x1c, 0x00, 0x00, 0x16, 0x0a, 0x38, 0x00, 0x12, 0xca, 0x03,
561 0xc0, 0xc3, 0xc5, 0x16, 0x16, 0x30, 0x00,
562 0x00, 0x12, 0x12, 0x01, 0x5c, 0x00,
563 0x0f, 0xa0, 0x9c, 0x41,
564 0x0f, 0xa0, 0x9c, 0x41, 0x0a, 0x01,
568 { 0x16, 0x05, 0x1c, 0x00, 0x00 };
572static const unsigned char packet_send_CloseAudioStreamRX[] = { 0x16, 0x05, 0x31, 0x00, 0xff };
573static const unsigned char packet_send_CloseAudioStreamTX[] = { 0x16, 0x05, 0x31, 0xff, 0x00 };
576 { 0x16, 0x06, 0x1b, 0x00, 0x00, 0x05 };
578 { 0x16, 0x06, 0x1d, 0x00, 0x01, 0xb8 };
580 { 0x16, 0x08, 0x1d, 0x00, 0x01, 0xb8, 0x01, 0x5e };
582 { 0x16, 0x06, 0x32, 0xc0, 0x01, 0x00 };
585 { 0x16, 0x06, 0x32, 0xdf, 0x00, 0xff, 0x16, 0x05, 0x1c, 0x00, 0x00, 0x16,
586 0x04, 0x1a, 0x01, 0x16, 0x05, 0x12, 0x13 , 0x18, 0x16, 0x04, 0x18,
587 0x20, 0x16, 0x04, 0x10, 0x00
593 { 0x16, 0x06, 0x32, 0xdf, 0x00, 0xff, 0x16, 0x05, 0x31, 0x00, 0x00, 0x16, 0x04, 0x37, 0x10 };
595 { 0x16, 0x06, 0x32, 0xdf, 0x00, 0xff, 0x19, 0x04, 0x00, 0x10, 0x16, 0x05, 0x1c, 0x00,
598 { 0x16, 0x08, 0x38, 0x00, 0x00, 0xe0, 0x00, 0xa0 };
600 { 0x16, 0x0e, 0x3a, 0x00, 0x02, 0x04, 0x00, 0x00,
602 0x00, 0x00, 0x3e, 0x80
609 { 0x16, 0x1a, 0x30, 0x00, 0xff, 0x00, 0x00, 0x01, 0x00, 0xb8, 0xb8, 0x0e,
6100x0e, 0x01, 0x14, 0x50, 0x00,
611 0x00, 0x14, 0x50, 0x00, 0x00, 0x0a, 0x93, 0x69, 0x05
614 { 0x16, 0x1a, 0x30, 0xff, 0x00, 0x00, 0x00, 0x01, 0x00, 0xb8, 0xb8, 0x0e,
6150x0e, 0x01, 0x14, 0x50,
616 0x00, 0x00, 0x14, 0x50, 0x00, 0x00, 0x0a, 0x93, 0x69, 0x05
620 { 0x16, 0x1a, 0x30, 0x00, 0xff, 0x00, 0x00, 0x02, 0x01, 0xb8, 0xb8, 0x06,
6210x06, 0x81, 0x14, 0x50,
623 0x51, 0x14, 0x50, 0x00, 0x00, 0x0a, 0x93,
627 { 0x16, 0x1a, 0x30, 0xff, 0x00, 0x00, 0x00, 0x02, 0x01, 0xb8, 0xb8, 0x06,
6280x06, 0x81, 0x14, 0x50,
629 0x00, 0x00, 0x14, 0x50, 0x00, 0x00,
630 0x0a, 0x93, 0x69, 0x05
636 0x06, 0x07, 0x08, 0x32
639 { 0x17, 0x04, 0x24, 0x08 };
641 { 0x17, 0x05, 0x0b, 0x05, 0x00, 0x17, 0x08, 0x16,
642 'T',
'i',
'm',
'e',
'r' };
645static const unsigned char packet_send_S7[] = { 0x17, 0x06, 0x0f, 0x30, 0x07, 0x07 };
647 { 0x17, 0x06, 0x10, 0x81, 0x04, 0x20 };
650 {
'J',
'a',
'n',
'F',
'e',
'b',
'M',
'a',
'r',
'A',
'p',
'r',
'M',
'a',
'y',
'J',
'u',
'n',
651 'J',
'u',
'l',
'A',
'u',
'g',
'S',
'e',
'p',
'O',
'c',
't',
'N',
'o',
'v',
'D',
'e',
'c' };
653 { 0x17, 0x0a, 0x15,
'-',
'-',
'-',
'-',
'-',
'-', 0x20 };
655 { 0x17, 0x0f, 0x19, 0x10, 0x01, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
6560x20, 0x20, 0x20, 0x20, 0x19,
657 0x05, 0x0f, 0x01, 0x00
660 { 0x17, 0x10, 0x19, 0x02, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
6610x20, 0x20, 0x20, 0x20 };
663 { 0x17, 0x1e, 0x1b, 0x04, 0x00, 0x25, 0x20, 0x20,
6640x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
665 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
666 0x17, 0x04, 0x10, 0x87
669 { 0x17, 0x20, 0x19, 0x08, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
6700x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
671 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20
674 { 0x17, 0x0b, 0x19, 0x00, 0x20, 0x20, 0x20, 0x20,
680 { 0x17, 0x08, 0x21, 0x1b, 0x2d, 0x41, 0x1b, 0x00 };
683 { 0x17, 0x08, 0x21, 0x1b, 0x2d, 0x42, 0x1b, 0x00 };
686 { 0x17, 0x08, 0x21, 0x1b, 0x2d, 0x44, 0x1b, 0x00 };
689 { 0x17, 0x08, 0x21, 0x1b, 0x2d, 0x4c, 0x1b, 0x00 };
692 { 0x17, 0x08, 0x21, 0x1b, 0x29, 0x49, 0x1b, 0x7e };
699static const unsigned char packet_send_S1[] = { 0x1a, 0x07, 0x07, 0x00, 0x00, 0x00, 0x13 };
702 { 0x1e, 0x05, 0x12, 0x00, 0x78 };
704#define BUFFSEND unsigned char buffsend[64] = { 0x00, 0x00, 0xaa, 0xbb, 0x02, 0x01 }
706static const char tdesc[] =
"UNISTIM Channel Driver";
718 const char *dest,
int *cause);
729 unsigned int duration);
738 .description =
tdesc,
815 char tmp[1024], *p, *p_orig =
NULL, *p_trans =
NULL;
831 while (fgets(
tmp,
sizeof(
tmp), f)) {
832 if (!(p = strchr(
tmp,
'\n'))) {
837 if (!(p = strchr(
tmp,
'"'))) {
840 if (
tmp == strstr(
tmp,
"msgid")) {
842 p = strchr(p_orig,
'"');
843 }
else if (
tmp == strstr(
tmp,
"msgstr")) {
845 p = strchr(p_trans,
'"');
850 if (!p_trans || !p_orig) {
899 return (now.tv_sec * 1000) + (now.tv_usec / 1000);
903static void send_raw_client(
int size,
const unsigned char *data,
struct sockaddr_in *addr_to,
904 const struct sockaddr_in *addr_ourip)
907 struct iovec msg_iov;
909 char buffer[CMSG_SPACE(
sizeof(
struct in_pktinfo))];
910 struct cmsghdr *ip_msg = (
struct cmsghdr *) buffer;
911 struct in_pktinfo *pki = (
struct in_pktinfo *) CMSG_DATA(ip_msg);
918 msg_iov.iov_base = (
char *) data;
919 msg_iov.iov_len = size;
921 msg.msg_name = addr_to;
922 msg.msg_namelen =
sizeof(
struct sockaddr_in);
923 msg.msg_iov = &msg_iov;
925 msg.msg_control = ip_msg;
926 msg.msg_controllen =
sizeof(buffer);
929 ip_msg->cmsg_len = CMSG_LEN(
sizeof(*pki));
930 ip_msg->cmsg_level = IPPROTO_IP;
931 ip_msg->cmsg_type = IP_PKTINFO;
932 pki->ipi_ifindex = 0;
933 pki->ipi_spec_dst.s_addr = addr_ourip->sin_addr.s_addr;
939 ast_verb(0,
"\n**> From %s sending %d bytes to %s ***\n",
944 ast_verb(0,
"\n******************************************\n");
953 if (sendto(
unistimsock, data, size, 0, (
struct sockaddr *) addr_to,
sizeof(*addr_to))
973 memcpy((
void *)data +
sizeof(
unsigned short), (
void *)&
seq,
sizeof(
unsigned short));
982 ast_verb(0,
"Sending datas with seq #0x%04x Using slot #%d :\n", (
unsigned)pte->
seq_server, buf_pos);
1007 struct cmsghdr *cmsg;
1008 struct sockaddr_in peeraddr;
1009 struct in_addr addr;
1010 struct msghdr mh = {
1011 .msg_name = &peeraddr,
1012 .msg_namelen =
sizeof(peeraddr),
1013 .msg_control = cmbuf,
1014 .msg_controllen =
sizeof(cmbuf),
1016 memset(&addr, 0,
sizeof(addr));
1018 err = recvmsg(fd, &mh, MSG_PEEK);
1023 for(cmsg = CMSG_FIRSTHDR(&mh);
1025 cmsg = CMSG_NXTHDR(&mh, cmsg))
1027 if (cmsg->cmsg_level == IPPROTO_IP && cmsg->cmsg_type == IP_PKTINFO) {
1028 struct in_pktinfo *pkt = (
struct in_pktinfo*)CMSG_DATA(cmsg);
1029 addr = pkt->ipi_addr;
1035 memcpy(&toAddr->sin_addr, &addr,
sizeof(
struct in_addr));
1038 memcpy(toAddr, &
public_ip,
sizeof(*toAddr));
1054 memcpy(&s->
sin, addr_from,
sizeof(
struct sockaddr_in));
1059 s->
sout.sin_family = AF_INET;
1061 ast_verb(0,
"Creating a new entry for the phone from %s received via server ip %s\n",
1092 unsigned int tick = 0;
1106 ast_verb(0,
"Our single packet was ACKed.\n");
1115 ast_verb(0,
"Our send queue is completely ACKed.\n");
1122 ast_verb(0,
"We still have packets in our send queue\n");
1131 ast_verb(0,
"Sending start timer\n");
1141 ast_verb(0,
"Sending stop timer\n");
1151 ast_verb(0,
"Sending icon pos %d with status 0x%02hhx\n", pos,
status);
1171 ast_verb(0,
"Sending expansion icon pos %d with status 0x%02hhx\n", pos,
status);
1185 ast_log(
LOG_ERROR,
"[expansion] Asked to display NULL text (pos %d)\n", pos);
1189 ast_verb(0,
"[expansion] Sending text at pos %d\n", pos);
1197 memcpy(buffsend + 11,
text, i);
1206 ast_verb(0,
"Sending Stream Based Tone Off\n");
1219 ast_verb(0,
"Sending Stream Based Tone Frequency Component List Download %d %d\n", tone1, tone2);
1239 ast_verb(0,
"Sending Stream Based Tone On\n");
1280 ast_verb(0,
"Sending favorite pos %d with status 0x%02hhx\n", pos,
status);
1315 if(
d->height == 1 && num % 3 == 2) {
1323 unsigned char i = 0;
1329 ast_verb(0,
"Refreshing all favorite\n");
1331 for (i = 0; i <
FAVNUM; i++) {
1346 for (i = 0; i <
EXPNUM; i++) {
1354 if ((fav < 0) || (fav >=
FAVNUM)) {
1357 if (
d->sline[fav]) {
1360 if (
d->softkeynumber[fav][0] ==
'\0') {
1368 if ((fav < 0) || (fav >=
FAVNUM)) {
1371 if (!
d->sline[fav]) {
1392 for (i = 0; i <
FAVNUM; i++) {
1407 ast_verb(0,
"Found softkey %d for device %s\n", i,
name);
1425 if (softkeylinepos != -1) {
1431 for (i = 0; i <
FAVNUM; i++) {
1432 if (
d->sp[i] == pte->
device) {
1433 if (
d->softkeyicon[i] !=
status) {
1450 ast_verb(0,
"Trying to register extension '%s' into context '%s' to %s\n",
1462 ast_verb(0,
"Trying to unregister extension '%s' context '%s'\n",
1488 ast_verb(0,
"close_client session %p device %p\n", s, s->
device);
1520 ast_verb(0,
"Freeing an unregistered client\n");
1545 ast_verb(0,
"Too many retransmit - freeing client\n");
1557 "Asked to retransmit an ACKed slot ! last_buf_available=%d, seq_server = #0x%04x last_seq_ack = #0x%04x\n",
1563 unsigned short *sbuf = (
unsigned short *) pte->
wsabufsend[i].
buf;
1566 seq = ntohs(sbuf[1]);
1567 ast_verb(0,
"Retransmit slot #%d (seq=#0x%04x), last ack was #0x%04x\n", i,
1584 ast_log(
LOG_ERROR,
"Asked to display NULL text (pos %d, inverse flag %d)\n", pos, inverse);
1591 ast_verb(0,
"Sending text at pos %d, inverse flag %d\n", pos, inverse);
1595 buffsend[11] = inverse;
1600 memcpy(buffsend + 12,
text, i);
1609 ast_verb(0,
"Sending status text\n");
1613 int n = strlen(
text);
1616 for (i = 0, j = 0; i < 4; i++, j += 7) {
1617 int pos = 0x08 + (i * 0x20);
1622 memcpy(buffsend + 10, (j < n) ? (
text + j) :
" ", 7);
1634 memcpy(buffsend + 10,
text, i);
1643 ast_verb(0,
"Sending led_update (%x)\n", (
unsigned)led);
1658 ast_verb(0,
"Sending mute packet (%x)\n", (
unsigned)mute);
1676 ast_verb(0,
"Sending select output packet output=%x volume=%x mute=%x\n",
1677 (
unsigned)output, (
unsigned)
volume, (
unsigned)mute);
1681 buffsend[9] = output;
1689 buffsend[11] = mute;
1711 if (mute_icon != -1) {
1723 ast_verb(0,
"Sending ring packet\n");
1726 buffsend[24] = style + 0x10;
1727 buffsend[29] =
volume * 0x10;
1735 ast_verb(0,
"Sending no ring packet\n");
1746 ast_verb(0,
"Sending title text\n");
1753 memcpy(buffsend + 10,
text, i);
1768 ast_verb(0,
"Sending Month Labels\n");
1777 month = (month + 1)%12;
1788 struct ast_tm atm = { 0, };
1791 ast_verb(0,
"Sending Time & Date\n");
1795 buffsend[10] = (
unsigned char) atm.
tm_mon + 1;
1796 buffsend[11] = (
unsigned char) atm.
tm_mday;
1797 buffsend[12] = (
unsigned char) atm.
tm_hour;
1798 buffsend[13] = (
unsigned char) atm.
tm_min;
1807 struct ast_tm atm = { 0, };
1810 ast_verb(0,
"Sending Time & Date #2\n");
1819 buffsend[14] = (
unsigned char) atm.
tm_mon + 1;
1820 buffsend[15] = (
unsigned char) atm.
tm_mday;
1821 buffsend[16] = (
unsigned char) atm.
tm_hour;
1822 buffsend[17] = (
unsigned char) atm.
tm_min;
1830 struct ast_tm atm = { 0, };
1833 ast_verb(0,
"Sending Time & Date #3\n");
1837 buffsend[10] = (
unsigned char) atm.
tm_mon + 1;
1838 buffsend[11] = (
unsigned char) atm.
tm_mday;
1839 buffsend[12] = (
unsigned char) atm.
tm_hour;
1840 buffsend[13] = (
unsigned char) atm.
tm_min;
1848 ast_verb(0,
"Sending set blink\n");
1860 ast_verb(0,
"Sending set cursor position\n");
1871 const unsigned char* packet_send_charset;
1875 ast_verb(0,
"Sending set default charset\n");
1902 memcpy(buffsend +
SIZE_HEADER, packet_send_charset, packet_size);
1911 ast_verb(0,
"ResumeConnectionWithServer received\n");
1912 ast_verb(0,
"Sending packet_send_query_mac_address\n");
1927 if (!strcasecmp(s->
macaddr,
d->id)) {
1950 memcpy(dst, src,
sizeof(*dst));
1981 ast_debug(1,
"Released sub %u of channel %s@%s\n",
sub->subtype,
sub->parent->name,
sub->parent->parent->name);
1996 ast_verb(3,
"Allocating UNISTIM subchannel #%d on %s ptr=%p\n", x,
d->
name,
sub);
2058 return "SELECTOPTION";
2060 return "SELECTCODEC";
2062 return "SELECTLANGUAGE";
2078 sprintf(&addrmac[i],
"%02hhx",
buf[
tmp]);
2082 ast_verb(0,
"MAC Address received: %s\n", addrmac);
2084 strcpy(pte->
macaddr, addrmac);
2097 ast_verb(0,
"New phone, autoprovisioning on\n");
2103 if (strcasecmp(
d->
name,
"template")) {
2112 memcpy(newd,
d,
sizeof(*newd));
2114 newd->lines.first =
NULL;
2115 newd->lines.last =
NULL;
2125 newl->
name, newd->name);
2126 snprintf(l->name,
sizeof(l->name),
"%d", atoi(l->name) + 1);
2146 newd->session = pte;
2147 newd->language[0] =
'\0';
2148 newd->to_delete = -1;
2184 ast_log(
LOG_ERROR,
"Subchannel lost sice reboot. Hanged channel may apear!\n");
2243 ast_verb(0,
"Sending query_basic_manager_04\n");
2250 ast_verb(0,
"Sending query_basic_manager_10\n");
2262 if (fwrite(&
c, 1, 1, f) != 1) {
2285 char count = 0, *histbuf;
2289 struct ast_tm atm = { 0, };
2319 snprintf(line1,
sizeof(line1),
"%04d/%02d/%02d %02d:%02d:%02d %s",
2325 if ((f = fopen(
tmp,
"r"))) {
2326 struct stat bufstat;
2328 if (stat(
tmp, &bufstat)) {
2334 if (bufstat.st_size != size) {
2336 "History file %s has an incorrect size (%d instead of %d). It will be replaced by a new one.",
2337 tmp, (
int) bufstat.st_size, size);
2349 if ((
errno != ENOENT) && (count == 0)) {
2353 f = fopen(
tmp,
"w");
2376 if (fread(&count, 1, 1, f) != 1) {
2389 if (!(f2 = fopen(tmp2,
"w"))) {
2410 if (fread(histbuf, size, 1, f) != 1) {
2417 if (fwrite(histbuf, size, 1, f2) != 1) {
2434 if (rename(tmp2,
tmp)) {
2486 size = strlen(callerid);
2490 memcpy(data, callerid, size);
2538 ast_verb(0,
"Starting silence generator\n");
2549 ast_verb(0,
"Stopping silence generator\n");
2612 sub->alreadygone = 1;
2616 ast_verb(0,
"attempt_transfer failed.\n");
2623 if (sub_transf->
owner) {
2629 ast_verb(0,
"USTM(%s@%s-%d) channel already destroyed\n",
sub->parent->name,
2690 struct sockaddr_in us = { 0, };
2700 if (htons(us.sin_port)) {
2701 rtp_start = htons(us.sin_port) + 1;
2715 struct sockaddr_in public = { 0, };
2716 struct sockaddr_in us = { 0, };
2717 struct sockaddr_in sin = { 0, };
2729 memcpy(&
public, &us,
sizeof(
public));
2731 memcpy(&
public, &
public_ip,
sizeof(
public));
2734 ast_verb(0,
"RTP started : Our IP/port is : %s:%hd with codec %s\n",
2737 ast_verb(0,
"Starting phone RTP stack. Our public IP is %s\n",
2741 pte =
sub->parent->parent->session;
2747 ast_verb(0,
"Sending packet_send_rtp_packet_size for codec %d\n", codec);
2751 buffsend[10] = (int) codec & 0xffffffffLL;
2755 ast_verb(0,
"Sending Jitter Buffer Parameters Configuration\n");
2761 uint16_t rtcpsin_port = ntohs(us.sin_port) + 1;
2774 memcpy(buffsend + 28, &
public.sin_addr,
sizeof(
public.sin_addr));
2780 memcpy(buffsend + 23, &
public.sin_addr,
sizeof(
public.sin_addr));
2784 buffsend[11] = codec;
2785 buffsend[12] = codec;
2789 ast_verb(0,
"Sending OpenAudioStreamRX\n");
2799 memcpy(buffsend + 28, &
public.sin_addr,
sizeof(
public.sin_addr));
2805 memcpy(buffsend + 23, &
public.sin_addr,
sizeof(
public.sin_addr));
2809 buffsend[11] = codec;
2810 buffsend[12] = codec;
2813 uint16_t rtcpsin_port = htons(us.sin_port) + 1;
2816 ast_verb(0,
"Sending packet_send_call default method\n");
2820 memcpy(buffsend + 53, &
public.sin_addr,
sizeof(
public.sin_addr));
2826 buffsend[40] = codec;
2827 buffsend[41] = codec;
2849 struct sockaddr_in sin = { 0, };
2850 struct sockaddr_in sout = { 0, };
2863 if (!
sub->parent->parent) {
2867 if (!
sub->parent->parent->session) {
2875 sout =
sub->parent->parent->session->sout;
2897 sin.sin_family = AF_INET;
2899 memcpy(&sin.sin_addr, &
sub->parent->parent->session->sin.sin_addr,
2900 sizeof(sin.sin_addr));
2911 "Our read/writeformat has been changed to something incompatible: %s, using %s best codec from %s\n",
2937 ast_verb(0,
"Country code found (%s), freq1=%u freq2=%u\n",
2947 const char *tmp_number =
ustmtext(
"Number:", pte);
2948 int line, tmp_copy, offset = 0, i;
2953 if (offset > strlen(tmp_number)) {
2954 offset = strlen(tmp_number);
2956 tmp_copy = strlen(tmp_number) - offset + 1;
2957 if (tmp_copy >
sizeof(
tmp)) {
2958 tmp_copy =
sizeof(
tmp);
2960 memcpy(
tmp, tmp_number + offset, tmp_copy);
2969 offset = strlen(
tmp);
3036 if ((!
a->owner) || (!
b->owner)) {
3038 "Attempted to swap subchannels with a null owner : sub #%p=%p sub #%p=%p\n",
3039 a,
a->owner,
b,
b->owner);
3064 if (!
sub || !
sub->owner) {
3088 if (!
sub || !
sub->owner) {
3094 ast_verb(0,
"Transfer canceled, hangup our threeway channel\n");
3168 ast_verb(0,
"Started three way call on channel %p (%s) subchan %u\n",
3175 if (softkey == -1) {
3189 sub->softkey = softkey;
3192 ast_verb(0,
"Using softkey %d, line %p\n",
sub->softkey,
sub->parent);
3198 const char *pickupexten;
3208 ast_log(
LOG_ERROR,
"Unable to retrieve pickup configuration options. Unable to detect call pickup extension\n");
3211 pickupexten =
ast_strdupa(pickup_cfg->pickupexten);
3217 ast_verb(0,
"Try to pickup in unistim_new\n");
3276 for (i = 0; i <
FAVNUM; i++) {
3286 if (
sub->softkey == i) {
3289 if (
sub->softkey < 0) {
3296 if (
sub->softkey < 0) {
3304 ast_verb(0,
"Handle Call Incoming for %s@%s\n",
sub->parent->name,
3337 row = (
digit -
'1') % 3;
3338 col = (
digit -
'1' - row) / 3;
3343 }
else if (
digit ==
'*') {
3345 }
else if (
digit ==
'0') {
3347 }
else if (
digit ==
'#') {
3362 if (!
sub || !
sub->owner ||
sub->alreadygone) {
3392 ast_verb(0,
"Handle line w/o sub - dialpage\n");
3402 ast_verb(0,
"Handle favorite w/o sub - dialing\n");
3729#define SELECTCODEC_START_ENTRY_POS 15
3730#define SELECTCODEC_MAX_LENGTH 2
3731#define SELECTCODEC_MSG "Codec number : .."
3740 strcat(
buf,
" (G711u=0,");
3762 if ((keycode >=
KEY_0) && (keycode <=
KEY_9)) {
3769 while (i < pte->size_buff_entry) {
3821 char tmp_language[40];
3873#define SELECTEXTENSION_START_ENTRY_POS 0
3874#define SELECTEXTENSION_MAX_LENGTH 10
3875#define SELECTEXTENSION_MSG ".........."