Mon May 14 04:46:25 2007

Asterisk developer's documentation


chan_skinny.c File Reference

Implementation of the Skinny protocol. More...

#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"

Include dependency graph for chan_skinny.c:

Go to the source code of this file.

Data Structures

struct  activate_call_plane_message
struct  alarm_message
struct  button_definition
struct  button_definition_template
struct  button_template_res_message
struct  call_info_message
struct  call_state_message
struct  capabilities_res_message
struct  close_receive_channel_message
struct  definetimedate_message
struct  dialed_number_message
struct  display_notify_message
struct  display_prompt_status_message
struct  displaytext_message
struct  keypad_button_message
struct  line_stat_res_message
struct  line_state_req_message
struct  media_qualifier
struct  offhook_message
struct  onhook_message
struct  open_receive_channel_ack_message
struct  open_receive_channel_message
struct  register_ack_message
struct  register_message
struct  register_rej_message
struct  reset_message
struct  select_soft_keys_message
struct  server_identifier
struct  server_res_message
struct  set_lamp_message
struct  set_microphone_message
struct  set_ringer_message
struct  set_speaker_message
struct  skinny_addon
union  skinny_data
struct  skinny_device
struct  skinny_line
struct  skinny_paging_device
struct  skinny_req
struct  skinny_speeddial
struct  skinny_subchannel
struct  skinnysession
struct  soft_key_definitions
struct  soft_key_event_message
struct  soft_key_set_definition
struct  soft_key_set_res_message
struct  soft_key_template_definition
struct  soft_key_template_res_message
struct  speed_dial_stat_req_message
struct  speed_dial_stat_res_message
struct  start_media_transmission_message
struct  start_tone_message
struct  station_capabilities
struct  stimulus_message
struct  stop_media_transmission_message
struct  version_res_message

Defines

#define ACTIVATE_CALL_PLANE_MESSAGE   0x0116
#define ALARM_MESSAGE   0x0020
#define BT_AUTOANSWER   STIMULUS_AUTOANSWER
#define BT_CALLPARK   STIMULUS_CALLPARK
#define BT_CALLPICKUP   STIMULUS_CALLPICKUP
#define BT_CONFERENCE   STIMULUS_CONFERENCE
#define BT_CUST_HINT   0xB1
#define BT_CUST_LINESPEEDDIAL   0xB0
#define BT_DISPLAY   STIMULUS_DISPLAY
#define BT_FORWARDALL   STIMULUS_FORWARDALL
#define BT_FORWARDBUSY   STIMULUS_FORWARDBUSY
#define BT_FORWARDNOANSWER   STIMULUS_FORWARDNOANSWER
#define BT_HOLD   STIMULUS_HOLD
#define BT_LINE   STIMULUS_LINE
#define BT_NONE   0x00
#define BT_REDIAL   STIMULUS_REDIAL
#define BT_SPEEDDIAL   STIMULUS_SPEEDDIAL
#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
#define CLEAR_PROMPT_MESSAGE   0x0113
#define CLOSE_RECEIVE_CHANNEL_MESSAGE   0x0106
#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 HEADSET_STATUS_MESSAGE   0x002B
#define htolel(x)   (x)
#define htoles(x)   (x)
#define IP_PORT_MESSAGE   0x0002
#define KEEP_ALIVE_ACK_MESSAGE   0x0100
#define KEEP_ALIVE_MESSAGE   0x0000
#define KEYDEF_CONNECTED   1
#define KEYDEF_CONNWITHCONF   7
#define KEYDEF_CONNWITHTRANS   5
#define KEYDEF_DADFD   6
#define KEYDEF_OFFHOOK   4
#define KEYDEF_OFFHOOKWITHFEAT   9
#define KEYDEF_ONHOLD   2
#define KEYDEF_ONHOOK   0
#define KEYDEF_RINGIN   3
#define KEYDEF_RINGOUT   8
#define KEYDEF_UNKNOWN   10
#define KEYPAD_BUTTON_MESSAGE   0x0003
#define letohl(x)   (x)
#define letohs(x)   (x)
#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
#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
#define SKINNY_CALLWAITTONE   0x2D
#define SKINNY_CONGESTION   7
#define SKINNY_CONNECTED   5
#define SKINNY_CX_CONF   3
#define SKINNY_CX_CONFERENCE   3
#define SKINNY_CX_INACTIVE   4
#define SKINNY_CX_MUTE   4
#define SKINNY_CX_RECVONLY   1
#define SKINNY_CX_SENDONLY   0
#define SKINNY_CX_SENDRECV   2
#define SKINNY_DEVICE_12   4
#define SKINNY_DEVICE_12SP   3
#define SKINNY_DEVICE_12SPPLUS   2
#define SKINNY_DEVICE_30SPPLUS   1
#define SKINNY_DEVICE_30VIP   5
#define SKINNY_DEVICE_7902   30008
#define SKINNY_DEVICE_7905   20000
#define SKINNY_DEVICE_7910   6
#define SKINNY_DEVICE_7911   307
#define SKINNY_DEVICE_7912   30007
#define SKINNY_DEVICE_7920   30002
#define SKINNY_DEVICE_7935   9
#define SKINNY_DEVICE_7936   30019
#define SKINNY_DEVICE_7940   8
#define SKINNY_DEVICE_7941   115
#define SKINNY_DEVICE_7941GE   309
#define SKINNY_DEVICE_7960   7
#define SKINNY_DEVICE_7961   30018
#define SKINNY_DEVICE_7961GE   308
#define SKINNY_DEVICE_7970   30006
#define SKINNY_DEVICE_7971   119
#define SKINNY_DEVICE_7985   302
#define SKINNY_DEVICE_ATA186   12
#define SKINNY_DEVICE_CIPC   30016
#define SKINNY_DEVICE_NONE   0
#define SKINNY_DEVICE_SCCPGATEWAY_AN   30027
#define SKINNY_DEVICE_SCCPGATEWAY_BRI   30028
#define SKINNY_DEVICE_UNKNOWN   -1
#define SKINNY_DIALTONE   0x21
#define SKINNY_HOLD   8
#define SKINNY_INVALID   14
#define SKINNY_LAMP_BLINK   5
#define SKINNY_LAMP_FLASH   4
#define SKINNY_LAMP_OFF   1
#define SKINNY_LAMP_ON   2
#define SKINNY_LAMP_WINK   3
#define SKINNY_MAX_PACKET   1000
#define SKINNY_MICOFF   2
#define SKINNY_MICON   1
#define SKINNY_NOTONE   0x7F
#define SKINNY_OFFHOOK   1
#define SKINNY_ONHOOK   2
#define SKINNY_PARK   11
#define SKINNY_PROGRESS   12
#define SKINNY_REORDER   0x25
#define SKINNY_RING_FEATURE   4
#define SKINNY_RING_INSIDE   2
#define SKINNY_RING_OFF   1
#define SKINNY_RING_OUTSIDE   3
#define SKINNY_RINGIN   4
#define SKINNY_RINGOUT   3
#define SKINNY_SILENCE   0x00
#define SKINNY_SPEAKEROFF   2
#define SKINNY_SPEAKERON   1
#define SKINNY_TRANSFER   10
#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
#define START_TONE_MESSAGE   0x0082
#define STIMULUS_AUTOANSWER   0x11
#define STIMULUS_CALLPARK   0x7E
#define STIMULUS_CALLPICKUP   0x7F
#define STIMULUS_CONFERENCE   0x7D
#define STIMULUS_DISPLAY   0x08
#define STIMULUS_FORWARDALL   0x05
#define STIMULUS_FORWARDBUSY   0x06
#define STIMULUS_FORWARDNOANSWER   0x07
#define STIMULUS_HOLD   0x03
#define STIMULUS_LINE   0x09
#define STIMULUS_MESSAGE   0x0005
#define STIMULUS_NONE   0xFF
#define STIMULUS_REDIAL   0x01
#define STIMULUS_SPEEDDIAL   0x02
#define STIMULUS_TRANSFER   0x04
#define STIMULUS_VOICEMAIL   0x0F
#define STOP_MEDIA_TRANSMISSION_MESSAGE   0x008B
#define STOP_TONE_MESSAGE   0x0083
#define TIME_DATE_REQ_MESSAGE   0x000D
#define TYPE_LINE   2
#define TYPE_TRUNK   1
#define UNREGISTER_MESSAGE   0x0027
#define VERSION_REQ_MESSAGE   0x000F
#define VERSION_RES_MESSAGE   0x0098

Enumerations

enum  skinny_codecs {
  SKINNY_CODEC_ALAW = 2, SKINNY_CODEC_ULAW = 4, SKINNY_CODEC_G723_1 = 9, SKINNY_CODEC_G729A = 12,
  SKINNY_CODEC_G726_32 = 82, SKINNY_CODEC_H261 = 100, SKINNY_CODEC_H263 = 101
}

Functions

static void * accept_thread (void *ignore)
 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_devicebuild_device (const char *cat, struct ast_variable *v)
static int codec_ast2skinny (int astcodec)
static int codec_skinny2ast (enum skinny_codecs skinnycodec)
static char * complete_skinny_reset (const char *line, const char *word, int pos, int state)
static char * control2str (int ind)
static void delete_devices (void)
static void destroy_session (struct skinnysession *s)
static char * device2str (int type)
static void do_housekeeping (struct skinnysession *s)
static void * do_monitor (void *data)
static struct skinny_linefind_line_by_instance (struct skinny_device *d, int instance)
static struct skinny_linefind_line_by_name (const char *dest)
static struct skinny_speeddialfind_speeddial_by_instance (struct skinny_device *d, int instance)
static struct skinny_subchannelfind_subchannel_by_instance_reference (struct skinny_device *d, int instance, int reference)
static struct skinny_subchannelfind_subchannel_by_reference (struct skinny_device *d, int reference)
static void * get_button_template (struct skinnysession *s, struct button_definition_template *btn)
static int get_input (struct skinnysession *s)
static int handle_alarm_message (struct skinny_req *req, struct skinnysession *s)
static int handle_button_template_req_message (struct skinny_req *req, struct skinnysession *s)
static int handle_capabilities_res_message (struct skinny_req *req, struct skinnysession *s)
static int handle_headset_status_message (struct skinny_req *req, struct skinnysession *s)
static int handle_ip_port_message (struct skinny_req *req, struct skinnysession *s)
static int handle_keep_alive_message (struct skinny_req *req, struct skinnysession *s)
static int handle_keypad_button_message (struct skinny_req *req, struct skinnysession *s)
static int handle_line_state_req_message (struct skinny_req *req, struct skinnysession *s)
static int handle_message (struct skinny_req *req, struct skinnysession *s)
static int handle_offhook_message (struct skinny_req *req, struct skinnysession *s)
static int handle_onhook_message (struct skinny_req *req, struct skinnysession *s)
static int handle_open_receive_channel_ack_message (struct skinny_req *req, struct skinnysession *s)
static int handle_register_available_lines_message (struct skinny_req *req, struct skinnysession *s)
static int handle_register_message (struct skinny_req *req, struct skinnysession *s)
static int handle_server_request_message (struct skinny_req *req, struct skinnysession *s)
static int handle_soft_key_event_message (struct skinny_req *req, struct skinnysession *s)
static int handle_soft_key_set_req_message (struct skinny_req *req, struct skinnysession *s)
static int handle_soft_key_template_req_message (struct skinny_req *req, struct skinnysession *s)
static int handle_speed_dial_stat_req_message (struct skinny_req *req, struct skinnysession *s)
static int handle_stimulus_message (struct skinny_req *req, struct skinnysession *s)
static int handle_time_date_req_message (struct skinny_req *req, struct skinnysession *s)
static int handle_unregister_message (struct skinny_req *req, struct skinnysession *s)
static int handle_version_req_message (struct skinny_req *req, struct skinnysession *s)
static int load_module (void)
static int reload_config (void)
static struct skinny_reqreq_alloc (size_t size, int response_message)
static int restart_monitor (void)
static int skinny_answer (struct ast_channel *ast)
static int skinny_call (struct ast_channel *ast, char *dest, int timeout)
static int skinny_do_debug (int fd, int argc, char *argv[])
static int skinny_fixup (struct ast_channel *oldchan, struct ast_channel *newchan)
static enum ast_rtp_get_result skinny_get_rtp_peer (struct ast_channel *c, struct ast_rtp **rtp)
static enum ast_rtp_get_result skinny_get_vrtp_peer (struct ast_channel *c, struct ast_rtp **rtp)
static int skinny_hangup (struct ast_channel *ast)
static int skinny_hold (struct skinny_subchannel *sub)
static int skinny_indicate (struct ast_channel *ast, int ind, const void *data, size_t datalen)
static struct ast_channelskinny_new (struct skinny_line *l, int state)
static void * skinny_newcall (void *data)
static int skinny_no_debug (int fd, int argc, char *argv[])
static struct ast_frameskinny_read (struct ast_channel *ast)
static int skinny_register (struct skinny_req *req, struct skinnysession *s)
static struct skinny_reqskinny_req_parse (struct skinnysession *s)
static struct ast_channelskinny_request (const char *type, int format, void *data, int *cause)
static int skinny_reset_device (int fd, int argc, char *argv[])
static struct ast_frameskinny_rtp_read (struct skinny_subchannel *sub)
static int skinny_senddigit_begin (struct ast_channel *ast, char digit)
static int skinny_senddigit_end (struct ast_channel *ast, char digit, unsigned int duration)
static void * skinny_session (void *data)
static int skinny_set_rtp_peer (struct ast_channel *c, struct ast_rtp *rtp, struct ast_rtp *vrtp, int codecs, int nat_active)
static int skinny_show_devices (int fd, int argc, char *argv[])
static int skinny_show_lines (int fd, int argc, char *argv[])
static void * skinny_ss (void *data)
static int skinny_unhold (struct skinny_subchannel *sub)
static int skinny_unregister (struct skinny_req *req, struct skinnysession *s)
static int skinny_write (struct ast_channel *ast, struct ast_frame *frame)
static void start_rtp (struct skinny_subchannel *sub)
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 void transmit_callstate (struct skinnysession *s, int instance, int state, unsigned callid)
static void transmit_connect (struct skinnysession *s, struct skinny_subchannel *sub)
static void transmit_dialednumber (struct skinnysession *s, const char *text, int instance, int callid)
static void transmit_displaymessage (struct skinnysession *s, const char *text)
static void transmit_displaynotify (struct skinnysession *s, const char *text, int t)
static void transmit_displaypromptstatus (struct skinnysession *s, const char *text, int t, int instance, int callid)
static void transmit_lamp_indication (struct skinnysession *s, int stimulus, int instance, int indication)
static int transmit_response (struct skinnysession *s, struct skinny_req *req)
static void transmit_ringer_mode (struct skinnysession *s, int mode)
static void transmit_selectsoftkeys (struct skinnysession *s, int instance, int callid, int softkey)
static void transmit_speaker_mode (struct skinnysession *s, int mode)
static void transmit_tone (struct skinnysession *s, int tone)
static int unload_module (void)

Variables

static struct in_addr __ourip
static pthread_t accept_t
static char accountcode [AST_MAX_ACCOUNT_CODE] = ""
ast_hostent ahp
static int amaflags = 0
static struct sockaddr_in bindaddr
static int callnums = 1
static int callreturn = 0
static int callwaiting = 0
static int cancallforward = 0
static char cid_name [AST_MAX_EXTENSION] = ""
static char cid_num [AST_MAX_EXTENSION] = ""
static struct ast_cli_entry cli_skinny []
static const char config [] = "skinny.conf"
static char context [AST_MAX_CONTEXT] = "default"
static ast_group_t cur_callergroup = 0
static ast_group_t cur_pickupgroup = 0
static char date_format [6] = "D-M-Y"
static char debug_usage []
static int default_capability = AST_FORMAT_ULAW | AST_FORMAT_ALAW
static struct ast_jb_conf default_jbconf
static struct ast_codec_pref default_prefs
static struct skinny_devicedevices
static int firstdigittimeout = 16000
static int gendigittimeout = 8000
static struct ast_jb_conf global_jbconf
hostent * hp
static int immediate = 0
static struct io_contextio
static int keep_alive = 120
static char language [MAX_LANGUAGE] = ""
static char linelabel [AST_MAX_EXTENSION] = ""
static char mailbox [AST_MAX_EXTENSION]
static int matchdigittimeout = 3000
static char mohinterpret [MAX_MUSICCLASS] = "default"
static char mohsuggest [MAX_MUSICCLASS] = ""
static pthread_t monitor_thread = AST_PTHREADT_NULL
static int mwiblink = 0
static int nat = 0
static char no_debug_usage []
static char ourhost [256]
static int ourport
static char reset_usage []
static struct sched_contextsched
static struct skinnysessionsessions
static char show_devices_usage []
static char show_lines_usage []
int skinny_header_size = 12
static struct ast_rtp_protocol skinny_rtp
static struct ast_channel_tech skinny_tech
static int skinnydebug = 0
static int skinnysock = -1
static const uint8_t soft_key_default_connected []
static const uint8_t soft_key_default_connwithconf []
static const uint8_t soft_key_default_connwithtrans []
static const uint8_t soft_key_default_dadfd []
static struct soft_key_definitions soft_key_default_definitions []
static const uint8_t soft_key_default_offhook []
static const uint8_t soft_key_default_offhookwithfeat []
static const uint8_t soft_key_default_onhold []
static const uint8_t soft_key_default_onhook []
static const uint8_t soft_key_default_ringin []
static const uint8_t soft_key_default_ringout []
static const uint8_t soft_key_default_unknown []
soft_key_template_definition soft_key_template_default []
static const char tdesc [] = "Skinny Client Control Protocol (Skinny)"
static int threewaycalling = 0
static int transfer = 0
static char version_id [16] = "P002F202"


Detailed Description

Implementation of the Skinny protocol.

Author:
Jeremy McNamara & Florian Overkamp & North Antara

Definition in file chan_skinny.c.


Define Documentation

#define ACTIVATE_CALL_PLANE_MESSAGE   0x0116

Definition at line 679 of file chan_skinny.c.

Referenced by skinny_hold(), skinny_unhold(), and transmit_callstate().

#define ALARM_MESSAGE   0x0020

Definition at line 219 of file chan_skinny.c.

Referenced by handle_message().

#define BT_AUTOANSWER   STIMULUS_AUTOANSWER

Definition at line 402 of file chan_skinny.c.

#define BT_CALLPARK   STIMULUS_CALLPARK

Definition at line 404 of file chan_skinny.c.

Referenced by get_button_template().

#define BT_CALLPICKUP   STIMULUS_CALLPICKUP

Definition at line 405 of file chan_skinny.c.

#define BT_CONFERENCE   STIMULUS_CONFERENCE

Definition at line 403 of file chan_skinny.c.

Referenced by get_button_template().

#define BT_CUST_HINT   0xB1

Definition at line 412 of file chan_skinny.c.

Referenced by handle_button_template_req_message().

#define BT_CUST_LINESPEEDDIAL   0xB0

Definition at line 411 of file chan_skinny.c.

Referenced by get_button_template(), and handle_button_template_req_message().

#define BT_DISPLAY   STIMULUS_DISPLAY

Definition at line 399 of file chan_skinny.c.

Referenced by get_button_template().

#define BT_FORWARDALL   STIMULUS_FORWARDALL

Definition at line 396 of file chan_skinny.c.

Referenced by get_button_template().

#define BT_FORWARDBUSY   STIMULUS_FORWARDBUSY

Definition at line 397 of file chan_skinny.c.

#define BT_FORWARDNOANSWER   STIMULUS_FORWARDNOANSWER

Definition at line 398 of file chan_skinny.c.

#define BT_HOLD   STIMULUS_HOLD

Definition at line 394 of file chan_skinny.c.

Referenced by get_button_template().

#define BT_LINE   STIMULUS_LINE

Definition at line 400 of file chan_skinny.c.

Referenced by get_button_template(), and handle_button_template_req_message().

#define BT_NONE   0x00

Definition at line 406 of file chan_skinny.c.

Referenced by get_button_template(), and handle_button_template_req_message().

#define BT_REDIAL   STIMULUS_REDIAL

Definition at line 392 of file chan_skinny.c.

Referenced by get_button_template().

#define BT_SPEEDDIAL   STIMULUS_SPEEDDIAL

Definition at line 393 of file chan_skinny.c.

Referenced by get_button_template(), and handle_button_template_req_message().

#define BT_TRANSFER   STIMULUS_TRANSFER

Definition at line 395 of file chan_skinny.c.

Referenced by get_button_template().

#define BT_VOICEMAIL   STIMULUS_VOICEMAIL

Definition at line 401 of file chan_skinny.c.

Referenced by get_button_template().

#define BUTTON_TEMPLATE_REQ_MESSAGE   0x000E

Definition at line 215 of file chan_skinny.c.

Referenced by handle_message().

#define BUTTON_TEMPLATE_RES_MESSAGE   0x0097

Definition at line 363 of file chan_skinny.c.

Referenced by handle_button_template_req_message().

#define CALL_INFO_MESSAGE   0x008F

Definition at line 314 of file chan_skinny.c.

Referenced by transmit_callinfo().

#define CALL_STATE_MESSAGE   0x0111

Definition at line 658 of file chan_skinny.c.

Referenced by transmit_callstate().

#define CAPABILITIES_REQ_MESSAGE   0x009B

Definition at line 435 of file chan_skinny.c.

Referenced by handle_register_message().

#define CAPABILITIES_RES_MESSAGE   0x0010

Definition at line 189 of file chan_skinny.c.

Referenced by handle_message().

#define CLEAR_DISPLAY_MESSAGE   0x009A

Definition at line 433 of file chan_skinny.c.

Referenced by transmit_displaymessage().

#define CLEAR_NOTIFY_MESSAGE   0x0115

Definition at line 431 of file chan_skinny.c.

#define CLEAR_PROMPT_MESSAGE   0x0113

Definition at line 432 of file chan_skinny.c.

#define CLOSE_RECEIVE_CHANNEL_MESSAGE   0x0106

Definition at line 470 of file chan_skinny.c.

Referenced by skinny_hold(), and transmit_callstate().

#define CONTROL2STR_BUFSIZE   100

Definition at line 142 of file chan_skinny.c.

Referenced by control2str().

#define DEFAULT_SKINNY_BACKLOG   2

Definition at line 97 of file chan_skinny.c.

Referenced by reload_config().

#define DEFAULT_SKINNY_PORT   2000

Definition at line 96 of file chan_skinny.c.

Referenced by build_device(), and reload_config().

#define DEFINETIMEDATE_MESSAGE   0x0094

Definition at line 350 of file chan_skinny.c.

Referenced by handle_time_date_req_message().

#define DEVICE2STR_BUFSIZE   15

Definition at line 139 of file chan_skinny.c.

Referenced by device2str().

#define DIALED_NUMBER_MESSAGE   0x011D

Definition at line 684 of file chan_skinny.c.

Referenced by transmit_dialednumber().

#define DISPLAY_NOTIFY_MESSAGE   0x0114

Definition at line 673 of file chan_skinny.c.

Referenced by transmit_displaynotify().

#define DISPLAY_PROMPT_STATUS_MESSAGE   0x0112

Definition at line 665 of file chan_skinny.c.

Referenced by transmit_displaypromptstatus().

#define DISPLAYTEXT_MESSAGE   0x0099

Definition at line 426 of file chan_skinny.c.

Referenced by transmit_displaymessage().

#define HEADSET_STATUS_MESSAGE   0x002B

Definition at line 246 of file chan_skinny.c.

Referenced by handle_message().

#define htolel (  )     (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)

Definition at line 108 of file chan_skinny.c.

#define IP_PORT_MESSAGE   0x0002

Definition at line 161 of file chan_skinny.c.

Referenced by handle_message().

#define KEEP_ALIVE_ACK_MESSAGE   0x0100

Definition at line 458 of file chan_skinny.c.

Referenced by handle_keep_alive_message().

#define KEEP_ALIVE_MESSAGE   0x0000

Definition at line 148 of file chan_skinny.c.

Referenced by handle_message().

#define KEYDEF_CONNECTED   1

Definition at line 484 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 490 of file chan_skinny.c.

#define KEYDEF_CONNWITHTRANS   5

Definition at line 488 of file chan_skinny.c.

#define KEYDEF_DADFD   6

Definition at line 489 of file chan_skinny.c.

#define KEYDEF_OFFHOOK   4

Definition at line 487 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 492 of file chan_skinny.c.

#define KEYDEF_ONHOLD   2

Definition at line 485 of file chan_skinny.c.

#define KEYDEF_ONHOOK   0

Definition at line 483 of file chan_skinny.c.

Referenced by handle_soft_key_set_req_message().

#define KEYDEF_RINGIN   3

Definition at line 486 of file chan_skinny.c.

Referenced by skinny_call().

#define KEYDEF_RINGOUT   8

Definition at line 491 of file chan_skinny.c.

#define KEYDEF_UNKNOWN   10

Definition at line 493 of file chan_skinny.c.

#define KEYPAD_BUTTON_MESSAGE   0x0003

Definition at line 163 of file chan_skinny.c.

Referenced by handle_message().

#define letohl (  )     (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)

Definition at line 106 of file chan_skinny.c.

#define LINE_STAT_RES_MESSAGE   0x0092

Definition at line 342 of file chan_skinny.c.

Referenced by handle_line_state_req_message().

#define LINE_STATE_REQ_MESSAGE   0x000B

Definition at line 209 of file chan_skinny.c.

Referenced by handle_message().

#define OFFHOOK_MESSAGE   0x0006

Definition at line 177 of file chan_skinny.c.

Referenced by handle_message().

#define ONHOOK_MESSAGE   0x0007

Definition at line 183 of file chan_skinny.c.

Referenced by handle_message().

#define OPEN_RECEIVE_CHANNEL_ACK_MESSAGE   0x0022

Definition at line 227 of file chan_skinny.c.

Referenced by handle_message().

#define OPEN_RECEIVE_CHANNEL_MESSAGE   0x0105

Definition at line 460 of file chan_skinny.c.

Referenced by transmit_connect().

#define REGISTER_ACK_MESSAGE   0x0081

Definition at line 249 of file chan_skinny.c.

Referenced by handle_register_message().

#define REGISTER_AVAILABLE_LINES_MESSAGE   0x002D

Definition at line 247 of file chan_skinny.c.

Referenced by handle_message().

#define REGISTER_MESSAGE   0x0001

Definition at line 151 of file chan_skinny.c.

Referenced by handle_message().

#define REGISTER_REJ_MESSAGE   0x009D

Definition at line 437 of file chan_skinny.c.

Referenced by handle_register_message().

#define RESET_MESSAGE   0x009F

Definition at line 453 of file chan_skinny.c.

Referenced by skinny_reset_device().

#define SELECT_SOFT_KEYS_MESSAGE   0x0110

Definition at line 650 of file chan_skinny.c.

Referenced by transmit_selectsoftkeys().

#define SERVER_REQUEST_MESSAGE   0x0012

Definition at line 217 of file chan_skinny.c.

Referenced by handle_message().

#define SERVER_RES_MESSAGE   0x009E

Definition at line 442 of file chan_skinny.c.

Referenced by handle_server_request_message().

#define SET_LAMP_MESSAGE   0x0086

Definition at line 272 of file chan_skinny.c.

Referenced by transmit_lamp_indication().

#define SET_MICROPHONE_MESSAGE   0x0089

Definition at line 285 of file chan_skinny.c.

#define SET_RINGER_MESSAGE   0x0085

Definition at line 265 of file chan_skinny.c.

Referenced by transmit_ringer_mode().

#define SET_SPEAKER_MESSAGE   0x0088

Definition at line 279 of file chan_skinny.c.

Referenced by transmit_speaker_mode().

#define SKINNY_ALERT   0x24

Definition at line 837 of file chan_skinny.c.

Referenced by skinny_call(), and skinny_indicate().

#define SKINNY_BUSY   6

Definition at line 825 of file chan_skinny.c.

