Asterisk - The Open Source Telephony Project  GIT-master-a24979a
Data Structures | Macros | Enumerations | Functions | Variables
chan_unistim.c File Reference

chan_unistim channel driver for Asterisk More...

#include "asterisk.h"
#include <sys/stat.h>
#include <signal.h>
#include "asterisk/paths.h"
#include "asterisk/network.h"
#include "asterisk/channel.h"
#include "asterisk/config.h"
#include "asterisk/module.h"
#include "asterisk/pbx.h"
#include "asterisk/rtp_engine.h"
#include "asterisk/unaligned.h"
#include "asterisk/netsock2.h"
#include "asterisk/acl.h"
#include "asterisk/callerid.h"
#include "asterisk/cli.h"
#include "asterisk/app.h"
#include "asterisk/mwi.h"
#include "asterisk/musiconhold.h"
#include "asterisk/causes.h"
#include "asterisk/indications.h"
#include "asterisk/pickup.h"
#include "asterisk/astobj2.h"
#include "asterisk/astdb.h"
#include "asterisk/features_config.h"
#include "asterisk/bridge.h"
#include "asterisk/stasis_channels.h"
#include "asterisk/format_cache.h"
Include dependency graph for chan_unistim.c:

Go to the source code of this file.

Data Structures

struct  unistim_device
 A device containing one or more lines. More...
 
struct  unistim_languages
 
struct  unistim_line
 
struct  unistim_menu_item
 
struct  unistim_subchannel
 
struct  unistimsession
 
struct  ustm_lang_entry
 
struct  wsabuf
 

Macros

#define AST_CONFIG_MAX_PATH   255
 
#define BUFFSEND   unsigned char buffsend[64] = { 0x00, 0x00, 0xaa, 0xbb, 0x02, 0x01 }
 
#define DEBUG_TIMER   dummy
 
#define DEFAULT_CODEC   0x00
 
#define DEFAULT_INTERDIGIT_TIMER   4000
 
#define DEFAULTCALLERID   "Unknown"
 
#define DEFAULTCALLERNAME   " "
 
#define DEFAULTCONTEXT   "default"
 
#define DEFAULTHEIGHT   3
 
#define DEVICE_NAME_LEN   16
 
#define EXPNUM   24
 
#define FAV_BLINK_FAST   0x20
 
#define FAV_BLINK_SLOW   0x40
 
#define FAV_ICON_BOX   0x3F
 
#define FAV_ICON_CALL_CENTER   0x34
 
#define FAV_ICON_CITY   0x31
 
#define FAV_ICON_COMPUTER   0x38
 
#define FAV_ICON_FAX   0x35
 
#define FAV_ICON_FORWARD   0x39
 
#define FAV_ICON_HEADPHONES   0x2E
 
#define FAV_ICON_HEADPHONES_ONHOLD   0x2F
 
#define FAV_ICON_HOME   0x30
 
#define FAV_ICON_INBOX   0x3C
 
#define FAV_ICON_LOCKED   0x3A
 
#define FAV_ICON_MAILBOX   0x36
 
#define FAV_ICON_MEETING   0x3E
 
#define FAV_ICON_NONE   0x00
 
#define FAV_ICON_OFFHOOK_BLACK   0x24
 
#define FAV_ICON_OFFHOOK_WHITE   0x25
 
#define FAV_ICON_ONHOLD_BLACK   0x26
 
#define FAV_ICON_ONHOLD_WHITE   0x27
 
#define FAV_ICON_ONHOOK_BLACK   0x20
 
#define FAV_ICON_ONHOOK_WHITE   0x21
 
#define FAV_ICON_OUTBOX   0x3D
 
#define FAV_ICON_PAGER   0x33
 
#define FAV_ICON_PHONE_BLACK   0x2A
 
#define FAV_ICON_PHONE_WHITE   0x2B
 
#define FAV_ICON_REFLECT   0x37
 
#define FAV_ICON_SHARP   0x32
 
#define FAV_ICON_SPEAKER_OFFHOOK_BLACK   0x28
 
#define FAV_ICON_SPEAKER_OFFHOOK_WHITE   0x29
 
#define FAV_ICON_SPEAKER_ONHOLD_BLACK   0x2C
 
#define FAV_ICON_SPEAKER_ONHOLD_WHITE   0x2D
 
#define FAV_ICON_SPEAKER_ONHOOK_BLACK   0x22
 
#define FAV_ICON_SPEAKER_ONHOOK_WHITE   0x23
 
#define FAV_ICON_TRASH   0x3B
 
#define FAV_LINE_ICON   FAV_ICON_ONHOOK_BLACK
 
#define FAV_MAX_LENGTH   0x0A
 
#define FAVNUM   6
 
#define IDLE_WAIT   1000
 
#define LED_BAR_OFF   0x00 /* bar off */
 
#define LED_BAR_ON   0x01 /* bar on */
 
#define LED_BAR_P2   0x02 /* bar 1s on/1s */
 
#define LED_BAR_P3   0x03 /* bar 2.5s on/0.5s off */
 
#define LED_BAR_P4   0x04 /* bar 0.6s on/0.3s off */
 
#define LED_BAR_P5   0x05 /* bar 0.5s on/0.5s off */
 
#define LED_BAR_P6   0x06 /* bar 2s on/0.5s off */
 
#define LED_BAR_P7   0x07 /* bar off */
 
#define LED_HEADPHONE_OFF   0x010
 
#define LED_HEADPHONE_ON   0x011
 
#define LED_MUTE_BLINK   0x1A
 
#define LED_MUTE_OFF   0x018
 
#define LED_MUTE_ON   0x019
 
#define LED_SPEAKER_OFF   0x08
 
#define LED_SPEAKER_ON   0x09
 
#define MAX_BUF_NUMBER   150
 
#define MAX_BUF_SIZE   64
 
#define MAX_ENTRY_LOG   30
 
#define MAX_SCREEN_NUMBER   15
 
#define MONTH_LABEL_SIZE   3
 
#define MUTE_OFF   0x00
 
#define MUTE_ON   0xFF
 
#define MUTE_ON_DISCRET   0xCE
 
#define NB_MAX_RETRANSMIT   8
 
#define OUTPUT_HANDSET   0xC0
 
#define OUTPUT_HEADPHONE   0xC1
 
#define OUTPUT_SPEAKER   0xC2
 
#define RETRANSMIT_TIMER   2000
 
#define SELECTCODEC_MAX_LENGTH   2
 
#define SELECTCODEC_MSG   "Codec number : .."
 
#define SELECTCODEC_START_ENTRY_POS   15
 
#define SELECTEXTENSION_MAX_LENGTH   10
 
#define SELECTEXTENSION_MSG   ".........."
 
#define SELECTEXTENSION_START_ENTRY_POS   0
 
#define SIZE_HEADER   6
 
#define SIZE_MAC_ADDR   17
 
#define SIZE_PAGE   4096
 
#define STATUS_LENGTH_MAX   28
 
#define SUB_REAL   0
 
#define SUB_RING   1
 
#define SUB_THREEWAY   2
 
#define TEXT_INVERSE   0x25
 
#define TEXT_LENGTH_MAX   24
 
#define TEXT_LINE0   0x00
 
#define TEXT_LINE1   0x20
 
#define TEXT_LINE2   0x40
 
#define TEXT_NORMAL   0x05
 
#define TIMER_MWI   5000
 
#define USTM_LANG_DIR   "unistimLang"
 
#define USTM_LOG_DIR   "unistimHistory"
 
#define VOLUME_INSANELY_LOUD   0x07
 
#define VOLUME_LOW   0x01
 
#define VOLUME_LOW_SPEAKER   0x03
 
#define VOLUME_NORMAL   0x02
 

Enumerations

enum  autoprov_extn { EXTENSION_NONE = 0 , EXTENSION_ASK , EXTENSION_LINE , EXTENSION_TN }
 
enum  autoprovision { AUTOPROVISIONING_NO = 0 , AUTOPROVISIONING_YES , AUTOPROVISIONING_TN }
 
enum  charset {
  LANG_DEFAULT , ISO_8859_1 , ISO_8859_2 , ISO_8859_4 ,
  ISO_8859_5 , ISO_2022_JP
}
 
enum  handset_state { STATE_ONHOOK , STATE_OFFHOOK }
 
enum  phone_key {
  KEY_0 = 0x40 , KEY_1 = 0x41 , KEY_2 = 0x42 , KEY_3 = 0x43 ,
  KEY_4 = 0x44 , KEY_5 = 0x45 , KEY_6 = 0x46 , KEY_7 = 0x47 ,
  KEY_8 = 0x48 , KEY_9 = 0x49 , KEY_STAR = 0x4a , KEY_SHARP = 0x4b ,
  KEY_UP = 0x4c , KEY_DOWN = 0x4d , KEY_RIGHT = 0x4e , KEY_LEFT = 0x4f ,
  KEY_QUIT = 0x50 , KEY_COPY = 0x51 , KEY_FUNC1 = 0x54 , KEY_FUNC2 = 0x55 ,
  KEY_FUNC3 = 0x56 , KEY_FUNC4 = 0x57 , KEY_ONHOLD = 0x5b , KEY_HANGUP = 0x5c ,
  KEY_MUTE = 0x5d , KEY_HEADPHN = 0x5e , KEY_LOUDSPK = 0x5f , KEY_FAV0 = 0x60 ,
  KEY_FAV1 = 0x61 , KEY_FAV2 = 0x62 , KEY_FAV3 = 0x63 , KEY_FAV4 = 0x64 ,
  KEY_FAV5 = 0x65 , KEY_COMPUTR = 0x7b , KEY_CONF = 0x7c , KEY_SNDHIST = 0x7d ,
  KEY_RCVHIST = 0x7e , KEY_INDEX = 0x7f
}
 
enum  phone_state {
  STATE_INIT , STATE_AUTHDENY , STATE_MAINPAGE , STATE_EXTENSION ,
  STATE_DIALPAGE , STATE_RINGING , STATE_CALL , STATE_SELECTOPTION ,
  STATE_SELECTCODEC , STATE_SELECTLANGUAGE , STATE_CLEANING , STATE_HISTORY
}
 

Functions

static void __reg_module (void)
 
static void __unreg_module (void)
 
struct ast_moduleAST_MODULE_SELF_SYM (void)
 
static int attempt_transfer (struct unistim_subchannel *p1, struct unistim_subchannel *p2)
 
static struct unistim_devicebuild_device (const char *cat, const struct ast_variable *v)
 
static void change_callerid (struct unistimsession *pte, int type, char *callerid)
 
static void change_favorite_icon (struct unistimsession *pte, unsigned char status)
 
static struct unistimsessionchannel_to_session (struct ast_channel *ast)
 
static void check_send_queue (struct unistimsession *pte)
 
static void close_call (struct unistimsession *pte)
 
static void close_client (struct unistimsession *s)
 
static char * control2str (int ind)
 
static struct unistimsessioncreate_client (const struct sockaddr_in *addr_from)
 
static void delete_device (struct unistim_device *d)
 
static void discard_call (struct unistimsession *pte)
 
static void display_last_error (const char *sz_msg)
 
static void * do_monitor (void *data)
 
static void dummy (char *unused,...)
 
static int find_language (const char *)
 
static struct unistim_linefind_line_by_number (struct unistim_device *d, const char *val)
 
static int find_rtp_port (struct unistim_subchannel *s)
 
static struct unistim_subchannelfind_subchannel_by_name (const char *dest)
 
static void finish_bookmark (void)
 
static int get_active_softkey (struct unistimsession *pte)
 
static int get_avail_softkey (struct unistimsession *pte, const char *name)
 
static struct unistim_subchannelget_sub (struct unistim_device *device, int type)
 
static struct unistim_subchannelget_sub_holding (struct unistim_device *device, int type, int holding)
 
static unsigned int get_tick_count (void)
 
static int get_to_address (int fd, struct sockaddr_in *toAddr)
 
static void handle_call_incoming (struct unistimsession *s)
 
static void handle_call_outgoing (struct unistimsession *s)
 
static void handle_dial_page (struct unistimsession *pte)
 
static void handle_key_fav (struct unistimsession *pte, char keycode)
 
static void handle_select_codec (struct unistimsession *)
 
static void handle_select_language (struct unistimsession *)
 
static void handle_select_option (struct unistimsession *pte)
 
static void ignore_call (struct unistimsession *pte)
 
static void in_band_indication (struct ast_channel *ast, const struct ast_tone_zone *tz, const char *indication)
 
static void init_phone_step2 (struct unistimsession *pte)
 
static int is_key_favorite (struct unistim_device *d, int fav)
 
static int is_key_line (struct unistim_device *d, int fav)
 
static void key_call (struct unistimsession *pte, char keycode)
 
static void key_dial_page (struct unistimsession *pte, char keycode)
 
static void key_favorite (struct unistimsession *, char)
 
static void key_history (struct unistimsession *pte, char keycode)
 
static void key_main_page (struct unistimsession *pte, char keycode)
 
static void key_ringing (struct unistimsession *pte, char keycode)
 
static void key_select_codec (struct unistimsession *pte, char keycode)
 
static void key_select_extension (struct unistimsession *pte, char keycode)
 
static void key_select_language (struct unistimsession *pte, char keycode)
 
static void key_select_option (struct unistimsession *pte, char keycode)
 
static int lang_cmp_fn (void *obj, void *arg, int flags)
 
static int lang_hash_fn (const void *obj, const int flags)
 
static int load_module (void)
 
static void microphone_mute_toggle (struct unistimsession *pte)
 
static char open_history (struct unistimsession *pte, char way, FILE **f)
 
static int parse_bookmark (const char *text, struct unistim_device *d)
 
static void parsing (int size, unsigned char *buf, struct unistimsession *pte, struct sockaddr_in *addr_from)
 
static void process_request (int size, unsigned char *buf, struct unistimsession *pte)
 
static const char * ptestate_tostr (const int type)
 
static void rcv_mac_addr (struct unistimsession *pte, const unsigned char *buf)
 
static void rcv_resume_connection_with_server (struct unistimsession *pte)
 
static void refresh_all_favorite (struct unistimsession *pte)
 
static int register_extension (const struct unistimsession *pte)
 
static int reload (void)
 
static int reload_config (void)
 
static int restart_monitor (void)
 
static void send_blink_cursor (struct unistimsession *pte)
 
static void send_callerid_screen (struct unistimsession *, struct unistim_subchannel *)
 
static void send_charset_update (struct unistimsession *pte, int charset)
 
static void send_client (int size, const unsigned char *data, struct unistimsession *pte)
 
static void send_cursor_pos (struct unistimsession *pte, unsigned char pos)
 
static void send_date_time (struct unistimsession *pte)
 
static void send_date_time2 (struct unistimsession *pte)
 
static void send_date_time3 (struct unistimsession *pte)
 
static void send_dial_tone (struct unistimsession *pte)
 
static int send_dtmf_tone (struct unistimsession *pte, char digit)
 
static void send_end_call (struct unistimsession *pte)
 
static void send_expansion_icon (unsigned char pos, unsigned char status, struct unistimsession *pte)
 
static void send_expansion_next (struct unistimsession *pte)
 
static void send_expansion_short (unsigned char pos, unsigned char status, struct unistimsession *pte)
 
static void send_expansion_text (unsigned char pos, struct unistimsession *pte, const char *text)
 
static void send_favorite (unsigned char pos, unsigned char status, struct unistimsession *pte, const char *text)
 
static void send_favorite_selected (unsigned char status, struct unistimsession *pte)
 
static void send_favorite_short (unsigned char pos, unsigned char status, struct unistimsession *pte)
 
static void send_icon (unsigned char pos, unsigned char status, struct unistimsession *pte)
 
static void send_idle_clock (struct unistimsession *pte)
 
static void send_led_update (struct unistimsession *pte, unsigned char led)
 
static void send_month_labels (struct unistimsession *pte, int month)
 
static void send_mute (struct unistimsession *pte, unsigned char mute)
 
static void send_no_ring (struct unistimsession *pte)
 
static void send_ping (struct unistimsession *pte)
 
static void send_raw_client (int size, const unsigned char *data, struct sockaddr_in *addr_to, const struct sockaddr_in *addr_ourip)
 
static int send_retransmit (struct unistimsession *pte)
 
static void send_ring (struct unistimsession *pte, signed char volume, signed char style)
 
static void send_select_output (struct unistimsession *pte, unsigned char output, unsigned char volume, unsigned char mute)
 
static void send_start_rtp (struct unistim_subchannel *)
 
static void send_start_timer (struct unistimsession *pte)
 
static void send_stop_timer (struct unistimsession *pte)
 
static void send_text (unsigned char pos, unsigned char inverse, struct unistimsession *pte, const char *text)
 
static void send_text_status (struct unistimsession *pte, const char *text)
 
static void send_texttitle (struct unistimsession *pte, const char *text)
 
static void send_tone (struct unistimsession *pte, uint16_t tone1, uint16_t tone2)
 
static void set_ping_timer (struct unistimsession *pte)
 
static void show_entry_history (struct unistimsession *pte, FILE **f)
 
static void show_extension_page (struct unistimsession *pte)
 
static void show_history (struct unistimsession *pte, char way)
 
static void show_main_page (struct unistimsession *pte)
 
static void show_phone_number (struct unistimsession *pte)
 
static int soft_key_visible (struct unistim_device *d, unsigned char num)
 
static void start_rtp (struct unistim_subchannel *sub)
 
static void sub_hold (struct unistimsession *pte, struct unistim_subchannel *sub)
 
static void sub_start_silence (struct unistimsession *pte, struct unistim_subchannel *sub)
 
static void sub_stop_silence (struct unistimsession *pte, struct unistim_subchannel *sub)
 
static void sub_unhold (struct unistimsession *pte, struct unistim_subchannel *sub)
 
static const char * subtype_tostr (const int type)
 
static void swap_subs (struct unistim_subchannel *a, struct unistim_subchannel *b)
 
static void transfer_call_step1 (struct unistimsession *pte)
 
static void transfer_cancel_step2 (struct unistimsession *pte)
 
static struct unistim_subchannelunistim_alloc_sub (struct unistim_device *d, int x)
 
static int unistim_answer (struct ast_channel *ast)
 
static int unistim_call (struct ast_channel *ast, const char *dest, int timeout)
 
