46 #if defined(__CYGWIN__)
78 #define CAPABILITY AST_FORMAT_ALAW | AST_FORMAT_ULAW
80 #define DEFAULTCONTEXT "default"
81 #define DEFAULTCALLERID "Unknown"
82 #define DEFAULTCALLERNAME " "
83 #define DEFAULTHEIGHT 3
84 #define USTM_LOG_DIR "unistimHistory"
87 #define MAX_BUF_SIZE 64
89 #define MAX_BUF_NUMBER 50
91 #define NB_MAX_RETRANSMIT 8
93 #define IDLE_WAIT 1000
95 #define RETRANSMIT_TIMER 2000
97 #define TIMER_MWI 10000
99 #define DEFAULT_CODEC 0x00
100 #define SIZE_PAGE 4096
101 #define DEVICE_NAME_LEN 16
102 #define AST_CONFIG_MAX_PATH 255
103 #define MAX_ENTRY_LOG 30
106 #define SUB_THREEWAY 1
126 #define OUTPUT_HANDSET 0xC0
127 #define OUTPUT_HEADPHONE 0xC1
128 #define OUTPUT_SPEAKER 0xC2
130 #define VOLUME_LOW 0x01
131 #define VOLUME_LOW_SPEAKER 0x03
132 #define VOLUME_NORMAL 0x02
133 #define VOLUME_INSANELY_LOUD 0x07
135 #define MUTE_OFF 0x00
137 #define MUTE_ON_DISCRET 0xCE
139 #define SIZE_HEADER 6
140 #define SIZE_MAC_ADDR 17
141 #define TEXT_LENGTH_MAX 24
142 #define TEXT_LINE0 0x00
143 #define TEXT_LINE1 0x20
144 #define TEXT_LINE2 0x40
145 #define TEXT_NORMAL 0x05
146 #define TEXT_INVERSE 0x25
147 #define STATUS_LENGTH_MAX 28
149 #define FAV_ICON_NONE 0x00
150 #define FAV_ICON_ONHOOK_BLACK 0x20
151 #define FAV_ICON_ONHOOK_WHITE 0x21
152 #define FAV_ICON_SPEAKER_ONHOOK_BLACK 0x22
153 #define FAV_ICON_SPEAKER_ONHOOK_WHITE 0x23
154 #define FAV_ICON_OFFHOOK_BLACK 0x24
155 #define FAV_ICON_OFFHOOK_WHITE 0x25
156 #define FAV_ICON_ONHOLD_BLACK 0x26
157 #define FAV_ICON_ONHOLD_WHITE 0x27
158 #define FAV_ICON_SPEAKER_OFFHOOK_BLACK 0x28
159 #define FAV_ICON_SPEAKER_OFFHOOK_WHITE 0x29
160 #define FAV_ICON_PHONE_BLACK 0x2A
161 #define FAV_ICON_PHONE_WHITE 0x2B
162 #define FAV_ICON_SPEAKER_ONHOLD_BLACK 0x2C
163 #define FAV_ICON_SPEAKER_ONHOLD_WHITE 0x2D
164 #define FAV_ICON_HEADPHONES 0x2E
165 #define FAV_ICON_HEADPHONES_ONHOLD 0x2F
166 #define FAV_ICON_HOME 0x30
167 #define FAV_ICON_CITY 0x31
168 #define FAV_ICON_SHARP 0x32
169 #define FAV_ICON_PAGER 0x33
170 #define FAV_ICON_CALL_CENTER 0x34
171 #define FAV_ICON_FAX 0x35
172 #define FAV_ICON_MAILBOX 0x36
173 #define FAV_ICON_REFLECT 0x37
174 #define FAV_ICON_COMPUTER 0x38
175 #define FAV_ICON_FORWARD 0x39
176 #define FAV_ICON_LOCKED 0x3A
177 #define FAV_ICON_TRASH 0x3B
178 #define FAV_ICON_INBOX 0x3C
179 #define FAV_ICON_OUTBOX 0x3D
180 #define FAV_ICON_MEETING 0x3E
181 #define FAV_ICON_BOX 0x3F
183 #define FAV_BLINK_FAST 0x20
184 #define FAV_BLINK_SLOW 0x40
186 #define FAV_MAX_LENGTH 0x0A
188 static void dummy(
char *unused, ...)
199 .resync_threshold = 1000,
209 #define DEBUG_TIMER dummy
222 }
qos = { 0, 0, 0, 0 };
512 { 0xff, 0xff, 0xff, 0xff, 0x02, 0x02, 0xff, 0xff, 0xff, 0xff, 0x9e, 0x03, 0x08 };
514 { 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 };
517 { 0x00, 0x00, 0x00, 0x13, 0x9a, 0x0a, 0x02 };
519 { 0x00, 0x00, 0x00, 0x13, 0x99, 0x04, 0x00 };
521 { 0x00, 0x00, 0x00, 0x13, 0x99, 0x03, 0x04 };
523 { 0x00, 0x00, 0x00, 0x13, 0x99, 0x03, 0x03 };
524 static const unsigned char packet_recv_r2[] = { 0x00, 0x00, 0x00, 0x13, 0x96, 0x03, 0x03 };
528 { 0xff, 0xff, 0xff, 0xff, 0x9e, 0x03, 0x08 };
530 { 0xff, 0xff, 0xff, 0xff, 0x9a, 0x0d, 0x07 };
533 { 0x11, 0x09, 0x02, 0x02, 0x05, 0x06, 0x07,
537 { 0x11, 0x09, 0x02, 0x0a, 0x05, 0x06, 0x07,
538 0x08, 0x32, 0x17, 0x04, 0x24, 0x07, 0x19,
539 0x04, 0x07, 0x00, 0x19, 0x05, 0x09, 0x3e, 0x0f, 0x16, 0x05, 0x00, 0x80, 0x00, 0x1e,
540 0x05, 0x12, 0x00, 0x78
544 { 0x16, 0x04, 0x1a, 0x00, 0x16, 0x04, 0x11, 0x00 };
546 { 0x16, 0x04, 0x1a, 0x00, 0x16, 0x04, 0x11, 0x00, 0x16, 0x06, 0x32, 0xdf, 0x00, 0xff,
547 0x16, 0x05, 0x1c, 0x00, 0x00, 0x17, 0x05,
548 0x0b, 0x00, 0x00, 0x19, 0x04, 0x00, 0x00, 0x19, 0x04, 0x00, 0x08, 0x19, 0x04, 0x00,
549 0x10, 0x19, 0x04, 0x00, 0x18, 0x16, 0x05,
550 0x31, 0x00, 0x00, 0x16, 0x05, 0x04, 0x00, 0x00
553 { 0x16, 0x04, 0x1a, 0x00, 0x16, 0x04, 0x11, 0x00, 0x16, 0x06, 0x32, 0xdf,
554 0x00, 0xff, 0x16, 0x05, 0x1c, 0x00, 0x00, 0x16, 0x0a, 0x38, 0x00, 0x12, 0xca, 0x03,
555 0xc0, 0xc3, 0xc5, 0x16, 0x16, 0x30, 0x00,
556 0x00, 0x12, 0x12, 0x01, 0x5c, 0x00,
557 0x0f, 0xa0, 0x9c, 0x41,
558 0x0f, 0xa0, 0x9c, 0x41, 0x0a, 0x01,
562 { 0x16, 0x05, 0x1c, 0x00, 0x00 };
568 { 0x16, 0x06, 0x1b, 0x00, 0x00, 0x05 };
570 { 0x16, 0x06, 0x1d, 0x00, 0x01, 0xb8 };
572 { 0x16, 0x08, 0x1d, 0x00, 0x01, 0xb8, 0x01, 0x5e };
574 { 0x16, 0x06, 0x32, 0xc0, 0x01, 0x00 };
576 { 0x16, 0x06, 0x32, 0xdf, 0x00, 0xff, 0x16, 0x05, 0x1c, 0x00, 0x00, 0x16,
577 0x04, 0x1a, 0x01, 0x16, 0x05, 0x12, 0x13 , 0x18, 0x16, 0x04, 0x18,
578 0x20, 0x16, 0x04, 0x10, 0x00
581 { 0x16, 0x06, 0x32, 0xdf, 0x00, 0xff, 0x16, 0x05, 0x31, 0x00, 0x00, 0x19, 0x04, 0x00,
582 0x10, 0x19, 0x04, 0x00, 0x18, 0x16, 0x05,
583 0x04, 0x00, 0x00, 0x16, 0x04, 0x37, 0x10
586 { 0x16, 0x06, 0x32, 0xdf, 0x00, 0xff, 0x19, 0x04, 0x00, 0x10, 0x16, 0x05, 0x1c, 0x00,
589 { 0x16, 0x08, 0x38, 0x00, 0x00, 0xe0, 0x00, 0xa0 };
591 { 0x16, 0x0e, 0x3a, 0x00, 0x02, 0x04, 0x00, 0x00,
593 0x00, 0x00, 0x3e, 0x80
600 { 0x16, 0x1a, 0x30, 0x00, 0xff, 0x00, 0x00, 0x01, 0x00, 0xb8, 0xb8, 0x0e,
601 0x0e, 0x01, 0x14, 0x50, 0x00,
602 0x00, 0x14, 0x50, 0x00, 0x00, 0x0a, 0x93, 0x69, 0x05
605 { 0x16, 0x1a, 0x30, 0xff, 0x00, 0x00, 0x00, 0x01, 0x00, 0xb8, 0xb8, 0x0e,
606 0x0e, 0x01, 0x14, 0x50,
607 0x00, 0x00, 0x14, 0x50, 0x00, 0x00, 0x0a, 0x93, 0x69, 0x05
611 { 0x16, 0x1a, 0x30, 0x00, 0xff, 0x00, 0x00, 0x02, 0x01, 0xb8, 0xb8, 0x06,
612 0x06, 0x81, 0x14, 0x50,
614 0x51, 0x14, 0x50, 0x00, 0x00, 0x0a, 0x93,
618 { 0x16, 0x1a, 0x30, 0xff, 0x00, 0x00, 0x00, 0x02, 0x01, 0xb8, 0xb8, 0x06,
619 0x06, 0x81, 0x14, 0x50,
620 0x00, 0x00, 0x14, 0x50, 0x00, 0x00,
621 0x0a, 0x93, 0x69, 0x05
627 0x06, 0x07, 0x08, 0x32
630 { 0x17, 0x04, 0x24, 0x08 };
632 { 0x17, 0x05, 0x0b, 0x05, 0x00, 0x17, 0x08, 0x16, 0x44, 0x75, 0x72, 0xe9,
636 static const unsigned char packet_send_S7[] = { 0x17, 0x06, 0x0f, 0x30, 0x07, 0x07 };
638 { 0x17, 0x06, 0x10, 0x81, 0x04, 0x20 };
643 { 0x17, 0x0f, 0x19, 0x10, 0x01, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
644 0x20, 0x20, 0x20, 0x20, 0x19,
645 0x05, 0x0f, 0x01, 0x00
648 { 0x17, 0x10, 0x19, 0x02, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
649 0x20, 0x20, 0x20, 0x20 };
651 { 0x17, 0x1e, 0x1b, 0x04, 0x00, 0x25, 0x20, 0x20,
652 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
653 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
654 0x17, 0x04, 0x10, 0x87
657 { 0x17, 0x20, 0x19, 0x08, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
658 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
659 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20
662 { 0x17, 0x0b, 0x19, 0x00, 0x20, 0x20, 0x20, 0x20,
670 static const unsigned char packet_send_S1[] = { 0x1a, 0x07, 0x07, 0x00, 0x00, 0x00, 0x13 };
673 { 0x1e, 0x05, 0x12, 0x00, 0x78 };
675 #define BUFFSEND unsigned char buffsend[64] = { 0x00, 0x00, 0xaa, 0xbb, 0x02, 0x01 }
677 static const char tdesc[] =
"UNISTIM Channel Driver";
688 void *
data,
int *cause);
699 unsigned int duration);
708 .description =
tdesc,
740 return (now.tv_sec * 1000) + (now.tv_usec / 1000);
744 static void send_raw_client(
int size,
const unsigned char *data,
struct sockaddr_in *addr_to,
745 const struct sockaddr_in *addr_ourip)
748 struct iovec msg_iov;
750 char buffer[CMSG_SPACE(
sizeof(
struct in_pktinfo))];
751 struct cmsghdr *ip_msg = (
struct cmsghdr *) buffer;
752 struct in_pktinfo *pki = (
struct in_pktinfo *) CMSG_DATA(ip_msg);
759 msg_iov.iov_base = (
char *) data;
760 msg_iov.iov_len = size;
762 msg.msg_name = addr_to;
763 msg.msg_namelen =
sizeof(
struct sockaddr_in);
764 msg.msg_iov = &msg_iov;
766 msg.msg_control = ip_msg;
767 msg.msg_controllen =
sizeof(buffer);
770 ip_msg->cmsg_len = CMSG_LEN(
sizeof(*pki));
771 ip_msg->cmsg_level = IPPROTO_IP;
772 ip_msg->cmsg_type = IP_PKTINFO;
773 pki->ipi_ifindex = 0;
774 pki->ipi_spec_dst.s_addr = addr_ourip->sin_addr.s_addr;
780 char iabuf[INET_ADDRSTRLEN];
781 char iabuf2[INET_ADDRSTRLEN];
782 ast_verb(0,
"\n**> From %s sending %d bytes to %s ***\n",
785 for (tmp = 0; tmp < size; tmp++)
786 ast_verb(0,
"%.2x ", (
unsigned char) data[tmp]);
787 ast_verb(0,
"\n******************************************\n");
792 if (sendmsg(unistimsock, &msg, 0) == -1)
795 if (sendto(unistimsock, data, size, 0, (
struct sockaddr *) addr_to,
sizeof(*addr_to))
815 memcpy((
void *)data +
sizeof(
unsigned short), (
void *)&seq,
sizeof(
unsigned short));
824 ast_verb(6,
"Sending datas with seq #0x%.4x Using slot #%d :\n", (
unsigned)pte->
seq_server, buf_pos);
838 memcpy(buffsend +
SIZE_HEADER, packet_send_ping,
sizeof(packet_send_ping));
850 struct in_addr address;
855 memset(&msg, 0,
sizeof(msg));
856 memset(&ip_msg, 0,
sizeof(ip_msg));
859 msg.msg_control = &ip_msg;
860 msg.msg_controllen =
sizeof(ip_msg);
862 err = recvmsg(fd, &msg, MSG_PEEK);
865 memcpy(&toAddr->sin_addr, &ip_msg.address,
sizeof(
struct in_addr));
868 memcpy(&toAddr, &public_ip,
sizeof(&toAddr));
883 memcpy(&s->
sin, addr_from,
sizeof(
struct sockaddr_in));
885 s->
sout.sin_family = AF_INET;
887 ast_verb(0,
"Creating a new entry for the phone from %s received via server ip %s\n",
916 memcpy(buffsend +
SIZE_HEADER, packet_send_end_call,
sizeof(packet_send_end_call));
922 unsigned int tick = 0;
936 ast_verb(6,
"Our single packet was ACKed.\n");
944 ast_verb(6,
"Our send queue is completely ACKed.\n");
950 ast_verb(6,
"We still have packets in our send queue\n");
958 ast_verb(0,
"Sending start timer\n");
959 memcpy(buffsend +
SIZE_HEADER, packet_send_StartTimer,
sizeof(packet_send_StartTimer));
967 ast_verb(0,
"Sending stop timer\n");
968 memcpy(buffsend +
SIZE_HEADER, packet_send_stop_timer,
sizeof(packet_send_stop_timer));
976 ast_verb(0,
"Sending icon pos %d with status 0x%.2x\n", pos, (
unsigned)status);
977 memcpy(buffsend +
SIZE_HEADER, packet_send_icon,
sizeof(packet_send_icon));
988 ast_verb(0,
"Sending Stream Based Tone Off\n");
989 memcpy(buffsend +
SIZE_HEADER, packet_send_stream_based_tone_off,
990 sizeof(packet_send_stream_based_tone_off));
1000 ast_verb(0,
"Sending Stream Based Tone Frequency Component List Download %d %d\n", tone1, tone2);
1003 memcpy(buffsend +
SIZE_HEADER, packet_send_stream_based_tone_single_freq,
1004 sizeof(packet_send_stream_based_tone_single_freq));
1005 buffsend[10] = (tone1 & 0xff00) >> 8;
1006 buffsend[11] = (tone1 & 0x00ff);
1011 memcpy(buffsend +
SIZE_HEADER, packet_send_stream_based_tone_dial_freq,
1012 sizeof(packet_send_stream_based_tone_dial_freq));
1013 buffsend[10] = (tone1 & 0xff00) >> 8;
1014 buffsend[11] = (tone1 & 0x00ff);
1015 buffsend[12] = (tone2 & 0xff00) >> 8;
1016 buffsend[13] = (tone2 & 0x00ff);
1022 ast_verb(0,
"Sending Stream Based Tone On\n");
1023 memcpy(buffsend +
SIZE_HEADER, packet_send_stream_based_tone_on,
1024 sizeof(packet_send_stream_based_tone_on));
1044 ast_verb(0,
"Sending favorite pos %d with status 0x%.2x\n", pos, (
unsigned)status);
1045 memcpy(buffsend +
SIZE_HEADER, packet_send_favorite,
sizeof(packet_send_favorite));
1061 ast_verb(0,
"Refreshing all favorite\n");
1062 for (i = 0; i < 6; i++) {
1086 for (i = 0; i < 6; i++) {
1102 ast_verb(0,
"Trying to register extension '%s' into context '%s' to %s\n",
1113 ast_verb(0,
"Trying to unregister extension '%s' context '%s'\n",
1137 ast_verb(0,
"close_client session %p device %p lines %p sub %p\n",
1155 ast_verb(0,
"Freeing an unregistered client\n");
1177 ast_verb(0,
"Too many retransmit - freeing client\n");
1188 "Asked to retransmit an ACKed slot ! last_buf_available=%d, seq_server = #0x%.4x last_seq_ack = #0x%.4x\n",
1194 unsigned short *sbuf = (
unsigned short *) pte->
wsabufsend[i].
buf;
1197 seq = ntohs(sbuf[1]);
1198 ast_verb(0,
"Retransmit slot #%d (seq=#0x%.4x), last ack was #0x%.4x\n", i,
1216 ast_verb(0,
"Sending text at pos %d, inverse flag %d\n", pos, inverse);
1217 memcpy(buffsend +
SIZE_HEADER, packet_send_text,
sizeof(packet_send_text));
1219 buffsend[11] = inverse;
1223 memcpy(buffsend + 12, text, i);
1232 ast_verb(0,
"Sending status text\n");
1235 int n = strlen(text);
1238 for (i = 0, j = 0; i < 4; i++, j += 7) {
1239 int pos = 0x08 + (i * 0x20);
1240 memcpy(buffsend +
SIZE_HEADER, packet_send_status2,
1241 sizeof(packet_send_status2));
1244 memcpy(buffsend + 10, (j < n) ? (text + j) :
" ", 7);
1252 memcpy(buffsend +
SIZE_HEADER, packet_send_status,
sizeof(packet_send_status));
1256 memcpy(buffsend + 10, text, i);
1269 ast_verb(0,
"Sending led_update (%x)\n", (
unsigned)led);
1270 memcpy(buffsend +
SIZE_HEADER, packet_send_led_update,
sizeof(packet_send_led_update));
1284 ast_verb(0,
"Sending select output packet output=%x volume=%x mute=%x\n", (
unsigned)output,
1285 (
unsigned)volume, (
unsigned)mute);
1286 memcpy(buffsend +
SIZE_HEADER, packet_send_select_output,
1287 sizeof(packet_send_select_output));
1288 buffsend[9] = output;
1293 buffsend[10] = volume;
1297 buffsend[11] =
mute;
1343 ast_verb(0,
"Sending ring packet\n");
1344 memcpy(buffsend +
SIZE_HEADER, packet_send_ring,
sizeof(packet_send_ring));
1345 buffsend[24] = style + 0x10;
1346 buffsend[29] = volume * 0x10;
1354 ast_verb(0,
"Sending no ring packet\n");
1355 memcpy(buffsend +
SIZE_HEADER, packet_send_no_ring,
sizeof(packet_send_no_ring));
1364 ast_verb(0,
"Sending title text\n");
1365 memcpy(buffsend +
SIZE_HEADER, packet_send_title,
sizeof(packet_send_title));
1369 memcpy(buffsend + 10, text, i);
1378 struct ast_tm atm = { 0, };
1381 ast_verb(0,
"Sending Time & Date\n");
1382 memcpy(buffsend +
SIZE_HEADER, packet_send_date_time,
sizeof(packet_send_date_time));
1384 buffsend[10] = (
unsigned char) atm.
tm_mon + 1;
1385 buffsend[11] = (
unsigned char) atm.
tm_mday;
1386 buffsend[12] = (
unsigned char) atm.
tm_hour;
1387 buffsend[13] = (
unsigned char) atm.
tm_min;
1395 struct ast_tm atm = { 0, };
1398 ast_verb(0,
"Sending Time & Date #2\n");
1399 memcpy(buffsend +
SIZE_HEADER, packet_send_date_time2,
sizeof(packet_send_date_time2));
1405 buffsend[14] = (
unsigned char) atm.
tm_mon + 1;
1406 buffsend[15] = (
unsigned char) atm.
tm_mday;
1407 buffsend[16] = (
unsigned char) atm.
tm_hour;
1408 buffsend[17] = (
unsigned char) atm.
tm_min;
1416 struct ast_tm atm = { 0, };
1419 ast_verb(0,
"Sending Time & Date #3\n");
1420 memcpy(buffsend +
SIZE_HEADER, packet_send_date_time3,
sizeof(packet_send_date_time3));
1422 buffsend[10] = (
unsigned char) atm.
tm_mon + 1;
1423 buffsend[11] = (
unsigned char) atm.
tm_mday;
1424 buffsend[12] = (
unsigned char) atm.
tm_hour;
1425 buffsend[13] = (
unsigned char) atm.
tm_min;
1433 ast_verb(0,
"Sending set blink\n");
1434 memcpy(buffsend +
SIZE_HEADER, packet_send_blink_cursor,
sizeof(packet_send_blink_cursor));
1444 ast_verb(0,
"Sending set cursor position\n");
1445 memcpy(buffsend +
SIZE_HEADER, packet_send_set_pos_cursor,
1446 sizeof(packet_send_set_pos_cursor));
1456 ast_verb(0,
"ResumeConnectionWithServer received\n");
1457 ast_verb(0,
"Sending packet_send_query_mac_address\n");
1459 memcpy(buffsend +
SIZE_HEADER, packet_send_query_mac_address,
1460 sizeof(packet_send_query_mac_address));
1515 ast_debug(1,
"Released sub %d of channel %s@%s\n", x, p->
name,
1530 sprintf(&addrmac[i],
"%.2x", (
unsigned) buf[tmp]);
1534 ast_verb(0,
"Mac Address received : %s\n", addrmac);
1536 strcpy(pte->
macaddr, addrmac);
1539 switch (autoprovisioning) {
1549 ast_verb(0,
"New phone, autoprovisioning on\n");
1554 if (!strcasecmp(d->
name,
"template")) {
1561 memcpy(newd, d,
sizeof(*newd));
1568 memcpy(newl, d->
lines,
sizeof(*newl));
1614 "Autoprovisioning with database is not yet functional\n");
1665 memcpy(buffsend + SIZE_HEADER, packet_send_S1,
sizeof(packet_send_S1));
1666 send_client(SIZE_HEADER +
sizeof(packet_send_S1), buffsend, pte);
1669 ast_verb(0,
"Sending query_basic_manager_04\n");
1670 memcpy(buffsend + SIZE_HEADER, packet_send_query_basic_manager_04,
1671 sizeof(packet_send_query_basic_manager_04));
1672 send_client(SIZE_HEADER +
sizeof(packet_send_query_basic_manager_04), buffsend, pte);
1675 ast_verb(0,
"Sending query_basic_manager_10\n");
1676 memcpy(buffsend + SIZE_HEADER, packet_send_query_basic_manager_10,
1677 sizeof(packet_send_query_basic_manager_10));
1678 send_client(SIZE_HEADER +
sizeof(packet_send_query_basic_manager_10), buffsend, pte);
1686 if (fwrite(&c, 1, 1, f) != 1) {
1709 char count = 0, *histbuf;
1713 struct ast_tm atm = { 0, };
1727 if (
errno != EEXIST) {
1736 strcpy(tmp2,
"Miss");
1738 strcpy(tmp2,
"Fail");
1740 strcpy(tmp2,
"Answ");
1741 snprintf(line1,
sizeof(line1),
"%04d/%02d/%02d %02d:%02d:%02d %s",
1747 if ((f = fopen(tmp,
"r"))) {
1748 struct stat bufstat;
1750 if (stat(tmp, &bufstat)) {
1756 if (bufstat.st_size != size) {
1758 "History file %s has an incorrect size (%d instead of %d). It will be replaced by a new one.",
1759 tmp, (
int) bufstat.st_size, size);
1771 if ((
errno != ENOENT) && (count == 0)) {
1775 f = fopen(tmp,
"w");
1797 if (fread(&count, 1, 1, f) != 1) {
1810 if (!(f2 = fopen(tmp2,
"w"))) {
1832 if (fread(histbuf, size, 1, f) != 1) {
1839 if (fwrite(histbuf, size, 1, f2) != 1) {
1853 if (rename(tmp2, tmp))
1874 ast_verb(0,
"Swapping %d and %d\n", a, b);
1878 "Attempted to swap subchannels with a null owner : sub #%d=%p sub #%d=%p\n",
1899 *chana = NULL, *chanb = NULL, *bridgea = NULL, *bridgeb = NULL, *peera =
1900 NULL, *peerb = NULL, *peerc = NULL;
1915 }
else if (bridgeb) {
1921 if (peera && peerb && peerc && (peerb != peerc)) {
1935 "Transfer attempted with no appropriate bridged calls to transfer\n");
1958 size = strlen(callerid);
1961 memcpy(data, callerid, size);
1976 ast_verb(0,
"attempt_transfer failed.\n");
2027 struct sockaddr_in us = { 0, };
2028 struct sockaddr_in public = { 0, };
2029 struct sockaddr_in sin = { 0, };
2031 struct sockaddr_in sout = { 0, };
2078 sin.sin_family = AF_INET;
2081 sizeof(sin.sin_addr));
2090 "Our read/writeformat has been changed to something incompatible: %s, using %s best codec from %s\n",
2099 if (public_ip.sin_family == 0)
2100 memcpy(&
public, &us,
sizeof(
public));
2102 memcpy(&
public, &public_ip,
sizeof(
public));
2104 ast_verb(0,
"RTP started : Our IP/port is : %s:%hd with codec %s\n",
2107 ast_verb(0,
"Starting phone RTP stack. Our public IP is %s\n",
2114 memcpy(buffsend +
SIZE_HEADER, packet_send_rtp_packet_size,
2115 sizeof(packet_send_rtp_packet_size));
2116 buffsend[10] = (int) codec & 0xffffffffLL;
2121 ast_verb(0,
"Sending Jitter Buffer Parameters Configuration\n");
2122 memcpy(buffsend +
SIZE_HEADER, packet_send_jitter_buffer_conf,
2123 sizeof(packet_send_jitter_buffer_conf));
2127 uint16_t rtcpsin_port = htons(us.sin_port) + 1;
2130 ast_verb(0,
"Sending OpenAudioStreamTX using method #%d\n",
2133 memcpy(buffsend +
SIZE_HEADER, packet_send_open_audio_stream_tx3,
2134 sizeof(packet_send_open_audio_stream_tx3));
2136 memcpy(buffsend +
SIZE_HEADER, packet_send_open_audio_stream_tx,
2137 sizeof(packet_send_open_audio_stream_tx));
2139 memcpy(buffsend + 28, &
public.sin_addr,
sizeof(
public.sin_addr));
2140 buffsend[20] = (htons(sin.sin_port) & 0xff00) >> 8;
2141 buffsend[21] = (htons(sin.sin_port) & 0x00ff);
2142 buffsend[23] = (rtcpsin_port & 0x00ff);
2143 buffsend[22] = (rtcpsin_port & 0xff00) >> 8;
2144 buffsend[25] = (us.sin_port & 0xff00) >> 8;
2145 buffsend[24] = (us.sin_port & 0x00ff);
2146 buffsend[27] = (rtcpsin_port & 0x00ff);
2147 buffsend[26] = (rtcpsin_port & 0xff00) >> 8;
2149 memcpy(buffsend + 23, &
public.sin_addr,
sizeof(
public.sin_addr));
2150 buffsend[15] = (htons(sin.sin_port) & 0xff00) >> 8;
2151 buffsend[16] = (htons(sin.sin_port) & 0x00ff);
2152 buffsend[20] = (us.sin_port & 0xff00) >> 8;
2153 buffsend[19] = (us.sin_port & 0x00ff);
2155 buffsend[11] = codec;
2156 buffsend[12] = codec;
2161 ast_verb(0,
"Sending OpenAudioStreamRX\n");
2163 memcpy(buffsend +
SIZE_HEADER, packet_send_open_audio_stream_rx3,
2164 sizeof(packet_send_open_audio_stream_rx3));
2166 memcpy(buffsend +
SIZE_HEADER, packet_send_open_audio_stream_rx,
2167 sizeof(packet_send_open_audio_stream_rx));
2169 memcpy(buffsend + 28, &
public.sin_addr,
sizeof(
public.sin_addr));
2170 buffsend[20] = (htons(sin.sin_port) & 0xff00) >> 8;
2171 buffsend[21] = (htons(sin.sin_port) & 0x00ff);
2172 buffsend[23] = (rtcpsin_port & 0x00ff);
2173 buffsend[22] = (rtcpsin_port & 0xff00) >> 8;
2174 buffsend[25] = (us.sin_port & 0xff00) >> 8;
2175 buffsend[24] = (us.sin_port & 0x00ff);
2176 buffsend[27] = (rtcpsin_port & 0x00ff);
2177 buffsend[26] = (rtcpsin_port & 0xff00) >> 8;
2179 memcpy(buffsend + 23, &
public.sin_addr,
sizeof(
public.sin_addr));
2180 buffsend[15] = (htons(sin.sin_port) & 0xff00) >> 8;
2181 buffsend[16] = (htons(sin.sin_port) & 0x00ff);
2182 buffsend[20] = (us.sin_port & 0xff00) >> 8;
2183 buffsend[19] = (us.sin_port & 0x00ff);
2185 buffsend[11] = codec;
2186 buffsend[12] = codec;
2190 uint16_t rtcpsin_port = htons(us.sin_port) + 1;
2193 ast_verb(0,
"Sending packet_send_call default method\n");
2195 memcpy(buffsend +
SIZE_HEADER, packet_send_call,
sizeof(packet_send_call));
2196 memcpy(buffsend + 53, &
public.sin_addr,
sizeof(
public.sin_addr));
2198 buffsend[49] = (us.sin_port & 0x00ff);
2199 buffsend[50] = (us.sin_port & 0xff00) >> 8;
2201 buffsend[52] = (rtcpsin_port & 0x00ff);
2202 buffsend[51] = (rtcpsin_port & 0xff00) >> 8;
2204 buffsend[40] = codec;
2205 buffsend[41] = codec;
2218 buffsend[45] = (htons(sin.sin_port) & 0xff00) >> 8;
2219 buffsend[46] = (htons(sin.sin_port) & 0x00ff);
2220 buffsend[47] = (rtcpsin_port & 0xff00) >> 8;
2221 buffsend[48] = (rtcpsin_port & 0x00ff);
2234 ast_verb(0,
"No country defined, using US tone\n");
2240 ast_verb(0,
"Country code != 2 char, using US tone\n");
2245 while (frequency[i].freq1) {
2249 ast_verb(0,
"Country code found (%s), freq1=%d freq2=%d\n",
2250 frequency[i].
country, frequency[i].freq1, frequency[i].freq2);
2251 send_tone(pte, frequency[i].freq1, frequency[i].freq2);
2272 strcpy(tmp,
"Number : ...............");
2339 ast_verb(0,
"Transfer canceled, hangup our threeway channel\n");
2365 else if (unistimdebug)
2366 ast_verb(0,
"Starting silence generator\n");
2415 if (!subchannel->
owner) {
2421 "Can't transfer while an another transfer is taking place\n");
2431 ast_verb(0,
"Stopping silence generator\n");
2462 ast_verb(0,
"Started three way call on channel %p (%s) subchan %u\n",
2482 }
else if (unistimdebug)
2518 ast_verb(0,
"Send Digit %c\n", digit);
2640 "Unable to find peer subchannel for music on hold\n");
2695 char tmpbuf[] =
"Number : ...............";
2702 while (i < pte->device->size_phone_number) {
2712 tmpbuf[i + 9] = keycode;
2765 ast_verb(0,
"Stopping silence generator\n");
2816 #define SELECTCODEC_START_ENTRY_POS 15
2817 #define SELECTCODEC_MAX_LENGTH 2
2818 #define SELECTCODEC_MSG "Codec number : .."
2821 char buf[30],
buf2[5];
2824 strcpy(buf,
"Using codec ");
2827 strcat(buf,
" (G711u=0,");
2849 if ((keycode >=
KEY_0) && (keycode <=
KEY_9)) {
2856 while (i < pte->size_buff_entry) {
2893 #define SELECTEXTENSION_START_ENTRY_POS 0
2894 #define SELECTEXTENSION_MAX_LENGTH 10
2895 #define SELECTEXTENSION_MSG ".........."
2920 if ((keycode >=
KEY_0) && (keycode <=
KEY_9)) {
2927 while (i < pte->size_buff_entry) {
2954 if (d->
id[0] ==
'T') {
3010 int pos = 0, i = 0, size = strlen(number);
3012 for (; i < size; i++) {
3013 if ((number[i] >=
'0') && (number[i] <=
'9')) {
3018 number[pos] = number[i];
3036 line[
sizeof(line) - 1] =
'\0';
3043 line[
sizeof(line) - 1] =
'\0';
3051 line[
sizeof(line) - 1] =
'\0';
3055 snprintf(line,
sizeof(line),
"Call %03d/%03d", pte->
buff_entry[2],
3062 strcpy(func1,
"Prvious");
3066 strcpy(func2,
"Next ");
3068 strcpy(func3,
"Redial ");
3071 snprintf(status,
sizeof(status),
"%s%s%sCancel", func1, func2, func3);
3082 *f = fopen(tmp,
"r");
3087 if (fread(&count, 1, 1, *f) != 1) {
3164 strcpy(tmpbuf,
"IP : ");
3284 if (fseek(f, offset, SEEK_CUR)) {
3301 if (fseek(f, offset, SEEK_CUR)) {
3340 memcpy(buffsend +
SIZE_HEADER, packet_send_s4,
sizeof(packet_send_s4));
3346 memcpy(buffsend +
SIZE_HEADER, packet_send_S7,
sizeof(packet_send_S7));
3350 memcpy(buffsend +
SIZE_HEADER, packet_send_Contrast,
sizeof(packet_send_Contrast));
3357 memcpy(buffsend +
SIZE_HEADER, packet_send_s9,
sizeof(packet_send_s9));
3363 memcpy(buffsend +
SIZE_HEADER, packet_send_S7,
sizeof(packet_send_S7));
3375 for (i = 1; i < 6; i++)
3379 strcpy(tmp,
"MAC = ");
3391 memcpy(buffsend +
SIZE_HEADER, packet_send_arrow,
sizeof(packet_send_arrow));
3400 (buf +
SIZE_HEADER, packet_recv_resume_connection_with_server,
3401 sizeof(packet_recv_resume_connection_with_server)) == 0) {
3405 if (memcmp(buf +
SIZE_HEADER, packet_recv_firm_version,
sizeof(packet_recv_firm_version)) ==
3409 ast_verb(0,
"Got the firmware version : '%s'\n", buf + 13);
3413 if (memcmp(buf +
SIZE_HEADER, packet_recv_mac_addr,
sizeof(packet_recv_mac_addr)) == 0) {
3417 if (memcmp(buf +
SIZE_HEADER, packet_recv_r2,
sizeof(packet_recv_r2)) == 0) {
3425 ast_verb(0,
"Request not authorized in this state\n");
3428 if (!memcmp(buf +
SIZE_HEADER, packet_recv_pressed_key,
sizeof(packet_recv_pressed_key))) {
3429 char keycode = buf[13];
3432 ast_verb(0,
"Key pressed : keycode = 0x%.2x - current state : %d\n", (
unsigned)keycode,
3435 switch (pte->
state) {
3438 ast_verb(0,
"No keys allowed in the init state\n");
3442 ast_verb(0,
"No keys allowed in authdeny state\n");
3470 if (memcmp(buf +
SIZE_HEADER, packet_recv_pick_up,
sizeof(packet_recv_pick_up)) == 0) {
3492 if (memcmp(buf +
SIZE_HEADER, packet_recv_hangup,
sizeof(packet_recv_hangup)) == 0) {
3509 strcat(tmpbuf,
" Unknown request packet\n");
3516 struct sockaddr_in *addr_from)
3518 unsigned short *sbuf = (
unsigned short *) buf;
3532 if (sbuf[0] == 0xffff) {
3533 if (size !=
sizeof(packet_rcv_discovery)) {
3536 if (memcmp(buf, packet_rcv_discovery,
sizeof(packet_rcv_discovery)) == 0) {
3538 ast_verb(0,
"Discovery packet received - Sending Discovery ACK\n");
3542 ast_verb(1,
"Duplicated Discovery packet\n");
3544 packet_send_discovery_ack, addr_from, &pte->
sout);
3550 packet_send_discovery_ack, addr_from, &pte->
sout);
3556 packet_send_discovery_ack, addr_from, &pte->
sout);
3566 ast_verb(0,
"%s Not a discovery packet from an unknown source : ignoring\n",
3580 seq = ntohs(sbuf[1]);
3584 ast_verb(6,
"ACK received for packet #0x%.4x\n", (
unsigned)seq);
3595 ast_verb(0,
"ACK at 0xffff, restarting counter.\n");
3599 "%s Warning : ACK received for an already ACKed packet : #0x%.4x we are at #0x%.4x\n",
3606 "%s Error : ACK received for a non-existent packet : #0x%.4x\n",
3612 ast_verb(0,
"%s ACK gap : Received ACK #0x%.4x, previous was #0x%.4x\n",
3634 "%s Warning : received a retransmitted packet : #0x%.4x (we are at #0x%.4x)\n",
3635 tmpbuf, (
unsigned)seq, (
unsigned)pte->
seq_phone);
3644 "%s Warning : we lost a packet : received #0x%.4x (we are at #0x%.4x)\n",
3645 tmpbuf, (
unsigned)seq, (
unsigned)pte->
seq_phone);
3649 ast_log(
LOG_NOTICE,
"%s Retransmit request for packet #0x%.4x\n", tmpbuf, (
unsigned)seq);
3652 "%s Error : received a request for an already ACKed packet : #0x%.4x\n",
3658 "%s Error : received a request for a non-existent packet : #0x%.4x\n",
3665 ast_log(
LOG_NOTICE,
"%s Unknown request : got 0x%.2x expected 0x00,0x01 or 0x02\n",
3666 tmpbuf, (
unsigned)buf[4]);
3779 ast_debug(1,
"Asked to hangup channel not connected\n");
3787 ast_verb(0,
"Destroying RTP session\n");
3799 ast_verb(0,
"Real call disconnected while talking to threeway\n");
3807 ast_verb(0,
"threeway call disconnected, switching to real call\n");
3829 ast_verb(0,
"Asked to hangup channel not connected (no session)\n");
3832 ast_verb(0,
"Destroying RTP session\n");
3842 ast_verb(0,
"Stopping silence generator\n");
3848 "Trying to stop silence generator on a null channel !\n");
3857 ast_verb(0,
"Destroying RTP session\n");
3860 }
else if (unistimdebug)
3861 ast_verb(0,
"No RTP session to destroy\n");
3864 ast_verb(0,
"Cleaning other subchannels\n");
3911 struct sockaddr_in addr_from = { 0, };
3915 int dw_num_bytes_rcvd;
3917 int dw_num_bytes_rcvdd;
3918 char iabuf[INET_ADDRSTRLEN];
3922 recvfrom(unistimsock, buff,
SIZE_PAGE, 0, (
struct sockaddr *) &addr_from,
3924 if (dw_num_bytes_rcvd == -1) {
3925 if (
errno == EAGAIN)
3927 else if (
errno != ECONNREFUSED)
3936 if (cur->
sin.sin_addr.s_addr == addr_from.sin_addr.s_addr) {
3947 ast_verb(0,
"\n*** Dump %d bytes from %s - phone_table[%d] ***\n",
3949 for (dw_num_bytes_rcvdd = 0; dw_num_bytes_rcvdd < dw_num_bytes_rcvd;
3950 dw_num_bytes_rcvdd++)
3951 ast_verb(0,
"%.2x ", (
unsigned char) buff[dw_num_bytes_rcvdd]);
3952 ast_verb(0,
"\n******************************************\n");
3957 ast_verb(0,
"Received a packet from an unknown source\n");
3958 parsing(dw_num_bytes_rcvd, buff, NULL, (
struct sockaddr_in *) &addr_from);
3961 parsing(dw_num_bytes_rcvd, buff, cur, (
struct sockaddr_in *) &addr_from);
3983 switch (ast->
fdno) {
3999 "Oooh, format changed from %s to %s\n",
4042 "Asked to transmit frame type %s, while native formats is %s (read/write = (%s/%s)\n",
4069 ast_debug(1,
"New owner for channel USTM/%s@%s-%u is %s\n", l->
name,
4072 if (p->
owner != oldchan) {
4091 return "Other end has hungup";
4093 return "Local ring";
4095 return "Remote end is ringing";
4097 return "Remote end has answered";
4099 return "Remote end is busy";
4101 return "Make it go off hook";
4103 return "Line is off hook";
4105 return "Congestion (circuits busy)";
4107 return "Flash hook";
4111 return "Set a low-level option";
4115 return "Un-Key Radio";
4123 const char *indication)
4143 ast_verb(3,
"Asked to indicate '%s' condition on channel %s\n",
4218 at = strchr(line,
'@');
4228 at = strchr(device,
'/');
4232 if (!strcasecmp(d->
name, device)) {
4239 if (!strcasecmp(l->
name, line)) {
4246 if ((*at <
'0') || (*at >
'7'))
4249 char ring_volume = -1;
4250 char ring_style = *at -
'0';
4252 if ((*at >=
'0') && (*at <=
'3'))
4253 ring_volume = *at -
'0';
4255 ast_verb(0,
"Distinctive ring : style #%d volume %d\n",
4256 ring_style, ring_volume);
4300 ast_verb(0,
"Send Digit off %c\n", digit);
4323 ast_verb(0,
"unistim_sendtext called\n");
4330 size = strlen(text);
4331 if (text[0] ==
'@') {
4332 int pos = 0, i = 1, tok = 0, sz = 0;
4338 memset(label, 0, 11);
4339 memset(number, 0, 16);
4344 if ((cur <
'0') && (cur >
'5')) {
4346 "sendtext failed : position must be a number beetween 0 and 5\n");
4360 if ((cur <
'3') && (cur >
'6')) {
4362 "sendtext failed : icon must be a number beetween 32 and 63 (first digit invalid)\n");
4365 icon = (cur -
'0') * 10;
4369 if ((cur <
'0') && (cur >
'9')) {
4371 "sendtext failed : icon must be a number beetween 32 and 63 (second digit invalid)\n");
4374 icon += (cur -
'0');
4380 "sendtext failed : icon must be a number beetween 32 and 63 (too many digits)\n");
4399 "sendtext failed : extension too long = %d (15 car max)\n",
4435 tmp[
sizeof(tmp) - 1] =
'\0';
4441 tmp[
sizeof(tmp) - 1] =
'\0';
4444 tmp[
sizeof(tmp) - 1] =
'\0';
4460 context =
"default";
4511 ast_verb(0,
"unistim_new sub=%u (%p) chan=%p\n", sub->
subtype, sub, tmp);
4522 char tmp1[256], tmp2[256], tmp3[256];
4523 ast_verb(0,
"Best codec = %s from nativeformats %s (line cap=%s global=%s)\n",
4531 ast_verb(0,
"New unistim channel with a previous rtp handle ?\n");
4560 char *
name, *loc, *instr;
4576 ast_verb(0,
"Starting pbx in unistim_new\n");
4590 unsigned int dw_timeout = 0;
4596 if (unistimsock > -1)
4604 dw_timeout = UINT_MAX;
4607 DEBUG_TIMER(
"checking timeout for session %p with tick = %u\n", cur, tick);
4609 DEBUG_TIMER(
"checking timeout for session %p timeout = %u\n", cur,
4619 DEBUG_TIMER(
"The chained link was modified, restarting...\n");
4621 dw_timeout = UINT_MAX;
4626 if (dw_timeout > cur->
timeout - tick)
4627 dw_timeout = cur->
timeout - tick;
4650 unistim_reloading = 0;
4653 ast_verb(1,
"Reloading unistim.conf...\n");
4656 pthread_testcancel();
4665 pthread_attr_t attr;
4673 if (monitor_thread == pthread_self()) {
4680 pthread_kill(monitor_thread, SIGURG);
4682 pthread_attr_init(&attr);
4683 pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
4709 "Asked to get a channel of format %s while capability is %s result : %s\n",
4715 "Asked to get a channel of unsupported format %s while capability is %s\n",
4733 ast_verb(3,
"unistim_request(%s)\n", tmp);
4737 ast_verb(0,
"Can't create channel : Busy !\n");
4764 e->
command =
"unistim show info";
4766 "Usage: unistim show info\n"
4767 " Dump internal structures.\n";
4777 ast_cli(a->
fd,
"Dumping internal structures :\ndevice\n->line\n-->sub\n");
4779 ast_cli(a->
fd,
"\nname=%s id=%s line=%p ha=%p sess=%p device=%p\n",
4782 line = device->
lines;
4785 "->name=%s fullname=%s exten=%s callid=%s cap=%" PRId64
" device=%p line=%p\n",
4789 sub = line->
subs[i];
4797 ast_cli(a->
fd,
"Warning ! subchannel->subs[%d] have a subtype=%u\n", i,
4800 "-->subtype=%u chan=%p rtp=%p bridge=%p line=%p alreadygone=%d\n",
4806 device = device->
next;
4813 "sin=%s timeout=%d state=%d macaddr=%s device=%p session=%p\n",
4828 unsigned char c, cc;
4833 e->
command =
"unistim send packet";
4835 "Usage: unistim send packet USTM/line@name hexa\n"
4836 " unistim send packet USTM/1000@hans 19040004\n";
4846 if (strlen(a->
argv[3]) < 9)
4856 ast_cli(a->
fd,
"Can't find '%s'\n", tmp);
4860 ast_cli(a->
fd,
"'%s' is not connected\n", tmp);
4864 for (i = 0; i <
len; i++) {
4876 tmp[j++] = (c << 4) | cc;
4887 e->
command =
"unistim set debug {on|off}";
4889 "Usage: unistim set debug\n"
4890 " Display debug messages.\n";
4900 if (!strcasecmp(a->
argv[3],
"on")) {
4902 ast_cli(a->
fd,
"UNISTIM Debugging Enabled\n");
4903 }
else if (!strcasecmp(a->
argv[3],
"off")) {
4905 ast_cli(a->
fd,
"UNISTIM Debugging Disabled\n");
4920 e->
command =
"unistim reload";
4922 "Usage: unistim reload\n"
4923 " Reloads UNISTIM configuration from unistim.conf\n";
4937 if (!unistim_reloading)
4938 unistim_reloading = 1;
4953 static void unquote(
char *out,
const char *src,
int maxlen)
4955 int len = strlen(src);
4958 if ((len > 1) && src[0] ==
'\"') {
4963 if (maxlen > len - 1)
4965 memcpy(out, src, maxlen);
4966 ((
char *) out)[maxlen] =
'\0';
4968 memcpy(out, src, maxlen);
4979 int len = strlen(text);
4983 if ((len > 2) && (line[1] ==
'@')) {
4985 if ((p >=
'0') && (p <=
'5'))
4989 "Invalid position for bookmark : must be between 0 and 5\n");
4996 memmove(line, line + 2,
sizeof(line) - 2);
4999 for (p = 0; p <= 5; p++) {
5008 at = strchr(line,
'@');
5016 at = strchr(at,
'@');
5026 at = strchr(number,
'@');
5037 if (strncmp(icon,
"USTM/", 5))
5047 ast_verb(0,
"New bookmark at pos %d label='%s' number='%s' icon=%x\n",
5058 for (i = 0; i < 6; i++) {
5069 if (d->
sp[i] == NULL)
5083 int nbsoftkey,
dateformat, timeformat, callhistory;
5086 char ringvolume, ringstyle;
5093 if (!strcmp(d->
name, cat)) {
5095 if (unistimsock < 0) {
5126 linelabel[0] =
'\0';
5134 if (!strcasecmp(v->
name,
"rtp_port"))
5136 else if (!strcasecmp(v->
name,
"rtp_method"))
5138 else if (!strcasecmp(v->
name,
"status_method"))
5140 else if (!strcasecmp(v->
name,
"device"))
5142 else if (!strcasecmp(v->
name,
"tn"))
5144 else if (!strcasecmp(v->
name,
"permit") || !strcasecmp(v->
name,
"deny"))
5146 else if (!strcasecmp(v->
name,
"context"))
5148 else if (!strcasecmp(v->
name,
"maintext0"))
5150 else if (!strcasecmp(v->
name,
"maintext1"))
5152 else if (!strcasecmp(v->
name,
"maintext2"))
5154 else if (!strcasecmp(v->
name,
"titledefault"))
5156 else if (!strcasecmp(v->
name,
"dateformat"))
5157 dateformat = atoi(v->
value);
5158 else if (!strcasecmp(v->
name,
"timeformat"))
5159 timeformat = atoi(v->
value);
5160 else if (!strcasecmp(v->
name,
"contrast")) {
5166 }
else if (!strcasecmp(v->
name,
"nat"))
5168 else if (!strcasecmp(v->
name,
"ringvolume"))
5169 ringvolume = atoi(v->
value);
5170 else if (!strcasecmp(v->
name,
"ringstyle"))
5171 ringstyle = atoi(v->
value);
5172 else if (!strcasecmp(v->
name,
"callhistory"))
5173 callhistory = atoi(v->
value);
5174 else if (!strcasecmp(v->
name,
"callerid")) {
5175 if (!strcasecmp(v->
value,
"asreceived"))
5179 }
else if (!strcasecmp(v->
name,
"language"))
5181 else if (!strcasecmp(v->
name,
"country"))
5183 else if (!strcasecmp(v->
name,
"accountcode"))
5185 else if (!strcasecmp(v->
name,
"amaflags")) {
5193 }
else if (!strcasecmp(v->
name,
"musiconhold"))
5195 else if (!strcasecmp(v->
name,
"callgroup"))
5197 else if (!strcasecmp(v->
name,
"pickupgroup"))
5199 else if (!strcasecmp(v->
name,
"mailbox"))
5201 else if (!strcasecmp(v->
name,
"parkinglot"))
5203 else if (!strcasecmp(v->
name,
"linelabel"))
5205 else if (!strcasecmp(v->
name,
"extension")) {
5206 if (!strcasecmp(v->
value,
"none"))
5208 else if (!strcasecmp(v->
value,
"ask"))
5210 else if (!strcasecmp(v->
value,
"line"))
5214 }
else if (!strcasecmp(v->
name,
"bookmark")) {
5217 "More than 6 softkeys defined. Ignoring new entries.\n");
5222 }
else if (!strcasecmp(v->
name,
"line")) {
5223 int len = strlen(linelabel);
5227 "You must use bookmark AFTER line=>. Only one line is supported in this version\n");
5243 memset(d->
sp, 0,
sizeof(d->
sp));
5251 if ((len > 2) && (linelabel[1] ==
'@')) {
5258 "Invalid position for linelabel : must be between 0 and 5\n");
5288 }
else if (!strcasecmp(v->
name,
"height")) {
5321 "tn= and device= can't be used together. Ignoring device= entry\n");
5326 if (strcmp(d->
name,
"template")) {
5336 strcpy(d->
id,
"000000000000");
5347 struct ast_tm tm = { 0, };
5357 }
else if (strlen(tm.
tm_zone) < 9) {
5384 struct sockaddr_in bindaddr = { 0, };
5385 char *
config =
"unistim.conf";
5388 const int reuseFlag = 1;
5398 ast_log(
LOG_ERROR,
"Config file %s is in an invalid format. Aborting.\n", config);
5405 unistim_keepalive = 120;
5413 if (!strcasecmp(v->
name,
"keepalive"))
5414 unistim_keepalive = atoi(v->
value);
5415 else if (!strcasecmp(v->
name,
"port"))
5416 unistim_port = atoi(v->
value);
5417 else if (!strcasecmp(v->
name,
"tos")) {
5420 }
else if (!strcasecmp(v->
name,
"tos_audio")) {
5423 }
else if (!strcasecmp(v->
name,
"cos")) {
5426 }
else if (!strcasecmp(v->
name,
"cos_audio")) {
5429 }
else if (!strcasecmp(v->
name,
"autoprovisioning")) {
5430 if (!strcasecmp(v->
value,
"no"))
5432 else if (!strcasecmp(v->
value,
"yes"))
5434 else if (!strcasecmp(v->
value,
"db"))
5436 else if (!strcasecmp(v->
value,
"tn"))
5440 }
else if (!strcasecmp(v->
name,
"public_ip")) {
5445 memcpy(&public_ip.sin_addr, hp->h_addr,
sizeof(public_ip.sin_addr));
5446 public_ip.sin_family = AF_INET;
5452 if ((unistim_keepalive < 10) ||
5453 (unistim_keepalive >
5459 packet_send_ping[4] =
5461 if ((unistim_port < 1) || (unistim_port > 65535)) {
5466 unistim_keepalive *= 1000;
5479 if (strcasecmp(cat,
"general")) {
5505 "Device '%s' was not deleted : a call is in progress. Try again later.\n",
5515 "Device '%s' with threeway call subchannels allocated, aborting.\n",
5547 if (d2->
next == d) {
5575 if (unistimsock > -1)
5577 bindaddr.sin_addr.s_addr = INADDR_ANY;
5578 bindaddr.sin_port = htons(unistim_port);
5579 bindaddr.sin_family = AF_INET;
5580 unistimsock = socket(AF_INET, SOCK_DGRAM, 0);
5581 if (unistimsock < 0) {
5587 const int pktinfoFlag = 1;
5588 setsockopt(unistimsock, IPPROTO_IP, IP_PKTINFO, &pktinfoFlag,
5589 sizeof(pktinfoFlag));
5592 if (public_ip.sin_family == 0) {
5594 "Your OS does not support IP_PKTINFO, you must set public_ip.\n");
5599 setsockopt(unistimsock, SOL_SOCKET, SO_REUSEADDR, (
const char *) &reuseFlag,
5601 if (bind(unistimsock, (
struct sockaddr *) &bindaddr,
sizeof(bindaddr)) < 0) {
5608 ast_verb(2,
"UNISTIM Listening on %s:%d\n",
ast_inet_ntoa(bindaddr.sin_addr), htons(bindaddr.sin_port));
5626 *instance = sub->
rtp;
5634 struct sockaddr_in them = { 0, };
5635 struct sockaddr_in us = { 0, };
5691 ast_log(
LOG_ERROR,
"Unable to register channel type '%s'\n", channel_type);
5692 goto chanreg_failed;
5730 pthread_cancel(monitor_thread);
5731 pthread_kill(monitor_thread, SIGURG);
5732 pthread_join(monitor_thread, NULL);
5739 if (unistimsock > -1)
int ast_io_wait(struct io_context *ioc, int howlong)
Waits for IO.
static void rcv_mac_addr(struct unistimsession *pte, const unsigned char *buf)
static const unsigned char packet_send_query_basic_manager_10[]
static const char channel_type[]
static const unsigned char packet_send_select_output[]
static const unsigned char packet_send_icon[]
struct ast_channel * owner
char softkeynumber[6][16]
#define SELECTEXTENSION_START_ENTRY_POS
char call_forward[AST_MAX_EXTENSION]
int ast_queue_hangup(struct ast_channel *chan)
Queue a hangup frame.
union ast_frame_subclass subclass
static const unsigned char packet_send_StartTimer[]
int ast_hangup(struct ast_channel *chan)
Hang up a channel.
static int alloc_sub(struct unistim_line *l, int x)
static char * unistim_do_debug(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
static int write_history(struct unistimsession *pte, char way, char ismissed)
static const unsigned char packet_send_S1[]
static struct unistimsession * sessions
Main Channel structure associated with a channel.
static void show_history(struct unistimsession *pte, char way)
#define AST_CLI_DEFINE(fn, txt,...)
static struct tone_zone_unistim frequency[]
char * str
Subscriber phone number (Malloced)
static void send_client(int size, const unsigned char *data, struct unistimsession *pte)
struct ast_party_connected_line connected
Channel Connected Line ID information.
Asterisk main include file. File version handling, generic pbx functions.
static int UnregisterExtension(const struct unistimsession *pte)
static int unistim_fixup(struct ast_channel *oldchan, struct ast_channel *newchan)
static struct ast_frame * unistim_rtp_read(const struct ast_channel *ast, const struct unistim_subchannel *sub)
static const char config[]
int ast_queue_control(struct ast_channel *chan, enum ast_control_frame_type control)
Queue a control frame with payload.
struct ast_frame ast_null_frame
struct ast_party_caller caller
Channel Caller ID information.
static const unsigned char packet_send_stream_based_tone_off[]
char * strsep(char **str, const char *delims)
static void rcv_resume_connection_with_server(struct unistimsession *pte)
A device containing one or more lines.
char name[DEVICE_NAME_LEN]
static pthread_t monitor_thread
static struct ast_tone_zone * ast_tone_zone_unref(struct ast_tone_zone *tz)
Release a reference to an ast_tone_zone.
static struct ast_channel * unistim_new(struct unistim_subchannel *sub, int state, const char *linkedid)
int ast_channel_masquerade(struct ast_channel *original, struct ast_channel *clone)
Weird function made for call transfers.
CallerID (and other GR30) management and generation Includes code and algorithms from the Zapata libr...
char parkinglot[AST_MAX_CONTEXT]
static const unsigned char packet_send_date_time2[]
#define FAV_ICON_ONHOLD_BLACK
time_t start_call_timestamp
struct ast_party_id id
Connected party ID.
char lst_cnm[TEXT_LENGTH_MAX]
struct ast_rtp_instance * rtp
int ast_cli_unregister_multiple(struct ast_cli_entry *e, int len)
Unregister multiple commands.
static struct sockaddr_in address_from
#define AST_CAUSE_SWITCH_CONGESTION
char language[MAX_LANGUAGE]
struct ast_party_name name
Subscriber name.
#define AST_FORMAT_G723_1
void ast_channel_unregister(const struct ast_channel_tech *tech)
Unregister a channel technology.
#define FAV_ICON_HEADPHONES_ONHOLD
static const unsigned char packet_send_s4[]
static void Keyfavorite(struct unistimsession *pte, char keycode)
#define AST_CAUSE_NETWORK_OUT_OF_ORDER
static void check_send_queue(struct unistimsession *pte)
int ast_app_has_voicemail(const char *mailbox, const char *folder)
Determine if a given mailbox has any voicemail If folder is NULL, defaults to "INBOX". If folder is "INBOX", includes the number of messages in the "Urgent" folder.
struct ast_rtp_codecs * ast_rtp_instance_get_codecs(struct ast_rtp_instance *instance)
Get the codecs structure of an RTP instance.
static const unsigned char packet_send_Contrast[]
struct wsabuf wsabufsend[MAX_BUF_NUMBER]
static char * unistim_info(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
descriptor for a cli entry.
static int send_retransmit(struct unistimsession *pte)
enum ast_pbx_result ast_pbx_start(struct ast_channel *c)
Create a new thread and start the PBX.
unsigned short seq_server
static struct ast_cli_entry unistim_cli[]
struct ast_variable * ast_variable_browse(const struct ast_config *config, const char *category)
Goes through variables.
static const unsigned char packet_send_stream_based_tone_single_freq[]
static void dummy(char *unused,...)
int ast_jb_read_conf(struct ast_jb_conf *conf, const char *varname, const char *value)
Sets jitterbuffer configuration property.
static void in_band_indication(struct ast_channel *ast, const struct ast_tone_zone *tz, const char *indication)
static struct io_context * io
#define AST_CONFIG_MAX_PATH
struct ast_tm * ast_localtime(const struct timeval *timep, struct ast_tm *p_tm, const char *zone)
Timezone-independent version of localtime_r(3).
static void change_favorite_icon(struct unistimsession *pte, unsigned char status)
Structure for variables, used for configurations and for channel variables.
static struct unistim_device * build_device(const char *cat, const struct ast_variable *v)
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.
int ast_rtp_instance_write(struct ast_rtp_instance *instance, struct ast_frame *frame)
Send a frame out over RTP.
static const unsigned char packet_recv_pick_up[]
#define ast_rtp_glue_register(glue)
static void send_ping(struct unistimsession *pte)
static void unquote(char *out, const char *src, int maxlen)
struct ast_event * ast_event_get_cached(enum ast_event_type,...)
Retrieve an event from the cache.
static void send_select_output(struct unistimsession *pte, unsigned char output, unsigned char volume, unsigned char mute)
static void key_main_page(struct unistimsession *pte, char keycode)
Configuration File Parser.
int ast_netsock_set_qos(int netsocket, int tos, int cos, const char *desc)
char * str
Subscriber name (Malloced)
int * ast_io_add(struct io_context *ioc, int fd, ast_io_cb callback, short events, void *data)
Adds an IO context.
static void close_call(struct unistimsession *pte)
static void set_ping_timer(struct unistimsession *pte)
static const unsigned char packet_send_set_pos_cursor[]
static struct ast_threadstorage buf2
static int unistim_call(struct ast_channel *ast, char *dest, int timeout)
format_t ast_best_codec(format_t fmts)
Pick the best audio codec.
unsigned char buf[MAX_BUF_NUMBER][MAX_BUF_SIZE]
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
Number of new messages Used by: AST_EVENT_MWI Payload type: UINT.
#define ast_mutex_lock(a)
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_MODULE_INFO(keystr, flags_to_set, desc, fields...)
static const unsigned char packet_send_stream_based_tone_on[]
static void close_client(struct unistimsession *s)
static int attempt_transfer(struct unistim_subchannel *p1, struct unistim_subchannel *p2)
int ast_str2tos(const char *value, unsigned int *tos)
Convert a string to the appropriate TOS value.
void ast_playtones_stop(struct ast_channel *chan)
Stop playing tones on a channel.
static const unsigned char packet_send_query_mac_address[]
#define FAV_ICON_ONHOOK_BLACK
static const unsigned char packet_send_led_update[]
static void send_date_time3(struct unistimsession *pte)
static const unsigned char packet_send_open_audio_stream_tx[]
static int ParseBookmark(const char *text, struct unistim_device *d)
static void * unistim_ss(void *data)
void ast_cli(int fd, const char *fmt,...)
void ast_update_use_count(void)
Notify when usecount has been changed.
const ast_string_field linkedid
static const unsigned char packet_send_S7[]
enum ast_channel_adsicpe adsicpe
static void HandleSelectCodec(struct unistimsession *pte)
void ast_moh_stop(struct ast_channel *chan)
Turn off music on hold on a given channel.
static void HandleCallOutgoing(struct unistimsession *s)
Socket address structure.
static struct ast_frame * unistim_read(struct ast_channel *ast)
static const unsigned char packet_send_date_time[]
#define ast_verb(level,...)
void ast_config_destroy(struct ast_config *config)
Destroys a config.
struct unistim_subchannel * subs[MAX_SUBS]
static void * do_monitor(void *data)
static ast_mutex_t sessionlock
struct ast_channel * ast_channel_alloc(int needqueue, int state, const char *cid_num, const char *cid_name, const char *acctcode, const char *exten, const char *context, const char *linkedid, const int amaflag, const char *name_fmt,...)
static int load_module(void)
static const unsigned char packet_send_open_audio_stream_rx3[]
static int unistim_answer(struct ast_channel *ast)
static int unistim_register(struct unistimsession *s)
int ast_context_remove_extension(const char *context, const char *extension, int priority, const char *registrar)
Simply remove extension from context.
unsigned short last_seq_ack
int ast_queue_hangup_with_cause(struct ast_channel *chan, int cause)
Queue a hangup frame with hangupcause set.
#define FAV_ICON_HEADPHONES
int args
This gets set in ast_cli_register()
static char OpenHistory(struct unistimsession *pte, char way, FILE **f)
#define STATUS_LENGTH_MAX
static char * unistim_sp(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
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, so don't do anything useful but setting a flag and waiting for do_monitor to do the job in our thread
static void send_blink_cursor(struct unistimsession *pte)
static struct unistim_subchannel * find_subchannel_by_name(const char *dest)
static int unistim_send_mwi_to_peer(struct unistimsession *s, unsigned int tick)
struct unistim_device * device
struct unistimsession * next
static int unalloc_sub(struct unistim_line *p, int x)
internal representation of acl entries In principle user applications would have no need for this...
static void send_texttitle(struct unistimsession *pte, const char *text)
struct ast_party_id id
Caller party ID.
static const char tdesc[]
struct unistim_line * next
int ast_set_write_format(struct ast_channel *chan, format_t format)
Sets write format on channel chan Set write format for channel to whichever component of "format" is ...
static void refresh_all_favorite(struct unistimsession *pte)
static void send_tone(struct unistimsession *pte, uint16_t tone1, uint16_t tone2)
static ast_mutex_t devicelock
static void start_rtp(struct unistim_subchannel *sub)
static const unsigned char packet_recv_firm_version[]
int ast_set_read_format(struct ast_channel *chan, format_t format)
Sets read format on channel chan Set read format for channel to whichever component of "format" is be...
#define ast_debug(level,...)
Log a DEBUG message.
unsigned long tick_next_ping
static const unsigned char packet_send_jitter_buffer_conf[]
#define FAV_ICON_PHONE_BLACK
Context IE Used by AST_EVENT_MWI Payload type: str.
static struct sockaddr_in public_ip
#define VOLUME_LOW_SPEAKER
static const unsigned char packet_send_ring[]
static const unsigned char packet_send_date_time3[]
General Asterisk PBX channel definitions.
Asterisk file paths, configured in asterisk.conf.
void io_context_destroy(struct io_context *ioc)
Destroys a context.
#define ast_sockaddr_from_sin(addr, sin)
Converts a struct sockaddr_in to a struct ast_sockaddr.
static const unsigned char packet_send_stop_timer[]
A set of tones for a given locale.
#define DEFAULTCALLERNAME
#define ast_config_load(filename, flags)
Load a config file.
static const unsigned char packet_send_favorite[]
static int reload_config(void)
#define AST_PTHREADT_NULL
static force_inline int attribute_pure ast_strlen_zero(const char *s)
struct unistim_device * next
Access Control of various sorts.
static int unload_module(void)
char softkeydevice[6][16]
Global IO variables are now in a struct in order to be made threadsafe.
#define AST_MAX_EXTENSION
static int get_to_address(int fd, struct sockaddr_in *toAddr)
#define AST_CAUSE_NORMAL_CLEARING
struct unistimsession * session
static void key_select_extension(struct unistimsession *pte, char keycode)
#define NB_MAX_RETRANSMIT
#define ao2_ref(o, delta)
char * ast_category_browse(struct ast_config *config, const char *prev)
Goes through categories.
static struct ast_jb_conf default_jbconf
Global jitterbuffer configuration - by default, jb is disabled.
char mailbox[AST_MAX_EXTENSION]
static char * control2str(int ind)
static int unistim_keepalive
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_rtp_instance_set_remote_address(struct ast_rtp_instance *instance, const struct ast_sockaddr *address)
Set the address of the remote endpoint that we are sending RTP to.
static const unsigned char packet_send_query_basic_manager_04[]
static void handle_dial_page(struct unistimsession *pte)
static char language[MAX_LANGUAGE]
static int unistim_sendtext(struct ast_channel *ast, const char *text)
static const unsigned char packet_send_open_audio_stream_tx3[]
struct ast_channel * _bridge
ast_group_t ast_get_group(const char *s)
struct ast_tone_zone * tz
unsigned short w_day_of_week
#define FAV_ICON_SPEAKER_ONHOLD_BLACK
Structure to describe a channel "technology", ie a channel driver See for examples: ...
Core PBX routines and definitions.
int ast_queue_frame(struct ast_channel *chan, struct ast_frame *f)
Queue one or more frames to a channel's frame queue.
enum autoprov_extn extension
char cid_num[AST_MAX_EXTENSION]
char musicclass[MAX_MUSICCLASS]
static struct unistimsession * create_client(const struct sockaddr_in *addr_from)
static unsigned int size_addr_from
static int ReformatNumber(char *number)
#define FAV_ICON_SPEAKER_ONHOOK_BLACK
static int unistim_do_senddigit(struct unistimsession *pte, char digit)
static struct sched_context * sched
static void send_stop_timer(struct unistimsession *pte)
Wrapper for network related headers, masking differences between various operating systems...
static void send_favorite(unsigned char pos, unsigned char status, struct unistimsession *pte, const char *text)
static void ShowExtensionPage(struct unistimsession *pte)
static const unsigned char packet_send_status2[]
struct ast_silence_generator * ast_channel_start_silence_generator(struct ast_channel *chan)
Starts a silence generator on the given channel.
static struct ast_jb_conf global_jbconf
static void SendDialTone(struct unistimsession *pte)
#define ast_strdupa(s)
duplicate a string in memory from the stack
unsigned short w_milliseconds
char * ast_getformatname(format_t format)
Get the name of a format.
static void send_text_status(struct unistimsession *pte, const char *text)
int attribute_pure ast_true(const char *val)
Make sure something is true. Determine if a string containing a boolean value is "true". This function checks to see whether a string passed to it is an indication of an "true" value. It checks to see if the string is "yes", "true", "y", "t", "on" or "1".
void sched_context_destroy(struct sched_context *c)
destroys a schedule context Destroys (free's) the given sched_context structure
static const unsigned char packet_send_call[]
#define FAV_ICON_CALL_CENTER
static void IgnoreCall(struct unistimsession *pte)
static const unsigned char packet_send_no_ring[]
static const unsigned char packet_recv_resume_connection_with_server[]
static const unsigned char packet_recv_hangup[]
static void show_main_page(struct unistimsession *pte)
static const unsigned char packet_recv_pressed_key[]
static void swap_subs(struct unistim_line *p, int a, int b)
struct ast_tone_zone * ast_get_indication_zone(const char *country)
locate ast_tone_zone
static void key_history(struct unistimsession *pte, char keycode)
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
int ast_cdr_amaflags2int(const char *flag)
Convert a string to a detail record AMA flag.
enum ast_channel_state _state
struct ast_tone_zone_sound * ast_get_indication_tone(const struct ast_tone_zone *zone, const char *indication)
Locate a tone zone sound.
struct ast_channel * ast_bridged_channel(struct ast_channel *chan)
Find bridged channel.
#define FAV_ICON_SPEAKER_OFFHOOK_BLACK
const ast_string_field name
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_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
static const unsigned char packet_send_s9[]
static const unsigned char packet_send_text[]
const char * ast_config_AST_LOG_DIR
int ast_softhangup_nolock(struct ast_channel *chan, int reason)
Softly hangup up a channel (no channel lock)
struct unistim_line * lines
static const unsigned char packet_send_title[]
static void cancel_dial(struct unistimsession *pte)
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.
static const unsigned char packet_send_stream_based_tone_dial_freq[]
const char * ast_inet_ntoa(struct in_addr ia)
thread-safe replacement for inet_ntoa().
#define ast_pthread_create(a, b, c, d)
static const unsigned char packet_send_end_call[]
#define SELECTEXTENSION_MAX_LENGTH
void ast_rtp_instance_get_remote_address(struct ast_rtp_instance *instance, struct ast_sockaddr *address)
Get the address of the remote endpoint that we are sending RTP to.
int ast_str2cos(const char *value, unsigned int *cos)
Convert a string to the appropriate COS value.
static const unsigned char packet_send_rtp_packet_size[]
int ast_rtp_instance_fd(struct ast_rtp_instance *instance, int rtcp)
Get the file descriptor for an RTP session (or RTCP)
static struct unistim_device * devices
char context[AST_MAX_EXTENSION]
static void send_led_update(struct unistimsession *pte, unsigned char led)
struct ast_rtp_instance * ast_rtp_instance_new(const char *engine_name, struct sched_context *sched, const struct ast_sockaddr *sa, void *data)
Create a new RTP instance.
static int unistim_hangup(struct ast_channel *ast)
char lst_cid[TEXT_LENGTH_MAX]
unsigned int flags
Combination of the AST_JB_ENABLED, AST_JB_FORCED and AST_JB_LOG flags.
static void send_ring(struct unistimsession *pte, char volume, char style)
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.
Structure used to handle boolean flags.
int ast_rtp_instance_destroy(struct ast_rtp_instance *instance)
Destroy an RTP instance.
static int unistim_reloading
char exten[AST_MAX_EXTENSION]
void ast_jb_configure(struct ast_channel *chan, const struct ast_jb_conf *conf)
Configures a jitterbuffer on a channel.
static void send_text(unsigned char pos, unsigned char inverse, struct unistimsession *pte, const char *text)
static struct ast_channel * unistim_request(const char *type, format_t format, const struct ast_channel *requestor, void *data, int *cause)
static int write_entry_history(struct unistimsession *pte, FILE *f, char c, char *line1)
uint32_t ast_event_get_ie_uint(const struct ast_event *event, enum ast_event_ie_type ie_type)
Get the value of an information element that has an integer payload.
static int unistim_write(struct ast_channel *ast, struct ast_frame *frame)
static const unsigned char packet_send_blink_cursor[]
static void parsing(int size, unsigned char *buf, struct unistimsession *pte, struct sockaddr_in *addr_from)
static void HandleCallIncoming(struct unistimsession *s)
static volatile unsigned int seq
static void key_select_codec(struct unistimsession *pte, char keycode)
static const unsigned char packet_send_open_audio_stream_rx[]
struct hostent * ast_gethostbyname(const char *host, struct ast_hostent *hp)
Thread-safe gethostbyname function to use in Asterisk.
static char dateformat[256]
static void key_call(struct unistimsession *pte, char keycode)
static void send_no_ring(struct unistimsession *pte)
void ast_event_destroy(struct ast_event *event)
Destroy an event.
static void send_cursor_pos(struct unistimsession *pte, unsigned char pos)
struct sched_context * sched_context_create(void)
New schedule context.
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.
Channels have this property if they can create jitter; i.e. most VoIP channels.
Standard Command Line Interface.
static void process_request(int size, unsigned char *buf, struct unistimsession *pte)
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
struct unistim_line * parent
static unsigned char * buff
static enum autoprovision autoprovisioning
#define SELECTCODEC_START_ENTRY_POS
int ast_cli_register_multiple(struct ast_cli_entry *e, int len)
Register multiple commands.
static void send_date_time(struct unistimsession *pte)
int ast_setstate(struct ast_channel *chan, enum ast_channel_state)
Change the state of a channel.
#define AST_PTHREADT_STOP
int ast_rtp_glue_unregister(struct ast_rtp_glue *glue)
Unregister RTP glue.
static const unsigned char packet_send_status[]
Application convenience functions, designed to give consistent look and feel to Asterisk apps...
enum ast_pbx_result ast_pbx_run(struct ast_channel *c)
Execute the PBX in the current thread.
char * ast_getformatname_multiple(char *buf, size_t size, format_t format)
Get the names of a set of formats.
struct unistim_device * parent
static const unsigned char packet_recv_mac_addr[]
static int RegisterExtension(const struct unistimsession *pte)
Data structure associated with a single frame of data.
Internal Asterisk hangup causes.
#define SELECTCODEC_MAX_LENGTH
static void send_start_timer(struct unistimsession *pte)
int ast_playtones_start(struct ast_channel *chan, int vol, const char *tonelist, int interruptible)
Start playing a list of tones on a channel.
static void finish_bookmark(void)
static unsigned int get_tick_count(void)
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.
Channels have this property if they can accept input with jitter; i.e. most VoIP channels.
const char * data
Description of a tone.
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.
#define ast_sockaddr_to_sin(addr, sin)
Converts a struct ast_sockaddr to a struct sockaddr_in.
static void show_entry_history(struct unistimsession *pte, FILE **f)
enum ast_frame_type frametype
struct ast_variable * next
static const unsigned char packet_send_arrow[]
static int unistim_indicate(struct ast_channel *ast, int ind, const void *data, size_t datalen)
static struct adsi_event events[]
#define ast_mutex_init(pmutex)
static ast_mutex_t usecnt_lock
unsigned char valid
TRUE if the name information is valid/present.
#define CONFIG_STATUS_FILEINVALID
static char context[AST_MAX_CONTEXT]
static void key_ringing(struct unistimsession *pte, char keycode)
static void key_dial_page(struct unistimsession *pte, char keycode)
#define ast_mutex_destroy(a)
static void display_last_error(const char *sz_msg)
static void change_callerid(struct unistimsession *pte, int type, char *callerid)
static const unsigned char packet_rcv_discovery[]
static int unistim_senddigit_end(struct ast_channel *ast, char digit, unsigned int duration)
static void init_phone_step2(struct unistimsession *pte)
static int restart_monitor(void)
static struct unistimsession * channel_to_session(struct ast_channel *ast)
#define ASTERISK_GPL_KEY
The text the key() function should return.
Pluggable RTP Architecture.
Asterisk module definitions.
static struct hostent * hp
static void send_end_call(struct unistimsession *pte)
#define SELECTEXTENSION_MSG
static snd_pcm_format_t format
union ast_frame::@172 data
struct ast_channel_tech * tech
int ast_rtp_codecs_payload_code(struct ast_rtp_codecs *codecs, const int asterisk_format, const format_t code)
Retrieve a payload based on whether it is an Asterisk format and the code.
static const unsigned char packet_send_discovery_ack[]
static void send_date_time2(struct unistimsession *pte)
char extension_number[11]
unsigned char valid
TRUE if the number information is valid/present.
static int unistim_senddigit_begin(struct ast_channel *ast, char digit)
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, format_t codecs, int nat_active)
General jitterbuffer configuration.
struct ast_silence_generator * silence_generator
static enum ast_rtp_glue_result unistim_get_rtp_peer(struct ast_channel *chan, struct ast_rtp_instance **instance)
#define AST_CAUSE_CONGESTION
static void TransferCallStep1(struct unistimsession *pte)
struct unistim_device * sp[6]
char exten[AST_MAX_EXTENSION]
#define AST_MUTEX_DEFINE_STATIC(mutex)
Structure for mutex and tracking information.
static char mailbox[AST_MAX_EXTENSION]
#define FAV_ICON_OFFHOOK_BLACK
struct ast_frame * ast_rtp_instance_read(struct ast_rtp_instance *instance, int rtcp)
Receive a frame over RTP.
#define ASTERISK_FILE_VERSION(file, version)
Register/unregister a source code file with the core.
static int unistimsock_read(int *id, int fd, short events, void *ignore)
static ast_mutex_t unistim_reload_lock
static struct ast_channel_tech unistim_tech
#define ast_mutex_unlock(a)
static ast_mutex_t monlock
static unsigned char packet_send_ping[]
static void Sendicon(unsigned char pos, unsigned char status, struct unistimsession *pte)
static const unsigned char packet_recv_r2[]
int ast_mkdir(const char *path, int mode)
Recursively create directory path.
int ast_callerid_parse(char *instr, char **name, char **location)
Destructively parse inbuf into name and location (or number)
enum ast_bridge_result ast_rtp_instance_bridge(struct ast_channel *c0, struct ast_channel *c1, int flags, struct ast_frame **fo, struct ast_channel **rc, int timeoutms)
Bridge two channels that use RTP instances.
#define ast_string_field_set(x, field, data)
Set a field to a simple string value.
struct ast_party_number number
Subscriber phone number.
static struct ast_rtp_glue unistim_rtp_glue
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...
static void send_raw_client(int size, const unsigned char *data, struct sockaddr_in *addr_to, const struct sockaddr_in *addr_ourip)