Referenced by skinny_indicate().

#define SKINNY_BUSYTONE   0x23

Definition at line 836 of file chan_skinny.c.

Referenced by skinny_indicate().

#define SKINNY_CALLWAIT   9

Definition at line 828 of file chan_skinny.c.

#define SKINNY_CALLWAITTONE   0x2D

Definition at line 839 of file chan_skinny.c.

Referenced by skinny_call().

#define SKINNY_CONGESTION   7

Definition at line 826 of file chan_skinny.c.

Referenced by skinny_indicate().

#define SKINNY_CONNECTED   5

Definition at line 824 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 860 of file chan_skinny.c.

#define SKINNY_CX_CONFERENCE   3

Definition at line 861 of file chan_skinny.c.

#define SKINNY_CX_INACTIVE   4

Definition at line 863 of file chan_skinny.c.

Referenced by skinny_new().

#define SKINNY_CX_MUTE   4

Definition at line 862 of file chan_skinny.c.

#define SKINNY_CX_RECVONLY   1

Definition at line 858 of file chan_skinny.c.

Referenced by handle_onhook_message(), and handle_soft_key_event_message().

#define SKINNY_CX_SENDONLY   0

Definition at line 857 of file chan_skinny.c.

#define SKINNY_CX_SENDRECV   2

Definition at line 859 of file chan_skinny.c.

Referenced by skinny_answer().

#define SKINNY_DEVICE_12   4

Definition at line 790 of file chan_skinny.c.

Referenced by device2str(), and get_button_template().

#define SKINNY_DEVICE_12SP   3

Definition at line 789 of file chan_skinny.c.

Referenced by device2str(), and get_button_template().

#define SKINNY_DEVICE_12SPPLUS   2

Definition at line 788 of file chan_skinny.c.

Referenced by device2str(), and get_button_template().

#define SKINNY_DEVICE_30SPPLUS   1

Definition at line 787 of file chan_skinny.c.

Referenced by device2str(), and get_button_template().

#define SKINNY_DEVICE_30VIP   5

Definition at line 791 of file chan_skinny.c.

Referenced by device2str(), and get_button_template().

#define SKINNY_DEVICE_7902   30008

Definition at line 807 of file chan_skinny.c.

Referenced by device2str(), and get_button_template().

#define SKINNY_DEVICE_7905   20000

Definition at line 803 of file chan_skinny.c.

Referenced by device2str(), and get_button_template().

#define SKINNY_DEVICE_7910   6

Definition at line 792 of file chan_skinny.c.

Referenced by device2str(), and get_button_template().

#define SKINNY_DEVICE_7911   307

Definition at line 800 of file chan_skinny.c.

Referenced by device2str(), and get_button_template().

#define SKINNY_DEVICE_7912   30007

Definition at line 806 of file chan_skinny.c.

Referenced by device2str(), and get_button_template().

#define SKINNY_DEVICE_7920   30002

Definition at line 804 of file chan_skinny.c.

Referenced by device2str(), and get_button_template().

#define SKINNY_DEVICE_7935   9

Definition at line 795 of file chan_skinny.c.

Referenced by device2str(), and get_button_template().

#define SKINNY_DEVICE_7936   30019

Definition at line 810 of file chan_skinny.c.

Referenced by device2str(), and get_button_template().

#define SKINNY_DEVICE_7940   8

Definition at line 794 of file chan_skinny.c.

Referenced by device2str(), and get_button_template().

#define SKINNY_DEVICE_7941   115

Definition at line 797 of file chan_skinny.c.

Referenced by device2str(), and get_button_template().

#define SKINNY_DEVICE_7941GE   309

Definition at line 802 of file chan_skinny.c.

Referenced by device2str(), and get_button_template().

#define SKINNY_DEVICE_7960   7

Definition at line 793 of file chan_skinny.c.

Referenced by device2str(), and get_button_template().

#define SKINNY_DEVICE_7961   30018

Definition at line 809 of file chan_skinny.c.

Referenced by device2str(), and get_button_template().

#define SKINNY_DEVICE_7961GE   308

Definition at line 801 of file chan_skinny.c.

Referenced by device2str(), and get_button_template().

#define SKINNY_DEVICE_7970   30006

Definition at line 805 of file chan_skinny.c.

Referenced by device2str(), and get_button_template().

#define SKINNY_DEVICE_7971   119

Definition at line 798 of file chan_skinny.c.

Referenced by device2str(), and get_button_template().

#define SKINNY_DEVICE_7985   302

Definition at line 799 of file chan_skinny.c.

Referenced by device2str(), and get_button_template().

#define SKINNY_DEVICE_ATA186   12

Definition at line 796 of file chan_skinny.c.

Referenced by device2str(), and get_button_template().

#define SKINNY_DEVICE_CIPC   30016

Definition at line 808 of file chan_skinny.c.

Referenced by device2str(), and get_button_template().

#define SKINNY_DEVICE_NONE   0

Definition at line 786 of file chan_skinny.c.

Referenced by device2str().

#define SKINNY_DEVICE_SCCPGATEWAY_AN   30027

Definition at line 811 of file chan_skinny.c.

Referenced by device2str(), and get_button_template().

#define SKINNY_DEVICE_SCCPGATEWAY_BRI   30028

Definition at line 812 of file chan_skinny.c.

Referenced by device2str(), and get_button_template().

#define SKINNY_DEVICE_UNKNOWN   -1

Definition at line 785 of file chan_skinny.c.

Referenced by device2str().

#define SKINNY_DIALTONE   0x21

Definition at line 835 of file chan_skinny.c.

Referenced by handle_offhook_message(), handle_soft_key_event_message(), handle_stimulus_message(), and skinny_ss().

#define SKINNY_HOLD   8

Definition at line 827 of file chan_skinny.c.

#define SKINNY_INVALID   14

Definition at line 832 of file chan_skinny.c.

#define SKINNY_LAMP_BLINK   5

Definition at line 846 of file chan_skinny.c.

Referenced by skinny_call(), and skinny_hold().

#define SKINNY_LAMP_FLASH   4

Definition at line 845 of file chan_skinny.c.

#define SKINNY_LAMP_OFF   1

Definition at line 842 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 843 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 844 of file chan_skinny.c.

#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 818 of file chan_skinny.c.

#define SKINNY_MICON   1

Definition at line 817 of file chan_skinny.c.

#define SKINNY_NOTONE   0x7F

Definition at line 840 of file chan_skinny.c.

Referenced by transmit_tone().

#define SKINNY_OFFHOOK   1

Definition at line 820 of file chan_skinny.c.

Referenced by 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 821 of file chan_skinny.c.

Referenced by build_device(), handle_onhook_message(), handle_soft_key_event_message(), skinny_call(), skinny_hangup(), and transmit_callstate().

#define SKINNY_PARK   11

Definition at line 830 of file chan_skinny.c.

#define SKINNY_PROGRESS   12

Definition at line 831 of file chan_skinny.c.

Referenced by skinny_indicate().

#define SKINNY_REORDER   0x25

Definition at line 838 of file chan_skinny.c.

Referenced by skinny_indicate(), skinny_newcall(), and skinny_ss().

#define SKINNY_RING_FEATURE   4

Definition at line 851 of file chan_skinny.c.

#define SKINNY_RING_INSIDE   2

Definition at line 849 of file chan_skinny.c.

Referenced by skinny_call().

#define SKINNY_RING_OFF   1

Definition at line 848 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 850 of file chan_skinny.c.

#define SKINNY_RINGIN   4

Definition at line 823 of file chan_skinny.c.

Referenced by skinny_call().

#define SKINNY_RINGOUT   3

Definition at line 822 of file chan_skinny.c.

Referenced by skinny_indicate().

#define SKINNY_SILENCE   0x00

Definition at line 834 of file chan_skinny.c.

Referenced by 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 815 of file chan_skinny.c.

Referenced by skinny_hangup(), and transmit_callstate().

#define SKINNY_SPEAKERON   1

Definition at line 814 of file chan_skinny.c.

Referenced by handle_stimulus_message().

#define SKINNY_TRANSFER   10

Definition at line 829 of file chan_skinny.c.

#define SOFT_KEY_EVENT_MESSAGE   0x0026

Definition at line 237 of file chan_skinny.c.

Referenced by handle_message().

#define SOFT_KEY_SET_REQ_MESSAGE   0x0025

Definition at line 235 of file chan_skinny.c.

Referenced by handle_message().

#define SOFT_KEY_SET_RES_MESSAGE   0x0109

Definition at line 635 of file chan_skinny.c.

Referenced by handle_soft_key_set_req_message().

#define SOFT_KEY_TEMPLATE_REQ_MESSAGE   0x0028

Definition at line 245 of file chan_skinny.c.

Referenced by handle_message().

#define SOFT_KEY_TEMPLATE_RES_MESSAGE   0x0108

Definition at line 476 of file chan_skinny.c.

Referenced by handle_soft_key_template_req_message().

#define SOFTKEY_ANSWER   0x0B

Definition at line 506 of file chan_skinny.c.

Referenced by handle_soft_key_event_message().

#define SOFTKEY_BKSPC   0x08

Definition at line 503 of file chan_skinny.c.

Referenced by handle_soft_key_event_message().

#define SOFTKEY_CFWDALL   0x05

Definition at line 500 of file chan_skinny.c.

Referenced by handle_soft_key_event_message().

#define SOFTKEY_CFWDBUSY   0x06

Definition at line 501 of file chan_skinny.c.

Referenced by handle_soft_key_event_message().

#define SOFTKEY_CFWDNOANSWER   0x07

Definition at line 502 of file chan_skinny.c.

Referenced by handle_soft_key_event_message().

#define SOFTKEY_CONFRN   0x0D

Definition at line 508 of file chan_skinny.c.

Referenced by handle_soft_key_event_message().

#define SOFTKEY_ENDCALL   0x09

Definition at line 504 of file chan_skinny.c.

Referenced by handle_soft_key_event_message().

#define SOFTKEY_GPICKUP   0x12

Definition at line 513 of file chan_skinny.c.

Referenced by handle_soft_key_event_message().

#define SOFTKEY_HOLD   0x03

Definition at line 498 of file chan_skinny.c.

Referenced by handle_soft_key_event_message().

#define SOFTKEY_INFO   0x0C

Definition at line 507 of file chan_skinny.c.

Referenced by handle_soft_key_event_message().

#define SOFTKEY_JOIN   0x0F

Definition at line 510 of file chan_skinny.c.

Referenced by handle_soft_key_event_message().

#define SOFTKEY_MEETME   0x10

Definition at line 511 of file chan_skinny.c.

Referenced by handle_soft_key_event_message().

#define SOFTKEY_NEWCALL   0x02

Definition at line 497 of file chan_skinny.c.

Referenced by handle_soft_key_event_message().

#define SOFTKEY_NONE   0x00

Definition at line 495 of file chan_skinny.c.

Referenced by handle_soft_key_event_message().

#define SOFTKEY_PARK   0x0E

Definition at line 509 of file chan_skinny.c.

Referenced by handle_soft_key_event_message().

#define SOFTKEY_PICKUP   0x11

Definition at line 512 of file chan_skinny.c.

Referenced by handle_soft_key_event_message().

#define SOFTKEY_REDIAL   0x01

Definition at line 496 of file chan_skinny.c.

Referenced by handle_soft_key_event_message().

#define SOFTKEY_RESUME   0x0A

Definition at line 505 of file chan_skinny.c.

Referenced by handle_soft_key_event_message().

#define SOFTKEY_TRNSFER   0x04

Definition at line 499 of file chan_skinny.c.

Referenced by handle_soft_key_event_message().

#define SPEED_DIAL_STAT_REQ_MESSAGE   0x000A

Definition at line 204 of file chan_skinny.c.

Referenced by handle_message().

#define SPEED_DIAL_STAT_RES_MESSAGE   0x0091

Definition at line 335 of file chan_skinny.c.

Referenced by handle_speed_dial_stat_req_message().

#define START_MEDIA_TRANSMISSION_MESSAGE   0x008A

Definition at line 290 of file chan_skinny.c.

Referenced by handle_open_receive_channel_ack_message().

#define START_TONE_MESSAGE   0x0082

Definition at line 258 of file chan_skinny.c.

Referenced by transmit_tone().

#define STIMULUS_AUTOANSWER   0x11

Definition at line 385 of file chan_skinny.c.

#define STIMULUS_CALLPARK   0x7E

Definition at line 387 of file chan_skinny.c.

Referenced by handle_stimulus_message().

#define STIMULUS_CALLPICKUP   0x7F

Definition at line 388 of file chan_skinny.c.

#define STIMULUS_CONFERENCE   0x7D

Definition at line 386 of file chan_skinny.c.

Referenced by handle_stimulus_message().

#define STIMULUS_DISPLAY   0x08

Definition at line 382 of file chan_skinny.c.

Referenced by handle_stimulus_message().

#define STIMULUS_FORWARDALL   0x05

Definition at line 379 of file chan_skinny.c.

Referenced by handle_soft_key_event_message(), and handle_stimulus_message().

#define STIMULUS_FORWARDBUSY   0x06

Definition at line 380 of file chan_skinny.c.

Referenced by handle_stimulus_message().

#define STIMULUS_FORWARDNOANSWER   0x07

Definition at line 381 of file chan_skinny.c.

Referenced by handle_stimulus_message().

#define STIMULUS_HOLD   0x03

Definition at line 377 of file chan_skinny.c.

Referenced by handle_stimulus_message().

#define STIMULUS_LINE   0x09

Definition at line 383 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

Definition at line 170 of file chan_skinny.c.

Referenced by handle_message().

#define STIMULUS_NONE   0xFF

Definition at line 389 of file chan_skinny.c.

#define STIMULUS_REDIAL   0x01

Definition at line 375 of file chan_skinny.c.

Referenced by handle_stimulus_message().

#define STIMULUS_SPEEDDIAL   0x02

Definition at line 376 of file chan_skinny.c.

Referenced by handle_stimulus_message().

#define STIMULUS_TRANSFER   0x04

Definition at line 378 of file chan_skinny.c.

Referenced by handle_stimulus_message().

#define STIMULUS_VOICEMAIL   0x0F

Definition at line 384 of file chan_skinny.c.

Referenced by handle_stimulus_message().

#define STOP_MEDIA_TRANSMISSION_MESSAGE   0x008B

Definition at line 308 of file chan_skinny.c.

Referenced by skinny_hold(), and transmit_callstate().

#define STOP_TONE_MESSAGE   0x0083

Definition at line 263 of file chan_skinny.c.

Referenced by transmit_tone().

#define TIME_DATE_REQ_MESSAGE   0x000D

Definition at line 214 of file chan_skinny.c.

Referenced by handle_message().

#define TYPE_LINE   2

Definition at line 854 of file chan_skinny.c.

#define TYPE_TRUNK   1

Definition at line 853 of file chan_skinny.c.

#define UNREGISTER_MESSAGE   0x0027

Definition at line 244 of file chan_skinny.c.

Referenced by handle_message().

#define VERSION_REQ_MESSAGE   0x000F

Definition at line 216 of file chan_skinny.c.

Referenced by handle_message().

#define VERSION_RES_MESSAGE   0x0098

Definition at line 421 of file chan_skinny.c.

Referenced by handle_version_req_message().


Enumeration Type Documentation

enum skinny_codecs

Enumerator:
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 };


Function Documentation

static void* accept_thread ( void *  ignore  )  [static]

Definition at line 4281 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(), LOG_NOTICE, LOG_WARNING, s, sessions, skinny_session(), skinnydebug, and skinnysock.

04282 {
04283    int as;
04284    struct sockaddr_in sin;
04285    socklen_t sinlen;
04286    struct skinnysession *s;
04287    struct protoent *p;
04288    int arg = 1;
04289    pthread_attr_t attr;
04290    pthread_t tcp_thread;
04291 
04292    pthread_attr_init(&attr);
04293    pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
04294 
04295    for (;;) {
04296       sinlen = sizeof(sin);
04297       as = accept(skinnysock, (struct sockaddr *)&sin, &sinlen);
04298       if (as < 0) {
04299          ast_log(LOG_NOTICE, "Accept returned -1: %s\n", strerror(errno));
04300          continue;
04301       }
04302       p = getprotobyname("tcp");
04303       if(p) {
04304          if( setsockopt(as, p->p_proto, TCP_NODELAY, (char *)&arg, sizeof(arg) ) < 0 ) {
04305             ast_log(LOG_WARNING, "Failed to set Skinny tcp connection to TCP_NODELAY mode: %s\n", strerror(errno));
04306          }
04307       }
04308       if (!(s = ast_calloc(1, sizeof(struct skinnysession))))
04309          continue;
04310 
04311       memcpy(&s->sin, &sin, sizeof(sin));
04312       ast_mutex_init(&s->lock);
04313       s->fd = as;
04314       ast_mutex_lock(&sessionlock);
04315       s->next = sessions;
04316       sessions = s;
04317       ast_mutex_unlock(&sessionlock);
04318 
04319       if (ast_pthread_create(&tcp_thread, &attr, skinny_session, s)) {
04320          destroy_session(s);
04321       }
04322    }
04323    if (skinnydebug)
04324       ast_verbose("killing accept thread\n");
04325    close(as);
04326    pthread_attr_destroy(&attr);
04327    return 0;
04328 }

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]

Definition at line 2018 of file chan_skinny.c.

References __ourip, accountcode, skinny_device::addons, skinny_device::addr, amaflags, 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, callreturn, skinny_line::callwaiting, callwaiting, skinny_line::cancallforward, cancallforward, skinny_line::capability, skinny_device::capability, skinny_line::cid_name, cid_name, skinny_line::cid_num, cid_num, skinny_line::context, context, cur_callergroup, cur_pickupgroup, default_capability, default_prefs, DEFAULT_SKINNY_PORT, skinny_speeddial::exten, exten, free, skinny_device::ha, skinny_line::hookstate, skinny_device::id, skinny_line::immediate, immediate, skinny_line::instance, skinny_speeddial::instance, skinny_line::label, skinny_speeddial::label, skinny_line::language, language, skinny_device::lastlineinstance, linelabel, ast_variable::lineno, skinny_device::lines, skinny_line::lock, skinny_addon::lock, skinny_speeddial::lock, LOG_ERROR, LOG_WARNING, skinny_line::mailbox, mailbox, skinny_line::mohinterpret, mohinterpret, skinny_line::mohsuggest, mohsuggest, skinny_line::msgstate, skinny_line::mwiblink, mwiblink, skinny_line::name, ast_variable::name, skinny_device::name, skinny_line::nat, 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, threewaycalling, skinny_line::transfer, 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().

02019 {
02020    struct skinny_device *d;
02021    struct skinny_line *l;
02022    struct skinny_speeddial *sd;
02023    struct skinny_addon *a;
02024    int lineInstance = 1;
02025    int speeddialInstance = 1;
02026    int y = 0;
02027 
02028    if (!(d = ast_calloc(1, sizeof(struct skinny_device)))) {
02029       return NULL;
02030    } else {
02031       ast_copy_string(d->name, cat, sizeof(d->name));
02032       d->lastlineinstance = 1;
02033       d->capability = default_capability;
02034       d->prefs = default_prefs;
02035       while(v) {
02036          if (!strcasecmp(v->name, "host")) {
02037             if (ast_get_ip(&d->addr, v->value)) {
02038                free(d);
02039                return NULL;
02040             }
02041          } else if (!strcasecmp(v->name, "port")) {
02042             d->addr.sin_port = htons(atoi(v->value));
02043          } else if (!strcasecmp(v->name, "device")) {
02044             ast_copy_string(d->id, v->value, sizeof(d->id));
02045          } else if (!strcasecmp(v->name, "permit") || !strcasecmp(v->name, "deny")) {
02046             d->ha = ast_append_ha(v->name, v->value, d->ha);
02047          } else if (!strcasecmp(v->name, "context")) {
02048             ast_copy_string(context, v->value, sizeof(context));
02049          } else if (!strcasecmp(v->name, "allow")) {
02050             ast_parse_allow_disallow(&d->prefs, &d->capability, v->value, 1);
02051          } else if (!strcasecmp(v->name, "disallow")) {
02052             ast_parse_allow_disallow(&d->prefs, &d->capability, v->value, 0);
02053          } else if (!strcasecmp(v->name, "version")) {
02054             ast_copy_string(d->version_id, v->value, sizeof(d->version_id));
02055          } else if (!strcasecmp(v->name, "nat")) {
02056             nat = ast_true(v->value);
02057          } else if (!strcasecmp(v->name, "callerid")) {
02058             if (!strcasecmp(v->value, "asreceived")) {
02059                cid_num[0] = '\0';
02060                cid_name[0] = '\0';
02061             } else {
02062                ast_callerid_split(v->value, cid_name, sizeof(cid_name), cid_num, sizeof(cid_num));
02063             }
02064          } else if (!strcasecmp(v->name, "language")) {
02065             ast_copy_string(language, v->value, sizeof(language));
02066          } else if (!strcasecmp(v->name, "accountcode")) {
02067             ast_copy_string(accountcode, v->value, sizeof(accountcode));
02068          } else if (!strcasecmp(v->name, "amaflags")) {
02069             y = ast_cdr_amaflags2int(v->value);
02070             if (y < 0) {
02071                ast_log(LOG_WARNING, "Invalid AMA flags: %s at line %d\n", v->value, v->lineno);
02072             } else {
02073                amaflags = y;
02074             }
02075          } else if (!strcasecmp(v->name, "mohinterpret") || !strcasecmp(v->name, "musiconhold")) {
02076             ast_copy_string(mohinterpret, v->value, sizeof(mohinterpret));
02077          } else if (!strcasecmp(v->name, "mohsuggest")) {
02078             ast_copy_string(mohsuggest, v->value, sizeof(mohsuggest));
02079          } else if (!strcasecmp(v->name, "callgroup")) {
02080             cur_callergroup = ast_get_group(v->value);
02081          } else if (!strcasecmp(v->name, "pickupgroup")) {
02082             cur_pickupgroup = ast_get_group(v->value);
02083          } else if (!strcasecmp(v->name, "immediate")) {
02084             immediate = ast_true(v->value);
02085          } else if (!strcasecmp(v->name, "cancallforward")) {
02086             cancallforward = ast_true(v->value);
02087          } else if (!strcasecmp(v->name, "mailbox")) {
02088             ast_copy_string(mailbox, v->value, sizeof(mailbox));
02089          } else if (!strcasecmp(v->name, "callreturn")) {
02090             callreturn = ast_true(v->value);
02091          } else if (!strcasecmp(v->name, "callwaiting")) {
02092             callwaiting = ast_true(v->value);
02093          } else if (!strcasecmp(v->name, "transfer")) {
02094             transfer = ast_true(v->value);
02095          } else if (!strcasecmp(v->name, "threewaycalling")) {
02096             threewaycalling = ast_true(v->value);
02097          } else if (!strcasecmp(v->name, "mwiblink")) {
02098             mwiblink = ast_true(v->value);
02099          } else if (!strcasecmp(v->name, "linelabel")) {
02100             ast_copy_string(linelabel, v->value, sizeof(linelabel));
02101          } else if (!strcasecmp(v->name, "speeddial")) {
02102             if (!(sd = ast_calloc(1, sizeof(struct skinny_speeddial)))) {
02103                return NULL;
02104             } else {
02105                char *stringp, *exten, *label;
02106                stringp = v->value;
02107                exten = strsep(&stringp, ",");
02108                label = strsep(&stringp, ",");
02109                ast_mutex_init(&sd->lock);
02110                ast_copy_string(sd->exten, exten, sizeof(sd->exten));
02111                if (label)
02112                   ast_copy_string(sd->label, label, sizeof(sd->label));
02113                else
02114                   ast_copy_string(sd->label, exten, sizeof(sd->label));
02115                sd->instance = speeddialInstance++;
02116 
02117                sd->parent = d;
02118 
02119                sd->next = d->speeddials;
02120                d->speeddials = sd;
02121             }
02122          } else if (!strcasecmp(v->name, "addon")) {
02123             if (!(a = ast_calloc(1, sizeof(struct skinny_addon)))) {
02124                return NULL;
02125             } else {
02126                ast_mutex_init(&a->lock);
02127                ast_copy_string(a->type, v->value, sizeof(a->type));
02128 
02129                a->next = d->addons;
02130                d->addons = a;
02131             }
02132          } else if (!strcasecmp(v->name, "trunk") || !strcasecmp(v->name, "line")) {
02133             if (!(l = ast_calloc(1, sizeof(struct skinny_line)))) {
02134                return NULL;
02135             } else {
02136                ast_mutex_init(&l->lock);
02137                ast_copy_string(l->name, v->value, sizeof(l->name));
02138 
02139                /* XXX Should we check for uniqueness?? XXX */
02140                ast_copy_string(l->context, context, sizeof(l->context));
02141                ast_copy_string(l->cid_num, cid_num, sizeof(l->cid_num));
02142                ast_copy_string(l->cid_name, cid_name, sizeof(l->cid_name));
02143                ast_copy_string(l->label, linelabel, sizeof(l->label));
02144                ast_copy_string(l->language, language, sizeof(l->language));
02145                ast_copy_string(l->mohinterpret, mohinterpret, sizeof(l->mohinterpret));
02146                ast_copy_string(l->mohsuggest, mohsuggest, sizeof(l->mohsuggest));
02147                ast_copy_string(l->mailbox, mailbox, sizeof(l->mailbox));
02148                ast_copy_string(l->mailbox, mailbox, sizeof(l->mailbox));
02149                if (!ast_strlen_zero(mailbox)) {
02150                   if (option_verbose > 2)
02151                      ast_verbose(VERBOSE_PREFIX_3 "Setting mailbox '%s' on %s@%s\n", mailbox, d->name, l->name);
02152                }
02153                l->msgstate = -1;
02154                l->capability = d->capability;
02155                l->prefs = d->prefs;
02156                l->parent = d;
02157                if (!strcasecmp(v->name, "trunk")) {
02158                   l->type = TYPE_TRUNK;
02159                } else {
02160                   l->type = TYPE_LINE;
02161                }
02162                l->immediate = immediate;
02163                l->callgroup = cur_callergroup;
02164                l->pickupgroup = cur_pickupgroup;
02165                l->callreturn = callreturn;
02166                l->cancallforward = cancallforward;
02167                l->callwaiting = callwaiting;
02168                l->transfer = transfer;
02169                l->threewaycalling = threewaycalling;
02170                l->mwiblink = mwiblink;
02171                l->onhooktime = time(NULL);
02172                l->instance = lineInstance++;
02173                /* ASSUME we're onhook at this point */
02174                l->hookstate = SKINNY_ONHOOK;
02175                l->nat = nat;
02176 
02177                l->next = d->lines;
02178                d->lines = l;
02179             }
02180          } else {
02181             ast_log(LOG_WARNING, "Don't know keyword '%s' at line %d\n", v->name, v->lineno);
02182          }
02183          v = v->next;
02184       }
02185 
02186       if (!d->lines) {
02187          ast_log(LOG_ERROR, "A Skinny device must have at least one line!\n");
02188          return NULL;
02189       }
02190       if (/*d->addr.sin_addr.s_addr && */!ntohs(d->addr.sin_port)) {
02191          d->addr.sin_port = htons(DEFAULT_SKINNY_PORT);
02192       }
02193 #if 0
02194       /* I don't think we need this anymore at all, since d->ourip is set in skinny_register now */
02195       if (d->addr.sin_addr.s_addr) {
02196          /* XXX See note above, in 'host' option. */
02197          if (ast_ouraddrfor(&d->addr.sin_addr, &d->ourip)) {
02198             d->ourip = __ourip;
02199          }
02200       } else {
02201          d->ourip = __ourip;
02202       }
02203 #endif
02204    }
02205    return d;
02206 }

static int codec_ast2skinny ( int  astcodec  )  [static]

Definition at line 1322 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().