static char * unistim_do_debug (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 
static int unistim_do_senddigit (struct unistimsession *pte, char digit)
 
static int unistim_fixup (struct ast_channel *oldchan, struct ast_channel *newchan)
 
static int unistim_free_sub (struct unistim_subchannel *)
 
static enum ast_rtp_glue_result unistim_get_rtp_peer (struct ast_channel *chan, struct ast_rtp_instance **instance)
 
static int unistim_hangup (struct ast_channel *ast)
 
static int unistim_hangup_clean (struct ast_channel *ast, struct unistim_subchannel *sub)
 
static int unistim_indicate (struct ast_channel *ast, int ind, const void *data, size_t datalen)
 
static struct unistim_lineunistim_line_alloc (void)
 
static void unistim_line_copy (struct unistim_line *dst, struct unistim_line *src)
 
static struct unistim_lineunistim_line_destroy (struct unistim_line *l)
 
static struct ast_channelunistim_new (struct unistim_subchannel *sub, int state, const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor)
 
static struct ast_frameunistim_read (struct ast_channel *ast)
 
static int unistim_register (struct unistimsession *s)
 
static char * unistim_reload (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 — unistim_reload: Force reload of module from cli — Runs in the asterisk main thread, so don't do anything useful but setting a flag and waiting for do_monitor to do the job in our thread More...
 
static struct ast_channelunistim_request (const char *type, struct ast_format_cap *cap, const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor, const char *dest, int *cause)
 
static struct ast_frameunistim_rtp_read (const struct ast_channel *ast, const struct unistim_subchannel *sub)
 
static int unistim_send_mwi_to_peer (struct unistim_line *peer, unsigned int tick)
 
static int unistim_senddigit_begin (struct ast_channel *ast, char digit)
 
static int unistim_senddigit_end (struct ast_channel *ast, char digit, unsigned int duration)
 
static int unistim_sendtext (struct ast_channel *ast, const char *text)
 
static void unistim_set_owner (struct unistim_subchannel *sub, struct ast_channel *chan)
 
static int unistim_set_rtp_peer (struct ast_channel *chan, struct ast_rtp_instance *rtp, struct ast_rtp_instance *vrtp, struct ast_rtp_instance *trtp, const struct ast_format_cap *codecs, int nat_active)
 
static char * unistim_show_devices (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 
static char * unistim_show_info (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 
static char * unistim_sp (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 
static void * unistim_ss (void *data)
 
static int unistim_unalloc_sub (struct unistim_device *d, struct unistim_subchannel *sub)
 
static int unistim_write (struct ast_channel *ast, struct ast_frame *frame)
 
static int unistimsock_read (int *id, int fd, short events, void *ignore)
 
static int unload_module (void)
 
static void unquote (char *out, const char *src, int maxlen)
 
static int unregister_extension (const struct unistimsession *pte)
 
static const char * ustmtext (const char *str, struct unistimsession *pte)
 
static int write_entry_history (struct unistimsession *pte, FILE *f, char c, char *line1)
 
static int write_history (struct unistimsession *pte, char way, char ismissed)
 

Variables

static struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_DEFAULT , .description = "UNISTIM Protocol (USTM)" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = AST_BUILDOPT_SUM, .support_level = AST_MODULE_SUPPORT_EXTENDED, .load = load_module, .unload = unload_module, .reload = reload, }
 
static const struct ast_module_infoast_module_info = &__mod_info
 
static enum autoprovision autoprovisioning = AUTOPROVISIONING_NO
 
static unsigned char * buff
 
static const char channel_type [] = "USTM"
 
static struct ast_jb_conf default_jbconf
 Global jitterbuffer configuration - by default, jb is disabled. More...
 
static ast_mutex_t devicelock = { PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP , NULL, {1, 0} }
 
static struct unistim_devicedevices = NULL
 
static const float dtmf_col [] = { 1209, 1336, 1477, 1633 }
 
static const int dtmf_row [] = { 697, 770, 852, 941 }
 
struct ast_format_capglobal_cap
 
static struct ast_jb_conf global_jbconf
 
static struct io_contextio
 
static pthread_t monitor_thread = AST_PTHREADT_NULL
 
static ast_mutex_t monlock = { PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP , NULL, {1, 0} }
 
static unsigned char monthlabels []
 
static struct unistim_languages options_languages []
 
static struct unistim_menu_item options_menu []
 
static const unsigned char packet_rcv_discovery []
 
static const unsigned char packet_recv_expansion_pressed_key []
 
static const unsigned char packet_recv_firm_version []
 
static const unsigned char packet_recv_hangup []
 
static const unsigned char packet_recv_it_type []
 
static const unsigned char packet_recv_mac_addr []
 
static const unsigned char packet_recv_pick_up []
 
static const unsigned char packet_recv_pressed_key []
 
static const unsigned char packet_recv_r2 [] = { 0x00, 0x00, 0x00, 0x13, 0x96, 0x03, 0x03 }
 
static const unsigned char packet_recv_resume_connection_with_server []
 
static const unsigned char packet_send_arrow [] = { 0x17, 0x04, 0x04, 0x00 }
 
static const unsigned char packet_send_blink_cursor [] = { 0x17, 0x04, 0x10, 0x86 }
 
static const unsigned char packet_send_call []
 
static const unsigned char packet_send_charset_iso_2022_jp []
 
static const unsigned char packet_send_charset_iso_8859_1 []
 
static const unsigned char packet_send_charset_iso_8859_2 []
 
static const unsigned char packet_send_charset_iso_8859_4 []
 
static const unsigned char packet_send_charset_iso_8859_5 []
 
static const unsigned char packet_send_Contrast []
 
static const unsigned char packet_send_date_time []
 
static const unsigned char packet_send_date_time2 []
 
static const unsigned char packet_send_date_time3 []
 
static const unsigned char packet_send_discovery_ack []
 
static const unsigned char packet_send_end_call []
 
static const unsigned char packet_send_expansion_icon [] = { 0x09, 0x06, 0x59, 0x05, 0x47, 0x20 }
 
static const unsigned char packet_send_expansion_next [] = { 0x09, 0x03, 0x17 }
 
static const unsigned char packet_send_expansion_text []
 
static const unsigned char packet_send_favorite []
 
static const unsigned char packet_send_icon [] = { 0x17, 0x05, 0x14, 0x00, 0x25 }
 
static const unsigned char packet_send_jitter_buffer_conf []
 
static const unsigned char packet_send_led_update [] = { 0x19, 0x04, 0x00, 0x00 }
 
static unsigned char packet_send_monthlabels_download []
 
static const unsigned char packet_send_mute [] = { 0x16, 0x05, 0x04, 0x00, 0x00 }
 
static const unsigned char packet_send_no_ring []
 
static const unsigned char packet_send_open_audio_stream_rx []
 
static const unsigned char packet_send_open_audio_stream_rx3 []
 
static const unsigned char packet_send_open_audio_stream_tx []
 
static const unsigned char packet_send_open_audio_stream_tx3 []
 
static unsigned char packet_send_ping []
 
static const unsigned char packet_send_query_basic_manager_04 [] = { 0x1a, 0x04, 0x01, 0x04 }
 
static const unsigned char packet_send_query_basic_manager_10 [] = { 0x1a, 0x04, 0x01, 0x10 }
 
static const unsigned char packet_send_query_mac_address [] = { 0x1a, 0x04, 0x01, 0x08 }
 
static const unsigned char packet_send_ring []
 
static const unsigned char packet_send_rtp_packet_size []
 
static const unsigned char packet_send_S1 [] = { 0x1a, 0x07, 0x07, 0x00, 0x00, 0x00, 0x13 }
 
static const unsigned char packet_send_s4 []
 
static const unsigned char packet_send_S7 [] = { 0x17, 0x06, 0x0f, 0x30, 0x07, 0x07 }
 
static const unsigned char packet_send_s9 []
 
static const unsigned char packet_send_select_output []
 
static const unsigned char packet_send_set_pos_cursor []
 
static const unsigned char packet_send_start_timer []
 
static const unsigned char packet_send_status []
 
static const unsigned char packet_send_status2 []
 
static const unsigned char packet_send_stop_timer [] = { 0x17, 0x05, 0x0b, 0x02, 0x00 }
 
static const unsigned char packet_send_stream_based_tone_dual_freq []
 
static const unsigned char packet_send_stream_based_tone_off []
 
static const unsigned char packet_send_stream_based_tone_on []
 
static const unsigned char packet_send_stream_based_tone_single_freq []
 
static const unsigned char packet_send_text []
 
static const unsigned char packet_send_title []
 
static struct sockaddr_in public_ip = { 0, }
 
struct {
   unsigned int   cos
 
   unsigned int   cos_audio
 
   unsigned int   tos
 
   unsigned int   tos_audio
 
qos = { 0, 0, 0, 0 }
 
static struct ast_sched_contextsched
 
static ast_mutex_t sessionlock = { PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP , NULL, {1, 0} }
 
static struct unistimsessionsessions = NULL
 
static const char tdesc [] = "UNISTIM Channel Driver"
 
static struct ast_cli_entry unistim_cli []
 
static int unistim_keepalive
 
static int unistim_port
 
static ast_mutex_t unistim_reload_lock = { PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP , NULL, {1, 0} }
 
static int unistim_reloading = 0
 
static struct ast_rtp_glue unistim_rtp_glue
 
static struct ast_channel_tech unistim_tech
 
static int unistimdebug = 0
 
static int unistimsock = -1
 
static char ustm_strcopy [1024]
 

Detailed Description

chan_unistim channel driver for Asterisk

Author
Cedric Hans cedri.nosp@m.c.ha.nosp@m.ns@ml.nosp@m.kj.n.nosp@m.et

Unistim (Unified Networks IP Stimulus) channel driver for Nortel i2002, i2004 and i2050

Definition in file chan_unistim.c.

Macro Definition Documentation

◆ AST_CONFIG_MAX_PATH

#define AST_CONFIG_MAX_PATH   255

Definition at line 113 of file chan_unistim.c.

◆ BUFFSEND

#define BUFFSEND   unsigned char buffsend[64] = { 0x00, 0x00, 0xaa, 0xbb, 0x02, 0x01 }

Definition at line 704 of file chan_unistim.c.

◆ DEBUG_TIMER

#define DEBUG_TIMER   dummy

Definition at line 241 of file chan_unistim.c.

◆ DEFAULT_CODEC

#define DEFAULT_CODEC   0x00

Not used

Definition at line 110 of file chan_unistim.c.

◆ DEFAULT_INTERDIGIT_TIMER

#define DEFAULT_INTERDIGIT_TIMER   4000

Timeout value for entered number being dialed

Definition at line 107 of file chan_unistim.c.

◆ DEFAULTCALLERID

#define DEFAULTCALLERID   "Unknown"

Definition at line 84 of file chan_unistim.c.

◆ DEFAULTCALLERNAME

#define DEFAULTCALLERNAME   " "

Definition at line 85 of file chan_unistim.c.

◆ DEFAULTCONTEXT

#define DEFAULTCONTEXT   "default"

Definition at line 83 of file chan_unistim.c.

◆ DEFAULTHEIGHT

#define DEFAULTHEIGHT   3

Definition at line 86 of file chan_unistim.c.

◆ DEVICE_NAME_LEN

#define DEVICE_NAME_LEN   16

Definition at line 112 of file chan_unistim.c.

◆ EXPNUM

#define EXPNUM   24

Definition at line 217 of file chan_unistim.c.

◆ FAV_BLINK_FAST

#define FAV_BLINK_FAST   0x20

Definition at line 211 of file chan_unistim.c.

◆ FAV_BLINK_SLOW

#define FAV_BLINK_SLOW   0x40

Definition at line 212 of file chan_unistim.c.

◆ FAV_ICON_BOX

#define FAV_ICON_BOX   0x3F

Definition at line 209 of file chan_unistim.c.

◆ FAV_ICON_CALL_CENTER

#define FAV_ICON_CALL_CENTER   0x34

Definition at line 198 of file chan_unistim.c.

◆ FAV_ICON_CITY

#define FAV_ICON_CITY   0x31

Definition at line 195 of file chan_unistim.c.

◆ FAV_ICON_COMPUTER

#define FAV_ICON_COMPUTER   0x38

Definition at line 202 of file chan_unistim.c.

◆ FAV_ICON_FAX

#define FAV_ICON_FAX   0x35

Definition at line 199 of file chan_unistim.c.

◆ FAV_ICON_FORWARD

#define FAV_ICON_FORWARD   0x39

Definition at line 203 of file chan_unistim.c.

◆ FAV_ICON_HEADPHONES

#define FAV_ICON_HEADPHONES   0x2E

Definition at line 192 of file chan_unistim.c.

◆ FAV_ICON_HEADPHONES_ONHOLD

#define FAV_ICON_HEADPHONES_ONHOLD   0x2F

Definition at line 193 of file chan_unistim.c.

◆ FAV_ICON_HOME

#define FAV_ICON_HOME   0x30

Definition at line 194 of file chan_unistim.c.

◆ FAV_ICON_INBOX

#define FAV_ICON_INBOX   0x3C

Definition at line 206 of file chan_unistim.c.

◆ FAV_ICON_LOCKED

#define FAV_ICON_LOCKED   0x3A

Definition at line 204 of file chan_unistim.c.

◆ FAV_ICON_MAILBOX

#define FAV_ICON_MAILBOX   0x36

Definition at line 200 of file chan_unistim.c.

◆ FAV_ICON_MEETING

#define FAV_ICON_MEETING   0x3E

Definition at line 208 of file chan_unistim.c.

◆ FAV_ICON_NONE

#define FAV_ICON_NONE   0x00

Definition at line 177 of file chan_unistim.c.

◆ FAV_ICON_OFFHOOK_BLACK

#define FAV_ICON_OFFHOOK_BLACK   0x24

Definition at line 182 of file chan_unistim.c.

◆ FAV_ICON_OFFHOOK_WHITE

#define FAV_ICON_OFFHOOK_WHITE   0x25

Definition at line 183 of file chan_unistim.c.

◆ FAV_ICON_ONHOLD_BLACK

#define FAV_ICON_ONHOLD_BLACK   0x26

Definition at line 184 of file chan_unistim.c.

◆ FAV_ICON_ONHOLD_WHITE

#define FAV_ICON_ONHOLD_WHITE   0x27

Definition at line 185 of file chan_unistim.c.

◆ FAV_ICON_ONHOOK_BLACK

#define FAV_ICON_ONHOOK_BLACK   0x20

Definition at line 178 of file chan_unistim.c.

◆ FAV_ICON_ONHOOK_WHITE

#define FAV_ICON_ONHOOK_WHITE   0x21

Definition at line 179 of file chan_unistim.c.

◆ FAV_ICON_OUTBOX

#define FAV_ICON_OUTBOX   0x3D

Definition at line 207 of file chan_unistim.c.

◆ FAV_ICON_PAGER

#define FAV_ICON_PAGER   0x33

Definition at line 197 of file chan_unistim.c.

◆ FAV_ICON_PHONE_BLACK

#define FAV_ICON_PHONE_BLACK   0x2A

Definition at line 188 of file chan_unistim.c.

◆ FAV_ICON_PHONE_WHITE

#define FAV_ICON_PHONE_WHITE   0x2B

Definition at line 189 of file chan_unistim.c.

◆ FAV_ICON_REFLECT

#define FAV_ICON_REFLECT   0x37

Definition at line 201 of file chan_unistim.c.

◆ FAV_ICON_SHARP

#define FAV_ICON_SHARP   0x32

Definition at line 196 of file chan_unistim.c.

◆ FAV_ICON_SPEAKER_OFFHOOK_BLACK

#define FAV_ICON_SPEAKER_OFFHOOK_BLACK   0x28

Definition at line 186 of file chan_unistim.c.

◆ FAV_ICON_SPEAKER_OFFHOOK_WHITE

#define FAV_ICON_SPEAKER_OFFHOOK_WHITE   0x29

Definition at line 187 of file chan_unistim.c.

◆ FAV_ICON_SPEAKER_ONHOLD_BLACK

#define FAV_ICON_SPEAKER_ONHOLD_BLACK   0x2C

Definition at line 190 of file chan_unistim.c.

◆ FAV_ICON_SPEAKER_ONHOLD_WHITE

#define FAV_ICON_SPEAKER_ONHOLD_WHITE   0x2D

Definition at line 191 of file chan_unistim.c.

◆ FAV_ICON_SPEAKER_ONHOOK_BLACK

#define FAV_ICON_SPEAKER_ONHOOK_BLACK   0x22

Definition at line 180 of file chan_unistim.c.

◆ FAV_ICON_SPEAKER_ONHOOK_WHITE

#define FAV_ICON_SPEAKER_ONHOOK_WHITE   0x23

Definition at line 181 of file chan_unistim.c.

◆ FAV_ICON_TRASH

#define FAV_ICON_TRASH   0x3B

Definition at line 205 of file chan_unistim.c.

◆ FAV_LINE_ICON

#define FAV_LINE_ICON   FAV_ICON_ONHOOK_BLACK

Definition at line 218 of file chan_unistim.c.

◆ FAV_MAX_LENGTH

#define FAV_MAX_LENGTH   0x0A

Definition at line 214 of file chan_unistim.c.

◆ FAVNUM

#define FAVNUM   6

Definition at line 216 of file chan_unistim.c.

◆ IDLE_WAIT

#define IDLE_WAIT   1000

Nb of milliseconds waited when no events are scheduled

Definition at line 101 of file chan_unistim.c.

◆ LED_BAR_OFF

#define LED_BAR_OFF   0x00 /* bar off */

Definition at line 151 of file chan_unistim.c.

◆ LED_BAR_ON

#define LED_BAR_ON   0x01 /* bar on */

Definition at line 152 of file chan_unistim.c.

◆ LED_BAR_P2

#define LED_BAR_P2   0x02 /* bar 1s on/1s */

Definition at line 153 of file chan_unistim.c.

◆ LED_BAR_P3

#define LED_BAR_P3   0x03 /* bar 2.5s on/0.5s off */

Definition at line 154 of file chan_unistim.c.

◆ LED_BAR_P4

#define LED_BAR_P4   0x04 /* bar 0.6s on/0.3s off */

Definition at line 155 of file chan_unistim.c.

◆ LED_BAR_P5

#define LED_BAR_P5   0x05 /* bar 0.5s on/0.5s off */

Definition at line 156 of file chan_unistim.c.

◆ LED_BAR_P6

#define LED_BAR_P6   0x06 /* bar 2s on/0.5s off */

Definition at line 157 of file chan_unistim.c.

◆ LED_BAR_P7

#define LED_BAR_P7   0x07 /* bar off */

Definition at line 158 of file chan_unistim.c.

◆ LED_HEADPHONE_OFF

#define LED_HEADPHONE_OFF   0x010

Definition at line 161 of file chan_unistim.c.

◆ LED_HEADPHONE_ON

#define LED_HEADPHONE_ON   0x011

Definition at line 162 of file chan_unistim.c.

◆ LED_MUTE_BLINK

#define LED_MUTE_BLINK   0x1A

Definition at line 165 of file chan_unistim.c.

◆ LED_MUTE_OFF

#define LED_MUTE_OFF   0x018

Definition at line 163 of file chan_unistim.c.

◆ LED_MUTE_ON

#define LED_MUTE_ON   0x019

Definition at line 164 of file chan_unistim.c.

◆ LED_SPEAKER_OFF

#define LED_SPEAKER_OFF   0x08

Definition at line 159 of file chan_unistim.c.

◆ LED_SPEAKER_ON

#define LED_SPEAKER_ON   0x09

Definition at line 160 of file chan_unistim.c.

◆ MAX_BUF_NUMBER

#define MAX_BUF_NUMBER   150

Number of slots for the transmit queue

Definition at line 93 of file chan_unistim.c.

◆ MAX_BUF_SIZE

#define MAX_BUF_SIZE   64

Size of the transmit buffer

Definition at line 91 of file chan_unistim.c.

◆ MAX_ENTRY_LOG

#define MAX_ENTRY_LOG   30

Definition at line 114 of file chan_unistim.c.

◆ MAX_SCREEN_NUMBER

#define MAX_SCREEN_NUMBER   15

Number of digits displayed on screen

Definition at line 95 of file chan_unistim.c.

◆ MONTH_LABEL_SIZE

#define MONTH_LABEL_SIZE   3

Length of month label size

Definition at line 97 of file chan_unistim.c.

◆ MUTE_OFF

#define MUTE_OFF   0x00

Definition at line 147 of file chan_unistim.c.

◆ MUTE_ON

#define MUTE_ON   0xFF

Definition at line 148 of file chan_unistim.c.

◆ MUTE_ON_DISCRET

#define MUTE_ON_DISCRET   0xCE

Definition at line 149 of file chan_unistim.c.

◆ NB_MAX_RETRANSMIT

#define NB_MAX_RETRANSMIT   8

Try x times before removing the phone

Definition at line 99 of file chan_unistim.c.

◆ OUTPUT_HANDSET

#define OUTPUT_HANDSET   0xC0

Definition at line 138 of file chan_unistim.c.

◆ OUTPUT_HEADPHONE

#define OUTPUT_HEADPHONE   0xC1

Definition at line 139 of file chan_unistim.c.

◆ OUTPUT_SPEAKER

#define OUTPUT_SPEAKER   0xC2

Definition at line 140 of file chan_unistim.c.

◆ RETRANSMIT_TIMER

#define RETRANSMIT_TIMER   2000

Wait x milliseconds before resending a packet

Definition at line 103 of file chan_unistim.c.

◆ SELECTCODEC_MAX_LENGTH

#define SELECTCODEC_MAX_LENGTH   2

Definition at line 3730 of file chan_unistim.c.

◆ SELECTCODEC_MSG

#define SELECTCODEC_MSG   "Codec number : .."

Definition at line 3731 of file chan_unistim.c.

◆ SELECTCODEC_START_ENTRY_POS

#define SELECTCODEC_START_ENTRY_POS   15

Definition at line 3729 of file chan_unistim.c.

◆ SELECTEXTENSION_MAX_LENGTH

#define SELECTEXTENSION_MAX_LENGTH   10

Definition at line 3874 of file chan_unistim.c.

◆ SELECTEXTENSION_MSG

#define SELECTEXTENSION_MSG   ".........."

Definition at line 3875 of file chan_unistim.c.

◆ SELECTEXTENSION_START_ENTRY_POS

#define SELECTEXTENSION_START_ENTRY_POS   0

Definition at line 3873 of file chan_unistim.c.

◆ SIZE_HEADER

#define SIZE_HEADER   6

Definition at line 167 of file chan_unistim.c.

◆ SIZE_MAC_ADDR

#define SIZE_MAC_ADDR   17

Definition at line 168 of file chan_unistim.c.

◆ SIZE_PAGE

#define SIZE_PAGE   4096

Definition at line 111 of file chan_unistim.c.

◆ STATUS_LENGTH_MAX

#define STATUS_LENGTH_MAX   28

Definition at line 175 of file chan_unistim.c.

◆ SUB_REAL

#define SUB_REAL   0

Definition at line 116 of file chan_unistim.c.

◆ SUB_RING

#define SUB_RING   1

Definition at line 117 of file chan_unistim.c.

◆ SUB_THREEWAY

#define SUB_THREEWAY   2

Definition at line 118 of file chan_unistim.c.

◆ TEXT_INVERSE

#define TEXT_INVERSE   0x25

Definition at line 174 of file chan_unistim.c.

◆ TEXT_LENGTH_MAX

#define TEXT_LENGTH_MAX   24

Definition at line 169 of file chan_unistim.c.

◆ TEXT_LINE0

#define TEXT_LINE0   0x00

Definition at line 170 of file chan_unistim.c.

◆ TEXT_LINE1

#define TEXT_LINE1   0x20

Definition at line 171 of file chan_unistim.c.

◆ TEXT_LINE2

#define TEXT_LINE2   0x40

Definition at line 172 of file chan_unistim.c.

◆ TEXT_NORMAL

#define TEXT_NORMAL   0x05

Definition at line 173 of file chan_unistim.c.

◆ TIMER_MWI

#define TIMER_MWI   5000

How often the mailbox is checked for new messages

Definition at line 105 of file chan_unistim.c.

◆ USTM_LANG_DIR

#define USTM_LANG_DIR   "unistimLang"

Definition at line 88 of file chan_unistim.c.

◆ USTM_LOG_DIR

#define USTM_LOG_DIR   "unistimHistory"

Definition at line 87 of file chan_unistim.c.

◆ VOLUME_INSANELY_LOUD

#define VOLUME_INSANELY_LOUD   0x07

Definition at line 145 of file chan_unistim.c.

◆ VOLUME_LOW

#define VOLUME_LOW   0x01

Definition at line 142 of file chan_unistim.c.

◆ VOLUME_LOW_SPEAKER

#define VOLUME_LOW_SPEAKER   0x03

Definition at line 143 of file chan_unistim.c.

◆ VOLUME_NORMAL

#define VOLUME_NORMAL   0x02

Definition at line 144 of file chan_unistim.c.

Enumeration Type Documentation

◆ autoprov_extn

Enumerator
EXTENSION_NONE 

Do not create an extension into the default dialplan

EXTENSION_ASK 

Prompt user for an extension number and register it

EXTENSION_LINE 

Register an extension with the line=> value

EXTENSION_TN 

Used with AUTOPROVISIONING_TN

Definition at line 128 of file chan_unistim.c.

128  {
129  /*! Do not create an extension into the default dialplan */
130  EXTENSION_NONE = 0,
131  /*! Prompt user for an extension number and register it */
133  /*! Register an extension with the line=> value */
135  /*! Used with AUTOPROVISIONING_TN */
137 };
@ EXTENSION_ASK
Definition: chan_unistim.c:132
@ EXTENSION_LINE
Definition: chan_unistim.c:134
@ EXTENSION_TN
Definition: chan_unistim.c:136
@ EXTENSION_NONE
Definition: chan_unistim.c:130

◆ autoprovision

Enumerator
AUTOPROVISIONING_NO 
AUTOPROVISIONING_YES 
AUTOPROVISIONING_TN 

Definition at line 122 of file chan_unistim.c.

122  {
126 };
@ AUTOPROVISIONING_NO
Definition: chan_unistim.c:123
@ AUTOPROVISIONING_TN
Definition: chan_unistim.c:125
@ AUTOPROVISIONING_YES
Definition: chan_unistim.c:124

◆ charset

enum charset
Enumerator
LANG_DEFAULT 
ISO_8859_1 
ISO_8859_2 
ISO_8859_4 
ISO_8859_5 
ISO_2022_JP 

Definition at line 336 of file chan_unistim.c.

336  {
337  LANG_DEFAULT,
338  ISO_8859_1,
339  ISO_8859_2,
340  ISO_8859_4,
341  ISO_8859_5,
342  ISO_2022_JP,
343 };
@ ISO_8859_1
Definition: chan_unistim.c:338
@ ISO_8859_4
Definition: chan_unistim.c:340
@ LANG_DEFAULT
Definition: chan_unistim.c:337
@ ISO_8859_5
Definition: chan_unistim.c:341
@ ISO_2022_JP
Definition: chan_unistim.c:342
@ ISO_8859_2
Definition: chan_unistim.c:339

◆ handset_state

Enumerator
STATE_ONHOOK 
STATE_OFFHOOK 

Definition at line 290 of file chan_unistim.c.

290  {
291  STATE_ONHOOK,
293 };
@ STATE_OFFHOOK
Definition: chan_unistim.c:292
@ STATE_ONHOOK
Definition: chan_unistim.c:291

◆ phone_key

enum phone_key
Enumerator
KEY_0 
KEY_1 
KEY_2 
KEY_3 
KEY_4 
KEY_5 
KEY_6 
KEY_7 
KEY_8 
KEY_9 
KEY_STAR 
KEY_SHARP 
KEY_UP 
KEY_DOWN 
KEY_RIGHT 
KEY_LEFT 
KEY_QUIT 
KEY_COPY 
KEY_FUNC1 
KEY_FUNC2 
KEY_FUNC3 
KEY_FUNC4 
KEY_ONHOLD 
KEY_HANGUP 
KEY_MUTE 
KEY_HEADPHN 
KEY_LOUDSPK 
KEY_FAV0 
KEY_FAV1 
KEY_FAV2 
KEY_FAV3 
KEY_FAV4 
KEY_FAV5 
KEY_COMPUTR 
KEY_CONF 
KEY_SNDHIST 
KEY_RCVHIST 
KEY_INDEX 

Definition at line 295 of file chan_unistim.c.

295  {
296  KEY_0 = 0x40,
297  KEY_1 = 0x41,
298  KEY_2 = 0x42,
299  KEY_3 = 0x43,
300  KEY_4 = 0x44,
301  KEY_5 = 0x45,
302  KEY_6 = 0x46,
303  KEY_7 = 0x47,
304  KEY_8 = 0x48,
305  KEY_9 = 0x49,
306  KEY_STAR = 0x4a,
307  KEY_SHARP = 0x4b,
308  KEY_UP = 0x4c,
309  KEY_DOWN = 0x4d,
310  KEY_RIGHT = 0x4e,
311  KEY_LEFT = 0x4f,
312  KEY_QUIT = 0x50,
313  KEY_COPY = 0x51,
314  KEY_FUNC1 = 0x54,
315  KEY_FUNC2 = 0x55,
316  KEY_FUNC3 = 0x56,
317  KEY_FUNC4 = 0x57,
318  KEY_ONHOLD = 0x5b,
319  KEY_HANGUP = 0x5c,
320  KEY_MUTE = 0x5d,
321  KEY_HEADPHN = 0x5e,
322  KEY_LOUDSPK = 0x5f,
323  KEY_FAV0 = 0x60,
324  KEY_FAV1 = 0x61,
325  KEY_FAV2 = 0x62,
326  KEY_FAV3 = 0x63,
327  KEY_FAV4 = 0x64,
328  KEY_FAV5 = 0x65,
329  KEY_COMPUTR = 0x7b,
330  KEY_CONF = 0x7c,
331  KEY_SNDHIST = 0x7d,
332  KEY_RCVHIST = 0x7e,
333  KEY_INDEX = 0x7f
334 };
@ KEY_INDEX
Definition: chan_unistim.c:333
@ KEY_FAV0
Definition: chan_unistim.c:323
@ KEY_QUIT
Definition: chan_unistim.c:312
@ KEY_UP
Definition: chan_unistim.c:308
@ KEY_HANGUP
Definition: chan_unistim.c:319
@ KEY_2
Definition: chan_unistim.c:298
@ KEY_6
Definition: chan_unistim.c:302
@ KEY_FUNC4
Definition: chan_unistim.c:317
@ KEY_1
Definition: chan_unistim.c:297
@ KEY_RCVHIST
Definition: chan_unistim.c:332
@ KEY_FAV3
Definition: chan_unistim.c:326
@ KEY_COMPUTR
Definition: chan_unistim.c:329
@ KEY_9
Definition: chan_unistim.c:305
@ KEY_LEFT
Definition: chan_unistim.c:311
@ KEY_RIGHT
Definition: chan_unistim.c:310
@ KEY_0
Definition: chan_unistim.c:296
@ KEY_FAV2
Definition: chan_unistim.c:325
@ KEY_FUNC3
Definition: chan_unistim.c:316
@ KEY_SNDHIST
Definition: chan_unistim.c:331
@ KEY_CONF
Definition: chan_unistim.c:330
@ KEY_SHARP
Definition: chan_unistim.c:307
@ KEY_FAV4
Definition: chan_unistim.c:327
@ KEY_DOWN
Definition: chan_unistim.c:309
@ KEY_8
Definition: chan_unistim.c:304
@ KEY_MUTE
Definition: chan_unistim.c:320
@ KEY_COPY
Definition: chan_unistim.c:313
@ KEY_STAR
Definition: chan_unistim.c:306
@ KEY_ONHOLD
Definition: chan_unistim.c:318
@ KEY_LOUDSPK
Definition: chan_unistim.c:322
@ KEY_FAV1
Definition: chan_unistim.c:324
@ KEY_FAV5
Definition: chan_unistim.c:328
@ KEY_HEADPHN
Definition: chan_unistim.c:321
@ KEY_FUNC1
Definition: chan_unistim.c:314
@ KEY_7
Definition: chan_unistim.c:303
@ KEY_4
Definition: chan_unistim.c:300
@ KEY_5
Definition: chan_unistim.c:301
@ KEY_FUNC2
Definition: chan_unistim.c:315
@ KEY_3
Definition: chan_unistim.c:299

◆ phone_state

Enumerator
STATE_INIT 
STATE_AUTHDENY 
STATE_MAINPAGE 
STATE_EXTENSION 
STATE_DIALPAGE 
STATE_RINGING 
STATE_CALL 
STATE_SELECTOPTION 
STATE_SELECTCODEC 
STATE_SELECTLANGUAGE 
STATE_CLEANING 
STATE_HISTORY 

Definition at line 275 of file chan_unistim.c.

275  {
276  STATE_INIT,
282  STATE_CALL,
288 };
@ STATE_EXTENSION
Definition: chan_unistim.c:279
@ STATE_HISTORY
Definition: chan_unistim.c:287
@ STATE_AUTHDENY
Definition: chan_unistim.c:277
@ STATE_SELECTOPTION
Definition: chan_unistim.c:283
@ STATE_CLEANING
Definition: chan_unistim.c:286
@ STATE_CALL
Definition: chan_unistim.c:282
@ STATE_SELECTCODEC
Definition: chan_unistim.c:284
@ STATE_INIT
Definition: chan_unistim.c:276
@ STATE_MAINPAGE
Definition: chan_unistim.c:278
@ STATE_SELECTLANGUAGE
Definition: chan_unistim.c:285
@ STATE_DIALPAGE
Definition: chan_unistim.c:280
@ STATE_RINGING
Definition: chan_unistim.c:281

Function Documentation

◆ __reg_module()

static void __reg_module ( void  )
static

Definition at line 7206 of file chan_unistim.c.

◆ __unreg_module()

static void __unreg_module ( void  )
static

Definition at line 7206 of file chan_unistim.c.

◆ AST_MODULE_SELF_SYM()

struct ast_module* AST_MODULE_SELF_SYM ( void  )

Definition at line 7206 of file chan_unistim.c.

◆ attempt_transfer()

static int attempt_transfer ( struct unistim_subchannel p1,
struct unistim_subchannel p2 
)
static

Definition at line 2440 of file chan_unistim.c.

2441 {
2442  RAII_VAR(struct ast_channel *, chana, NULL, ast_channel_unref);
2443  RAII_VAR(struct ast_channel *, chanb, NULL, ast_channel_unref);
2444 
2445  if (!p1->owner || !p2->owner) {
2446  ast_log(LOG_WARNING, "Transfer attempted without dual ownership?\n");
2447  return -1;
2448  }
2449  chana = ast_channel_ref(p1->owner);
2450  chanb = ast_channel_ref(p2->owner);
2451 
2452  switch (ast_bridge_transfer_attended(chana, chanb)) {
2454  ast_log(LOG_WARNING, "Transfer failed. Invalid bridge setup\n");
2455  break;
2457  ast_log(LOG_WARNING, "Transfer not permitted\n");
2458  break;
2460  ast_log(LOG_WARNING, "Transfer encountered internal error\n");
2461  break;
2463  return 0;
2464  }
2465 
2466  /* Control only reaches this point if transfer has failed */
2469  return -1;
2470 }
#define ast_log
Definition: astobj2.c:42
@ AST_BRIDGE_TRANSFER_NOT_PERMITTED
Definition: bridge.h:1102
@ AST_BRIDGE_TRANSFER_SUCCESS
Definition: bridge.h:1100
@ AST_BRIDGE_TRANSFER_INVALID
Definition: bridge.h:1104
@ AST_BRIDGE_TRANSFER_FAIL
Definition: bridge.h:1106
enum ast_transfer_result ast_bridge_transfer_attended(struct ast_channel *to_transferee, struct ast_channel *to_transfer_target)
Attended transfer.
Definition: bridge.c:4662
@ AST_SOFTHANGUP_DEV
Definition: channel.h:1121
#define ast_channel_ref(c)
Increase channel reference count.
Definition: channel.h:2947
#define ast_channel_unref(c)
Decrease channel reference count.
Definition: channel.h:2958
int ast_softhangup_nolock(struct ast_channel *chan, int cause)
Softly hangup up a channel (no channel lock)
Definition: channel.c:2457
#define LOG_WARNING
#define NULL
Definition: resample.c:96
Main Channel structure associated with a channel.
struct ast_channel * owner
Definition: chan_unistim.c:356
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
Definition: utils.h:936

References ast_bridge_transfer_attended(), AST_BRIDGE_TRANSFER_FAIL, AST_BRIDGE_TRANSFER_INVALID, AST_BRIDGE_TRANSFER_NOT_PERMITTED, AST_BRIDGE_TRANSFER_SUCCESS, ast_channel_ref, ast_channel_unref, ast_log, AST_SOFTHANGUP_DEV, ast_softhangup_nolock(), LOG_WARNING, NULL, unistim_subchannel::owner, and RAII_VAR.

Referenced by close_call().

◆ build_device()

static struct unistim_device* build_device ( const char *  cat,
const struct ast_variable v 
)
static

Definition at line 6501 of file chan_unistim.c.

6502 {
6503  struct unistim_device *d;
6504  struct unistim_line *l = NULL, *lt = NULL;
6505  int create = 1;
6506  int nbsoftkey, dateformat, timeformat, callhistory, sharpdial, linecnt;
6507  char linelabel[AST_MAX_EXTENSION];
6508  signed char ringvolume, ringstyle, cwvolume, cwstyle;
6509 
6510  /* First, we need to know if we already have this name in our list */
6511  /* Get a lock for the device chained list */
6513  d = devices;
6514  while (d) {
6515  if (!strcmp(d->name, cat)) {
6516  /* Yep, we alreay have this one */
6517  if (unistimsock < 0) {
6518  /* It's a dupe */
6519  ast_log(LOG_WARNING, "Duplicate entry found (%s), ignoring.\n", cat);
6521  return NULL;
6522  }
6523  /* we're reloading right now */
6524  create = 0;
6525  break;
6526  }
6527  d = d->next;
6528  }
6530  if (!(lt = ast_calloc(1, sizeof(*lt)))) {
6531  return NULL;
6532  }
6533  if (create) {
6534  if (!(d = ast_calloc(1, sizeof(*d)))) {
6535  return NULL;
6536  }
6537  ast_mutex_init(&d->lock);
6538  ast_copy_string(d->name, cat, sizeof(d->name));
6539 
6540  ast_copy_string(d->context, DEFAULTCONTEXT, sizeof(d->context));
6541  d->contrast = -1;
6542  d->output = OUTPUT_HANDSET;
6543  d->previous_output = OUTPUT_HANDSET;
6544  d->volume = VOLUME_LOW;
6545  d->microphone = MUTE_OFF;
6546  d->height = DEFAULTHEIGHT;
6547  d->selected = -1;
6548  d->interdigit_timer = DEFAULT_INTERDIGIT_TIMER;
6549  } else {
6550  /* Delete existing line information */
6551  AST_LIST_LOCK(&d->lines);
6552  AST_LIST_TRAVERSE_SAFE_BEGIN(&d->lines, l, list){
6555  }
6557  AST_LIST_UNLOCK(&d->lines);
6558 
6559  /* reset bookmarks */
6560  memset(d->softkeylabel, 0, sizeof(d->softkeylabel));
6561  memset(d->softkeynumber, 0, sizeof(d->softkeynumber));
6562  memset(d->softkeyicon, 0, sizeof(d->softkeyicon));
6563  memset(d->softkeydevice, 0, sizeof(d->softkeydevice));
6564  memset(d->ssub, 0, sizeof(d->ssub));
6565  memset(d->sline, 0, sizeof(d->sline));
6566  memset(d->sp, 0, sizeof(d->sp));
6567  }
6568  linelabel[0] = '\0';
6569  dateformat = 1;
6570  timeformat = 1;
6571  ringvolume = 2;
6572  cwvolume = 1;
6573  callhistory = 1;
6574  sharpdial = 0;
6575  ringstyle = 3;
6576  cwstyle = 2;
6577  nbsoftkey = 0;
6578  linecnt = 0;
6579  d->dtmfduration = 0;
6580  while (v) {
6581  if (!strcasecmp(v->name, "rtp_port")) {
6582  d->rtp_port = atoi(v->value);
6583  } else if (!strcasecmp(v->name, "rtp_method")) {
6584  d->rtp_method = atoi(v->value);
6585  } else if (!strcasecmp(v->name, "status_method")) {
6586  d->status_method = atoi(v->value);
6587  } else if (!strcasecmp(v->name, "device")) {
6588  ast_copy_string(d->id, v->value, sizeof(d->id));
6589  } else if (!strcasecmp(v->name, "tn")) {
6590  ast_copy_string(d->extension_number, v->value, sizeof(d->extension_number));
6591  } else if (!strcasecmp(v->name, "permit") || !strcasecmp(v->name, "deny")) {
6592  int acl_error = 0;
6593  d->ha = ast_append_ha(v->name, v->value, d->ha, &acl_error);
6594  if (acl_error) {
6595  ast_log(LOG_ERROR, "Invalid ACL '%s' specified for device '%s' on line %d. Deleting device\n",
6596  v->value, cat, v->lineno);
6597  delete_device(d);
6598  return NULL;
6599  }
6600  } else if (!strcasecmp(v->name, "context")) {
6601  ast_copy_string(d->context, v->value, sizeof(d->context));
6602  } else if (!strcasecmp(v->name, "maintext0")) {
6603  unquote(d->maintext0, v->value, sizeof(d->maintext0) - 1);
6604  } else if (!strcasecmp(v->name, "maintext1")) {
6605  unquote(d->maintext1, v->value, sizeof(d->maintext1) - 1);
6606  } else if (!strcasecmp(v->name, "maintext2")) {
6607  unquote(d->maintext2, v->value, sizeof(d->maintext2) - 1);
6608  } else if (!strcasecmp(v->name, "titledefault")) {
6609  unquote(d->titledefault, v->value, sizeof(d->titledefault) - 1);
6610  } else if (!strcasecmp(v->name, "dateformat")) {
6611  dateformat = atoi(v->value);
6612  } else if (!strcasecmp(v->name, "timeformat")) {
6613  timeformat = atoi(v->value);
6614  } else if (!strcasecmp(v->name, "contrast")) {
6615  d->contrast = atoi(v->value);
6616  if ((d->contrast < 0) || (d->contrast > 15)) {
6617  ast_log(LOG_WARNING, "contrast must be beetween 0 and 15\n");
6618  d->contrast = 8;
6619  }
6620  } else if (!strcasecmp(v->name, "nat")) {
6621  d->nat = ast_true(v->value);
6622  } else if (!strcasecmp(v->name, "hasexp")) {
6623  d->hasexp = ast_true(v->value);
6624  } else if (!strcasecmp(v->name, "ringvolume")) {
6625  ringvolume = atoi(v->value);
6626  } else if (!strcasecmp(v->name, "ringstyle")) {
6627  ringstyle = atoi(v->value);
6628  } else if (!strcasecmp(v->name, "cwvolume")) {
6629  cwvolume = atoi(v->value);
6630  } else if (!strcasecmp(v->name, "cwstyle")) {
6631  cwstyle = atoi(v->value);
6632  } else if (!strcasecmp(v->name, "callhistory")) {
6633  callhistory = atoi(v->value);
6634  } else if (!strcasecmp(v->name, "sharpdial")) {
6635  sharpdial = ast_true(v->value) ? 1 : 0;
6636  } else if (!strcasecmp(v->name, "interdigit_timer")) {
6637  d->interdigit_timer = atoi(v->value);
6638  } else if (!strcasecmp(v->name, "dtmf_duration")) {
6639  d->dtmfduration = atoi(v->value);
6640  if (d->dtmfduration > 150) {
6641  d->dtmfduration = 150;
6642  }
6643  } else if (!strcasecmp(v->name, "callerid")) {
6644  if (!strcasecmp(v->value, "asreceived")) {
6645  lt->cid_num[0] = '\0';
6646  } else {
6647  ast_copy_string(lt->cid_num, v->value, sizeof(lt->cid_num));
6648  }
6649  } else if (!strcasecmp(v->name, "language")) {
6650  ast_copy_string(d->language, v->value, sizeof(d->language));
6651  } else if (!strcasecmp(v->name, "country")) {
6652  ast_copy_string(d->country, v->value, sizeof(d->country));
6653  } else if (!strcasecmp(v->name, "accountcode")) {
6654  ast_copy_string(lt->accountcode, v->value, sizeof(lt->accountcode));
6655  } else if (!strcasecmp(v->name, "amaflags")) {
6656  int y;
6658  if (y < 0) {
6659  ast_log(LOG_WARNING, "Invalid AMA flags: %s at line %d\n", v->value,
6660  v->lineno);
6661  } else {
6662  lt->amaflags = y;
6663  }
6664  } else if (!strcasecmp(v->name, "musiconhold")) {
6665  ast_copy_string(lt->musicclass, v->value, sizeof(lt->musicclass));
6666  } else if (!strcasecmp(v->name, "callgroup")) {
6667  lt->callgroup = ast_get_group(v->value);
6668  } else if (!strcasecmp(v->name, "pickupgroup")) {
6669  lt->pickupgroup = ast_get_group(v->value);
6670  } else if (!strcasecmp(v->name, "mailbox")) {
6671  ast_copy_string(lt->mailbox, v->value, sizeof(lt->mailbox));
6672  } else if (!strcasecmp(v->name, "parkinglot")) {
6673  ast_copy_string(lt->parkinglot, v->value, sizeof(lt->parkinglot));
6674  } else if (!strcasecmp(v->name, "linelabel")) {
6675  unquote(linelabel, v->value, sizeof(linelabel) - 1);
6676  } else if (!strcasecmp(v->name, "extension")) {
6677  if (!strcasecmp(v->value, "none")) {
6678  d->extension = EXTENSION_NONE;
6679  } else if (!strcasecmp(v->value, "ask")) {
6680  d->extension = EXTENSION_ASK;
6681  } else if (!strcasecmp(v->value, "line")) {
6682  d->extension = EXTENSION_LINE;
6683  } else {
6684  ast_log(LOG_WARNING, "Unknown extension option.\n");
6685  }
6686  } else if (!strcasecmp(v->name, "bookmark")) {
6687  if (nbsoftkey > 5) {
6689  "More than 6 softkeys defined. Ignoring new entries.\n");
6690  } else {
6691  if (parse_bookmark(v->value, d)) {
6692  nbsoftkey++;
6693  }
6694  }
6695  } else if (!strcasecmp(v->name, "line")) {
6696  int len = strlen(linelabel);
6697  int create_line = 0;
6698 
6699  l = find_line_by_number(d, v->value);
6700  if (!l) { /* If line still not exists */
6701  if (!(l = unistim_line_alloc())) {
6702  ast_free(d);
6703  ast_free(lt);
6704  return NULL;
6705  }
6706  lt->cap = l->cap;
6707  memcpy(l, lt, sizeof(*l));
6708  ast_mutex_init(&l->lock);
6709  create_line = 1;
6710  }
6711  d->to_delete = 0;
6712 
6713  /* Set softkey info for new line*/
6714  d->sline[nbsoftkey] = l;
6715  d->softkeyicon[nbsoftkey] = FAV_LINE_ICON;
6716  if (!len) { /* label is undefined ? */
6717  ast_copy_string(d->softkeylabel[nbsoftkey], v->value, sizeof(d->softkeylabel[nbsoftkey]));
6718  } else {
6719  int softkeylinepos = 0;
6720  if ((len > 2) && (linelabel[1] == '@')) {
6721  softkeylinepos = linelabel[0];
6722  if ((softkeylinepos >= '0') && (softkeylinepos <= '5')) {
6723  softkeylinepos -= '0';
6724  d->softkeyicon[nbsoftkey] = FAV_ICON_NONE;
6725  } else {
6727  "Invalid position for linelabel : must be between 0 and 5\n");
6728  }
6729  ast_copy_string(d->softkeylabel[softkeylinepos], linelabel + 2,
6730  sizeof(d->softkeylabel[softkeylinepos]));
6731  d->softkeyicon[softkeylinepos] = FAV_LINE_ICON;
6732  } else {
6733  ast_copy_string(d->softkeylabel[nbsoftkey], linelabel,
6734  sizeof(d->softkeylabel[nbsoftkey]));
6735  }
6736  }
6737  nbsoftkey++;
6738 
6739  if (create_line) {
6740  ast_copy_string(l->name, v->value, sizeof(l->name));
6741  snprintf(l->fullname, sizeof(l->fullname), "USTM/%s@%s", l->name, d->name);
6742  if (!ast_strlen_zero(l->mailbox)) {
6743  if (unistimdebug) {
6744  ast_verb(3, "Setting mailbox '%s' on %s@%s\n", l->mailbox, d->name, l->name);
6745  }
6746  }
6748  l->parent = d;
6749  linecnt++;
6750  AST_LIST_LOCK(&d->lines);
6751  AST_LIST_INSERT_TAIL(&d->lines, l, list);
6752  AST_LIST_UNLOCK(&d->lines);
6753  }
6754  } else if (!strcasecmp(v->name, "height")) {
6755  /* Allow the user to lower the expected display lines on the phone
6756  * For example the Nortel i2001 and i2002 only have one ! */
6757  d->height = atoi(v->value);
6758  } else
6759  ast_log(LOG_WARNING, "Don't know keyword '%s' at line %d\n", v->name,
6760  v->lineno);
6761  v = v->next;
6762  }
6763  ast_free(lt);
6764  if (linecnt == 0) {
6765  ast_log(LOG_ERROR, "An Unistim device must have at least one line!\n");
6766  ast_free(d);
6767  return NULL;
6768  }
6769  d->ringvolume = ringvolume;
6770  d->ringstyle = ringstyle;
6771  d->cwvolume = cwvolume;
6772  d->cwstyle = cwstyle;
6773  d->callhistory = callhistory;
6774  d->sharp_dial = sharpdial;
6775  d->tz = ast_get_indication_zone(d->country);
6776  if ((d->tz == NULL) && !ast_strlen_zero(d->country)) {
6777  ast_log(LOG_WARNING, "Country '%s' was not found in indications.conf\n",
6778  d->country);
6779  }
6780  d->datetimeformat = 48 + (dateformat * 4);
6781  d->datetimeformat += timeformat;
6783  (!ast_strlen_zero(d->extension_number))) {
6784  d->extension = EXTENSION_TN;
6785  if (!ast_strlen_zero(d->id)) {
6787  "tn= and device= can't be used together. Ignoring device= entry\n");
6788  }
6789  d->id[0] = 'T'; /* magic : this is a tn entry */
6790  ast_copy_string((d->id) + 1, d->extension_number, sizeof(d->id) - 1);
6791  d->extension_number[0] = '\0';
6792  } else if (ast_strlen_zero(d->id)) {
6793  if (strcmp(d->name, "template")) {
6794  ast_log(LOG_ERROR, "You must specify the mac address with device=\n");
6795  if (d->tz) {
6796  d->tz = ast_tone_zone_unref(d->tz);
6797  }
6798  ast_free(d);
6799  return NULL;
6800  } else {
6801  strcpy(d->id, "000000000000");
6802  }
6803  }
6804  if (!d->rtp_port) {
6805  d->rtp_port = 10000;
6806  }
6807  if (d->contrast == -1) {
6808  d->contrast = 8;
6809  }
6810  if (ast_strlen_zero(d->maintext1)) {
6811  strcpy(d->maintext1, d->name);
6812  }
6813  if (ast_strlen_zero(d->titledefault)) {
6814  struct ast_tm tm = { 0, };
6815  struct timeval cur_time = ast_tvnow();
6816 
6817  if ((ast_localtime(&cur_time, &tm, 0)) == 0 || ast_strlen_zero(tm.tm_zone)) {
6818  ast_log(LOG_WARNING, "Error in ast_localtime()\n");
6819  ast_copy_string(d->titledefault, "UNISTIM for*", 12);
6820  } else {
6821  if (strlen(tm.tm_zone) < 4) {
6822  strcpy(d->titledefault, "TimeZone ");
6823  strcat(d->titledefault, tm.tm_zone);
6824  } else if (strlen(tm.tm_zone) < 9) {
6825  strcpy(d->titledefault, "TZ ");
6826  strcat(d->titledefault, tm.tm_zone);
6827  } else {
6828  ast_copy_string(d->titledefault, tm.tm_zone, 12);
6829  }
6830  }
6831  }
6832  /* Update the chained link if it's a new device */
6833  if (create) {
6835  d->next = devices;
6836  devices = d;
6838  ast_verb(3, "Added device '%s'\n", d->name);
6839  } else {
6840  ast_verb(3, "Device '%s' reloaded\n", d->name);
6841  }
6842  return d;
6843 }
struct ast_ha * ast_append_ha(const char *sense, const char *stuff, struct ast_ha *path, int *error)
Add a new rule to a list of HAs.
Definition: acl.c:713
#define ast_free(a)
Definition: astmm.h:180
#define ast_calloc(num, len)
A wrapper for calloc()
Definition: astmm.h:202
static int unistimsock
Definition: chan_unistim.c:247
static int unistimdebug
Definition: chan_unistim.c:243
static enum autoprovision autoprovisioning
Definition: chan_unistim.c:245
#define VOLUME_LOW
Definition: chan_unistim.c:142
#define MUTE_OFF
Definition: chan_unistim.c:147
static struct unistim_device * devices
static struct unistim_line * find_line_by_number(struct unistim_device *d, const char *val)
static ast_mutex_t devicelock
Definition: chan_unistim.c:273
static void delete_device(struct unistim_device *d)
#define DEFAULTCONTEXT
Definition: chan_unistim.c:83
#define FAV_LINE_ICON
Definition: chan_unistim.c:218
#define OUTPUT_HANDSET
Definition: chan_unistim.c:138
#define DEFAULT_INTERDIGIT_TIMER
Definition: chan_unistim.c:107
static struct unistim_line * unistim_line_alloc(void)
static int parse_bookmark(const char *text, struct unistim_device *d)
static struct unistim_line * unistim_line_destroy(struct unistim_line *l)
struct ast_format_cap * global_cap
Definition: chan_unistim.c:120
#define DEFAULTHEIGHT
Definition: chan_unistim.c:86
#define FAV_ICON_NONE
Definition: chan_unistim.c:177
static void unquote(char *out, const char *src, int maxlen)
enum ama_flags ast_channel_string2amaflag(const char *flag)
Convert a string to a detail record AMA flag.
Definition: channel.c:4395
ast_group_t ast_get_group(const char *s)
Definition: channel.c:7701
#define AST_MAX_EXTENSION
Definition: channel.h:134
@ AST_MEDIA_TYPE_UNKNOWN
Definition: codec.h:31
int ast_format_cap_append_from_cap(struct ast_format_cap *dst, const struct ast_format_cap *src, enum ast_media_type type)
Append the formats of provided type in src to dst.
Definition: format_cap.c:269
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
#define LOG_ERROR
#define ast_verb(level,...)
struct ast_tone_zone * ast_get_indication_zone(const char *country)
locate ast_tone_zone
Definition: indications.c:433
static struct ast_tone_zone * ast_tone_zone_unref(struct ast_tone_zone *tz)
Release a reference to an ast_tone_zone.
Definition: indications.h:205
#define AST_LIST_INSERT_TAIL(head, elm, field)
Appends a list entry to the tail of a list.
Definition: linkedlists.h:731
#define AST_LIST_TRAVERSE_SAFE_END
Closes a safe loop traversal block.
Definition: linkedlists.h:615
#define AST_LIST_LOCK(head)
Locks a list.
Definition: linkedlists.h:40
#define AST_LIST_TRAVERSE_SAFE_BEGIN(head, var, field)
Loops safely over (traverses) the entries in a list.
Definition: linkedlists.h:529
#define AST_LIST_REMOVE_CURRENT(field)
Removes the current entry from a list during a traversal.
Definition: linkedlists.h:557
#define AST_LIST_UNLOCK(head)
Attempts to unlock a list.
Definition: linkedlists.h:140
struct ast_tm * ast_localtime(const struct timeval *timep, struct ast_tm *p_tm, const char *zone)
Timezone-independent version of localtime_r(3).
Definition: localtime.c:1739
#define ast_mutex_init(pmutex)
Definition: lock.h:184
#define ast_mutex_unlock(a)
Definition: lock.h:188
#define ast_mutex_lock(a)
Definition: lock.h:187
static char dateformat[256]
Definition: logger.c:81
int attribute_pure ast_true(const char *val)
Make sure something is true. Determine if a string containing a boolean value is "true"....
Definition: main/utils.c:2097
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition: strings.h:65
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:406
char * tm_zone
Definition: localtime.h:46
struct ast_variable * next
struct test_val * next
const char * name
A device containing one or more lines.
Definition: chan_unistim.c:394
char fullname[101]
Definition: chan_unistim.c:375
char name[80]
Definition: chan_unistim.c:374
struct ast_format_cap * cap
Definition: chan_unistim.c:384
struct unistim_device * parent
Definition: chan_unistim.c:387
struct unistim_line::@146 list
char mailbox[AST_MAX_EXTENSION]
Definition: chan_unistim.c:378
ast_mutex_t lock
Definition: chan_unistim.c:373
static struct test_val d
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
Definition: time.h:157

References ast_append_ha(), ast_calloc, ast_channel_string2amaflag(), ast_copy_string(), ast_format_cap_append_from_cap(), ast_free, ast_get_group(), ast_get_indication_zone(), AST_LIST_INSERT_TAIL, AST_LIST_LOCK, AST_LIST_REMOVE_CURRENT, AST_LIST_TRAVERSE_SAFE_BEGIN, AST_LIST_TRAVERSE_SAFE_END, AST_LIST_UNLOCK, ast_localtime(), ast_log, AST_MAX_EXTENSION, AST_MEDIA_TYPE_UNKNOWN, ast_mutex_init, ast_mutex_lock, ast_mutex_unlock, ast_strlen_zero(), ast_tone_zone_unref(), ast_true(), ast_tvnow(), ast_verb, autoprovisioning, AUTOPROVISIONING_TN, unistim_line::cap, d, dateformat, DEFAULT_INTERDIGIT_TIMER, DEFAULTCONTEXT, DEFAULTHEIGHT, delete_device(), devicelock, devices, EXTENSION_ASK, EXTENSION_LINE, EXTENSION_NONE, EXTENSION_TN, FAV_ICON_NONE, FAV_LINE_ICON, find_line_by_number(), unistim_line::fullname, global_cap, len(), ast_variable::lineno, unistim_line::list, unistim_line::lock, LOG_ERROR, LOG_WARNING, unistim_line::mailbox, MUTE_OFF, unistim_line::name, ast_variable::name, test_val::name, ast_variable::next, test_val::next, NULL, OUTPUT_HANDSET, unistim_line::parent, parse_bookmark(), ast_tm::tm_zone, unistim_line_alloc(), unistim_line_destroy(), unistimdebug, unistimsock, unquote(), ast_variable::value, and VOLUME_LOW.

Referenced by reload_config().

◆ change_callerid()

void change_callerid ( struct unistimsession pte,
int  type,
char *  callerid 
)
static

Definition at line 2472 of file chan_unistim.c.

2473 {
2474  char *data;
2475  int size;
2476 
2477  if (type) {
2478  data = pte->device->lst_cnm;
2479  } else {
2480  data = pte->device->lst_cid;
2481  }
2482 
2483  /* This is very nearly strncpy(), except that the remaining buffer
2484  * is padded with ' ', instead of '\0' */
2485  memset(data, ' ', TEXT_LENGTH_MAX);
2486  size = strlen(callerid);
2487  if (size > TEXT_LENGTH_MAX) {
2488  size = TEXT_LENGTH_MAX;
2489  }
2490  memcpy(data, callerid, size);
2491 }
static const char type[]
Definition: chan_ooh323.c:109
#define TEXT_LENGTH_MAX
Definition: chan_unistim.c:169
char lst_cid[TEXT_LENGTH_MAX]
Definition: chan_unistim.c:436
char lst_cnm[TEXT_LENGTH_MAX]
Definition: chan_unistim.c:437
struct unistim_device * device
Definition: chan_unistim.c:476

References unistimsession::device, unistim_device::lst_cid, unistim_device::lst_cnm, TEXT_LENGTH_MAX, and type.

Referenced by close_call(), and send_callerid_screen().

◆ change_favorite_icon()

static void change_favorite_icon ( struct unistimsession pte,
unsigned char  status 
)
static

Definition at line 1418 of file chan_unistim.c.

1419 {
1420  struct unistim_device *d = devices;
1421  int i;
1422  /* Update the current phone line softkey icon */
1423  if (pte->state != STATE_CLEANING) {
1424  int softkeylinepos = get_active_softkey(pte);
1425  if (softkeylinepos != -1) {
1426  send_favorite_short(softkeylinepos, status, pte);
1427  }
1428  }
1429  /* Notify other phones if we're in their bookmark */
1430  while (d) {
1431  for (i = 0; i < FAVNUM; i++) {
1432  if (d->sp[i] == pte->device) { /* It's us ? */
1433  if (d->softkeyicon[i] != status) { /* Avoid resending the same icon */
1434  d->softkeyicon[i] = status;
1435  if (d->session) {
1436  send_favorite(i, status + 1, d->session, d->softkeylabel[i]);
1437  }
1438  }
1439  }
1440  }
1441  d = d->next;
1442  }
1443 }
jack_status_t status
Definition: app_jack.c:146
static void send_favorite_short(unsigned char pos, unsigned char status, struct unistimsession *pte)
static void send_favorite(unsigned char pos, unsigned char status, struct unistimsession *pte, const char *text)
static int get_active_softkey(struct unistimsession *pte)
#define FAVNUM
Definition: chan_unistim.c:216

References d, unistimsession::device, devices, FAVNUM, get_active_softkey(), test_val::next, send_favorite(), send_favorite_short(), unistimsession::state, STATE_CLEANING, and status.

Referenced by close_client(), handle_dial_page(), send_select_output(), show_main_page(), and unistim_call().

◆ channel_to_session()

static struct unistimsession* channel_to_session ( struct ast_channel ast)
static

Definition at line 4794 of file chan_unistim.c.

4795 {
4796  struct unistim_subchannel *sub;
4797  if (!ast) {
4798  ast_log(LOG_WARNING, "Unistim callback function called with a null channel\n");
4799  return NULL;
4800  }
4801  if (!ast_channel_tech_pvt(ast)) {
4802  ast_log(LOG_WARNING, "Unistim callback function called without a tech_pvt\n");
4803  return NULL;
4804  }
4805  sub = ast_channel_tech_pvt(ast);
4806 
4807  if (!sub->parent) {
4808  ast_log(LOG_WARNING, "Unistim callback function called without a line\n");
4809  return NULL;
4810  }
4811  if (!sub->parent->parent) {
4812  ast_log(LOG_WARNING, "Unistim callback function called without a device\n");
4813  return NULL;
4814  }
4815  ast_mutex_lock(&sub->parent->parent->lock);
4816  if (!sub->parent->parent->session) {
4817  ast_log(LOG_WARNING, "Unistim callback function called without a session\n");
4818  ast_mutex_unlock(&sub->parent->parent->lock);
4819  return NULL;
4820  }
4821  ast_mutex_unlock(&sub->parent->parent->lock);
4822  return sub->parent->parent->session;
4823 }
void * ast_channel_tech_pvt(const struct ast_channel *chan)
struct stasis_forward * sub
Definition: res_corosync.c:240

References ast_channel_tech_pvt(), ast_log, ast_mutex_lock, ast_mutex_unlock, LOG_WARNING, NULL, and sub.

Referenced by unistim_answer(), unistim_call(), unistim_hangup(), unistim_indicate(), unistim_senddigit_begin(), unistim_senddigit_end(), and unistim_sendtext().

◆ check_send_queue()

static void check_send_queue ( struct unistimsession pte)
static

Definition at line 1101 of file chan_unistim.c.

1102 {
1103  /* Check if our send queue contained only one element */
1104  if (pte->last_buf_available == 1) {
1105  if (unistimdebug) {
1106  ast_verb(0, "Our single packet was ACKed.\n");
1107  }
1108  pte->last_buf_available--;
1109  set_ping_timer(pte);
1110  return;
1111  }
1112  /* Check if this ACK catch up our latest packet */
1113  else if (pte->last_seq_ack + 1 == pte->seq_server + 1) {
1114  if (unistimdebug) {
1115  ast_verb(0, "Our send queue is completely ACKed.\n");
1116  }
1117  pte->last_buf_available = 0; /* Purge the send queue */
1118  set_ping_timer(pte);
1119  return;
1120  }
1121  if (unistimdebug) {
1122  ast_verb(0, "We still have packets in our send queue\n");
1123  }
1124  return;
1125 }
static void set_ping_timer(struct unistimsession *pte)
unsigned short seq_server
Definition: chan_unistim.c:464
unsigned short last_seq_ack
Definition: chan_unistim.c:465

References ast_verb, unistimsession::last_buf_available, unistimsession::last_seq_ack, unistimsession::seq_server, set_ping_timer(), and unistimdebug.

Referenced by parsing().

◆ close_call()

static void close_call ( struct unistimsession pte)
static

Definition at line 2599 of file chan_unistim.c.

2600 {
2601  struct unistim_subchannel *sub, *sub_transf;
2602 
2603  sub = get_sub(pte->device, SUB_REAL);
2604  sub_transf = get_sub(pte->device, SUB_THREEWAY);
2605  send_stop_timer(pte);
2606  if (!sub) {
2607  ast_log(LOG_WARNING, "Close call without sub\n");
2608  return;
2609  }
2610  send_favorite_short(sub->softkey, FAV_LINE_ICON, pte);
2611  if (sub->owner) {
2612  sub->alreadygone = 1;
2613  if (sub_transf) {
2614  sub_transf->alreadygone = 1;
2615  if (attempt_transfer(sub, sub_transf) < 0) {
2616  ast_verb(0, "attempt_transfer failed.\n");
2617  }
2618  } else {
2619  ast_queue_hangup(sub->owner);
2620  }
2621  } else {
2622  if (sub_transf) {
2623  if (sub_transf->owner) {
2625  } else {
2626  ast_log(LOG_WARNING, "threeway sub without owner\n");
2627  }
2628  } else {
2629  ast_verb(0, "USTM(%s@%s-%d) channel already destroyed\n", sub->parent->name,
2630  pte->device->name, sub->softkey);
2631  }
2632  }
2633  change_callerid(pte, 0, pte->device->redial_number);
2634  change_callerid(pte, 1, "");
2635  write_history(pte, 'o', pte->device->missed_call);
2636  pte->device->missed_call = 0;
2637  show_main_page(pte);
2638  return;
2639 }
#define AST_CAUSE_NORMAL_CLEARING
Definition: causes.h:106
#define SUB_REAL
Definition: chan_unistim.c:116
#define SUB_THREEWAY
Definition: chan_unistim.c:118
static int attempt_transfer(struct unistim_subchannel *p1, struct unistim_subchannel *p2)
static void show_main_page(struct unistimsession *pte)
static int write_history(struct unistimsession *pte, char way, char ismissed)
static void send_stop_timer(struct unistimsession *pte)
static struct unistim_subchannel * get_sub(struct unistim_device *device, int type)
static void change_callerid(struct unistimsession *pte, int type, char *callerid)
int ast_queue_hangup(struct ast_channel *chan)
Queue a hangup frame.
Definition: channel.c:1144
int ast_queue_hangup_with_cause(struct ast_channel *chan, int cause)
Queue a hangup frame with hangupcause set.
Definition: channel.c:1160
char redial_number[AST_MAX_EXTENSION]
Definition: chan_unistim.c:400
char name[DEVICE_NAME_LEN]
Definition: chan_unistim.c:402

References unistim_subchannel::alreadygone, AST_CAUSE_NORMAL_CLEARING, ast_log, ast_queue_hangup(), ast_queue_hangup_with_cause(), ast_verb, attempt_transfer(), change_callerid(), unistimsession::device, FAV_LINE_ICON, get_sub(), LOG_WARNING, unistim_device::missed_call, unistim_device::name, unistim_subchannel::owner, unistim_device::redial_number, send_favorite_short(), send_stop_timer(), show_main_page(), sub, SUB_REAL, SUB_THREEWAY, and write_history().

Referenced by key_call(), process_request(), and unistim_hangup().

◆ close_client()

static void close_client ( struct unistimsession s)
static

Definition at line 1470 of file chan_unistim.c.

1471 {
1472  struct unistim_subchannel *sub = NULL;
1473  struct unistimsession *cur, *prev = NULL;
1475  cur = sessions;
1476  /* Looking for the session in the linked chain */
1477  while (cur) {
1478  if (cur == s) {
1479  break;
1480  }
1481  prev = cur;
1482  cur = cur->next;
1483  }
1484  if (cur) { /* Session found ? */
1485  if (cur->device) { /* This session was registered ? */
1486  s->state = STATE_CLEANING;
1487  if (unistimdebug) {
1488  ast_verb(0, "close_client session %p device %p\n", s, s->device);
1489  }
1491  ast_mutex_lock(&s->device->lock);
1492  AST_LIST_LOCK(&s->device->subs);
1494  if (!sub) {
1495  continue;
1496  }
1497  if (sub->owner) { /* Call in progress ? */
1498  if (unistimdebug) {
1499  ast_verb(0, "Aborting call\n");
1500  }
1502  } else {
1503  if (unistimdebug) {
1504  ast_debug(1, "Released sub %u of channel %s@%s\n", sub->subtype, sub->parent->name, s->device->name);
1505  }
1508  }
1509  }
1511  AST_LIST_UNLOCK(&s->device->subs);
1512 
1515  }
1516  cur->device->session = NULL;
1518  } else {
1519  if (unistimdebug) {
1520  ast_verb(0, "Freeing an unregistered client\n");
1521  }
1522  }
1523  if (prev) {
1524  prev->next = cur->next;
1525  } else {
1526  sessions = cur->next;
1527  }
1528  ast_mutex_destroy(&s->lock);
1529  ast_free(s);
1530  } else {
1531  ast_log(LOG_WARNING, "Trying to delete non-existent session %p?\n", s);
1532  }
1534  return;
1535 }
#define AST_CAUSE_NETWORK_OUT_OF_ORDER
Definition: causes.h:121
static struct unistimsession * sessions
static void change_favorite_icon(struct unistimsession *pte, unsigned char status)
static ast_mutex_t sessionlock
Definition: chan_unistim.c:271
static int unistim_free_sub(struct unistim_subchannel *)
static int unregister_extension(const struct unistimsession *pte)
#define ast_debug(level,...)
Log a DEBUG message.
#define ast_mutex_destroy(a)
Definition: lock.h:186
struct unistim_device::@147 subs
char extension_number[11]
Definition: chan_unistim.c:448
struct unistimsession * session
Definition: chan_unistim.c:454
ast_mutex_t lock
Definition: chan_unistim.c:395
struct unistimsession * next
Definition: chan_unistim.c:477
ast_mutex_t lock
Definition: chan_unistim.c:459

