#include "asterisk.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
#include <sys/ioctl.h>
#include <net/if.h>
#include <errno.h>
#include <fcntl.h>
#include <netdb.h>
#include <arpa/inet.h>
#include <sys/signal.h>
#include <signal.h>
#include <ctype.h>
#include "asterisk/lock.h"
#include "asterisk/channel.h"
#include "asterisk/config.h"
#include "asterisk/logger.h"
#include "asterisk/module.h"
#include "asterisk/pbx.h"
#include "asterisk/options.h"
#include "asterisk/sched.h"
#include "asterisk/io.h"
#include "asterisk/rtp.h"
#include "asterisk/acl.h"
#include "asterisk/callerid.h"
#include "asterisk/cli.h"
#include "asterisk/say.h"
#include "asterisk/cdr.h"
#include "asterisk/astdb.h"
#include "asterisk/features.h"
#include "asterisk/app.h"
#include "asterisk/musiconhold.h"
#include "asterisk/utils.h"
#include "asterisk/dsp.h"
#include "asterisk/stringfields.h"
#include "asterisk/astobj.h"
#include "asterisk/abstract_jb.h"
#include "asterisk/threadstorage.h"
Go to the source code of this file.
Definition in file chan_skinny.c.
#define ACTIVATE_CALL_PLANE_MESSAGE 0x0116 |
Definition at line 705 of file chan_skinny.c.
Referenced by skinny_hold(), skinny_unhold(), and transmit_callstate().
#define ALARM_MESSAGE 0x0020 |
#define BT_AUTOANSWER STIMULUS_AUTOANSWER |
Definition at line 421 of file chan_skinny.c.
#define BT_CALLPARK STIMULUS_CALLPARK |
#define BT_CALLPICKUP STIMULUS_CALLPICKUP |
Definition at line 424 of file chan_skinny.c.
#define BT_CONFERENCE STIMULUS_CONFERENCE |
#define BT_CUST_HINT 0xB1 |
#define BT_CUST_LINESPEEDDIAL 0xB0 |
Definition at line 430 of file chan_skinny.c.
Referenced by get_button_template(), and handle_button_template_req_message().
#define BT_DISPLAY STIMULUS_DISPLAY |
#define BT_FORWARDALL STIMULUS_FORWARDALL |
#define BT_FORWARDBUSY STIMULUS_FORWARDBUSY |
Definition at line 416 of file chan_skinny.c.
#define BT_FORWARDNOANSWER STIMULUS_FORWARDNOANSWER |
Definition at line 417 of file chan_skinny.c.
#define BT_HOLD STIMULUS_HOLD |
#define BT_LINE STIMULUS_LINE |
Definition at line 419 of file chan_skinny.c.
Referenced by get_button_template(), and handle_button_template_req_message().
#define BT_NONE 0x00 |
Definition at line 425 of file chan_skinny.c.
Referenced by get_button_template(), and handle_button_template_req_message().
#define BT_REDIAL STIMULUS_REDIAL |
#define BT_SPEEDDIAL STIMULUS_SPEEDDIAL |
Definition at line 412 of file chan_skinny.c.
Referenced by get_button_template(), and handle_button_template_req_message().
#define BT_TRANSFER STIMULUS_TRANSFER |
#define BT_VOICEMAIL STIMULUS_VOICEMAIL |
#define BUTTON_TEMPLATE_REQ_MESSAGE 0x000E |
#define BUTTON_TEMPLATE_RES_MESSAGE 0x0097 |
#define CALL_INFO_MESSAGE 0x008F |
#define CALL_STATE_MESSAGE 0x0111 |
#define CAPABILITIES_REQ_MESSAGE 0x009B |
#define CAPABILITIES_RES_MESSAGE 0x0010 |
#define CLEAR_DISPLAY_MESSAGE 0x009A |
#define CLEAR_NOTIFY_MESSAGE 0x0115 |
Definition at line 450 of file chan_skinny.c.
#define CLEAR_PROMPT_MESSAGE 0x0113 |
#define CLOSE_RECEIVE_CHANNEL_MESSAGE 0x0106 |
Definition at line 489 of file chan_skinny.c.
Referenced by skinny_hold(), and transmit_callstate().
#define CONTROL2STR_BUFSIZE 100 |
#define DEFAULT_SKINNY_BACKLOG 2 |
#define DEFAULT_SKINNY_PORT 2000 |
#define DEFINETIMEDATE_MESSAGE 0x0094 |
#define DEVICE2STR_BUFSIZE 15 |
#define DIALED_NUMBER_MESSAGE 0x011D |
#define DISPLAY_NOTIFY_MESSAGE 0x0114 |
#define DISPLAY_PROMPT_STATUS_MESSAGE 0x0112 |
#define DISPLAYTEXT_MESSAGE 0x0099 |
#define ENBLOC_CALL_MESSAGE 0x0004 |
#define HEADSET_STATUS_MESSAGE 0x002B |
#define htolel | ( | x | ) | (x) |
Definition at line 107 of file chan_skinny.c.
Referenced by get_input(), handle_button_template_req_message(), handle_open_receive_channel_ack_message(), handle_register_message(), handle_server_request_message(), handle_soft_key_set_req_message(), handle_soft_key_template_req_message(), handle_speed_dial_stat_req_message(), handle_time_date_req_message(), load_module(), req_alloc(), skinny_hold(), skinny_unhold(), transmit_callinfo(), transmit_callstate(), transmit_connect(), transmit_dialednumber(), transmit_displaynotify(), transmit_displaypromptstatus(), transmit_lamp_indication(), transmit_ringer_mode(), transmit_selectsoftkeys(), transmit_speaker_mode(), and transmit_tone().
#define htoles | ( | x | ) | (x) |
Definition at line 108 of file chan_skinny.c.
#define IP_PORT_MESSAGE 0x0002 |
#define KEEP_ALIVE_ACK_MESSAGE 0x0100 |
#define KEEP_ALIVE_MESSAGE 0x0000 |
#define KEYDEF_CONNECTED 1 |
Definition at line 504 of file chan_skinny.c.
Referenced by handle_offhook_message(), handle_soft_key_event_message(), handle_stimulus_message(), and skinny_answer().
#define KEYDEF_CONNWITHCONF 7 |
Definition at line 510 of file chan_skinny.c.
#define KEYDEF_CONNWITHTRANS 5 |
Definition at line 508 of file chan_skinny.c.
#define KEYDEF_DADFD 6 |
Definition at line 509 of file chan_skinny.c.
#define KEYDEF_OFFHOOK 4 |
Definition at line 507 of file chan_skinny.c.
Referenced by handle_offhook_message(), handle_soft_key_event_message(), and handle_stimulus_message().
#define KEYDEF_OFFHOOKWITHFEAT 9 |
Definition at line 512 of file chan_skinny.c.
#define KEYDEF_ONHOLD 2 |
Definition at line 505 of file chan_skinny.c.
#define KEYDEF_ONHOOK 0 |
Definition at line 503 of file chan_skinny.c.
Referenced by handle_soft_key_set_req_message(), and transmit_callstate().
#define KEYDEF_RINGIN 3 |
#define KEYDEF_RINGOUT 8 |
Definition at line 511 of file chan_skinny.c.
Referenced by handle_soft_key_event_message(), and handle_stimulus_message().
#define KEYDEF_UNKNOWN 10 |
Definition at line 513 of file chan_skinny.c.
#define KEYPAD_BUTTON_MESSAGE 0x0003 |
#define letohl | ( | x | ) | (x) |
Definition at line 105 of file chan_skinny.c.
Referenced by get_input(), handle_capabilities_res_message(), handle_keypad_button_message(), handle_line_state_req_message(), handle_message(), handle_offhook_message(), handle_onhook_message(), handle_open_receive_channel_ack_message(), handle_soft_key_event_message(), handle_speed_dial_stat_req_message(), handle_stimulus_message(), skinny_register(), skinny_req_parse(), and transmit_response().
#define letohs | ( | x | ) | (x) |
Definition at line 106 of file chan_skinny.c.
#define LINE_STAT_RES_MESSAGE 0x0092 |
#define LINE_STATE_REQ_MESSAGE 0x000B |
#define OFFHOOK_MESSAGE 0x0006 |
#define ONHOOK_MESSAGE 0x0007 |
#define OPEN_RECEIVE_CHANNEL_ACK_MESSAGE 0x0022 |
#define OPEN_RECEIVE_CHANNEL_MESSAGE 0x0105 |
#define REGISTER_ACK_MESSAGE 0x0081 |
#define REGISTER_AVAILABLE_LINES_MESSAGE 0x002D |
#define REGISTER_MESSAGE 0x0001 |
#define REGISTER_REJ_MESSAGE 0x009D |
#define RESET_MESSAGE 0x009F |
#define SELECT_SOFT_KEYS_MESSAGE 0x0110 |
#define SERVER_REQUEST_MESSAGE 0x0012 |
#define SERVER_RES_MESSAGE 0x009E |
#define SET_LAMP_MESSAGE 0x0086 |
#define SET_MICROPHONE_MESSAGE 0x0089 |
Definition at line 301 of file chan_skinny.c.
#define SET_RINGER_MESSAGE 0x0085 |
#define SET_SPEAKER_MESSAGE 0x0088 |
#define SKINNY_ALERT 0x24 |
#define SKINNY_BUSY 6 |
#define SKINNY_BUSYTONE 0x23 |
#define SKINNY_CALLWAIT 9 |
Definition at line 858 of file chan_skinny.c.
#define SKINNY_CALLWAITTONE 0x2D |
#define SKINNY_CONGESTION 7 |
#define SKINNY_CONNECTED 5 |
Definition at line 854 of file chan_skinny.c.
Referenced by handle_offhook_message(), handle_soft_key_event_message(), handle_stimulus_message(), and skinny_answer().
#define SKINNY_CX_CONF 3 |
Definition at line 890 of file chan_skinny.c.
#define SKINNY_CX_CONFERENCE 3 |
Definition at line 891 of file chan_skinny.c.
#define SKINNY_CX_INACTIVE 4 |
#define SKINNY_CX_MUTE 4 |
Definition at line 892 of file chan_skinny.c.
#define SKINNY_CX_RECVONLY 1 |
Definition at line 888 of file chan_skinny.c.
Referenced by handle_onhook_message(), and handle_soft_key_event_message().
#define SKINNY_CX_SENDONLY 0 |
Definition at line 887 of file chan_skinny.c.
#define SKINNY_CX_SENDRECV 2 |
#define SKINNY_DEVICE_12 4 |
Definition at line 819 of file chan_skinny.c.
Referenced by device2str(), and get_button_template().
#define SKINNY_DEVICE_12SP 3 |
Definition at line 818 of file chan_skinny.c.
Referenced by device2str(), and get_button_template().
#define SKINNY_DEVICE_12SPPLUS 2 |
Definition at line 817 of file chan_skinny.c.
Referenced by device2str(), and get_button_template().
#define SKINNY_DEVICE_30SPPLUS 1 |
Definition at line 816 of file chan_skinny.c.
Referenced by device2str(), and get_button_template().
#define SKINNY_DEVICE_30VIP 5 |
Definition at line 820 of file chan_skinny.c.
Referenced by device2str(), and get_button_template().
#define SKINNY_DEVICE_7902 30008 |
Definition at line 837 of file chan_skinny.c.
Referenced by device2str(), and get_button_template().
#define SKINNY_DEVICE_7905 20000 |
Definition at line 833 of file chan_skinny.c.
Referenced by device2str(), and get_button_template().
#define SKINNY_DEVICE_7910 6 |
Definition at line 821 of file chan_skinny.c.
Referenced by device2str(), and get_button_template().
#define SKINNY_DEVICE_7911 307 |
Definition at line 829 of file chan_skinny.c.
Referenced by device2str(), and get_button_template().
#define SKINNY_DEVICE_7912 30007 |
Definition at line 836 of file chan_skinny.c.
Referenced by device2str(), and get_button_template().
#define SKINNY_DEVICE_7920 30002 |
Definition at line 834 of file chan_skinny.c.
Referenced by device2str(), and get_button_template().
#define SKINNY_DEVICE_7921 365 |
Definition at line 832 of file chan_skinny.c.
Referenced by device2str(), and get_button_template().
#define SKINNY_DEVICE_7935 9 |
Definition at line 824 of file chan_skinny.c.
Referenced by device2str(), and get_button_template().
#define SKINNY_DEVICE_7936 30019 |
Definition at line 840 of file chan_skinny.c.
Referenced by device2str(), and get_button_template().
#define SKINNY_DEVICE_7940 8 |
Definition at line 823 of file chan_skinny.c.
Referenced by device2str(), and get_button_template().
#define SKINNY_DEVICE_7941 115 |
Definition at line 826 of file chan_skinny.c.
Referenced by device2str(), and get_button_template().
#define SKINNY_DEVICE_7941GE 309 |
Definition at line 831 of file chan_skinny.c.
Referenced by device2str(), and get_button_template().
#define SKINNY_DEVICE_7960 7 |
Definition at line 822 of file chan_skinny.c.
Referenced by device2str(), and get_button_template().
#define SKINNY_DEVICE_7961 30018 |
Definition at line 839 of file chan_skinny.c.
Referenced by device2str(), and get_button_template().
#define SKINNY_DEVICE_7961GE 308 |
Definition at line 830 of file chan_skinny.c.
Referenced by device2str(), and get_button_template().
#define SKINNY_DEVICE_7970 30006 |
Definition at line 835 of file chan_skinny.c.
Referenced by device2str(), and get_button_template().
#define SKINNY_DEVICE_7971 119 |
Definition at line 827 of file chan_skinny.c.
Referenced by device2str(), and get_button_template().
#define SKINNY_DEVICE_7985 302 |
Definition at line 828 of file chan_skinny.c.
Referenced by device2str(), and get_button_template().
#define SKINNY_DEVICE_ATA186 12 |
Definition at line 825 of file chan_skinny.c.
Referenced by device2str(), and get_button_template().
#define SKINNY_DEVICE_CIPC 30016 |
Definition at line 838 of file chan_skinny.c.
Referenced by device2str(), and get_button_template().
#define SKINNY_DEVICE_NONE 0 |
#define SKINNY_DEVICE_SCCPGATEWAY_AN 30027 |
Definition at line 841 of file chan_skinny.c.
Referenced by device2str(), and get_button_template().
#define SKINNY_DEVICE_SCCPGATEWAY_BRI 30028 |
Definition at line 842 of file chan_skinny.c.
Referenced by device2str(), and get_button_template().
#define SKINNY_DEVICE_UNKNOWN -1 |
#define SKINNY_DIALTONE 0x21 |
Definition at line 865 of file chan_skinny.c.
Referenced by handle_enbloc_call_message(), handle_offhook_message(), handle_soft_key_event_message(), handle_stimulus_message(), and skinny_ss().
#define SKINNY_HOLD 8 |
Definition at line 857 of file chan_skinny.c.
#define SKINNY_INVALID 14 |
Definition at line 862 of file chan_skinny.c.
#define SKINNY_LAMP_BLINK 5 |
#define SKINNY_LAMP_FLASH 4 |
Definition at line 875 of file chan_skinny.c.
#define SKINNY_LAMP_OFF 1 |
Definition at line 872 of file chan_skinny.c.
Referenced by handle_soft_key_event_message(), handle_stimulus_message(), and skinny_hangup().
#define SKINNY_LAMP_ON 2 |
Definition at line 873 of file chan_skinny.c.
Referenced by handle_offhook_message(), handle_soft_key_event_message(), handle_stimulus_message(), and skinny_unhold().
#define SKINNY_LAMP_WINK 3 |
Definition at line 874 of file chan_skinny.c.
#define SKINNY_MAX_CAPABILITIES 18 |
#define SKINNY_MAX_PACKET 1000 |
Definition at line 98 of file chan_skinny.c.
Referenced by skinny_req_parse(), and transmit_response().
#define SKINNY_MICOFF 2 |
Definition at line 848 of file chan_skinny.c.
#define SKINNY_MICON 1 |
Definition at line 847 of file chan_skinny.c.
#define SKINNY_NOTONE 0x7F |
#define SKINNY_OFFHOOK 1 |
Definition at line 850 of file chan_skinny.c.
Referenced by handle_enbloc_call_message(), handle_offhook_message(), handle_soft_key_event_message(), handle_stimulus_message(), skinny_call(), skinny_hangup(), and transmit_callstate().
#define SKINNY_ONHOOK 2 |
Definition at line 851 of file chan_skinny.c.
Referenced by build_device(), handle_onhook_message(), handle_soft_key_event_message(), handle_stimulus_message(), skinny_call(), skinny_hangup(), and transmit_callstate().
#define SKINNY_PARK 11 |
Definition at line 860 of file chan_skinny.c.
#define SKINNY_PROGRESS 12 |
#define SKINNY_REORDER 0x25 |
Definition at line 868 of file chan_skinny.c.
Referenced by skinny_indicate(), skinny_newcall(), and skinny_ss().
#define SKINNY_RING_FEATURE 4 |
Definition at line 881 of file chan_skinny.c.
#define SKINNY_RING_INSIDE 2 |
#define SKINNY_RING_OFF 1 |
Definition at line 878 of file chan_skinny.c.
Referenced by handle_offhook_message(), handle_soft_key_event_message(), handle_stimulus_message(), and skinny_hangup().
#define SKINNY_RING_OUTSIDE 3 |
Definition at line 880 of file chan_skinny.c.
#define SKINNY_RINGIN 4 |
#define SKINNY_RINGOUT 3 |
#define SKINNY_SILENCE 0x00 |
Definition at line 864 of file chan_skinny.c.
Referenced by handle_enbloc_call_message(), handle_offhook_message(), handle_soft_key_event_message(), handle_stimulus_message(), skinny_answer(), skinny_hangup(), skinny_indicate(), and skinny_ss().
#define SKINNY_SPEAKEROFF 2 |
Definition at line 845 of file chan_skinny.c.
Referenced by handle_stimulus_message(), skinny_hangup(), and transmit_callstate().
#define SKINNY_SPEAKERON 1 |
Definition at line 844 of file chan_skinny.c.
Referenced by handle_soft_key_event_message(), and handle_stimulus_message().
#define SKINNY_TRANSFER 10 |
Definition at line 859 of file chan_skinny.c.
#define SOFT_KEY_EVENT_MESSAGE 0x0026 |
#define SOFT_KEY_SET_REQ_MESSAGE 0x0025 |
#define SOFT_KEY_SET_RES_MESSAGE 0x0109 |
#define SOFT_KEY_TEMPLATE_REQ_MESSAGE 0x0028 |
#define SOFT_KEY_TEMPLATE_RES_MESSAGE 0x0108 |
#define SOFTKEY_ANSWER 0x0B |
#define SOFTKEY_BKSPC 0x08 |
#define SOFTKEY_CFWDALL 0x05 |
#define SOFTKEY_CFWDBUSY 0x06 |
#define SOFTKEY_CFWDNOANSWER 0x07 |
#define SOFTKEY_CONFRN 0x0D |
#define SOFTKEY_ENDCALL 0x09 |
#define SOFTKEY_GPICKUP 0x12 |
#define SOFTKEY_HOLD 0x03 |
#define SOFTKEY_INFO 0x0C |
#define SOFTKEY_JOIN 0x0F |
#define SOFTKEY_MEETME 0x10 |
#define SOFTKEY_NEWCALL 0x02 |
#define SOFTKEY_NONE 0x00 |
#define SOFTKEY_PARK 0x0E |
#define SOFTKEY_PICKUP 0x11 |
#define SOFTKEY_REDIAL 0x01 |
#define SOFTKEY_RESUME 0x0A |
#define SOFTKEY_TRNSFER 0x04 |
#define SPEED_DIAL_STAT_REQ_MESSAGE 0x000A |
#define SPEED_DIAL_STAT_RES_MESSAGE 0x0091 |
#define START_MEDIA_TRANSMISSION_MESSAGE 0x008A |
Definition at line 306 of file chan_skinny.c.
Referenced by handle_open_receive_channel_ack_message().
#define START_TONE_MESSAGE 0x0082 |
#define STIMULUS_AUTOANSWER 0x11 |
Definition at line 404 of file chan_skinny.c.
#define STIMULUS_CALLPARK 0x7E |
#define STIMULUS_CALLPICKUP 0x7F |
Definition at line 407 of file chan_skinny.c.
#define STIMULUS_CONFERENCE 0x7D |
#define STIMULUS_DISPLAY 0x08 |
#define STIMULUS_FORWARDALL 0x05 |
Definition at line 398 of file chan_skinny.c.
Referenced by handle_soft_key_event_message(), and handle_stimulus_message().
#define STIMULUS_FORWARDBUSY 0x06 |
#define STIMULUS_FORWARDNOANSWER 0x07 |
#define STIMULUS_HOLD 0x03 |
#define STIMULUS_LINE 0x09 |
Definition at line 402 of file chan_skinny.c.
Referenced by handle_offhook_message(), handle_soft_key_event_message(), handle_stimulus_message(), skinny_call(), skinny_hangup(), skinny_hold(), and skinny_unhold().
#define STIMULUS_MESSAGE 0x0005 |
#define STIMULUS_NONE 0xFF |
Definition at line 408 of file chan_skinny.c.
#define STIMULUS_REDIAL 0x01 |
#define STIMULUS_SPEEDDIAL 0x02 |
#define STIMULUS_TRANSFER 0x04 |
#define STIMULUS_VOICEMAIL 0x0F |
#define STOP_MEDIA_TRANSMISSION_MESSAGE 0x008B |
Definition at line 325 of file chan_skinny.c.
Referenced by skinny_hold(), and transmit_callstate().
#define STOP_TONE_MESSAGE 0x0083 |
#define TIME_DATE_REQ_MESSAGE 0x000D |
#define TYPE_LINE 2 |
Definition at line 884 of file chan_skinny.c.
#define TYPE_TRUNK 1 |
Definition at line 883 of file chan_skinny.c.
#define UNREGISTER_MESSAGE 0x0027 |
#define VERSION_REQ_MESSAGE 0x000F |
#define VERSION_RES_MESSAGE 0x0098 |
enum skinny_codecs |
SKINNY_CODEC_ALAW | |
SKINNY_CODEC_ULAW | |
SKINNY_CODEC_G723_1 | |
SKINNY_CODEC_G729A | |
SKINNY_CODEC_G726_32 | |
SKINNY_CODEC_H261 | |
SKINNY_CODEC_H263 |
Definition at line 86 of file chan_skinny.c.
00086 { 00087 SKINNY_CODEC_ALAW = 2, 00088 SKINNY_CODEC_ULAW = 4, 00089 SKINNY_CODEC_G723_1 = 9, 00090 SKINNY_CODEC_G729A = 12, 00091 SKINNY_CODEC_G726_32 = 82, /* XXX Which packing order does this translate to? */ 00092 SKINNY_CODEC_H261 = 100, 00093 SKINNY_CODEC_H263 = 101 00094 };
static void* accept_thread | ( | void * | ignore | ) | [static] |
Definition at line 4490 of file chan_skinny.c.
References ast_calloc, ast_log(), ast_mutex_init(), ast_mutex_lock(), ast_mutex_unlock(), ast_pthread_create, ast_verbose(), destroy_session(), errno, skinnysession::fd, skinnysession::lock, LOG_NOTICE, LOG_WARNING, skinnysession::next, s, sessions, skinnysession::sin, and skinny_session().
04491 { 04492 int as; 04493 struct sockaddr_in sin; 04494 socklen_t sinlen; 04495 struct skinnysession *s; 04496 struct protoent *p; 04497 int arg = 1; 04498 pthread_attr_t attr; 04499 pthread_t tcp_thread; 04500 04501 pthread_attr_init(&attr); 04502 pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); 04503 04504 for (;;) { 04505 sinlen = sizeof(sin); 04506 as = accept(skinnysock, (struct sockaddr *)&sin, &sinlen); 04507 if (as < 0) { 04508 ast_log(LOG_NOTICE, "Accept returned -1: %s\n", strerror(errno)); 04509 continue; 04510 } 04511 p = getprotobyname("tcp"); 04512 if(p) { 04513 if( setsockopt(as, p->p_proto, TCP_NODELAY, (char *)&arg, sizeof(arg) ) < 0 ) { 04514 ast_log(LOG_WARNING, "Failed to set Skinny tcp connection to TCP_NODELAY mode: %s\n", strerror(errno)); 04515 } 04516 } 04517 if (!(s = ast_calloc(1, sizeof(struct skinnysession)))) 04518 continue; 04519 04520 memcpy(&s->sin, &sin, sizeof(sin)); 04521 ast_mutex_init(&s->lock); 04522 s->fd = as; 04523 ast_mutex_lock(&sessionlock); 04524 s->next = sessions; 04525 sessions = s; 04526 ast_mutex_unlock(&sessionlock); 04527 04528 if (ast_pthread_create(&tcp_thread, &attr, skinny_session, s)) { 04529 destroy_session(s); 04530 } 04531 } 04532 if (skinnydebug) 04533 ast_verbose("killing accept thread\n"); 04534 close(as); 04535 pthread_attr_destroy(&attr); 04536 return 0; 04537 }
AST_MODULE_INFO | ( | ASTERISK_GPL_KEY | , | |
AST_MODFLAG_DEFAULT | , | |||
"Skinny Client Control Protocol (Skinny)" | , | |||
. | load = load_module , |
|||
. | unload = unload_module | |||
) |
AST_MUTEX_DEFINE_STATIC | ( | devicelock | ) |
AST_MUTEX_DEFINE_STATIC | ( | sessionlock | ) |
AST_MUTEX_DEFINE_STATIC | ( | netlock | ) |
AST_MUTEX_DEFINE_STATIC | ( | monlock | ) |
AST_THREADSTORAGE | ( | control2str_threadbuf | , | |
control2str_threadbuf_init | ||||
) |
AST_THREADSTORAGE | ( | device2str_threadbuf | , | |
device2str_threadbuf_init | ||||
) |
static struct skinny_device* build_device | ( | const char * | cat, | |
struct ast_variable * | v | |||
) | [static, read] |
Definition at line 2083 of file chan_skinny.c.
References __ourip, skinny_device::addons, skinny_device::addr, ast_append_ha(), ast_callerid_split(), ast_calloc, ast_cdr_amaflags2int(), ast_get_group(), ast_get_ip(), ast_log(), ast_mutex_init(), ast_ouraddrfor(), ast_parse_allow_disallow(), ast_strlen_zero(), ast_true(), ast_verbose(), skinny_line::callgroup, skinny_line::callreturn, skinny_line::callwaiting, skinny_line::cancallforward, skinny_line::capability, skinny_device::capability, skinny_line::cid_name, skinny_line::cid_num, skinny_line::context, default_prefs, DEFAULT_SKINNY_PORT, skinny_speeddial::exten, exten, free, skinny_device::ha, skinny_line::hookstate, skinny_device::id, skinny_line::immediate, skinny_line::instance, skinny_speeddial::instance, skinny_line::label, skinny_speeddial::label, skinny_line::language, skinny_device::lastlineinstance, ast_variable::lineno, skinny_device::lines, skinny_line::lock, skinny_addon::lock, skinny_speeddial::lock, LOG_ERROR, LOG_WARNING, skinny_line::mailbox, skinny_line::mohinterpret, skinny_line::mohsuggest, skinny_line::msgstate, skinny_line::mwiblink, skinny_line::name, ast_variable::name, skinny_device::name, skinny_line::nat, ast_variable::next, skinny_line::next, skinny_addon::next, skinny_speeddial::next, skinny_line::onhooktime, option_verbose, skinny_device::ourip, skinny_line::parent, skinny_speeddial::parent, skinny_line::pickupgroup, skinny_line::prefs, skinny_device::prefs, SKINNY_ONHOOK, skinny_device::speeddials, strsep(), skinny_line::threewaycalling, skinny_line::transfer, skinny_line::type, skinny_addon::type, TYPE_LINE, TYPE_TRUNK, ast_variable::value, VERBOSE_PREFIX_3, and skinny_device::version_id.
Referenced by reload_config().
02084 { 02085 struct skinny_device *d; 02086 struct skinny_line *l; 02087 struct skinny_speeddial *sd; 02088 struct skinny_addon *a; 02089 int lineInstance = 1; 02090 int speeddialInstance = 1; 02091 int y = 0; 02092 02093 if (!(d = ast_calloc(1, sizeof(struct skinny_device)))) { 02094 return NULL; 02095 } else { 02096 ast_copy_string(d->name, cat, sizeof(d->name)); 02097 d->lastlineinstance = 1; 02098 d->capability = default_capability; 02099 d->prefs = default_prefs; 02100 while(v) { 02101 if (!strcasecmp(v->name, "host")) { 02102 if (ast_get_ip(&d->addr, v->value)) { 02103 free(d); 02104 return NULL; 02105 } 02106 } else if (!strcasecmp(v->name, "port")) { 02107 d->addr.sin_port = htons(atoi(v->value)); 02108 } else if (!strcasecmp(v->name, "device")) { 02109 ast_copy_string(d->id, v->value, sizeof(d->id)); 02110 } else if (!strcasecmp(v->name, "permit") || !strcasecmp(v->name, "deny")) { 02111 d->ha = ast_append_ha(v->name, v->value, d->ha); 02112 } else if (!strcasecmp(v->name, "context")) { 02113 ast_copy_string(context, v->value, sizeof(context)); 02114 } else if (!strcasecmp(v->name, "allow")) { 02115 ast_parse_allow_disallow(&d->prefs, &d->capability, v->value, 1); 02116 } else if (!strcasecmp(v->name, "disallow")) { 02117 ast_parse_allow_disallow(&d->prefs, &d->capability, v->value, 0); 02118 } else if (!strcasecmp(v->name, "version")) { 02119 ast_copy_string(d->version_id, v->value, sizeof(d->version_id)); 02120 } else if (!strcasecmp(v->name, "nat")) { 02121 nat = ast_true(v->value); 02122 } else if (!strcasecmp(v->name, "callerid")) { 02123 if (!strcasecmp(v->value, "asreceived")) { 02124 cid_num[0] = '\0'; 02125 cid_name[0] = '\0'; 02126 } else { 02127 ast_callerid_split(v->value, cid_name, sizeof(cid_name), cid_num, sizeof(cid_num)); 02128 } 02129 } else if (!strcasecmp(v->name, "language")) { 02130 ast_copy_string(language, v->value, sizeof(language)); 02131 } else if (!strcasecmp(v->name, "accountcode")) { 02132 ast_copy_string(accountcode, v->value, sizeof(accountcode)); 02133 } else if (!strcasecmp(v->name, "amaflags")) { 02134 y = ast_cdr_amaflags2int(v->value); 02135 if (y < 0) { 02136 ast_log(LOG_WARNING, "Invalid AMA flags: %s at line %d\n", v->value, v->lineno); 02137 } else { 02138 amaflags = y; 02139 } 02140 } else if (!strcasecmp(v->name, "mohinterpret") || !strcasecmp(v->name, "musiconhold")) { 02141 ast_copy_string(mohinterpret, v->value, sizeof(mohinterpret)); 02142 } else if (!strcasecmp(v->name, "mohsuggest")) { 02143 ast_copy_string(mohsuggest, v->value, sizeof(mohsuggest)); 02144 } else if (!strcasecmp(v->name, "callgroup")) { 02145 cur_callergroup = ast_get_group(v->value); 02146 } else if (!strcasecmp(v->name, "pickupgroup")) { 02147 cur_pickupgroup = ast_get_group(v->value); 02148 } else if (!strcasecmp(v->name, "immediate")) { 02149 immediate = ast_true(v->value); 02150 } else if (!strcasecmp(v->name, "cancallforward")) { 02151 cancallforward = ast_true(v->value); 02152 } else if (!strcasecmp(v->name, "mailbox")) { 02153 ast_copy_string(mailbox, v->value, sizeof(mailbox)); 02154 } else if (!strcasecmp(v->name, "callreturn")) { 02155 callreturn = ast_true(v->value); 02156 } else if (!strcasecmp(v->name, "callwaiting")) { 02157 callwaiting = ast_true(v->value); 02158 } else if (!strcasecmp(v->name, "transfer")) { 02159 transfer = ast_true(v->value); 02160 } else if (!strcasecmp(v->name, "threewaycalling")) { 02161 threewaycalling = ast_true(v->value); 02162 } else if (!strcasecmp(v->name, "mwiblink")) { 02163 mwiblink = ast_true(v->value); 02164 } else if (!strcasecmp(v->name, "linelabel")) { 02165 ast_copy_string(linelabel, v->value, sizeof(linelabel)); 02166 } else if (!strcasecmp(v->name, "speeddial")) { 02167 if (!(sd = ast_calloc(1, sizeof(struct skinny_speeddial)))) { 02168 return NULL; 02169 } else { 02170 char *stringp, *exten, *label; 02171 stringp = v->value; 02172 exten = strsep(&stringp, ","); 02173 label = strsep(&stringp, ","); 02174 ast_mutex_init(&sd->lock); 02175 ast_copy_string(sd->exten, exten, sizeof(sd->exten)); 02176 if (label) 02177 ast_copy_string(sd->label, label, sizeof(sd->label)); 02178 else 02179 ast_copy_string(sd->label, exten, sizeof(sd->label)); 02180 sd->instance = speeddialInstance++; 02181 02182 sd->parent = d; 02183 02184 sd->next = d->speeddials; 02185 d->speeddials = sd; 02186 } 02187 } else if (!strcasecmp(v->name, "addon")) { 02188 if (!(a = ast_calloc(1, sizeof(struct skinny_addon)))) { 02189 return NULL; 02190 } else { 02191 ast_mutex_init(&a->lock); 02192 ast_copy_string(a->type, v->value, sizeof(a->type)); 02193 02194 a->next = d->addons; 02195 d->addons = a; 02196 } 02197 } else if (!strcasecmp(v->name, "trunk") || !strcasecmp(v->name, "line")) { 02198 if (!(l = ast_calloc(1, sizeof(struct skinny_line)))) { 02199 return NULL; 02200 } else { 02201 ast_mutex_init(&l->lock); 02202 ast_copy_string(l->name, v->value, sizeof(l->name)); 02203 02204 /* XXX Should we check for uniqueness?? XXX */ 02205 ast_copy_string(l->context, context, sizeof(l->context)); 02206 ast_copy_string(l->cid_num, cid_num, sizeof(l->cid_num)); 02207 ast_copy_string(l->cid_name, cid_name, sizeof(l->cid_name)); 02208 ast_copy_string(l->label, linelabel, sizeof(l->label)); 02209 ast_copy_string(l->language, language, sizeof(l->language)); 02210 ast_copy_string(l->mohinterpret, mohinterpret, sizeof(l->mohinterpret)); 02211 ast_copy_string(l->mohsuggest, mohsuggest, sizeof(l->mohsuggest)); 02212 ast_copy_string(l->mailbox, mailbox, sizeof(l->mailbox)); 02213 if (!ast_strlen_zero(mailbox)) { 02214 if (option_verbose > 2) 02215 ast_verbose(VERBOSE_PREFIX_3 "Setting mailbox '%s' on %s@%s\n", mailbox, d->name, l->name); 02216 } 02217 l->msgstate = -1; 02218 l->capability = d->capability; 02219 l->prefs = d->prefs; 02220 l->parent = d; 02221 if (!strcasecmp(v->name, "trunk")) { 02222 l->type = TYPE_TRUNK; 02223 } else { 02224 l->type = TYPE_LINE; 02225 } 02226 l->immediate = immediate; 02227 l->callgroup = cur_callergroup; 02228 l->pickupgroup = cur_pickupgroup; 02229 l->callreturn = callreturn; 02230 l->cancallforward = cancallforward; 02231 l->callwaiting = callwaiting; 02232 l->transfer = transfer; 02233 l->threewaycalling = threewaycalling; 02234 l->mwiblink = mwiblink; 02235 l->onhooktime = time(NULL); 02236 l->instance = lineInstance++; 02237 /* ASSUME we're onhook at this point */ 02238 l->hookstate = SKINNY_ONHOOK; 02239 l->nat = nat; 02240 02241 l->next = d->lines; 02242 d->lines = l; 02243 } 02244 } else { 02245 ast_log(LOG_WARNING, "Don't know keyword '%s' at line %d\n", v->name, v->lineno); 02246 } 02247 v = v->next; 02248 } 02249 02250 if (!d->lines) { 02251 ast_log(LOG_ERROR, "A Skinny device must have at least one line!\n"); 02252 return NULL; 02253 } 02254 if (/*d->addr.sin_addr.s_addr && */!ntohs(d->addr.sin_port)) { 02255 d->addr.sin_port = htons(DEFAULT_SKINNY_PORT); 02256 } 02257 #if 0 02258 /* I don't think we need this anymore at all, since d->ourip is set in skinny_register now */ 02259 if (d->addr.sin_addr.s_addr) { 02260 /* XXX See note above, in 'host' option. */ 02261 if (ast_ouraddrfor(&d->addr.sin_addr, &d->ourip)) { 02262 d->ourip = __ourip; 02263 } 02264 } else { 02265 d->ourip = __ourip; 02266 } 02267 #endif 02268 } 02269 return d; 02270 }
static int codec_ast2skinny | ( | int | astcodec | ) | [static] |
Definition at line 1362 of file chan_skinny.c.
References AST_FORMAT_ALAW, AST_FORMAT_G723_1, AST_FORMAT_G726_AAL2, AST_FORMAT_G729A, AST_FORMAT_H261, AST_FORMAT_H263, AST_FORMAT_ULAW, SKINNY_CODEC_ALAW, SKINNY_CODEC_G723_1, SKINNY_CODEC_G726_32, SKINNY_CODEC_G729A, SKINNY_CODEC_H261, SKINNY_CODEC_H263, and SKINNY_CODEC_ULAW.
Referenced by handle_open_receive_channel_ack_message(), and transmit_connect().
01363 { 01364 switch (astcodec) { 01365 case AST_FORMAT_ALAW: 01366 return SKINNY_CODEC_ALAW; 01367 case AST_FORMAT_ULAW: 01368 return SKINNY_CODEC_ULAW; 01369 case AST_FORMAT_G723_1: 01370 return SKINNY_CODEC_G723_1; 01371 case AST_FORMAT_G729A: 01372 return SKINNY_CODEC_G729A; 01373 case AST_FORMAT_G726_AAL2: /* XXX Is this right? */ 01374 return SKINNY_CODEC_G726_32; 01375 case AST_FORMAT_H261: 01376 return SKINNY_CODEC_H261; 01377 case AST_FORMAT_H263: 01378 return SKINNY_CODEC_H263; 01379 default: 01380 return 0; 01381 } 01382 }
static int codec_skinny2ast | ( | enum skinny_codecs | skinnycodec | ) | [static] |
Definition at line 1340 of file chan_skinny.c.
References AST_FORMAT_ALAW, AST_FORMAT_G723_1, AST_FORMAT_G726_AAL2, AST_FORMAT_G729A, AST_FORMAT_H261, AST_FORMAT_H263, AST_FORMAT_ULAW, SKINNY_CODEC_ALAW, SKINNY_CODEC_G723_1, SKINNY_CODEC_G726_32, SKINNY_CODEC_G729A, SKINNY_CODEC_H261, SKINNY_CODEC_H263, and SKINNY_CODEC_ULAW.
Referenced by handle_capabilities_res_message().
01341 { 01342 switch (skinnycodec) { 01343 case SKINNY_CODEC_ALAW: 01344 return AST_FORMAT_ALAW; 01345 case SKINNY_CODEC_ULAW: 01346 return AST_FORMAT_ULAW; 01347 case SKINNY_CODEC_G723_1: 01348 return AST_FORMAT_G723_1; 01349 case SKINNY_CODEC_G729A: 01350 return AST_FORMAT_G729A; 01351 case SKINNY_CODEC_G726_32: 01352 return AST_FORMAT_G726_AAL2; /* XXX Is this right? */ 01353 case SKINNY_CODEC_H261: 01354 return AST_FORMAT_H261; 01355 case SKINNY_CODEC_H263: 01356 return AST_FORMAT_H263; 01357 default: 01358 return 0; 01359 } 01360 }
static char* complete_skinny_reset | ( | const char * | line, | |
const char * | word, | |||
int | pos, | |||
int | state | |||
) | [static] |
Definition at line 1852 of file chan_skinny.c.
References ast_strdup, devices, skinny_device::id, and skinny_device::next.
01853 { 01854 struct skinny_device *d; 01855 01856 char *result = NULL; 01857 int wordlen = strlen(word); 01858 int which = 0; 01859 01860 if (pos == 2) { 01861 for (d = devices; d && !result; d = d->next) { 01862 if (!strncasecmp(word, d->id, wordlen) && ++which > state) 01863 result = ast_strdup(d->id); 01864 } 01865 } 01866 01867 return result; 01868 }
static char* control2str | ( | int | ind | ) | [static] |
Definition at line 2675 of file chan_skinny.c.
References AST_CONTROL_ANSWER, AST_CONTROL_BUSY, AST_CONTROL_CONGESTION, AST_CONTROL_FLASH, AST_CONTROL_HANGUP, AST_CONTROL_HOLD, AST_CONTROL_OFFHOOK, AST_CONTROL_OPTION, AST_CONTROL_PROCEEDING, AST_CONTROL_PROGRESS, AST_CONTROL_RADIO_KEY, AST_CONTROL_RADIO_UNKEY, AST_CONTROL_RING, AST_CONTROL_RINGING, AST_CONTROL_TAKEOFFHOOK, AST_CONTROL_UNHOLD, AST_CONTROL_WINK, and CONTROL2STR_BUFSIZE.
02675 { 02676 char *tmp; 02677 02678 switch (ind) { 02679 case AST_CONTROL_HANGUP: 02680 return "Other end has hungup"; 02681 case AST_CONTROL_RING: 02682 return "Local ring"; 02683 case AST_CONTROL_RINGING: 02684 return "Remote end is ringing"; 02685 case AST_CONTROL_ANSWER: 02686 return "Remote end has answered"; 02687 case AST_CONTROL_BUSY: 02688 return "Remote end is busy"; 02689 case AST_CONTROL_TAKEOFFHOOK: 02690 return "Make it go off hook"; 02691 case AST_CONTROL_OFFHOOK: 02692 return "Line is off hook"; 02693 case AST_CONTROL_CONGESTION: 02694 return "Congestion (circuits busy)"; 02695 case AST_CONTROL_FLASH: 02696 return "Flash hook"; 02697 case AST_CONTROL_WINK: 02698 return "Wink"; 02699 case AST_CONTROL_OPTION: 02700 return "Set a low-level option"; 02701 case AST_CONTROL_RADIO_KEY: 02702 return "Key Radio"; 02703 case AST_CONTROL_RADIO_UNKEY: 02704 return "Un-Key Radio"; 02705 case AST_CONTROL_PROGRESS: 02706 return "Remote end is making Progress"; 02707 case AST_CONTROL_PROCEEDING: 02708 return "Remote end is proceeding"; 02709 case AST_CONTROL_HOLD: 02710 return "Hold"; 02711 case AST_CONTROL_UNHOLD: 02712 return "Unhold"; 02713 case -1: 02714 return "Stop tone"; 02715 default: 02716 if (!(tmp = ast_threadstorage_get(&control2str_threadbuf, CONTROL2STR_BUFSIZE))) 02717 return "Unknown"; 02718 snprintf(tmp, CONTROL2STR_BUFSIZE, "UNKNOWN-%d", ind); 02719 return tmp; 02720 } 02721 }
static void delete_devices | ( | void | ) | [static] |
Definition at line 4776 of file chan_skinny.c.
References skinny_device::addons, ast_mutex_destroy(), ast_mutex_lock(), ast_mutex_unlock(), devices, free, skinny_device::lines, skinny_addon::lock, skinny_speeddial::lock, skinny_line::lock, skinny_device::next, skinny_addon::next, skinny_speeddial::next, skinny_line::next, and skinny_device::speeddials.
Referenced by unload_module().
04777 { 04778 struct skinny_device *d, *dlast; 04779 struct skinny_line *l, *llast; 04780 struct skinny_speeddial *sd, *sdlast; 04781 struct skinny_addon *a, *alast; 04782 04783 ast_mutex_lock(&devicelock); 04784 04785 /* Delete all devices */ 04786 for (d=devices;d;) { 04787 /* Delete all lines for this device */ 04788 for (l=d->lines;l;) { 04789 llast = l; 04790 l = l->next; 04791 ast_mutex_destroy(&llast->lock); 04792 free(llast); 04793 } 04794 /* Delete all speeddials for this device */ 04795 for (sd=d->speeddials;sd;) { 04796 sdlast = sd; 04797 sd = sd->next; 04798 ast_mutex_destroy(&sdlast->lock); 04799 free(sdlast); 04800 } 04801 /* Delete all addons for this device */ 04802 for (a=d->addons;a;) { 04803 alast = a; 04804 a = a->next; 04805 ast_mutex_destroy(&alast->lock); 04806 free(alast); 04807 } 04808 dlast = d; 04809 d = d->next; 04810 free(dlast); 04811 } 04812 devices=NULL; 04813 ast_mutex_unlock(&devicelock); 04814 }
static void destroy_session | ( | struct skinnysession * | s | ) | [static] |
Definition at line 4327 of file chan_skinny.c.
References ast_log(), ast_mutex_destroy(), ast_mutex_lock(), ast_mutex_unlock(), skinnysession::fd, free, skinnysession::lock, LOG_WARNING, skinnysession::next, and sessions.
04328 { 04329 struct skinnysession *cur, *prev = NULL; 04330 ast_mutex_lock(&sessionlock); 04331 cur = sessions; 04332 while(cur) { 04333 if (cur == s) { 04334 break; 04335 } 04336 prev = cur; 04337 cur = cur->next; 04338 } 04339 if (cur) { 04340 if (prev) { 04341 prev->next = cur->next; 04342 } else { 04343 sessions = cur->next; 04344 } 04345 if (s->fd > -1) { 04346 close(s->fd); 04347 } 04348 ast_mutex_destroy(&s->lock); 04349 free(s); 04350 } else { 04351 ast_log(LOG_WARNING, "Trying to delete nonexistent session %p?\n", s); 04352 } 04353 ast_mutex_unlock(&sessionlock); 04354 }
static char* device2str | ( | int | type | ) | [static] |
Definition at line 1906 of file chan_skinny.c.
References DEVICE2STR_BUFSIZE, SKINNY_DEVICE_12, SKINNY_DEVICE_12SP, SKINNY_DEVICE_12SPPLUS, SKINNY_DEVICE_30SPPLUS, SKINNY_DEVICE_30VIP, SKINNY_DEVICE_7902, SKINNY_DEVICE_7905, SKINNY_DEVICE_7910, SKINNY_DEVICE_7911, SKINNY_DEVICE_7912, SKINNY_DEVICE_7920, SKINNY_DEVICE_7921, SKINNY_DEVICE_7935, SKINNY_DEVICE_7936, SKINNY_DEVICE_7940, SKINNY_DEVICE_7941, SKINNY_DEVICE_7941GE, SKINNY_DEVICE_7960, SKINNY_DEVICE_7961, SKINNY_DEVICE_7961GE, SKINNY_DEVICE_7970, SKINNY_DEVICE_7971, SKINNY_DEVICE_7985, SKINNY_DEVICE_ATA186, SKINNY_DEVICE_CIPC, SKINNY_DEVICE_NONE, SKINNY_DEVICE_SCCPGATEWAY_AN, SKINNY_DEVICE_SCCPGATEWAY_BRI, and SKINNY_DEVICE_UNKNOWN.
Referenced by skinny_show_devices().
01907 { 01908 char *tmp; 01909 01910 switch (type) { 01911 case SKINNY_DEVICE_NONE: 01912 return "No Device"; 01913 case SKINNY_DEVICE_30SPPLUS: 01914 return "30SP Plus"; 01915 case SKINNY_DEVICE_12SPPLUS: 01916 return "12SP Plus"; 01917 case SKINNY_DEVICE_12SP: 01918 return "12SP"; 01919 case SKINNY_DEVICE_12: 01920 return "12"; 01921 case SKINNY_DEVICE_30VIP: 01922 return "30VIP"; 01923 case SKINNY_DEVICE_7910: 01924 return "7910"; 01925 case SKINNY_DEVICE_7960: 01926 return "7960"; 01927 case SKINNY_DEVICE_7940: 01928 return "7940"; 01929 case SKINNY_DEVICE_7935: 01930 return "7935"; 01931 case SKINNY_DEVICE_ATA186: 01932 return "ATA186"; 01933 case SKINNY_DEVICE_7941: 01934 return "7941"; 01935 case SKINNY_DEVICE_7971: 01936 return "7971"; 01937 case SKINNY_DEVICE_7985: 01938 return "7985"; 01939 case SKINNY_DEVICE_7911: 01940 return "7911"; 01941 case SKINNY_DEVICE_7961GE: 01942 return "7961GE"; 01943 case SKINNY_DEVICE_7941GE: 01944 return "7941GE"; 01945 case SKINNY_DEVICE_7921: 01946 return "7921"; 01947 case SKINNY_DEVICE_7905: 01948 return "7905"; 01949 case SKINNY_DEVICE_7920: 01950 return "7920"; 01951 case SKINNY_DEVICE_7970: 01952 return "7970"; 01953 case SKINNY_DEVICE_7912: 01954 return "7912"; 01955 case SKINNY_DEVICE_7902: 01956 return "7902"; 01957 case SKINNY_DEVICE_CIPC: 01958 return "IP Communicator"; 01959 case SKINNY_DEVICE_7961: 01960 return "7961"; 01961 case SKINNY_DEVICE_7936: 01962 return "7936"; 01963 case SKINNY_DEVICE_SCCPGATEWAY_AN: 01964 return "SCCPGATEWAY_AN"; 01965 case SKINNY_DEVICE_SCCPGATEWAY_BRI: 01966 return "SCCPGATEWAY_BRI"; 01967 case SKINNY_DEVICE_UNKNOWN: 01968 return "Unknown"; 01969 default: 01970 if (!(tmp = ast_threadstorage_get(&device2str_threadbuf, DEVICE2STR_BUFSIZE))) 01971 return "Unknown"; 01972 snprintf(tmp, DEVICE2STR_BUFSIZE, "UNKNOWN-%d", type); 01973 return tmp; 01974 } 01975 }
static void do_housekeeping | ( | struct skinnysession * | s | ) | [static] |
Definition at line 1759 of file chan_skinny.c.
References handle_time_date_req_message().
Referenced by handle_keep_alive_message(), handle_onhook_message(), handle_soft_key_event_message(), and skinny_hangup().
01760 { 01761 /* 01762 int new; 01763 int old; 01764 struct skinny_device *d = s->device; 01765 struct skinny_line *l; 01766 */ 01767 01768 /* Update time on device */ 01769 handle_time_date_req_message(NULL, s); 01770 01771 /* 01772 for (l = d->lines; l; l = l->next) { 01773 if (has_voicemail(l)) { 01774 if (skinnydebug) 01775 ast_verbose("Checking for voicemail Skinny %s@%s\n", l->name, d->name); 01776 ast_app_inboxcount(l->mailbox, &new, &old); 01777 if (skinnydebug) 01778 ast_verbose("Skinny %s@%s has voicemail!\n", l->name, d->name); 01779 transmit_lamp_indication(s, STIMULUS_VOICEMAIL, l->instance, l->mwiblink?SKINNY_LAMP_BLINK:SKINNY_LAMP_ON); 01780 } else { 01781 transmit_lamp_indication(s, STIMULUS_VOICEMAIL, l->instance, SKINNY_LAMP_OFF); 01782 } 01783 } 01784 */ 01785 }
static void* do_monitor | ( | void * | data | ) | [static] |
Definition at line 4539 of file chan_skinny.c.
References ast_io_wait(), ast_mutex_lock(), ast_mutex_unlock(), ast_sched_runq(), and ast_sched_wait().
04540 { 04541 int res; 04542 04543 /* This thread monitors all the interfaces which are not yet in use 04544 (and thus do not have a separate thread) indefinitely */ 04545 /* From here on out, we die whenever asked */ 04546 for(;;) { 04547 pthread_testcancel(); 04548 /* Wait for sched or io */ 04549 res = ast_sched_wait(sched); 04550 if ((res < 0) || (res > 1000)) { 04551 res = 1000; 04552 } 04553 res = ast_io_wait(io, res); 04554 ast_mutex_lock(&monlock); 04555 if (res >= 0) { 04556 ast_sched_runq(sched); 04557 } 04558 ast_mutex_unlock(&monlock); 04559 } 04560 /* Never reached */ 04561 return NULL; 04562 04563 }
static struct skinny_line* find_line_by_instance | ( | struct skinny_device * | d, | |
int | instance | |||
) | [static, read] |
Definition at line 1221 of file chan_skinny.c.
References ast_log(), skinny_line::instance, skinny_device::lines, LOG_WARNING, skinny_device::name, and skinny_line::next.
Referenced by find_subchannel_by_instance_reference(), handle_enbloc_call_message(), handle_line_state_req_message(), handle_offhook_message(), handle_soft_key_event_message(), and handle_stimulus_message().
01222 { 01223 struct skinny_line *l; 01224 01225 if (!instance) 01226 instance = 1; 01227 01228 for (l = d->lines; l; l = l->next) { 01229 if (l->instance == instance) 01230 break; 01231 } 01232 01233 if (!l) { 01234 ast_log(LOG_WARNING, "Could not find line with instance '%d' on device '%s'\n", instance, d->name); 01235 } 01236 return l; 01237 }
static struct skinny_line* find_line_by_name | ( | const char * | dest | ) | [static, read] |
Definition at line 1239 of file chan_skinny.c.
References ast_log(), ast_mutex_lock(), ast_mutex_unlock(), ast_verbose(), devices, skinny_device::lines, LOG_NOTICE, skinny_line::name, skinny_device::name, skinny_line::next, and skinny_device::next.
Referenced by skinny_request().
01240 { 01241 struct skinny_line *l; 01242 struct skinny_device *d; 01243 char line[256]; 01244 char *at; 01245 char *device; 01246 01247 ast_copy_string(line, dest, sizeof(line)); 01248 at = strchr(line, '@'); 01249 if (!at) { 01250 ast_log(LOG_NOTICE, "Device '%s' has no @ (at) sign!\n", dest); 01251 return NULL; 01252 } 01253 *at++ = '\0'; 01254 device = at; 01255 ast_mutex_lock(&devicelock); 01256 for (d = devices; d; d = d->next) { 01257 if (!strcasecmp(d->name, device)) { 01258 if (skinnydebug) 01259 ast_verbose("Found device: %s\n", d->name); 01260 /* Found the device */ 01261 for (l = d->lines; l; l = l->next) { 01262 /* Search for the right line */ 01263 if (!strcasecmp(l->name, line)) { 01264 ast_mutex_unlock(&devicelock); 01265 return l; 01266 } 01267 } 01268 } 01269 } 01270 /* Device not found */ 01271 ast_mutex_unlock(&devicelock); 01272 return NULL; 01273 }
static struct skinny_speeddial* find_speeddial_by_instance | ( | struct skinny_device * | d, | |
int | instance | |||
) | [static, read] |
Definition at line 1325 of file chan_skinny.c.
References ast_log(), skinny_speeddial::instance, LOG_WARNING, skinny_device::name, skinny_speeddial::next, and skinny_device::speeddials.
Referenced by handle_speed_dial_stat_req_message(), and handle_stimulus_message().
01326 { 01327 struct skinny_speeddial *sd; 01328 01329 for (sd = d->speeddials; sd; sd = sd->next) { 01330 if (sd->instance == instance) 01331 break; 01332 } 01333 01334 if (!sd) { 01335 ast_log(LOG_WARNING, "Could not find speeddial with instance '%d' on device '%s'\n", instance, d->name); 01336 } 01337 return sd; 01338 }
static struct skinny_subchannel* find_subchannel_by_instance_reference | ( | struct skinny_device * | d, | |
int | instance, | |||
int | reference | |||
) | [static, read] |
Definition at line 1276 of file chan_skinny.c.
References ast_log(), skinny_subchannel::callid, find_line_by_instance(), LOG_WARNING, skinny_device::name, skinny_subchannel::next, and skinny_line::sub.
Referenced by handle_enbloc_call_message(), handle_keypad_button_message(), handle_message(), handle_offhook_message(), handle_onhook_message(), handle_soft_key_event_message(), and handle_stimulus_message().
01277 { 01278 struct skinny_line *l = find_line_by_instance(d, instance); 01279 struct skinny_subchannel *sub; 01280 01281 if (!l) { 01282 return NULL; 01283 } 01284 01285 if (!reference) 01286 sub = l->sub; 01287 else { 01288 for (sub = l->sub; sub; sub = sub->next) { 01289 if (sub->callid == reference) 01290 break; 01291 } 01292 } 01293 01294 if (!sub) { 01295 ast_log(LOG_WARNING, "Could not find subchannel with reference '%d' on '%s'\n", reference, d->name); 01296 } 01297 return sub; 01298 }
static struct skinny_subchannel* find_subchannel_by_reference | ( | struct skinny_device * | d, | |
int | reference | |||
) | [static, read] |
Definition at line 1301 of file chan_skinny.c.
References ast_log(), skinny_subchannel::callid, skinny_device::lines, LOG_WARNING, skinny_line::name, skinny_device::name, skinny_subchannel::next, skinny_line::next, and skinny_line::sub.
Referenced by handle_open_receive_channel_ack_message().
01302 { 01303 struct skinny_line *l; 01304 struct skinny_subchannel *sub = NULL; 01305 01306 for (l = d->lines; l; l = l->next) { 01307 for (sub = l->sub; sub; sub = sub->next) { 01308 if (sub->callid == reference) 01309 break; 01310 } 01311 if (sub) 01312 break; 01313 } 01314 01315 if (!l) { 01316 ast_log(LOG_WARNING, "Could not find any lines that contained a subchannel with reference '%d' on device '%s'\n", reference, d->name); 01317 } else { 01318 if (!sub) { 01319 ast_log(LOG_WARNING, "Could not find subchannel with reference '%d' on '%s@%s'\n", reference, l->name, d->name); 01320 } 01321 } 01322 return sub; 01323 }
static void* get_button_template | ( | struct skinnysession * | s, | |
struct button_definition_template * | btn | |||
) | [static] |
Definition at line 1091 of file chan_skinny.c.
References skinny_device::addons, ast_log(), BT_CALLPARK, BT_CONFERENCE, BT_CUST_LINESPEEDDIAL, BT_DISPLAY, BT_FORWARDALL, BT_HOLD, BT_LINE, BT_NONE, BT_REDIAL, BT_SPEEDDIAL, BT_TRANSFER, BT_VOICEMAIL, skinnysession::device, LOG_WARNING, skinny_addon::next, SKINNY_DEVICE_12, SKINNY_DEVICE_12SP, SKINNY_DEVICE_12SPPLUS, SKINNY_DEVICE_30SPPLUS, SKINNY_DEVICE_30VIP, SKINNY_DEVICE_7902, SKINNY_DEVICE_7905, SKINNY_DEVICE_7910, SKINNY_DEVICE_7911, SKINNY_DEVICE_7912, SKINNY_DEVICE_7920, SKINNY_DEVICE_7921, SKINNY_DEVICE_7935, SKINNY_DEVICE_7936, SKINNY_DEVICE_7940, SKINNY_DEVICE_7941, SKINNY_DEVICE_7941GE, SKINNY_DEVICE_7960, SKINNY_DEVICE_7961, SKINNY_DEVICE_7961GE, SKINNY_DEVICE_7970, SKINNY_DEVICE_7971, SKINNY_DEVICE_7985, SKINNY_DEVICE_ATA186, SKINNY_DEVICE_CIPC, SKINNY_DEVICE_SCCPGATEWAY_AN, SKINNY_DEVICE_SCCPGATEWAY_BRI, skinny_addon::type, and skinny_device::type.
Referenced by handle_button_template_req_message().
01092 { 01093 struct skinny_device *d = s->device; 01094 struct skinny_addon *a = d->addons; 01095 int i; 01096 01097 switch (d->type) { 01098 case SKINNY_DEVICE_30SPPLUS: 01099 case SKINNY_DEVICE_30VIP: 01100 /* 13 rows, 2 columns */ 01101 for (i = 0; i < 4; i++) 01102 (btn++)->buttonDefinition = BT_LINE; 01103 (btn++)->buttonDefinition = BT_REDIAL; 01104 (btn++)->buttonDefinition = BT_VOICEMAIL; 01105 (btn++)->buttonDefinition = BT_CALLPARK; 01106 (btn++)->buttonDefinition = BT_FORWARDALL; 01107 (btn++)->buttonDefinition = BT_CONFERENCE; 01108 for (i = 0; i < 4; i++) 01109 (btn++)->buttonDefinition = BT_NONE; 01110 for (i = 0; i < 13; i++) 01111 (btn++)->buttonDefinition = BT_SPEEDDIAL; 01112 01113 break; 01114 case SKINNY_DEVICE_12SPPLUS: 01115 case SKINNY_DEVICE_12SP: 01116 case SKINNY_DEVICE_12: 01117 /* 6 rows, 2 columns */ 01118 for (i = 0; i < 2; i++) 01119 (btn++)->buttonDefinition = BT_LINE; 01120 (btn++)->buttonDefinition = BT_REDIAL; 01121 for (i = 0; i < 3; i++) 01122 (btn++)->buttonDefinition = BT_SPEEDDIAL; 01123 (btn++)->buttonDefinition = BT_HOLD; 01124 (btn++)->buttonDefinition = BT_TRANSFER; 01125 (btn++)->buttonDefinition = BT_FORWARDALL; 01126 (btn++)->buttonDefinition = BT_CALLPARK; 01127 (btn++)->buttonDefinition = BT_VOICEMAIL; 01128 (btn++)->buttonDefinition = BT_CONFERENCE; 01129 break; 01130 case SKINNY_DEVICE_7910: 01131 (btn++)->buttonDefinition = BT_LINE; 01132 (btn++)->buttonDefinition = BT_HOLD; 01133 (btn++)->buttonDefinition = BT_TRANSFER; 01134 (btn++)->buttonDefinition = BT_DISPLAY; 01135 (btn++)->buttonDefinition = BT_VOICEMAIL; 01136 (btn++)->buttonDefinition = BT_CONFERENCE; 01137 (btn++)->buttonDefinition = BT_FORWARDALL; 01138 for (i = 0; i < 2; i++) 01139 (btn++)->buttonDefinition = BT_SPEEDDIAL; 01140 (btn++)->buttonDefinition = BT_REDIAL; 01141 break; 01142 case SKINNY_DEVICE_7960: 01143 case SKINNY_DEVICE_7961: 01144 case SKINNY_DEVICE_7961GE: 01145 for (i = 0; i < 6; i++) 01146 (btn++)->buttonDefinition = BT_CUST_LINESPEEDDIAL; 01147 break; 01148 case SKINNY_DEVICE_7940: 01149 case SKINNY_DEVICE_7941: 01150 case SKINNY_DEVICE_7941GE: 01151 for (i = 0; i < 2; i++) 01152 (btn++)->buttonDefinition = BT_CUST_LINESPEEDDIAL; 01153 break; 01154 case SKINNY_DEVICE_7935: 01155 case SKINNY_DEVICE_7936: 01156 for (i = 0; i < 2; i++) 01157 (btn++)->buttonDefinition = BT_LINE; 01158 break; 01159 case SKINNY_DEVICE_ATA186: 01160 (btn++)->buttonDefinition = BT_LINE; 01161 break; 01162 case SKINNY_DEVICE_7970: 01163 case SKINNY_DEVICE_7971: 01164 case SKINNY_DEVICE_CIPC: 01165 for (i = 0; i < 8; i++) 01166 (btn++)->buttonDefinition = BT_CUST_LINESPEEDDIAL; 01167 break; 01168 case SKINNY_DEVICE_7985: 01169 /* XXX I have no idea what the buttons look like on these. */ 01170 ast_log(LOG_WARNING, "Unsupported device type '%d (7985)' found.\n", d->type); 01171 break; 01172 case SKINNY_DEVICE_7912: 01173 case SKINNY_DEVICE_7911: 01174 case SKINNY_DEVICE_7905: 01175 (btn++)->buttonDefinition = BT_LINE; 01176 (btn++)->buttonDefinition = BT_HOLD; 01177 break; 01178 case SKINNY_DEVICE_7920: 01179 case SKINNY_DEVICE_7921: 01180 /* XXX I don't know if this is right. */ 01181 for (i = 0; i < 4; i++) 01182 (btn++)->buttonDefinition = BT_CUST_LINESPEEDDIAL; 01183 break; 01184 case SKINNY_DEVICE_7902: 01185 ast_log(LOG_WARNING, "Unsupported device type '%d (7902)' found.\n", d->type); 01186 break; 01187 case SKINNY_DEVICE_SCCPGATEWAY_AN: 01188 case SKINNY_DEVICE_SCCPGATEWAY_BRI: 01189 ast_log(LOG_WARNING, "Unsupported device type '%d (SCCP gateway)' found.\n", d->type); 01190 break; 01191 default: 01192 ast_log(LOG_WARNING, "Unknown device type '%d' found.\n", d->type); 01193 break; 01194 } 01195 01196 for (a = d->addons; a; a = a->next) { 01197 if (!strcasecmp(a->type, "7914")) { 01198 for (i = 0; i < 14; i++) 01199 (btn++)->buttonDefinition = BT_CUST_LINESPEEDDIAL; 01200 } else { 01201 ast_log(LOG_WARNING, "Unknown addon type '%s' found. Skipping.\n", a->type); 01202 } 01203 } 01204 01205 return btn; 01206 }
static int get_input | ( | struct skinnysession * | s | ) | [static] |
Definition at line 4356 of file chan_skinny.c.
References ast_log(), ast_mutex_lock(), ast_mutex_unlock(), ast_verbose(), errno, pollfd::events, skinnysession::fd, pollfd::fd, htolel, skinnysession::inbuf, letohl, skinnysession::lock, LOG_WARNING, poll(), POLLIN, pollfd::revents, and skinny_unregister().
04357 { 04358 int res; 04359 int dlen = 0; 04360 struct pollfd fds[1]; 04361 04362 fds[0].fd = s->fd; 04363 fds[0].events = POLLIN; 04364 fds[0].revents = 0; 04365 res = poll(fds, 1, (keep_alive * 1100)); /* If nothing has happen, client is dead */ 04366 /* we add 10% to the keep_alive to deal */ 04367 /* with network delays, etc */ 04368 if (res < 0) { 04369 if (errno != EINTR) { 04370 ast_log(LOG_WARNING, "Select returned error: %s\n", strerror(errno)); 04371 return res; 04372 } 04373 } else if (res == 0) { 04374 if (skinnydebug) 04375 ast_verbose("Skinny Client was lost, unregistering\n"); 04376 skinny_unregister(NULL, s); 04377 return -1; 04378 } 04379 04380 if (fds[0].revents) { 04381 ast_mutex_lock(&s->lock); 04382 memset(s->inbuf,0,sizeof(s->inbuf)); 04383 res = read(s->fd, s->inbuf, 4); 04384 if (res < 0) { 04385 ast_log(LOG_WARNING, "read() returned error: %s\n", strerror(errno)); 04386 04387 if (skinnydebug) 04388 ast_verbose("Skinny Client was lost, unregistering\n"); 04389 04390 skinny_unregister(NULL,s); 04391 ast_mutex_unlock(&s->lock); 04392 return res; 04393 } else if (res != 4) { 04394 ast_log(LOG_WARNING, "Skinny Client sent less data than expected. Expected 4 but got %d.\n", res); 04395 ast_mutex_unlock(&s->lock); 04396 04397 if (res == 0) { 04398 if (skinnydebug) 04399 ast_verbose("Skinny Client was lost, unregistering\n"); 04400 skinny_unregister(NULL, s); 04401 } 04402 04403 return -1; 04404 } 04405 04406 dlen = letohl(*(int *)s->inbuf); 04407 if (dlen < 4) { 04408 ast_log(LOG_WARNING, "Skinny Client sent invalid data.\n"); 04409 ast_mutex_unlock(&s->lock); 04410 return -1; 04411 } 04412 if (dlen+8 > sizeof(s->inbuf)) { 04413 dlen = sizeof(s->inbuf) - 8; 04414 } 04415 *(int *)s->inbuf = htolel(dlen); 04416 04417 res = read(s->fd, s->inbuf+4, dlen+4); 04418 ast_mutex_unlock(&s->lock); 04419 if (res < 0) { 04420 ast_log(LOG_WARNING, "read() returned error: %s\n", strerror(errno)); 04421 return res; 04422 } else if (res != (dlen+4)) { 04423 ast_log(LOG_WARNING, "Skinny Client sent less data than expected.\n"); 04424 return -1; 04425 } 04426 return res; 04427 } 04428 return 0; 04429 }
static int handle_alarm_message | ( | struct skinny_req * | req, | |
struct skinnysession * | s | |||
) | [static] |
Definition at line 3707 of file chan_skinny.c.
References skinny_data::alarm, ast_verbose(), skinny_req::data, and alarm_message::displayMessage.
Referenced by handle_message().
03708 { 03709 /* no response necessary */ 03710 if (skinnydebug) 03711 ast_verbose("Received Alarm Message: %s\n", req->data.alarm.displayMessage); 03712 03713 return 1; 03714 }
static int handle_button_template_req_message | ( | struct skinny_req * | req, | |
struct skinnysession * | s | |||
) | [static] |
Definition at line 3571 of file chan_skinny.c.
References ast_verbose(), BT_CUST_HINT, BT_CUST_LINESPEEDDIAL, BT_LINE, BT_NONE, BT_SPEEDDIAL, BUTTON_TEMPLATE_RES_MESSAGE, button_template_res_message::buttonCount, button_definition::buttonDefinition, button_definition_template::buttonDefinition, button_template_res_message::buttonOffset, skinny_data::buttontemplate, skinny_req::data, button_template_res_message::definition, skinnysession::device, get_button_template(), htolel, skinny_speeddial::instance, skinny_line::instance, button_definition::instanceNumber, skinny_device::lines, skinny_device::name, skinny_speeddial::next, skinny_line::next, req_alloc(), skinny_device::speeddials, button_template_res_message::totalButtonCount, transmit_response(), and skinny_device::type.
Referenced by handle_message().
03572 { 03573 struct skinny_device *d = s->device; 03574 struct skinny_line *l; 03575 int i; 03576 03577 struct skinny_speeddial *sd; 03578 struct button_definition_template btn[42]; 03579 int lineInstance = 1; 03580 int speeddialInstance = 1; 03581 int buttonCount = 0; 03582 03583 if (!(req = req_alloc(sizeof(struct button_template_res_message), BUTTON_TEMPLATE_RES_MESSAGE))) 03584 return -1; 03585 03586 memset(&btn, 0, sizeof(btn)); 03587 03588 get_button_template(s, btn); 03589 03590 for (i=0; i<42; i++) { 03591 int btnSet = 0; 03592 switch (btn[i].buttonDefinition) { 03593 case BT_CUST_LINESPEEDDIAL: 03594 /* assume failure */ 03595 req->data.buttontemplate.definition[i].buttonDefinition = BT_NONE; 03596 req->data.buttontemplate.definition[i].instanceNumber = htolel(0); 03597 03598 for (l = d->lines; l; l = l->next) { 03599 if (l->instance == lineInstance) { 03600 ast_verbose("Adding button: %d, %d\n", BT_LINE, lineInstance); 03601 req->data.buttontemplate.definition[i].buttonDefinition = BT_LINE; 03602 req->data.buttontemplate.definition[i].instanceNumber = htolel(lineInstance); 03603 lineInstance++; 03604 buttonCount++; 03605 btnSet = 1; 03606 break; 03607 } 03608 } 03609 03610 if (!btnSet) { 03611 for (sd = d->speeddials; sd; sd = sd->next) { 03612 if (sd->instance == speeddialInstance) { 03613 ast_verbose("Adding button: %d, %d\n", BT_SPEEDDIAL, speeddialInstance); 03614 req->data.buttontemplate.definition[i].buttonDefinition = BT_SPEEDDIAL; 03615 req->data.buttontemplate.definition[i].instanceNumber = htolel(speeddialInstance); 03616 speeddialInstance++; 03617 buttonCount++; 03618 btnSet = 1; 03619 break; 03620 } 03621 } 03622 } 03623 break; 03624 case BT_LINE: 03625 req->data.buttontemplate.definition[i].buttonDefinition = htolel(BT_NONE); 03626 req->data.buttontemplate.definition[i].instanceNumber = htolel(0); 03627 03628 for (l = d->lines; l; l = l->next) { 03629 if (l->instance == lineInstance) { 03630 ast_verbose("Adding button: %d, %d\n", BT_LINE, lineInstance); 03631 req->data.buttontemplate.definition[i].buttonDefinition = BT_LINE; 03632 req->data.buttontemplate.definition[i].instanceNumber = htolel(lineInstance); 03633 lineInstance++; 03634 buttonCount++; 03635 btnSet = 1; 03636 break; 03637 } 03638 } 03639 break; 03640 case BT_SPEEDDIAL: 03641 req->data.buttontemplate.definition[i].buttonDefinition = BT_NONE; 03642 req->data.buttontemplate.definition[i].instanceNumber = 0; 03643 03644 for (sd = d->speeddials; sd; sd = sd->next) { 03645 if (sd->instance == speeddialInstance) { 03646 ast_verbose("Adding button: %d, %d\n", BT_SPEEDDIAL, speeddialInstance); 03647 req->data.buttontemplate.definition[i].buttonDefinition = BT_SPEEDDIAL; 03648 req->data.buttontemplate.definition[i].instanceNumber = htolel(speeddialInstance); 03649 speeddialInstance++; 03650 buttonCount++; 03651 btnSet = 1; 03652 break; 03653 } 03654 } 03655 break; 03656 case BT_CUST_HINT: 03657 break; 03658 case BT_NONE: 03659 break; 03660 default: 03661 ast_verbose("Adding button: %d, %d\n", btn[i].buttonDefinition, 0); 03662 req->data.buttontemplate.definition[i].buttonDefinition = htolel(btn[i].buttonDefinition); 03663 req->data.buttontemplate.definition[i].instanceNumber = htolel(0); 03664 buttonCount++; 03665 btnSet = 1; 03666 break; 03667 } 03668 } 03669 03670 req->data.buttontemplate.buttonOffset = htolel(0); 03671 req->data.buttontemplate.buttonCount = htolel(buttonCount); 03672 req->data.buttontemplate.totalButtonCount = htolel(buttonCount); 03673 03674 if (skinnydebug) 03675 ast_verbose("Sending %d template to %s\n", 03676 d->type, 03677 d->name); 03678 transmit_response(s, req); 03679 return 1; 03680 }
static int handle_capabilities_res_message | ( | struct skinny_req * | req, | |
struct skinnysession * | s | |||
) | [static] |
Definition at line 3458 of file chan_skinny.c.
References ast_log(), ast_mutex_lock(), ast_mutex_unlock(), ast_verbose(), skinny_line::capability, skinny_device::capability, capabilities_res_message::caps, skinny_data::caps, station_capabilities::codec, codec_skinny2ast(), capabilities_res_message::count, skinny_req::data, skinnysession::device, letohl, skinny_device::lines, skinny_line::lock, LOG_WARNING, skinny_line::next, and SKINNY_MAX_CAPABILITIES.
Referenced by handle_message().
03459 { 03460 struct skinny_device *d = s->device; 03461 struct skinny_line *l; 03462 uint32_t count = 0; 03463 int codecs = 0; 03464 int i; 03465 03466 count = letohl(req->data.caps.count); 03467 if (count > SKINNY_MAX_CAPABILITIES) { 03468 count = SKINNY_MAX_CAPABILITIES; 03469 ast_log(LOG_WARNING, "Received more capabilities than we can handle (%d). Ignoring the rest.\n", SKINNY_MAX_CAPABILITIES); 03470 } 03471 03472 for (i = 0; i < count; i++) { 03473 int acodec = 0; 03474 int scodec = 0; 03475 scodec = letohl(req->data.caps.caps[i].codec); 03476 acodec = codec_skinny2ast(scodec); 03477 if (skinnydebug) 03478 ast_verbose("Adding codec capability '%d (%d)'\n", acodec, scodec); 03479 codecs |= acodec; 03480 } 03481 03482 d->capability &= codecs; 03483 ast_verbose("Device capability set to '%d'\n", d->capability); 03484 for (l = d->lines; l; l = l->next) { 03485 ast_mutex_lock(&l->lock); 03486 l->capability = d->capability; 03487 ast_mutex_unlock(&l->lock); 03488 } 03489 03490 return 1; 03491 }
static int handle_enbloc_call_message | ( | struct skinny_req * | req, | |
struct skinnysession * | s | |||
) | [static] |
Definition at line 3785 of file chan_skinny.c.
References ast_hangup(), ast_ignore_pattern(), ast_log(), ast_pthread_create, AST_STATE_DOWN, ast_verbose(), enbloc_call_message::calledParty, skinny_subchannel::callid, ast_channel::context, skinny_req::data, skinnysession::device, skinny_data::enbloccallmessage, errno, ast_channel::exten, find_line_by_instance(), find_subchannel_by_instance_reference(), skinny_line::hookstate, skinny_line::instance, skinny_device::lastcallreference, skinny_device::lastlineinstance, LOG_WARNING, skinny_device::name, skinny_line::name, skinny_subchannel::parent, SKINNY_DIALTONE, skinny_new(), skinny_newcall(), SKINNY_OFFHOOK, SKINNY_SILENCE, t, ast_channel::tech_pvt, transmit_callstate(), transmit_displaymessage(), and transmit_tone().
Referenced by handle_message().
03786 { 03787 struct skinny_device *d = s->device; 03788 struct skinny_line *l; 03789 struct skinny_subchannel *sub = NULL; 03790 struct ast_channel *c; 03791 pthread_t t; 03792 03793 if (skinnydebug) 03794 ast_verbose("Received Enbloc Call: %s\n", req->data.enbloccallmessage.calledParty); 03795 03796 sub = find_subchannel_by_instance_reference(d, d->lastlineinstance, d->lastcallreference); 03797 03798 if (!sub) { 03799 l = find_line_by_instance(d, d->lastlineinstance); 03800 if (!l) { 03801 return 0; 03802 } 03803 } else { 03804 l = sub->parent; 03805 } 03806 03807 c = skinny_new(l, AST_STATE_DOWN); 03808 03809 if(!c) { 03810 ast_log(LOG_WARNING, "Unable to create channel for %s@%s\n", l->name, d->name); 03811 } else { 03812 l->hookstate = SKINNY_OFFHOOK; 03813 03814 sub = c->tech_pvt; 03815 transmit_callstate(s, l->instance, SKINNY_OFFHOOK, sub->callid); 03816 if (skinnydebug) 03817 ast_verbose("Attempting to Clear display on Skinny %s@%s\n", l->name, d->name); 03818 transmit_displaymessage(s, NULL, l->instance, sub->callid); /* clear display */ 03819 transmit_tone(s, SKINNY_DIALTONE, l->instance, sub->callid); 03820 03821 if (!ast_ignore_pattern(c->context, req->data.enbloccallmessage.calledParty)) { 03822 transmit_tone(s, SKINNY_SILENCE, l->instance, sub->callid); 03823 } 03824 ast_copy_string(c->exten, req->data.enbloccallmessage.calledParty, sizeof(c->exten)); 03825 if (ast_pthread_create(&t, NULL, skinny_newcall, c)) { 03826 ast_log(LOG_WARNING, "Unable to create new call thread: %s\n", strerror(errno)); 03827 ast_hangup(c); 03828 } 03829 } 03830 03831 return 1; 03832 }
static int handle_headset_status_message | ( | struct skinny_req * | req, | |
struct skinnysession * | s | |||
) | [static] |
static int handle_ip_port_message | ( | struct skinny_req * | req, | |
struct skinnysession * | s | |||
) | [static] |
static int handle_keep_alive_message | ( | struct skinny_req * | req, | |
struct skinnysession * | s | |||
) | [static] |
Definition at line 2958 of file chan_skinny.c.
References do_housekeeping(), KEEP_ALIVE_ACK_MESSAGE, req_alloc(), and transmit_response().
Referenced by handle_message().
02959 { 02960 if (!(req = req_alloc(0, KEEP_ALIVE_ACK_MESSAGE))) 02961 return -1; 02962 02963 transmit_response(s, req); 02964 do_housekeeping(s); 02965 return 1; 02966 }
static int handle_keypad_button_message | ( | struct skinny_req * | req, | |
struct skinnysession * | s | |||
) | [static] |
Definition at line 3016 of file chan_skinny.c.
References ast_channel::_state, AST_FRAME_DTMF_BEGIN, AST_FRAME_DTMF_END, ast_log(), ast_queue_frame(), ast_verbose(), keypad_button_message::button, keypad_button_message::callReference, skinny_req::data, skinnysession::device, find_subchannel_by_instance_reference(), ast_frame::frametype, skinny_data::keypad, skinny_device::lastcallreference, skinny_device::lastlineinstance, letohl, keypad_button_message::lineInstance, LOG_WARNING, skinny_line::name, skinny_subchannel::next, skinny_subchannel::owner, skinny_subchannel::parent, ast_frame::src, and ast_frame::subclass.
Referenced by handle_message().
03017 { 03018 struct skinny_subchannel *sub = NULL; 03019 struct skinny_line *l; 03020 struct skinny_device *d = s->device; 03021 struct ast_frame f = { 0, }; 03022 char dgt; 03023 int digit; 03024 int lineInstance; 03025 int callReference; 03026 03027 digit = letohl(req->data.keypad.button); 03028 lineInstance = letohl(req->data.keypad.lineInstance); 03029 callReference = letohl(req->data.keypad.callReference); 03030 03031 if (digit == 14) { 03032 dgt = '*'; 03033 } else if (digit == 15) { 03034 dgt = '#'; 03035 } else if (digit >= 0 && digit <= 9) { 03036 dgt = '0' + digit; 03037 } else { 03038 /* digit=10-13 (A,B,C,D ?), or 03039 * digit is bad value 03040 * 03041 * probably should not end up here, but set 03042 * value for backward compatibility, and log 03043 * a warning. 03044 */ 03045 dgt = '0' + digit; 03046 ast_log(LOG_WARNING, "Unsupported digit %d\n", digit); 03047 } 03048 03049 f.subclass = dgt; 03050 03051 f.src = "skinny"; 03052 03053 if (lineInstance && callReference) 03054 sub = find_subchannel_by_instance_reference(d, lineInstance, callReference); 03055 else 03056 sub = find_subchannel_by_instance_reference(d, d->lastlineinstance, d->lastcallreference); 03057 03058 if (!sub) 03059 return 0; 03060 03061 l = sub->parent; 03062 if (sub->owner) { 03063 if (sub->owner->_state == 0) { 03064 f.frametype = AST_FRAME_DTMF_BEGIN; 03065 ast_queue_frame(sub->owner, &f); 03066 } 03067 /* XXX MUST queue this frame to all lines in threeway call if threeway call is active */ 03068 f.frametype = AST_FRAME_DTMF_END; 03069 ast_queue_frame(sub->owner, &f); 03070 /* XXX This seriously needs to be fixed */ 03071 if (sub->next && sub->next->owner) { 03072 if (sub->owner->_state == 0) { 03073 f.frametype = AST_FRAME_DTMF_BEGIN; 03074 ast_queue_frame(sub->next->owner, &f); 03075 } 03076 f.frametype = AST_FRAME_DTMF_END; 03077 ast_queue_frame(sub->next->owner, &f); 03078 } 03079 } else { 03080 if (skinnydebug) 03081 ast_verbose("No owner: %s\n", l->name); 03082 } 03083 return 1; 03084 }
static int handle_line_state_req_message | ( | struct skinny_req * | req, | |
struct skinnysession * | s | |||
) | [static] |
Definition at line 3518 of file chan_skinny.c.
References ast_mutex_lock(), ast_mutex_unlock(), skinny_req::data, skinnysession::device, find_line_by_instance(), skinny_line::instance, skinny_line::label, letohl, skinny_data::line, LINE_STAT_RES_MESSAGE, line_stat_res_message::lineDirNumber, line_stat_res_message::lineDisplayName, line_stat_res_message::lineNumber, line_state_req_message::lineNumber, skinny_data::linestat, skinny_line::name, req_alloc(), and transmit_response().
Referenced by handle_message().
03519 { 03520 struct skinny_device *d = s->device; 03521 struct skinny_line *l; 03522 int instance; 03523 03524 instance = letohl(req->data.line.lineNumber); 03525 03526 ast_mutex_lock(&devicelock); 03527 03528 l = find_line_by_instance(d, instance); 03529 03530 if (!l) { 03531 return 0; 03532 } 03533 03534 ast_mutex_unlock(&devicelock); 03535 03536 if (!(req = req_alloc(sizeof(struct line_stat_res_message), LINE_STAT_RES_MESSAGE))) 03537 return -1; 03538 03539 req->data.linestat.lineNumber = letohl(instance); 03540 memcpy(req->data.linestat.lineDirNumber, l->name, 03541 sizeof(req->data.linestat.lineDirNumber)); 03542 memcpy(req->data.linestat.lineDisplayName, l->label, 03543 sizeof(req->data.linestat.lineDisplayName)); 03544 transmit_response(s,req); 03545 return 1; 03546 }
static int handle_message | ( | struct skinny_req * | req, | |
struct skinnysession * | s | |||
) | [static] |
Definition at line 4159 of file chan_skinny.c.
References ast_channel::_state, ALARM_MESSAGE, ast_log(), AST_STATE_UP, ast_verbose(), keypad_button_message::button, BUTTON_TEMPLATE_REQ_MESSAGE, keypad_button_message::callReference, CAPABILITIES_RES_MESSAGE, skinny_req::data, skinnysession::device, skinny_req::e, ENBLOC_CALL_MESSAGE, skinny_device::exten, find_subchannel_by_instance_reference(), free, handle_alarm_message(), handle_button_template_req_message(), handle_capabilities_res_message(), handle_enbloc_call_message(), handle_headset_status_message(), handle_ip_port_message(), handle_keep_alive_message(), handle_keypad_button_message(), handle_line_state_req_message(), handle_offhook_message(), handle_onhook_message(), handle_open_receive_channel_ack_message(), handle_register_available_lines_message(), handle_register_message(), handle_server_request_message(), handle_soft_key_event_message(), handle_soft_key_set_req_message(), handle_soft_key_template_req_message(), handle_speed_dial_stat_req_message(), handle_stimulus_message(), handle_time_date_req_message(), handle_unregister_message(), handle_version_req_message(), HEADSET_STATUS_MESSAGE, IP_PORT_MESSAGE, KEEP_ALIVE_MESSAGE, skinny_data::keypad, KEYPAD_BUTTON_MESSAGE, len, letohl, LINE_STATE_REQ_MESSAGE, keypad_button_message::lineInstance, LOG_WARNING, register_message::name, OFFHOOK_MESSAGE, ONHOOK_MESSAGE, OPEN_RECEIVE_CHANNEL_ACK_MESSAGE, skinny_subchannel::owner, skinny_data::reg, REGISTER_AVAILABLE_LINES_MESSAGE, REGISTER_MESSAGE, SERVER_REQUEST_MESSAGE, SOFT_KEY_EVENT_MESSAGE, SOFT_KEY_SET_REQ_MESSAGE, SOFT_KEY_TEMPLATE_REQ_MESSAGE, SPEED_DIAL_STAT_REQ_MESSAGE, STIMULUS_MESSAGE, TIME_DATE_REQ_MESSAGE, UNREGISTER_MESSAGE, and VERSION_REQ_MESSAGE.
Referenced by skinny_session().
04160 { 04161 int res = 0; 04162 struct skinny_device *d = s->device; 04163 struct skinny_subchannel *sub; 04164 int lineInstance; 04165 int callReference; 04166 04167 if ((!s->device) && (letohl(req->e) != REGISTER_MESSAGE && letohl(req->e) != ALARM_MESSAGE)) { 04168 ast_log(LOG_WARNING, "Client sent message #%d without first registering.\n", req->e); 04169 free(req); 04170 return 0; 04171 } 04172 04173 switch(letohl(req->e)) { 04174 case KEEP_ALIVE_MESSAGE: 04175 res = handle_keep_alive_message(req, s); 04176 break; 04177 case REGISTER_MESSAGE: 04178 if (skinnydebug) 04179 ast_verbose("Device %s is attempting to register\n", req->data.reg.name); 04180 04181 res = handle_register_message(req, s); 04182 break; 04183 case IP_PORT_MESSAGE: 04184 res = handle_ip_port_message(req, s); 04185 break; 04186 case KEYPAD_BUTTON_MESSAGE: 04187 if (skinnydebug) 04188 ast_verbose("Collected digit: [%d]\n", letohl(req->data.keypad.button)); 04189 04190 lineInstance = letohl(req->data.keypad.lineInstance); 04191 callReference = letohl(req->data.keypad.callReference); 04192 04193 sub = find_subchannel_by_instance_reference(d, lineInstance, callReference); 04194 04195 if (sub && (sub->owner && sub->owner->_state < AST_STATE_UP)) { 04196 char dgt; 04197 int digit = letohl(req->data.keypad.button); 04198 size_t len; 04199 04200 if (digit == 14) { 04201 dgt = '*'; 04202 } else if (digit == 15) { 04203 dgt = '#'; 04204 } else if (digit >= 0 && digit <= 9) { 04205 dgt = '0' + digit; 04206 } else { 04207 /* digit=10-13 (A,B,C,D ?), or 04208 * digit is bad value 04209 * 04210 * probably should not end up here, but set 04211 * value for backward compatibility, and log 04212 * a warning. 04213 */ 04214 dgt = '0' + digit; 04215 ast_log(LOG_WARNING, "Unsupported digit %d\n", digit); 04216 } 04217 04218 len = strlen(d->exten); 04219 if (len < sizeof(d->exten) - 1) { 04220 d->exten[len] = dgt; 04221 d->exten[len+1] = '\0'; 04222 } else { 04223 ast_log(LOG_WARNING, "Dropping digit with value %d because digit queue is full\n", dgt); 04224 } 04225 } else 04226 res = handle_keypad_button_message(req, s); 04227 break; 04228 case ENBLOC_CALL_MESSAGE: 04229 res = handle_enbloc_call_message(req, s); 04230 break; 04231 case STIMULUS_MESSAGE: 04232 res = handle_stimulus_message(req, s); 04233 break; 04234 case OFFHOOK_MESSAGE: 04235 res = handle_offhook_message(req, s); 04236 break; 04237 case ONHOOK_MESSAGE: 04238 res = handle_onhook_message(req, s); 04239 break; 04240 case CAPABILITIES_RES_MESSAGE: 04241 if (skinnydebug) 04242 ast_verbose("Received CapabilitiesRes\n"); 04243 04244 res = handle_capabilities_res_message(req, s); 04245 break; 04246 case SPEED_DIAL_STAT_REQ_MESSAGE: 04247 if (skinnydebug) 04248 ast_verbose("Received SpeedDialStatRequest\n"); 04249 04250 res = handle_speed_dial_stat_req_message(req, s); 04251 break; 04252 case LINE_STATE_REQ_MESSAGE: 04253 if (skinnydebug) 04254 ast_verbose("Received LineStatRequest\n"); 04255 res = handle_line_state_req_message(req, s); 04256 break; 04257 case TIME_DATE_REQ_MESSAGE: 04258 if (skinnydebug) 04259 ast_verbose("Received Time/Date Request\n"); 04260 04261 res = handle_time_date_req_message(req, s); 04262 break; 04263 case BUTTON_TEMPLATE_REQ_MESSAGE: 04264 if (skinnydebug) 04265 ast_verbose("Buttontemplate requested\n"); 04266 04267 res = handle_button_template_req_message(req, s); 04268 break; 04269 case VERSION_REQ_MESSAGE: 04270 if (skinnydebug) 04271 ast_verbose("Version Request\n"); 04272 04273 res = handle_version_req_message(req, s); 04274 break; 04275 case SERVER_REQUEST_MESSAGE: 04276 if (skinnydebug) 04277 ast_verbose("Received Server Request\n"); 04278 04279 res = handle_server_request_message(req, s); 04280 break; 04281 case ALARM_MESSAGE: 04282 res = handle_alarm_message(req, s); 04283 break; 04284 case OPEN_RECEIVE_CHANNEL_ACK_MESSAGE: 04285 if (skinnydebug) 04286 ast_verbose("Received Open Receive Channel Ack\n"); 04287 04288 res = handle_open_receive_channel_ack_message(req, s); 04289 break; 04290 case SOFT_KEY_SET_REQ_MESSAGE: 04291 if (skinnydebug) 04292 ast_verbose("Received SoftKeySetReq\n"); 04293 04294 res = handle_soft_key_set_req_message(req, s); 04295 break; 04296 case SOFT_KEY_EVENT_MESSAGE: 04297 res = handle_soft_key_event_message(req, s); 04298 break; 04299 case UNREGISTER_MESSAGE: 04300 if (skinnydebug) 04301 ast_verbose("Received Unregister Request\n"); 04302 04303 res = handle_unregister_message(req, s); 04304 break; 04305 case SOFT_KEY_TEMPLATE_REQ_MESSAGE: 04306 if (skinnydebug) 04307 ast_verbose("Received SoftKey Template Request\n"); 04308 04309 res = handle_soft_key_template_req_message(req, s); 04310 break; 04311 case HEADSET_STATUS_MESSAGE: 04312 res = handle_headset_status_message(req, s); 04313 break; 04314 case REGISTER_AVAILABLE_LINES_MESSAGE: 04315 res = handle_register_available_lines_message(req, s); 04316 break; 04317 default: 04318 if (skinnydebug) 04319 ast_verbose("RECEIVED UNKNOWN MESSAGE TYPE: %x\n", letohl(req->e)); 04320 break; 04321 } 04322 if (res >= 0 && req) 04323 free(req); 04324 return res; 04325 }
static int handle_offhook_message | ( | struct skinny_req * | req, | |
struct skinnysession * | s | |||
) | [static] |
Definition at line 3325 of file chan_skinny.c.
References AST_CONTROL_ANSWER, ast_hangup(), ast_log(), ast_pthread_create, ast_queue_control(), ast_setstate(), AST_STATE_DOWN, AST_STATE_UP, ast_verbose(), skinny_subchannel::callid, skinny_req::data, skinnysession::device, errno, find_line_by_instance(), find_subchannel_by_instance_reference(), skinny_line::hookstate, skinny_line::instance, KEYDEF_CONNECTED, KEYDEF_OFFHOOK, skinny_device::lastcallreference, skinny_device::lastlineinstance, letohl, LOG_DEBUG, LOG_WARNING, skinny_device::name, skinny_line::name, skinny_data::offhook, skinny_subchannel::onhold, skinny_subchannel::outgoing, skinny_subchannel::owner, skinny_subchannel::parent, SKINNY_CONNECTED, SKINNY_DIALTONE, SKINNY_LAMP_ON, skinny_new(), SKINNY_OFFHOOK, SKINNY_RING_OFF, SKINNY_SILENCE, skinny_ss(), start_rtp(), STIMULUS_LINE, t, ast_channel::tech_pvt, transmit_callstate(), transmit_displaymessage(), transmit_lamp_indication(), transmit_ringer_mode(), transmit_selectsoftkeys(), transmit_tone(), offhook_message::unknown1, and offhook_message::unknown2.
Referenced by handle_message().
03326 { 03327 struct skinny_device *d = s->device; 03328 struct skinny_line *l; 03329 struct skinny_subchannel *sub; 03330 struct ast_channel *c; 03331 pthread_t t; 03332 int unknown1; 03333 int unknown2; 03334 03335 unknown1 = letohl(req->data.offhook.unknown1); 03336 unknown2 = letohl(req->data.offhook.unknown2); 03337 03338 sub = find_subchannel_by_instance_reference(d, d->lastlineinstance, d->lastcallreference); 03339 03340 if (!sub) { 03341 l = find_line_by_instance(d, d->lastlineinstance); 03342 if (!l) { 03343 return 0; 03344 } 03345 } else { 03346 l = sub->parent; 03347 } 03348 03349 transmit_ringer_mode(s, SKINNY_RING_OFF); 03350 l->hookstate = SKINNY_OFFHOOK; 03351 03352 if (sub && sub->onhold) { 03353 return 1; 03354 } 03355 03356 transmit_lamp_indication(s, STIMULUS_LINE, l->instance, SKINNY_LAMP_ON); 03357 03358 if (sub && sub->outgoing) { 03359 /* We're answering a ringing call */ 03360 ast_queue_control(sub->owner, AST_CONTROL_ANSWER); 03361 transmit_callstate(s, l->instance, SKINNY_OFFHOOK, sub->callid); 03362 transmit_tone(s, SKINNY_SILENCE, l->instance, sub->callid); 03363 transmit_callstate(s, l->instance, SKINNY_CONNECTED, sub->callid); 03364 transmit_selectsoftkeys(s, l->instance, sub->callid, KEYDEF_CONNECTED); 03365 start_rtp(sub); 03366 ast_setstate(sub->owner, AST_STATE_UP); 03367 } else { 03368 if (sub && sub->owner) { 03369 ast_log(LOG_DEBUG, "Current sub [%s] already has owner\n", sub->owner->name); 03370 } else { 03371 c = skinny_new(l, AST_STATE_DOWN); 03372 if(c) { 03373 sub = c->tech_pvt; 03374 transmit_callstate(s, l->instance, SKINNY_OFFHOOK, sub->callid); 03375 if (skinnydebug) 03376 ast_verbose("Attempting to Clear display on Skinny %s@%s\n", l->name, d->name); 03377 transmit_displaymessage(s, NULL, l->instance, sub->callid); /* clear display */ 03378 transmit_tone(s, SKINNY_DIALTONE, l->instance, sub->callid); 03379 transmit_selectsoftkeys(s, l->instance, sub->callid, KEYDEF_OFFHOOK); 03380 03381 /* start the switch thread */ 03382 if (ast_pthread_create(&t, NULL, skinny_ss, c)) { 03383 ast_log(LOG_WARNING, "Unable to create switch thread: %s\n", strerror(errno)); 03384 ast_hangup(c); 03385 } 03386 } else { 03387 ast_log(LOG_WARNING, "Unable to create channel for %s@%s\n", l->name, d->name); 03388 } 03389 } 03390 } 03391 return 1; 03392 }
static int handle_onhook_message | ( | struct skinny_req * | req, | |
struct skinnysession * | s | |||
) | [static] |
Definition at line 3394 of file chan_skinny.c.
References skinny_subchannel::alreadygone, ast_log(), ast_queue_hangup(), ast_verbose(), attempt_transfer(), skinny_subchannel::callid, skinny_subchannel::cxmode, skinny_req::data, skinnysession::device, do_housekeeping(), find_subchannel_by_instance_reference(), skinny_line::hookstate, skinny_line::instance, skinny_device::lastcallreference, skinny_device::lastlineinstance, letohl, LOG_WARNING, skinny_device::name, skinny_line::name, skinny_subchannel::next, skinny_subchannel::onhold, skinny_data::onhook, skinny_subchannel::outgoing, skinny_subchannel::owner, skinny_subchannel::parent, skinny_subchannel::rtp, SKINNY_CX_RECVONLY, SKINNY_ONHOOK, skinny_line::transfer, transmit_callstate(), onhook_message::unknown1, and onhook_message::unknown2.
Referenced by handle_message().
03395 { 03396 struct skinny_device *d = s->device; 03397 struct skinny_line *l; 03398 struct skinny_subchannel *sub; 03399 int unknown1; 03400 int unknown2; 03401 03402 unknown1 = letohl(req->data.onhook.unknown1); 03403 unknown2 = letohl(req->data.onhook.unknown2); 03404 03405 sub = find_subchannel_by_instance_reference(d, d->lastlineinstance, d->lastcallreference); 03406 03407 if (!sub) { 03408 return 0; 03409 } 03410 l = sub->parent; 03411 03412 if (l->hookstate == SKINNY_ONHOOK) { 03413 /* Something else already put us back on hook */ 03414 return 0; 03415 } 03416 l->hookstate = SKINNY_ONHOOK; 03417 03418 if (sub->onhold) { 03419 return 0; 03420 } 03421 03422 sub->cxmode = SKINNY_CX_RECVONLY; 03423 transmit_callstate(s, l->instance, l->hookstate, sub->callid); 03424 if (skinnydebug) 03425 ast_verbose("Skinny %s@%s went on hook\n", l->name, d->name); 03426 if (l->transfer && (sub->owner && sub->next && sub->next->owner) && ((!sub->outgoing) || (sub->next && !sub->next->outgoing))) { 03427 /* We're allowed to transfer, we have two active calls and 03428 we made at least one of the calls. Let's try and transfer */ 03429 03430 #if 0 03431 if ((res = attempt_transfer(p)) < 0) { 03432 if (sub->next && sub->next->owner) { 03433 sub->next->alreadygone = 1; 03434 ast_queue_hangup(sub->next->owner,1); 03435 } 03436 } else if (res) { 03437 ast_log(LOG_WARNING, "Transfer attempt failed\n"); 03438 return 0; 03439 } 03440 #endif 03441 } else { 03442 /* Hangup the current call */ 03443 /* If there is another active call, skinny_hangup will ring the phone with the other call */ 03444 if (sub->owner) { 03445 sub->alreadygone = 1; 03446 ast_queue_hangup(sub->owner); 03447 } else { 03448 ast_log(LOG_WARNING, "Skinny(%s@%s-%d) channel already destroyed\n", 03449 l->name, d->name, sub->callid); 03450 } 03451 } 03452 if ((l->hookstate == SKINNY_ONHOOK) && (sub->next && !sub->next->rtp)) { 03453 do_housekeeping(s); 03454 } 03455 return 1; 03456 }
static int handle_open_receive_channel_ack_message | ( | struct skinny_req * | req, | |
struct skinnysession * | s | |||
) | [static] |
Definition at line 3716 of file chan_skinny.c.
References ast_best_codec(), ast_codec_pref_getsize(), ast_inet_ntoa(), ast_log(), ast_rtp_get_us(), ast_rtp_set_peer(), ast_verbose(), media_qualifier::bitRate, ast_format_list::bits, skinny_subchannel::callid, skinny_line::capability, codec_ast2skinny(), start_media_transmission_message::conferenceId, ast_format_list::cur_ms, skinny_req::data, skinnysession::device, find_subchannel_by_reference(), htolel, open_receive_channel_ack_message::ipAddr, letohl, LOG_ERROR, skinny_data::openreceivechannelack, skinny_device::ourip, media_qualifier::packets, start_media_transmission_message::packetSize, skinny_subchannel::parent, open_receive_channel_ack_message::passThruId, start_media_transmission_message::passThruPartyId, start_media_transmission_message::payloadType, open_receive_channel_ack_message::port, media_qualifier::precedence, skinny_line::prefs, start_media_transmission_message::qualifier, start_media_transmission_message::remoteIp, start_media_transmission_message::remotePort, req_alloc(), skinny_subchannel::rtp, START_MEDIA_TRANSMISSION_MESSAGE, skinny_data::startmedia, open_receive_channel_ack_message::status, transmit_response(), and media_qualifier::vad.
Referenced by handle_message().
03717 { 03718 struct skinny_device *d = s->device; 03719 struct skinny_line *l; 03720 struct skinny_subchannel *sub; 03721 struct ast_format_list fmt; 03722 struct sockaddr_in sin; 03723 struct sockaddr_in us; 03724 uint32_t addr; 03725 int port; 03726 int status; 03727 int passthruid; 03728 03729 status = letohl(req->data.openreceivechannelack.status); 03730 if (status) { 03731 ast_log(LOG_ERROR, "Open Receive Channel Failure\n"); 03732 return 0; 03733 } 03734 addr = letohl(req->data.openreceivechannelack.ipAddr); 03735 port = letohl(req->data.openreceivechannelack.port); 03736 passthruid = letohl(req->data.openreceivechannelack.passThruId); 03737 03738 sin.sin_family = AF_INET; 03739 sin.sin_addr.s_addr = addr; 03740 sin.sin_port = htons(port); 03741 03742 sub = find_subchannel_by_reference(d, passthruid); 03743 03744 if (!sub) 03745 return 0; 03746 03747 l = sub->parent; 03748 03749 if (sub->rtp) { 03750 ast_rtp_set_peer(sub->rtp, &sin); 03751 ast_rtp_get_us(sub->rtp, &us); 03752 } else { 03753 ast_log(LOG_ERROR, "No RTP structure, this is very bad\n"); 03754 return 0; 03755 } 03756 03757 if (skinnydebug) { 03758 ast_verbose("ipaddr = %s:%d\n", ast_inet_ntoa(sin.sin_addr), ntohs(sin.sin_port)); 03759 ast_verbose("ourip = %s:%d\n", ast_inet_ntoa(d->ourip), ntohs(us.sin_port)); 03760 } 03761 03762 if (!(req = req_alloc(sizeof(struct start_media_transmission_message), START_MEDIA_TRANSMISSION_MESSAGE))) 03763 return -1; 03764 03765 fmt = ast_codec_pref_getsize(&l->prefs, ast_best_codec(l->capability)); 03766 03767 if (skinnydebug) 03768 ast_verbose("Setting payloadType to '%d' (%d ms)\n", fmt.bits, fmt.cur_ms); 03769 03770 req->data.startmedia.conferenceId = htolel(sub->callid); 03771 req->data.startmedia.passThruPartyId = htolel(sub->callid); 03772 req->data.startmedia.remoteIp = htolel(d->ourip.s_addr); 03773 req->data.startmedia.remotePort = htolel(ntohs(us.sin_port)); 03774 req->data.startmedia.packetSize = htolel(fmt.cur_ms); 03775 req->data.startmedia.payloadType = htolel(codec_ast2skinny(fmt.bits)); 03776 req->data.startmedia.qualifier.precedence = htolel(127); 03777 req->data.startmedia.qualifier.vad = htolel(0); 03778 req->data.startmedia.qualifier.packets = htolel(0); 03779 req->data.startmedia.qualifier.bitRate = htolel(0); 03780 transmit_response(s, req); 03781 03782 return 1; 03783 }
static int handle_register_available_lines_message | ( | struct skinny_req * | req, | |
struct skinnysession * | s | |||
) | [static] |
Definition at line 4153 of file chan_skinny.c.
Referenced by handle_message().
04154 { 04155 /* XXX I have no clue what this is for, but my phone was sending it, so... */ 04156 return 1; 04157 }
static int handle_register_message | ( | struct skinny_req * | req, | |
struct skinnysession * | s | |||
) | [static] |
Definition at line 2968 of file chan_skinny.c.
References ast_log(), ast_verbose(), CAPABILITIES_REQ_MESSAGE, skinny_req::data, register_ack_message::dateTemplate, register_rej_message::errMsg, htolel, register_ack_message::keepAlive, LOG_ERROR, register_message::name, name, option_verbose, skinny_data::reg, skinny_data::regack, REGISTER_ACK_MESSAGE, REGISTER_REJ_MESSAGE, skinny_data::regrej, req_alloc(), register_ack_message::res, skinny_req::res, register_ack_message::res2, register_ack_message::secondaryKeepAlive, skinny_register(), transmit_response(), and VERBOSE_PREFIX_3.
Referenced by handle_message().
02969 { 02970 char name[16]; 02971 int res; 02972 02973 memcpy(&name, req->data.reg.name, sizeof(name)); 02974 02975 res = skinny_register(req, s); 02976 if (!res) { 02977 ast_log(LOG_ERROR, "Rejecting Device %s: Device not found\n", name); 02978 if (!(req = req_alloc(sizeof(struct register_rej_message), REGISTER_REJ_MESSAGE))) 02979 return -1; 02980 02981 snprintf(req->data.regrej.errMsg, sizeof(req->data.regrej.errMsg), "No Authority: %s", name); 02982 transmit_response(s, req); 02983 return 0; 02984 } 02985 if (option_verbose > 2) 02986 ast_verbose(VERBOSE_PREFIX_3 "Device '%s' successfully registered\n", name); 02987 02988 if (!(req = req_alloc(sizeof(struct register_ack_message), REGISTER_ACK_MESSAGE))) 02989 return -1; 02990 02991 req->data.regack.res[0] = '0'; 02992 req->data.regack.res[1] = '\0'; 02993 req->data.regack.keepAlive = htolel(keep_alive); 02994 memcpy(req->data.regack.dateTemplate, date_format, sizeof(req->data.regack.dateTemplate)); 02995 req->data.regack.res2[0] = '0'; 02996 req->data.regack.res2[1] = '\0'; 02997 req->data.regack.secondaryKeepAlive = htolel(keep_alive); 02998 transmit_response(s, req); 02999 if (skinnydebug) 03000 ast_verbose("Requesting capabilities\n"); 03001 03002 if (!(req = req_alloc(0, CAPABILITIES_REQ_MESSAGE))) 03003 return -1; 03004 03005 transmit_response(s, req); 03006 03007 return res; 03008 }
static int handle_server_request_message | ( | struct skinny_req * | req, | |
struct skinnysession * | s | |||
) | [static] |
Definition at line 3693 of file chan_skinny.c.
References skinny_req::data, skinnysession::device, htolel, skinny_device::ourip, req_alloc(), server_res_message::server, SERVER_RES_MESSAGE, server_res_message::serverIpAddr, server_res_message::serverListenPort, server_identifier::serverName, skinny_data::serverres, and transmit_response().
Referenced by handle_message().
03694 { 03695 struct skinny_device *d = s->device; 03696 if (!(req = req_alloc(sizeof(struct server_res_message), SERVER_RES_MESSAGE))) 03697 return -1; 03698 03699 memcpy(req->data.serverres.server[0].serverName, ourhost, 03700 sizeof(req->data.serverres.server[0].serverName)); 03701 req->data.serverres.serverListenPort[0] = htolel(ourport); 03702 req->data.serverres.serverIpAddr[0] = htolel(d->ourip.s_addr); 03703 transmit_response(s, req); 03704 return 1; 03705 }
static int handle_soft_key_event_message | ( | struct skinny_req * | req, | |
struct skinnysession * | s | |||
) | [static] |
Definition at line 3867 of file chan_skinny.c.
References skinny_subchannel::alreadygone, AST_CONTROL_ANSWER, ast_hangup(), ast_ignore_pattern(), ast_log(), ast_pthread_create, ast_queue_control(), ast_queue_hangup(), ast_setstate(), AST_STATE_DOWN, AST_STATE_UP, ast_verbose(), attempt_transfer(), skinny_subchannel::callid, soft_key_event_message::callreference, ast_channel::context, skinny_subchannel::cxmode, skinny_req::data, skinnysession::device, skinny_line::dnd, do_housekeeping(), errno, event, ast_channel::exten, find_line_by_instance(), find_subchannel_by_instance_reference(), skinny_line::hookstate, skinny_line::instance, soft_key_event_message::instance, KEYDEF_CONNECTED, KEYDEF_OFFHOOK, KEYDEF_RINGOUT, skinny_device::lastcallreference, skinny_device::lastlineinstance, skinny_line::lastnumberdialed, letohl, LOG_WARNING, skinny_device::name, skinny_line::name, skinny_subchannel::next, skinny_subchannel::onhold, option_verbose, skinny_subchannel::outgoing, skinny_subchannel::owner, skinny_subchannel::rtp, SKINNY_CONNECTED, SKINNY_CX_RECVONLY, SKINNY_DIALTONE, skinny_hold(), SKINNY_LAMP_OFF, SKINNY_LAMP_ON, skinny_new(), skinny_newcall(), SKINNY_OFFHOOK, SKINNY_ONHOOK, SKINNY_RING_OFF, SKINNY_SILENCE, SKINNY_SPEAKERON, skinny_ss(), skinny_unhold(), SOFTKEY_ANSWER, SOFTKEY_BKSPC, SOFTKEY_CFWDALL, SOFTKEY_CFWDBUSY, SOFTKEY_CFWDNOANSWER, SOFTKEY_CONFRN, SOFTKEY_ENDCALL, SOFTKEY_GPICKUP, SOFTKEY_HOLD, SOFTKEY_INFO, SOFTKEY_JOIN, SOFTKEY_MEETME, SOFTKEY_NEWCALL, SOFTKEY_NONE, SOFTKEY_PARK, SOFTKEY_PICKUP, SOFTKEY_REDIAL, SOFTKEY_RESUME, SOFTKEY_TRNSFER, soft_key_event_message::softKeyEvent, skinny_data::softkeyeventmessage, start_rtp(), STIMULUS_FORWARDALL, STIMULUS_LINE, t, ast_channel::tech_pvt, skinny_line::transfer, transmit_callstate(), transmit_displaymessage(), transmit_displaynotify(), transmit_lamp_indication(), transmit_ringer_mode(), transmit_selectsoftkeys(), transmit_speaker_mode(), transmit_tone(), and VERBOSE_PREFIX_3.
Referenced by handle_message().
03868 { 03869 struct skinny_device *d = s->device; 03870 struct skinny_line *l; 03871 struct skinny_subchannel *sub = NULL; 03872 struct ast_channel *c; 03873 pthread_t t; 03874 int event; 03875 int instance; 03876 int callreference; 03877 03878 event = letohl(req->data.softkeyeventmessage.softKeyEvent); 03879 instance = letohl(req->data.softkeyeventmessage.instance); 03880 callreference = letohl(req->data.softkeyeventmessage.callreference); 03881 03882 if (instance) { 03883 l = find_line_by_instance(d, instance); 03884 if (callreference) { 03885 sub = find_subchannel_by_instance_reference(d, instance, callreference); 03886 } else { 03887 sub = find_subchannel_by_instance_reference(d, instance, d->lastcallreference); 03888 } 03889 } else { 03890 l = find_line_by_instance(d, d->lastlineinstance); 03891 } 03892 03893 if (!l) { 03894 if (skinnydebug) 03895 ast_verbose("Received Softkey Event: %d(%d/%d)\n", event, instance, callreference); 03896 return 0; 03897 } 03898 03899 switch(event) { 03900 case SOFTKEY_NONE: 03901 if (skinnydebug) 03902 ast_verbose("Received Softkey Event: None(%d/%d)\n", instance, callreference); 03903 break; 03904 case SOFTKEY_REDIAL: 03905 if (skinnydebug) 03906 ast_verbose("Received Softkey Event: Redial(%d/%d)\n", instance, callreference); 03907 03908 #if 0 03909 if (!sub || !sub->owner) { 03910 c = skinny_new(l, AST_STATE_DOWN); 03911 } else { 03912 c = sub->owner; 03913 } 03914 03915 if(!c) { 03916 ast_log(LOG_WARNING, "Unable to create channel for %s@%s\n", l->name, d->name); 03917 } else { 03918 sub = c->tech_pvt; 03919 transmit_callstate(s, l->instance, SKINNY_OFFHOOK, sub->callid); 03920 if (skinnydebug) 03921 ast_verbose("Attempting to Clear display on Skinny %s@%s\n", l->name, d->name); 03922 transmit_displaymessage(s, NULL, l->instance, sub->callid); /* clear display */ 03923 transmit_tone(s, SKINNY_DIALTONE, l->instance, sub->callid); 03924 transmit_selectsoftkeys(s, l->instance, sub->callid, KEYDEF_RINGOUT); 03925 03926 if (!ast_ignore_pattern(c->context, l->lastnumberdialed)) { 03927 transmit_tone(s, SKINNY_SILENCE, l->instance, sub->callid); 03928 } 03929 ast_copy_string(c->exten, l->lastnumberdialed, sizeof(c->exten)); 03930 if (ast_pthread_create(&t, NULL, skinny_newcall, c)) { 03931 ast_log(LOG_WARNING, "Unable to create new call thread: %s\n", strerror(errno)); 03932 ast_hangup(c); 03933 } 03934 } 03935 #endif 03936 break; 03937 case SOFTKEY_NEWCALL: /* Actually the DIAL softkey */ 03938 if (skinnydebug) 03939 ast_verbose("Received Softkey Event: New Call(%d/%d)\n", instance, callreference); 03940 03941 if (!sub || !sub->owner) { 03942 c = skinny_new(l, AST_STATE_DOWN); 03943 } else { 03944 c = sub->owner; 03945 } 03946 03947 if (!c) { 03948 ast_log(LOG_WARNING, "Unable to create channel for %s@%s\n", l->name, d->name); 03949 } else { 03950 sub = c->tech_pvt; 03951 if (l->hookstate == SKINNY_ONHOOK) { 03952 l->hookstate = SKINNY_OFFHOOK; 03953 transmit_speaker_mode(s, SKINNY_SPEAKERON); 03954 transmit_callstate(s, l->instance, SKINNY_OFFHOOK, sub->callid); 03955 } 03956 03957 if (skinnydebug) 03958 ast_verbose("Attempting to Clear display on Skinny %s@%s\n", l->name, d->name); 03959 transmit_displaymessage(s, NULL, l->instance, sub->callid); /* clear display */ 03960 transmit_tone(s, SKINNY_DIALTONE, l->instance, sub->callid); 03961 transmit_selectsoftkeys(s, l->instance, sub->callid, KEYDEF_OFFHOOK); 03962 03963 /* start the switch thread */ 03964 if (ast_pthread_create(&t, NULL, skinny_ss, c)) { 03965 ast_log(LOG_WARNING, "Unable to create switch thread: %s\n", strerror(errno)); 03966 ast_hangup(c); 03967 } 03968 } 03969 break; 03970 case SOFTKEY_HOLD: 03971 if (skinnydebug) 03972 ast_verbose("Received Softkey Event: Hold(%d/%d)\n", instance, callreference); 03973 03974 if (sub) { 03975 if (sub->onhold) { 03976 skinny_unhold(sub); 03977 } else { 03978 skinny_hold(sub); 03979 } 03980 } 03981 03982 break; 03983 case SOFTKEY_TRNSFER: 03984 if (skinnydebug) 03985 ast_verbose("Received Softkey Event: Transfer(%d/%d)\n", instance, callreference); 03986 /* XXX figure out how to transfer */ 03987 break; 03988 case SOFTKEY_CFWDALL: 03989 if (skinnydebug) 03990 ast_verbose("Received Softkey Event: Forward All(%d/%d)\n", instance, callreference); 03991 03992 /* Do not disturb */ 03993 if (l->dnd != 0){ 03994 if (option_verbose > 2) 03995 ast_verbose(VERBOSE_PREFIX_3 "Disabling DND on %s@%s\n", l->name, d->name); 03996 l->dnd = 0; 03997 transmit_lamp_indication(s, STIMULUS_FORWARDALL, 1, SKINNY_LAMP_ON); 03998 transmit_displaynotify(s, "DnD disabled", 10); 03999 } else { 04000 if (option_verbose > 2) 04001 ast_verbose(VERBOSE_PREFIX_3 "Enabling DND on %s@%s\n", l->name, d->name); 04002 l->dnd = 1; 04003 transmit_lamp_indication(s, STIMULUS_FORWARDALL, 1, SKINNY_LAMP_OFF); 04004 transmit_displaynotify(s, "DnD enabled", 10); 04005 } 04006 break; 04007 case SOFTKEY_CFWDBUSY: 04008 if (skinnydebug) 04009 ast_verbose("Received Softkey Event: Forward Busy (%d/%d)\n", instance, callreference); 04010 break; 04011 case SOFTKEY_CFWDNOANSWER: 04012 if (skinnydebug) 04013 ast_verbose("Received Softkey Event: Forward No Answer (%d/%d)\n", instance, callreference); 04014 break; 04015 case SOFTKEY_BKSPC: 04016 if (skinnydebug) 04017 ast_verbose("Received Softkey Event: Backspace(%d/%d)\n", instance, callreference); 04018 break; 04019 case SOFTKEY_ENDCALL: 04020 if (skinnydebug) 04021 ast_verbose("Received Softkey Event: End Call(%d/%d)\n", instance, callreference); 04022 04023 if (l->hookstate == SKINNY_ONHOOK) { 04024 /* Something else already put us back on hook */ 04025 break; 04026 } 04027 if (sub) { 04028 sub->cxmode = SKINNY_CX_RECVONLY; 04029 l->hookstate = SKINNY_ONHOOK; 04030 transmit_callstate(s, l->instance, l->hookstate, sub->callid); 04031 if (skinnydebug) 04032 ast_verbose("Skinny %s@%s went on hook\n", l->name, d->name); 04033 if (l->transfer && (sub->owner && sub->next && sub->next->owner) && ((!sub->outgoing) || (sub->next && !sub->next->outgoing))) { 04034 /* We're allowed to transfer, we have two active calls and 04035 we made at least one of the calls. Let's try and transfer */ 04036 04037 #if 0 04038 if ((res = attempt_transfer(p)) < 0) { 04039 if (sub->next && sub->next->owner) { 04040 sub->next->alreadygone = 1; 04041 ast_queue_hangup(sub->next->owner, 1); 04042 } 04043 } else if (res) { 04044 ast_log(LOG_WARNING, "Transfer attempt failed\n"); 04045 break; 04046 } 04047 #endif 04048 } else { 04049 /* Hangup the current call */ 04050 /* If there is another active call, skinny_hangup will ring the phone with the other call */ 04051 if (sub->owner) { 04052 sub->alreadygone = 1; 04053 ast_queue_hangup(sub->owner); 04054 } else { 04055 ast_log(LOG_WARNING, "Skinny(%s@%s-%d) channel already destroyed\n", 04056 l->name, d->name, sub->callid); 04057 } 04058 } 04059 if ((l->hookstate == SKINNY_ONHOOK) && (sub->next && !sub->next->rtp)) { 04060 do_housekeeping(s); 04061 } 04062 } 04063 break; 04064 case SOFTKEY_RESUME: 04065 if (skinnydebug) 04066 ast_verbose("Received Softkey Event: Resume(%d/%d)\n", instance, callreference); 04067 break; 04068 case SOFTKEY_ANSWER: 04069 if (skinnydebug) 04070 ast_verbose("Received Softkey Event: Answer(%d/%d)\n", instance, callreference); 04071 04072 transmit_ringer_mode(s,SKINNY_RING_OFF); 04073 transmit_lamp_indication(s, STIMULUS_LINE, l->instance, SKINNY_LAMP_ON); 04074 04075 l->hookstate = SKINNY_OFFHOOK; 04076 04077 if (sub && sub->outgoing) { 04078 /* We're answering a ringing call */ 04079 ast_queue_control(sub->owner, AST_CONTROL_ANSWER); 04080 transmit_callstate(s, l->instance, SKINNY_OFFHOOK, sub->callid); 04081 transmit_tone(s, SKINNY_SILENCE, l->instance, sub->callid); 04082 transmit_callstate(s, l->instance, SKINNY_CONNECTED, sub->callid); 04083 transmit_selectsoftkeys(s, l->instance, sub->callid, KEYDEF_CONNECTED); 04084 start_rtp(sub); 04085 ast_setstate(sub->owner, AST_STATE_UP); 04086 } 04087 break; 04088 case SOFTKEY_INFO: 04089 if (skinnydebug) 04090 ast_verbose("Received Softkey Event: Info(%d/%d)\n", instance, callreference); 04091 break; 04092 case SOFTKEY_CONFRN: 04093 if (skinnydebug) 04094 ast_verbose("Received Softkey Event: Conference(%d/%d)\n", instance, callreference); 04095 /* XXX determine the best way to pull off a conference. Meetme? */ 04096 break; 04097 case SOFTKEY_PARK: 04098 if (skinnydebug) 04099 ast_verbose("Received Softkey Event: Park Call(%d/%d)\n", instance, callreference); 04100 /* XXX Park the call */ 04101 break; 04102 case SOFTKEY_JOIN: 04103 if (skinnydebug) 04104 ast_verbose("Received Softkey Event: Join(%d/%d)\n", instance, callreference); 04105 break; 04106 case SOFTKEY_MEETME: 04107 /* XXX How is this different from CONFRN? */ 04108 if (skinnydebug) 04109 ast_verbose("Received Softkey Event: Meetme(%d/%d)\n", instance, callreference); 04110 break; 04111 case SOFTKEY_PICKUP: 04112 if (skinnydebug) 04113 ast_verbose("Received Softkey Event: Pickup(%d/%d)\n", instance, callreference); 04114 break; 04115 case SOFTKEY_GPICKUP: 04116 if (skinnydebug) 04117 ast_verbose("Received Softkey Event: Group Pickup(%d/%d)\n", instance, callreference); 04118 break; 04119 default: 04120 if (skinnydebug) 04121 ast_verbose("Received unknown Softkey Event: %d(%d/%d)\n", event, instance, callreference); 04122 break; 04123 } 04124 return 1; 04125 }
static int handle_soft_key_set_req_message | ( | struct skinny_req * | req, | |
struct skinnysession * | s | |||
) | [static] |
Definition at line 3835 of file chan_skinny.c.
References soft_key_definitions::count, skinny_req::data, soft_key_definitions::defaults, htolel, KEYDEF_ONHOOK, soft_key_definitions::mode, req_alloc(), SOFT_KEY_SET_RES_MESSAGE, soft_key_set_definition::softKeyInfoIndex, soft_key_set_res_message::softKeySetCount, soft_key_set_res_message::softKeySetDefinition, soft_key_set_res_message::softKeySetOffset, skinny_data::softkeysets, soft_key_set_definition::softKeyTemplateIndex, soft_key_set_res_message::totalSoftKeySetCount, transmit_response(), and transmit_selectsoftkeys().
Referenced by handle_message().
03836 { 03837 int i; 03838 int x; 03839 int y; 03840 const struct soft_key_definitions *softkeymode = soft_key_default_definitions; 03841 03842 if (!(req = req_alloc(sizeof(struct soft_key_set_res_message), SOFT_KEY_SET_RES_MESSAGE))) 03843 return -1; 03844 03845 req->data.softkeysets.softKeySetOffset = htolel(0); 03846 req->data.softkeysets.softKeySetCount = htolel(11); 03847 req->data.softkeysets.totalSoftKeySetCount = htolel(11); 03848 for (x = 0; x < sizeof(soft_key_default_definitions) / sizeof(struct soft_key_definitions); x++) { 03849 const uint8_t *defaults = softkeymode->defaults; 03850 /* XXX I wanted to get the size of the array dynamically, but that wasn't wanting to work. 03851 This will have to do for now. */ 03852 for (y = 0; y < softkeymode->count; y++) { 03853 for (i = 0; i < (sizeof(soft_key_template_default) / sizeof(struct soft_key_template_definition)); i++) { 03854 if (defaults[y] == i+1) { 03855 req->data.softkeysets.softKeySetDefinition[softkeymode->mode].softKeyTemplateIndex[y] = htolel(i+1); 03856 req->data.softkeysets.softKeySetDefinition[softkeymode->mode].softKeyInfoIndex[y] = htolel(i+301); 03857 } 03858 } 03859 } 03860 softkeymode++; 03861 } 03862 transmit_response(s,req); 03863 transmit_selectsoftkeys(s, 0, 0, KEYDEF_ONHOOK); 03864 return 1; 03865 }
static int handle_soft_key_template_req_message | ( | struct skinny_req * | req, | |
struct skinnysession * | s | |||
) | [static] |
Definition at line 4132 of file chan_skinny.c.
References skinny_req::data, htolel, req_alloc(), SOFT_KEY_TEMPLATE_RES_MESSAGE, soft_key_template_res_message::softKeyCount, soft_key_template_res_message::softKeyOffset, skinny_data::softkeytemplate, soft_key_template_res_message::softKeyTemplateDefinition, soft_key_template_res_message::totalSoftKeyCount, and transmit_response().
Referenced by handle_message().
04133 { 04134 if (!(req = req_alloc(sizeof(struct soft_key_template_res_message), SOFT_KEY_TEMPLATE_RES_MESSAGE))) 04135 return -1; 04136 04137 req->data.softkeytemplate.softKeyOffset = htolel(0); 04138 req->data.softkeytemplate.softKeyCount = htolel(sizeof(soft_key_template_default) / sizeof(struct soft_key_template_definition)); 04139 req->data.softkeytemplate.totalSoftKeyCount = htolel(sizeof(soft_key_template_default) / sizeof(struct soft_key_template_definition)); 04140 memcpy(req->data.softkeytemplate.softKeyTemplateDefinition, 04141 soft_key_template_default, 04142 sizeof(soft_key_template_default)); 04143 transmit_response(s,req); 04144 return 1; 04145 }
static int handle_speed_dial_stat_req_message | ( | struct skinny_req * | req, | |
struct skinnysession * | s | |||
) | [static] |
Definition at line 3493 of file chan_skinny.c.
References skinny_req::data, skinnysession::device, skinny_speeddial::exten, find_speeddial_by_instance(), htolel, skinny_speeddial::instance, skinny_speeddial::label, letohl, req_alloc(), SPEED_DIAL_STAT_RES_MESSAGE, skinny_data::speeddial, speed_dial_stat_res_message::speedDialDirNumber, speed_dial_stat_res_message::speedDialDisplayName, speed_dial_stat_req_message::speedDialNumber, skinny_data::speeddialreq, and transmit_response().
Referenced by handle_message().
03494 { 03495 struct skinny_device *d = s->device; 03496 struct skinny_speeddial *sd; 03497 int instance; 03498 03499 instance = letohl(req->data.speeddialreq.speedDialNumber); 03500 03501 sd = find_speeddial_by_instance(d, instance); 03502 03503 if (!sd) { 03504 return 0; 03505 } 03506 03507 if (!(req = req_alloc(sizeof(struct speed_dial_stat_res_message), SPEED_DIAL_STAT_RES_MESSAGE))) 03508 return -1; 03509 03510 req->data.speeddialreq.speedDialNumber = htolel(instance); 03511 snprintf(req->data.speeddial.speedDialDirNumber, sizeof(req->data.speeddial.speedDialDirNumber), sd->exten); 03512 snprintf(req->data.speeddial.speedDialDisplayName, sizeof(req->data.speeddial.speedDialDisplayName), sd->label); 03513 03514 transmit_response(s, req); 03515 return 1; 03516 }
static int handle_stimulus_message | ( | struct skinny_req * | req, | |
struct skinnysession * | s | |||
) | [static] |
Definition at line 3086 of file chan_skinny.c.
References AST_CONTROL_ANSWER, ast_exists_extension(), ast_hangup(), ast_ignore_pattern(), ast_log(), ast_matchmore_extension(), ast_pthread_create, ast_queue_control(), ast_setstate(), AST_STATE_DOWN, AST_STATE_UP, ast_strlen_zero(), ast_verbose(), skinny_subchannel::callid, stimulus_message::callreference, skinny_line::cid_num, ast_channel::context, skinny_req::data, skinnysession::device, skinny_line::dnd, errno, event, ast_channel::exten, find_line_by_instance(), find_speeddial_by_instance(), find_subchannel_by_instance_reference(), skinny_line::hookstate, skinny_line::instance, KEYDEF_CONNECTED, KEYDEF_OFFHOOK, KEYDEF_RINGOUT, skinny_device::lastcallreference, skinny_device::lastlineinstance, skinny_line::lastnumberdialed, letohl, LOG_DEBUG, LOG_WARNING, skinny_device::name, skinny_line::name, skinny_subchannel::onhold, option_verbose, skinny_subchannel::outgoing, skinny_subchannel::owner, skinny_subchannel::parent, SKINNY_CONNECTED, SKINNY_DIALTONE, skinny_hold(), SKINNY_LAMP_OFF, SKINNY_LAMP_ON, skinny_new(), skinny_newcall(), SKINNY_OFFHOOK, SKINNY_ONHOOK, SKINNY_RING_OFF, SKINNY_SILENCE, SKINNY_SPEAKEROFF, SKINNY_SPEAKERON, skinny_ss(), skinny_unhold(), start_rtp(), stimulus_message::stimulus, skinny_data::stimulus, STIMULUS_CALLPARK, STIMULUS_CONFERENCE, STIMULUS_DISPLAY, STIMULUS_FORWARDALL, STIMULUS_FORWARDBUSY, STIMULUS_FORWARDNOANSWER, STIMULUS_HOLD, STIMULUS_LINE, STIMULUS_REDIAL, STIMULUS_SPEEDDIAL, STIMULUS_TRANSFER, STIMULUS_VOICEMAIL, stimulus_message::stimulusInstance, t, ast_channel::tech_pvt, transmit_callstate(), transmit_displaymessage(), transmit_displaynotify(), transmit_displaypromptstatus(), transmit_lamp_indication(), transmit_ringer_mode(), transmit_selectsoftkeys(), transmit_speaker_mode(), transmit_tone(), and VERBOSE_PREFIX_3.
Referenced by handle_message().
03087 { 03088 struct skinny_device *d = s->device; 03089 struct skinny_line *l; 03090 struct skinny_subchannel *sub; 03091 /*struct skinny_speeddial *sd;*/ 03092 struct ast_channel *c; 03093 pthread_t t; 03094 int event; 03095 int instance; 03096 int callreference; 03097 /*int res = 0;*/ 03098 03099 event = letohl(req->data.stimulus.stimulus); 03100 instance = letohl(req->data.stimulus.stimulusInstance); 03101 callreference = letohl(req->data.stimulus.callreference); 03102 if (skinnydebug) 03103 ast_verbose("callreference in handle_stimulus_message is '%d'\n", callreference); 03104 03105 /* Note that this call should be using the passed in instance and callreference */ 03106 sub = find_subchannel_by_instance_reference(d, d->lastlineinstance, d->lastcallreference); 03107 03108 if (!sub) { 03109 l = find_line_by_instance(d, d->lastlineinstance); 03110 if (!l) { 03111 return 0; 03112 } 03113 } else { 03114 l = sub->parent; 03115 } 03116 03117 switch(event) { 03118 case STIMULUS_REDIAL: 03119 if (skinnydebug) 03120 ast_verbose("Received Stimulus: Redial(%d/%d)\n", instance, callreference); 03121 03122 #if 0 03123 if (ast_strlen_zero(l->lastnumberdialed)) { 03124 ast_log(LOG_WARNING, "Attempted redial, but no previously dialed number found.\n"); 03125 l->hookstate = SKINNY_ONHOOK; 03126 transmit_speaker_mode(s, SKINNY_SPEAKEROFF); 03127 transmit_callstate(s, l->instance, SKINNY_ONHOOK, instance); 03128 break; 03129 } 03130 03131 c = skinny_new(l, AST_STATE_DOWN); 03132 if(!c) { 03133 ast_log(LOG_WARNING, "Unable to create channel for %s@%s\n", l->name, d->name); 03134 } else { 03135 sub = c->tech_pvt; 03136 transmit_callstate(s, l->instance, SKINNY_OFFHOOK, sub->callid); 03137 if (skinnydebug) 03138 ast_verbose("Attempting to Clear display on Skinny %s@%s\n", l->name, d->name); 03139 transmit_displaymessage(s, NULL, l->instance, sub->callid); /* clear display */ 03140 transmit_tone(s, SKINNY_DIALTONE, l->instance, sub->callid); 03141 transmit_selectsoftkeys(s, l->instance, sub->callid, KEYDEF_RINGOUT); 03142 03143 if (!ast_ignore_pattern(c->context, l->lastnumberdialed)) { 03144 transmit_tone(s, SKINNY_SILENCE, l->instance, sub->callid); 03145 } 03146 ast_copy_string(c->exten, l->lastnumberdialed, sizeof(c->exten)); 03147 if (ast_pthread_create(&t, NULL, skinny_newcall, c)) { 03148 ast_log(LOG_WARNING, "Unable to create new call thread: %s\n", strerror(errno)); 03149 ast_hangup(c); 03150 } 03151 } 03152 #endif 03153 break; 03154 case STIMULUS_SPEEDDIAL: 03155 if (skinnydebug) 03156 ast_verbose("Received Stimulus: SpeedDial(%d/%d)\n", instance, callreference); 03157 03158 #if 0 03159 if (!(sd = find_speeddial_by_instance(d, instance))) { 03160 return 0; 03161 } 03162 03163 if (ast_strlen_zero(l->lastnumberdialed)) { 03164 ast_log(LOG_WARNING, "Attempted redial, but no previously dialed number found.\n"); 03165 l->hookstate = SKINNY_ONHOOK; 03166 transmit_speaker_mode(s, SKINNY_SPEAKEROFF); 03167 transmit_callstate(s, l->instance, SKINNY_ONHOOK, instance); 03168 break; 03169 } 03170 03171 c = skinny_new(l, AST_STATE_DOWN); 03172 if(c) { 03173 sub = c->tech_pvt; 03174 l = sub->parent; 03175 transmit_callstate(s, l->instance, SKINNY_OFFHOOK, sub->callid); 03176 if (skinnydebug) 03177 ast_verbose("Attempting to Clear display on Skinny %s@%s\n", l->name, d->name); 03178 transmit_displaymessage(s, NULL, l->instance, sub->callid); /* clear display */ 03179 transmit_tone(s, SKINNY_DIALTONE, l->instance, sub->callid); 03180 transmit_selectsoftkeys(s, l->instance, sub->callid, KEYDEF_RINGOUT); 03181 03182 if (!ast_ignore_pattern(c->context, sd->exten)) { 03183 transmit_tone(s, SKINNY_SILENCE, l->instance, sub->callid); 03184 } 03185 if (ast_exists_extension(c, c->context, sd->exten, 1, l->cid_num)) { 03186 if (!ast_matchmore_extension(c, c->context, sd->exten, 1, l->cid_num)) { 03187 ast_copy_string(c->exten, sd->exten, sizeof(c->exten)); 03188 ast_copy_string(l->lastnumberdialed, sd->exten, sizeof(l->lastnumberdialed)); 03189 skinny_newcall(c); 03190 break; 03191 } 03192 } 03193 } else { 03194 ast_log(LOG_WARNING, "Unable to create channel for %s@%s\n", l->name, d->name); 03195 } 03196 #endif 03197 break; 03198 case STIMULUS_HOLD: 03199 if (skinnydebug) 03200 ast_verbose("Received Stimulus: Hold(%d/%d)\n", instance, callreference); 03201 03202 if (!sub) 03203 break; 03204 03205 if (sub->onhold) { 03206 skinny_unhold(sub); 03207 } else { 03208 skinny_hold(sub); 03209 } 03210 break; 03211 case STIMULUS_TRANSFER: 03212 if (skinnydebug) 03213 ast_verbose("Received Stimulus: Transfer(%d/%d)\n", instance, callreference); 03214 /* XXX figure out how to transfer */ 03215 break; 03216 case STIMULUS_CONFERENCE: 03217 if (skinnydebug) 03218 ast_verbose("Received Stimulus: Conference(%d/%d)\n", instance, callreference); 03219 /* XXX determine the best way to pull off a conference. Meetme? */ 03220 break; 03221 case STIMULUS_VOICEMAIL: 03222 if (skinnydebug) 03223 ast_verbose("Received Stimulus: Voicemail(%d/%d)\n", instance, callreference); 03224 /* XXX Find and dial voicemail extension */ 03225 break; 03226 case STIMULUS_CALLPARK: 03227 if (skinnydebug) 03228 ast_verbose("Received Stimulus: Park Call(%d/%d)\n", instance, callreference); 03229 /* XXX Park the call */ 03230 break; 03231 case STIMULUS_FORWARDALL: 03232 if (skinnydebug) 03233 ast_verbose("Received Stimulus: Forward All(%d/%d)\n", instance, callreference); 03234 /* Why is DND under FORWARDALL? */ 03235 /* Because it's the same thing. */ 03236 03237 /* Do not disturb */ 03238 if (l->dnd != 0){ 03239 if (option_verbose > 2) 03240 ast_verbose(VERBOSE_PREFIX_3 "Disabling DND on %s@%s\n", l->name, d->name); 03241 l->dnd = 0; 03242 transmit_lamp_indication(s, STIMULUS_FORWARDALL, 1, SKINNY_LAMP_ON); 03243 transmit_displaynotify(s, "DnD disabled", 10); 03244 } else { 03245 if (option_verbose > 2) 03246 ast_verbose(VERBOSE_PREFIX_3 "Enabling DND on %s@%s\n", l->name, d->name); 03247 l->dnd = 1; 03248 transmit_lamp_indication(s, STIMULUS_FORWARDALL, 1, SKINNY_LAMP_OFF); 03249 transmit_displaynotify(s, "DnD enabled", 10); 03250 } 03251 break; 03252 case STIMULUS_FORWARDBUSY: 03253 if (skinnydebug) 03254 ast_verbose("Received Stimulus: Forward Busy (%d/%d)\n", instance, callreference); 03255 break; 03256 case STIMULUS_FORWARDNOANSWER: 03257 if (skinnydebug) 03258 ast_verbose("Received Stimulus: Forward No Answer (%d/%d)\n", instance, callreference); 03259 break; 03260 case STIMULUS_DISPLAY: 03261 /* Not sure what this is */ 03262 if (skinnydebug) 03263 ast_verbose("Received Stimulus: Display(%d/%d)\n", instance, callreference); 03264 break; 03265 case STIMULUS_LINE: 03266 if (skinnydebug) 03267 ast_verbose("Received Stimulus: Line(%d/%d)\n", instance, callreference); 03268 03269 l = find_line_by_instance(s->device, instance); 03270 03271 if (!l) { 03272 return 0; 03273 } 03274 03275 /* turn the speaker on */ 03276 transmit_speaker_mode(s, SKINNY_SPEAKERON); 03277 transmit_ringer_mode(s, SKINNY_RING_OFF); 03278 transmit_lamp_indication(s, STIMULUS_LINE, l->instance, SKINNY_LAMP_ON); 03279 03280 l->hookstate = SKINNY_OFFHOOK; 03281 03282 if (sub && sub->outgoing) { 03283 /* We're answering a ringing call */ 03284 ast_queue_control(sub->owner, AST_CONTROL_ANSWER); 03285 transmit_callstate(s, l->instance, SKINNY_OFFHOOK, sub->callid); 03286 transmit_tone(s, SKINNY_SILENCE, l->instance, sub->callid); 03287 transmit_callstate(s, l->instance, SKINNY_CONNECTED, sub->callid); 03288 transmit_displaypromptstatus(s, "Connected", 0, l->instance, sub->callid); 03289 transmit_selectsoftkeys(s, l->instance, sub->callid, KEYDEF_CONNECTED); 03290 start_rtp(sub); 03291 ast_setstate(sub->owner, AST_STATE_UP); 03292 } else { 03293 if (sub && sub->owner) { 03294 ast_log(LOG_DEBUG, "Current subchannel [%s] already has owner\n", sub->owner->name); 03295 } else { 03296 c = skinny_new(l, AST_STATE_DOWN); 03297 if(c) { 03298 sub = c->tech_pvt; 03299 transmit_callstate(s, l->instance, SKINNY_OFFHOOK, sub->callid); 03300 if (skinnydebug) 03301 ast_verbose("Attempting to Clear display on Skinny %s@%s\n", l->name, d->name); 03302 transmit_displaymessage(s, NULL, l->instance, sub->callid); /* clear display */ 03303 transmit_tone(s, SKINNY_DIALTONE, l->instance, sub->callid); 03304 transmit_selectsoftkeys(s, l->instance, sub->callid, KEYDEF_OFFHOOK); 03305 03306 /* start the switch thread */ 03307 if (ast_pthread_create(&t, NULL, skinny_ss, c)) { 03308 ast_log(LOG_WARNING, "Unable to create switch thread: %s\n", strerror(errno)); 03309 ast_hangup(c); 03310 } 03311 } else { 03312 ast_log(LOG_WARNING, "Unable to create channel for %s@%s\n", l->name, d->name); 03313 } 03314 } 03315 } 03316 break; 03317 default: 03318 if (skinnydebug) 03319 ast_verbose("RECEIVED UNKNOWN STIMULUS: %d(%d/%d)\n", event, instance, callreference); 03320 break; 03321 } 03322 return 1; 03323 }
static int handle_time_date_req_message | ( | struct skinny_req * | req, | |
struct skinnysession * | s | |||
) | [static] |
Definition at line 3548 of file chan_skinny.c.
References skinny_req::data, definetimedate_message::day, definetimedate_message::dayofweek, skinny_data::definetimedate, DEFINETIMEDATE_MESSAGE, definetimedate_message::hour, htolel, definetimedate_message::milliseconds, definetimedate_message::minute, definetimedate_message::month, req_alloc(), definetimedate_message::seconds, definetimedate_message::timestamp, transmit_response(), and definetimedate_message::year.
Referenced by do_housekeeping(), and handle_message().
03549 { 03550 time_t timer; 03551 struct tm *cmtime; 03552 03553 if (!(req = req_alloc(sizeof(struct definetimedate_message), DEFINETIMEDATE_MESSAGE))) 03554 return -1; 03555 03556 timer = time(NULL); 03557 cmtime = localtime(&timer); 03558 req->data.definetimedate.year = htolel(cmtime->tm_year+1900); 03559 req->data.definetimedate.month = htolel(cmtime->tm_mon+1); 03560 req->data.definetimedate.dayofweek = htolel(cmtime->tm_wday); 03561 req->data.definetimedate.day = htolel(cmtime->tm_mday); 03562 req->data.definetimedate.hour = htolel(cmtime->tm_hour); 03563 req->data.definetimedate.minute = htolel(cmtime->tm_min); 03564 req->data.definetimedate.seconds = htolel(cmtime->tm_sec); 03565 req->data.definetimedate.milliseconds = htolel(0); 03566 req->data.definetimedate.timestamp = htolel(timer); 03567 transmit_response(s, req); 03568 return 1; 03569 }
static int handle_unregister_message | ( | struct skinny_req * | req, | |
struct skinnysession * | s | |||
) | [static] |
Definition at line 4127 of file chan_skinny.c.
References skinny_unregister().
Referenced by handle_message().
04128 { 04129 return skinny_unregister(req, s); 04130 }
static int handle_version_req_message | ( | struct skinny_req * | req, | |
struct skinnysession * | s | |||
) | [static] |
Definition at line 3682 of file chan_skinny.c.
References skinny_req::data, skinnysession::device, req_alloc(), transmit_response(), version_res_message::version, skinny_data::version, skinny_device::version_id, and VERSION_RES_MESSAGE.
Referenced by handle_message().
03683 { 03684 struct skinny_device *d = s->device; 03685 if (!(req = req_alloc(sizeof(struct version_res_message), VERSION_RES_MESSAGE))) 03686 return -1; 03687 03688 snprintf(req->data.version.version, sizeof(req->data.version.version), d->version_id); 03689 transmit_response(s, req); 03690 return 1; 03691 }
static int load_module | ( | void | ) | [static] |
Definition at line 4830 of file chan_skinny.c.
References ast_channel_register(), ast_cli_register_multiple(), ast_log(), AST_MODULE_LOAD_DECLINE, ast_rtp_proto_register(), htolel, io_context_create(), LOG_ERROR, LOG_WARNING, reload_config(), restart_monitor(), sched_context_create(), and soft_key_template_definition::softKeyEvent.
04831 { 04832 int res = 0; 04833 04834 for (; res < (sizeof(soft_key_template_default) / sizeof(soft_key_template_default[0])); res++) { 04835 soft_key_template_default[res].softKeyEvent = htolel(soft_key_template_default[res].softKeyEvent); 04836 } 04837 /* load and parse config */ 04838 res = reload_config(); 04839 if (res == -1) { 04840 return AST_MODULE_LOAD_DECLINE; 04841 } 04842 04843 /* Make sure we can register our skinny channel type */ 04844 if (ast_channel_register(&skinny_tech)) { 04845 ast_log(LOG_ERROR, "Unable to register channel class 'Skinny'\n"); 04846 return -1; 04847 } 04848 04849 ast_rtp_proto_register(&skinny_rtp); 04850 ast_cli_register_multiple(cli_skinny, sizeof(cli_skinny) / sizeof(struct ast_cli_entry)); 04851 sched = sched_context_create(); 04852 if (!sched) { 04853 ast_log(LOG_WARNING, "Unable to create schedule context\n"); 04854 } 04855 io = io_context_create(); 04856 if (!io) { 04857 ast_log(LOG_WARNING, "Unable to create I/O context\n"); 04858 } 04859 /* And start the monitor for the first time */ 04860 restart_monitor(); 04861 04862 return res; 04863 }
static int reload_config | ( | void | ) | [static] |
Definition at line 4629 of file chan_skinny.c.
References __ourip, accept_thread(), ahp, ast_category_browse(), ast_config_destroy(), ast_config_load(), ast_gethostbyname(), ast_inet_ntoa(), ast_jb_read_conf(), ast_log(), ast_mutex_lock(), ast_mutex_unlock(), ast_parse_allow_disallow(), ast_pthread_create_background, ast_variable_browse(), ast_verbose(), bindaddr, build_device(), default_prefs, DEFAULT_SKINNY_BACKLOG, DEFAULT_SKINNY_PORT, devices, errno, global_jbconf, ast_variable::lineno, LOG_ERROR, LOG_NOTICE, LOG_WARNING, skinny_device::name, ast_variable::name, skinny_device::next, ast_variable::next, option_verbose, ast_variable::value, VERBOSE_PREFIX_2, and VERBOSE_PREFIX_3.
04630 { 04631 int on = 1; 04632 struct ast_config *cfg; 04633 struct ast_variable *v; 04634 char *cat; 04635 struct skinny_device *d; 04636 int oldport = ntohs(bindaddr.sin_port); 04637 04638 if (gethostname(ourhost, sizeof(ourhost))) { 04639 ast_log(LOG_WARNING, "Unable to get hostname, Skinny disabled\n"); 04640 return 0; 04641 } 04642 cfg = ast_config_load(config); 04643 04644 /* We *must* have a config file otherwise stop immediately */ 04645 if (!cfg) { 04646 ast_log(LOG_NOTICE, "Unable to load config %s, Skinny disabled\n", config); 04647 return -1; 04648 } 04649 memset(&bindaddr, 0, sizeof(bindaddr)); 04650 memset(&default_prefs, 0, sizeof(default_prefs)); 04651 04652 /* Copy the default jb config over global_jbconf */ 04653 memcpy(&global_jbconf, &default_jbconf, sizeof(struct ast_jb_conf)); 04654 04655 /* load the general section */ 04656 v = ast_variable_browse(cfg, "general"); 04657 while (v) { 04658 /* handle jb conf */ 04659 if (!ast_jb_read_conf(&global_jbconf, v->name, v->value)) { 04660 v = v->next; 04661 continue; 04662 } 04663 04664 /* Create the interface list */ 04665 if (!strcasecmp(v->name, "bindaddr")) { 04666 if (!(hp = ast_gethostbyname(v->value, &ahp))) { 04667 ast_log(LOG_WARNING, "Invalid address: %s\n", v->value); 04668 } else { 04669 memcpy(&bindaddr.sin_addr, hp->h_addr, sizeof(bindaddr.sin_addr)); 04670 } 04671 } else if (!strcasecmp(v->name, "keepalive")) { 04672 keep_alive = atoi(v->value); 04673 } else if (!strcasecmp(v->name, "dateformat")) { 04674 memcpy(date_format, v->value, sizeof(date_format)); 04675 } else if (!strcasecmp(v->name, "allow")) { 04676 ast_parse_allow_disallow(&default_prefs, &default_capability, v->value, 1); 04677 } else if (!strcasecmp(v->name, "disallow")) { 04678 ast_parse_allow_disallow(&default_prefs, &default_capability, v->value, 0); 04679 } else if (!strcasecmp(v->name, "bindport") || !strcasecmp(v->name, "port")) { 04680 if (sscanf(v->value, "%d", &ourport) == 1) { 04681 bindaddr.sin_port = htons(ourport); 04682 } else { 04683 ast_log(LOG_WARNING, "Invalid bindport '%s' at line %d of %s\n", v->value, v->lineno, config); 04684 } 04685 if (!strcasecmp(v->name, "port")) { /*! \todo Remove 'port' option after 1.4 */ 04686 ast_log(LOG_WARNING, "Option 'port' at line %d of %s has been deprecated. Please use 'bindport' instead.\n", v->lineno, config); 04687 } 04688 } 04689 v = v->next; 04690 } 04691 04692 if (ntohl(bindaddr.sin_addr.s_addr)) { 04693 __ourip = bindaddr.sin_addr; 04694 } else { 04695 hp = ast_gethostbyname(ourhost, &ahp); 04696 if (!hp) { 04697 ast_log(LOG_WARNING, "Unable to get our IP address, Skinny disabled\n"); 04698 ast_config_destroy(cfg); 04699 return 0; 04700 } 04701 memcpy(&__ourip, hp->h_addr, sizeof(__ourip)); 04702 } 04703 if (!ntohs(bindaddr.sin_port)) { 04704 bindaddr.sin_port = ntohs(DEFAULT_SKINNY_PORT); 04705 } 04706 bindaddr.sin_family = AF_INET; 04707 04708 /* load the device sections */ 04709 cat = ast_category_browse(cfg, NULL); 04710 while(cat) { 04711 if (!strcasecmp(cat, "general")) { 04712 /* Nothing to do */ 04713 #if 0 04714 } else if (!strncasecmp(cat, "paging-", 7)) { 04715 p = build_paging_device(cat, ast_variable_browse(cfg, cat)); 04716 if (p) { 04717 } 04718 #endif 04719 } else { 04720 d = build_device(cat, ast_variable_browse(cfg, cat)); 04721 if (d) { 04722 if (option_verbose > 2) 04723 ast_verbose(VERBOSE_PREFIX_3 "Added device '%s'\n", d->name); 04724 ast_mutex_lock(&devicelock); 04725 d->next = devices; 04726 devices = d; 04727 ast_mutex_unlock(&devicelock); 04728 } 04729 } 04730 cat = ast_category_browse(cfg, cat); 04731 } 04732 ast_mutex_lock(&netlock); 04733 if ((skinnysock > -1) && (ntohs(bindaddr.sin_port) != oldport)) { 04734 close(skinnysock); 04735 skinnysock = -1; 04736 } 04737 if (skinnysock < 0) { 04738 skinnysock = socket(AF_INET, SOCK_STREAM, 0); 04739 if(setsockopt(skinnysock, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)) == -1) { 04740 ast_log(LOG_ERROR, "Set Socket Options failed: errno %d, %s\n", errno, strerror(errno)); 04741 ast_config_destroy(cfg); 04742 return 0; 04743 } 04744 if (skinnysock < 0) { 04745 ast_log(LOG_WARNING, "Unable to create Skinny socket: %s\n", strerror(errno)); 04746 } else { 04747 if (bind(skinnysock, (struct sockaddr *)&bindaddr, sizeof(bindaddr)) < 0) { 04748 ast_log(LOG_WARNING, "Failed to bind to %s:%d: %s\n", 04749 ast_inet_ntoa(bindaddr.sin_addr), ntohs(bindaddr.sin_port), 04750 strerror(errno)); 04751 close(skinnysock); 04752 skinnysock = -1; 04753 ast_config_destroy(cfg); 04754 return 0; 04755 } 04756 if (listen(skinnysock,DEFAULT_SKINNY_BACKLOG)) { 04757 ast_log(LOG_WARNING, "Failed to start listening to %s:%d: %s\n", 04758 ast_inet_ntoa(bindaddr.sin_addr), ntohs(bindaddr.sin_port), 04759 strerror(errno)); 04760 close(skinnysock); 04761 skinnysock = -1; 04762 ast_config_destroy(cfg); 04763 return 0; 04764 } 04765 if (option_verbose > 1) 04766 ast_verbose(VERBOSE_PREFIX_2 "Skinny listening on %s:%d\n", 04767 ast_inet_ntoa(bindaddr.sin_addr), ntohs(bindaddr.sin_port)); 04768 ast_pthread_create_background(&accept_t,NULL, accept_thread, NULL); 04769 } 04770 } 04771 ast_mutex_unlock(&netlock); 04772 ast_config_destroy(cfg); 04773 return 1; 04774 }
static struct skinny_req* req_alloc | ( | size_t | size, | |
int | response_message | |||
) | [static, read] |
Definition at line 1208 of file chan_skinny.c.
References ast_calloc, skinny_req::e, htolel, and skinny_req::len.
Referenced by handle_button_template_req_message(), handle_keep_alive_message(), handle_line_state_req_message(), handle_open_receive_channel_ack_message(), handle_register_message(), handle_server_request_message(), handle_soft_key_set_req_message(), handle_soft_key_template_req_message(), handle_speed_dial_stat_req_message(), handle_time_date_req_message(), handle_version_req_message(), skinny_hold(), skinny_reset_device(), skinny_unhold(), transmit_callinfo(), transmit_callstate(), transmit_connect(), transmit_dialednumber(), transmit_displaymessage(), transmit_displaynotify(), transmit_displaypromptstatus(), transmit_lamp_indication(), transmit_ringer_mode(), transmit_selectsoftkeys(), transmit_speaker_mode(), and transmit_tone().
01209 { 01210 struct skinny_req *req; 01211 01212 if (!(req = ast_calloc(1, skinny_header_size + size + 4))) 01213 return NULL; 01214 01215 req->len = htolel(size+4); 01216 req->e = htolel(response_message); 01217 01218 return req; 01219 }
static int restart_monitor | ( | void | ) | [static] |
Definition at line 4565 of file chan_skinny.c.
References ast_log(), ast_mutex_lock(), ast_mutex_unlock(), ast_pthread_create_background, AST_PTHREADT_NULL, AST_PTHREADT_STOP, do_monitor(), LOG_ERROR, and LOG_WARNING.
04566 { 04567 /* If we're supposed to be stopped -- stay stopped */ 04568 if (monitor_thread == AST_PTHREADT_STOP) 04569 return 0; 04570 04571 ast_mutex_lock(&monlock); 04572 if (monitor_thread == pthread_self()) { 04573 ast_mutex_unlock(&monlock); 04574 ast_log(LOG_WARNING, "Cannot kill myself\n"); 04575 return -1; 04576 } 04577 if (monitor_thread != AST_PTHREADT_NULL) { 04578 /* Wake up the thread */ 04579 pthread_kill(monitor_thread, SIGURG); 04580 } else { 04581 /* Start a new monitor */ 04582 if (ast_pthread_create_background(&monitor_thread, NULL, do_monitor, NULL) < 0) { 04583 ast_mutex_unlock(&monlock); 04584 ast_log(LOG_ERROR, "Unable to start monitor thread.\n"); 04585 return -1; 04586 } 04587 } 04588 ast_mutex_unlock(&monlock); 04589 return 0; 04590 }
static int skinny_answer | ( | struct ast_channel * | ast | ) | [static] |
Definition at line 2526 of file chan_skinny.c.
References ast_channel::_state, AST_MAX_EXTENSION, ast_setstate(), AST_STATE_UP, ast_verbose(), skinny_subchannel::callid, ast_channel::cid, ast_callerid::cid_name, ast_callerid::cid_num, skinny_subchannel::cxmode, ast_channel::exten, exten, skinny_line::instance, KEYDEF_CONNECTED, ast_channel::macroexten, skinny_device::name, skinny_line::name, skinny_line::parent, skinny_subchannel::parent, skinny_subchannel::rtp, s, S_OR, skinny_device::session, SKINNY_CONNECTED, SKINNY_CX_SENDRECV, SKINNY_SILENCE, start_rtp(), ast_channel::tech_pvt, transmit_callinfo(), transmit_callstate(), transmit_displaypromptstatus(), transmit_selectsoftkeys(), and transmit_tone().
02527 { 02528 int res = 0; 02529 struct skinny_subchannel *sub = ast->tech_pvt; 02530 struct skinny_line *l = sub->parent; 02531 struct skinny_device *d = l->parent; 02532 struct skinnysession *s = d->session; 02533 char exten[AST_MAX_EXTENSION] = ""; 02534 02535 ast_copy_string(exten, S_OR(ast->macroexten, ast->exten), sizeof(exten)); 02536 02537 sub->cxmode = SKINNY_CX_SENDRECV; 02538 if (!sub->rtp) { 02539 start_rtp(sub); 02540 } 02541 if (skinnydebug) 02542 ast_verbose("skinny_answer(%s) on %s@%s-%d\n", ast->name, l->name, d->name, sub->callid); 02543 if (ast->_state != AST_STATE_UP) { 02544 ast_setstate(ast, AST_STATE_UP); 02545 } 02546 02547 transmit_tone(s, SKINNY_SILENCE, l->instance, sub->callid); 02548 /* order matters here... 02549 for some reason, transmit_callinfo must be before transmit_callstate, 02550 or you won't get keypad messages in some situations. */ 02551 transmit_callinfo(s, ast->cid.cid_name, ast->cid.cid_num, exten, exten, l->instance, sub->callid, 2); 02552 transmit_callstate(s, l->instance, SKINNY_CONNECTED, sub->callid); 02553 transmit_selectsoftkeys(s, l->instance, sub->callid, KEYDEF_CONNECTED); 02554 transmit_displaypromptstatus(s, "Connected", 0, l->instance, sub->callid); 02555 return res; 02556 }
static int skinny_call | ( | struct ast_channel * | ast, | |
char * | dest, | |||
int | timeout | |||
) | [static] |
Definition at line 2430 of file chan_skinny.c.
References ast_channel::_state, AST_CONTROL_BUSY, AST_CONTROL_RINGING, ast_log(), ast_queue_control(), ast_setstate(), AST_STATE_DOWN, AST_STATE_RESERVED, AST_STATE_RINGING, ast_verbose(), skinny_subchannel::callid, ast_channel::cid, skinny_line::cid_name, ast_callerid::cid_name, skinny_line::cid_num, ast_callerid::cid_num, skinny_line::dnd, skinny_line::hookstate, skinny_line::instance, KEYDEF_RINGIN, LOG_ERROR, LOG_WARNING, skinny_subchannel::outgoing, skinny_line::parent, skinny_subchannel::parent, skinny_device::registered, s, skinny_device::session, SKINNY_ALERT, SKINNY_CALLWAITTONE, SKINNY_LAMP_BLINK, SKINNY_OFFHOOK, SKINNY_ONHOOK, SKINNY_RING_INSIDE, SKINNY_RINGIN, STIMULUS_LINE, ast_channel::tech_pvt, transmit_callinfo(), transmit_callstate(), transmit_displaypromptstatus(), transmit_lamp_indication(), transmit_ringer_mode(), transmit_selectsoftkeys(), and VERBOSE_PREFIX_3.
02431 { 02432 int res = 0; 02433 int tone = 0; 02434 struct skinny_subchannel *sub = ast->tech_pvt; 02435 struct skinny_line *l = sub->parent; 02436 struct skinny_device *d = l->parent; 02437 struct skinnysession *s = d->session; 02438 02439 if (!d->registered) { 02440 ast_log(LOG_ERROR, "Device not registered, cannot call %s\n", dest); 02441 return -1; 02442 } 02443 02444 if ((ast->_state != AST_STATE_DOWN) && (ast->_state != AST_STATE_RESERVED)) { 02445 ast_log(LOG_WARNING, "skinny_call called on %s, neither down nor reserved\n", ast->name); 02446 return -1; 02447 } 02448 02449 if (skinnydebug) 02450 ast_verbose(VERBOSE_PREFIX_3 "skinny_call(%s)\n", ast->name); 02451 02452 if (l->dnd) { 02453 ast_queue_control(ast, AST_CONTROL_BUSY); 02454 return -1; 02455 } 02456 02457 switch (l->hookstate) { 02458 case SKINNY_OFFHOOK: 02459 tone = SKINNY_CALLWAITTONE; 02460 break; 02461 case SKINNY_ONHOOK: 02462 tone = SKINNY_ALERT; 02463 break; 02464 default: 02465 ast_log(LOG_ERROR, "Don't know how to deal with hookstate %d\n", l->hookstate); 02466 break; 02467 } 02468 02469 transmit_callstate(s, l->instance, SKINNY_RINGIN, sub->callid); 02470 transmit_selectsoftkeys(s, l->instance, sub->callid, KEYDEF_RINGIN); 02471 transmit_displaypromptstatus(s, "Ring-In", 0, l->instance, sub->callid); 02472 transmit_callinfo(s, ast->cid.cid_name, ast->cid.cid_num, l->cid_name, l->cid_num, l->instance, sub->callid, 1); 02473 transmit_lamp_indication(s, STIMULUS_LINE, l->instance, SKINNY_LAMP_BLINK); 02474 transmit_ringer_mode(s, SKINNY_RING_INSIDE); 02475 02476 ast_setstate(ast, AST_STATE_RINGING); 02477 ast_queue_control(ast, AST_CONTROL_RINGING); 02478 sub->outgoing = 1; 02479 return res; 02480 }
static int skinny_do_debug | ( | int | fd, | |
int | argc, | |||
char * | argv[] | |||
) | [static] |
Definition at line 1832 of file chan_skinny.c.
References ast_cli(), RESULT_SHOWUSAGE, and RESULT_SUCCESS.
01833 { 01834 if (argc != 3) { 01835 return RESULT_SHOWUSAGE; 01836 } 01837 skinnydebug = 1; 01838 ast_cli(fd, "Skinny Debugging Enabled\n"); 01839 return RESULT_SUCCESS; 01840 }
static int skinny_fixup | ( | struct ast_channel * | oldchan, | |
struct ast_channel * | newchan | |||
) | [static] |
Definition at line 2644 of file chan_skinny.c.
References ast_log(), LOG_NOTICE, LOG_WARNING, skinny_subchannel::owner, and ast_channel::tech_pvt.
02645 { 02646 struct skinny_subchannel *sub = newchan->tech_pvt; 02647 ast_log(LOG_NOTICE, "skinny_fixup(%s, %s)\n", oldchan->name, newchan->name); 02648 if (sub->owner != oldchan) { 02649 ast_log(LOG_WARNING, "old channel wasn't %p but was %p\n", oldchan, sub->owner); 02650 return -1; 02651 } 02652 sub->owner = newchan; 02653 return 0; 02654 }
static enum ast_rtp_get_result skinny_get_rtp_peer | ( | struct ast_channel * | c, | |
struct ast_rtp ** | rtp | |||
) | [static] |
Definition at line 1802 of file chan_skinny.c.
References AST_RTP_GET_FAILED, AST_RTP_TRY_NATIVE, skinny_subchannel::rtp, and ast_channel::tech_pvt.
01803 { 01804 struct skinny_subchannel *sub = NULL; 01805 01806 if (!(sub = c->tech_pvt) || !(sub->rtp)) 01807 return AST_RTP_GET_FAILED; 01808 01809 *rtp = sub->rtp; 01810 01811 return AST_RTP_TRY_NATIVE; 01812 }
static enum ast_rtp_get_result skinny_get_vrtp_peer | ( | struct ast_channel * | c, | |
struct ast_rtp ** | rtp | |||
) | [static] |
Definition at line 1790 of file chan_skinny.c.
References AST_RTP_GET_FAILED, AST_RTP_TRY_NATIVE, ast_channel::tech_pvt, and skinny_subchannel::vrtp.
01791 { 01792 struct skinny_subchannel *sub = NULL; 01793 01794 if (!(sub = c->tech_pvt) || !(sub->vrtp)) 01795 return AST_RTP_GET_FAILED; 01796 01797 *rtp = sub->vrtp; 01798 01799 return AST_RTP_TRY_NATIVE; 01800 }
static int skinny_hangup | ( | struct ast_channel * | ast | ) | [static] |
Definition at line 2482 of file chan_skinny.c.
References skinny_subchannel::alreadygone, ast_log(), ast_mutex_lock(), ast_mutex_unlock(), ast_rtp_destroy(), ast_verbose(), skinny_subchannel::callid, do_housekeeping(), skinny_line::hookstate, skinny_line::instance, skinny_subchannel::lock, LOG_DEBUG, skinny_device::name, skinny_line::name, skinny_subchannel::outgoing, skinny_subchannel::owner, skinny_line::parent, skinny_subchannel::parent, skinny_device::registered, skinny_subchannel::rtp, s, skinny_device::session, SKINNY_LAMP_OFF, SKINNY_OFFHOOK, SKINNY_ONHOOK, SKINNY_RING_OFF, SKINNY_SILENCE, SKINNY_SPEAKEROFF, STIMULUS_LINE, ast_channel::tech_pvt, transmit_callstate(), transmit_lamp_indication(), transmit_ringer_mode(), transmit_speaker_mode(), transmit_tone(), skinny_line::type, and TYPE_LINE.
02483 { 02484 struct skinny_subchannel *sub = ast->tech_pvt; 02485 struct skinny_line *l; 02486 struct skinny_device *d; 02487 struct skinnysession *s; 02488 02489 if (!sub) { 02490 ast_log(LOG_DEBUG, "Asked to hangup channel not connected\n"); 02491 return 0; 02492 } 02493 l = sub->parent; 02494 d = l->parent; 02495 s = d->session; 02496 if (skinnydebug) 02497 ast_verbose("skinny_hangup(%s) on %s@%s\n", ast->name, l->name, d->name); 02498 02499 if (d->registered) { 02500 if ((l->type = TYPE_LINE) && (l->hookstate == SKINNY_OFFHOOK)) { 02501 l->hookstate = SKINNY_ONHOOK; 02502 transmit_callstate(s, l->instance, SKINNY_ONHOOK, sub->callid); 02503 transmit_lamp_indication(s, STIMULUS_LINE, l->instance, SKINNY_LAMP_OFF); 02504 transmit_speaker_mode(s, SKINNY_SPEAKEROFF); 02505 } else if ((l->type = TYPE_LINE) && (l->hookstate == SKINNY_ONHOOK)) { 02506 transmit_tone(s, SKINNY_SILENCE, l->instance, sub->callid); 02507 transmit_callstate(s, l->instance, SKINNY_ONHOOK, sub->callid); 02508 transmit_ringer_mode(s, SKINNY_RING_OFF); 02509 transmit_lamp_indication(s, STIMULUS_LINE, l->instance, SKINNY_LAMP_OFF); 02510 do_housekeeping(s); 02511 } 02512 } 02513 ast_mutex_lock(&sub->lock); 02514 sub->owner = NULL; 02515 ast->tech_pvt = NULL; 02516 sub->alreadygone = 0; 02517 sub->outgoing = 0; 02518 if (sub->rtp) { 02519 ast_rtp_destroy(sub->rtp); 02520 sub->rtp = NULL; 02521 } 02522 ast_mutex_unlock(&sub->lock); 02523 return 0; 02524 }
static int skinny_hold | ( | struct skinny_subchannel * | sub | ) | [static] |
Definition at line 2885 of file chan_skinny.c.
References ACTIVATE_CALL_PLANE_MESSAGE, skinny_data::activatecallplane, AST_CONTROL_HOLD, ast_queue_control_data(), ast_strlen_zero(), ast_verbose(), skinny_subchannel::callid, CLOSE_RECEIVE_CHANNEL_MESSAGE, skinny_data::closereceivechannel, stop_media_transmission_message::conferenceId, close_receive_channel_message::conferenceId, skinny_req::data, htolel, skinny_line::instance, activate_call_plane_message::lineInstance, skinny_line::mohsuggest, skinny_subchannel::onhold, skinny_subchannel::owner, skinny_line::parent, skinny_subchannel::parent, close_receive_channel_message::partyId, stop_media_transmission_message::passThruPartyId, req_alloc(), s, S_OR, skinny_device::session, SKINNY_LAMP_BLINK, STIMULUS_LINE, STOP_MEDIA_TRANSMISSION_MESSAGE, skinny_data::stopmedia, transmit_lamp_indication(), and transmit_response().
Referenced by handle_soft_key_event_message(), and handle_stimulus_message().
02886 { 02887 struct skinny_line *l = sub->parent; 02888 struct skinny_device *d = l->parent; 02889 struct skinnysession *s = d->session; 02890 struct skinny_req *req; 02891 02892 /* Don't try to hold a channel that doesn't exist */ 02893 if (!sub || !sub->owner) 02894 return 0; 02895 02896 /* Channel needs to be put on hold */ 02897 if (skinnydebug) 02898 ast_verbose("Putting on Hold(%d)\n", l->instance); 02899 02900 ast_queue_control_data(sub->owner, AST_CONTROL_HOLD, 02901 S_OR(l->mohsuggest, NULL), 02902 !ast_strlen_zero(l->mohsuggest) ? strlen(l->mohsuggest) + 1 : 0); 02903 02904 if (!(req = req_alloc(sizeof(struct activate_call_plane_message), ACTIVATE_CALL_PLANE_MESSAGE))) 02905 return 0; 02906 02907 req->data.activatecallplane.lineInstance = htolel(l->instance); 02908 transmit_response(s, req); 02909 02910 if (!(req = req_alloc(sizeof(struct close_receive_channel_message), CLOSE_RECEIVE_CHANNEL_MESSAGE))) 02911 return 0; 02912 02913 req->data.closereceivechannel.conferenceId = htolel(sub->callid); 02914 req->data.closereceivechannel.partyId = htolel(sub->callid); 02915 transmit_response(s, req); 02916 02917 if (!(req = req_alloc(sizeof(struct stop_media_transmission_message), STOP_MEDIA_TRANSMISSION_MESSAGE))) 02918 return 0; 02919 02920 req->data.stopmedia.conferenceId = htolel(sub->callid); 02921 req->data.stopmedia.passThruPartyId = htolel(sub->callid); 02922 transmit_response(s, req); 02923 02924 transmit_lamp_indication(s, STIMULUS_LINE, l->instance, SKINNY_LAMP_BLINK); 02925 sub->onhold = 1; 02926 return 1; 02927 }
static int skinny_indicate | ( | struct ast_channel * | ast, | |
int | ind, | |||
const void * | data, | |||
size_t | datalen | |||
) | [static] |
Definition at line 2724 of file chan_skinny.c.
References ast_channel::_state, skinny_subchannel::alreadygone, AST_CONTROL_BUSY, AST_CONTROL_CONGESTION, AST_CONTROL_HOLD, AST_CONTROL_PROCEEDING, AST_CONTROL_PROGRESS, AST_CONTROL_RINGING, AST_CONTROL_UNHOLD, ast_log(), AST_MAX_EXTENSION, ast_moh_start(), ast_moh_stop(), AST_SOFTHANGUP_DEV, ast_softhangup_nolock(), AST_STATE_UP, ast_verbose(), skinny_subchannel::callid, ast_channel::cid, ast_callerid::cid_name, ast_callerid::cid_num, control2str(), ast_channel::exten, exten, skinny_line::instance, LOG_NOTICE, LOG_WARNING, ast_channel::macroexten, skinny_line::mohinterpret, skinny_subchannel::outgoing, skinny_line::parent, skinny_subchannel::parent, skinny_subchannel::progress, skinny_subchannel::ringing, s, S_OR, skinny_device::session, SKINNY_ALERT, SKINNY_BUSY, SKINNY_BUSYTONE, SKINNY_CONGESTION, SKINNY_PROGRESS, SKINNY_REORDER, SKINNY_RINGOUT, SKINNY_SILENCE, ast_channel::tech_pvt, transmit_callinfo(), transmit_callstate(), transmit_dialednumber(), transmit_displaypromptstatus(), transmit_tone(), and VERBOSE_PREFIX_3.
02725 { 02726 struct skinny_subchannel *sub = ast->tech_pvt; 02727 struct skinny_line *l = sub->parent; 02728 struct skinny_device *d = l->parent; 02729 struct skinnysession *s = d->session; 02730 char exten[AST_MAX_EXTENSION] = ""; 02731 02732 if (!s) { 02733 ast_log(LOG_NOTICE, "Asked to indicate '%s' condition on channel %s, but session does not exist.\n", control2str(ind), ast->name); 02734 return -1; 02735 } 02736 02737 ast_copy_string(exten, S_OR(ast->macroexten, ast->exten), sizeof(exten)); 02738 02739 if (skinnydebug) 02740 ast_verbose(VERBOSE_PREFIX_3 "Asked to indicate '%s' condition on channel %s\n", control2str(ind), ast->name); 02741 switch(ind) { 02742 case AST_CONTROL_RINGING: 02743 if (ast->_state != AST_STATE_UP) { 02744 if (!sub->progress) { 02745 transmit_tone(s, SKINNY_ALERT, l->instance, sub->callid); 02746 transmit_callstate(s, l->instance, SKINNY_RINGOUT, sub->callid); 02747 transmit_dialednumber(s, exten, l->instance, sub->callid); 02748 transmit_displaypromptstatus(s, "Ring Out", 0, l->instance, sub->callid); 02749 transmit_callinfo(s, ast->cid.cid_name, ast->cid.cid_num, exten, exten, l->instance, sub->callid, 2); /* 2 = outgoing from phone */ 02750 sub->ringing = 1; 02751 break; 02752 } 02753 } 02754 return -1; 02755 case AST_CONTROL_BUSY: 02756 if (ast->_state != AST_STATE_UP) { 02757 transmit_tone(s, SKINNY_BUSYTONE, l->instance, sub->callid); 02758 transmit_callstate(s, l->instance, SKINNY_BUSY, sub->callid); 02759 sub->alreadygone = 1; 02760 ast_softhangup_nolock(ast, AST_SOFTHANGUP_DEV); 02761 break; 02762 } 02763 return -1; 02764 case AST_CONTROL_CONGESTION: 02765 if (ast->_state != AST_STATE_UP) { 02766 transmit_tone(s, SKINNY_REORDER, l->instance, sub->callid); 02767 transmit_callstate(s, l->instance, SKINNY_CONGESTION, sub->callid); 02768 sub->alreadygone = 1; 02769 ast_softhangup_nolock(ast, AST_SOFTHANGUP_DEV); 02770 break; 02771 } 02772 return -1; 02773 case AST_CONTROL_PROGRESS: 02774 if ((ast->_state != AST_STATE_UP) && !sub->progress && !sub->outgoing) { 02775 transmit_tone(s, SKINNY_ALERT, l->instance, sub->callid); 02776 transmit_callstate(s, l->instance, SKINNY_PROGRESS, sub->callid); 02777 transmit_displaypromptstatus(s, "Call Progress", 0, l->instance, sub->callid); 02778 transmit_callinfo(s, ast->cid.cid_name, ast->cid.cid_num, exten, exten, l->instance, sub->callid, 2); /* 2 = outgoing from phone */ 02779 sub->progress = 1; 02780 break; 02781 } 02782 return -1; 02783 case -1: 02784 transmit_tone(s, SKINNY_SILENCE, l->instance, sub->callid); 02785 break; 02786 case AST_CONTROL_HOLD: 02787 ast_moh_start(ast, data, l->mohinterpret); 02788 break; 02789 case AST_CONTROL_UNHOLD: 02790 ast_moh_stop(ast); 02791 break; 02792 case AST_CONTROL_PROCEEDING: 02793 break; 02794 default: 02795 ast_log(LOG_WARNING, "Don't know how to indicate condition %d\n", ind); 02796 return -1; 02797 } 02798 return 0; 02799 }
static struct ast_channel* skinny_new | ( | struct skinny_line * | l, | |
int | state | |||
) | [static, read] |
Definition at line 2801 of file chan_skinny.c.
References skinny_line::accountcode, ast_channel::adsicpe, ast_channel::amaflags, skinny_line::amaflags, AST_ADSI_UNAVAILABLE, ast_best_codec(), ast_calloc, ast_channel_alloc(), ast_hangup(), ast_jb_configure(), ast_log(), ast_module_ref(), ast_mutex_init(), ast_pbx_start(), ast_rtp_fd(), AST_STATE_DOWN, AST_STATE_RING, ast_strdup, ast_string_field_set, ast_strlen_zero(), ast_verbose(), skinny_line::call_forward, skinny_line::callgroup, ast_channel::callgroup, skinny_subchannel::callid, skinny_line::capability, ast_channel::cid, ast_callerid::cid_ani, skinny_line::cid_name, skinny_line::cid_num, ast_channel::context, skinny_line::context, skinny_subchannel::cxmode, ast_channel::exten, skinny_line::exten, ast_channel::fds, fmt, global_jbconf, skinny_line::instance, skinny_line::language, skinny_device::lastcallreference, skinny_device::lastlineinstance, skinny_subchannel::lock, LOG_WARNING, skinny_device::name, skinny_line::name, skinny_line::nat, skinny_subchannel::nat, ast_channel::nativeformats, skinny_subchannel::next, skinny_subchannel::onhold, skinny_subchannel::owner, skinny_subchannel::parent, skinny_line::parent, skinny_line::pickupgroup, ast_channel::pickupgroup, ast_channel::priority, ast_channel::rawreadformat, ast_channel::rawwriteformat, ast_channel::readformat, ast_channel::rings, skinny_subchannel::rtp, SKINNY_CX_INACTIVE, skinny_line::sub, ast_channel::tech, ast_channel::tech_pvt, and ast_channel::writeformat.
Referenced by handle_enbloc_call_message(), handle_offhook_message(), handle_soft_key_event_message(), handle_stimulus_message(), and skinny_request().
02802 { 02803 struct ast_channel *tmp; 02804 struct skinny_subchannel *sub; 02805 struct skinny_device *d = l->parent; 02806 int fmt; 02807 02808 tmp = ast_channel_alloc(1, state, l->cid_num, l->cid_name, l->accountcode, l->exten, l->context, l->amaflags, "Skinny/%s@%s-%d", l->name, d->name, callnums); 02809 if (!tmp) { 02810 ast_log(LOG_WARNING, "Unable to allocate channel structure\n"); 02811 return NULL; 02812 } else { 02813 sub = ast_calloc(1, sizeof(struct skinny_subchannel)); 02814 if (!sub) { 02815 ast_log(LOG_WARNING, "Unable to allocate Skinny subchannel\n"); 02816 return NULL; 02817 } else { 02818 ast_mutex_init(&sub->lock); 02819 02820 sub->owner = tmp; 02821 sub->callid = callnums++; 02822 d->lastlineinstance = l->instance; 02823 d->lastcallreference = sub->callid; 02824 sub->cxmode = SKINNY_CX_INACTIVE; 02825 sub->nat = l->nat; 02826 sub->parent = l; 02827 sub->onhold = 0; 02828 02829 sub->next = l->sub; 02830 l->sub = sub; 02831 } 02832 tmp->tech = &skinny_tech; 02833 tmp->tech_pvt = sub; 02834 tmp->nativeformats = l->capability; 02835 if (!tmp->nativeformats) 02836 tmp->nativeformats = default_capability; 02837 fmt = ast_best_codec(tmp->nativeformats); 02838 if (skinnydebug) 02839 ast_verbose("skinny_new: tmp->nativeformats=%d fmt=%d\n", tmp->nativeformats, fmt); 02840 if (sub->rtp) { 02841 tmp->fds[0] = ast_rtp_fd(sub->rtp); 02842 } 02843 if (state == AST_STATE_RING) { 02844 tmp->rings = 1; 02845 } 02846 tmp->writeformat = fmt; 02847 tmp->rawwriteformat = fmt; 02848 tmp->readformat = fmt; 02849 tmp->rawreadformat = fmt; 02850 if (!ast_strlen_zero(l->language)) 02851 ast_string_field_set(tmp, language, l->language); 02852 if (!ast_strlen_zero(l->accountcode)) 02853 ast_string_field_set(tmp, accountcode, l->accountcode); 02854 if (l->amaflags) 02855 tmp->amaflags = l->amaflags; 02856 02857 ast_module_ref(ast_module_info->self); 02858 tmp->callgroup = l->callgroup; 02859 tmp->pickupgroup = l->pickupgroup; 02860 ast_string_field_set(tmp, call_forward, l->call_forward); 02861 ast_copy_string(tmp->context, l->context, sizeof(tmp->context)); 02862 ast_copy_string(tmp->exten, l->exten, sizeof(tmp->exten)); 02863 02864 /* Don't use ast_set_callerid() here because it will 02865 * generate a needless NewCallerID event */ 02866 tmp->cid.cid_ani = ast_strdup(l->cid_num); 02867 02868 tmp->priority = 1; 02869 tmp->adsicpe = AST_ADSI_UNAVAILABLE; 02870 02871 if (sub->rtp) 02872 ast_jb_configure(tmp, &global_jbconf); 02873 02874 if (state != AST_STATE_DOWN) { 02875 if (ast_pbx_start(tmp)) { 02876 ast_log(LOG_WARNING, "Unable to start PBX on %s\n", tmp->name); 02877 ast_hangup(tmp); 02878 tmp = NULL; 02879 } 02880 } 02881 } 02882 return tmp; 02883 }
static void* skinny_newcall | ( | void * | data | ) | [static] |
Definition at line 2307 of file chan_skinny.c.
References ast_log(), ast_pbx_run(), ast_set_callerid(), ast_setstate(), AST_STATE_RING, skinny_subchannel::callid, ast_channel::cid, ast_callerid::cid_ani, skinny_line::cid_name, skinny_line::cid_num, ast_channel::exten, skinny_line::hidecallerid, skinny_line::instance, skinny_line::lastnumberdialed, LOG_WARNING, skinny_line::parent, skinny_subchannel::parent, s, skinny_device::session, SKINNY_REORDER, ast_channel::tech_pvt, and transmit_tone().
Referenced by handle_enbloc_call_message(), handle_soft_key_event_message(), handle_stimulus_message(), and skinny_ss().
02308 { 02309 struct ast_channel *c = data; 02310 struct skinny_subchannel *sub = c->tech_pvt; 02311 struct skinny_line *l = sub->parent; 02312 struct skinny_device *d = l->parent; 02313 struct skinnysession *s = d->session; 02314 int res = 0; 02315 02316 ast_copy_string(l->lastnumberdialed, c->exten, sizeof(l->lastnumberdialed)); 02317 ast_set_callerid(c, 02318 l->hidecallerid ? "" : l->cid_num, 02319 l->hidecallerid ? "" : l->cid_name, 02320 c->cid.cid_ani ? NULL : l->cid_num); 02321 ast_setstate(c, AST_STATE_RING); 02322 res = ast_pbx_run(c); 02323 if (res) { 02324 ast_log(LOG_WARNING, "PBX exited non-zero\n"); 02325 transmit_tone(s, SKINNY_REORDER, l->instance, sub->callid); 02326 } 02327 return NULL; 02328 }
static int skinny_no_debug | ( | int | fd, | |
int | argc, | |||
char * | argv[] | |||
) | [static] |
Definition at line 1842 of file chan_skinny.c.
References ast_cli(), RESULT_SHOWUSAGE, and RESULT_SUCCESS.
01843 { 01844 if (argc != 4) { 01845 return RESULT_SHOWUSAGE; 01846 } 01847 skinnydebug = 0; 01848 ast_cli(fd, "Skinny Debugging Disabled\n"); 01849 return RESULT_SUCCESS; 01850 }
static struct ast_frame * skinny_read | ( | struct ast_channel * | ast | ) | [static, read] |
Definition at line 2606 of file chan_skinny.c.
References ast_mutex_lock(), ast_mutex_unlock(), skinny_subchannel::lock, skinny_rtp_read(), and ast_channel::tech_pvt.
02607 { 02608 struct ast_frame *fr; 02609 struct skinny_subchannel *sub = ast->tech_pvt; 02610 ast_mutex_lock(&sub->lock); 02611 fr = skinny_rtp_read(sub); 02612 ast_mutex_unlock(&sub->lock); 02613 return fr; 02614 }
static int skinny_register | ( | struct skinny_req * | req, | |
struct skinnysession * | s | |||
) | [static] |
Definition at line 1385 of file chan_skinny.c.
References __ourip, ast_apply_ha(), ast_log(), ast_mutex_lock(), ast_mutex_unlock(), ast_strlen_zero(), skinny_req::data, skinnysession::device, devices, skinnysession::fd, skinny_device::ha, skinny_device::id, letohl, LOG_WARNING, register_message::name, skinny_device::next, skinny_device::ourip, skinny_data::reg, skinny_device::registered, skinny_device::session, skinnysession::sin, register_message::type, skinny_device::type, and skinny_device::version_id.
Referenced by handle_register_message().
01386 { 01387 struct skinny_device *d; 01388 struct sockaddr_in sin; 01389 socklen_t slen; 01390 01391 ast_mutex_lock(&devicelock); 01392 for (d = devices; d; d = d->next) { 01393 if (!strcasecmp(req->data.reg.name, d->id) 01394 && ast_apply_ha(d->ha, &(s->sin))) { 01395 s->device = d; 01396 d->type = letohl(req->data.reg.type); 01397 if (ast_strlen_zero(d->version_id)) { 01398 ast_copy_string(d->version_id, version_id, sizeof(d->version_id)); 01399 } 01400 d->registered = 1; 01401 d->session = s; 01402 01403 slen = sizeof(sin); 01404 if (getsockname(s->fd, (struct sockaddr *)&sin, &slen)) { 01405 ast_log(LOG_WARNING, "Cannot get socket name\n"); 01406 sin.sin_addr = __ourip; 01407 } 01408 d->ourip = sin.sin_addr; 01409 break; 01410 } 01411 } 01412 ast_mutex_unlock(&devicelock); 01413 if (!d) { 01414 return 0; 01415 } 01416 return 1; 01417 }
static struct skinny_req* skinny_req_parse | ( | struct skinnysession * | s | ) | [static, read] |
Definition at line 4431 of file chan_skinny.c.
References ast_calloc, ast_log(), ast_mutex_lock(), ast_mutex_unlock(), skinny_req::data, skinny_req::e, skinnysession::fd, free, skinnysession::inbuf, letohl, skinnysession::lock, LOG_ERROR, and SKINNY_MAX_PACKET.
Referenced by skinny_session().
04432 { 04433 struct skinny_req *req; 04434 04435 if (!(req = ast_calloc(1, SKINNY_MAX_PACKET))) 04436 return NULL; 04437 04438 ast_mutex_lock(&s->lock); 04439 memcpy(req, s->inbuf, skinny_header_size); 04440 memcpy(&req->data, s->inbuf+skinny_header_size, letohl(*(int*)(s->inbuf))-4); 04441 04442 ast_mutex_unlock(&s->lock); 04443 04444 if (letohl(req->e) < 0) { 04445 ast_log(LOG_ERROR, "Event Message is NULL from socket %d, This is bad\n", s->fd); 04446 free(req); 04447 return NULL; 04448 } 04449 04450 return req; 04451 }
static struct ast_channel * skinny_request | ( | const char * | type, | |
int | format, | |||
void * | data, | |||
int * | cause | |||
) | [static, read] |
Definition at line 4592 of file chan_skinny.c.
References AST_FORMAT_MAX_AUDIO, ast_log(), AST_STATE_DOWN, ast_strlen_zero(), ast_verbose(), find_line_by_name(), LOG_NOTICE, LOG_WARNING, option_verbose, restart_monitor(), skinny_new(), and VERBOSE_PREFIX_3.
04593 { 04594 int oldformat; 04595 04596 struct skinny_line *l; 04597 struct ast_channel *tmpc = NULL; 04598 char tmp[256]; 04599 char *dest = data; 04600 04601 oldformat = format; 04602 04603 if (!(format &= ((AST_FORMAT_MAX_AUDIO << 1) - 1))) { 04604 ast_log(LOG_NOTICE, "Asked to get a channel of unsupported format '%d'\n", format); 04605 return NULL; 04606 } 04607 04608 ast_copy_string(tmp, dest, sizeof(tmp)); 04609 if (ast_strlen_zero(tmp)) { 04610 ast_log(LOG_NOTICE, "Skinny channels require a device\n"); 04611 return NULL; 04612 } 04613 l = find_line_by_name(tmp); 04614 if (!l) { 04615 ast_log(LOG_NOTICE, "No available lines on: %s\n", dest); 04616 return NULL; 04617 } 04618 if (option_verbose > 2) { 04619 ast_verbose(VERBOSE_PREFIX_3 "skinny_request(%s)\n", tmp); 04620 } 04621 tmpc = skinny_new(l, AST_STATE_DOWN); 04622 if (!tmpc) { 04623 ast_log(LOG_WARNING, "Unable to make channel for '%s'\n", tmp); 04624 } 04625 restart_monitor(); 04626 return tmpc; 04627 }
static int skinny_reset_device | ( | int | fd, | |
int | argc, | |||
char * | argv[] | |||
) | [static] |
Definition at line 1870 of file chan_skinny.c.
References ast_mutex_lock(), ast_mutex_unlock(), ast_verbose(), skinny_req::data, devices, skinny_device::id, skinny_device::next, option_verbose, req_alloc(), skinny_data::reset, RESET_MESSAGE, reset_message::resetType, RESULT_SHOWUSAGE, RESULT_SUCCESS, skinny_device::session, transmit_response(), and VERBOSE_PREFIX_3.
01871 { 01872 struct skinny_device *d; 01873 struct skinny_req *req; 01874 01875 if (argc < 3 || argc > 4) { 01876 return RESULT_SHOWUSAGE; 01877 } 01878 ast_mutex_lock(&devicelock); 01879 01880 for (d = devices; d; d = d->next) { 01881 int fullrestart = 0; 01882 if (!strcasecmp(argv[2], d->id) || !strcasecmp(argv[2], "all")) { 01883 if (!(d->session)) 01884 continue; 01885 01886 if (!(req = req_alloc(sizeof(struct reset_message), RESET_MESSAGE))) 01887 continue; 01888 01889 if (argc == 4 && !strcasecmp(argv[3], "restart")) 01890 fullrestart = 1; 01891 01892 if (fullrestart) 01893 req->data.reset.resetType = 2; 01894 else 01895 req->data.reset.resetType = 1; 01896 01897 if (option_verbose > 2) 01898 ast_verbose(VERBOSE_PREFIX_3 "%s device %s.\n", (fullrestart) ? "Restarting" : "Resetting", d->id); 01899 transmit_response(d->session, req); 01900 } 01901 } 01902 ast_mutex_unlock(&devicelock); 01903 return RESULT_SUCCESS; 01904 }
static struct ast_frame* skinny_rtp_read | ( | struct skinny_subchannel * | sub | ) | [static, read] |
Definition at line 2559 of file chan_skinny.c.
References AST_FRAME_VOICE, ast_log(), ast_null_frame, ast_rtcp_read(), ast_rtp_read(), ast_set_read_format(), ast_set_write_format(), ast_udptl_read(), f, ast_channel::fdno, ast_frame::frametype, LOG_DEBUG, ast_channel::nativeformats, skinny_subchannel::owner, ast_channel::readformat, skinny_subchannel::rtp, ast_frame::subclass, skinny_subchannel::vrtp, and ast_channel::writeformat.
Referenced by skinny_read().
02560 { 02561 struct ast_channel *ast = sub->owner; 02562 struct ast_frame *f; 02563 02564 if (!sub->rtp) { 02565 /* We have no RTP allocated for this channel */ 02566 return &ast_null_frame; 02567 } 02568 02569 switch(ast->fdno) { 02570 case 0: 02571 f = ast_rtp_read(sub->rtp); /* RTP Audio */ 02572 break; 02573 case 1: 02574 f = ast_rtcp_read(sub->rtp); /* RTCP Control Channel */ 02575 break; 02576 case 2: 02577 f = ast_rtp_read(sub->vrtp); /* RTP Video */ 02578 break; 02579 case 3: 02580 f = ast_rtcp_read(sub->vrtp); /* RTCP Control Channel for video */ 02581 break; 02582 #if 0 02583 case 5: 02584 /* Not yet supported */ 02585 f = ast_udptl_read(sub->udptl); /* UDPTL for T.38 */ 02586 break; 02587 #endif 02588 default: 02589 f = &ast_null_frame; 02590 } 02591 02592 if (ast) { 02593 /* We already hold the channel lock */ 02594 if (f->frametype == AST_FRAME_VOICE) { 02595 if (f->subclass != ast->nativeformats) { 02596 ast_log(LOG_DEBUG, "Oooh, format changed to %d\n", f->subclass); 02597 ast->nativeformats = f->subclass; 02598 ast_set_read_format(ast, ast->readformat); 02599 ast_set_write_format(ast, ast->writeformat); 02600 } 02601 } 02602 } 02603 return f; 02604 }
static int skinny_senddigit_begin | ( | struct ast_channel * | ast, | |
char | digit | |||
) | [static] |
static int skinny_senddigit_end | ( | struct ast_channel * | ast, | |
char | digit, | |||
unsigned int | duration | |||
) | [static] |
Definition at line 2661 of file chan_skinny.c.
References skinny_subchannel::callid, skinny_line::instance, skinny_line::parent, skinny_subchannel::parent, skinny_device::session, ast_channel::tech_pvt, and transmit_tone().
02662 { 02663 #if 0 02664 struct skinny_subchannel *sub = ast->tech_pvt; 02665 struct skinny_line *l = sub->parent; 02666 struct skinny_device *d = l->parent; 02667 int tmp; 02668 /* not right */ 02669 sprintf(tmp, "%d", digit); 02670 transmit_tone(d->session, digit, l->instance, sub->callid); 02671 #endif 02672 return -1; /* Stop inband indications */ 02673 }
static void* skinny_session | ( | void * | data | ) | [static] |
Definition at line 4453 of file chan_skinny.c.
References ast_inet_ntoa(), ast_log(), ast_verbose(), destroy_session(), errno, get_input(), handle_message(), LOG_NOTICE, option_verbose, skinny_req::res, s, skinnysession::sin, skinny_req_parse(), and VERBOSE_PREFIX_3.
Referenced by accept_thread().
04454 { 04455 int res; 04456 struct skinny_req *req; 04457 struct skinnysession *s = data; 04458 04459 if (option_verbose > 2) 04460 ast_verbose(VERBOSE_PREFIX_3 "Starting Skinny session from %s\n", ast_inet_ntoa(s->sin.sin_addr)); 04461 04462 for (;;) { 04463 res = get_input(s); 04464 if (res < 0) { 04465 break; 04466 } 04467 04468 if (res > 0) 04469 { 04470 if (!(req = skinny_req_parse(s))) { 04471 destroy_session(s); 04472 return NULL; 04473 } 04474 04475 res = handle_message(req, s); 04476 if (res < 0) { 04477 destroy_session(s); 04478 return NULL; 04479 } 04480 } 04481 } 04482 ast_log(LOG_NOTICE, "Skinny Session returned: %s\n", strerror(errno)); 04483 04484 if (s) 04485 destroy_session(s); 04486 04487 return 0; 04488 }
static int skinny_set_rtp_peer | ( | struct ast_channel * | c, | |
struct ast_rtp * | rtp, | |||
struct ast_rtp * | vrtp, | |||
int | codecs, | |||
int | nat_active | |||
) | [static] |
Definition at line 1814 of file chan_skinny.c.
References ast_channel::tech_pvt.
01815 { 01816 struct skinny_subchannel *sub; 01817 sub = c->tech_pvt; 01818 if (sub) { 01819 /* transmit_modify_with_sdp(sub, rtp); @@FIXME@@ if needed */ 01820 return 0; 01821 } 01822 return -1; 01823 }
static int skinny_show_devices | ( | int | fd, | |
int | argc, | |||
char * | argv[] | |||
) | [static] |
Definition at line 1977 of file chan_skinny.c.
References ast_cli(), ast_inet_ntoa(), ast_mutex_lock(), ast_mutex_unlock(), device2str(), devices, skinny_device::id, skinny_device::lines, skinny_device::name, skinny_line::next, skinny_device::next, skinny_device::registered, RESULT_SHOWUSAGE, RESULT_SUCCESS, skinny_device::session, skinnysession::sin, and skinny_device::type.
01978 { 01979 struct skinny_device *d; 01980 struct skinny_line *l; 01981 int numlines = 0; 01982 01983 if (argc != 3) { 01984 return RESULT_SHOWUSAGE; 01985 } 01986 ast_mutex_lock(&devicelock); 01987 01988 ast_cli(fd, "Name DeviceId IP Type R NL\n"); 01989 ast_cli(fd, "-------------------- ---------------- --------------- --------------- - --\n"); 01990 for (d = devices; d; d = d->next) { 01991 numlines = 0; 01992 for (l = d->lines; l; l = l->next) { 01993 numlines++; 01994 } 01995 01996 ast_cli(fd, "%-20s %-16s %-15s %-15s %c %2d\n", 01997 d->name, 01998 d->id, 01999 d->session?ast_inet_ntoa(d->session->sin.sin_addr):"", 02000 device2str(d->type), 02001 d->registered?'Y':'N', 02002 numlines); 02003 } 02004 ast_mutex_unlock(&devicelock); 02005 return RESULT_SUCCESS; 02006 }
static int skinny_show_lines | ( | int | fd, | |
int | argc, | |||
char * | argv[] | |||
) | [static] |
Definition at line 2008 of file chan_skinny.c.
References ast_cli(), ast_mutex_lock(), ast_mutex_unlock(), devices, skinny_line::instance, skinny_line::label, skinny_device::lines, skinny_line::name, skinny_device::name, skinny_line::next, skinny_device::next, RESULT_SHOWUSAGE, and RESULT_SUCCESS.
02009 { 02010 struct skinny_device *d; 02011 struct skinny_line *l; 02012 02013 if (argc != 3) { 02014 return RESULT_SHOWUSAGE; 02015 } 02016 ast_mutex_lock(&devicelock); 02017 02018 ast_cli(fd, "Device Name Instance Name Label \n"); 02019 ast_cli(fd, "-------------------- -------- -------------------- --------------------\n"); 02020 for (d = devices; d; d = d->next) { 02021 for (l = d->lines; l; l = l->next) { 02022 ast_cli(fd, "%-20s %8d %-20s %-20s\n", 02023 d->name, 02024 l->instance, 02025 l->name, 02026 l->label); 02027 } 02028 } 02029 02030 ast_mutex_unlock(&devicelock); 02031 return RESULT_SUCCESS; 02032 }
static void* skinny_ss | ( | void * | data | ) | [static] |
Definition at line 2330 of file chan_skinny.c.
References ast_channel::_state, ast_canmatch_extension(), ast_exists_extension(), ast_hangup(), ast_ignore_pattern(), ast_indicate(), ast_log(), ast_matchmore_extension(), AST_MAX_EXTENSION, ast_safe_sleep(), AST_STATE_UP, ast_strlen_zero(), ast_verbose(), skinny_line::call_forward, skinny_subchannel::callid, ast_channel::cid, ast_callerid::cid_num, skinny_line::cid_num, ast_channel::context, ast_channel::exten, skinny_device::exten, skinny_line::instance, skinny_line::lastnumberdialed, len, LOG_DEBUG, LOG_WARNING, skinny_device::name, skinny_line::name, option_verbose, skinny_subchannel::owner, skinny_line::parent, skinny_subchannel::parent, s, skinny_device::session, SKINNY_DIALTONE, skinny_newcall(), SKINNY_REORDER, SKINNY_SILENCE, ast_channel::tech_pvt, transmit_tone(), and VERBOSE_PREFIX_3.
Referenced by handle_offhook_message(), handle_soft_key_event_message(), and handle_stimulus_message().
02331 { 02332 struct ast_channel *c = data; 02333 struct skinny_subchannel *sub = c->tech_pvt; 02334 struct skinny_line *l = sub->parent; 02335 struct skinny_device *d = l->parent; 02336 struct skinnysession *s = d->session; 02337 int len = 0; 02338 int timeout = firstdigittimeout; 02339 int res = 0; 02340 int getforward=0; 02341 int loop_pause = 100; 02342 02343 if (option_verbose > 2) 02344 ast_verbose( VERBOSE_PREFIX_3 "Starting simple switch on '%s@%s'\n", l->name, d->name); 02345 len = strlen(d->exten); 02346 02347 while (len < AST_MAX_EXTENSION-1) { 02348 02349 res = 1; /* Assume we will get a digit */ 02350 while (strlen(d->exten) == len) { 02351 ast_safe_sleep(c, loop_pause); 02352 timeout -= loop_pause; 02353 if (timeout <= 0){ 02354 res = 0; 02355 break; 02356 } 02357 } 02358 02359 len = strlen(d->exten); 02360 02361 if (!ast_ignore_pattern(c->context, d->exten)) { 02362 transmit_tone(s, SKINNY_SILENCE, l->instance, sub->callid); 02363 } 02364 02365 if (ast_exists_extension(c, c->context, d->exten, 1, l->cid_num)) { 02366 if (!res || !ast_matchmore_extension(c, c->context, d->exten, 1, l->cid_num)) { 02367 if (getforward) { 02368 /* Record this as the forwarding extension */ 02369 ast_copy_string(l->call_forward, d->exten, sizeof(l->call_forward)); 02370 if (option_verbose > 2) 02371 ast_verbose(VERBOSE_PREFIX_3 "Setting call forward to '%s' on channel %s\n", 02372 l->call_forward, c->name); 02373 transmit_tone(s, SKINNY_DIALTONE, l->instance, sub->callid); 02374 if (res) { 02375 break; 02376 } 02377 ast_safe_sleep(c, 500); 02378 ast_indicate(c, -1); 02379 ast_safe_sleep(c, 1000); 02380 memset(d->exten, 0, sizeof(d->exten)); 02381 transmit_tone(s, SKINNY_DIALTONE, l->instance, sub->callid); 02382 len = 0; 02383 getforward = 0; 02384 } else { 02385 ast_copy_string(c->exten, d->exten, sizeof(c->exten)); 02386 ast_copy_string(l->lastnumberdialed, d->exten, sizeof(l->lastnumberdialed)); 02387 memset (d->exten, 0, sizeof(d->exten)); 02388 skinny_newcall(c); 02389 return NULL; 02390 } 02391 } else { 02392 /* It's a match, but they just typed a digit, and there is an ambiguous match, 02393 so just set the timeout to matchdigittimeout and wait some more */ 02394 timeout = matchdigittimeout; 02395 } 02396 } else if (res == 0) { 02397 ast_log(LOG_DEBUG, "Not enough digits (and no ambiguous match)...\n"); 02398 memset(d->exten, 0, sizeof(d->exten)); 02399 transmit_tone(s, SKINNY_REORDER, l->instance, sub->callid); 02400 if (sub->owner && sub->owner->_state != AST_STATE_UP) { 02401 ast_indicate(c, -1); 02402 ast_hangup(c); 02403 } 02404 return NULL; 02405 } else if (!ast_canmatch_extension(c, c->context, d->exten, 1, c->cid.cid_num) && 02406 ((d->exten[0] != '*') || (!ast_strlen_zero(d->exten) > 2))) { 02407 ast_log(LOG_WARNING, "Can't match [%s] from '%s' in context %s\n", d->exten, c->cid.cid_num ? c->cid.cid_num : "<Unknown Caller>", c->context); 02408 memset(d->exten, 0, sizeof(d->exten)); 02409 transmit_tone(s, SKINNY_REORDER, l->instance, sub->callid); 02410 /* hang out for 3 seconds to let congestion play */ 02411 ast_safe_sleep(c, 3000); 02412 break; 02413 } 02414 if (!timeout) { 02415 timeout = gendigittimeout; 02416 } 02417 if (len && !ast_ignore_pattern(c->context, d->exten)) { 02418 ast_indicate(c, -1); 02419 } 02420 } 02421 if (c) 02422 ast_hangup(c); 02423 02424 memset(d->exten, 0, sizeof(d->exten)); 02425 return NULL; 02426 }
static int skinny_unhold | ( | struct skinny_subchannel * | sub | ) | [static] |
Definition at line 2929 of file chan_skinny.c.
References ACTIVATE_CALL_PLANE_MESSAGE, skinny_data::activatecallplane, AST_CONTROL_UNHOLD, ast_queue_control(), ast_verbose(), skinny_req::data, htolel, skinny_line::instance, activate_call_plane_message::lineInstance, skinny_subchannel::onhold, skinny_subchannel::owner, skinny_line::parent, skinny_subchannel::parent, req_alloc(), s, skinny_device::session, SKINNY_LAMP_ON, STIMULUS_LINE, transmit_connect(), transmit_lamp_indication(), and transmit_response().
Referenced by handle_soft_key_event_message(), and handle_stimulus_message().
02930 { 02931 struct skinny_line *l = sub->parent; 02932 struct skinny_device *d = l->parent; 02933 struct skinnysession *s = d->session; 02934 struct skinny_req *req; 02935 02936 /* Don't try to unhold a channel that doesn't exist */ 02937 if (!sub || !sub->owner) 02938 return 0; 02939 02940 /* Channel is on hold, so we will unhold */ 02941 if (skinnydebug) 02942 ast_verbose("Taking off Hold(%d)\n", l->instance); 02943 02944 ast_queue_control(sub->owner, AST_CONTROL_UNHOLD); 02945 02946 if (!(req = req_alloc(sizeof(struct activate_call_plane_message), ACTIVATE_CALL_PLANE_MESSAGE))) 02947 return 0; 02948 02949 req->data.activatecallplane.lineInstance = htolel(l->instance); 02950 transmit_response(s, req); 02951 02952 transmit_connect(s, sub); 02953 transmit_lamp_indication(s, STIMULUS_LINE, l->instance, SKINNY_LAMP_ON); 02954 sub->onhold = 0; 02955 return 1; 02956 }
static int skinny_unregister | ( | struct skinny_req * | req, | |
struct skinnysession * | s | |||
) | [static] |
Definition at line 1419 of file chan_skinny.c.
References skinnysession::device, skinny_device::registered, and skinny_device::session.
Referenced by get_input(), handle_unregister_message(), and transmit_response().
01420 { 01421 struct skinny_device *d; 01422 01423 d = s->device; 01424 01425 if (d) { 01426 d->session = NULL; 01427 d->registered = 0; 01428 } 01429 01430 return -1; /* main loop will destroy the session */ 01431 }
static int skinny_write | ( | struct ast_channel * | ast, | |
struct ast_frame * | frame | |||
) | [static] |
Definition at line 2616 of file chan_skinny.c.
References AST_FRAME_IMAGE, AST_FRAME_VOICE, ast_log(), ast_mutex_lock(), ast_mutex_unlock(), ast_rtp_write(), ast_frame::frametype, skinny_subchannel::lock, LOG_WARNING, ast_channel::nativeformats, ast_channel::readformat, skinny_subchannel::rtp, ast_frame::subclass, ast_channel::tech_pvt, and ast_channel::writeformat.
02617 { 02618 struct skinny_subchannel *sub = ast->tech_pvt; 02619 int res = 0; 02620 if (frame->frametype != AST_FRAME_VOICE) { 02621 if (frame->frametype == AST_FRAME_IMAGE) { 02622 return 0; 02623 } else { 02624 ast_log(LOG_WARNING, "Can't send %d type frames with skinny_write\n", frame->frametype); 02625 return 0; 02626 } 02627 } else { 02628 if (!(frame->subclass & ast->nativeformats)) { 02629 ast_log(LOG_WARNING, "Asked to transmit frame type %d, while native formats is %d (read/write = %d/%d)\n", 02630 frame->subclass, ast->nativeformats, ast->readformat, ast->writeformat); 02631 return -1; 02632 } 02633 } 02634 if (sub) { 02635 ast_mutex_lock(&sub->lock); 02636 if (sub->rtp) { 02637 res = ast_rtp_write(sub->rtp, frame); 02638 } 02639 ast_mutex_unlock(&sub->lock); 02640 } 02641 return res; 02642 }
static void start_rtp | ( | struct skinny_subchannel * | sub | ) | [static] |
Definition at line 2272 of file chan_skinny.c.
References ast_mutex_lock(), ast_mutex_unlock(), ast_rtcp_fd(), ast_rtp_codec_setpref(), ast_rtp_fd(), ast_rtp_new_with_bindaddr(), ast_rtp_setnat(), bindaddr, ast_channel::fds, skinny_subchannel::lock, skinny_line::nat, skinny_subchannel::owner, skinny_line::parent, skinny_subchannel::parent, skinny_line::prefs, skinny_subchannel::rtp, skinny_device::session, transmit_connect(), and skinny_subchannel::vrtp.
02273 { 02274 struct skinny_line *l = sub->parent; 02275 struct skinny_device *d = l->parent; 02276 int hasvideo = 0; 02277 02278 ast_mutex_lock(&sub->lock); 02279 /* Allocate the RTP */ 02280 sub->rtp = ast_rtp_new_with_bindaddr(sched, io, 1, 0, bindaddr.sin_addr); 02281 if (hasvideo) 02282 sub->vrtp = ast_rtp_new_with_bindaddr(sched, io, 1, 0, bindaddr.sin_addr); 02283 02284 if (sub->rtp && sub->owner) { 02285 sub->owner->fds[0] = ast_rtp_fd(sub->rtp); 02286 sub->owner->fds[1] = ast_rtcp_fd(sub->rtp); 02287 } 02288 if (hasvideo && sub->vrtp && sub->owner) { 02289 sub->owner->fds[2] = ast_rtp_fd(sub->vrtp); 02290 sub->owner->fds[3] = ast_rtcp_fd(sub->vrtp); 02291 } 02292 if (sub->rtp) { 02293 ast_rtp_setnat(sub->rtp, l->nat); 02294 } 02295 if (sub->vrtp) { 02296 ast_rtp_setnat(sub->vrtp, l->nat); 02297 } 02298 /* Set Frame packetization */ 02299 if (sub->rtp) 02300 ast_rtp_codec_setpref(sub->rtp, &l->prefs); 02301 02302 /* Create the RTP connection */ 02303 transmit_connect(d->session, sub); 02304 ast_mutex_unlock(&sub->lock); 02305 }
static void transmit_callinfo | ( | struct skinnysession * | s, | |
const char * | fromname, | |||
const char * | fromnum, | |||
const char * | toname, | |||
const char * | tonum, | |||
int | instance, | |||
int | callid, | |||
int | calltype | |||
) | [static] |
Definition at line 1495 of file chan_skinny.c.
References ast_verbose(), CALL_INFO_MESSAGE, call_info_message::calledParty, call_info_message::calledPartyName, skinny_data::callinfo, call_info_message::callingParty, call_info_message::callingPartyName, skinny_req::data, skinnysession::device, htolel, call_info_message::instance, skinny_device::name, call_info_message::reference, req_alloc(), transmit_response(), and call_info_message::type.
Referenced by skinny_answer(), skinny_call(), and skinny_indicate().
01496 { 01497 struct skinny_req *req; 01498 01499 if (!(req = req_alloc(sizeof(struct call_info_message), CALL_INFO_MESSAGE))) 01500 return; 01501 01502 if (skinnydebug) 01503 ast_verbose("Setting Callinfo to %s(%s) from %s(%s) on %s(%d)\n", fromname, fromnum, toname, tonum, s->device->name, instance); 01504 01505 if (fromname) { 01506 ast_copy_string(req->data.callinfo.callingPartyName, fromname, sizeof(req->data.callinfo.callingPartyName)); 01507 } 01508 if (fromnum) { 01509 ast_copy_string(req->data.callinfo.callingParty, fromnum, sizeof(req->data.callinfo.callingParty)); 01510 } 01511 if (toname) { 01512 ast_copy_string(req->data.callinfo.calledPartyName, toname, sizeof(req->data.callinfo.calledPartyName)); 01513 } 01514 if (tonum) { 01515 ast_copy_string(req->data.callinfo.calledParty, tonum, sizeof(req->data.callinfo.calledParty)); 01516 } 01517 req->data.callinfo.instance = htolel(instance); 01518 req->data.callinfo.reference = htolel(callid); 01519 req->data.callinfo.type = htolel(calltype); 01520 transmit_response(s, req); 01521 }
static void transmit_callstate | ( | struct skinnysession * | s, | |
int | instance, | |||
int | state, | |||
unsigned | callid | |||
) | [static] |
Definition at line 1707 of file chan_skinny.c.
References ACTIVATE_CALL_PLANE_MESSAGE, skinny_data::activatecallplane, CALL_STATE_MESSAGE, call_state_message::callReference, call_state_message::callState, skinny_data::callstate, CLOSE_RECEIVE_CHANNEL_MESSAGE, skinny_data::closereceivechannel, stop_media_transmission_message::conferenceId, close_receive_channel_message::conferenceId, skinny_req::data, htolel, KEYDEF_ONHOOK, activate_call_plane_message::lineInstance, call_state_message::lineInstance, close_receive_channel_message::partyId, stop_media_transmission_message::passThruPartyId, req_alloc(), SKINNY_OFFHOOK, SKINNY_ONHOOK, SKINNY_SPEAKEROFF, STOP_MEDIA_TRANSMISSION_MESSAGE, skinny_data::stopmedia, transmit_displaypromptstatus(), transmit_response(), transmit_selectsoftkeys(), and transmit_speaker_mode().
Referenced by handle_enbloc_call_message(), handle_offhook_message(), handle_onhook_message(), handle_soft_key_event_message(), handle_stimulus_message(), skinny_answer(), skinny_call(), skinny_hangup(), and skinny_indicate().
01708 { 01709 struct skinny_req *req; 01710 01711 if (state == SKINNY_ONHOOK) { 01712 if (!(req = req_alloc(sizeof(struct close_receive_channel_message), CLOSE_RECEIVE_CHANNEL_MESSAGE))) 01713 return; 01714 01715 req->data.closereceivechannel.conferenceId = htolel(callid); 01716 req->data.closereceivechannel.partyId = htolel(callid); 01717 transmit_response(s, req); 01718 01719 if (!(req = req_alloc(sizeof(struct stop_media_transmission_message), STOP_MEDIA_TRANSMISSION_MESSAGE))) 01720 return; 01721 01722 req->data.stopmedia.conferenceId = htolel(callid); 01723 req->data.stopmedia.passThruPartyId = htolel(callid); 01724 transmit_response(s, req); 01725 01726 transmit_speaker_mode(s, SKINNY_SPEAKEROFF); 01727 01728 transmit_displaypromptstatus(s, NULL, 0, instance, callid); 01729 } 01730 01731 if (!(req = req_alloc(sizeof(struct call_state_message), CALL_STATE_MESSAGE))) 01732 return; 01733 01734 req->data.callstate.callState = htolel(state); 01735 req->data.callstate.lineInstance = htolel(instance); 01736 req->data.callstate.callReference = htolel(callid); 01737 transmit_response(s, req); 01738 01739 if (state == SKINNY_ONHOOK) { 01740 transmit_selectsoftkeys(s, 0, 0, KEYDEF_ONHOOK); 01741 } 01742 01743 if (state == SKINNY_OFFHOOK || state == SKINNY_ONHOOK) { 01744 if (!(req = req_alloc(sizeof(struct activate_call_plane_message), ACTIVATE_CALL_PLANE_MESSAGE))) 01745 return; 01746 01747 req->data.activatecallplane.lineInstance = htolel(instance); 01748 transmit_response(s, req); 01749 } 01750 }
static void transmit_connect | ( | struct skinnysession * | s, | |
struct skinny_subchannel * | sub | |||
) | [static] |
Definition at line 1523 of file chan_skinny.c.
References ast_best_codec(), ast_codec_pref_getsize(), open_receive_channel_message::bitrate, ast_format_list::bits, skinny_subchannel::callid, open_receive_channel_message::capability, skinny_line::capability, codec_ast2skinny(), open_receive_channel_message::conferenceId, ast_format_list::cur_ms, skinny_req::data, open_receive_channel_message::echo, htolel, OPEN_RECEIVE_CHANNEL_MESSAGE, skinny_data::openreceivechannel, open_receive_channel_message::packets, skinny_subchannel::parent, open_receive_channel_message::partyId, skinny_line::prefs, req_alloc(), and transmit_response().
Referenced by skinny_unhold(), and start_rtp().
01524 { 01525 struct skinny_req *req; 01526 struct skinny_line *l = sub->parent; 01527 struct ast_format_list fmt; 01528 01529 if (!(req = req_alloc(sizeof(struct open_receive_channel_message), OPEN_RECEIVE_CHANNEL_MESSAGE))) 01530 return; 01531 01532 fmt = ast_codec_pref_getsize(&l->prefs, ast_best_codec(l->capability)); 01533 01534 req->data.openreceivechannel.conferenceId = htolel(sub->callid); 01535 req->data.openreceivechannel.partyId = htolel(sub->callid); 01536 req->data.openreceivechannel.packets = htolel(fmt.cur_ms); 01537 req->data.openreceivechannel.capability = htolel(codec_ast2skinny(fmt.bits)); 01538 req->data.openreceivechannel.echo = htolel(0); 01539 req->data.openreceivechannel.bitrate = htolel(0); 01540 transmit_response(s, req); 01541 }
static void transmit_dialednumber | ( | struct skinnysession * | s, | |
const char * | text, | |||
int | instance, | |||
int | callid | |||
) | [static] |
Definition at line 1693 of file chan_skinny.c.
References dialed_number_message::callReference, skinny_req::data, DIALED_NUMBER_MESSAGE, dialed_number_message::dialedNumber, skinny_data::dialednumber, htolel, dialed_number_message::lineInstance, req_alloc(), and transmit_response().
Referenced by skinny_indicate().
01694 { 01695 struct skinny_req *req; 01696 01697 if (!(req = req_alloc(sizeof(struct dialed_number_message), DIALED_NUMBER_MESSAGE))) 01698 return; 01699 01700 ast_copy_string(req->data.dialednumber.dialedNumber, text, sizeof(req->data.dialednumber.dialedNumber)); 01701 req->data.dialednumber.lineInstance = htolel(instance); 01702 req->data.dialednumber.callReference = htolel(callid); 01703 01704 transmit_response(s, req); 01705 }
static void transmit_displaymessage | ( | struct skinnysession * | s, | |
const char * | text, | |||
int | instance, | |||
int | reference | |||
) | [static] |
Definition at line 1623 of file chan_skinny.c.
References ast_verbose(), clear_prompt_message::callReference, CLEAR_DISPLAY_MESSAGE, skinny_data::clearpromptstatus, skinny_req::data, skinny_data::displaytext, DISPLAYTEXT_MESSAGE, clear_prompt_message::lineInstance, req_alloc(), displaytext_message::text, and transmit_response().
Referenced by handle_enbloc_call_message(), handle_offhook_message(), handle_soft_key_event_message(), and handle_stimulus_message().
01624 { 01625 struct skinny_req *req; 01626 01627 if (text == 0) { 01628 if (!(req = req_alloc(0, CLEAR_DISPLAY_MESSAGE))) 01629 return; 01630 01631 req->data.clearpromptstatus.lineInstance = instance; 01632 req->data.clearpromptstatus.callReference = reference; 01633 01634 if (skinnydebug) 01635 ast_verbose("Clearing Display\n"); 01636 } else { 01637 if (!(req = req_alloc(sizeof(struct displaytext_message), DISPLAYTEXT_MESSAGE))) 01638 return; 01639 01640 ast_copy_string(req->data.displaytext.text, text, sizeof(req->data.displaytext.text)); 01641 if (skinnydebug) 01642 ast_verbose("Displaying message '%s'\n", req->data.displaytext.text); 01643 } 01644 01645 transmit_response(s, req); 01646 }
static void transmit_displaynotify | ( | struct skinnysession * | s, | |
const char * | text, | |||
int | t | |||
) | [static] |
Definition at line 1648 of file chan_skinny.c.
References ast_verbose(), skinny_req::data, DISPLAY_NOTIFY_MESSAGE, display_notify_message::displayMessage, skinny_data::displaynotify, display_notify_message::displayTimeout, htolel, req_alloc(), and transmit_response().
Referenced by handle_soft_key_event_message(), and handle_stimulus_message().
01649 { 01650 struct skinny_req *req; 01651 01652 if (!(req = req_alloc(sizeof(struct display_notify_message), DISPLAY_NOTIFY_MESSAGE))) 01653 return; 01654 01655 ast_copy_string(req->data.displaynotify.displayMessage, text, sizeof(req->data.displaynotify.displayMessage)); 01656 req->data.displaynotify.displayTimeout = htolel(t); 01657 01658 if (skinnydebug) 01659 ast_verbose("Displaying notify '%s'\n", text); 01660 01661 transmit_response(s, req); 01662 }
static void transmit_displaypromptstatus | ( | struct skinnysession * | s, | |
const char * | text, | |||
int | t, | |||
int | instance, | |||
int | callid | |||
) | [static] |
Definition at line 1664 of file chan_skinny.c.
References ast_verbose(), display_prompt_status_message::callReference, clear_prompt_message::callReference, CLEAR_PROMPT_MESSAGE, skinny_data::clearpromptstatus, skinny_req::data, DISPLAY_PROMPT_STATUS_MESSAGE, skinny_data::displaypromptstatus, htolel, display_prompt_status_message::lineInstance, clear_prompt_message::lineInstance, display_prompt_status_message::messageTimeout, display_prompt_status_message::promptMessage, req_alloc(), and transmit_response().
Referenced by handle_stimulus_message(), skinny_answer(), skinny_call(), skinny_indicate(), and transmit_callstate().
01665 { 01666 struct skinny_req *req; 01667 01668 if (text == 0) { 01669 if (!(req = req_alloc(sizeof(struct clear_prompt_message), CLEAR_PROMPT_MESSAGE))) 01670 return; 01671 01672 req->data.clearpromptstatus.lineInstance = htolel(instance); 01673 req->data.clearpromptstatus.callReference = htolel(callid); 01674 01675 if (skinnydebug) 01676 ast_verbose("Clearing Prompt\n"); 01677 } else { 01678 if (!(req = req_alloc(sizeof(struct display_prompt_status_message), DISPLAY_PROMPT_STATUS_MESSAGE))) 01679 return; 01680 01681 ast_copy_string(req->data.displaypromptstatus.promptMessage, text, sizeof(req->data.displaypromptstatus.promptMessage)); 01682 req->data.displaypromptstatus.messageTimeout = htolel(t); 01683 req->data.displaypromptstatus.lineInstance = htolel(instance); 01684 req->data.displaypromptstatus.callReference = htolel(callid); 01685 01686 if (skinnydebug) 01687 ast_verbose("Displaying Prompt Status '%s'\n", text); 01688 } 01689 01690 transmit_response(s, req); 01691 }
static void transmit_lamp_indication | ( | struct skinnysession * | s, | |
int | stimulus, | |||
int | instance, | |||
int | indication | |||
) | [static] |
Definition at line 1585 of file chan_skinny.c.
References skinny_req::data, set_lamp_message::deviceStimulus, htolel, req_alloc(), SET_LAMP_MESSAGE, skinny_data::setlamp, set_lamp_message::stimulus, set_lamp_message::stimulusInstance, and transmit_response().
Referenced by handle_offhook_message(), handle_soft_key_event_message(), handle_stimulus_message(), skinny_call(), skinny_hangup(), skinny_hold(), and skinny_unhold().
01586 { 01587 struct skinny_req *req; 01588 01589 if (!(req = req_alloc(sizeof(struct set_lamp_message), SET_LAMP_MESSAGE))) 01590 return; 01591 01592 req->data.setlamp.stimulus = htolel(stimulus); 01593 req->data.setlamp.stimulusInstance = htolel(instance); 01594 req->data.setlamp.deviceStimulus = htolel(indication); 01595 transmit_response(s, req); 01596 }
static int transmit_response | ( | struct skinnysession * | s, | |
struct skinny_req * | req | |||
) | [static] |
Definition at line 1433 of file chan_skinny.c.
References ast_log(), ast_mutex_lock(), ast_mutex_unlock(), skinny_req::data, skinny_req::e, errno, skinnysession::fd, skinny_req::len, letohl, skinnysession::lock, LOG_VERBOSE, LOG_WARNING, skinnysession::outbuf, SKINNY_MAX_PACKET, and skinny_unregister().
01434 { 01435 int res = 0; 01436 01437 if (!s) { 01438 ast_log(LOG_WARNING, "Asked to transmit to a non-existant session!\n"); 01439 return -1; 01440 } 01441 01442 ast_mutex_lock(&s->lock); 01443 01444 if (skinnydebug) 01445 ast_log(LOG_VERBOSE, "writing packet type %04X (%d bytes) to socket %d\n", letohl(req->e), letohl(req->len)+8, s->fd); 01446 01447 if (letohl(req->len > SKINNY_MAX_PACKET) || letohl(req->len < 0)) { 01448 ast_log(LOG_WARNING, "transmit_response: the length of the request is out of bounds\n"); 01449 return -1; 01450 } 01451 01452 memset(s->outbuf,0,sizeof(s->outbuf)); 01453 memcpy(s->outbuf, req, skinny_header_size); 01454 memcpy(s->outbuf+skinny_header_size, &req->data, letohl(req->len)); 01455 01456 res = write(s->fd, s->outbuf, letohl(req->len)+8); 01457 01458 if (res != letohl(req->len)+8) { 01459 ast_log(LOG_WARNING, "Transmit: write only sent %d out of %d bytes: %s\n", res, letohl(req->len)+8, strerror(errno)); 01460 if (res == -1) { 01461 if (skinnydebug) 01462 ast_log(LOG_WARNING, "Transmit: Skinny Client was lost, unregistering\n"); 01463 skinny_unregister(NULL, s); 01464 } 01465 01466 } 01467 01468 ast_mutex_unlock(&s->lock); 01469 return 1; 01470 }
static void transmit_ringer_mode | ( | struct skinnysession * | s, | |
int | mode | |||
) | [static] |
Definition at line 1598 of file chan_skinny.c.
References ast_verbose(), skinny_req::data, htolel, req_alloc(), set_ringer_message::ringerMode, SET_RINGER_MESSAGE, skinny_data::setringer, transmit_response(), set_ringer_message::unknown1, and set_ringer_message::unknown2.
Referenced by handle_offhook_message(), handle_soft_key_event_message(), handle_stimulus_message(), skinny_call(), and skinny_hangup().
01599 { 01600 struct skinny_req *req; 01601 01602 if (skinnydebug) 01603 ast_verbose("Setting ringer mode to '%d'.\n", mode); 01604 01605 if (!(req = req_alloc(sizeof(struct set_ringer_message), SET_RINGER_MESSAGE))) 01606 return; 01607 01608 req->data.setringer.ringerMode = htolel(mode); 01609 /* XXX okay, I don't quite know what this is, but here's what happens (on a 7960). 01610 Note: The phone will always show as ringing on the display. 01611 01612 1: phone will audibly ring over and over 01613 2: phone will audibly ring only once 01614 any other value, will NOT cause the phone to audibly ring 01615 */ 01616 req->data.setringer.unknown1 = htolel(1); 01617 /* XXX the value here doesn't seem to change anything. Must be higher than 0. 01618 Perhaps a packet capture can shed some light on this. */ 01619 req->data.setringer.unknown2 = htolel(1); 01620 transmit_response(s, req); 01621 }
static void transmit_selectsoftkeys | ( | struct skinnysession * | s, | |
int | instance, | |||
int | callid, | |||
int | softkey | |||
) | [static] |
Definition at line 1571 of file chan_skinny.c.
References skinny_req::data, htolel, select_soft_keys_message::instance, select_soft_keys_message::reference, req_alloc(), SELECT_SOFT_KEYS_MESSAGE, skinny_data::selectsoftkey, select_soft_keys_message::softKeySetIndex, transmit_response(), and select_soft_keys_message::validKeyMask.
Referenced by handle_offhook_message(), handle_soft_key_event_message(), handle_soft_key_set_req_message(), handle_stimulus_message(), skinny_answer(), skinny_call(), and transmit_callstate().
01572 { 01573 struct skinny_req *req; 01574 01575 if (!(req = req_alloc(sizeof(struct select_soft_keys_message), SELECT_SOFT_KEYS_MESSAGE))) 01576 return; 01577 01578 req->data.selectsoftkey.instance = htolel(instance); 01579 req->data.selectsoftkey.reference = htolel(callid); 01580 req->data.selectsoftkey.softKeySetIndex = htolel(softkey); 01581 req->data.selectsoftkey.validKeyMask = htolel(0xFFFFFFFF); 01582 transmit_response(s, req); 01583 }
static void transmit_speaker_mode | ( | struct skinnysession * | s, | |
int | mode | |||
) | [static] |
Definition at line 1472 of file chan_skinny.c.
References skinny_req::data, htolel, set_speaker_message::mode, req_alloc(), SET_SPEAKER_MESSAGE, skinny_data::setspeaker, and transmit_response().
Referenced by handle_soft_key_event_message(), handle_stimulus_message(), skinny_hangup(), and transmit_callstate().
01473 { 01474 struct skinny_req *req; 01475 01476 if (!(req = req_alloc(sizeof(struct set_speaker_message), SET_SPEAKER_MESSAGE))) 01477 return; 01478 01479 req->data.setspeaker.mode = htolel(mode); 01480 transmit_response(s, req); 01481 }
static void transmit_tone | ( | struct skinnysession * | s, | |
int | tone, | |||
int | instance, | |||
int | reference | |||
) | [static] |
Definition at line 1543 of file chan_skinny.c.
References skinny_req::data, htolel, stop_tone_message::instance, start_tone_message::instance, stop_tone_message::reference, start_tone_message::reference, req_alloc(), SKINNY_NOTONE, START_TONE_MESSAGE, skinny_data::starttone, STOP_TONE_MESSAGE, skinny_data::stoptone, start_tone_message::tone, and transmit_response().
Referenced by handle_enbloc_call_message(), handle_offhook_message(), handle_soft_key_event_message(), handle_stimulus_message(), skinny_answer(), skinny_hangup(), skinny_indicate(), skinny_newcall(), skinny_senddigit_end(), and skinny_ss().
01544 { 01545 struct skinny_req *req; 01546 01547 if (tone == SKINNY_NOTONE) { 01548 /* This is bad, mmm'kay? */ 01549 return; 01550 } 01551 01552 if (tone > 0) { 01553 if (!(req = req_alloc(sizeof(struct start_tone_message), START_TONE_MESSAGE))) 01554 return; 01555 req->data.starttone.tone = htolel(tone); 01556 req->data.starttone.instance = htolel(instance); 01557 req->data.starttone.reference = htolel(reference); 01558 } else { 01559 if (!(req = req_alloc(sizeof(struct stop_tone_message), STOP_TONE_MESSAGE))) 01560 return; 01561 req->data.stoptone.instance = htolel(instance); 01562 req->data.stoptone.reference = htolel(reference); 01563 } 01564 01565 if (tone > 0) { 01566 req->data.starttone.tone = htolel(tone); 01567 } 01568 transmit_response(s, req); 01569 }
static int unload_module | ( | void | ) | [static] |
Definition at line 4865 of file chan_skinny.c.
References skinny_subchannel::alreadygone, ast_channel_unregister(), ast_cli_unregister_multiple(), ast_mutex_destroy(), ast_mutex_lock(), ast_mutex_unlock(), AST_PTHREADT_NULL, AST_PTHREADT_STOP, ast_rtp_proto_unregister(), ast_softhangup(), AST_SOFTHANGUP_APPUNLOAD, delete_devices(), skinnysession::device, skinnysession::fd, free, skinny_device::lines, skinnysession::lock, skinny_subchannel::lock, skinny_line::lock, skinny_subchannel::next, skinny_line::next, skinny_device::next, skinnysession::next, skinny_subchannel::owner, s, sched_context_destroy(), sessions, and skinny_line::sub.
04866 { 04867 struct skinnysession *s, *slast; 04868 struct skinny_device *d; 04869 struct skinny_line *l; 04870 struct skinny_subchannel *sub; 04871 04872 ast_mutex_lock(&sessionlock); 04873 /* Destroy all the interfaces and free their memory */ 04874 s = sessions; 04875 while(s) { 04876 slast = s; 04877 s = s->next; 04878 for (d = slast->device; d; d = d->next) { 04879 for (l = d->lines; l; l = l->next) { 04880 ast_mutex_lock(&l->lock); 04881 for (sub = l->sub; sub; sub = sub->next) { 04882 ast_mutex_lock(&sub->lock); 04883 if (sub->owner) { 04884 sub->alreadygone = 1; 04885 ast_softhangup(sub->owner, AST_SOFTHANGUP_APPUNLOAD); 04886 } 04887 ast_mutex_unlock(&sub->lock); 04888 } 04889 ast_mutex_unlock(&l->lock); 04890 } 04891 } 04892 if (slast->fd > -1) 04893 close(slast->fd); 04894 ast_mutex_destroy(&slast->lock); 04895 free(slast); 04896 } 04897 sessions = NULL; 04898 ast_mutex_unlock(&sessionlock); 04899 04900 delete_devices(); 04901 04902 ast_mutex_lock(&monlock); 04903 if ((monitor_thread != AST_PTHREADT_NULL) && (monitor_thread != AST_PTHREADT_STOP)) { 04904 pthread_cancel(monitor_thread); 04905 pthread_kill(monitor_thread, SIGURG); 04906 pthread_join(monitor_thread, NULL); 04907 } 04908 monitor_thread = AST_PTHREADT_STOP; 04909 ast_mutex_unlock(&monlock); 04910 04911 ast_mutex_lock(&netlock); 04912 if (accept_t && (accept_t != AST_PTHREADT_STOP)) { 04913 pthread_cancel(accept_t); 04914 pthread_kill(accept_t, SIGURG); 04915 pthread_join(accept_t, NULL); 04916 } 04917 accept_t = AST_PTHREADT_STOP; 04918 ast_mutex_unlock(&netlock); 04919 04920 ast_rtp_proto_unregister(&skinny_rtp); 04921 ast_channel_unregister(&skinny_tech); 04922 ast_cli_unregister_multiple(cli_skinny, sizeof(cli_skinny) / sizeof(struct ast_cli_entry)); 04923 04924 close(skinnysock); 04925 if (sched) 04926 sched_context_destroy(sched); 04927 04928 return 0; 04929 }
struct in_addr __ourip [static] |
Definition at line 785 of file chan_skinny.c.
pthread_t accept_t [static] |
Definition at line 789 of file chan_skinny.c.
char accountcode[AST_MAX_ACCOUNT_CODE] = "" [static] |
Definition at line 809 of file chan_skinny.c.
struct ast_hostent ahp |
int amaflags = 0 [static] |
Definition at line 811 of file chan_skinny.c.
struct sockaddr_in bindaddr [static] |
Definition at line 782 of file chan_skinny.c.
int callnums = 1 [static] |
Definition at line 812 of file chan_skinny.c.
int callreturn = 0 [static] |
Definition at line 802 of file chan_skinny.c.
int callwaiting = 0 [static] |
Definition at line 801 of file chan_skinny.c.
int cancallforward = 0 [static] |
Definition at line 807 of file chan_skinny.c.
char cid_name[AST_MAX_EXTENSION] = "" [static] |
Definition at line 795 of file chan_skinny.c.
char cid_num[AST_MAX_EXTENSION] = "" [static] |
Definition at line 794 of file chan_skinny.c.
struct ast_cli_entry cli_skinny[] [static] |
Definition at line 2054 of file chan_skinny.c.
const char config[] = "skinny.conf" [static] |
Definition at line 81 of file chan_skinny.c.
char context[AST_MAX_CONTEXT] = "default" [static] |
Definition at line 790 of file chan_skinny.c.
ast_group_t cur_callergroup = 0 [static] |
Definition at line 798 of file chan_skinny.c.
ast_group_t cur_pickupgroup = 0 [static] |
Definition at line 799 of file chan_skinny.c.
char date_format[6] = "D-M-Y" [static] |
Definition at line 101 of file chan_skinny.c.
char debug_usage[] [static] |
Initial value:
"Usage: skinny set debug\n" " Enables dumping of Skinny packets for debugging purposes\n"
Definition at line 2042 of file chan_skinny.c.
int default_capability = AST_FORMAT_ULAW | AST_FORMAT_ALAW [static] |
Definition at line 83 of file chan_skinny.c.
struct ast_jb_conf default_jbconf [static] |
Global jitterbuffer configuration - by default, jb is disabled
Definition at line 129 of file chan_skinny.c.
struct ast_codec_pref default_prefs [static] |
Definition at line 84 of file chan_skinny.c.
struct skinny_device * devices [static] |
int firstdigittimeout = 16000 [static] |
Definition at line 928 of file chan_skinny.c.
int gendigittimeout = 8000 [static] |
Definition at line 931 of file chan_skinny.c.
struct ast_jb_conf global_jbconf [static] |
Definition at line 136 of file chan_skinny.c.
struct hostent* hp |
Definition at line 787 of file chan_skinny.c.
Referenced by __ast_http_load(), ast_dnsmgr_lookup(), ast_find_ourip(), ast_get_ip_or_srv(), ast_sip_ouraddrfor(), build_peer(), check_via(), create_addr(), dnsmgr_refresh(), gtalk_load_config(), gtalk_update_stun(), iax_template_parse(), launch_netscript(), parse_register_contact(), process_sdp(), reload_config(), rpt_exec(), rtcp_do_debug_ip(), rtcp_do_debug_ip_deprecated(), rtp_do_debug_ip(), set_address_from_contact(), set_config(), set_destination(), sip_devicestate(), sip_do_debug_ip(), and udptl_do_debug_ip().
int immediate = 0 [static] |
Definition at line 800 of file chan_skinny.c.
struct io_context* io [static] |
Definition at line 907 of file chan_skinny.c.
int keep_alive = 120 [static] |
Definition at line 100 of file chan_skinny.c.
char language[MAX_LANGUAGE] = "" [static] |
Definition at line 791 of file chan_skinny.c.
char linelabel[AST_MAX_EXTENSION] = "" [static] |
Definition at line 796 of file chan_skinny.c.
char mailbox[AST_MAX_EXTENSION] [static] |
Definition at line 810 of file chan_skinny.c.
int matchdigittimeout = 3000 [static] |
Definition at line 934 of file chan_skinny.c.
char mohinterpret[MAX_MUSICCLASS] = "default" [static] |
Definition at line 792 of file chan_skinny.c.
char mohsuggest[MAX_MUSICCLASS] = "" [static] |
Definition at line 793 of file chan_skinny.c.
pthread_t monitor_thread = AST_PTHREADT_NULL [static] |
Definition at line 925 of file chan_skinny.c.
int mwiblink = 0 [static] |
Definition at line 804 of file chan_skinny.c.
int nat = 0 [static] |
Definition at line 797 of file chan_skinny.c.
char no_debug_usage[] [static] |
Initial value:
"Usage: skinny set debug off\n" " Disables dumping of Skinny packets for debugging purposes\n"
Definition at line 2046 of file chan_skinny.c.
char ourhost[256] [static] |
Definition at line 783 of file chan_skinny.c.
int ourport [static] |
Definition at line 784 of file chan_skinny.c.
char reset_usage[] [static] |
Initial value:
"Usage: skinny reset <DeviceId|all> [restart]\n" " Causes a Skinny device to reset itself, optionally with a full restart\n"
Definition at line 2050 of file chan_skinny.c.
struct sched_context* sched = NULL [static] |
Definition at line 906 of file chan_skinny.c.
struct skinnysession * sessions [static] |
Referenced by accept_thread(), destroy_session(), and unload_module().
char show_devices_usage[] [static] |
Initial value:
"Usage: skinny show devices\n" " Lists all devices known to the Skinny subsystem.\n"
Definition at line 2034 of file chan_skinny.c.
char show_lines_usage[] [static] |
Initial value:
"Usage: skinny show lines\n" " Lists all lines known to the Skinny subsystem.\n"
Definition at line 2038 of file chan_skinny.c.
int skinny_header_size = 12 |
Definition at line 773 of file chan_skinny.c.
struct ast_rtp_protocol skinny_rtp [static] |
Definition at line 1825 of file chan_skinny.c.
struct ast_channel_tech skinny_tech [static] |
Definition at line 1073 of file chan_skinny.c.
int skinnydebug = 0 [static] |
Definition at line 779 of file chan_skinny.c.
int skinnysock = -1 [static] |
Definition at line 788 of file chan_skinny.c.
const uint8_t soft_key_default_connected[] [static] |
Definition at line 571 of file chan_skinny.c.
const uint8_t soft_key_default_connwithconf[] [static] |
const uint8_t soft_key_default_connwithtrans[] [static] |
Definition at line 601 of file chan_skinny.c.
const uint8_t soft_key_default_dadfd[] [static] |
struct soft_key_definitions soft_key_default_definitions[] [static] |
Definition at line 633 of file chan_skinny.c.
const uint8_t soft_key_default_offhook[] [static] |
Definition at line 593 of file chan_skinny.c.
const uint8_t soft_key_default_offhookwithfeat[] [static] |
const uint8_t soft_key_default_onhold[] [static] |
Definition at line 580 of file chan_skinny.c.
const uint8_t soft_key_default_onhook[] [static] |
Definition at line 562 of file chan_skinny.c.
const uint8_t soft_key_default_ringin[] [static] |
Initial value:
Definition at line 587 of file chan_skinny.c.
const uint8_t soft_key_default_ringout[] [static] |
const uint8_t soft_key_default_unknown[] [static] |
Definition at line 535 of file chan_skinny.c.
const char tdesc[] = "Skinny Client Control Protocol (Skinny)" [static] |
Definition at line 80 of file chan_skinny.c.
int threewaycalling = 0 [static] |
Definition at line 803 of file chan_skinny.c.
int transfer = 0 [static] |
Definition at line 806 of file chan_skinny.c.
char version_id[16] = "P002F202" [static] |
Definition at line 102 of file chan_skinny.c.