01323 {
01324    switch (astcodec) {
01325    case AST_FORMAT_ALAW:
01326       return SKINNY_CODEC_ALAW;
01327    case AST_FORMAT_ULAW:
01328       return SKINNY_CODEC_ULAW;
01329    case AST_FORMAT_G723_1:
01330       return SKINNY_CODEC_G723_1;
01331    case AST_FORMAT_G729A:
01332       return SKINNY_CODEC_G729A;
01333    case AST_FORMAT_G726_AAL2: /* XXX Is this right? */
01334       return SKINNY_CODEC_G726_32;
01335    case AST_FORMAT_H261:
01336       return SKINNY_CODEC_H261;
01337    case AST_FORMAT_H263:
01338       return SKINNY_CODEC_H263;
01339    default:
01340       return 0;
01341    }
01342 }

static int codec_skinny2ast ( enum skinny_codecs  skinnycodec  )  [static]

Definition at line 1300 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().

01301 {
01302    switch (skinnycodec) {
01303    case SKINNY_CODEC_ALAW:
01304       return AST_FORMAT_ALAW;
01305    case SKINNY_CODEC_ULAW:
01306       return AST_FORMAT_ULAW;
01307    case SKINNY_CODEC_G723_1:
01308       return AST_FORMAT_G723_1;
01309    case SKINNY_CODEC_G729A:
01310       return AST_FORMAT_G729A;
01311    case SKINNY_CODEC_G726_32:
01312       return AST_FORMAT_G726_AAL2; /* XXX Is this right? */
01313    case SKINNY_CODEC_H261:
01314       return AST_FORMAT_H261;
01315    case SKINNY_CODEC_H263:
01316       return AST_FORMAT_H263;
01317    default:
01318       return 0;
01319    }
01320 }

static char* complete_skinny_reset ( const char *  line,
const char *  word,
int  pos,
int  state 
) [static]

Definition at line 1789 of file chan_skinny.c.

References ast_strdup, devices, skinny_device::id, skinny_device::next, and result.

01790 {
01791    struct skinny_device *d;
01792 
01793    char *result = NULL;
01794    int wordlen = strlen(word);
01795    int which = 0;
01796 
01797    if (pos == 2) {
01798       for (d = devices; d && !result; d = d->next) {
01799          if (!strncasecmp(word, d->id, wordlen) && ++which > state)
01800             result = ast_strdup(d->id);
01801       }
01802    }
01803 
01804    return result;
01805 }

static char* control2str ( int  ind  )  [static]

Definition at line 2597 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.

02597                                   {
02598    char *tmp;
02599 
02600    switch (ind) {
02601    case AST_CONTROL_HANGUP:
02602       return "Other end has hungup";
02603    case AST_CONTROL_RING:
02604       return "Local ring";
02605    case AST_CONTROL_RINGING:
02606       return "Remote end is ringing";
02607    case AST_CONTROL_ANSWER:
02608       return "Remote end has answered";
02609    case AST_CONTROL_BUSY:
02610       return "Remote end is busy";
02611    case AST_CONTROL_TAKEOFFHOOK:
02612       return "Make it go off hook";
02613    case AST_CONTROL_OFFHOOK:
02614       return "Line is off hook";
02615    case AST_CONTROL_CONGESTION:
02616       return "Congestion (circuits busy)";
02617    case AST_CONTROL_FLASH:
02618       return "Flash hook";
02619    case AST_CONTROL_WINK:
02620       return "Wink";
02621    case AST_CONTROL_OPTION:
02622       return "Set a low-level option";
02623    case AST_CONTROL_RADIO_KEY:
02624       return "Key Radio";
02625    case AST_CONTROL_RADIO_UNKEY:
02626       return "Un-Key Radio";
02627    case AST_CONTROL_PROGRESS:
02628       return "Remote end is making Progress";
02629    case AST_CONTROL_PROCEEDING:
02630       return "Remote end is proceeding";
02631    case AST_CONTROL_HOLD:
02632       return "Hold";
02633    case AST_CONTROL_UNHOLD:
02634       return "Unhold";
02635    case -1:
02636       return "Stop tone";
02637    default:
02638       if (!(tmp = ast_threadstorage_get(&control2str_threadbuf, CONTROL2STR_BUFSIZE)))
02639                         return "Unknown";
02640       snprintf(tmp, CONTROL2STR_BUFSIZE, "UNKNOWN-%d", ind);
02641       return tmp;
02642    }
02643 }

static void delete_devices ( void   )  [static]

Definition at line 4567 of file chan_skinny.c.

References ast_mutex_destroy(), ast_mutex_lock(), devices, free, skinny_device::lines, skinny_speeddial::lock, skinny_line::lock, skinny_speeddial::next, skinny_line::next, and skinny_device::speeddials.

Referenced by unload_module().

04568 {
04569    struct skinny_device *d, *dlast;
04570    struct skinny_line *l, *llast;
04571    struct skinny_speeddial *sd, *sdlast;
04572    struct skinny_addon *a, *alast;
04573 
04574    ast_mutex_lock(&devicelock);
04575 
04576    /* Delete all devices */
04577    for (d=devices;d;) {
04578       /* Delete all lines for this device */
04579       for (l=d->lines;l;) {
04580          llast = l;
04581          l = l->next;
04582          ast_mutex_destroy(&llast->lock);
04583          free(llast);
04584       }
04585       /* Delete all speeddials for this device */
04586       for (sd=d->speeddials;sd;) {
04587          sdlast = sd;
04588          sd = sd->next;
04589          ast_mutex_destroy(&sdlast->lock);
04590          free(sdlast);
04591       }
04592       /* Delete all addons for this device */
04593       for (a=d->addons;a;) {
04594          alast = a;
04595          a = a->next;
04596          ast_mutex_destroy(&alast->lock);
04597          free(alast);
04598       }
04599       dlast = d;
04600       d = d->next;
04601       free(dlast);
04602    }
04603    devices=NULL;
04604    ast_mutex_unlock(&devicelock);
04605 }

static void destroy_session ( struct skinnysession s  )  [static]

Definition at line 4124 of file chan_skinny.c.

References ast_log(), ast_mutex_destroy(), ast_mutex_lock(), ast_mutex_unlock(), free, LOG_WARNING, skinnysession::next, s, and sessions.

04125 {
04126    struct skinnysession *cur, *prev = NULL;
04127    ast_mutex_lock(&sessionlock);
04128    cur = sessions;
04129    while(cur) {
04130       if (cur == s) {
04131          break;
04132       }
04133       prev = cur;
04134       cur = cur->next;
04135    }
04136    if (cur) {
04137       if (prev) {
04138          prev->next = cur->next;
04139       } else {
04140          sessions = cur->next;
04141       }
04142       if (s->fd > -1) {
04143          close(s->fd);
04144       }
04145       ast_mutex_destroy(&s->lock);
04146       free(s);
04147    } else {
04148       ast_log(LOG_WARNING, "Trying to delete nonexistent session %p?\n", s);
04149    }
04150    ast_mutex_unlock(&sessionlock);
04151 }

static char* device2str ( int  type  )  [static]

Definition at line 1843 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_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().

01844 {
01845    char *tmp;
01846 
01847    switch (type) {
01848    case SKINNY_DEVICE_NONE:
01849       return "No Device";
01850    case SKINNY_DEVICE_30SPPLUS:
01851       return "30SP Plus";
01852    case SKINNY_DEVICE_12SPPLUS:
01853       return "12SP Plus";
01854    case SKINNY_DEVICE_12SP:
01855       return "12SP";
01856    case SKINNY_DEVICE_12:
01857       return "12";
01858    case SKINNY_DEVICE_30VIP:
01859       return "30VIP";
01860    case SKINNY_DEVICE_7910:
01861       return "7910";
01862    case SKINNY_DEVICE_7960:
01863       return "7960";
01864    case SKINNY_DEVICE_7940:
01865       return "7940";
01866    case SKINNY_DEVICE_7935:
01867       return "7935";
01868    case SKINNY_DEVICE_ATA186:
01869       return "ATA186";
01870    case SKINNY_DEVICE_7941:
01871       return "7941";
01872    case SKINNY_DEVICE_7971:
01873       return "7971";
01874    case SKINNY_DEVICE_7985:
01875       return "7985";
01876    case SKINNY_DEVICE_7911:
01877       return "7911";
01878    case SKINNY_DEVICE_7961GE:
01879       return "7961GE";
01880    case SKINNY_DEVICE_7941GE:
01881       return "7941GE";
01882    case SKINNY_DEVICE_7905:
01883       return "7905";
01884    case SKINNY_DEVICE_7920:
01885       return "7920";
01886    case SKINNY_DEVICE_7970:
01887       return "7970";
01888    case SKINNY_DEVICE_7912:
01889       return "7912";
01890    case SKINNY_DEVICE_7902:
01891       return "7902";
01892    case SKINNY_DEVICE_CIPC:
01893       return "IP Communicator";
01894    case SKINNY_DEVICE_7961:
01895       return "7961";
01896    case SKINNY_DEVICE_7936:
01897       return "7936";
01898    case SKINNY_DEVICE_SCCPGATEWAY_AN:
01899       return "SCCPGATEWAY_AN";
01900    case SKINNY_DEVICE_SCCPGATEWAY_BRI:
01901       return "SCCPGATEWAY_BRI";
01902    case SKINNY_DEVICE_UNKNOWN:
01903       return "Unknown";
01904    default:
01905       if (!(tmp = ast_threadstorage_get(&device2str_threadbuf, DEVICE2STR_BUFSIZE)))
01906          return "Unknown";
01907       snprintf(tmp, DEVICE2STR_BUFSIZE, "UNKNOWN-%d", type);
01908       return tmp;
01909    }
01910 }

static void do_housekeeping ( struct skinnysession s  )  [static]

Definition at line 1697 of file chan_skinny.c.

References s, and transmit_displaymessage().

Referenced by handle_keep_alive_message(), handle_onhook_message(), handle_soft_key_event_message(), and skinny_hangup().

01698 {
01699 /*
01700    int new;
01701    int old;
01702    struct skinny_device *d = s->device;
01703    struct skinny_line *l;
01704 */
01705 
01706    transmit_displaymessage(s, NULL);
01707 
01708 /*
01709    for (l = d->lines; l; l = l->next) {
01710       if (has_voicemail(l)) {
01711          if (skinnydebug)
01712             ast_verbose("Checking for voicemail Skinny %s@%s\n", l->name, d->name);
01713          ast_app_inboxcount(l->mailbox, &new, &old);
01714          if (skinnydebug)
01715             ast_verbose("Skinny %s@%s has voicemail!\n", l->name, d->name);
01716          transmit_lamp_indication(s, STIMULUS_VOICEMAIL, l->instance, l->mwiblink?SKINNY_LAMP_BLINK:SKINNY_LAMP_ON);
01717       } else {
01718          transmit_lamp_indication(s, STIMULUS_VOICEMAIL, l->instance, SKINNY_LAMP_OFF);
01719       }
01720    }
01721 */
01722 }

static void* do_monitor ( void *  data  )  [static]

Definition at line 4330 of file chan_skinny.c.

References ast_io_wait(), ast_mutex_lock(), ast_mutex_unlock(), ast_sched_runq(), ast_sched_wait(), and io.

04331 {
04332    int res;
04333 
04334    /* This thread monitors all the interfaces which are not yet in use
04335       (and thus do not have a separate thread) indefinitely */
04336    /* From here on out, we die whenever asked */
04337    for(;;) {
04338       pthread_testcancel();
04339       /* Wait for sched or io */
04340       res = ast_sched_wait(sched);
04341       if ((res < 0) || (res > 1000)) {
04342          res = 1000;
04343       }
04344       res = ast_io_wait(io, res);
04345       ast_mutex_lock(&monlock);
04346       if (res >= 0) {
04347          ast_sched_runq(sched);
04348       }
04349       ast_mutex_unlock(&monlock);
04350    }
04351    /* Never reached */
04352    return NULL;
04353 
04354 }

static struct skinny_line* find_line_by_instance ( struct skinny_device d,
int  instance 
) [static]

Definition at line 1188 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_line_state_req_message(), handle_offhook_message(), handle_soft_key_event_message(), and handle_stimulus_message().

01189 {
01190    struct skinny_line *l;
01191 
01192    for (l = d->lines; l; l = l->next) {
01193       if (l->instance == instance)
01194          break;
01195    }
01196 
01197    if (!l) {
01198       ast_log(LOG_WARNING, "Could not find line with instance '%d' on device '%s'\n", instance, d->name);
01199    }
01200    return l;
01201 }

static struct skinny_line* find_line_by_name ( const char *  dest  )  [static]

Definition at line 1203 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().

01204 {
01205    struct skinny_line *l;
01206    struct skinny_device *d;
01207    char line[256];
01208    char *at;
01209    char *device;
01210 
01211    ast_copy_string(line, dest, sizeof(line));
01212    at = strchr(line, '@');
01213    if (!at) {
01214       ast_log(LOG_NOTICE, "Device '%s' has no @ (at) sign!\n", dest);
01215       return NULL;
01216    }
01217    *at++ = '\0';
01218    device = at;
01219    ast_mutex_lock(&devicelock);
01220    for (d = devices; d; d = d->next) {
01221       if (!strcasecmp(d->name, device)) {
01222          if (skinnydebug)
01223             ast_verbose("Found device: %s\n", d->name);
01224          /* Found the device */
01225          for (l = d->lines; l; l = l->next) {
01226             /* Search for the right line */
01227             if (!strcasecmp(l->name, line)) {
01228                ast_mutex_unlock(&devicelock);
01229                return l;
01230             }
01231          }
01232       }
01233    }
01234    /* Device not found */
01235    ast_mutex_unlock(&devicelock);
01236    return NULL;
01237 }

static struct skinny_speeddial* find_speeddial_by_instance ( struct skinny_device d,
int  instance 
) [static]

Definition at line 1285 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().

01286 {
01287    struct skinny_speeddial *sd;
01288 
01289    for (sd = d->speeddials; sd; sd = sd->next) {
01290       if (sd->instance == instance)
01291          break;
01292    }
01293 
01294    if (!sd) {
01295       ast_log(LOG_WARNING, "Could not find speeddial with instance '%d' on device '%s'\n", instance, d->name);
01296    }
01297    return sd;
01298 }

static struct skinny_subchannel* find_subchannel_by_instance_reference ( struct skinny_device d,
int  instance,
int  reference 
) [static]

Definition at line 1240 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_keypad_button_message(), handle_offhook_message(), handle_onhook_message(), handle_soft_key_event_message(), and handle_stimulus_message().

01241 {
01242    struct skinny_line *l = find_line_by_instance(d, instance);
01243    struct skinny_subchannel *sub;
01244 
01245    if (!l) {
01246       return NULL;
01247    }
01248 
01249    for (sub = l->sub; sub; sub = sub->next) {
01250       if (sub->callid == reference)
01251          break;
01252    }
01253 
01254    if (!sub) {
01255       ast_log(LOG_WARNING, "Could not find subchannel with reference '%d' on '%s'\n", reference, d->name);
01256    }
01257    return sub;
01258 }

static struct skinny_subchannel* find_subchannel_by_reference ( struct skinny_device d,
int  reference 
) [static]

Definition at line 1261 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().

01262 {
01263    struct skinny_line *l;
01264    struct skinny_subchannel *sub = NULL;
01265 
01266    for (l = d->lines; l; l = l->next) {
01267       for (sub = l->sub; sub; sub = sub->next) {
01268          if (sub->callid == reference)
01269             break;
01270       }
01271       if (sub)
01272          break;
01273    }
01274 
01275    if (!l) {
01276       ast_log(LOG_WARNING, "Could not find any lines that contained a subchannel with reference '%d' on device '%s'\n", reference, d->name);
01277    } else {
01278       if (!sub) {
01279          ast_log(LOG_WARNING, "Could not find subchannel with reference '%d' on '%s@%s'\n", reference, l->name, d->name);
01280       }
01281    }
01282    return sub;
01283 }

static void* get_button_template ( struct skinnysession s,
struct button_definition_template btn 
) [static]

Definition at line 1059 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, LOG_WARNING, skinny_addon::next, s, 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_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().

01060 {
01061    struct skinny_device *d = s->device;
01062    struct skinny_addon *a = d->addons;
01063    int i;
01064 
01065    switch (d->type) {
01066       case SKINNY_DEVICE_30SPPLUS:
01067       case SKINNY_DEVICE_30VIP:
01068          /* 13 rows, 2 columns */
01069          for (i = 0; i < 4; i++)
01070             (btn++)->buttonDefinition = BT_LINE;
01071          (btn++)->buttonDefinition = BT_REDIAL;
01072          (btn++)->buttonDefinition = BT_VOICEMAIL;
01073          (btn++)->buttonDefinition = BT_CALLPARK;
01074          (btn++)->buttonDefinition = BT_FORWARDALL;
01075          (btn++)->buttonDefinition = BT_CONFERENCE;
01076          for (i = 0; i < 4; i++)
01077             (btn++)->buttonDefinition = BT_NONE;
01078          for (i = 0; i < 13; i++)
01079             (btn++)->buttonDefinition = BT_SPEEDDIAL;
01080          
01081          break;
01082       case SKINNY_DEVICE_12SPPLUS:
01083       case SKINNY_DEVICE_12SP:
01084       case SKINNY_DEVICE_12:
01085          /* 6 rows, 2 columns */
01086          for (i = 0; i < 2; i++)
01087             (btn++)->buttonDefinition = BT_LINE;
01088          (btn++)->buttonDefinition = BT_REDIAL;
01089          for (i = 0; i < 3; i++)
01090             (btn++)->buttonDefinition = BT_SPEEDDIAL;
01091          (btn++)->buttonDefinition = BT_HOLD;
01092          (btn++)->buttonDefinition = BT_TRANSFER;
01093          (btn++)->buttonDefinition = BT_FORWARDALL;
01094          (btn++)->buttonDefinition = BT_CALLPARK;
01095          (btn++)->buttonDefinition = BT_VOICEMAIL;
01096          (btn++)->buttonDefinition = BT_CONFERENCE;
01097          break;
01098       case SKINNY_DEVICE_7910:
01099          (btn++)->buttonDefinition = BT_LINE;
01100          (btn++)->buttonDefinition = BT_HOLD;
01101          (btn++)->buttonDefinition = BT_TRANSFER;
01102          (btn++)->buttonDefinition = BT_DISPLAY;
01103          (btn++)->buttonDefinition = BT_VOICEMAIL;
01104          (btn++)->buttonDefinition = BT_CONFERENCE;
01105          (btn++)->buttonDefinition = BT_FORWARDALL;
01106          for (i = 0; i < 2; i++)
01107             (btn++)->buttonDefinition = BT_SPEEDDIAL;
01108          (btn++)->buttonDefinition = BT_REDIAL;
01109          break;
01110       case SKINNY_DEVICE_7960:
01111       case SKINNY_DEVICE_7961:
01112       case SKINNY_DEVICE_7961GE:
01113          for (i = 0; i < 6; i++)
01114             (btn++)->buttonDefinition = BT_CUST_LINESPEEDDIAL;
01115          break;
01116       case SKINNY_DEVICE_7940:
01117       case SKINNY_DEVICE_7941:
01118       case SKINNY_DEVICE_7941GE:
01119          for (i = 0; i < 2; i++)
01120             (btn++)->buttonDefinition = BT_CUST_LINESPEEDDIAL;
01121          break;
01122       case SKINNY_DEVICE_7935:
01123       case SKINNY_DEVICE_7936:
01124          for (i = 0; i < 2; i++)
01125             (btn++)->buttonDefinition = BT_LINE;
01126          break;
01127       case SKINNY_DEVICE_ATA186:
01128          (btn++)->buttonDefinition = BT_LINE;
01129          break;
01130       case SKINNY_DEVICE_7970:
01131       case SKINNY_DEVICE_7971:
01132       case SKINNY_DEVICE_CIPC:
01133          for (i = 0; i < 8; i++)
01134             (btn++)->buttonDefinition = BT_CUST_LINESPEEDDIAL;
01135          break;
01136       case SKINNY_DEVICE_7985:
01137          /* XXX I have no idea what the buttons look like on these. */
01138          ast_log(LOG_WARNING, "Unsupported device type '%d (7985)' found.\n", d->type);
01139          break;
01140       case SKINNY_DEVICE_7912:
01141       case SKINNY_DEVICE_7911:
01142       case SKINNY_DEVICE_7905:
01143          (btn++)->buttonDefinition = BT_LINE;
01144          (btn++)->buttonDefinition = BT_HOLD;
01145          break;
01146       case SKINNY_DEVICE_7920:
01147          /* XXX I don't know if this is right. */
01148          for (i = 0; i < 4; i++)
01149             (btn++)->buttonDefinition = BT_CUST_LINESPEEDDIAL;
01150          break;
01151       case SKINNY_DEVICE_7902:
01152          ast_log(LOG_WARNING, "Unsupported device type '%d (7902)' found.\n", d->type);
01153          break;
01154       case SKINNY_DEVICE_SCCPGATEWAY_AN:
01155       case SKINNY_DEVICE_SCCPGATEWAY_BRI:
01156          ast_log(LOG_WARNING, "Unsupported device type '%d (SCCP gateway)' found.\n", d->type);
01157          break;
01158       default:
01159          ast_log(LOG_WARNING, "Unknown device type '%d' found.\n", d->type);
01160          break;
01161    }
01162 
01163    for (a = d->addons; a; a = a->next) {
01164       if (!strcasecmp(a->type, "7914")) {
01165          for (i = 0; i < 14; i++)
01166             (btn++)->buttonDefinition = BT_CUST_LINESPEEDDIAL;
01167       } else {
01168          ast_log(LOG_WARNING, "Unknown addon type '%s' found.  Skipping.\n", a->type);
01169       }
01170    }
01171 
01172    return btn;
01173 }

static int get_input ( struct skinnysession s  )  [static]

Definition at line 4153 of file chan_skinny.c.

References ast_log(), ast_mutex_lock(), ast_mutex_unlock(), ast_verbose(), pollfd::events, pollfd::fd, htolel, letohl, LOG_WARNING, poll(), POLLIN, pollfd::revents, s, skinny_unregister(), and skinnydebug.

04154 {
04155    int res;
04156    int dlen = 0;
04157    struct pollfd fds[1];
04158 
04159    fds[0].fd = s->fd;
04160    fds[0].events = POLLIN;
04161    fds[0].revents = 0;
04162    res = poll(fds, 1, -1);
04163 
04164    if (res < 0) {
04165       if (errno != EINTR)
04166       {
04167          ast_log(LOG_WARNING, "Select returned error: %s\n", strerror(errno));
04168          return res;
04169       }
04170    }
04171    if (fds[0].revents) {
04172       ast_mutex_lock(&s->lock);
04173       memset(s->inbuf,0,sizeof(s->inbuf));
04174       res = read(s->fd, s->inbuf, 4);
04175       if (res < 0) {
04176          ast_log(LOG_WARNING, "read() returned error: %s\n", strerror(errno));
04177 
04178          if (skinnydebug)
04179             ast_verbose("Skinny Client was lost, unregistering\n");
04180          
04181          skinny_unregister(NULL,s);
04182          ast_mutex_unlock(&s->lock);
04183          return res;
04184       } else if (res != 4) {
04185          ast_log(LOG_WARNING, "Skinny Client sent less data than expected.  Expected 4 but got %d.\n", res);
04186          ast_mutex_unlock(&s->lock);
04187          
04188          if (res == 0) {
04189             if (skinnydebug)
04190                ast_verbose("Skinny Client was lost, unregistering\n");
04191             skinny_unregister(NULL, s);
04192          }
04193            
04194          return -1;
04195       }
04196       
04197       dlen = letohl(*(int *)s->inbuf);
04198       if (dlen < 0) {
04199          ast_log(LOG_WARNING, "Skinny Client sent invalid data.\n");
04200          ast_mutex_unlock(&s->lock);
04201          return -1;
04202       }
04203       if (dlen+8 > sizeof(s->inbuf)) {
04204          dlen = sizeof(s->inbuf) - 8;
04205       }
04206       *(int *)s->inbuf = htolel(dlen);
04207 
04208       res = read(s->fd, s->inbuf+4, dlen+4);
04209       ast_mutex_unlock(&s->lock);
04210       if (res < 0) {
04211          ast_log(LOG_WARNING, "read() returned error: %s\n", strerror(errno));
04212          return res;
04213       } else if (res != (dlen+4)) {
04214          ast_log(LOG_WARNING, "Skinny Client sent less data than expected.\n");
04215          return -1;
04216       }
04217       return res;
04218    }
04219    return 0;
04220 }

static int handle_alarm_message ( struct skinny_req req,
struct skinnysession s 
) [static]

Definition at line 3598 of file chan_skinny.c.

References skinny_data::alarm, ast_verbose(), skinny_req::data, alarm_message::displayMessage, and skinnydebug.

Referenced by handle_message().

03599 {
03600    /* no response necessary */
03601    if (skinnydebug)
03602       ast_verbose("Received Alarm Message: %s\n", req->data.alarm.displayMessage);
03603 
03604    return 1;
03605 }

static int handle_button_template_req_message ( struct skinny_req req,
struct skinnysession s 
) [static]

Definition at line 3462 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_definition::buttonDefinition, button_definition_template::buttonDefinition, skinny_data::buttontemplate, skinny_req::data, button_template_res_message::definition, get_button_template(), htolel, skinny_speeddial::instance, skinny_line::instance, button_definition::instanceNumber, skinny_device::lines, skinny_speeddial::next, skinny_line::next, req_alloc(), s, and skinny_device::speeddials.

Referenced by handle_message().

03463 {
03464    struct skinny_device *d = s->device;
03465    struct skinny_line *l;
03466    int i;
03467 
03468    struct skinny_speeddial *sd;
03469    struct button_definition_template btn[42];
03470    int lineInstance = 1;
03471    int speeddialInstance = 1;
03472    int buttonCount = 0;
03473 
03474    if (!(req = req_alloc(sizeof(struct button_template_res_message), BUTTON_TEMPLATE_RES_MESSAGE)))
03475       return -1;
03476 
03477    memset(&btn, 0, sizeof(btn));
03478 
03479    get_button_template(s, btn);
03480 
03481    for (i=0; i<42; i++) {
03482       int btnSet = 0;
03483       switch (btn[i].buttonDefinition) {
03484          case BT_CUST_LINESPEEDDIAL:
03485             /* assume failure */
03486             req->data.buttontemplate.definition[i].buttonDefinition = BT_NONE;
03487             req->data.buttontemplate.definition[i].instanceNumber = htolel(0);
03488 
03489             for (l = d->lines; l; l = l->next) {
03490                if (l->instance == lineInstance) {
03491                   ast_verbose("Adding button: %d, %d\n", BT_LINE, lineInstance);
03492                   req->data.buttontemplate.definition[i].buttonDefinition = BT_LINE;
03493                   req->data.buttontemplate.definition[i].instanceNumber = htolel(lineInstance);
03494                   lineInstance++;
03495                   buttonCount++;
03496                   btnSet = 1;
03497                   break;
03498                }
03499             }
03500 
03501             if (!btnSet) {
03502                for (sd = d->speeddials; sd; sd = sd->next) {
03503                   if (sd->instance == speeddialInstance) {
03504                      ast_verbose("Adding button: %d, %d\n", BT_SPEEDDIAL, speeddialInstance);
03505                      req->data.buttontemplate.definition[i].buttonDefinition = BT_SPEEDDIAL;
03506                      req->data.buttontemplate.definition[i].instanceNumber = htolel(speeddialInstance);
03507                      speeddialInstance++;
03508                      buttonCount++;
03509                      btnSet = 1;
03510                      break;
03511                   }
03512                }
03513             }
03514             break;
03515          case BT_LINE:
03516             req->data.buttontemplate.definition[i].buttonDefinition = htolel(BT_NONE);
03517             req->data.buttontemplate.definition[i].instanceNumber = htolel(0);
03518 
03519             for (l = d->lines; l; l = l->next) {
03520                if (l->instance == lineInstance) {
03521                   ast_verbose("Adding button: %d, %d\n", BT_LINE, lineInstance);
03522                   req->data.buttontemplate.definition[i].buttonDefinition = BT_LINE;
03523                   req->data.buttontemplate.definition[i].instanceNumber = htolel(lineInstance);
03524                   lineInstance++;
03525                   buttonCount++;
03526                   btnSet = 1;
03527                   break;
03528                }
03529             }
03530             break;
03531          case BT_SPEEDDIAL:
03532             req->data.buttontemplate.definition[i].buttonDefinition = BT_NONE;
03533             req->data.buttontemplate.definition[i].instanceNumber = 0;
03534 
03535             for (sd = d->speeddials; sd; sd = sd->next) {
03536                if (sd->instance == speeddialInstance) {
03537                   ast_verbose("Adding button: %d, %d\n", BT_SPEEDDIAL, speeddialInstance);
03538                   req->data.buttontemplate.definition[i].buttonDefinition = BT_SPEEDDIAL;
03539                   req->data.buttontemplate.definition[i].instanceNumber = htolel(speeddialInstance);
03540                   speeddialInstance++;
03541                   buttonCount++;
03542                   btnSet = 1;
03543                   break;
03544                }
03545             }
03546             break;
03547          case BT_CUST_HINT:
03548             break;
03549          case BT_NONE:
03550             break;
03551          default:
03552             ast_verbose("Adding button: %d, %d\n", btn[i].buttonDefinition, 0);
03553             req->data.buttontemplate.definition[i].buttonDefinition = htolel(btn[i].buttonDefinition);
03554             req->data.buttontemplate.definition[i].instanceNumber = htolel(0);
03555             buttonCount++;
03556             btnSet = 1;
03557             break;
03558       }
03559    }
03560 
03561    req->data.buttontemplate.buttonOffset = htolel(0);
03562    req->data.buttontemplate.buttonCount = htolel(buttonCount);
03563    req->data.buttontemplate.totalButtonCount = htolel(buttonCount);
03564 
03565    if (skinnydebug)
03566       ast_verbose("Sending %d template to %s\n",
03567                d->type,
03568                d->name);
03569    transmit_response(s, req);
03570    return 1;
03571 }