References AST_CAUSE_NETWORK_OUT_OF_ORDER, ast_debug, ast_free, AST_LIST_LOCK, AST_LIST_REMOVE_CURRENT, AST_LIST_TRAVERSE_SAFE_BEGIN, AST_LIST_TRAVERSE_SAFE_END, AST_LIST_UNLOCK, ast_log, ast_mutex_destroy, ast_mutex_lock, ast_mutex_unlock, ast_queue_hangup_with_cause(), ast_strlen_zero(), ast_verb, change_favorite_icon(), unistimsession::device, unistim_device::extension_number, FAV_ICON_NONE, unistim_device::lock, unistimsession::lock, LOG_WARNING, unistim_device::name, unistimsession::next, NULL, unistim_device::session, sessionlock, sessions, unistimsession::state, STATE_CLEANING, sub, unistim_device::subs, unistim_free_sub(), unistimdebug, and unregister_extension().

Referenced by parsing(), and send_retransmit().

◆ control2str()

static char* control2str ( int  ind)
static

Definition at line 5279 of file chan_unistim.c.

5280 {
5281  switch (ind) {
5282  case AST_CONTROL_HANGUP:
5283  return "Other end has hungup";
5284  case AST_CONTROL_RING:
5285  return "Local ring";
5286  case AST_CONTROL_RINGING:
5287  return "Remote end is ringing";
5288  case AST_CONTROL_ANSWER:
5289  return "Remote end has answered";
5290  case AST_CONTROL_BUSY:
5291  return "Remote end is busy";
5293  return "Make it go off hook";
5294  case AST_CONTROL_OFFHOOK:
5295  return "Line is off hook";
5297  return "Congestion (circuits busy)";
5298  case AST_CONTROL_FLASH:
5299  return "Flash hook";
5300  case AST_CONTROL_WINK:
5301  return "Wink";
5302  case AST_CONTROL_OPTION:
5303  return "Set a low-level option";
5304  case AST_CONTROL_RADIO_KEY:
5305  return "Key Radio";
5307  return "Un-Key Radio";
5309  return "Remote end changed";
5310  case AST_CONTROL_SRCCHANGE:
5311  return "RTP source updated";
5312  case AST_CONTROL_SRCUPDATE:
5313  return "Source of media changed";
5314  case -1:
5315  return "Stop tone";
5316  }
5317  return "UNKNOWN";
5318 }
@ AST_CONTROL_RING
@ AST_CONTROL_SRCUPDATE
@ AST_CONTROL_WINK
@ AST_CONTROL_OFFHOOK
@ AST_CONTROL_RADIO_UNKEY
@ AST_CONTROL_BUSY
@ AST_CONTROL_TAKEOFFHOOK
@ AST_CONTROL_CONGESTION
@ AST_CONTROL_ANSWER
@ AST_CONTROL_RINGING
@ AST_CONTROL_HANGUP
@ AST_CONTROL_RADIO_KEY
@ AST_CONTROL_OPTION
@ AST_CONTROL_CONNECTED_LINE
@ AST_CONTROL_FLASH
@ AST_CONTROL_SRCCHANGE

References AST_CONTROL_ANSWER, AST_CONTROL_BUSY, AST_CONTROL_CONGESTION, AST_CONTROL_CONNECTED_LINE, AST_CONTROL_FLASH, AST_CONTROL_HANGUP, AST_CONTROL_OFFHOOK, AST_CONTROL_OPTION, AST_CONTROL_RADIO_KEY, AST_CONTROL_RADIO_UNKEY, AST_CONTROL_RING, AST_CONTROL_RINGING, AST_CONTROL_SRCCHANGE, AST_CONTROL_SRCUPDATE, AST_CONTROL_TAKEOFFHOOK, and AST_CONTROL_WINK.

Referenced by unistim_indicate().

◆ create_client()

static struct unistimsession* create_client ( const struct sockaddr_in *  addr_from)
static

Definition at line 1046 of file chan_unistim.c.

1047 {
1048  int tmp;
1049  struct unistimsession *s;
1050 
1051  if (!(s = ast_calloc(1, sizeof(*s))))
1052  return NULL;
1053 
1054  memcpy(&s->sin, addr_from, sizeof(struct sockaddr_in));
1055  if (get_to_address(unistimsock, &s->sout) < 0) {
1056  ast_free(s);
1057  return NULL;
1058  }
1059  s->sout.sin_family = AF_INET;
1060  if (unistimdebug) {
1061  ast_verb(0, "Creating a new entry for the phone from %s received via server ip %s\n",
1062  ast_inet_ntoa(addr_from->sin_addr), ast_inet_ntoa(s->sout.sin_addr));
1063  }
1064  ast_mutex_init(&s->lock);
1066  s->next = sessions;
1067  sessions = s;
1068 
1070  s->state = STATE_INIT;
1072  /* Initialize struct wsabuf */
1073  for (tmp = 0; tmp < MAX_BUF_NUMBER; tmp++) {
1074  s->wsabufsend[tmp].buf = s->buf[tmp];
1075  }
1077  return s;
1078 }
static int tmp()
Definition: bt_open.c:389
static int unistim_keepalive
Definition: chan_unistim.c:246
static unsigned int get_tick_count(void)
Definition: chan_unistim.c:895
#define MAX_BUF_NUMBER
Definition: chan_unistim.c:93
#define RETRANSMIT_TIMER
Definition: chan_unistim.c:103
static int get_to_address(int fd, struct sockaddr_in *toAddr)
const char * ast_inet_ntoa(struct in_addr ia)
thread-safe replacement for inet_ntoa().
Definition: main/utils.c:928
unsigned char buf[MAX_BUF_NUMBER][MAX_BUF_SIZE]
Definition: chan_unistim.c:475
struct wsabuf wsabufsend[MAX_BUF_NUMBER]
Definition: chan_unistim.c:474
struct sockaddr_in sout
Definition: chan_unistim.c:461
unsigned long tick_next_ping
Definition: chan_unistim.c:466
struct sockaddr_in sin
Definition: chan_unistim.c:460
unsigned char * buf
Definition: chan_unistim.c:350