static int handle_capabilities_res_message ( struct skinny_req req,
struct skinnysession s 
) [static]

Definition at line 3355 of file chan_skinny.c.

References 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, letohl, skinny_device::lines, skinny_line::lock, skinny_line::next, s, and skinnydebug.

Referenced by handle_message().

03356 {
03357    struct skinny_device *d = s->device;
03358    struct skinny_line *l;
03359    int count = 0;
03360    int codecs = 0;
03361    int i;
03362 
03363    count = letohl(req->data.caps.count);
03364 
03365    for (i = 0; i < count; i++) {
03366       int acodec = 0;
03367       int scodec = 0;
03368       scodec = letohl(req->data.caps.caps[i].codec);
03369       acodec = codec_skinny2ast(scodec);
03370       if (skinnydebug)
03371          ast_verbose("Adding codec capability '%d (%d)'\n", acodec, scodec);
03372       codecs |= acodec;
03373    }
03374 
03375    d->capability &= codecs;
03376    ast_verbose("Device capability set to '%d'\n", d->capability);
03377    for (l = d->lines; l; l = l->next) {
03378       ast_mutex_lock(&l->lock);
03379       l->capability = d->capability;
03380       ast_mutex_unlock(&l->lock);
03381    }
03382 
03383    return 1;
03384 }

static int handle_headset_status_message ( struct skinny_req req,
struct skinnysession s 
) [static]

Definition at line 3989 of file chan_skinny.c.

Referenced by handle_message().

03990 {
03991    /* XXX umm...okay?  Why do I care? */
03992    return 1;
03993 }

static int handle_ip_port_message ( struct skinny_req req,
struct skinnysession s 
) [static]

Definition at line 2918 of file chan_skinny.c.

Referenced by handle_message().

02919 {
02920    /* no response necessary */
02921    return 1;
02922 }

static int handle_keep_alive_message ( struct skinny_req req,
struct skinnysession s 
) [static]

Definition at line 2866 of file chan_skinny.c.

References do_housekeeping(), KEEP_ALIVE_ACK_MESSAGE, req_alloc(), s, and transmit_response().

Referenced by handle_message().

02867 {
02868    if (!(req = req_alloc(0, KEEP_ALIVE_ACK_MESSAGE)))
02869       return -1;
02870 
02871    transmit_response(s, req);
02872    do_housekeeping(s);
02873    return 1;
02874 }

static int handle_keypad_button_message ( struct skinny_req req,
struct skinnysession s 
) [static]

Definition at line 2924 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, f, find_subchannel_by_instance_reference(), 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, s, and skinnydebug.

Referenced by handle_message().

02925 {
02926    struct skinny_subchannel *sub = NULL;
02927    struct skinny_line *l;
02928    struct skinny_device *d = s->device;
02929    struct ast_frame f = { 0, };
02930    char dgt;
02931    int digit;
02932    int lineInstance;
02933    int callReference;
02934 
02935    digit = letohl(req->data.keypad.button);
02936    lineInstance = letohl(req->data.keypad.lineInstance);
02937    callReference = letohl(req->data.keypad.callReference);
02938 
02939    if (digit == 14) {
02940       dgt = '*';
02941    } else if (digit == 15) {
02942       dgt = '#';
02943    } else if (digit >= 0 && digit <= 9) {
02944       dgt = '0' + digit;
02945    } else {
02946       /* digit=10-13 (A,B,C,D ?), or
02947        * digit is bad value
02948        *
02949        * probably should not end up here, but set
02950        * value for backward compatibility, and log
02951        * a warning.
02952        */
02953       dgt = '0' + digit;
02954       ast_log(LOG_WARNING, "Unsupported digit %d\n", digit);
02955    }
02956 
02957    f.subclass = dgt;
02958 
02959    f.src = "skinny";
02960 
02961    if (lineInstance && callReference)
02962       sub = find_subchannel_by_instance_reference(d, lineInstance, callReference);
02963    else
02964       sub = find_subchannel_by_instance_reference(d, d->lastlineinstance, d->lastcallreference);
02965 
02966    if (!sub)
02967       return 0;
02968 
02969    l = sub->parent;
02970    if (sub->owner) {
02971       if (sub->owner->_state == 0) {
02972          f.frametype = AST_FRAME_DTMF_BEGIN;
02973          ast_queue_frame(sub->owner, &f);
02974       }
02975       /* XXX MUST queue this frame to all lines in threeway call if threeway call is active */
02976       f.frametype = AST_FRAME_DTMF_END;
02977       ast_queue_frame(sub->owner, &f);
02978       /* XXX This seriously needs to be fixed */
02979       if (sub->next && sub->next->owner) {
02980          if (sub->owner->_state == 0) {
02981             f.frametype = AST_FRAME_DTMF_BEGIN;
02982             ast_queue_frame(sub->next->owner, &f);
02983          }
02984          f.frametype = AST_FRAME_DTMF_END;
02985          ast_queue_frame(sub->next->owner, &f);
02986       }
02987    } else {
02988       if (skinnydebug)
02989          ast_verbose("No owner: %s\n", l->name);
02990    }
02991    return 1;
02992 }

static int handle_line_state_req_message ( struct skinny_req req,
struct skinnysession s 
) [static]

Definition at line 3411 of file chan_skinny.c.

References ast_mutex_lock(), ast_mutex_unlock(), skinny_req::data, 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(), s, and transmit_response().

Referenced by handle_message().

03412 {
03413    struct skinny_device *d = s->device;
03414    struct skinny_line *l;
03415    int instance;
03416 
03417    instance = letohl(req->data.line.lineNumber);
03418 
03419    ast_mutex_lock(&devicelock);
03420 
03421    l = find_line_by_instance(d, instance);
03422 
03423    if (!l) {
03424       return 0;
03425    }
03426 
03427    ast_mutex_unlock(&devicelock);
03428 
03429    if (!(req = req_alloc(sizeof(struct line_stat_res_message), LINE_STAT_RES_MESSAGE)))
03430       return -1;
03431 
03432    req->data.linestat.lineNumber = letohl(instance);
03433    memcpy(req->data.linestat.lineDirNumber, l->name,
03434          sizeof(req->data.linestat.lineDirNumber));
03435    memcpy(req->data.linestat.lineDisplayName, l->label,
03436          sizeof(req->data.linestat.lineDisplayName));
03437    transmit_response(s,req);
03438    return 1;
03439 }

static int handle_message ( struct skinny_req req,
struct skinnysession s 
) [static]

Definition at line 4001 of file chan_skinny.c.

References ALARM_MESSAGE, ast_log(), ast_verbose(), keypad_button_message::button, BUTTON_TEMPLATE_REQ_MESSAGE, CAPABILITIES_RES_MESSAGE, skinny_req::data, skinny_req::e, free, handle_alarm_message(), handle_button_template_req_message(), handle_capabilities_res_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, letohl, LINE_STATE_REQ_MESSAGE, LOG_WARNING, register_message::name, OFFHOOK_MESSAGE, ONHOOK_MESSAGE, OPEN_RECEIVE_CHANNEL_ACK_MESSAGE, skinny_data::reg, REGISTER_AVAILABLE_LINES_MESSAGE, REGISTER_MESSAGE, s, SERVER_REQUEST_MESSAGE, skinnydebug, 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().

04002 {
04003    int res = 0;
04004 
04005    if ((!s->device) && (letohl(req->e) != REGISTER_MESSAGE && letohl(req->e) != ALARM_MESSAGE)) {
04006       ast_log(LOG_WARNING, "Client sent message #%d without first registering.\n", req->e);
04007       free(req);
04008       return 0;
04009    }
04010 
04011    switch(letohl(req->e))  {
04012    case KEEP_ALIVE_MESSAGE:
04013       res = handle_keep_alive_message(req, s);
04014       break;
04015    case REGISTER_MESSAGE:
04016       if (skinnydebug)
04017          ast_verbose("Device %s is attempting to register\n", req->data.reg.name);
04018 
04019       res = handle_register_message(req, s);
04020       break;
04021    case IP_PORT_MESSAGE:
04022       res = handle_ip_port_message(req, s);
04023       break;
04024    case KEYPAD_BUTTON_MESSAGE:
04025       if (skinnydebug)
04026          ast_verbose("Collected digit: [%d]\n", letohl(req->data.keypad.button));
04027 
04028       res = handle_keypad_button_message(req, s);
04029       break;
04030    case STIMULUS_MESSAGE:
04031       res = handle_stimulus_message(req, s);
04032       break;
04033    case OFFHOOK_MESSAGE:
04034       res = handle_offhook_message(req, s);
04035       break;
04036    case ONHOOK_MESSAGE:
04037       res = handle_onhook_message(req, s);
04038       break;
04039    case CAPABILITIES_RES_MESSAGE:
04040       if (skinnydebug)
04041          ast_verbose("Received CapabilitiesRes\n");
04042 
04043       res = handle_capabilities_res_message(req, s);
04044       break;
04045    case SPEED_DIAL_STAT_REQ_MESSAGE:
04046       if (skinnydebug)
04047          ast_verbose("Received SpeedDialStatRequest\n");
04048 
04049       res = handle_speed_dial_stat_req_message(req, s);
04050       break;
04051    case LINE_STATE_REQ_MESSAGE:
04052       res = handle_line_state_req_message(req, s);
04053       break;
04054    case TIME_DATE_REQ_MESSAGE:
04055       if (skinnydebug)
04056          ast_verbose("Received Time/Date Request\n");
04057 
04058       res = handle_time_date_req_message(req, s);
04059       break;
04060    case BUTTON_TEMPLATE_REQ_MESSAGE:
04061       if (skinnydebug)
04062          ast_verbose("Buttontemplate requested\n");
04063 
04064       res = handle_button_template_req_message(req, s);
04065       break;
04066    case VERSION_REQ_MESSAGE:
04067       if (skinnydebug)
04068          ast_verbose("Version Request\n");
04069 
04070       res = handle_version_req_message(req, s);
04071       break;
04072    case SERVER_REQUEST_MESSAGE:
04073       if (skinnydebug)
04074          ast_verbose("Received Server Request\n");
04075 
04076       res = handle_server_request_message(req, s);
04077       break;
04078    case ALARM_MESSAGE:
04079       res = handle_alarm_message(req, s);
04080       break;
04081    case OPEN_RECEIVE_CHANNEL_ACK_MESSAGE:
04082       if (skinnydebug)
04083          ast_verbose("Received Open Receive Channel Ack\n");
04084 
04085       res = handle_open_receive_channel_ack_message(req, s);
04086       break;
04087    case SOFT_KEY_SET_REQ_MESSAGE:
04088       if (skinnydebug)
04089          ast_verbose("Received SoftKeySetReq\n");
04090 
04091       res = handle_soft_key_set_req_message(req, s);
04092       break;
04093    case SOFT_KEY_EVENT_MESSAGE:
04094       res = handle_soft_key_event_message(req, s);
04095       break;
04096    case UNREGISTER_MESSAGE:
04097       if (skinnydebug)
04098          ast_verbose("Received Unregister Request\n");
04099 
04100       res = handle_unregister_message(req, s);
04101       break;
04102    case SOFT_KEY_TEMPLATE_REQ_MESSAGE:
04103       if (skinnydebug)
04104          ast_verbose("Received SoftKey Template Request\n");
04105 
04106       res = handle_soft_key_template_req_message(req, s);
04107       break;
04108    case HEADSET_STATUS_MESSAGE:
04109       res = handle_headset_status_message(req, s);
04110       break;
04111    case REGISTER_AVAILABLE_LINES_MESSAGE:
04112       res = handle_register_available_lines_message(req, s);
04113       break;
04114    default:
04115       if (skinnydebug)
04116          ast_verbose("RECEIVED UNKNOWN MESSAGE TYPE:  %x\n", letohl(req->e));
04117       break;
04118    }
04119    if (res >= 0 && req)
04120       free(req);
04121    return res;
04122 }

static int handle_offhook_message ( struct skinny_req req,
struct skinnysession s 
) [static]

Definition at line 3221 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, 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, s, SKINNY_CONNECTED, SKINNY_DIALTONE, SKINNY_LAMP_ON, skinny_new(), SKINNY_OFFHOOK, SKINNY_RING_OFF, SKINNY_SILENCE, skinny_ss(), skinnydebug, 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().

03222 {
03223    struct skinny_device *d = s->device;
03224    struct skinny_line *l;
03225    struct skinny_subchannel *sub;
03226    struct ast_channel *c;
03227    pthread_t t;
03228    int unknown1;
03229    int unknown2;
03230 
03231    unknown1 = letohl(req->data.offhook.unknown1);
03232    unknown2 = letohl(req->data.offhook.unknown2);
03233 
03234    sub = find_subchannel_by_instance_reference(d, d->lastlineinstance, d->lastcallreference);
03235 
03236    if (!sub) {
03237       l = find_line_by_instance(d, d->lastlineinstance);
03238       if (!l) {
03239          return 0;
03240       }
03241    } else {
03242       l = sub->parent;
03243    }
03244 
03245    if (sub && sub->onhold) {
03246       transmit_ringer_mode(s, SKINNY_RING_OFF);
03247       l->hookstate = SKINNY_OFFHOOK;
03248       return 1;
03249    }
03250 
03251    transmit_ringer_mode(s, SKINNY_RING_OFF);
03252    transmit_lamp_indication(s, STIMULUS_LINE, l->instance, SKINNY_LAMP_ON);
03253    l->hookstate = SKINNY_OFFHOOK;
03254 
03255    if (sub && sub->outgoing) {
03256       /* We're answering a ringing call */
03257       ast_queue_control(sub->owner, AST_CONTROL_ANSWER);
03258       transmit_callstate(s, l->instance, SKINNY_OFFHOOK, sub->callid);
03259       transmit_tone(s, SKINNY_SILENCE);
03260       transmit_callstate(s, l->instance, SKINNY_CONNECTED, sub->callid);
03261       transmit_selectsoftkeys(s, l->instance, sub->callid, KEYDEF_CONNECTED);
03262       start_rtp(sub);
03263       ast_setstate(sub->owner, AST_STATE_UP);
03264    } else {
03265       if (sub && sub->owner) {
03266          ast_log(LOG_DEBUG, "Current sub [%s] already has owner\n", sub->owner->name);
03267       } else {
03268          c = skinny_new(l, AST_STATE_DOWN);
03269          if(c) {
03270             sub = c->tech_pvt;
03271             transmit_callstate(s, l->instance, SKINNY_OFFHOOK, sub->callid);
03272             if (skinnydebug)
03273                ast_verbose("Attempting to Clear display on Skinny %s@%s\n", l->name, d->name);
03274             transmit_displaymessage(s, NULL); /* clear display */
03275             transmit_tone(s, SKINNY_DIALTONE);
03276             transmit_selectsoftkeys(s, l->instance, sub->callid, KEYDEF_OFFHOOK);
03277 
03278             /* start the switch thread */
03279             if (ast_pthread_create(&t, NULL, skinny_ss, c)) {
03280                ast_log(LOG_WARNING, "Unable to create switch thread: %s\n", strerror(errno));
03281                ast_hangup(c);
03282             }
03283          } else {
03284             ast_log(LOG_WARNING, "Unable to create channel for %s@%s\n", l->name, d->name);
03285          }
03286       }
03287    }
03288    return 1;
03289 }

static int handle_onhook_message ( struct skinny_req req,
struct skinnysession s 
) [static]

Definition at line 3291 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, 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, s, SKINNY_CX_RECVONLY, SKINNY_ONHOOK, skinnydebug, skinny_line::transfer, transmit_callstate(), onhook_message::unknown1, and onhook_message::unknown2.

Referenced by handle_message().

03292 {
03293    struct skinny_device *d = s->device;
03294    struct skinny_line *l;
03295    struct skinny_subchannel *sub;
03296    int unknown1;
03297    int unknown2;
03298 
03299    unknown1 = letohl(req->data.onhook.unknown1);
03300    unknown2 = letohl(req->data.onhook.unknown2);
03301 
03302    sub = find_subchannel_by_instance_reference(d, d->lastlineinstance, d->lastcallreference);
03303 
03304    if (!sub) {
03305       return 0;
03306    }
03307    l = sub->parent;
03308 
03309    if (sub->onhold) {
03310       l->hookstate = SKINNY_ONHOOK;
03311       return 0;
03312    }
03313 
03314    if (l->hookstate == SKINNY_ONHOOK) {
03315       /* Something else already put us back on hook */
03316       return 0;
03317    }
03318    sub->cxmode = SKINNY_CX_RECVONLY;
03319    l->hookstate = SKINNY_ONHOOK;
03320    transmit_callstate(s, l->instance, l->hookstate, sub->callid);
03321    if (skinnydebug)
03322       ast_verbose("Skinny %s@%s went on hook\n", l->name, d->name);
03323    if (l->transfer && (sub->owner && sub->next && sub->next->owner) && ((!sub->outgoing) || (sub->next && !sub->next->outgoing))) {
03324       /* We're allowed to transfer, we have two active calls and
03325          we made at least one of the calls.  Let's try and transfer */
03326 
03327 #if 0
03328       if ((res = attempt_transfer(p)) < 0) {
03329          if (sub->next && sub->next->owner) {
03330             sub->next->alreadygone = 1;
03331             ast_queue_hangup(sub->next->owner,1);
03332          }
03333       } else if (res) {
03334          ast_log(LOG_WARNING, "Transfer attempt failed\n");
03335          return 0;
03336       }
03337 #endif
03338    } else {
03339       /* Hangup the current call */
03340       /* If there is another active call, skinny_hangup will ring the phone with the other call */
03341       if (sub->owner) {
03342          sub->alreadygone = 1;
03343          ast_queue_hangup(sub->owner);
03344       } else {
03345          ast_log(LOG_WARNING, "Skinny(%s@%s-%d) channel already destroyed\n",
03346             l->name, d->name, sub->callid);
03347       }
03348    }
03349    if ((l->hookstate == SKINNY_ONHOOK) && (sub->next && !sub->next->rtp)) {
03350       do_housekeeping(s);
03351    }
03352    return 1;
03353 }

static int handle_open_receive_channel_ack_message ( struct skinny_req req,
struct skinnysession s 
) [static]

Definition at line 3607 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, skinny_subchannel::callid, skinny_line::capability, codec_ast2skinny(), start_media_transmission_message::conferenceId, skinny_req::data, find_subchannel_by_reference(), fmt, 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, s, skinnydebug, START_MEDIA_TRANSMISSION_MESSAGE, skinny_data::startmedia, open_receive_channel_ack_message::status, transmit_response(), and media_qualifier::vad.

Referenced by handle_message().

03608 {
03609    struct skinny_device *d = s->device;
03610    struct skinny_line *l;
03611    struct skinny_subchannel *sub;
03612    struct ast_format_list fmt;
03613    struct sockaddr_in sin;
03614    struct sockaddr_in us;
03615    uint32_t addr;
03616    int port;
03617    int status;
03618    int passthruid;
03619 
03620    status = letohl(req->data.openreceivechannelack.status);
03621    if (status) {
03622       ast_log(LOG_ERROR, "Open Receive Channel Failure\n");
03623       return 0;
03624    }
03625    addr = letohl(req->data.openreceivechannelack.ipAddr);
03626    port = letohl(req->data.openreceivechannelack.port);
03627    passthruid = letohl(req->data.openreceivechannelack.passThruId);
03628 
03629    sin.sin_family = AF_INET;
03630    sin.sin_addr.s_addr = addr;
03631    sin.sin_port = htons(port);
03632 
03633    sub = find_subchannel_by_reference(d, passthruid);
03634 
03635    if (!sub)
03636       return 0;
03637 
03638    l = sub->parent;
03639 
03640    if (sub->rtp) {
03641       ast_rtp_set_peer(sub->rtp, &sin);
03642       ast_rtp_get_us(sub->rtp, &us);
03643    } else {
03644       ast_log(LOG_ERROR, "No RTP structure, this is very bad\n");
03645       return 0;
03646    }
03647 
03648    if (skinnydebug) {
03649       ast_verbose("ipaddr = %s:%d\n", ast_inet_ntoa(sin.sin_addr), ntohs(sin.sin_port));
03650       ast_verbose("ourip = %s:%d\n", ast_inet_ntoa(d->ourip), ntohs(us.sin_port));
03651    }
03652 
03653    if (!(req = req_alloc(sizeof(struct start_media_transmission_message), START_MEDIA_TRANSMISSION_MESSAGE)))
03654       return -1;
03655 
03656    fmt = ast_codec_pref_getsize(&l->prefs, ast_best_codec(l->capability));
03657 
03658    if (skinnydebug)
03659       ast_verbose("Setting payloadType to '%d' (%d ms)\n", fmt.bits, fmt.cur_ms);
03660 
03661    req->data.startmedia.conferenceId = htolel(0);
03662    req->data.startmedia.passThruPartyId = htolel(sub->callid);
03663    req->data.startmedia.remoteIp = htolel(d->ourip.s_addr);
03664    req->data.startmedia.remotePort = htolel(ntohs(us.sin_port));
03665    req->data.startmedia.packetSize = htolel(fmt.cur_ms);
03666    req->data.startmedia.payloadType = htolel(codec_ast2skinny(fmt.bits));
03667    req->data.startmedia.qualifier.precedence = htolel(127);
03668    req->data.startmedia.qualifier.vad = htolel(0);
03669    req->data.startmedia.qualifier.packets = htolel(0);
03670    req->data.startmedia.qualifier.bitRate = htolel(0);
03671    transmit_response(s, req);
03672 
03673    return 1;
03674 }

static int handle_register_available_lines_message ( struct skinny_req req,
struct skinnysession s 
) [static]

Definition at line 3995 of file chan_skinny.c.

Referenced by handle_message().

03996 {
03997    /* XXX I have no clue what this is for, but my phone was sending it, so... */
03998    return 1;
03999 }

static int handle_register_message ( struct skinny_req req,
struct skinnysession s 
) [static]

Definition at line 2876 of file chan_skinny.c.

References ast_log(), ast_verbose(), CAPABILITIES_REQ_MESSAGE, skinny_req::data, date_format, register_ack_message::dateTemplate, register_rej_message::errMsg, htolel, keep_alive, 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, s, register_ack_message::secondaryKeepAlive, skinny_register(), skinnydebug, transmit_response(), and VERBOSE_PREFIX_3.

Referenced by handle_message().

02877 {
02878    char name[16];
02879    int res;
02880 
02881    memcpy(&name, req->data.reg.name, sizeof(name));
02882 
02883    res = skinny_register(req, s);
02884    if (!res) {
02885       ast_log(LOG_ERROR, "Rejecting Device %s: Device not found\n", name);
02886       if (!(req = req_alloc(sizeof(struct register_rej_message), REGISTER_REJ_MESSAGE)))
02887          return -1;
02888 
02889       snprintf(req->data.regrej.errMsg, sizeof(req->data.regrej.errMsg), "No Authority: %s", name);
02890       transmit_response(s, req);
02891       return 0;
02892    }
02893    if (option_verbose > 2)
02894       ast_verbose(VERBOSE_PREFIX_3 "Device '%s' successfully registered\n", name);
02895 
02896    if (!(req = req_alloc(sizeof(struct register_ack_message), REGISTER_ACK_MESSAGE)))
02897       return -1;
02898 
02899    req->data.regack.res[0] = '0';
02900    req->data.regack.res[1] = '\0';
02901    req->data.regack.keepAlive = htolel(keep_alive);
02902    ast_copy_string(req->data.regack.dateTemplate, date_format, sizeof(req->data.regack.dateTemplate));
02903    req->data.regack.res2[0] = '0';
02904    req->data.regack.res2[1] = '\0';
02905    req->data.regack.secondaryKeepAlive = htolel(keep_alive);
02906    transmit_response(s, req);
02907    if (skinnydebug)
02908       ast_verbose("Requesting capabilities\n");
02909 
02910    if (!(req = req_alloc(0, CAPABILITIES_REQ_MESSAGE)))
02911       return -1;
02912 
02913    transmit_response(s, req);
02914 
02915    return res;
02916 }

static int handle_server_request_message ( struct skinny_req req,
struct skinnysession s 
) [static]

Definition at line 3584 of file chan_skinny.c.

References skinny_req::data, htolel, ourhost, skinny_device::ourip, ourport, req_alloc(), s, 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().

03585 {
03586    struct skinny_device *d = s->device;
03587    if (!(req = req_alloc(sizeof(struct server_res_message), SERVER_RES_MESSAGE)))
03588       return -1;
03589 
03590    memcpy(req->data.serverres.server[0].serverName, ourhost,
03591          sizeof(req->data.serverres.server[0].serverName));
03592    req->data.serverres.serverListenPort[0] = htolel(ourport);
03593    req->data.serverres.serverIpAddr[0] = htolel(d->ourip.s_addr);
03594    transmit_response(s, req);
03595    return 1;
03596 }

static int handle_soft_key_event_message ( struct skinny_req req,
struct skinnysession s 
) [static]

Definition at line 3707 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_strlen_zero(), ast_verbose(), attempt_transfer(), skinny_subchannel::callid, ast_channel::context, skinny_subchannel::cxmode, skinny_req::data, skinny_line::dnd, do_housekeeping(), 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, 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, soft_key_event_message::reference, reference(), skinny_subchannel::rtp, s, 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_ss(), skinny_unhold(), skinnydebug, 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_tone(), and VERBOSE_PREFIX_3.

Referenced by handle_message().