References ast_calloc, ast_free, ast_inet_ntoa(), ast_mutex_init, ast_mutex_lock, ast_mutex_unlock, ast_verb, wsabuf::buf, unistimsession::buf, get_tick_count(), get_to_address(), unistimsession::lock, MAX_BUF_NUMBER, unistimsession::next, NULL, RETRANSMIT_TIMER, sessionlock, sessions, unistimsession::sin, unistimsession::sout, unistimsession::state, STATE_INIT, unistimsession::tick_next_ping, unistimsession::timeout, tmp(), unistim_keepalive, unistimdebug, unistimsock, and unistimsession::wsabufsend.

Referenced by parsing().

◆ delete_device()

static void delete_device ( struct unistim_device d)
static

Definition at line 6422 of file chan_unistim.c.

6423 {
6424  struct unistim_line *l;
6425  struct unistim_subchannel *sub;
6426  struct unistimsession *s;
6427 
6428  if (unistimdebug) {
6429  ast_verb(0, "Removing device '%s'\n", d->name);
6430  }
6431  AST_LIST_LOCK(&d->subs);
6432  AST_LIST_TRAVERSE_SAFE_BEGIN(&d->subs, sub, list){
6433  if (sub->subtype == SUB_REAL) {
6434  if (sub->owner) {
6436  "Device '%s' was not deleted : a call is in progress. Try again later.\n",
6437  d->name);
6438  AST_LIST_UNLOCK(&d->subs);
6439  return;
6440  }
6441  }
6442  if (sub->subtype == SUB_THREEWAY) {
6444  "Device '%s' with threeway call subchannels allocated, aborting.\n",
6445  d->name);
6446  AST_LIST_UNLOCK(&d->subs);
6447  return;
6448  }
6450  ast_mutex_destroy(&sub->lock);
6451  ast_free(sub);
6452  }
6454  AST_LIST_UNLOCK(&d->subs);
6455 
6456 
6457  AST_LIST_LOCK(&d->lines);
6458  AST_LIST_TRAVERSE_SAFE_BEGIN(&d->lines, l, list){
6460  ast_mutex_destroy(&l->lock);
6462  }
6464  AST_LIST_UNLOCK(&d->lines);
6465 
6466  if (d->session) {
6467  if (sessions == d->session) {
6468  sessions = d->session->next;
6469  } else {
6470  s = sessions;
6471  while (s) {
6472  if (s->next == d->session) {
6473  s->next = d->session->next;
6474  break;
6475  }
6476  s = s->next;
6477  }
6478  }
6479  ast_mutex_destroy(&d->session->lock);
6480  ast_free(d->session);
6481  }
6482  if (devices == d) {
6483  devices = d->next;
6484  } else {
6485  struct unistim_device *d2 = devices;
6486  while (d2) {
6487  if (d2->next == d) {
6488  d2->next = d->next;
6489  break;
6490  }
6491  d2 = d2->next;
6492  }
6493  }
6494  if (d->tz) {
6495  d->tz = ast_tone_zone_unref(d->tz);
6496  }
6497  ast_mutex_destroy(&d->lock);
6498  ast_free(d);
6499 }
struct unistim_device * next
Definition: chan_unistim.c:455

References ast_free, AST_LIST_LOCK, AST_LIST_REMOVE_CURRENT, AST_LIST_TRAVERSE_SAFE_BEGIN, AST_LIST_TRAVERSE_SAFE_END, AST_LIST_UNLOCK, ast_log, ast_mutex_destroy, ast_tone_zone_unref(), ast_verb, d, devices, unistim_line::lock, LOG_WARNING, test_val::name, unistim_device::next, unistimsession::next, test_val::next, sessions, sub, SUB_REAL, SUB_THREEWAY, unistim_line_destroy(), and unistimdebug.

Referenced by build_device(), and reload_config().

◆ discard_call()

static void discard_call ( struct unistimsession pte)
static

Definition at line 2647 of file chan_unistim.c.

2648 {
2649  struct unistim_subchannel* sub;
2650  sub = get_sub(pte->device, SUB_RING);
2651  if (!sub) {
2652  return;
2653  }
2654 
2656  return;
2657 }
#define SUB_RING
Definition: chan_unistim.c:117

References AST_CAUSE_NORMAL_CLEARING, ast_queue_hangup_with_cause(), unistimsession::device, get_sub(), sub, and SUB_RING.

Referenced by key_ringing().

◆ display_last_error()

static void display_last_error ( const char *  sz_msg)
static

Definition at line 889 of file chan_unistim.c.

890 {
891  /* Display the error message */
892  ast_log(LOG_WARNING, "%s : (%d) %s\n", sz_msg, errno, strerror(errno));
893 }
int errno

References ast_log, errno, and LOG_WARNING.

Referenced by key_history(), open_history(), send_raw_client(), show_entry_history(), write_entry_history(), and write_history().

◆ do_monitor()

static void* do_monitor ( void *  data)
static

Definition at line 5835 of file chan_unistim.c.

5836 {
5837  struct unistimsession *cur = NULL;
5838  unsigned int dw_timeout = 0;
5839  unsigned int tick;
5840  int res;
5841  int reloading;
5842 
5843  /* Add an I/O event to our UDP socket */
5844  if (unistimsock > -1) {
5846  }
5847  /* This thread monitors our UDP socket and timers */
5848  for (;;) {
5849  /* This loop is executed at least every IDLE_WAITus (1s) or every time a packet is received */
5850  /* Looking for the smallest time-out value */
5851  tick = get_tick_count();
5852  dw_timeout = UINT_MAX;
5854  cur = sessions;
5855  DEBUG_TIMER("checking timeout for session %p with tick = %u\n", cur, tick);
5856  while (cur) {
5857  DEBUG_TIMER("checking timeout for session %p timeout = %u\n", cur,
5858  cur->timeout);
5859  /* Check if we have miss something */
5860  if (cur->timeout <= tick) {
5861  DEBUG_TIMER("Event for session %p\n", cur);
5862  /* If the queue is empty, send a ping */
5863  if (cur->last_buf_available == 0) {
5864  send_ping(cur);
5865  } else {
5866  if (send_retransmit(cur)) {
5867  DEBUG_TIMER("The chained link was modified, restarting...\n");
5868  cur = sessions;
5869  dw_timeout = UINT_MAX;
5870  continue;
5871  }
5872  }
5873  }
5874  if (dw_timeout > cur->timeout - tick) {
5875  dw_timeout = cur->timeout - tick;
5876  }
5877  /* Checking if the phone is logged on for a new MWI */
5878  if (cur->device) {
5879  struct unistim_line *l;
5880  AST_LIST_LOCK(&cur->device->lines);
5881  AST_LIST_TRAVERSE(&cur->device->lines, l, list) {
5882  if ((!ast_strlen_zero(l->mailbox)) && (tick >= l->parent->nextmsgcheck)) {
5883  DEBUG_TIMER("Checking mailbox for MWI\n");
5884  unistim_send_mwi_to_peer(l, tick);
5885  break;
5886  }
5887  }
5888  AST_LIST_UNLOCK(&cur->device->lines);
5889  if (cur->device->nextdial && tick >= cur->device->nextdial) {
5890  handle_call_outgoing(cur);
5891  cur->device->nextdial = 0;
5892  }
5893  }
5894  cur = cur->next;
5895  }
5897  DEBUG_TIMER("Waiting for %dus\n", dw_timeout);
5898  res = dw_timeout;
5899  /* We should not wait more than IDLE_WAIT */
5900  if ((res < 0) || (res > IDLE_WAIT)) {
5901  res = IDLE_WAIT;
5902  }
5903  /* Wait for UDP messages for a maximum of res us */
5904  res = ast_io_wait(io, res); /* This function will call unistimsock_read if a packet is received */
5905  /* Check for a reload request */
5907  reloading = unistim_reloading;
5908  unistim_reloading = 0;
5910  if (reloading) {
5911  ast_verb(1, "Reloading unistim.conf...\n");
5912  reload_config();
5913  }
5914  pthread_testcancel();
5915  }
5916  /* Never reached */
5917  return NULL;
5918 }
static ast_mutex_t unistim_reload_lock
Definition: chan_unistim.c:261
static void handle_call_outgoing(struct unistimsession *s)
#define IDLE_WAIT
Definition: chan_unistim.c:101
static int unistim_reloading
Definition: chan_unistim.c:260
static void send_ping(struct unistimsession *pte)
Definition: chan_unistim.c:991
static int unistimsock_read(int *id, int fd, short events, void *ignore)
static int send_retransmit(struct unistimsession *pte)
static int unistim_send_mwi_to_peer(struct unistim_line *peer, unsigned int tick)
static int reload_config(void)
static struct io_context * io
Definition: chan_unistim.c:256
#define DEBUG_TIMER
Definition: chan_unistim.c:241
#define AST_IO_IN
Definition: io.h:34
int ast_io_wait(struct io_context *ioc, int howlong)
Waits for IO.
Definition: io.c:278
int * ast_io_add(struct io_context *ioc, int fd, ast_io_cb callback, short events, void *data)
Adds an IO context.
Definition: io.c:162
#define AST_LIST_TRAVERSE(head, var, field)
Loops over (traverses) the entries in a list.
Definition: linkedlists.h:491
struct unistim_device::@148 lines
time_t nextmsgcheck
Definition: chan_unistim.c:445

References ast_io_add(), AST_IO_IN, ast_io_wait(), AST_LIST_LOCK, AST_LIST_TRAVERSE, AST_LIST_UNLOCK, ast_mutex_lock, ast_mutex_unlock, ast_strlen_zero(), ast_verb, DEBUG_TIMER, unistimsession::device, get_tick_count(), handle_call_outgoing(), IDLE_WAIT, io, unistimsession::last_buf_available, unistim_device::lines, unistim_line::list, unistim_line::mailbox, unistimsession::next, unistim_device::nextdial, unistim_device::nextmsgcheck, NULL, unistim_line::parent, reload_config(), send_ping(), send_retransmit(), sessionlock, sessions, unistimsession::timeout, unistim_reload_lock, unistim_reloading, unistim_send_mwi_to_peer(), unistimsock, and unistimsock_read().

Referenced by restart_monitor().

◆ dummy()

static void dummy ( char *  unused,
  ... 
)
static

◆ find_language()

static int find_language ( const char *  lang)
static

Definition at line 3807 of file chan_unistim.c.

3808 {
3809  int i = 0;
3810  while (options_languages[i].lang_short != NULL) {
3811  if(!strcmp(options_languages[i].lang_short, lang)) {
3812  return i;
3813  }
3814  i++;
3815  }
3816  return 0;
3817 }
static struct unistim_languages options_languages[]
Definition: chan_unistim.c:771

References NULL, and options_languages.

Referenced by handle_select_language(), init_phone_step2(), reload_config(), send_charset_update(), and ustmtext().

◆ find_line_by_number()

static struct unistim_line* find_line_by_number ( struct unistim_device d,
const char *  val 
)
static

Definition at line 6408 of file chan_unistim.c.

6408  {
6409  struct unistim_line *l, *ret = NULL;
6410 
6411  AST_LIST_LOCK(&d->lines);
6412  AST_LIST_TRAVERSE(&d->lines, l, list) {
6413  if (!strcmp(l->name, val)) {
6414  ret = l;
6415  break;
6416  }
6417  }
6418  AST_LIST_UNLOCK(&d->lines);
6419  return ret;
6420 }
Definition: ast_expr2.c:325

References AST_LIST_LOCK, AST_LIST_TRAVERSE, AST_LIST_UNLOCK, d, unistim_line::list, unistim_line::name, and NULL.

Referenced by build_device().

◆ find_rtp_port()

static int find_rtp_port ( struct unistim_subchannel s)
static

Definition at line 2685 of file chan_unistim.c.

2686 {
2687  struct unistim_subchannel *sub = NULL;
2688  int rtp_start = s->parent->parent->rtp_port;
2689  struct ast_sockaddr us_tmp;
2690  struct sockaddr_in us = { 0, };
2691 
2693  AST_LIST_TRAVERSE(&s->parent->parent->subs, sub, list) {
2694  if (!sub) {
2695  continue;
2696  }
2697  if (sub->rtp) {
2699  ast_sockaddr_to_sin(&us_tmp, &us);
2700  if (htons(us.sin_port)) {
2701  rtp_start = htons(us.sin_port) + 1;
2702  break;
2703  }
2704  }
2705  }
2707  return rtp_start;
2708 }
#define ast_sockaddr_to_sin(addr, sin)
Converts a struct ast_sockaddr to a struct sockaddr_in.
Definition: netsock2.h:765
#define ast_rtp_instance_get_remote_address(instance, address)
Get the address of the remote endpoint that we are sending RTP to.
Definition: rtp_engine.h:1192
Socket address structure.
Definition: netsock2.h:97
struct unistim_line * parent
Definition: chan_unistim.c:357

References AST_LIST_LOCK, AST_LIST_TRAVERSE, AST_LIST_UNLOCK, ast_rtp_instance_get_remote_address, ast_sockaddr_to_sin, NULL, unistim_subchannel::parent, unistim_line::parent, unistim_device::rtp_port, sub, and unistim_device::subs.

Referenced by start_rtp().

◆ find_subchannel_by_name()

static struct unistim_subchannel* find_subchannel_by_name ( const char *  dest)
static

Definition at line 5421 of file chan_unistim.c.

5422 {
5423  struct unistim_line *l;
5424  struct unistim_device *d;
5425  struct unistim_subchannel *sub = NULL;
5426  char line[256];
5427  char *at;
5428  char *device;
5429 
5430  ast_copy_string(line, dest, sizeof(line));
5431  at = strchr(line, '@');
5432  if (!at) {
5433  ast_log(LOG_NOTICE, "Device '%s' has no @ (at) sign!\n", dest);
5434  return NULL;
5435  }
5436  *at = '\0';
5437  at++;
5438  device = at;
5440  d = devices;
5441  at = strchr(device, '/'); /* Extra options ? */
5442  if (at) {
5443  *at = '\0';
5444  }
5445  while (d) {
5446  if (!strcasecmp(d->name, device)) {
5447  if (unistimdebug) {
5448  ast_verb(0, "Found device: %s\n", d->name);
5449  }
5450  /* Found the device */
5451  AST_LIST_LOCK(&d->lines);
5452  AST_LIST_TRAVERSE(&d->lines, l, list) {
5453  /* Search for the right line */
5454  if (!strcasecmp(l->name, line)) {
5455  if (unistimdebug) {
5456  ast_verb(0, "Found line: %s\n", l->name);
5457  }
5458  sub = get_sub(d, SUB_REAL);
5459  if (!sub) {
5461  }
5462  if (sub->owner) {
5463  /* Allocate additional channel if asterisk channel already here */
5465  sub->holding = 1;
5466  }
5467  sub->ringvolume = -1;
5468  sub->ringstyle = -1;
5469  if (at) { /* Other options ? */
5470  at++; /* Skip slash */
5471  if (*at == 'r') { /* distinctive ring */
5472  at++;
5473  if ((*at < '0') || (*at > '7')) { /* ring style */
5474  ast_log(LOG_WARNING, "Invalid ring selection (%s)", at);
5475  } else {
5476  signed char ring_volume = -1;
5477  signed char ring_style = *at - '0';
5478  at++;
5479  if ((*at >= '0') && (*at <= '3')) { /* ring volume */
5480  ring_volume = *at - '0';
5481  }
5482  if (unistimdebug) {
5483  ast_verb(0, "Distinctive ring: style #%d volume %d\n",
5484  ring_style, ring_volume);
5485  }
5486  sub->ringvolume = ring_volume;
5487  sub->ringstyle = ring_style;
5488  }
5489  }
5490  }
5491  sub->parent = l;
5492  break;
5493  }
5494  }
5495  AST_LIST_UNLOCK(&d->lines);
5496  if (sub) {
5498  return sub;
5499  }
5500  }
5501  d = d->next;
5502  }
5503  /* Device not found */
5505 
5506  return NULL;
5507 }
static struct unistim_subchannel * unistim_alloc_sub(struct unistim_device *d, int x)
#define LOG_NOTICE
struct unistim_subchannel::@145 list

References ast_copy_string(), AST_LIST_LOCK, AST_LIST_TRAVERSE, AST_LIST_UNLOCK, ast_log, ast_mutex_lock, ast_mutex_unlock, ast_verb, d, devicelock, devices, get_sub(), unistim_subchannel::list, LOG_NOTICE, LOG_WARNING, unistim_line::name, test_val::name, test_val::next, NULL, sub, SUB_REAL, unistim_alloc_sub(), and unistimdebug.

Referenced by unistim_request(), and unistim_sp().

◆ finish_bookmark()

static void finish_bookmark ( void  )
static

Definition at line 6380 of file chan_unistim.c.

6381 {
6382  struct unistim_device *d = devices;
6383  int i;
6385  while (d) {
6386  for (i = 0; i < 6; i++) {
6387  if (d->softkeyicon[i] == 1) { /* Something for us */
6388  struct unistim_device *d2 = devices;
6389  while (d2) {
6390  if (!strcmp(d->softkeydevice[i], d2->name)) {
6391  d->sp[i] = d2;
6392  d->softkeyicon[i] = 0;
6393  break;
6394  }
6395  d2 = d2->next;
6396  }
6397  if (d->sp[i] == NULL) {
6398  ast_log(LOG_NOTICE, "Bookmark entry with device %s not found\n",
6399  d->softkeydevice[i]);
6400  }
6401  }
6402  }
6403  d = d->next;
6404  }
6406 }

References ast_log, ast_mutex_lock, ast_mutex_unlock, d, devicelock, devices, LOG_NOTICE, unistim_device::name, unistim_device::next, test_val::next, and NULL.

Referenced by reload_config().

◆ get_active_softkey()

static int get_active_softkey ( struct unistimsession pte)
static

Definition at line 1380 of file chan_unistim.c.

1381 {
1382  return pte->device->selected;
1383 }

References unistimsession::device, and unistim_device::selected.

Referenced by change_favorite_icon().

◆ get_avail_softkey()

static int get_avail_softkey ( struct unistimsession pte,
const char *  name 
)
static

Definition at line 1385 of file chan_unistim.c.

1386 {
1387  int i;
1388 
1389  if (!is_key_line(pte->device, pte->device->selected)) {
1390  pte->device->selected = -1;
1391  }
1392  for (i = 0; i < FAVNUM; i++) {
1393  if (pte->device->selected != -1 && pte->device->selected != i) {
1394  continue;
1395  }
1396  if (!soft_key_visible(pte->device, i)) {
1397  continue;
1398  }
1399  if (pte->device->ssub[i]) {
1400  continue;
1401  }
1402  if (is_key_line(pte->device, i)) {
1403  if (name && strcmp(name, pte->device->sline[i]->name)) {
1404  continue;
1405  }
1406  if (unistimdebug) {
1407  ast_verb(0, "Found softkey %d for device %s\n", i, name);
1408  }
1409  return i;
1410  }
1411  }
1412  return -1;
1413 }
static int is_key_line(struct unistim_device *d, int fav)
static int soft_key_visible(struct unistim_device *d, unsigned char num)
static const char name[]
Definition: format_mp3.c:68
struct unistim_subchannel * ssub[FAVNUM]
Definition: chan_unistim.c:409
struct unistim_line * sline[FAVNUM]
Definition: chan_unistim.c:410

References ast_verb, unistimsession::device, FAVNUM, is_key_line(), unistim_line::name, name, unistim_device::selected, unistim_device::sline, soft_key_visible(), unistim_device::ssub, and unistimdebug.

Referenced by handle_call_outgoing(), key_main_page(), process_request(), and unistim_request().

◆ get_sub()

static struct unistim_subchannel* get_sub ( struct unistim_device device,
int  type 
)
static

Definition at line 2493 of file chan_unistim.c.

2494 {
2495  struct unistim_subchannel *sub = NULL;
2496 
2497  AST_LIST_LOCK(&device->subs);
2498  AST_LIST_TRAVERSE(&device->subs, sub, list) {
2499  if (!sub) {
2500  continue;
2501  }
2502  if (sub->subtype == type) {
2503  break;
2504  }
2505  }
2506  AST_LIST_UNLOCK(&device->subs);
2507 
2508  return sub;
2509 }

References AST_LIST_LOCK, AST_LIST_TRAVERSE, AST_LIST_UNLOCK, unistim_subchannel::list, NULL, sub, unistim_device::subs, and type.

Referenced by close_call(), discard_call(), find_subchannel_by_name(), handle_call_incoming(), handle_call_outgoing(), key_call(), key_dial_page(), sub_unhold(), transfer_call_step1(), transfer_cancel_step2(), unistim_answer(), unistim_call(), unistim_do_senddigit(), unistim_hangup(), and unistim_request().

◆ get_sub_holding()

static struct unistim_subchannel* get_sub_holding ( struct unistim_device device,
int  type,
int  holding 
)
static

Definition at line 2511 of file chan_unistim.c.

2512 {
2513  struct unistim_subchannel *sub = NULL;
2514 
2515  AST_LIST_LOCK(&device->subs);
2516  AST_LIST_TRAVERSE(&device->subs, sub, list) {
2517  if (!sub) {
2518  continue;
2519  }
2520  if (sub->subtype == type && sub->holding == holding) {
2521  break;
2522  }
2523  }
2524  AST_LIST_UNLOCK(&device->subs);
2525 
2526  return sub;
2527 }

References AST_LIST_LOCK, AST_LIST_TRAVERSE, AST_LIST_UNLOCK, unistim_subchannel::holding, unistim_subchannel::list, NULL, sub, unistim_device::subs, and type.

Referenced by handle_key_fav().

◆ get_tick_count()

static unsigned int get_tick_count ( void  )
static

Definition at line 895 of file chan_unistim.c.

896 {
897  struct timeval now = ast_tvnow();
898 
899  return (now.tv_sec * 1000) + (now.tv_usec / 1000);
900 }

References ast_tvnow().

Referenced by create_client(), do_monitor(), key_dial_page(), send_client(), send_ping(), and send_retransmit().

◆ get_to_address()

static int get_to_address ( int  fd,
struct sockaddr_in *  toAddr 
)
static

Definition at line 1002 of file chan_unistim.c.

1003 {
1004 #ifdef HAVE_PKTINFO
1005  int err;
1006  char cmbuf[0x100];
1007  struct cmsghdr *cmsg;
1008  struct sockaddr_in peeraddr;
1009  struct in_addr addr;
1010  struct msghdr mh = {
1011  .msg_name = &peeraddr,
1012  .msg_namelen = sizeof(peeraddr),
1013  .msg_control = cmbuf,
1014  .msg_controllen = sizeof(cmbuf),
1015  };
1016  memset(&addr, 0, sizeof(addr));
1017  /* Get info about the incoming packet */
1018  err = recvmsg(fd, &mh, MSG_PEEK);
1019  if (err == -1) {
1020  ast_log(LOG_WARNING, "recvmsg returned an error: %s\n", strerror(errno));
1021  return err;
1022  }
1023  for(cmsg = CMSG_FIRSTHDR(&mh);
1024  cmsg != NULL;
1025  cmsg = CMSG_NXTHDR(&mh, cmsg))
1026  {
1027  if (cmsg->cmsg_level == IPPROTO_IP && cmsg->cmsg_type == IP_PKTINFO) {
1028  struct in_pktinfo *pkt = (struct in_pktinfo*)CMSG_DATA(cmsg);
1029  addr = pkt->ipi_addr;
1030  if (unistimdebug) {
1031  ast_verb(0, "message received on address %s\n", ast_inet_ntoa(addr));
1032  }
1033  }
1034  }
1035  memcpy(&toAddr->sin_addr, &addr, sizeof(struct in_addr));
1036  return err;
1037 #else
1038  memcpy(toAddr, &public_ip, sizeof(*toAddr));
1039  return 0;
1040 #endif
1041 }
static struct sockaddr_in public_ip
Definition: chan_unistim.c:258

References ast_inet_ntoa(), ast_log, ast_verb, errno, LOG_WARNING, NULL, public_ip, and unistimdebug.

Referenced by create_client().

◆ handle_call_incoming()

static void handle_call_incoming ( struct unistimsession s)
static

Definition at line 3262 of file chan_unistim.c.

3263 {
3264  struct unistim_subchannel *sub = NULL;
3265  int i;
3266 
3267  s->state = STATE_CALL;
3268  s->device->missed_call = 0;
3269  send_no_ring(s);
3270  sub = get_sub(s->device, SUB_RING); /* Put other SUB_REAL call on hold */
3271  if (!sub) {
3272  ast_log(LOG_WARNING, "No ringing lines on: %s\n", s->device->name);
3273  return;
3274  }
3275  /* Change icons for all ringing keys */
3276  for (i = 0; i < FAVNUM; i++) {
3277  if (!s->device->ssub[i]) { /* No sub assigned - skip */
3278  continue;
3279  }
3280  if (s->device->ssub[i]->subtype == SUB_REAL) {
3281  sub_hold(s, s->device->ssub[i]);
3282  }
3283  if (s->device->ssub[i] != sub) {
3284  continue;
3285  }
3286  if (sub->softkey == i) { /* If softkey assigned at this moment - do not erase */
3287  continue;
3288  }
3289  if (sub->softkey < 0) { /* If softkey not defined - first one used */
3290  sub->softkey = i;
3291  continue;
3292  }
3294  s->device->ssub[i] = NULL;
3295  }
3296  if (sub->softkey < 0) {
3297  ast_log(LOG_WARNING, "Can not assign softkey for incoming call on: %s\n", s->device->name);
3298  return;
3299  }
3301  sub->parent = s->device->sline[sub->softkey];
3302  sub->subtype = SUB_REAL;
3303  if (unistimdebug) {
3304  ast_verb(0, "Handle Call Incoming for %s@%s\n", sub->parent->name,
3305  s->device->name);
3306  }
3307  start_rtp(sub);
3308  if (!sub->rtp) {
3309  ast_log(LOG_WARNING, "Unable to create channel for %s@%s\n", sub->parent->name, s->device->name);
3310  return;
3311  }
3312  if (sub->owner) {
3314  }
3315  send_text(TEXT_LINE2, TEXT_NORMAL, s, ustmtext("is on-line", s));
3316  send_text_status(s, ustmtext(" Transf Hangup", s));
3317  send_start_timer(s);
3318 
3319  if ((s->device->output == OUTPUT_HANDSET) &&
3320  (s->device->receiver_state == STATE_ONHOOK)) {
3322  } else {
3324  }
3325  write_history(s, 'i', 0);
3326  return;
3327 }
static const char * ustmtext(const char *str, struct unistimsession *pte)
Definition: chan_unistim.c:800
#define TEXT_NORMAL
Definition: chan_unistim.c:173
static void send_text(unsigned char pos, unsigned char inverse, struct unistimsession *pte, const char *text)
static void sub_hold(struct unistimsession *pte, struct unistim_subchannel *sub)
static void start_rtp(struct unistim_subchannel *sub)
#define FAV_ICON_OFFHOOK_BLACK
Definition: chan_unistim.c:182
static void send_select_output(struct unistimsession *pte, unsigned char output, unsigned char volume, unsigned char mute)
static void send_text_status(struct unistimsession *pte, const char *text)
static void send_start_timer(struct unistimsession *pte)
#define TEXT_LINE2
Definition: chan_unistim.c:172
#define OUTPUT_SPEAKER
Definition: chan_unistim.c:140
static void send_no_ring(struct unistimsession *pte)
int ast_queue_control(struct ast_channel *chan, enum ast_control_frame_type control)
Queue a control frame without payload.
Definition: channel.c:1225
unsigned int subtype
Definition: chan_unistim.c:355