03708 {
03709    struct skinny_device *d = s->device;
03710    struct skinny_line *l;
03711    struct skinny_subchannel *sub = NULL;
03712    struct ast_channel *c;
03713    pthread_t t;
03714    int event;
03715    int instance;
03716    int reference;
03717 
03718    event = letohl(req->data.softkeyeventmessage.softKeyEvent);
03719    instance = letohl(req->data.softkeyeventmessage.instance);
03720    reference = letohl(req->data.softkeyeventmessage.reference);
03721 
03722    if (instance) {
03723       l = find_line_by_instance(d, instance);
03724       if (reference) {
03725          sub = find_subchannel_by_instance_reference(d, instance, reference);
03726       } else {
03727          sub = find_subchannel_by_instance_reference(d, instance, d->lastcallreference);
03728       }
03729    } else {
03730       l = find_line_by_instance(d, d->lastlineinstance);
03731    }
03732 
03733    if (!l) {
03734       if (skinnydebug)
03735          ast_verbose("Received Softkey Event: %d(%d)\n", event, instance);
03736       return 0;
03737    }
03738 
03739    switch(event) {
03740    case SOFTKEY_NONE:
03741       if (skinnydebug)
03742          ast_verbose("Received Softkey Event: None(%d)\n", instance);
03743       break;
03744    case SOFTKEY_REDIAL:
03745       if (skinnydebug)
03746          ast_verbose("Received Softkey Event: Redial(%d)\n", instance);
03747 
03748 #if 0
03749       if (!sub || !sub->owner) {
03750          c = skinny_new(l, AST_STATE_DOWN);
03751       } else {
03752          c = sub->owner;
03753       }
03754 
03755       if(!c) {
03756          ast_log(LOG_WARNING, "Unable to create channel for %s@%s\n", l->name, d->name);
03757       } else {
03758          sub = c->tech_pvt;
03759          transmit_callstate(s, l->instance, SKINNY_OFFHOOK, sub->callid);
03760          if (skinnydebug)
03761             ast_verbose("Attempting to Clear display on Skinny %s@%s\n", l->name, d->name);
03762          transmit_displaymessage(s, NULL); /* clear display */
03763          transmit_tone(s, SKINNY_DIALTONE);
03764 
03765          if (ast_strlen_zero(l->lastnumberdialed)) {
03766             ast_log(LOG_WARNING, "Attempted redial, but no previously dialed number found.\n");
03767             break;
03768          }
03769          if (!ast_ignore_pattern(c->context, l->lastnumberdialed)) {
03770             transmit_tone(s, SKINNY_SILENCE);
03771          }
03772          ast_copy_string(c->exten, l->lastnumberdialed, sizeof(c->exten));
03773          if (ast_pthread_create(&t, NULL, skinny_newcall, c)) {
03774             ast_log(LOG_WARNING, "Unable to create new call thread: %s\n", strerror(errno));
03775             ast_hangup(c);
03776          }
03777       }
03778 #endif
03779       break;
03780    case SOFTKEY_NEWCALL:
03781       /* XXX Untested */
03782       if (skinnydebug)
03783          ast_verbose("Received Softkey Event: New Call(%d)\n", instance);
03784 
03785       transmit_ringer_mode(s,SKINNY_RING_OFF);
03786       transmit_lamp_indication(s, STIMULUS_LINE, l->instance, SKINNY_LAMP_ON);
03787 
03788       l->hookstate = SKINNY_OFFHOOK;
03789 
03790       if (sub) {
03791          transmit_callstate(s, l->instance, SKINNY_OFFHOOK, sub->callid);
03792          if (skinnydebug)
03793             ast_verbose("Attempting to Clear display on Skinny %s@%s\n", l->name, d->name);
03794          transmit_displaymessage(s, NULL); /* clear display */
03795          transmit_tone(s, SKINNY_DIALTONE);
03796          transmit_selectsoftkeys(s, l->instance, sub->callid, KEYDEF_OFFHOOK);
03797          c = skinny_new(l, AST_STATE_DOWN);
03798          if(c) {
03799             /* start the switch thread */
03800             if (ast_pthread_create(&t, NULL, skinny_ss, c)) {
03801                ast_log(LOG_WARNING, "Unable to create switch thread: %s\n", strerror(errno));
03802                ast_hangup(c);
03803             }
03804          } else {
03805             ast_log(LOG_WARNING, "Unable to create channel for %s@%s\n", l->name, d->name);
03806          }
03807       }
03808       break;
03809    case SOFTKEY_HOLD:
03810       if (skinnydebug)
03811          ast_verbose("Received Softkey Event: Hold(%d)\n", instance);
03812 
03813       if (sub) {
03814          if (sub->onhold) {
03815             skinny_unhold(sub);
03816          } else {
03817             skinny_hold(sub);
03818          }
03819       }
03820             
03821       break;
03822    case SOFTKEY_TRNSFER:
03823       if (skinnydebug)
03824          ast_verbose("Received Softkey Event: Transfer(%d)\n", instance);
03825       transmit_tone(s, SKINNY_DIALTONE);
03826       /* XXX figure out how to transfer */
03827       break;
03828    case SOFTKEY_CFWDALL:
03829       if (skinnydebug)
03830          ast_verbose("Received Softkey Event: Forward All(%d)\n", instance);
03831 
03832       /* Do not disturb */
03833       transmit_tone(s, SKINNY_DIALTONE);
03834       if (l->dnd != 0){
03835          if (option_verbose > 2)
03836             ast_verbose(VERBOSE_PREFIX_3 "Disabling DND on %s@%s\n", l->name, d->name);
03837          l->dnd = 0;
03838          transmit_lamp_indication(s, STIMULUS_FORWARDALL, 1, SKINNY_LAMP_ON);
03839          transmit_displaynotify(s, "DnD disabled", 10);
03840       } else {
03841          if (option_verbose > 2)
03842             ast_verbose(VERBOSE_PREFIX_3 "Enabling DND on %s@%s\n", l->name, d->name);
03843          l->dnd = 1;
03844          transmit_lamp_indication(s, STIMULUS_FORWARDALL, 1, SKINNY_LAMP_OFF);
03845          transmit_displaynotify(s, "DnD enabled", 10);
03846       }
03847       break;
03848    case SOFTKEY_CFWDBUSY:
03849       if (skinnydebug)
03850          ast_verbose("Received Softkey Event: Forward Busy (%d)\n", instance);
03851       break;
03852    case SOFTKEY_CFWDNOANSWER:
03853       if (skinnydebug)
03854          ast_verbose("Received Softkey Event: Forward No Answer (%d)\n", instance);
03855       break;
03856    case SOFTKEY_BKSPC:
03857       if (skinnydebug)
03858          ast_verbose("Received Softkey Event: Backspace(%d)\n", instance);
03859       break;
03860    case SOFTKEY_ENDCALL:
03861       if (skinnydebug)
03862          ast_verbose("Received Softkey Event: End Call(%d)\n", instance);
03863 
03864       if (l->hookstate == SKINNY_ONHOOK) {
03865          /* Something else already put us back on hook */
03866          break;
03867       }
03868       if (sub) {
03869          sub->cxmode = SKINNY_CX_RECVONLY;
03870          l->hookstate = SKINNY_ONHOOK;
03871          transmit_callstate(s, l->instance, l->hookstate, sub->callid);
03872          if (skinnydebug)
03873             ast_verbose("Skinny %s@%s went on hook\n", l->name, d->name);
03874          if (l->transfer && (sub->owner && sub->next && sub->next->owner) && ((!sub->outgoing) || (sub->next && !sub->next->outgoing))) {
03875             /* We're allowed to transfer, we have two active calls and
03876                we made at least one of the calls.  Let's try and transfer */
03877 
03878 #if 0
03879             if ((res = attempt_transfer(p)) < 0) {
03880                if (sub->next && sub->next->owner) {
03881                   sub->next->alreadygone = 1;
03882                   ast_queue_hangup(sub->next->owner, 1);
03883                }
03884             } else if (res) {
03885                ast_log(LOG_WARNING, "Transfer attempt failed\n");
03886                break;
03887             }
03888 #endif
03889          } else {
03890             /* Hangup the current call */
03891             /* If there is another active call, skinny_hangup will ring the phone with the other call */
03892             if (sub->owner) {
03893                sub->alreadygone = 1;
03894                ast_queue_hangup(sub->owner);
03895             } else {
03896                ast_log(LOG_WARNING, "Skinny(%s@%s-%d) channel already destroyed\n",
03897                   l->name, d->name, sub->callid);
03898             }
03899          }
03900          if ((l->hookstate == SKINNY_ONHOOK) && (sub->next && !sub->next->rtp)) {
03901             do_housekeeping(s);
03902          }
03903       }
03904       break;
03905    case SOFTKEY_RESUME:
03906       if (skinnydebug)
03907          ast_verbose("Received Softkey Event: Resume(%d)\n", instance);
03908       break;
03909    case SOFTKEY_ANSWER:
03910       if (skinnydebug)
03911          ast_verbose("Received Softkey Event: Answer(%d)\n", instance);
03912 
03913       transmit_ringer_mode(s,SKINNY_RING_OFF);
03914       transmit_lamp_indication(s, STIMULUS_LINE, l->instance, SKINNY_LAMP_ON);
03915 
03916       l->hookstate = SKINNY_OFFHOOK;
03917 
03918       if (sub && sub->outgoing) {
03919          /* We're answering a ringing call */
03920          ast_queue_control(sub->owner, AST_CONTROL_ANSWER);
03921          transmit_callstate(s, l->instance, SKINNY_OFFHOOK, sub->callid);
03922          transmit_tone(s, SKINNY_SILENCE);
03923          transmit_callstate(s, l->instance, SKINNY_CONNECTED, sub->callid);
03924          transmit_selectsoftkeys(s, l->instance, sub->callid, KEYDEF_CONNECTED);
03925          start_rtp(sub);
03926          ast_setstate(sub->owner, AST_STATE_UP);
03927       }
03928       break;
03929    case SOFTKEY_INFO:
03930       if (skinnydebug)
03931          ast_verbose("Received Softkey Event: Info(%d)\n", instance);
03932       break;
03933    case SOFTKEY_CONFRN:
03934       if (skinnydebug)
03935          ast_verbose("Received Softkey Event: Transfer(%d)\n", instance);
03936       transmit_tone(s, SKINNY_DIALTONE);
03937       /* XXX determine the best way to pull off a conference.  Meetme? */
03938       break;
03939    case SOFTKEY_PARK:
03940       if (skinnydebug)
03941          ast_verbose("Received Softkey Event: Park Call(%d)\n", instance);
03942       /* XXX Park the call */
03943       break;
03944    case SOFTKEY_JOIN:
03945       if (skinnydebug)
03946          ast_verbose("Received Softkey Event: Join(%d)\n", instance);
03947       break;
03948    case SOFTKEY_MEETME:
03949       /* XXX How is this different from CONFRN? */
03950       if (skinnydebug)
03951          ast_verbose("Received Softkey Event: Meetme(%d)\n", instance);
03952       break;
03953    case SOFTKEY_PICKUP:
03954       if (skinnydebug)
03955          ast_verbose("Received Softkey Event: None(%d)\n", instance);
03956       break;
03957    case SOFTKEY_GPICKUP:
03958       if (skinnydebug)
03959          ast_verbose("Received Softkey Event: Group Pickup (%d)\n", instance);
03960       break;
03961    default:
03962       if (skinnydebug)
03963          ast_verbose("Received unknown Softkey Event: %d(%d)\n", event, instance);
03964       break;
03965    }
03966    return 1;
03967 }

static int handle_soft_key_set_req_message ( struct skinny_req req,
struct skinnysession s 
) [static]

Definition at line 3676 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(), s, soft_key_default_definitions, SOFT_KEY_SET_RES_MESSAGE, soft_key_template_default, 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().

03677 {
03678    int i;
03679    int x;
03680    int y;
03681    const struct soft_key_definitions *softkeymode = soft_key_default_definitions;
03682 
03683    if (!(req = req_alloc(sizeof(struct soft_key_set_res_message), SOFT_KEY_SET_RES_MESSAGE)))
03684       return -1;
03685 
03686    req->data.softkeysets.softKeySetOffset = htolel(0);
03687    req->data.softkeysets.softKeySetCount = htolel(11);
03688    req->data.softkeysets.totalSoftKeySetCount = htolel(11);
03689    for (x = 0; x < sizeof(soft_key_default_definitions) / sizeof(struct soft_key_definitions); x++) {
03690       const uint8_t *defaults = softkeymode->defaults;
03691       /* XXX I wanted to get the size of the array dynamically, but that wasn't wanting to work.
03692          This will have to do for now. */
03693       for (y = 0; y < softkeymode->count; y++) {
03694          for (i = 0; i < (sizeof(soft_key_template_default) / sizeof(struct soft_key_template_definition)); i++) {
03695             if (defaults[y] == i+1) {
03696                req->data.softkeysets.softKeySetDefinition[softkeymode->mode].softKeyTemplateIndex[y] = htolel(i+1);
03697             }
03698          }
03699       }
03700       softkeymode++;
03701    }
03702    transmit_response(s,req);
03703    transmit_selectsoftkeys(s, 0, 0, KEYDEF_ONHOOK);
03704    return 1;
03705 }

static int handle_soft_key_template_req_message ( struct skinny_req req,
struct skinnysession s 
) [static]

Definition at line 3974 of file chan_skinny.c.

References skinny_req::data, htolel, req_alloc(), s, soft_key_template_default, 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().

03975 {
03976    if (!(req = req_alloc(sizeof(struct soft_key_template_res_message), SOFT_KEY_TEMPLATE_RES_MESSAGE)))
03977       return -1;
03978 
03979    req->data.softkeytemplate.softKeyOffset = htolel(0);
03980    req->data.softkeytemplate.softKeyCount = htolel(sizeof(soft_key_template_default) / sizeof(struct soft_key_template_definition));
03981    req->data.softkeytemplate.totalSoftKeyCount = htolel(sizeof(soft_key_template_default) / sizeof(struct soft_key_template_definition));
03982    memcpy(req->data.softkeytemplate.softKeyTemplateDefinition,
03983       soft_key_template_default,
03984       sizeof(soft_key_template_default));
03985    transmit_response(s,req);
03986    return 1;
03987 }

static int handle_speed_dial_stat_req_message ( struct skinny_req req,
struct skinnysession s 
) [static]

Definition at line 3386 of file chan_skinny.c.

References skinny_req::data, skinny_speeddial::exten, find_speeddial_by_instance(), htolel, skinny_speeddial::instance, skinny_speeddial::label, letohl, req_alloc(), s, 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().

03387 {
03388    struct skinny_device *d = s->device;
03389    struct skinny_speeddial *sd;
03390    int instance;
03391 
03392    instance = letohl(req->data.speeddialreq.speedDialNumber);
03393 
03394    sd = find_speeddial_by_instance(d, instance);
03395 
03396    if (!sd) {
03397       return 0;
03398    }
03399 
03400    if (!(req = req_alloc(sizeof(struct speed_dial_stat_res_message), SPEED_DIAL_STAT_RES_MESSAGE)))
03401       return -1;
03402 
03403    req->data.speeddialreq.speedDialNumber = htolel(instance);
03404    snprintf(req->data.speeddial.speedDialDirNumber, sizeof(req->data.speeddial.speedDialDirNumber), sd->exten);
03405    snprintf(req->data.speeddial.speedDialDisplayName, sizeof(req->data.speeddial.speedDialDisplayName), sd->label);
03406 
03407    transmit_response(s, req);
03408    return 1;
03409 }

static int handle_stimulus_message ( struct skinny_req req,
struct skinnysession s 
) [static]

Definition at line 2994 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, skinny_line::cid_num, ast_channel::context, skinny_req::data, skinny_line::dnd, 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, 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, s, SKINNY_CONNECTED, SKINNY_DIALTONE, skinny_hold(), SKINNY_LAMP_OFF, SKINNY_LAMP_ON, skinny_new(), skinny_newcall(), SKINNY_OFFHOOK, SKINNY_RING_OFF, SKINNY_SILENCE, SKINNY_SPEAKERON, skinny_ss(), skinny_unhold(), skinnydebug, 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(), stimulus_message::unknown1, and VERBOSE_PREFIX_3.

Referenced by handle_message().

02995 {
02996    struct skinny_device *d = s->device;
02997    struct skinny_line *l;
02998    struct skinny_subchannel *sub;
02999    /*struct skinny_speeddial *sd;*/
03000    struct ast_channel *c;
03001    pthread_t t;
03002    int event;
03003    int instance;
03004    int unknown1;
03005    /*int res = 0;*/
03006 
03007    event = letohl(req->data.stimulus.stimulus);
03008    instance = letohl(req->data.stimulus.stimulusInstance);
03009    unknown1 = letohl(req->data.stimulus.unknown1); /* No clue.. */
03010    if (skinnydebug)
03011       ast_verbose("unknown1 in handle_stimulus_message is '%d'\n", unknown1);
03012 
03013    sub = find_subchannel_by_instance_reference(d, d->lastlineinstance, d->lastcallreference);
03014 
03015    if (!sub) {
03016       l = find_line_by_instance(d, d->lastlineinstance);
03017       if (!l) {
03018          return 0;
03019       }
03020    } else {
03021       l = sub->parent;
03022    }
03023 
03024    switch(event) {
03025    case STIMULUS_REDIAL:
03026       if (skinnydebug)
03027          ast_verbose("Received Stimulus: Redial(%d)\n", instance);
03028 
03029 #if 0
03030       c = skinny_new(l, AST_STATE_DOWN);
03031       if(!c) {
03032          ast_log(LOG_WARNING, "Unable to create channel for %s@%s\n", l->name, d->name);
03033       } else {
03034          sub = c->tech_pvt;
03035          transmit_callstate(s, l->instance, SKINNY_OFFHOOK, sub->callid);
03036          if (skinnydebug)
03037             ast_verbose("Attempting to Clear display on Skinny %s@%s\n", l->name, d->name);
03038          transmit_displaymessage(s, NULL); /* clear display */
03039          transmit_tone(s, SKINNY_DIALTONE);
03040 
03041          if (ast_strlen_zero(l->lastnumberdialed)) {
03042             ast_log(LOG_WARNING, "Attempted redial, but no previously dialed number found.\n");
03043             return 0;
03044          }
03045          if (!ast_ignore_pattern(c->context, l->lastnumberdialed)) {
03046             transmit_tone(s, SKINNY_SILENCE);
03047          }
03048          ast_copy_string(c->exten, l->lastnumberdialed, sizeof(c->exten));
03049          if (ast_pthread_create(&t, NULL, skinny_newcall, c)) {
03050             ast_log(LOG_WARNING, "Unable to create new call thread: %s\n", strerror(errno));
03051             ast_hangup(c);
03052          }
03053       }
03054 #endif
03055       break;
03056    case STIMULUS_SPEEDDIAL:
03057       if (skinnydebug)
03058          ast_verbose("Received Stimulus: SpeedDial(%d)\n", instance);
03059 
03060 #if 0
03061       if (!(sd = find_speeddial_by_instance(d, instance))) {
03062          return 0;
03063       }
03064 
03065       c = skinny_new(l, AST_STATE_DOWN);
03066       if(c) {
03067          sub = c->tech_pvt;
03068          l = sub->parent;
03069          transmit_callstate(s, l->instance, SKINNY_OFFHOOK, sub->callid);
03070          if (skinnydebug)
03071             ast_verbose("Attempting to Clear display on Skinny %s@%s\n", l->name, d->name);
03072          transmit_displaymessage(s, NULL); /* clear display */
03073          transmit_tone(s, SKINNY_DIALTONE);
03074 
03075          if (!ast_ignore_pattern(c->context, sd->exten)) {
03076             transmit_tone(s, SKINNY_SILENCE);
03077          }
03078          if (ast_exists_extension(c, c->context, sd->exten, 1, l->cid_num)) {
03079             if (!ast_matchmore_extension(c, c->context, sd->exten, 1, l->cid_num)) {
03080                ast_copy_string(c->exten, sd->exten, sizeof(c->exten));
03081                ast_copy_string(l->lastnumberdialed, sd->exten, sizeof(l->lastnumberdialed));
03082                skinny_newcall(c);
03083                break;
03084             }
03085          }
03086       } else {
03087          ast_log(LOG_WARNING, "Unable to create channel for %s@%s\n", l->name, d->name);
03088       }
03089 #endif
03090       break;
03091    case STIMULUS_HOLD:
03092       if (skinnydebug)
03093          ast_verbose("Received Stimulus: Hold(%d)\n", instance);
03094 
03095       if (!sub)
03096          break;
03097 
03098       if (sub->onhold) {
03099          skinny_unhold(sub);
03100       } else {
03101          skinny_hold(sub);
03102       }
03103       break;
03104    case STIMULUS_TRANSFER:
03105       if (skinnydebug)
03106          ast_verbose("Received Stimulus: Transfer(%d)\n", instance);
03107       transmit_tone(s, SKINNY_DIALTONE);
03108       /* XXX figure out how to transfer */
03109       break;
03110    case STIMULUS_CONFERENCE:
03111       if (skinnydebug)
03112          ast_verbose("Received Stimulus: Conference(%d)\n", instance);
03113       transmit_tone(s, SKINNY_DIALTONE);
03114       /* XXX determine the best way to pull off a conference.  Meetme? */
03115       break;
03116    case STIMULUS_VOICEMAIL:
03117       if (skinnydebug)
03118          ast_verbose("Received Stimulus: Voicemail(%d)\n", instance);
03119       /* XXX Find and dial voicemail extension */
03120       break;
03121    case STIMULUS_CALLPARK:
03122       if (skinnydebug)
03123          ast_verbose("Received Stimulus: Park Call(%d)\n", instance);
03124       /* XXX Park the call */
03125       break;
03126    case STIMULUS_FORWARDALL:
03127       if (skinnydebug)
03128          ast_verbose("Received Stimulus: Forward All(%d)\n", instance);
03129       /* Why is DND under FORWARDALL? */
03130       /* Because it's the same thing. */
03131 
03132       /* Do not disturb */
03133       transmit_tone(s, SKINNY_DIALTONE);
03134       if (l->dnd != 0){
03135          if (option_verbose > 2)
03136             ast_verbose(VERBOSE_PREFIX_3 "Disabling DND on %s@%s\n", l->name, d->name);
03137          l->dnd = 0;
03138          transmit_lamp_indication(s, STIMULUS_FORWARDALL, 1, SKINNY_LAMP_ON);
03139          transmit_displaynotify(s, "DnD disabled", 10);
03140       } else {
03141          if (option_verbose > 2)
03142             ast_verbose(VERBOSE_PREFIX_3 "Enabling DND on %s@%s\n", l->name, d->name);
03143          l->dnd = 1;
03144          transmit_lamp_indication(s, STIMULUS_FORWARDALL, 1, SKINNY_LAMP_OFF);
03145          transmit_displaynotify(s, "DnD enabled", 10);
03146       }
03147       break;
03148    case STIMULUS_FORWARDBUSY:
03149       if (skinnydebug)
03150          ast_verbose("Received Stimulus: Forward Busy (%d)\n", instance);
03151       break;
03152    case STIMULUS_FORWARDNOANSWER:
03153       if (skinnydebug)
03154          ast_verbose("Received Stimulus: Forward No Answer (%d)\n", instance);
03155       break;
03156    case STIMULUS_DISPLAY:
03157       /* Not sure what this is */
03158       if (skinnydebug)
03159          ast_verbose("Received Stimulus: Display(%d)\n", instance);
03160       break;
03161    case STIMULUS_LINE:
03162       if (skinnydebug)
03163          ast_verbose("Received Stimulus: Line(%d)\n", instance);
03164 
03165       l = find_line_by_instance(s->device, instance);
03166 
03167       if (!l) {
03168          return 0;
03169       }
03170 
03171       /* turn the speaker on */
03172       transmit_speaker_mode(s, SKINNY_SPEAKERON);
03173       transmit_ringer_mode(s, SKINNY_RING_OFF);
03174       transmit_lamp_indication(s, STIMULUS_LINE, l->instance, SKINNY_LAMP_ON);
03175 
03176       l->hookstate = SKINNY_OFFHOOK;
03177 
03178       if (sub && sub->outgoing) {
03179          /* We're answering a ringing call */
03180          ast_queue_control(sub->owner, AST_CONTROL_ANSWER);
03181          transmit_callstate(s, l->instance, SKINNY_OFFHOOK, sub->callid);
03182          transmit_tone(s, SKINNY_SILENCE);
03183          transmit_callstate(s, l->instance, SKINNY_CONNECTED, sub->callid);
03184          transmit_displaypromptstatus(s, "Connected", 0, l->instance, sub->callid);
03185          transmit_selectsoftkeys(s, l->instance, sub->callid, KEYDEF_CONNECTED);
03186          start_rtp(sub);
03187          ast_setstate(sub->owner, AST_STATE_UP);
03188       } else {
03189          if (sub && sub->owner) {
03190             ast_log(LOG_DEBUG, "Current subchannel [%s] already has owner\n", sub->owner->name);
03191          } else {
03192             c = skinny_new(l, AST_STATE_DOWN);
03193             if(c) {
03194                sub = c->tech_pvt;
03195                transmit_callstate(s, l->instance, SKINNY_OFFHOOK, sub->callid);
03196                if (skinnydebug)
03197                   ast_verbose("Attempting to Clear display on Skinny %s@%s\n", l->name, d->name);
03198                transmit_displaymessage(s, NULL); /* clear display */
03199                transmit_tone(s, SKINNY_DIALTONE);
03200                transmit_selectsoftkeys(s, l->instance, sub->callid, KEYDEF_OFFHOOK);
03201 
03202                /* start the switch thread */
03203                if (ast_pthread_create(&t, NULL, skinny_ss, c)) {
03204                   ast_log(LOG_WARNING, "Unable to create switch thread: %s\n", strerror(errno));
03205                   ast_hangup(c);
03206                }
03207             } else {
03208                ast_log(LOG_WARNING, "Unable to create channel for %s@%s\n", l->name, d->name);
03209             }
03210          }
03211       }
03212       break;
03213    default:
03214       if (skinnydebug)
03215          ast_verbose("RECEIVED UNKNOWN STIMULUS:  %d(%d)\n", event, instance);
03216       break;
03217    }
03218    return 1;
03219 }

static int handle_time_date_req_message ( struct skinny_req req,
struct skinnysession s 
) [static]

Definition at line 3441 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::minute, definetimedate_message::month, req_alloc(), s, definetimedate_message::seconds, transmit_response(), and definetimedate_message::year.

Referenced by handle_message().

03442 {
03443    time_t timer;
03444    struct tm *cmtime;
03445 
03446    if (!(req = req_alloc(sizeof(struct definetimedate_message), DEFINETIMEDATE_MESSAGE)))
03447       return -1;
03448 
03449    timer = time(NULL);
03450    cmtime = localtime(&timer);
03451    req->data.definetimedate.year = htolel(cmtime->tm_year+1900);
03452    req->data.definetimedate.month = htolel(cmtime->tm_mon+1);
03453    req->data.definetimedate.dayofweek = htolel(cmtime->tm_wday);
03454    req->data.definetimedate.day = htolel(cmtime->tm_mday);
03455    req->data.definetimedate.hour = htolel(cmtime->tm_hour);
03456    req->data.definetimedate.minute = htolel(cmtime->tm_min);
03457    req->data.definetimedate.seconds = htolel(cmtime->tm_sec);
03458    transmit_response(s, req);
03459    return 1;
03460 }

static int handle_unregister_message ( struct skinny_req req,
struct skinnysession s 
) [static]

Definition at line 3969 of file chan_skinny.c.

References s, and skinny_unregister().

Referenced by handle_message().

03970 {
03971    return skinny_unregister(req, s);
03972 }

static int handle_version_req_message ( struct skinny_req req,
struct skinnysession s 
) [static]

Definition at line 3573 of file chan_skinny.c.

References skinny_req::data, req_alloc(), s, transmit_response(), version_res_message::version, skinny_data::version, skinny_device::version_id, and VERSION_RES_MESSAGE.

Referenced by handle_message().

03574 {
03575    struct skinny_device *d = s->device;
03576    if (!(req = req_alloc(sizeof(struct version_res_message), VERSION_RES_MESSAGE)))
03577       return -1;
03578 
03579    snprintf(req->data.version.version, sizeof(req->data.version.version), d->version_id);
03580    transmit_response(s, req);
03581    return 1;
03582 }