References AST_CONTROL_ANSWER, ast_log, ast_queue_control(), ast_verb, unistimsession::device, FAV_ICON_OFFHOOK_BLACK, FAV_LINE_ICON, FAVNUM, get_sub(), LOG_WARNING, unistim_device::missed_call, MUTE_OFF, unistim_device::name, NULL, unistim_device::output, OUTPUT_HANDSET, OUTPUT_SPEAKER, unistim_device::receiver_state, send_favorite_short(), send_no_ring(), send_select_output(), send_start_timer(), send_text(), send_text_status(), unistim_device::sline, unistim_device::ssub, start_rtp(), unistimsession::state, STATE_CALL, STATE_ONHOOK, sub, sub_hold(), SUB_REAL, SUB_RING, unistim_subchannel::subtype, TEXT_LINE2, TEXT_NORMAL, unistimdebug, ustmtext(), unistim_device::volume, and write_history().

Referenced by handle_key_fav(), key_ringing(), and process_request().

◆ handle_call_outgoing()

static void handle_call_outgoing ( struct unistimsession s)
static

Definition at line 3111 of file chan_unistim.c.

3112 {
3113  struct ast_channel *c;
3114  struct unistim_subchannel *sub;
3115  int softkey;
3116 
3117  s->state = STATE_CALL;
3118 
3119  sub = get_sub(s->device, SUB_THREEWAY);
3120  if (sub) {
3121  /* If sub for threway call created than we use transfer behavior */
3122  struct unistim_subchannel *sub_trans = NULL;
3123  struct unistim_device *d = s->device;
3124 
3125  sub_trans = get_sub(d, SUB_REAL);
3126  if (sub_trans) {
3127  ast_log(LOG_WARNING, "Can't transfer while active subchannel exists!\n");
3128  return;
3129  }
3130  if (!sub->owner) {
3131  ast_log(LOG_WARNING, "Unable to find subchannel with music on hold\n");
3132  return;
3133  }
3134 
3135  sub_trans = unistim_alloc_sub(d, SUB_REAL);
3136  if (!sub_trans) {
3137  ast_log(LOG_WARNING, "Unable to allocate three-way subchannel\n");
3138  return;
3139  }
3140  sub_trans->parent = sub->parent;
3141  sub_stop_silence(s, sub);
3142  send_tone(s, 0, 0);
3143  /* Make new channel */
3144  c = unistim_new(sub_trans, AST_STATE_DOWN, NULL, NULL);
3145  if (!c) {
3146  ast_log(LOG_WARNING, "Cannot allocate new structure on channel %p\n", sub->parent);
3147  return;
3148  }
3149  /* Swap things around between the three-way and real call */
3150  swap_subs(sub, sub_trans);
3152  if (s->device->height == 1) {
3154  } else {
3155  send_text(TEXT_LINE0, TEXT_NORMAL, s, ustmtext("Calling (pre-transfer)", s));
3157  send_text(TEXT_LINE2, TEXT_NORMAL, s, ustmtext("Dialing...", s));
3158  }
3159  send_text_status(s, ustmtext("TransfrCancel", s));
3160 
3161  if (ast_pthread_create(&sub->ss_thread, NULL, unistim_ss, c)) {
3162  ast_log(LOG_WARNING, "Unable to start simple switch on channel %p\n", c);
3163  sub->ss_thread = AST_PTHREADT_NULL;
3164  ast_hangup(c);
3165  return;
3166  }
3167  if (unistimdebug) {
3168  ast_verb(0, "Started three way call on channel %p (%s) subchan %u\n",
3169  sub_trans->owner, ast_channel_name(sub_trans->owner), sub_trans->subtype);
3170  }
3171  return;
3172  }
3173 
3174  softkey = get_avail_softkey(s, NULL);
3175  if (softkey == -1) {
3176  ast_log(LOG_WARNING, "Have no avail softkey for calling\n");
3177  return;
3178  }
3179  sub = get_sub(s->device, SUB_REAL);
3180  if (sub) { /* have already call assigned */
3181  sub_hold(s, sub); /* Need to put on hold */
3182  }
3183  if (!(sub = unistim_alloc_sub(s->device, SUB_REAL))) {
3184  ast_log(LOG_WARNING, "Unable to allocate subchannel!\n");
3185  return;
3186  }
3187  sub->parent = s->device->sline[softkey];
3188  s->device->ssub[softkey] = sub;
3189  sub->softkey = softkey;
3190 
3191  if (unistimdebug) {
3192  ast_verb(0, "Using softkey %d, line %p\n", sub->softkey, sub->parent);
3193  }
3195  s->device->selected = -1;
3196  if (!sub->owner) { /* A call is already in progress ? */
3197  RAII_VAR(struct ast_features_pickup_config *, pickup_cfg, NULL, ao2_cleanup);
3198  const char *pickupexten;
3199 
3200  c = unistim_new(sub, AST_STATE_DOWN, NULL, NULL); /* No, starting a new one */
3201  if (!sub->rtp) { /* Need to start RTP before calling ast_pbx_run */
3202  start_rtp(sub);
3203  }
3204  if (c) {
3206  pickup_cfg = ast_get_chan_features_pickup_config(c);
3207  if (!pickup_cfg) {
3208  ast_log(LOG_ERROR, "Unable to retrieve pickup configuration options. Unable to detect call pickup extension\n");
3209  pickupexten = "";
3210  } else {
3211  pickupexten = ast_strdupa(pickup_cfg->pickupexten);
3212  }
3214  }
3215  if (c && !strcmp(s->device->phone_number, pickupexten)) {
3216  if (unistimdebug) {
3217  ast_verb(0, "Try to pickup in unistim_new\n");
3218  }
3219  send_text(TEXT_LINE0, TEXT_NORMAL, s, "");
3220  send_text_status(s, ustmtext(" Transf Hangup", s));
3221  send_start_timer(s);
3222  if (ast_pickup_call(c)) {
3223  ast_log(LOG_NOTICE, "Nothing to pick up\n");
3225  } else {
3227  }
3228  ast_hangup(c);
3229  c = NULL;
3230  } else if (c) {
3232  send_tone(s, 0, 0); /* Dialing empty number should also stop dial tone */
3233  if (s->device->height == 1) {
3234  if (strlen(s->device->phone_number) > 0) {
3236  } else {
3237  send_text(TEXT_LINE0, TEXT_NORMAL, s, ustmtext("Calling...", s));
3238  }
3239  } else {
3240  send_text(TEXT_LINE0, TEXT_NORMAL, s, ustmtext("Calling :", s));
3242  send_text(TEXT_LINE2, TEXT_NORMAL, s, ustmtext("Dialing...", s));
3243  }
3244  send_text_status(s, ustmtext(" Hangup", s));
3245 
3246  /* start switch */
3247  if (ast_pthread_create(&sub->ss_thread, NULL, unistim_ss, c)) {
3248  ast_log(LOG_WARNING, "Unable to create switch thread\n");
3249  sub->ss_thread = AST_PTHREADT_NULL;
3251  }
3252  } else
3253  ast_log(LOG_WARNING, "Unable to create channel for %s@%s\n",
3254  sub->parent->name, s->device->name);
3255  } else {
3256  ast_debug(1, "Current sub [%s] already has owner\n", ast_channel_name(sub->owner));
3257  }
3258  return;
3259 }
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: astmm.h:298
#define ao2_cleanup(obj)
Definition: astobj2.h:1934
#define AST_CAUSE_SWITCH_CONGESTION
Definition: causes.h:123
#define AST_CAUSE_CALL_REJECTED
Definition: causes.h:111
static void * unistim_ss(void *data)
static int get_avail_softkey(struct unistimsession *pte, const char *name)
static struct ast_channel * unistim_new(struct unistim_subchannel *sub, int state, const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor)
static void sub_stop_silence(struct unistimsession *pte, struct unistim_subchannel *sub)
static void send_tone(struct unistimsession *pte, uint16_t tone1, uint16_t tone2)
static void swap_subs(struct unistim_subchannel *a, struct unistim_subchannel *b)
#define TEXT_LINE1
Definition: chan_unistim.c:171
#define TEXT_LINE0
Definition: chan_unistim.c:170
void ast_hangup(struct ast_channel *chan)
Hang up a channel.
Definition: channel.c:2542
#define ast_channel_lock(chan)
Definition: channel.h:2922
const char * ast_channel_name(const struct ast_channel *chan)
void ast_channel_hangupcause_set(struct ast_channel *chan, int value)
#define ast_channel_unlock(chan)
Definition: channel.h:2923
@ AST_STATE_DOWN
Definition: channelstate.h:36
struct ast_features_pickup_config * ast_get_chan_features_pickup_config(struct ast_channel *chan)
Get the pickup configuration options for a channel.
#define AST_PTHREADT_NULL
Definition: lock.h:66
int ast_pickup_call(struct ast_channel *chan)
Pickup a call.
Definition: pickup.c:199
Configuration relating to call pickup.
char phone_number[AST_MAX_EXTENSION]
Definition: chan_unistim.c:399
static struct test_val c
#define ast_pthread_create(a, b, c, d)
Definition: utils.h:579

References ao2_cleanup, AST_CAUSE_CALL_REJECTED, AST_CAUSE_NORMAL_CLEARING, AST_CAUSE_SWITCH_CONGESTION, ast_channel_hangupcause_set(), ast_channel_lock, ast_channel_name(), ast_channel_unlock, ast_debug, ast_get_chan_features_pickup_config(), ast_hangup(), ast_log, ast_pickup_call(), ast_pthread_create, AST_PTHREADT_NULL, ast_queue_hangup_with_cause(), AST_STATE_DOWN, ast_strdupa, ast_verb, c, d, unistimsession::device, FAV_ICON_OFFHOOK_BLACK, get_avail_softkey(), get_sub(), unistim_device::height, LOG_ERROR, LOG_NOTICE, LOG_WARNING, MUTE_OFF, unistim_device::name, NULL, unistim_device::output, unistim_subchannel::owner, unistim_subchannel::parent, unistim_device::phone_number, RAII_VAR, unistim_device::selected, send_favorite_short(), send_select_output(), send_start_timer(), send_text(), send_text_status(), send_tone(), unistim_device::sline, unistim_subchannel::softkey, unistim_device::ssub, start_rtp(), unistimsession::state, STATE_CALL, sub, sub_hold(), SUB_REAL, sub_stop_silence(), SUB_THREEWAY, unistim_subchannel::subtype, swap_subs(), TEXT_LINE0, TEXT_LINE1, TEXT_LINE2, TEXT_NORMAL, unistim_alloc_sub(), unistim_new(), unistim_ss(), unistimdebug, ustmtext(), and unistim_device::volume.

Referenced by do_monitor(), key_dial_page(), key_favorite(), and key_main_page().

◆ handle_dial_page()

static void handle_dial_page ( struct unistimsession pte)
static

Definition at line 2983 of file chan_unistim.c.

2984 {
2985  pte->state = STATE_DIALPAGE;
2986  if (pte->device->call_forward[0] == -1) {
2987  send_text(TEXT_LINE0, TEXT_NORMAL, pte, "");
2988  send_text(TEXT_LINE1, TEXT_NORMAL, pte, ustmtext("Enter forward", pte));
2989  send_text_status(pte, ustmtext("Fwd Cancel BackSp Erase", pte));
2990  if (pte->device->call_forward[1] != 0) {
2992  sizeof(pte->device->phone_number));
2993  show_phone_number(pte);
2995  return;
2996  }
2997  } else {
2998  if ((pte->device->output == OUTPUT_HANDSET) &&
2999  (pte->device->receiver_state == STATE_ONHOOK)) {
3001  } else {
3002  send_select_output(pte, pte->device->output, pte->device->volume, MUTE_OFF);
3003  }
3004  send_dial_tone(pte);
3005 
3006  if (pte->device->height > 1) {
3007  send_text(TEXT_LINE0, TEXT_NORMAL, pte, ustmtext("Enter the number to dial", pte));
3008  send_text(TEXT_LINE1, TEXT_NORMAL, pte, ustmtext("and press Call", pte));
3009  }
3010  if (ast_strlen_zero(pte->device->redial_number)) {
3011  send_text_status(pte, ustmtext("Call BackSp Erase", pte));
3012  } else {
3013  send_text_status(pte, ustmtext("Call Redial BackSp Erase", pte));
3014  }
3015  }
3016 
3017  pte->device->size_phone_number = 0;
3018  pte->device->phone_number[0] = 0;
3019  show_phone_number(pte);
3022  pte->device->missed_call = 0;
3024  pte->device->lastmsgssent = -1;
3025  return;
3026 }
static void send_led_update(struct unistimsession *pte, unsigned char led)
static void send_dial_tone(struct unistimsession *pte)
#define LED_BAR_OFF
Definition: chan_unistim.c:151
#define FAV_ICON_PHONE_BLACK
Definition: chan_unistim.c:188
static void show_phone_number(struct unistimsession *pte)
static void send_icon(unsigned char pos, unsigned char status, struct unistimsession *pte)
char call_forward[AST_MAX_EXTENSION]
Definition: chan_unistim.c:438

References ast_copy_string(), ast_strlen_zero(), unistim_device::call_forward, change_favorite_icon(), unistimsession::device, FAV_ICON_NONE, FAV_ICON_PHONE_BLACK, unistim_device::height, unistim_device::lastmsgssent, LED_BAR_OFF, unistim_device::missed_call, MUTE_OFF, unistim_device::output, OUTPUT_HANDSET, OUTPUT_SPEAKER, unistim_device::phone_number, unistim_device::receiver_state, unistim_device::redial_number, send_dial_tone(), send_icon(), send_led_update(), send_select_output(), send_text(), send_text_status(), show_phone_number(), unistim_device::size_phone_number, unistimsession::state, STATE_DIALPAGE, STATE_ONHOOK, TEXT_LINE0, TEXT_LINE1, TEXT_NORMAL, ustmtext(), and unistim_device::volume.

Referenced by handle_key_fav(), key_main_page(), process_request(), and transfer_call_step1().

◆ handle_key_fav()

static void handle_key_fav ( struct unistimsession pte,
char  keycode 
)
static

Definition at line 3380 of file chan_unistim.c.

3381 {
3382  int keynum = keycode - KEY_FAV0;
3383  struct unistim_subchannel *sub, *sub_key = NULL;
3384  sub = get_sub_holding(pte->device, SUB_REAL, 0);
3385 
3386  /* Make an action on selected favorite key */
3387  if (!pte->device->ssub[keynum]) { /* Key have no assigned call */
3388  sub = get_sub_holding(pte->device, SUB_REAL, 0);
3390  if (is_key_line(pte->device, keynum)) {
3391  if (unistimdebug) {
3392  ast_verb(0, "Handle line w/o sub - dialpage\n");
3393  }
3394  pte->device->selected = keynum;
3395  sub_hold(pte, sub); /* Put active call on hold */
3396  send_stop_timer(pte);
3397  handle_dial_page(pte);
3398  } else if (is_key_favorite(pte->device, keynum)) {
3399  /* Put active call on hold in handle_call_outgoing function, after preparation and
3400  checking if lines available for calling */
3401  if (unistimdebug) {
3402  ast_verb(0, "Handle favorite w/o sub - dialing\n");
3403  }
3404  if ((pte->device->output == OUTPUT_HANDSET) &&
3405  (pte->device->receiver_state == STATE_ONHOOK)) {
3407  } else {
3408  send_select_output(pte, pte->device->output, pte->device->volume, MUTE_OFF);
3409  }
3410  key_favorite(pte, keycode);
3411  }
3412  } else {
3413  sub_key = pte->device->ssub[keynum];
3414  /* Favicon have assigned sub, activate it and put current on hold */
3415  if (sub_key->subtype == SUB_REAL && !sub_key->holding) {
3416  sub_hold(pte, sub_key);
3417  show_main_page(pte);
3418  } else if (sub_key->subtype == SUB_REAL && sub_key->holding) {
3419  /* We are going to unhold line (we should put active line on hold, of any) */
3420  if (pte->state == STATE_DIALPAGE){
3421  send_tone(pte, 0, 0);
3422  }
3423  sub_hold(pte, sub);
3424  send_callerid_screen(pte, sub_key);
3425  sub_unhold(pte, sub_key);
3426  pte->state = STATE_CALL;
3427  } else if (sub_key->subtype == SUB_RING) {
3428  sub_hold(pte, sub);
3429  sub_key->softkey = keynum;
3430  handle_call_incoming(pte);
3431  }
3432  }
3433 }
static void handle_call_incoming(struct unistimsession *s)
static void sub_unhold(struct unistimsession *pte, struct unistim_subchannel *sub)
static void send_callerid_screen(struct unistimsession *, struct unistim_subchannel *)
static int is_key_favorite(struct unistim_device *d, int fav)
static void handle_dial_page(struct unistimsession *pte)
static void send_favorite_selected(unsigned char status, struct unistimsession *pte)
static struct unistim_subchannel * get_sub_holding(struct unistim_device *device, int type, int holding)
static void key_favorite(struct unistimsession *, char)

References ast_verb, unistimsession::device, FAV_LINE_ICON, get_sub_holding(), handle_call_incoming(), handle_dial_page(), unistim_subchannel::holding, is_key_favorite(), is_key_line(), KEY_FAV0, key_favorite(), MUTE_OFF, NULL, unistim_device::output, OUTPUT_HANDSET, OUTPUT_SPEAKER, unistim_device::receiver_state, unistim_device::selected, send_callerid_screen(), send_favorite_selected(), send_select_output(), send_stop_timer(), send_tone(), show_main_page(), unistim_subchannel::softkey, unistim_device::ssub, unistimsession::state, STATE_CALL, STATE_DIALPAGE, STATE_ONHOOK, sub, sub_hold(), SUB_REAL, SUB_RING, sub_unhold(), unistim_subchannel::subtype, unistimdebug, and unistim_device::volume.

Referenced by key_call(), key_dial_page(), key_main_page(), and key_ringing().

◆ handle_select_codec()

static void handle_select_codec ( struct unistimsession pte)
static

Definition at line 3732 of file chan_unistim.c.

3733 {
3734  char buf[30], buf2[6];
3735 
3736  pte->state = STATE_SELECTCODEC;
3737  ast_copy_string(buf, ustmtext("Using codec", pte), sizeof(buf));
3738  snprintf(buf2, sizeof(buf2), " %d", pte->device->codec_number);
3739  strcat(buf, buf2);
3740  strcat(buf, " (G711u=0,");
3741 
3743  send_text(TEXT_LINE1, TEXT_NORMAL, pte, "G723=4,G711a=8,G729A=18)");
3745  send_blink_cursor(pte);
3747  pte->size_buff_entry = 0;
3748  send_text_status(pte, ustmtext("Select BackSp Erase Cancel", pte));
3749  return;
3750 }
#define TEXT_INVERSE
Definition: chan_unistim.c:174
static void send_blink_cursor(struct unistimsession *pte)
#define SELECTCODEC_START_ENTRY_POS
#define SELECTCODEC_MSG
static void send_cursor_pos(struct unistimsession *pte, unsigned char pos)
char buf[BUFSIZE]
Definition: eagi_proxy.c:66
static struct ast_threadstorage buf2

References ast_copy_string(), buf, buf2, unistim_device::codec_number, unistimsession::device, SELECTCODEC_MSG, SELECTCODEC_START_ENTRY_POS, send_blink_cursor(), send_cursor_pos(), send_text(), send_text_status(), unistimsession::size_buff_entry, unistimsession::state, STATE_SELECTCODEC, TEXT_INVERSE, TEXT_LINE0, TEXT_LINE1, TEXT_LINE2, TEXT_NORMAL, and ustmtext().

◆ handle_select_language()

static void handle_select_language ( struct unistimsession pte)
static

Definition at line 3819 of file chan_unistim.c.

3820 {
3821  char tmp_language[40];
3822  struct unistim_languages lang;
3823 
3824  if (pte->state != STATE_SELECTLANGUAGE) {
3825  pte->state = STATE_SELECTLANGUAGE;
3826  pte->size_buff_entry = 1;
3827  pte->buff_entry[0] = find_language(pte->device->language);
3828  }
3829  lang = options_languages[(int)pte->buff_entry[0]];
3830  ast_copy_string(tmp_language, pte->device->language, sizeof(tmp_language));
3831  ast_copy_string(pte->device->language, lang.lang_short, sizeof(pte->device->language));
3832  send_charset_update(pte, lang.encoding);
3833  send_text(TEXT_LINE0, TEXT_NORMAL, pte, ustmtext(lang.label, pte));
3834 
3835  ast_copy_string(pte->device->language, tmp_language, sizeof(pte->device->language));
3837  send_charset_update(pte, lang.encoding);
3838  send_text_status(pte, ustmtext("Select Cancel", pte));
3839  return;
3840 }
static void send_charset_update(struct unistimsession *pte, int charset)
static int find_language(const char *)
char language[MAX_LANGUAGE]
Definition: chan_unistim.c:412
char buff_entry[16]
Definition: chan_unistim.c:471