static int load_module ( void   )  [static]

Definition at line 4621 of file chan_skinny.c.

References ast_channel_register(), ast_cli_register_multiple(), ast_log(), AST_MODULE_LOAD_DECLINE, ast_rtp_proto_register(), cli_skinny, htolel, io, io_context_create(), LOG_ERROR, LOG_WARNING, reload_config(), restart_monitor(), sched_context_create(), skinny_rtp, skinny_tech, and soft_key_template_default.

04622 {
04623    int res = 0;
04624 
04625    for (; res < (sizeof(soft_key_template_default) / sizeof(soft_key_template_default[0])); res++) {
04626       soft_key_template_default[res].softKeyEvent = htolel(soft_key_template_default[res].softKeyEvent);
04627    }
04628    /* load and parse config */
04629    res = reload_config();
04630    if (res == -1) {
04631       return AST_MODULE_LOAD_DECLINE;
04632    }
04633 
04634    /* Make sure we can register our skinny channel type */
04635    if (ast_channel_register(&skinny_tech)) {
04636       ast_log(LOG_ERROR, "Unable to register channel class 'Skinny'\n");
04637       return -1;
04638    }
04639 
04640    ast_rtp_proto_register(&skinny_rtp);
04641    ast_cli_register_multiple(cli_skinny, sizeof(cli_skinny) / sizeof(struct ast_cli_entry));
04642    sched = sched_context_create();
04643    if (!sched) {
04644       ast_log(LOG_WARNING, "Unable to create schedule context\n");
04645    }
04646    io = io_context_create();
04647    if (!io) {
04648       ast_log(LOG_WARNING, "Unable to create I/O context\n");
04649    }
04650    /* And start the monitor for the first time */
04651    restart_monitor();
04652 
04653    return res;
04654 }

static int reload_config ( void   )  [static]

Definition at line 4420 of file chan_skinny.c.

References __ourip, accept_t, 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(), config, date_format, default_capability, default_jbconf, default_prefs, DEFAULT_SKINNY_BACKLOG, DEFAULT_SKINNY_PORT, devices, global_jbconf, hp, keep_alive, ast_variable::lineno, LOG_ERROR, LOG_NOTICE, LOG_WARNING, skinny_device::name, ast_variable::name, skinny_device::next, ast_variable::next, option_verbose, ourhost, ourport, skinnysock, ast_variable::value, VERBOSE_PREFIX_2, and VERBOSE_PREFIX_3.

04421 {
04422    int on = 1;
04423    struct ast_config *cfg;
04424    struct ast_variable *v;
04425    char *cat;
04426    struct skinny_device *d;
04427    int oldport = ntohs(bindaddr.sin_port);
04428 
04429    if (gethostname(ourhost, sizeof(ourhost))) {
04430       ast_log(LOG_WARNING, "Unable to get hostname, Skinny disabled\n");
04431       return 0;
04432    }
04433    cfg = ast_config_load(config);
04434 
04435    /* We *must* have a config file otherwise stop immediately */
04436    if (!cfg) {
04437       ast_log(LOG_NOTICE, "Unable to load config %s, Skinny disabled\n", config);
04438       return -1;
04439    }
04440    memset(&bindaddr, 0, sizeof(bindaddr));
04441    memset(&default_prefs, 0, sizeof(default_prefs));
04442 
04443    /* Copy the default jb config over global_jbconf */
04444    memcpy(&global_jbconf, &default_jbconf, sizeof(struct ast_jb_conf));
04445 
04446    /* load the general section */
04447    v = ast_variable_browse(cfg, "general");
04448    while (v) {
04449       /* handle jb conf */
04450       if (!ast_jb_read_conf(&global_jbconf, v->name, v->value)) {
04451          v = v->next;
04452          continue;
04453       }
04454 
04455       /* Create the interface list */
04456       if (!strcasecmp(v->name, "bindaddr")) {
04457          if (!(hp = ast_gethostbyname(v->value, &ahp))) {
04458             ast_log(LOG_WARNING, "Invalid address: %s\n", v->value);
04459          } else {
04460             memcpy(&bindaddr.sin_addr, hp->h_addr, sizeof(bindaddr.sin_addr));
04461          }
04462       } else if (!strcasecmp(v->name, "keepalive")) {
04463          keep_alive = atoi(v->value);
04464       } else if (!strcasecmp(v->name, "dateformat")) {
04465          ast_copy_string(date_format, v->value, sizeof(date_format));
04466       } else if (!strcasecmp(v->name, "allow")) {
04467          ast_parse_allow_disallow(&default_prefs, &default_capability, v->value, 1);
04468       } else if (!strcasecmp(v->name, "disallow")) {
04469          ast_parse_allow_disallow(&default_prefs, &default_capability, v->value, 0);
04470       } else if (!strcasecmp(v->name, "bindport") || !strcasecmp(v->name, "port")) {
04471          if (sscanf(v->value, "%d", &ourport) == 1) {
04472             bindaddr.sin_port = htons(ourport);
04473          } else {
04474             ast_log(LOG_WARNING, "Invalid bindport '%s' at line %d of %s\n", v->value, v->lineno, config);
04475          }
04476          if (!strcasecmp(v->name, "port")) { /*! \todo Remove 'port' option after 1.4 */
04477             ast_log(LOG_WARNING, "Option 'port' at line %d of %s has been deprecated.  Please use 'bindport' instead.\n", v->lineno, config);
04478          }
04479       }
04480       v = v->next;
04481    }
04482 
04483    if (ntohl(bindaddr.sin_addr.s_addr)) {
04484       __ourip = bindaddr.sin_addr;
04485    } else {
04486       hp = ast_gethostbyname(ourhost, &ahp);
04487       if (!hp) {
04488          ast_log(LOG_WARNING, "Unable to get our IP address, Skinny disabled\n");
04489          ast_config_destroy(cfg);
04490          return 0;
04491       }
04492       memcpy(&__ourip, hp->h_addr, sizeof(__ourip));
04493    }
04494    if (!ntohs(bindaddr.sin_port)) {
04495       bindaddr.sin_port = ntohs(DEFAULT_SKINNY_PORT);
04496    }
04497    bindaddr.sin_family = AF_INET;
04498 
04499    /* load the device sections */
04500    cat = ast_category_browse(cfg, NULL);
04501    while(cat) {
04502       if (!strcasecmp(cat, "general")) {
04503          /* Nothing to do */
04504 #if 0
04505       } else if (!strncasecmp(cat, "paging-", 7)) {
04506          p = build_paging_device(cat, ast_variable_browse(cfg, cat));
04507          if (p) {
04508          }
04509 #endif
04510       } else {
04511          d = build_device(cat, ast_variable_browse(cfg, cat));
04512          if (d) {
04513             if (option_verbose > 2)
04514                ast_verbose(VERBOSE_PREFIX_3 "Added device '%s'\n", d->name);
04515             ast_mutex_lock(&devicelock);
04516             d->next = devices;
04517             devices = d;
04518             ast_mutex_unlock(&devicelock);
04519          }
04520       }
04521       cat = ast_category_browse(cfg, cat);
04522    }
04523    ast_mutex_lock(&netlock);
04524    if ((skinnysock > -1) && (ntohs(bindaddr.sin_port) != oldport)) {
04525       close(skinnysock);
04526       skinnysock = -1;
04527    }
04528    if (skinnysock < 0) {
04529       skinnysock = socket(AF_INET, SOCK_STREAM, 0);
04530       if(setsockopt(skinnysock, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)) == -1) {
04531          ast_log(LOG_ERROR, "Set Socket Options failed: errno %d, %s\n", errno, strerror(errno));
04532          ast_config_destroy(cfg);
04533          return 0;
04534       }
04535       if (skinnysock < 0) {
04536          ast_log(LOG_WARNING, "Unable to create Skinny socket: %s\n", strerror(errno));
04537       } else {
04538          if (bind(skinnysock, (struct sockaddr *)&bindaddr, sizeof(bindaddr)) < 0) {
04539             ast_log(LOG_WARNING, "Failed to bind to %s:%d: %s\n",
04540                   ast_inet_ntoa(bindaddr.sin_addr), ntohs(bindaddr.sin_port),
04541                      strerror(errno));
04542             close(skinnysock);
04543             skinnysock = -1;
04544             ast_config_destroy(cfg);
04545             return 0;
04546          }
04547          if (listen(skinnysock,DEFAULT_SKINNY_BACKLOG)) {
04548                ast_log(LOG_WARNING, "Failed to start listening to %s:%d: %s\n",
04549                   ast_inet_ntoa(bindaddr.sin_addr), ntohs(bindaddr.sin_port),
04550                      strerror(errno));
04551                close(skinnysock);
04552                skinnysock = -1;
04553                ast_config_destroy(cfg);
04554                return 0;
04555          }
04556          if (option_verbose > 1)
04557             ast_verbose(VERBOSE_PREFIX_2 "Skinny listening on %s:%d\n",
04558                ast_inet_ntoa(bindaddr.sin_addr), ntohs(bindaddr.sin_port));
04559          ast_pthread_create_background(&accept_t,NULL, accept_thread, NULL);
04560       }
04561    }
04562    ast_mutex_unlock(&netlock);
04563    ast_config_destroy(cfg);
04564    return 1;
04565 }

static struct skinny_req* req_alloc ( size_t  size,
int  response_message 
) [static]

Definition at line 1175 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().

01176 {
01177    struct skinny_req *req;
01178 
01179    if (!(req = ast_calloc(1, skinny_header_size + size + 4)))
01180       return NULL;
01181 
01182    req->len = htolel(size+4);
01183    req->e = htolel(response_message);
01184 
01185    return req;
01186 }

static int restart_monitor ( void   )  [static]

Definition at line 4356 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, LOG_WARNING, and monitor_thread.

04357 {
04358    /* If we're supposed to be stopped -- stay stopped */
04359    if (monitor_thread == AST_PTHREADT_STOP)
04360       return 0;
04361 
04362    ast_mutex_lock(&monlock);
04363    if (monitor_thread == pthread_self()) {
04364       ast_mutex_unlock(&monlock);
04365       ast_log(LOG_WARNING, "Cannot kill myself\n");
04366       return -1;
04367    }
04368    if (monitor_thread != AST_PTHREADT_NULL) {
04369       /* Wake up the thread */
04370       pthread_kill(monitor_thread, SIGURG);
04371    } else {
04372       /* Start a new monitor */
04373       if (ast_pthread_create_background(&monitor_thread, NULL, do_monitor, NULL) < 0) {
04374          ast_mutex_unlock(&monlock);
04375          ast_log(LOG_ERROR, "Unable to start monitor thread.\n");
04376          return -1;
04377       }
04378    }
04379    ast_mutex_unlock(&monlock);
04380    return 0;
04381 }

static int skinny_answer ( struct ast_channel ast  )  [static]

Definition at line 2451 of file chan_skinny.c.

References ast_channel::_state, 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, skinny_line::instance, KEYDEF_CONNECTED, skinny_device::name, skinny_line::name, skinny_line::parent, skinny_subchannel::parent, skinny_subchannel::rtp, s, skinny_device::session, SKINNY_CONNECTED, SKINNY_CX_SENDRECV, SKINNY_SILENCE, skinnydebug, start_rtp(), skinny_line::sub, ast_channel::tech_pvt, transmit_callinfo(), transmit_callstate(), transmit_displaypromptstatus(), transmit_selectsoftkeys(), and transmit_tone().

02452 {
02453    int res = 0;
02454    struct skinny_subchannel *sub = ast->tech_pvt;
02455    struct skinny_line *l = sub->parent;
02456    struct skinny_device *d = l->parent;
02457    struct skinnysession *s = d->session;
02458 
02459    sub->cxmode = SKINNY_CX_SENDRECV;
02460    if (!sub->rtp) {
02461       start_rtp(sub);
02462    }
02463    if (skinnydebug)
02464       ast_verbose("skinny_answer(%s) on %s@%s-%d\n", ast->name, l->name, d->name, sub->callid);
02465    if (ast->_state != AST_STATE_UP) {
02466       ast_setstate(ast, AST_STATE_UP);
02467    }
02468 
02469    transmit_tone(s, SKINNY_SILENCE);
02470    /* order matters here...
02471       for some reason, transmit_callinfo must be before transmit_callstate,
02472       or you won't get keypad messages in some situations. */
02473    transmit_callinfo(s, ast->cid.cid_name, ast->cid.cid_num, ast->exten, ast->exten, l->instance, sub->callid, 2);
02474    transmit_callstate(s, l->instance, SKINNY_CONNECTED, sub->callid);
02475    transmit_selectsoftkeys(s, l->instance, sub->callid, KEYDEF_CONNECTED);
02476    transmit_displaypromptstatus(s, "Connected", 0, l->instance, sub->callid);
02477    return res;
02478 }

static int skinny_call ( struct ast_channel ast,
char *  dest,
int  timeout 
) [static]

Definition at line 2354 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, skinnydebug, STIMULUS_LINE, skinny_line::sub, ast_channel::tech_pvt, transmit_callinfo(), transmit_callstate(), transmit_displaypromptstatus(), transmit_lamp_indication(), transmit_ringer_mode(), transmit_selectsoftkeys(), and VERBOSE_PREFIX_3.

02355 {
02356    int res = 0;
02357    int tone = 0;
02358    struct skinny_subchannel *sub = ast->tech_pvt;
02359    struct skinny_line *l = sub->parent;
02360    struct skinny_device *d = l->parent;
02361    struct skinnysession *s = d->session;
02362 
02363    if (!d->registered) {
02364       ast_log(LOG_ERROR, "Device not registered, cannot call %s\n", dest);
02365       return -1;
02366    }
02367 
02368    if ((ast->_state != AST_STATE_DOWN) && (ast->_state != AST_STATE_RESERVED)) {
02369       ast_log(LOG_WARNING, "skinny_call called on %s, neither down nor reserved\n", ast->name);
02370       return -1;
02371    }
02372 
02373    if (skinnydebug)
02374       ast_verbose(VERBOSE_PREFIX_3 "skinny_call(%s)\n", ast->name);
02375 
02376    if (l->dnd) {
02377       ast_queue_control(ast, AST_CONTROL_BUSY);
02378       return -1;
02379    }
02380 
02381    switch (l->hookstate) {
02382    case SKINNY_OFFHOOK:
02383       tone = SKINNY_CALLWAITTONE;
02384       break;
02385    case SKINNY_ONHOOK:
02386       tone = SKINNY_ALERT;
02387       break;
02388    default:
02389       ast_log(LOG_ERROR, "Don't know how to deal with hookstate %d\n", l->hookstate);
02390       break;
02391    }
02392 
02393    transmit_callstate(s, l->instance, SKINNY_RINGIN, sub->callid);
02394    transmit_selectsoftkeys(s, l->instance, sub->callid, KEYDEF_RINGIN);
02395    transmit_displaypromptstatus(s, "Ring-In", 0, l->instance, sub->callid);
02396    transmit_callinfo(s, ast->cid.cid_name, ast->cid.cid_num, l->cid_name, l->cid_num, l->instance, sub->callid, 1);
02397    transmit_lamp_indication(s, STIMULUS_LINE, l->instance, SKINNY_LAMP_BLINK);
02398    transmit_ringer_mode(s, SKINNY_RING_INSIDE);
02399 
02400    ast_setstate(ast, AST_STATE_RINGING);
02401    ast_queue_control(ast, AST_CONTROL_RINGING);
02402    sub->outgoing = 1;
02403    return res;
02404 }

static int skinny_do_debug ( int  fd,
int  argc,
char *  argv[] 
) [static]

Definition at line 1769 of file chan_skinny.c.

References ast_cli(), RESULT_SHOWUSAGE, RESULT_SUCCESS, and skinnydebug.

01770 {
01771    if (argc != 3) {
01772       return RESULT_SHOWUSAGE;
01773    }
01774    skinnydebug = 1;
01775    ast_cli(fd, "Skinny Debugging Enabled\n");
01776    return RESULT_SUCCESS;
01777 }

static int skinny_fixup ( struct ast_channel oldchan,
struct ast_channel newchan 
) [static]

Definition at line 2566 of file chan_skinny.c.

References ast_log(), LOG_NOTICE, LOG_WARNING, skinny_subchannel::owner, and ast_channel::tech_pvt.

02567 {
02568    struct skinny_subchannel *sub = newchan->tech_pvt;
02569    ast_log(LOG_NOTICE, "skinny_fixup(%s, %s)\n", oldchan->name, newchan->name);
02570    if (sub->owner != oldchan) {
02571       ast_log(LOG_WARNING, "old channel wasn't %p but was %p\n", oldchan, sub->owner);
02572       return -1;
02573    }
02574    sub->owner = newchan;
02575    return 0;
02576 }

static enum ast_rtp_get_result skinny_get_rtp_peer ( struct ast_channel c,
struct ast_rtp **  rtp 
) [static]

Definition at line 1739 of file chan_skinny.c.

References AST_RTP_GET_FAILED, AST_RTP_TRY_NATIVE, skinny_subchannel::rtp, and ast_channel::tech_pvt.

01740 {
01741    struct skinny_subchannel *sub = NULL;
01742 
01743    if (!(sub = c->tech_pvt) || !(sub->rtp))
01744       return AST_RTP_GET_FAILED;
01745 
01746    *rtp = sub->rtp;
01747 
01748    return AST_RTP_TRY_NATIVE;
01749 }

static enum ast_rtp_get_result skinny_get_vrtp_peer ( struct ast_channel c,
struct ast_rtp **  rtp 
) [static]

Definition at line 1727 of file chan_skinny.c.

References AST_RTP_GET_FAILED, AST_RTP_TRY_NATIVE, skinny_subchannel::rtp, ast_channel::tech_pvt, and skinny_subchannel::vrtp.

01728 {
01729    struct skinny_subchannel *sub = NULL;
01730 
01731    if (!(sub = c->tech_pvt) || !(sub->vrtp))
01732       return AST_RTP_GET_FAILED;
01733 
01734    *rtp = sub->vrtp;
01735 
01736    return AST_RTP_TRY_NATIVE;
01737 }

static int skinny_hangup ( struct ast_channel ast  )  [static]

Definition at line 2406 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, skinnydebug, 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.

02407 {
02408    struct skinny_subchannel *sub = ast->tech_pvt;
02409    struct skinny_line *l;
02410    struct skinny_device *d;
02411    struct skinnysession *s;
02412 
02413    if (!sub) {
02414       ast_log(LOG_DEBUG, "Asked to hangup channel not connected\n");
02415       return 0;
02416    }
02417    l = sub->parent;
02418    d = l->parent;
02419    s = d->session;
02420    if (skinnydebug)
02421       ast_verbose("skinny_hangup(%s) on %s@%s\n", ast->name, l->name, d->name);
02422 
02423    if (d->registered) {
02424       if ((l->type = TYPE_LINE) && (l->hookstate == SKINNY_OFFHOOK)) {
02425          l->hookstate = SKINNY_ONHOOK;
02426          transmit_callstate(s, l->instance, SKINNY_ONHOOK, sub->callid);
02427          transmit_lamp_indication(s, STIMULUS_LINE, l->instance, SKINNY_LAMP_OFF);
02428          transmit_speaker_mode(s, SKINNY_SPEAKEROFF);
02429       } else if ((l->type = TYPE_LINE) && (l->hookstate == SKINNY_ONHOOK)) {
02430          transmit_callstate(s, l->instance, SKINNY_ONHOOK, sub->callid);
02431          transmit_speaker_mode(s, SKINNY_SPEAKEROFF);
02432          transmit_ringer_mode(s, SKINNY_RING_OFF);
02433          transmit_tone(s, SKINNY_SILENCE);
02434          transmit_lamp_indication(s, STIMULUS_LINE, l->instance, SKINNY_LAMP_OFF);
02435          do_housekeeping(s);
02436       }
02437    }
02438    ast_mutex_lock(&sub->lock);
02439    sub->owner = NULL;
02440    ast->tech_pvt = NULL;
02441    sub->alreadygone = 0;
02442    sub->outgoing = 0;
02443    if (sub->rtp) {
02444       ast_rtp_destroy(sub->rtp);
02445       sub->rtp = NULL;
02446    }
02447    ast_mutex_unlock(&sub->lock);
02448    return 0;
02449 }

static int skinny_hold ( struct skinny_subchannel sub  )  [static]

Definition at line 2801 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, skinnydebug, STIMULUS_LINE, STOP_MEDIA_TRANSMISSION_MESSAGE, skinny_data::stopmedia, skinny_line::sub, transmit_lamp_indication(), and transmit_response().

Referenced by handle_soft_key_event_message(), and handle_stimulus_message().

02802 {
02803    struct skinny_line *l = sub->parent;
02804    struct skinny_device *d = l->parent;
02805    struct skinnysession *s = d->session;
02806    struct skinny_req *req;
02807 
02808    /* Channel needs to be put on hold */
02809    if (skinnydebug)
02810       ast_verbose("Putting on Hold(%d)\n", l->instance);
02811 
02812    ast_queue_control_data(sub->owner, AST_CONTROL_HOLD,
02813       S_OR(l->mohsuggest, NULL),
02814       !ast_strlen_zero(l->mohsuggest) ? strlen(l->mohsuggest) + 1 : 0);
02815 
02816    if (!(req = req_alloc(sizeof(struct activate_call_plane_message), ACTIVATE_CALL_PLANE_MESSAGE)))
02817       return 0;
02818 
02819    req->data.activatecallplane.lineInstance = htolel(l->instance);
02820    transmit_response(s, req);
02821 
02822    if (!(req = req_alloc(sizeof(struct close_receive_channel_message), CLOSE_RECEIVE_CHANNEL_MESSAGE)))
02823       return 0;
02824 
02825    req->data.closereceivechannel.conferenceId = htolel(0);
02826    req->data.closereceivechannel.partyId = htolel(sub->callid);
02827    transmit_response(s, req);
02828 
02829    if (!(req = req_alloc(sizeof(struct stop_media_transmission_message), STOP_MEDIA_TRANSMISSION_MESSAGE)))
02830       return 0;
02831 
02832    req->data.stopmedia.conferenceId = htolel(0);
02833    req->data.stopmedia.passThruPartyId = htolel(sub->callid);
02834    transmit_response(s, req);
02835 
02836    transmit_lamp_indication(s, STIMULUS_LINE, l->instance, SKINNY_LAMP_BLINK);
02837    sub->onhold = 1;
02838    return 1;
02839 }

static int skinny_indicate ( struct ast_channel ast,
int  ind,
const void *  data,
size_t  datalen 
) [static]

Definition at line 2646 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_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, skinny_line::instance, LOG_WARNING, skinny_line::mohinterpret, skinny_subchannel::outgoing, skinny_line::parent, skinny_subchannel::parent, skinny_subchannel::progress, skinny_subchannel::ringing, s, skinny_device::session, SKINNY_ALERT, SKINNY_BUSY, SKINNY_BUSYTONE, SKINNY_CONGESTION, SKINNY_PROGRESS, SKINNY_REORDER, SKINNY_RINGOUT, SKINNY_SILENCE, skinnydebug, skinny_line::sub, ast_channel::tech_pvt, transmit_callinfo(), transmit_callstate(), transmit_dialednumber(), transmit_displaypromptstatus(), transmit_tone(), and VERBOSE_PREFIX_3.

02647 {
02648    struct skinny_subchannel *sub = ast->tech_pvt;
02649    struct skinny_line *l = sub->parent;
02650    struct skinny_device *d = l->parent;
02651    struct skinnysession *s = d->session;
02652 
02653    if (skinnydebug)
02654       ast_verbose(VERBOSE_PREFIX_3 "Asked to indicate '%s' condition on channel %s\n", control2str(ind), ast->name);
02655    switch(ind) {
02656    case AST_CONTROL_RINGING:
02657       if (ast->_state != AST_STATE_UP) {
02658          if (!sub->progress) {
02659             transmit_tone(s, SKINNY_ALERT);
02660             transmit_callstate(s, l->instance, SKINNY_RINGOUT, sub->callid);
02661             transmit_dialednumber(s, ast->exten, l->instance, sub->callid);
02662             transmit_displaypromptstatus(s, "Ring Out", 0, l->instance, sub->callid);
02663             transmit_callinfo(s, ast->cid.cid_name, ast->cid.cid_num, ast->exten, ast->exten, l->instance, sub->callid, 2); /* 2 = outgoing from phone */
02664             sub->ringing = 1;
02665             break;
02666          }
02667       }
02668       return -1;
02669    case AST_CONTROL_BUSY:
02670       if (ast->_state != AST_STATE_UP) {
02671          transmit_tone(s, SKINNY_BUSYTONE);
02672          transmit_callstate(s, l->instance, SKINNY_BUSY, sub->callid);
02673          sub->alreadygone = 1;
02674          ast_softhangup_nolock(ast, AST_SOFTHANGUP_DEV);
02675          break;
02676       }
02677       return -1;
02678    case AST_CONTROL_CONGESTION:
02679       if (ast->_state != AST_STATE_UP) {
02680          transmit_tone(s, SKINNY_REORDER);
02681          transmit_callstate(s, l->instance, SKINNY_CONGESTION, sub->callid);
02682          sub->alreadygone = 1;
02683          ast_softhangup_nolock(ast, AST_SOFTHANGUP_DEV);
02684          break;
02685       }
02686       return -1;
02687    case AST_CONTROL_PROGRESS:
02688       if ((ast->_state != AST_STATE_UP) && !sub->progress && !sub->outgoing) {
02689          transmit_tone(s, SKINNY_ALERT);
02690          transmit_callstate(s, l->instance, SKINNY_PROGRESS, sub->callid);
02691          transmit_displaypromptstatus(s, "Call Progress", 0, l->instance, sub->callid);
02692          transmit_callinfo(s, ast->cid.cid_name, ast->cid.cid_num, ast->exten, ast->exten, l->instance, sub->callid, 2); /* 2 = outgoing from phone */
02693          sub->progress = 1;
02694          break;
02695       }
02696       return -1;
02697    case -1:
02698       transmit_tone(s, SKINNY_SILENCE);
02699       break;
02700    case AST_CONTROL_HOLD:
02701       ast_moh_start(ast, data, l->mohinterpret);
02702       break;
02703    case AST_CONTROL_UNHOLD:
02704       ast_moh_stop(ast);
02705       break;
02706    case AST_CONTROL_PROCEEDING:
02707       break;
02708    default:
02709       ast_log(LOG_WARNING, "Don't know how to indicate condition %d\n", ind);
02710       return -1;
02711    }
02712    return 0;
02713 }

static struct ast_channel* skinny_new ( struct skinny_line l,
int  state 
) [static]

Definition at line 2715 of file chan_skinny.c.

References accountcode, 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, callnums, skinny_line::capability, ast_channel::cid, ast_callerid::cid_ani, ast_callerid::cid_name, skinny_line::cid_name, ast_callerid::cid_num, skinny_line::cid_num, ast_channel::context, skinny_line::context, skinny_subchannel::cxmode, default_capability, ast_channel::exten, skinny_line::exten, ast_channel::fds, fmt, global_jbconf, skinny_line::instance, language, 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_tech, skinnydebug, skinny_line::sub, ast_channel::tech, ast_channel::tech_pvt, and ast_channel::writeformat.

Referenced by handle_offhook_message(), handle_soft_key_event_message(), handle_stimulus_message(), and skinny_request().

02716 {
02717    struct ast_channel *tmp;
02718    struct skinny_subchannel *sub;
02719    struct skinny_device *d = l->parent;
02720    int fmt;
02721 
02722    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);
02723    if (!tmp) {
02724       ast_log(LOG_WARNING, "Unable to allocate channel structure\n");
02725       return NULL;
02726    } else {
02727       sub = ast_calloc(1, sizeof(struct skinny_subchannel));
02728       if (!sub) {
02729          ast_log(LOG_WARNING, "Unable to allocate Skinny subchannel\n");
02730          return NULL;
02731       } else {
02732          ast_mutex_init(&sub->lock);
02733 
02734          sub->owner = tmp;
02735          sub->callid = callnums++;
02736          d->lastlineinstance = l->instance;
02737          d->lastcallreference = sub->callid;
02738          sub->cxmode = SKINNY_CX_INACTIVE;
02739          sub->nat = l->nat;
02740          sub->parent = l;
02741          sub->onhold = 0;
02742 
02743          sub->next = l->sub;
02744          l->sub = sub;
02745       }
02746       tmp->tech = &skinny_tech;
02747       tmp->tech_pvt = sub;
02748       tmp->nativeformats = l->capability;
02749       if (!tmp->nativeformats)
02750          tmp->nativeformats = default_capability;
02751       fmt = ast_best_codec(tmp->nativeformats);
02752       if (skinnydebug)
02753          ast_verbose("skinny_new: tmp->nativeformats=%d fmt=%d\n", tmp->nativeformats, fmt);
02754       if (sub->rtp) {
02755          tmp->fds[0] = ast_rtp_fd(sub->rtp);
02756       }
02757       if (state == AST_STATE_RING) {
02758          tmp->rings = 1;
02759       }
02760       tmp->writeformat = fmt;
02761       tmp->rawwriteformat = fmt;
02762       tmp->readformat = fmt;
02763       tmp->rawreadformat = fmt;
02764       if (!ast_strlen_zero(l->language))
02765          ast_string_field_set(tmp, language, l->language);
02766       if (!ast_strlen_zero(l->accountcode))
02767          ast_string_field_set(tmp, accountcode, l->accountcode);
02768       if (l->amaflags)
02769          tmp->amaflags = l->amaflags;
02770 
02771       ast_module_ref(ast_module_info->self);
02772       tmp->callgroup = l->callgroup;
02773       tmp->pickupgroup = l->pickupgroup;
02774       ast_string_field_set(tmp, call_forward, l->call_forward);
02775       ast_copy_string(tmp->context, l->context, sizeof(tmp->context));
02776       ast_copy_string(tmp->exten, l->exten, sizeof(tmp->exten));
02777 
02778       /* Don't use ast_set_callerid() here because it will
02779        * generate a needless NewCallerID event */
02780       tmp->cid.cid_num = ast_strdup(l->cid_num);
02781       tmp->cid.cid_ani = ast_strdup(l->cid_num);
02782       tmp->cid.cid_name = ast_strdup(l->cid_name);
02783 
02784       tmp->priority = 1;
02785       tmp->adsicpe = AST_ADSI_UNAVAILABLE;
02786 
02787       if (sub->rtp)
02788          ast_jb_configure(tmp, &global_jbconf);
02789 
02790       if (state != AST_STATE_DOWN) {
02791          if (ast_pbx_start(tmp)) {
02792             ast_log(LOG_WARNING, "Unable to start PBX on %s\n", tmp->name);
02793             ast_hangup(tmp);
02794             tmp = NULL;
02795          }
02796       }
02797    }
02798    return tmp;
02799 }

static void* skinny_newcall ( void *  data  )  [static]

Definition at line 2243 of file chan_skinny.c.

References ast_log(), ast_pbx_run(), ast_set_callerid(), ast_setstate(), AST_STATE_RING, ast_channel::cid, ast_callerid::cid_ani, skinny_line::cid_name, skinny_line::cid_num, ast_channel::exten, skinny_line::hidecallerid, skinny_line::lastnumberdialed, LOG_WARNING, skinny_line::parent, skinny_subchannel::parent, s, skinny_device::session, SKINNY_REORDER, skinny_line::sub, ast_channel::tech_pvt, and transmit_tone().

Referenced by handle_soft_key_event_message(), handle_stimulus_message(), and skinny_ss().

02244 {
02245    struct ast_channel *c = data;
02246    struct skinny_subchannel *sub = c->tech_pvt;
02247    struct skinny_line *l = sub->parent;
02248    struct skinny_device *d = l->parent;
02249    struct skinnysession *s = d->session;
02250    int res = 0;
02251 
02252    ast_copy_string(l->lastnumberdialed, c->exten, sizeof(l->lastnumberdialed));
02253    ast_set_callerid(c,
02254       l->hidecallerid ? "" : l->cid_num,
02255       l->hidecallerid ? "" : l->cid_name,
02256       c->cid.cid_ani ? NULL : l->cid_num);
02257    ast_setstate(c, AST_STATE_RING);
02258    res = ast_pbx_run(c);
02259    if (res) {
02260       ast_log(LOG_WARNING, "PBX exited non-zero\n");
02261       transmit_tone(s, SKINNY_REORDER);
02262    }
02263    return NULL;
02264 }

static int skinny_no_debug ( int  fd,
int  argc,
char *  argv[] 
) [static]

Definition at line 1779 of file chan_skinny.c.

References ast_cli(), RESULT_SHOWUSAGE, RESULT_SUCCESS, and skinnydebug.

01780 {
01781    if (argc != 4) {
01782       return RESULT_SHOWUSAGE;
01783    }
01784    skinnydebug = 0;
01785    ast_cli(fd, "Skinny Debugging Disabled\n");
01786    return RESULT_SUCCESS;
01787 }

static struct ast_frame * skinny_read ( struct ast_channel ast  )  [static]

Definition at line 2528 of file chan_skinny.c.

References ast_mutex_lock(), ast_mutex_unlock(), skinny_subchannel::lock, skinny_rtp_read(), and ast_channel::tech_pvt.

02529 {
02530    struct ast_frame *fr;
02531    struct skinny_subchannel *sub = ast->tech_pvt;
02532    ast_mutex_lock(&sub->lock);
02533    fr = skinny_rtp_read(sub);
02534    ast_mutex_unlock(&sub->lock);
02535    return fr;
02536 }

static int skinny_register ( struct skinny_req req,
struct skinnysession s 
) [static]

Definition at line 1345 of file chan_skinny.c.

References __ourip, ast_apply_ha(), ast_log(), ast_mutex_lock(), ast_strlen_zero(), skinny_req::data, devices, skinny_device::ha, skinny_device::id, letohl, LOG_WARNING, register_message::name, skinny_device::next, skinny_data::reg, skinny_device::registered, s, skinny_device::session, register_message::type, skinny_device::type, version_id, and skinny_device::version_id.

Referenced by handle_register_message().

01346 {
01347    struct skinny_device *d;
01348    struct sockaddr_in sin;
01349    socklen_t slen;
01350 
01351    ast_mutex_lock(&devicelock);
01352    for (d = devices; d; d = d->next) {
01353       if (!strcasecmp(req->data.reg.name, d->id)
01354             && ast_apply_ha(d->ha, &(s->sin))) {
01355          s->device = d;
01356          d->type = letohl(req->data.reg.type);
01357          if (ast_strlen_zero(d->version_id)) {
01358             ast_copy_string(d->version_id, version_id, sizeof(d->version_id));
01359          }
01360          d->registered = 1;
01361          d->session = s;
01362 
01363          slen = sizeof(sin);
01364          if (getsockname(s->fd, (struct sockaddr *)&sin, &slen)) {
01365             ast_log(LOG_WARNING, "Cannot get socket name\n");
01366             sin.sin_addr = __ourip;
01367          }
01368          d->ourip = sin.sin_addr;
01369          break;
01370       }
01371    }
01372    ast_mutex_unlock(&devicelock);
01373    if (!d) {
01374       return 0;
01375    }
01376    return 1;
01377 }

static struct skinny_req* skinny_req_parse ( struct skinnysession s  )  [static]

Definition at line 4222 of file chan_skinny.c.

References ast_calloc, ast_log(), ast_mutex_lock(), ast_mutex_unlock(), skinny_req::data, skinny_req::e, free, letohl, LOG_ERROR, s, skinny_header_size, and SKINNY_MAX_PACKET.

Referenced by skinny_session().

04223 {
04224    struct skinny_req *req;
04225 
04226    if (!(req = ast_calloc(1, SKINNY_MAX_PACKET)))
04227       return NULL;
04228 
04229    ast_mutex_lock(&s->lock);
04230    memcpy(req, s->inbuf, skinny_header_size);
04231    memcpy(&req->data, s->inbuf+skinny_header_size, letohl(*(int*)(s->inbuf))-4);
04232 
04233    ast_mutex_unlock(&s->lock);
04234 
04235    if (letohl(req->e) < 0) {
04236       ast_log(LOG_ERROR, "Event Message is NULL from socket %d, This is bad\n", s->fd);
04237       free(req);
04238       return NULL;
04239    }
04240 
04241    return req;
04242 }

static struct ast_channel * skinny_request ( const char *  type,
int  format,
void *  data,
int *  cause 
) [static]

Definition at line 4383 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.

04384 {
04385    int oldformat;
04386    
04387    struct skinny_line *l;
04388    struct ast_channel *tmpc = NULL;
04389    char tmp[256];
04390    char *dest = data;
04391 
04392    oldformat = format;
04393    
04394    if (!(format &= ((AST_FORMAT_MAX_AUDIO << 1) - 1))) {
04395       ast_log(LOG_NOTICE, "Asked to get a channel of unsupported format '%d'\n", format);
04396       return NULL;   
04397    }     
04398 
04399    ast_copy_string(tmp, dest, sizeof(tmp));
04400    if (ast_strlen_zero(tmp)) {
04401       ast_log(LOG_NOTICE, "Skinny channels require a device\n");
04402       return NULL;
04403    }
04404    l = find_line_by_name(tmp);
04405    if (!l) {
04406       ast_log(LOG_NOTICE, "No available lines on: %s\n", dest);
04407       return NULL;
04408    }
04409    if (option_verbose > 2) {
04410       ast_verbose(VERBOSE_PREFIX_3 "skinny_request(%s)\n", tmp);
04411    }
04412    tmpc = skinny_new(l, AST_STATE_DOWN);
04413    if (!tmpc) {
04414       ast_log(LOG_WARNING, "Unable to make channel for '%s'\n", tmp);
04415    }
04416    restart_monitor();
04417    return tmpc;
04418 }

static int skinny_reset_device ( int  fd,
int  argc,
char *  argv[] 
) [static]

Definition at line 1807 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.

01808 {
01809    struct skinny_device *d;
01810    struct skinny_req *req;
01811 
01812    if (argc < 3 || argc > 4) {
01813       return RESULT_SHOWUSAGE;
01814    }
01815    ast_mutex_lock(&devicelock);
01816 
01817    for (d = devices; d; d = d->next) {
01818       int fullrestart = 0;
01819       if (!strcasecmp(argv[2], d->id) || !strcasecmp(argv[2], "all")) {
01820          if (!(d->session))
01821             continue;
01822 
01823          if (!(req = req_alloc(sizeof(struct reset_message), RESET_MESSAGE)))
01824             continue;
01825 
01826          if (argc == 4 && !strcasecmp(argv[3], "restart"))
01827             fullrestart = 1;
01828 
01829          if (fullrestart)
01830             req->data.reset.resetType = 2;
01831          else
01832             req->data.reset.resetType = 1;
01833 
01834          if (option_verbose > 2)
01835             ast_verbose(VERBOSE_PREFIX_3 "%s device %s.\n", (fullrestart) ? "Restarting" : "Resetting", d->id);
01836          transmit_response(d->session, req);
01837       }
01838    }
01839    ast_mutex_unlock(&devicelock);
01840    return RESULT_SUCCESS;
01841 }

static struct ast_frame* skinny_rtp_read ( struct skinny_subchannel sub  )  [static]

Definition at line 2481 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, LOG_DEBUG, ast_channel::nativeformats, skinny_subchannel::owner, ast_channel::readformat, skinny_subchannel::rtp, skinny_subchannel::vrtp, and ast_channel::writeformat.

Referenced by skinny_read().

02482 {
02483    struct ast_channel *ast = sub->owner;
02484    struct ast_frame *f;
02485 
02486    if (!sub->rtp) {
02487       /* We have no RTP allocated for this channel */
02488       return &ast_null_frame;
02489    }
02490 
02491    switch(ast->fdno) {
02492    case 0:
02493       f = ast_rtp_read(sub->rtp);   /* RTP Audio */
02494       break;
02495    case 1:
02496       f = ast_rtcp_read(sub->rtp);  /* RTCP Control Channel */
02497       break;
02498    case 2:
02499       f = ast_rtp_read(sub->vrtp);  /* RTP Video */
02500       break;
02501    case 3:
02502       f = ast_rtcp_read(sub->vrtp); /* RTCP Control Channel for video */
02503       break;
02504 #if 0
02505    case 5:
02506       /* Not yet supported */
02507       f = ast_udptl_read(sub->udptl);  /* UDPTL for T.38 */
02508       break;
02509 #endif
02510    default:
02511       f = &ast_null_frame;
02512    }
02513 
02514    if (ast) {
02515       /* We already hold the channel lock */
02516       if (f->frametype == AST_FRAME_VOICE) {
02517          if (f->subclass != ast->nativeformats) {
02518             ast_log(LOG_DEBUG, "Oooh, format changed to %d\n", f->subclass);
02519             ast->nativeformats = f->subclass;
02520             ast_set_read_format(ast, ast->readformat);
02521             ast_set_write_format(ast, ast->writeformat);
02522          }
02523       }
02524    }
02525    return f;
02526 }

static int skinny_senddigit_begin ( struct ast_channel ast,
char  digit 
) [static]

Definition at line 2578 of file chan_skinny.c.

02579 {
02580    return -1; /* Start inband indications */
02581 }

static int skinny_senddigit_end ( struct ast_channel ast,
char  digit,
unsigned int  duration 
) [static]

Definition at line 2583 of file chan_skinny.c.

References skinny_line::parent, skinny_subchannel::parent, skinny_device::session, skinny_line::sub, ast_channel::tech_pvt, and transmit_tone().

02584 {
02585 #if 0
02586    struct skinny_subchannel *sub = ast->tech_pvt;
02587    struct skinny_line *l = sub->parent;
02588    struct skinny_device *d = l->parent;
02589    int tmp;
02590    /* not right */
02591    sprintf(tmp, "%d", digit);
02592    transmit_tone(d->session, digit);
02593 #endif
02594    return -1; /* Stop inband indications */
02595 }

static void* skinny_session ( void *  data  )  [static]

Definition at line 4244 of file chan_skinny.c.

References ast_inet_ntoa(), ast_log(), ast_verbose(), destroy_session(), get_input(), handle_message(), LOG_NOTICE, option_verbose, skinny_req::res, s, skinny_req_parse(), and VERBOSE_PREFIX_3.

Referenced by accept_thread().

04245 {
04246    int res;
04247    struct skinny_req *req;
04248    struct skinnysession *s = data;
04249 
04250    if (option_verbose > 2)
04251       ast_verbose(VERBOSE_PREFIX_3 "Starting Skinny session from %s\n", ast_inet_ntoa(s->sin.sin_addr));
04252 
04253    for (;;) {
04254       res = get_input(s);
04255       if (res < 0) {
04256          break;
04257       }
04258 
04259       if (res > 0)
04260       {
04261          if (!(req = skinny_req_parse(s))) {
04262             destroy_session(s);
04263             return NULL;
04264          }
04265 
04266          res = handle_message(req, s);
04267          if (res < 0) {
04268             destroy_session(s);
04269             return NULL;
04270          }
04271       }
04272    }
04273    ast_log(LOG_NOTICE, "Skinny Session returned: %s\n", strerror(errno));
04274 
04275    if (s) 
04276       destroy_session(s);
04277    
04278    return 0;
04279 }

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 1751 of file chan_skinny.c.

References ast_channel::tech_pvt.

01752 {
01753    struct skinny_subchannel *sub;
01754    sub = c->tech_pvt;
01755    if (sub) {
01756       /* transmit_modify_with_sdp(sub, rtp); @@FIXME@@ if needed */
01757       return 0;
01758    }
01759    return -1;
01760 }

static int skinny_show_devices ( int  fd,
int  argc,
char *  argv[] 
) [static]

Definition at line 1912 of file chan_skinny.c.

References ast_cli(), ast_inet_ntoa(), ast_mutex_lock(), device2str(), devices, skinny_device::id, skinny_device::lines, skinny_device::name, skinny_line::next, skinny_device::next, skinny_device::registered, RESULT_SHOWUSAGE, skinny_device::session, skinnysession::sin, and skinny_device::type.

01913 {
01914    struct skinny_device *d;
01915    struct skinny_line *l;
01916    int numlines = 0;
01917 
01918    if (argc != 3) {
01919       return RESULT_SHOWUSAGE;
01920    }
01921    ast_mutex_lock(&devicelock);
01922 
01923    ast_cli(fd, "Name                 DeviceId         IP              Type            R NL\n");
01924    ast_cli(fd, "-------------------- ---------------- --------------- --------------- - --\n");
01925    for (d = devices; d; d = d->next) {
01926       numlines = 0;
01927       for (l = d->lines; l; l = l->next) {
01928          numlines++;
01929       }
01930 
01931       ast_cli(fd, "%-20s %-16s %-15s %-15s %c %2d\n",
01932             d->name,
01933             d->id,
01934             d->session?ast_inet_ntoa(d->session->sin.sin_addr):"",
01935             device2str(d->type),
01936             d->registered?'Y':'N',
01937             numlines);
01938    }
01939    ast_mutex_unlock(&devicelock);
01940    return RESULT_SUCCESS;
01941 }

static int skinny_show_lines ( int  fd,
int  argc,
char *  argv[] 
) [static]

Definition at line 1943 of file chan_skinny.c.

References ast_cli(), ast_mutex_lock(), devices, skinny_line::instance, skinny_line::label, skinny_device::lines, skinny_line::name, skinny_device::name, skinny_line::next, skinny_device::next, and RESULT_SHOWUSAGE.

01944 {
01945    struct skinny_device *d;
01946    struct skinny_line *l;
01947 
01948    if (argc != 3) {
01949       return RESULT_SHOWUSAGE;
01950    }
01951    ast_mutex_lock(&devicelock);
01952 
01953    ast_cli(fd, "Device Name          Instance Name                 Label               \n");
01954    ast_cli(fd, "-------------------- -------- -------------------- --------------------\n");
01955    for (d = devices; d; d = d->next) {
01956       for (l = d->lines; l; l = l->next) {
01957          ast_cli(fd, "%-20s %8d %-20s %-20s\n",
01958             d->name,
01959             l->instance,
01960             l->name,
01961             l->label);
01962       }
01963    }
01964 
01965    ast_mutex_unlock(&devicelock);
01966    return RESULT_SUCCESS;
01967 }

static void* skinny_ss ( void *  data  )  [static]

Definition at line 2266 of file chan_skinny.c.

References 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_strlen_zero(), ast_verbose(), ast_waitfordigit(), skinny_line::call_forward, ast_channel::cid, ast_callerid::cid_num, skinny_line::cid_num, ast_channel::context, ast_channel::exten, exten, firstdigittimeout, gendigittimeout, skinny_line::lastnumberdialed, len, LOG_DEBUG, LOG_WARNING, matchdigittimeout, skinny_device::name, skinny_line::name, option_verbose, skinny_line::parent, skinny_subchannel::parent, s, skinny_device::session, SKINNY_DIALTONE, skinny_newcall(), SKINNY_REORDER, SKINNY_SILENCE, skinnydebug, skinny_line::sub, ast_channel::tech_pvt, timeout, transmit_tone(), and VERBOSE_PREFIX_3.

Referenced by handle_offhook_message(), handle_soft_key_event_message(), and handle_stimulus_message().

02267 {
02268    struct ast_channel *c = data;
02269    struct skinny_subchannel *sub = c->tech_pvt;
02270    struct skinny_line *l = sub->parent;
02271    struct skinny_device *d = l->parent;
02272    struct skinnysession *s = d->session;
02273    char exten[AST_MAX_EXTENSION] = "";
02274    int len = 0;
02275    int timeout = firstdigittimeout;
02276    int res;
02277    int getforward=0;
02278 
02279    if (option_verbose > 2)
02280       ast_verbose( VERBOSE_PREFIX_3 "Starting simple switch on '%s@%s'\n", l->name, d->name);
02281 
02282    while (len < AST_MAX_EXTENSION-1) {
02283       res = ast_waitfordigit(c, timeout);
02284       timeout = 0;
02285       if (res < 0) {
02286          if (skinnydebug)
02287             ast_verbose("Skinny(%s@%s): waitfordigit returned < 0\n", l->name, d->name);
02288          ast_indicate(c, -1);
02289          ast_hangup(c);
02290          return NULL;
02291       } else if (res) {
02292          exten[len++]=res;
02293          exten[len] = '\0';
02294       }
02295       if (!ast_ignore_pattern(c->context, exten)) {
02296          transmit_tone(s, SKINNY_SILENCE);
02297       }
02298       if (ast_exists_extension(c, c->context, exten, 1, l->cid_num)) {
02299          if (!res || !ast_matchmore_extension(c, c->context, exten, 1, l->cid_num)) {
02300             if (getforward) {
02301                /* Record this as the forwarding extension */
02302                ast_copy_string(l->call_forward, exten, sizeof(l->call_forward));
02303                if (option_verbose > 2)
02304                   ast_verbose(VERBOSE_PREFIX_3 "Setting call forward to '%s' on channel %s\n",
02305                      l->call_forward, c->name);
02306                transmit_tone(s, SKINNY_DIALTONE);
02307                if (res) {
02308                   break;
02309                }
02310                ast_safe_sleep(c, 500);
02311                ast_indicate(c, -1);
02312                ast_safe_sleep(c, 1000);
02313                memset(exten, 0, sizeof(exten));
02314                transmit_tone(s, SKINNY_DIALTONE);
02315                len = 0;
02316                getforward = 0;
02317             } else {
02318                ast_copy_string(c->exten, exten, sizeof(c->exten));
02319                ast_copy_string(l->lastnumberdialed, exten, sizeof(l->lastnumberdialed));
02320                skinny_newcall(c);
02321                return NULL;
02322             }
02323          } else {
02324             /* It's a match, but they just typed a digit, and there is an ambiguous match,
02325                so just set the timeout to matchdigittimeout and wait some more */
02326             timeout = matchdigittimeout;
02327          }
02328       } else if (res == 0) {
02329          ast_log(LOG_DEBUG, "Not enough digits (and no ambiguous match)...\n");
02330          transmit_tone(s, SKINNY_REORDER);
02331          ast_hangup(c);
02332          return NULL;
02333       } else if (!ast_canmatch_extension(c, c->context, exten, 1, c->cid.cid_num) &&
02334             ((exten[0] != '*') || (!ast_strlen_zero(exten) > 2))) {
02335          ast_log(LOG_WARNING, "Can't match [%s] from '%s' in context %s\n", exten, c->cid.cid_num ? c->cid.cid_num : "<Unknown Caller>", c->context);
02336          transmit_tone(s, SKINNY_REORDER);
02337          /* hang out for 3 seconds to let congestion play */
02338          ast_safe_sleep(c, 3000);
02339          break;
02340       }
02341       if (!timeout) {
02342          timeout = gendigittimeout;
02343       }
02344       if (len && !ast_ignore_pattern(c->context, exten)) {
02345          ast_indicate(c, -1);
02346       }
02347    }
02348    ast_hangup(c);
02349    return NULL;
02350 }

static int skinny_unhold ( struct skinny_subchannel sub  )  [static]

Definition at line 2841 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, skinnydebug, STIMULUS_LINE, skinny_line::sub, transmit_connect(), transmit_lamp_indication(), and transmit_response().

Referenced by handle_soft_key_event_message(), and handle_stimulus_message().

02842 {
02843    struct skinny_line *l = sub->parent;
02844    struct skinny_device *d = l->parent;
02845    struct skinnysession *s = d->session;
02846    struct skinny_req *req;
02847 
02848    /* Channel is on hold, so we will unhold */
02849    if (skinnydebug)
02850       ast_verbose("Taking off Hold(%d)\n", l->instance);
02851 
02852    ast_queue_control(sub->owner, AST_CONTROL_UNHOLD);
02853 
02854    if (!(req = req_alloc(sizeof(struct activate_call_plane_message), ACTIVATE_CALL_PLANE_MESSAGE)))
02855       return 0;
02856 
02857    req->data.activatecallplane.lineInstance = htolel(l->instance);
02858    transmit_response(s, req);
02859 
02860    transmit_connect(s, sub);
02861    transmit_lamp_indication(s, STIMULUS_LINE, l->instance, SKINNY_LAMP_ON);
02862    sub->onhold = 0;
02863    return 1;
02864 }

static int skinny_unregister ( struct skinny_req req,
struct skinnysession s 
) [static]

Definition at line 1379 of file chan_skinny.c.

References skinny_device::registered, s, and skinny_device::session.

Referenced by get_input(), handle_unregister_message(), and transmit_response().

01380 {
01381    struct skinny_device *d;
01382 
01383    d = s->device;
01384 
01385    if (d) {
01386       d->session = NULL;
01387       d->registered = 0;
01388    }
01389 
01390    return -1; /* main loop will destroy the session */
01391 }

static int skinny_write ( struct ast_channel ast,
struct ast_frame frame 
) [static]

Definition at line 2538 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.

02539 {
02540    struct skinny_subchannel *sub = ast->tech_pvt;
02541    int res = 0;
02542    if (frame->frametype != AST_FRAME_VOICE) {
02543       if (frame->frametype == AST_FRAME_IMAGE) {
02544          return 0;
02545       } else {
02546          ast_log(LOG_WARNING, "Can't send %d type frames with skinny_write\n", frame->frametype);
02547          return 0;
02548       }
02549    } else {
02550       if (!(frame->subclass & ast->nativeformats)) {
02551          ast_log(LOG_WARNING, "Asked to transmit frame type %d, while native formats is %d (read/write = %d/%d)\n",
02552             frame->subclass, ast->nativeformats, ast->readformat, ast->writeformat);
02553          return -1;
02554       }
02555    }
02556    if (sub) {
02557       ast_mutex_lock(&sub->lock);
02558       if (sub->rtp) {
02559          res = ast_rtp_write(sub->rtp, frame);
02560       }
02561       ast_mutex_unlock(&sub->lock);
02562    }
02563    return res;
02564 }

static void start_rtp ( struct skinny_subchannel sub  )  [static]

Definition at line 2208 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, io, skinny_subchannel::lock, skinny_line::nat, skinny_subchannel::owner, skinny_line::parent, skinny_subchannel::parent, skinny_line::prefs, skinny_subchannel::rtp, skinny_device::session, skinny_line::sub, transmit_connect(), and skinny_subchannel::vrtp.

02209 {
02210    struct skinny_line *l = sub->parent;
02211    struct skinny_device *d = l->parent;
02212    int hasvideo = 0;
02213 
02214    ast_mutex_lock(&sub->lock);
02215    /* Allocate the RTP */
02216    sub->rtp = ast_rtp_new_with_bindaddr(sched, io, 1, 0, bindaddr.sin_addr);
02217    if (hasvideo)
02218       sub->vrtp = ast_rtp_new_with_bindaddr(sched, io, 1, 0, bindaddr.sin_addr);
02219    
02220    if (sub->rtp && sub->owner) {
02221       sub->owner->fds[0] = ast_rtp_fd(sub->rtp);
02222       sub->owner->fds[1] = ast_rtcp_fd(sub->rtp);
02223    }
02224    if (hasvideo && sub->vrtp && sub->owner) {
02225       sub->owner->fds[2] = ast_rtp_fd(sub->vrtp);
02226       sub->owner->fds[3] = ast_rtcp_fd(sub->vrtp);
02227    }
02228    if (sub->rtp) {
02229       ast_rtp_setnat(sub->rtp, l->nat);
02230    }
02231    if (sub->vrtp) {
02232       ast_rtp_setnat(sub->vrtp, l->nat);
02233    }
02234    /* Set Frame packetization */
02235    if (sub->rtp)
02236       ast_rtp_codec_setpref(sub->rtp, &l->prefs);
02237 
02238    /* Create the RTP connection */
02239    transmit_connect(d->session, sub);
02240    ast_mutex_unlock(&sub->lock);
02241 }

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 1497 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, htolel, call_info_message::instance, call_info_message::reference, req_alloc(), s, skinnydebug, transmit_response(), and call_info_message::type.