References ast_copy_string(), unistimsession::buff_entry, unistimsession::device, unistim_languages::encoding, find_language(), unistim_languages::label, unistim_languages::lang_short, unistim_device::language, options_languages, send_charset_update(), send_text(), send_text_status(), unistimsession::size_buff_entry, unistimsession::state, STATE_SELECTLANGUAGE, TEXT_LINE0, TEXT_NORMAL, and ustmtext().

Referenced by key_select_language().

◆ handle_select_option()

static void handle_select_option ( struct unistimsession pte)
static

Definition at line 3687 of file chan_unistim.c.

3688 {
3689  char tmp[128];
3690 
3691  if (pte->state != STATE_SELECTOPTION) {
3692  pte->state = STATE_SELECTOPTION;
3693  pte->size_buff_entry = 1;
3694  pte->buff_entry[0] = 0; /* Position in menu */
3695  }
3696  snprintf(tmp, sizeof(tmp), "%d. %s", pte->buff_entry[0] + 1, ustmtext(options_menu[(int)pte->buff_entry[0]].label, pte));
3698  send_text_status(pte, ustmtext("Select Cancel", pte));
3699  return;
3700 }
static struct unistim_menu_item options_menu[]
Definition: chan_unistim.c:764

References unistimsession::buff_entry, unistim_menu_item::label, options_menu, send_text(), send_text_status(), unistimsession::size_buff_entry, unistimsession::state, STATE_SELECTOPTION, TEXT_LINE0, TEXT_NORMAL, tmp(), and ustmtext().

Referenced by key_main_page(), key_select_language(), and key_select_option().

◆ ignore_call()

static void ignore_call ( struct unistimsession pte)
static

Definition at line 2641 of file chan_unistim.c.

2642 {
2643  send_no_ring(pte);
2644  return;
2645 }

References send_no_ring().

Referenced by key_ringing().

◆ in_band_indication()

static void in_band_indication ( struct ast_channel ast,
const struct ast_tone_zone tz,
const char *  indication 
)
static

Definition at line 5320 of file chan_unistim.c.

5322 {
5323  struct ast_tone_zone_sound *ts = NULL;
5324 
5325  if ((ts = ast_get_indication_tone(tz, indication))) {
5326  ast_playtones_start(ast, 0, ts->data, 1);
5327  ts = ast_tone_zone_sound_unref(ts);
5328  } else {
5329  ast_log(LOG_WARNING, "Unable to get indication tone for %s\n", indication);
5330  }
5331 }
static char * tz
Definition: cdr_pgsql.c:71
struct ast_tone_zone_sound * ast_get_indication_tone(const struct ast_tone_zone *zone, const char *indication)
Locate a tone zone sound.
Definition: indications.c:455
int ast_playtones_start(struct ast_channel *chan, int vol, const char *tonelist, int interruptible)
Start playing a list of tones on a channel.
Definition: indications.c:302
static struct ast_tone_zone_sound * ast_tone_zone_sound_unref(struct ast_tone_zone_sound *ts)
Release a reference to an ast_tone_zone_sound.
Definition: indications.h:227
Description of a tone.
Definition: indications.h:35
const char * data
Description of a tone.
Definition: indications.h:52

References ast_get_indication_tone(), ast_log, ast_playtones_start(), ast_tone_zone_sound_unref(), ast_tone_zone_sound::data, LOG_WARNING, NULL, and tz.

Referenced by unistim_indicate().

◆ init_phone_step2()

static void init_phone_step2 ( struct unistimsession pte)
static

Definition at line 4381 of file chan_unistim.c.

4382 {
4383  BUFFSEND;
4384  if (unistimdebug) {
4385  ast_verb(0, "Sending S4\n");
4386  }
4387  memcpy(buffsend + SIZE_HEADER, packet_send_s4, sizeof(packet_send_s4));
4388  send_client(SIZE_HEADER + sizeof(packet_send_s4), buffsend, pte);
4389  send_date_time2(pte);
4390  send_date_time3(pte);
4391  if (unistimdebug) {
4392  ast_verb(0, "Sending S7\n");
4393  }
4394  memcpy(buffsend + SIZE_HEADER, packet_send_S7, sizeof(packet_send_S7));
4395  send_client(SIZE_HEADER + sizeof(packet_send_S7), buffsend, pte);
4396  if (unistimdebug) {
4397  ast_verb(0, "Sending Contrast\n");
4398  }
4399  memcpy(buffsend + SIZE_HEADER, packet_send_Contrast, sizeof(packet_send_Contrast));
4400  if (pte->device != NULL) {
4401  buffsend[9] = pte->device->contrast;
4402  }
4403  send_client(SIZE_HEADER + sizeof(packet_send_Contrast), buffsend, pte);
4404 
4405  if (unistimdebug) {
4406  ast_verb(0, "Sending S9\n");
4407  }
4408  memcpy(buffsend + SIZE_HEADER, packet_send_s9, sizeof(packet_send_s9));
4409  send_client(SIZE_HEADER + sizeof(packet_send_s9), buffsend, pte);
4410  send_no_ring(pte);
4411 
4412  if (unistimdebug) {
4413  ast_verb(0, "Sending S7\n");
4414  }
4415  memcpy(buffsend + SIZE_HEADER, packet_send_S7, sizeof(packet_send_S7));
4416  send_client(SIZE_HEADER + sizeof(packet_send_S7), buffsend, pte);
4418  send_ping(pte);
4419  if (unistimdebug) {
4420  ast_verb(0, "Sending init language\n");
4421  }
4422  if (pte->device) {
4424  }
4425  if (pte->state < STATE_MAINPAGE) {
4427  show_extension_page(pte);
4428  return;
4429  } else {
4430  int i;
4431  char tmp[30];
4432 
4433  for (i = 1; i < FAVNUM; i++) {
4434  send_favorite(i, 0, pte, "");
4435  }
4436  send_text(TEXT_LINE0, TEXT_NORMAL, pte, ustmtext("Phone is not registered", pte));
4437  send_text(TEXT_LINE1, TEXT_NORMAL, pte, ustmtext("in unistim.conf", pte));
4438  strcpy(tmp, "MAC = ");
4439  strcat(tmp, pte->macaddr);
4441  send_text_status(pte, "");
4442  send_texttitle(pte, ustmtext("UNISTIM for*", pte));
4443  return;
4444  }
4445  }
4446  show_main_page(pte);
4447  refresh_all_favorite(pte);
4448  if (unistimdebug) {
4449  ast_verb(0, "Sending arrow\n");
4450  }
4451  memcpy(buffsend + SIZE_HEADER, packet_send_arrow, sizeof(packet_send_arrow));
4452  send_client(SIZE_HEADER + sizeof(packet_send_arrow), buffsend, pte);
4453  return;
4454 }
static void send_client(int size, const unsigned char *data, struct unistimsession *pte)
Definition: chan_unistim.c:959
static const unsigned char packet_send_s4[]
Definition: chan_unistim.c:551
static const unsigned char packet_send_arrow[]
Definition: chan_unistim.c:633
#define BUFFSEND
Definition: chan_unistim.c:704
static const unsigned char packet_send_s9[]
Definition: chan_unistim.c:594
static const unsigned char packet_send_S7[]
Definition: chan_unistim.c:645
static void show_extension_page(struct unistimsession *pte)
static void send_date_time2(struct unistimsession *pte)
#define SIZE_HEADER
Definition: chan_unistim.c:167
static void refresh_all_favorite(struct unistimsession *pte)
static void send_date_time3(struct unistimsession *pte)
static void send_texttitle(struct unistimsession *pte, const char *text)
static const unsigned char packet_send_Contrast[]
Definition: chan_unistim.c:638
signed char contrast
Definition: chan_unistim.c:419
char macaddr[18]
Definition: chan_unistim.c:472

References ast_verb, autoprovisioning, AUTOPROVISIONING_TN, BUFFSEND, unistim_device::contrast, unistimsession::device, unistim_languages::encoding, FAVNUM, find_language(), unistim_device::language, LED_BAR_OFF, unistimsession::macaddr, NULL, options_languages, packet_send_arrow, packet_send_Contrast, packet_send_s4, packet_send_S7, packet_send_s9, refresh_all_favorite(), send_charset_update(), send_client(), send_date_time2(), send_date_time3(), send_favorite(), send_led_update(), send_no_ring(), send_ping(), send_text(), send_text_status(), send_texttitle(), show_extension_page(), show_main_page(), SIZE_HEADER, unistimsession::state, STATE_MAINPAGE, TEXT_LINE0, TEXT_LINE1, TEXT_LINE2, TEXT_NORMAL, tmp(), unistimdebug, and ustmtext().

Referenced by process_request().

◆ is_key_favorite()

static int is_key_favorite ( struct unistim_device d,
int  fav 
)
static

Definition at line 1352 of file chan_unistim.c.

1353 {
1354  if ((fav < 0) || (fav >= FAVNUM)) {
1355  return 0;
1356  }
1357  if (d->sline[fav]) {
1358  return 0;
1359  }
1360  if (d->softkeynumber[fav][0] == '\0') {
1361  return 0;
1362  }
1363  return 1;
1364 }

References d, and FAVNUM.

Referenced by handle_key_fav(), is_key_line(), and key_favorite().

◆ is_key_line()

static int is_key_line ( struct unistim_device d,
int  fav 
)
static

Definition at line 1366 of file chan_unistim.c.

1367 {
1368  if ((fav < 0) || (fav >= FAVNUM)) {
1369  return 0;
1370  }
1371  if (!d->sline[fav]) {
1372  return 0;
1373  }
1374  if (is_key_favorite(d, fav)) {
1375  return 0;
1376  }
1377  return 1;
1378 }

References d, FAVNUM, and is_key_favorite().

Referenced by get_avail_softkey(), handle_key_fav(), unistim_call(), and unistim_hangup().

◆ key_call()

static void key_call ( struct unistimsession pte,
char  keycode 
)
static

Definition at line 3435 of file chan_unistim.c.

3436 {
3437  struct unistim_subchannel *sub = get_sub(pte->device, SUB_REAL);
3438  struct unistim_subchannel *sub_3way = get_sub(pte->device, SUB_THREEWAY);
3439 
3440  if (!sub) {
3441  return;
3442  }
3443  if ((keycode >= KEY_0) && (keycode <= KEY_SHARP)) {
3444  if (keycode == KEY_SHARP) {
3445  keycode = '#';
3446  } else if (keycode == KEY_STAR) {
3447  keycode = '*';
3448  } else {
3449  keycode -= 0x10;
3450  }
3451  unistim_do_senddigit(pte, keycode);
3452  return;
3453  }
3454  switch (keycode) {
3455  case KEY_FUNC1:
3456  if (sub->owner && ast_channel_state(sub->owner) == AST_STATE_UP) {
3457  if (sub_3way) {
3458  close_call(pte);
3459  }
3460  }
3461  break;
3462  case KEY_FUNC2:
3463  if (sub_3way) {
3464  transfer_cancel_step2(pte);
3465  } else if (ast_channel_state(sub->owner) == AST_STATE_UP) {
3466  transfer_call_step1(pte);
3467  }
3468  break;
3469  case KEY_HANGUP:
3470  case KEY_FUNC4:
3471  if (!sub_3way) {
3472  close_call(pte);
3473  }
3474  break;
3475  case KEY_FAV0:
3476  case KEY_FAV1:
3477  case KEY_FAV2:
3478  case KEY_FAV3:
3479  case KEY_FAV4:
3480  case KEY_FAV5:
3481  handle_key_fav(pte, keycode);
3482  break;
3483  case KEY_HEADPHN:
3484  if (pte->device->output == OUTPUT_HEADPHONE) {
3486  } else {
3488  }
3489  break;
3490  case KEY_LOUDSPK:
3491  if (pte->device->output != OUTPUT_SPEAKER)
3493  else
3495  MUTE_OFF);
3496  break;
3497  case KEY_ONHOLD:
3498  if (!sub) {
3499  if(pte->device->ssub[pte->device->selected]) {
3500  sub = pte->device->ssub[pte->device->selected];
3501  } else {
3502  break;
3503  }
3504  }
3505  if (sub->holding) {
3506  sub_unhold(pte, sub);
3507  } else {
3508  sub_hold(pte, sub);
3509  }
3510  break;
3511  }
3512  return;
3513 }
static void transfer_call_step1(struct unistimsession *pte)
static void handle_key_fav(struct unistimsession *pte, char keycode)
static void close_call(struct unistimsession *pte)
#define OUTPUT_HEADPHONE
Definition: chan_unistim.c:139
static void transfer_cancel_step2(struct unistimsession *pte)
static int unistim_do_senddigit(struct unistimsession *pte, char digit)
ast_channel_state
ast_channel states
Definition: channelstate.h:35
@ AST_STATE_UP
Definition: channelstate.h:42

References AST_STATE_UP, close_call(), unistimsession::device, get_sub(), handle_key_fav(), KEY_0, KEY_FAV0, KEY_FAV1, KEY_FAV2, KEY_FAV3, KEY_FAV4, KEY_FAV5, KEY_FUNC1, KEY_FUNC2, KEY_FUNC4, KEY_HANGUP, KEY_HEADPHN, KEY_LOUDSPK, KEY_ONHOLD, KEY_SHARP, KEY_STAR, MUTE_OFF, unistim_device::output, OUTPUT_HANDSET, OUTPUT_HEADPHONE, OUTPUT_SPEAKER, unistim_device::previous_output, unistim_device::selected, send_select_output(), unistim_device::ssub, sub, sub_hold(), SUB_REAL, SUB_THREEWAY, sub_unhold(), transfer_call_step1(), transfer_cancel_step2(), unistim_do_senddigit(), and unistim_device::volume.

Referenced by process_request().

◆ key_dial_page()

static void key_dial_page ( struct unistimsession pte,
char  keycode 
)
static

Definition at line 3561 of file chan_unistim.c.

3562 {
3564 
3565  pte->device->nextdial = 0;
3566  if (keycode == KEY_FUNC3) {
3567  if (pte->device->size_phone_number <= 1) {
3568  keycode = KEY_FUNC4;
3569  } else {
3570  pte->device->size_phone_number -= 2;
3571  keycode = pte->device->phone_number[pte->device->size_phone_number] + 0x10;
3572  }
3573  }
3574  if (keycode == KEY_SHARP && pte->device->sharp_dial == 1) {
3575  keycode = KEY_FUNC1;
3576  }
3577  if ((keycode >= KEY_0) && (keycode <= KEY_SHARP)) {
3578  int i = pte->device->size_phone_number;
3579 
3580  if (pte->device->size_phone_number == 0) {
3581  send_tone(pte, 0, 0);
3582  }
3583  if (keycode == KEY_SHARP) {
3584  keycode = '#';
3585  } else if (keycode == KEY_STAR) {
3586  keycode = '*';
3587  } else {
3588  keycode -= 0x10;
3589  }
3590  pte->device->phone_number[i] = keycode;
3591  pte->device->size_phone_number++;
3592  pte->device->phone_number[i + 1] = 0;
3593  show_phone_number(pte);
3594 
3595  if (ast_exists_extension(NULL, pte->device->context, pte->device->phone_number, 1, NULL) &&
3597  keycode = KEY_FUNC1;
3598  } else {
3599  if (pte->device->interdigit_timer) {
3601  }
3602  }
3603  }
3604  if (keycode == KEY_FUNC4) {
3605  pte->device->size_phone_number = 0;
3606  show_phone_number(pte);
3607  return;
3608  }
3609 
3610  if (pte->device->call_forward[0] == -1) {
3611  if (keycode == KEY_FUNC1) {
3613  sizeof(pte->device->call_forward));
3614  show_main_page(pte);
3615  } else if ((keycode == KEY_FUNC2) || (keycode == KEY_HANGUP)) {
3616  pte->device->call_forward[0] = '\0';
3619  show_main_page(pte);
3620  }
3621  return;
3622  }
3623  switch (keycode) {
3624  case KEY_FUNC2:
3625  if (ast_strlen_zero(pte->device->redial_number)) {
3626  break;
3627  }
3629  sizeof(pte->device->phone_number));
3630  case KEY_FUNC1:
3631  handle_call_outgoing(pte);
3632  break;
3633  case KEY_HANGUP:
3634  if (sub && sub->owner) {
3635  sub_stop_silence(pte, sub);
3636  send_tone(pte, 0, 0);
3637  ast_queue_unhold(sub->owner);
3638  sub->moh = 0;
3639  sub->subtype = SUB_REAL;
3640  pte->state = STATE_CALL;
3641 
3642  send_text_status(pte, ustmtext(" Transf Hangup", pte));
3643  send_callerid_screen(pte, sub);
3644  } else {
3647  show_main_page(pte);
3648  }
3649  break;
3650  case KEY_FAV0:
3651  case KEY_FAV1:
3652  case KEY_FAV2:
3653  case KEY_FAV3:
3654  case KEY_FAV4:
3655  case KEY_FAV5:
3657  pte->device->selected = -1;
3658  handle_key_fav(pte, keycode);
3659  break;
3660  case KEY_LOUDSPK:
3661  if (pte->device->output == OUTPUT_SPEAKER) {
3662  if (pte->device->receiver_state == STATE_OFFHOOK) {
3664  MUTE_OFF);
3665  } else {
3666  show_main_page(pte);
3667  }
3668  } else {
3670  }
3671  break;
3672  case KEY_HEADPHN:
3673  if (pte->device->output == OUTPUT_HEADPHONE) {
3674  if (pte->device->receiver_state == STATE_OFFHOOK) {
3676  } else {
3677  show_main_page(pte);
3678  }
3679  } else {
3681  }
3682  break;
3683  }
3684  return;
3685 }
#define LED_SPEAKER_OFF
Definition: chan_unistim.c:159
#define LED_HEADPHONE_OFF
Definition: chan_unistim.c:161
int ast_queue_unhold(struct ast_channel *chan)
Queue an unhold frame.
Definition: channel.c:1210
int ast_exists_extension(struct ast_channel *c, const char *context, const char *exten, int priority, const char *callerid)
Determine whether an extension exists.
Definition: pbx.c:4182
int ast_matchmore_extension(struct ast_channel *c, const char *context, const char *exten, int priority, const char *callerid)
Looks to see if adding anything to this extension might match something. (exists ^ canmatch)
Definition: pbx.c:4202
char context[AST_MAX_EXTENSION]
Definition: chan_unistim.c:398

References ast_copy_string(), ast_exists_extension(), ast_matchmore_extension(), ast_queue_unhold(), ast_strlen_zero(), unistim_device::call_forward, unistim_device::context, unistimsession::device, FAV_LINE_ICON, get_sub(), get_tick_count(), handle_call_outgoing(), handle_key_fav(), unistim_device::interdigit_timer, KEY_0, KEY_FAV0, KEY_FAV1, KEY_FAV2, KEY_FAV3, KEY_FAV4, KEY_FAV5, KEY_FUNC1, KEY_FUNC2, KEY_FUNC3, KEY_FUNC4, KEY_HANGUP, KEY_HEADPHN, KEY_LOUDSPK, KEY_SHARP, KEY_STAR, LED_HEADPHONE_OFF, LED_SPEAKER_OFF, MUTE_OFF, unistim_device::nextdial, NULL, unistim_device::output, OUTPUT_HANDSET, OUTPUT_HEADPHONE, OUTPUT_SPEAKER, unistim_device::phone_number, unistim_device::previous_output, unistim_device::receiver_state, unistim_device::redial_number, unistim_device::selected, send_callerid_screen(), send_favorite_selected(), send_led_update(), send_select_output(), send_text_status(), send_tone(), unistim_device::sharp_dial, show_main_page(), show_phone_number(), unistim_device::size_phone_number, unistimsession::state, STATE_CALL, STATE_OFFHOOK, sub, SUB_REAL, sub_stop_silence(), SUB_THREEWAY, ustmtext(), and unistim_device::volume.

Referenced by key_main_page(), and process_request().

◆ key_favorite()

static void key_favorite ( struct unistimsession pte,