Referenced by skinny_answer(), skinny_call(), and skinny_indicate().

01498 {
01499    struct skinny_req *req;
01500 
01501    if (!(req = req_alloc(sizeof(struct call_info_message), CALL_INFO_MESSAGE)))
01502       return;
01503 
01504    if (skinnydebug)
01505          ast_verbose("Setting Callinfo to %s(%s) from %s(%s) on %s(%d)\n", fromname, fromnum, toname, tonum, s->device->name, instance);
01506 
01507    if (fromname) {
01508       ast_copy_string(req->data.callinfo.callingPartyName, fromname, sizeof(req->data.callinfo.callingPartyName));
01509    }
01510    if (fromnum) {
01511       ast_copy_string(req->data.callinfo.callingParty, fromnum, sizeof(req->data.callinfo.callingParty));
01512    }
01513    if (toname) {
01514       ast_copy_string(req->data.callinfo.calledPartyName, toname, sizeof(req->data.callinfo.calledPartyName));
01515    }
01516    if (tonum) {
01517       ast_copy_string(req->data.callinfo.calledParty, tonum, sizeof(req->data.callinfo.calledParty));
01518    }
01519    req->data.callinfo.instance = htolel(instance);
01520    req->data.callinfo.reference = htolel(callid);
01521    req->data.callinfo.type = htolel(calltype);
01522    transmit_response(s, req);
01523 }

static void transmit_callstate ( struct skinnysession s,
int  instance,
int  state,
unsigned  callid 
) [static]

Definition at line 1454 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, activate_call_plane_message::lineInstance, call_state_message::lineInstance, close_receive_channel_message::partyId, stop_media_transmission_message::passThruPartyId, req_alloc(), s, SKINNY_OFFHOOK, SKINNY_ONHOOK, SKINNY_SPEAKEROFF, STOP_MEDIA_TRANSMISSION_MESSAGE, skinny_data::stopmedia, transmit_response(), and transmit_speaker_mode().

Referenced by handle_offhook_message(), handle_onhook_message(), handle_soft_key_event_message(), handle_stimulus_message(), skinny_answer(), skinny_call(), skinny_hangup(), and skinny_indicate().

01455 {
01456    struct skinny_req *req;
01457 
01458    if (!(req = req_alloc(sizeof(struct call_state_message), CALL_STATE_MESSAGE)))
01459       return;
01460 
01461    if (state == SKINNY_ONHOOK) {
01462       transmit_speaker_mode(s, SKINNY_SPEAKEROFF);
01463    }
01464    req->data.callstate.callState = htolel(state);
01465    req->data.callstate.lineInstance = htolel(instance);
01466    req->data.callstate.callReference = htolel(callid);
01467    transmit_response(s, req);
01468    if (state == SKINNY_OFFHOOK) {
01469       if (!(req = req_alloc(sizeof(struct activate_call_plane_message), ACTIVATE_CALL_PLANE_MESSAGE)))
01470          return;
01471 
01472       req->data.activatecallplane.lineInstance = htolel(instance);
01473       transmit_response(s, req);
01474    } else if (state == SKINNY_ONHOOK) {
01475       if (!(req = req_alloc(sizeof(struct activate_call_plane_message), ACTIVATE_CALL_PLANE_MESSAGE)))
01476          return;
01477 
01478       req->data.activatecallplane.lineInstance = htolel(instance);
01479       transmit_response(s, req);
01480 
01481       if (!(req = req_alloc(sizeof(struct close_receive_channel_message), CLOSE_RECEIVE_CHANNEL_MESSAGE)))
01482          return;
01483 
01484       req->data.closereceivechannel.conferenceId = 0;
01485       req->data.closereceivechannel.partyId = htolel(callid);
01486       transmit_response(s, req);
01487 
01488       if (!(req = req_alloc(sizeof(struct stop_media_transmission_message), STOP_MEDIA_TRANSMISSION_MESSAGE)))
01489          return;
01490 
01491       req->data.stopmedia.conferenceId = 0;
01492       req->data.stopmedia.passThruPartyId = htolel(callid);
01493       transmit_response(s, req);
01494    }
01495 }

static void transmit_connect ( struct skinnysession s,
struct skinny_subchannel sub 
) [static]

Definition at line 1525 of file chan_skinny.c.

References ast_best_codec(), ast_codec_pref_getsize(), open_receive_channel_message::bitrate, skinny_subchannel::callid, open_receive_channel_message::capability, skinny_line::capability, codec_ast2skinny(), open_receive_channel_message::conferenceId, skinny_req::data, open_receive_channel_message::echo, fmt, 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(), s, skinny_line::sub, and transmit_response().

Referenced by skinny_unhold(), and start_rtp().

01526 {
01527    struct skinny_req *req;
01528    struct skinny_line *l = sub->parent;
01529    struct ast_format_list fmt;
01530 
01531    if (!(req = req_alloc(sizeof(struct open_receive_channel_message), OPEN_RECEIVE_CHANNEL_MESSAGE)))
01532       return;
01533 
01534    fmt = ast_codec_pref_getsize(&l->prefs, ast_best_codec(l->capability));
01535 
01536    req->data.openreceivechannel.conferenceId = htolel(0);
01537    req->data.openreceivechannel.partyId = htolel(sub->callid);
01538    req->data.openreceivechannel.packets = htolel(fmt.cur_ms);
01539    req->data.openreceivechannel.capability = htolel(codec_ast2skinny(fmt.bits));
01540    req->data.openreceivechannel.echo = htolel(0);
01541    req->data.openreceivechannel.bitrate = htolel(0);
01542    transmit_response(s, req);
01543 }

static void transmit_dialednumber ( struct skinnysession s,
const char *  text,
int  instance,
int  callid 
) [static]

Definition at line 1676 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(), s, and transmit_response().

Referenced by skinny_indicate().

01677 {
01678    struct skinny_req *req;
01679 
01680    if (!(req = req_alloc(sizeof(struct dialed_number_message), DIALED_NUMBER_MESSAGE)))
01681       return;
01682 
01683    ast_copy_string(req->data.dialednumber.dialedNumber, text, sizeof(req->data.dialednumber.dialedNumber));
01684    req->data.dialednumber.lineInstance = htolel(instance);
01685    req->data.dialednumber.callReference = htolel(callid);
01686 
01687    transmit_response(s, req);
01688 }

static void transmit_displaymessage ( struct skinnysession s,
const char *  text 
) [static]

Definition at line 1620 of file chan_skinny.c.

References ast_verbose(), CLEAR_DISPLAY_MESSAGE, skinny_req::data, skinny_data::displaytext, DISPLAYTEXT_MESSAGE, req_alloc(), s, skinnydebug, displaytext_message::text, and transmit_response().

Referenced by do_housekeeping(), handle_offhook_message(), handle_soft_key_event_message(), and handle_stimulus_message().

01621 {
01622    struct skinny_req *req;
01623 
01624    if (text == 0) {
01625       if (!(req = req_alloc(0, CLEAR_DISPLAY_MESSAGE)))
01626          return;
01627 
01628       if (skinnydebug)
01629          ast_verbose("Clearing Display\n");
01630    } else {
01631       if (!(req = req_alloc(sizeof(struct displaytext_message), DISPLAYTEXT_MESSAGE)))
01632          return;
01633 
01634       ast_copy_string(req->data.displaytext.text, text, sizeof(req->data.displaytext.text));
01635       if (skinnydebug)
01636          ast_verbose("Displaying message '%s'\n", req->data.displaytext.text);
01637    }
01638 
01639    transmit_response(s, req);
01640 }

static void transmit_displaynotify ( struct skinnysession s,
const char *  text,
int  t 
) [static]

Definition at line 1642 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(), s, skinnydebug, and transmit_response().

Referenced by handle_soft_key_event_message(), and handle_stimulus_message().

01643 {
01644    struct skinny_req *req;
01645 
01646    if (!(req = req_alloc(sizeof(struct display_notify_message), DISPLAY_NOTIFY_MESSAGE)))
01647       return;
01648 
01649    ast_copy_string(req->data.displaynotify.displayMessage, text, sizeof(req->data.displaynotify.displayMessage));
01650    req->data.displaynotify.displayTimeout = htolel(t);
01651 
01652    if (skinnydebug)
01653       ast_verbose("Displaying notify '%s'\n", text);
01654 
01655    transmit_response(s, req);
01656 }

static void transmit_displaypromptstatus ( struct skinnysession s,
const char *  text,
int  t,
int  instance,
int  callid 
) [static]

Definition at line 1658 of file chan_skinny.c.

References ast_verbose(), display_prompt_status_message::callReference, skinny_req::data, DISPLAY_PROMPT_STATUS_MESSAGE, skinny_data::displaypromptstatus, htolel, display_prompt_status_message::lineInstance, display_prompt_status_message::messageTimeout, display_prompt_status_message::promptMessage, req_alloc(), s, skinnydebug, and transmit_response().

Referenced by handle_stimulus_message(), skinny_answer(), skinny_call(), and skinny_indicate().

01659 {
01660    struct skinny_req *req;
01661 
01662    if (!(req = req_alloc(sizeof(struct display_prompt_status_message), DISPLAY_PROMPT_STATUS_MESSAGE)))
01663       return;
01664 
01665    ast_copy_string(req->data.displaypromptstatus.promptMessage, text, sizeof(req->data.displaypromptstatus.promptMessage));
01666    req->data.displaypromptstatus.messageTimeout = htolel(t);
01667    req->data.displaypromptstatus.lineInstance = htolel(instance);
01668    req->data.displaypromptstatus.callReference = htolel(callid);
01669 
01670    if (skinnydebug)
01671       ast_verbose("Displaying Prompt Status '%s'\n", text);
01672 
01673    transmit_response(s, req);
01674 }

static void transmit_lamp_indication ( struct skinnysession s,
int  stimulus,
int  instance,
int  indication 
) [static]

Definition at line 1582 of file chan_skinny.c.

References skinny_req::data, set_lamp_message::deviceStimulus, htolel, req_alloc(), s, 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().

01583 {
01584    struct skinny_req *req;
01585 
01586    if (!(req = req_alloc(sizeof(struct set_lamp_message), SET_LAMP_MESSAGE)))
01587       return;
01588 
01589    req->data.setlamp.stimulus = htolel(stimulus);
01590    req->data.setlamp.stimulusInstance = htolel(instance);
01591    req->data.setlamp.deviceStimulus = htolel(indication);
01592    transmit_response(s, req);
01593 }

static int transmit_response ( struct skinnysession s,
struct skinny_req req 
) [static]

Definition at line 1393 of file chan_skinny.c.

References ast_log(), ast_mutex_lock(), ast_mutex_unlock(), skinny_req::data, skinny_req::e, skinny_req::len, letohl, LOG_VERBOSE, LOG_WARNING, s, skinny_header_size, SKINNY_MAX_PACKET, skinny_unregister(), and skinnydebug.

01394 {
01395    int res = 0;
01396 
01397    if (!s) {
01398       ast_log(LOG_WARNING, "Asked to transmit to a non-existant session!\n");
01399       return -1;
01400    }
01401 
01402    ast_mutex_lock(&s->lock);
01403 
01404    if (skinnydebug)
01405       ast_log(LOG_VERBOSE, "writing packet type %04X (%d bytes) to socket %d\n", letohl(req->e), letohl(req->len)+8, s->fd);
01406 
01407    if (letohl(req->len > SKINNY_MAX_PACKET) || letohl(req->len < 0)) {
01408       ast_log(LOG_WARNING, "transmit_response: the length of the request is out of bounds\n");
01409       return -1;
01410    }
01411 
01412    memset(s->outbuf,0,sizeof(s->outbuf));
01413    memcpy(s->outbuf, req, skinny_header_size);
01414    memcpy(s->outbuf+skinny_header_size, &req->data, letohl(req->len));
01415 
01416    res = write(s->fd, s->outbuf, letohl(req->len)+8);
01417 
01418    if (res != letohl(req->len)+8) {
01419       ast_log(LOG_WARNING, "Transmit: write only sent %d out of %d bytes: %s\n", res, letohl(req->len)+8, strerror(errno));
01420       if (res == -1) {
01421          if (skinnydebug)
01422             ast_log(LOG_WARNING, "Transmit: Skinny Client was lost, unregistering\n");
01423          skinny_unregister(NULL, s);
01424       }
01425       
01426    }
01427    
01428    ast_mutex_unlock(&s->lock);
01429    return 1;
01430 }

static void transmit_ringer_mode ( struct skinnysession s,
int  mode 
) [static]

Definition at line 1595 of file chan_skinny.c.

References ast_verbose(), skinny_req::data, htolel, req_alloc(), set_ringer_message::ringerMode, s, SET_RINGER_MESSAGE, skinny_data::setringer, skinnydebug, 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().

01596 {
01597    struct skinny_req *req;
01598 
01599    if (skinnydebug)
01600       ast_verbose("Setting ringer mode to '%d'.\n", mode);
01601 
01602    if (!(req = req_alloc(sizeof(struct set_ringer_message), SET_RINGER_MESSAGE)))
01603       return;
01604 
01605    req->data.setringer.ringerMode = htolel(mode);
01606    /* XXX okay, I don't quite know what this is, but here's what happens (on a 7960).
01607       Note: The phone will always show as ringing on the display.
01608 
01609       1: phone will audibly ring over and over
01610       2: phone will audibly ring only once
01611       any other value, will NOT cause the phone to audibly ring
01612    */
01613    req->data.setringer.unknown1 = htolel(1);
01614    /* XXX the value here doesn't seem to change anything.  Must be higher than 0.
01615       Perhaps a packet capture can shed some light on this. */
01616    req->data.setringer.unknown2 = htolel(1);
01617    transmit_response(s, req);
01618 }

static void transmit_selectsoftkeys ( struct skinnysession s,
int  instance,
int  callid,
int  softkey 
) [static]

Definition at line 1568 of file chan_skinny.c.

References skinny_req::data, htolel, select_soft_keys_message::instance, select_soft_keys_message::reference, req_alloc(), s, 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(), and skinny_call().

01569 {
01570    struct skinny_req *req;
01571 
01572    if (!(req = req_alloc(sizeof(struct select_soft_keys_message), SELECT_SOFT_KEYS_MESSAGE)))
01573       return;
01574 
01575    req->data.selectsoftkey.instance = htolel(instance);
01576    req->data.selectsoftkey.reference = htolel(callid);
01577    req->data.selectsoftkey.softKeySetIndex = htolel(softkey);
01578    req->data.selectsoftkey.validKeyMask = htolel(0xFFFFFFFF);
01579    transmit_response(s, req);
01580 }

static void transmit_speaker_mode ( struct skinnysession s,
int  mode 
) [static]

Definition at line 1432 of file chan_skinny.c.

References skinny_req::data, htolel, set_speaker_message::mode, req_alloc(), s, SET_SPEAKER_MESSAGE, skinny_data::setspeaker, and transmit_response().

Referenced by handle_stimulus_message(), skinny_hangup(), and transmit_callstate().

01433 {
01434    struct skinny_req *req;
01435 
01436    if (!(req = req_alloc(sizeof(struct set_speaker_message), SET_SPEAKER_MESSAGE)))
01437       return;
01438 
01439    req->data.setspeaker.mode = htolel(mode);
01440    transmit_response(s, req);
01441 }

static void transmit_tone ( struct skinnysession s,
int  tone 
) [static]

Definition at line 1545 of file chan_skinny.c.

References skinny_req::data, htolel, req_alloc(), s, SKINNY_NOTONE, START_TONE_MESSAGE, skinny_data::starttone, STOP_TONE_MESSAGE, start_tone_message::tone, and transmit_response().

Referenced by 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().

01546 {
01547    struct skinny_req *req;
01548 
01549    if (tone == SKINNY_NOTONE) {
01550       /* This is bad, mmm'kay? */
01551       return;
01552    }
01553 
01554    if (tone > 0) {
01555       if (!(req = req_alloc(sizeof(struct start_tone_message), START_TONE_MESSAGE)))
01556          return;
01557    } else {
01558       if (!(req = req_alloc(0, STOP_TONE_MESSAGE)))
01559          return;
01560    }
01561 
01562    if (tone > 0) {
01563       req->data.starttone.tone = htolel(tone);
01564    }
01565    transmit_response(s, req);
01566 }

static int unload_module ( void   )  [static]

Definition at line 4656 of file chan_skinny.c.

References accept_t, skinny_subchannel::alreadygone, ast_channel_unregister(), ast_cli_unregister_multiple(), ast_mutex_destroy(), ast_mutex_lock(), ast_mutex_unlock(), AST_PTHREADT_STOP, ast_rtp_proto_unregister(), ast_softhangup(), AST_SOFTHANGUP_APPUNLOAD, cli_skinny, delete_devices(), skinnysession::device, skinnysession::fd, free, skinny_device::lines, skinnysession::lock, skinny_subchannel::lock, skinny_line::lock, monitor_thread, skinny_subchannel::next, skinny_line::next, skinny_device::next, skinny_subchannel::owner, s, sched_context_destroy(), sessions, skinny_rtp, skinny_tech, skinnysock, and skinny_line::sub.

04657 {
04658    struct skinnysession *s, *slast;
04659    struct skinny_device *d;
04660    struct skinny_line *l;
04661    struct skinny_subchannel *sub;
04662 
04663    ast_mutex_lock(&sessionlock);
04664    /* Destroy all the interfaces and free their memory */
04665    s = sessions;
04666    while(s) {
04667       slast = s;
04668       s = s->next;
04669       for (d = slast->device; d; d = d->next) {
04670          for (l = d->lines; l; l = l->next) {
04671             ast_mutex_lock(&l->lock);
04672             for (sub = l->sub; sub; sub = sub->next) {
04673                ast_mutex_lock(&sub->lock);
04674                if (sub->owner) {
04675                   sub->alreadygone = 1;
04676                   ast_softhangup(sub->owner, AST_SOFTHANGUP_APPUNLOAD);
04677                }
04678                ast_mutex_unlock(&sub->lock);
04679             }
04680             ast_mutex_unlock(&l->lock);
04681          }
04682       }
04683       if (slast->fd > -1)
04684          close(slast->fd);
04685       ast_mutex_destroy(&slast->lock);
04686       free(slast);
04687    }
04688    sessions = NULL;
04689    ast_mutex_unlock(&sessionlock);
04690 
04691    delete_devices();
04692 
04693    ast_mutex_lock(&monlock);
04694    if (monitor_thread && (monitor_thread != AST_PTHREADT_STOP)) {
04695       pthread_cancel(monitor_thread);
04696       pthread_kill(monitor_thread, SIGURG);
04697       pthread_join(monitor_thread, NULL);
04698    }
04699    monitor_thread = AST_PTHREADT_STOP;
04700    ast_mutex_unlock(&monlock);
04701 
04702    ast_mutex_lock(&netlock);
04703    if (accept_t && (accept_t != AST_PTHREADT_STOP)) {
04704       pthread_cancel(accept_t);
04705       pthread_kill(accept_t, SIGURG);
04706       pthread_join(accept_t, NULL);
04707    }
04708    accept_t = AST_PTHREADT_STOP;
04709    ast_mutex_unlock(&netlock);
04710 
04711    ast_rtp_proto_unregister(&skinny_rtp);
04712    ast_channel_unregister(&skinny_tech);
04713    ast_cli_unregister_multiple(cli_skinny, sizeof(cli_skinny) / sizeof(struct ast_cli_entry));
04714 
04715    close(skinnysock);
04716    sched_context_destroy(sched);
04717 
04718    return 0;
04719 }


Variable Documentation

struct in_addr __ourip [static]

Definition at line 756 of file chan_skinny.c.

pthread_t accept_t [static]

Definition at line 760 of file chan_skinny.c.

Referenced by reload_config(), and unload_module().

char accountcode[AST_MAX_ACCOUNT_CODE] = "" [static]

Definition at line 780 of file chan_skinny.c.

struct ast_hostent ahp

Definition at line 757 of file chan_skinny.c.

Referenced by __ast_http_load(), ast_dnsmgr_lookup(), ast_find_ourip(), ast_get_ip_or_srv(), ast_sip_ouraddrfor(), check_via(), create_addr(), dnsmgr_refresh(), festival_exec(), gtalk_load_config(), gtalk_update_stun(), 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_destination(), sip_devicestate(), sip_do_debug_ip(), and udptl_do_debug_ip().

int amaflags = 0 [static]

Definition at line 782 of file chan_skinny.c.

struct sockaddr_in bindaddr [static]

Definition at line 753 of file chan_skinny.c.

int callnums = 1 [static]

Definition at line 783 of file chan_skinny.c.

Referenced by skinny_new().

int callreturn = 0 [static]

Definition at line 773 of file chan_skinny.c.

int callwaiting = 0 [static]

Definition at line 772 of file chan_skinny.c.

int cancallforward = 0 [static]

Definition at line 778 of file chan_skinny.c.

char cid_name[AST_MAX_EXTENSION] = "" [static]

Definition at line 766 of file chan_skinny.c.

char cid_num[AST_MAX_EXTENSION] = "" [static]

Definition at line 765 of file chan_skinny.c.

struct ast_cli_entry cli_skinny[] [static]

Definition at line 1989 of file chan_skinny.c.

Referenced by load_module(), and unload_module().

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 761 of file chan_skinny.c.

ast_group_t cur_callergroup = 0 [static]

Definition at line 769 of file chan_skinny.c.

ast_group_t cur_pickupgroup = 0 [static]

Definition at line 770 of file chan_skinny.c.

char date_format[6] = "D-M-Y" [static]

Definition at line 101 of file chan_skinny.c.

Referenced by handle_register_message(), and reload_config().

char debug_usage[] [static]

Initial value:

"Usage: skinny set debug\n"
"       Enables dumping of Skinny packets for debugging purposes\n"

Definition at line 1977 of file chan_skinny.c.

int default_capability = AST_FORMAT_ULAW | AST_FORMAT_ALAW [static]

Definition at line 83 of file chan_skinny.c.

Referenced by build_device(), reload_config(), and skinny_new().

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]

Referenced by complete_skinny_reset(), delete_devices(), find_line_by_name(), reload_config(), skinny_register(), skinny_reset_device(), skinny_show_devices(), and skinny_show_lines().

int firstdigittimeout = 16000 [static]

Definition at line 898 of file chan_skinny.c.

int gendigittimeout = 8000 [static]

Definition at line 901 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 758 of file chan_skinny.c.

Referenced by __ast_http_load(), ast_dnsmgr_lookup(), ast_find_ourip(), ast_get_ip_or_srv(), ast_gethostbyname(), ast_sip_ouraddrfor(), build_peer(), check_via(), connect_sphinx(), 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 771 of file chan_skinny.c.

struct io_context* io [static]

Definition at line 877 of file chan_skinny.c.

int keep_alive = 120 [static]

Definition at line 100 of file chan_skinny.c.

Referenced by handle_register_message(), and reload_config().

char language[MAX_LANGUAGE] = "" [static]

Definition at line 762 of file chan_skinny.c.

char linelabel[AST_MAX_EXTENSION] = "" [static]

Definition at line 767 of file chan_skinny.c.

Referenced by build_device().

char mailbox[AST_MAX_EXTENSION] [static]

Definition at line 781 of file chan_skinny.c.

int matchdigittimeout = 3000 [static]

Definition at line 904 of file chan_skinny.c.

char mohinterpret[MAX_MUSICCLASS] = "default" [static]

Definition at line 763 of file chan_skinny.c.

char mohsuggest[MAX_MUSICCLASS] = "" [static]

Definition at line 764 of file chan_skinny.c.

pthread_t monitor_thread = AST_PTHREADT_NULL [static]

Definition at line 895 of file chan_skinny.c.

int mwiblink = 0 [static]

Definition at line 775 of file chan_skinny.c.

Referenced by build_device().

int nat = 0 [static]

Definition at line 768 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 1981 of file chan_skinny.c.

char ourhost[256] [static]

Definition at line 754 of file chan_skinny.c.

int ourport [static]

Definition at line 755 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 1985 of file chan_skinny.c.

struct sched_context* sched [static]

Definition at line 876 of file chan_skinny.c.

struct skinnysession * sessions [static]

Referenced by accept_thread(), astman_verify_session_readpermissions(), astman_verify_session_writepermissions(), destroy_session(), find_session(), handle_showmanconn(), handle_showmaneventq(), manager_event(), 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 1969 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 1973 of file chan_skinny.c.

int skinny_header_size = 12

Definition at line 744 of file chan_skinny.c.

Referenced by skinny_req_parse(), and transmit_response().

struct ast_rtp_protocol skinny_rtp [static]

Definition at line 1762 of file chan_skinny.c.

Referenced by load_module(), and unload_module().

struct ast_channel_tech skinny_tech [static]

Definition at line 1041 of file chan_skinny.c.

Referenced by load_module(), skinny_new(), and unload_module().

int skinnydebug = 0 [static]

Definition at line 750 of file chan_skinny.c.

Referenced by accept_thread(), get_input(), handle_alarm_message(), handle_capabilities_res_message(), handle_keypad_button_message(), handle_message(), handle_offhook_message(), handle_onhook_message(), handle_open_receive_channel_ack_message(), handle_register_message(), handle_soft_key_event_message(), handle_stimulus_message(), skinny_answer(), skinny_call(), skinny_do_debug(), skinny_hangup(), skinny_hold(), skinny_indicate(), skinny_new(), skinny_no_debug(), skinny_ss(), skinny_unhold(), transmit_callinfo(), transmit_displaymessage(), transmit_displaynotify(), transmit_displaypromptstatus(), transmit_response(), and transmit_ringer_mode().

int skinnysock = -1 [static]

Definition at line 759 of file chan_skinny.c.

Referenced by accept_thread(), reload_config(), and unload_module().

const uint8_t soft_key_default_connected[] [static]

Definition at line 550 of file chan_skinny.c.

const uint8_t soft_key_default_connwithconf[] [static]

Initial value:

Definition at line 594 of file chan_skinny.c.

const uint8_t soft_key_default_connwithtrans[] [static]

Definition at line 580 of file chan_skinny.c.

const uint8_t soft_key_default_dadfd[] [static]

Initial value:

Definition at line 589 of file chan_skinny.c.

struct soft_key_definitions soft_key_default_definitions[] [static]

Definition at line 614 of file chan_skinny.c.

Referenced by handle_soft_key_set_req_message().

const uint8_t soft_key_default_offhook[] [static]

Definition at line 572 of file chan_skinny.c.

const uint8_t soft_key_default_offhookwithfeat[] [static]

Initial value:

Definition at line 605 of file chan_skinny.c.

const uint8_t soft_key_default_onhold[] [static]

Definition at line 559 of file chan_skinny.c.

const uint8_t soft_key_default_onhook[] [static]

Definition at line 542 of file chan_skinny.c.

const uint8_t soft_key_default_ringin[] [static]

Initial value:

Definition at line 566 of file chan_skinny.c.

const uint8_t soft_key_default_ringout[] [static]

Definition at line 598 of file chan_skinny.c.

const uint8_t soft_key_default_unknown[] [static]

Initial value:

Definition at line 610 of file chan_skinny.c.

struct soft_key_template_definition soft_key_template_default[]

Definition at line 515 of file chan_skinny.c.

Referenced by handle_soft_key_set_req_message(), handle_soft_key_template_req_message(), and load_module().

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 774 of file chan_skinny.c.

int transfer = 0 [static]

Definition at line 777 of file chan_skinny.c.

char version_id[16] = "P002F202" [static]

Definition at line 102 of file chan_skinny.c.

Referenced by skinny_register().


Generated on Mon May 14 04:46:27 2007 for Asterisk - the Open Source PBX by  doxygen 1.5.1