Asterisk - The Open Source Telephony Project  GIT-master-9ed6387
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"

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.

Referenced by open_history(), and write_history().

◆ BUFFSEND

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

◆ DEBUG_TIMER

#define DEBUG_TIMER   dummy

Definition at line 241 of file chan_unistim.c.

Referenced by do_monitor(), and set_ping_timer().

◆ DEFAULT_CODEC

#define DEFAULT_CODEC   0x00

Not used

Definition at line 110 of file chan_unistim.c.

Referenced by key_select_extension(), and unistim_register().

◆ DEFAULT_INTERDIGIT_TIMER

#define DEFAULT_INTERDIGIT_TIMER   4000

Timeout value for entered number being dialed

Definition at line 107 of file chan_unistim.c.

Referenced by build_device().

◆ DEFAULTCALLERID

#define DEFAULTCALLERID   "Unknown"

Definition at line 84 of file chan_unistim.c.

Referenced by send_callerid_screen().

◆ DEFAULTCALLERNAME

#define DEFAULTCALLERNAME   " "

Definition at line 85 of file chan_unistim.c.

Referenced by send_callerid_screen().

◆ DEFAULTCONTEXT

#define DEFAULTCONTEXT   "default"

Definition at line 83 of file chan_unistim.c.

Referenced by build_device().

◆ DEFAULTHEIGHT

#define DEFAULTHEIGHT   3

Definition at line 86 of file chan_unistim.c.

Referenced by build_device().

◆ 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.

Referenced by refresh_all_favorite().

◆ FAV_BLINK_FAST

#define FAV_BLINK_FAST   0x20

Definition at line 211 of file chan_unistim.c.

Referenced by unistim_call().

◆ FAV_BLINK_SLOW

#define FAV_BLINK_SLOW   0x40

Definition at line 212 of file chan_unistim.c.

Referenced by show_main_page(), and sub_hold().

◆ 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.

Referenced by show_main_page().

◆ 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.

Referenced by send_select_output().

◆ FAV_ICON_HEADPHONES_ONHOLD

#define FAV_ICON_HEADPHONES_ONHOLD   0x2F

Definition at line 193 of file chan_unistim.c.

Referenced by send_select_output().

◆ 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

◆ FAV_ICON_OFFHOOK_BLACK

#define FAV_ICON_OFFHOOK_BLACK   0x24

◆ 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.

Referenced by send_select_output(), and sub_hold().

◆ 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.

Referenced by handle_dial_page().

◆ 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.

Referenced by show_main_page().

◆ FAV_ICON_SHARP

#define FAV_ICON_SHARP   0x32

Definition at line 196 of file chan_unistim.c.

Referenced by parse_bookmark().

◆ FAV_ICON_SPEAKER_OFFHOOK_BLACK

#define FAV_ICON_SPEAKER_OFFHOOK_BLACK   0x28

Definition at line 186 of file chan_unistim.c.

Referenced by send_select_output().

◆ 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.

Referenced by send_select_output().

◆ 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.

Referenced by send_select_output(), and unistim_call().

◆ FAV_ICON_SPEAKER_ONHOOK_WHITE

#define FAV_ICON_SPEAKER_ONHOOK_WHITE   0x23

Definition at line 181 of file chan_unistim.c.

Referenced by refresh_all_favorite().

◆ 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

◆ FAV_MAX_LENGTH

#define FAV_MAX_LENGTH   0x0A

Definition at line 214 of file chan_unistim.c.

Referenced by send_favorite().

◆ FAVNUM

#define FAVNUM   6

◆ IDLE_WAIT

#define IDLE_WAIT   1000

Nb of milliseconds waited when no events are scheduled

Definition at line 101 of file chan_unistim.c.

Referenced by do_monitor().

◆ LED_BAR_OFF

#define LED_BAR_OFF   0x00 /* bar off */

◆ LED_BAR_ON

#define LED_BAR_ON   0x01 /* bar on */

Definition at line 152 of file chan_unistim.c.

Referenced by unistim_send_mwi_to_peer().

◆ 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.

Referenced by key_dial_page(), send_select_output(), and show_main_page().

◆ LED_HEADPHONE_ON

#define LED_HEADPHONE_ON   0x011

Definition at line 162 of file chan_unistim.c.

Referenced by send_select_output().

◆ 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.

Referenced by microphone_mute_toggle().

◆ LED_MUTE_ON

#define LED_MUTE_ON   0x019

Definition at line 164 of file chan_unistim.c.

Referenced by microphone_mute_toggle().

◆ LED_SPEAKER_OFF

#define LED_SPEAKER_OFF   0x08

Definition at line 159 of file chan_unistim.c.

Referenced by key_dial_page(), send_select_output(), and show_main_page().

◆ LED_SPEAKER_ON

#define LED_SPEAKER_ON   0x09

Definition at line 160 of file chan_unistim.c.

Referenced by send_select_output().

◆ MAX_BUF_NUMBER

#define MAX_BUF_NUMBER   150

Number of slots for the transmit queue

Definition at line 93 of file chan_unistim.c.

Referenced by create_client(), and send_client().

◆ 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.

Referenced by open_history(), and write_history().

◆ MAX_SCREEN_NUMBER

#define MAX_SCREEN_NUMBER   15

Number of digits displayed on screen

Definition at line 95 of file chan_unistim.c.

Referenced by show_phone_number().

◆ MONTH_LABEL_SIZE

#define MONTH_LABEL_SIZE   3

Length of month label size

Definition at line 97 of file chan_unistim.c.

Referenced by send_month_labels().

◆ MUTE_OFF

#define MUTE_OFF   0x00

◆ MUTE_ON

#define MUTE_ON   0xFF

Definition at line 148 of file chan_unistim.c.

Referenced by microphone_mute_toggle(), send_select_output(), and sub_hold().

◆ MUTE_ON_DISCRET

#define MUTE_ON_DISCRET   0xCE

Definition at line 149 of file chan_unistim.c.

Referenced by send_select_output(), and show_main_page().

◆ NB_MAX_RETRANSMIT

#define NB_MAX_RETRANSMIT   8

Try x times before removing the phone

Definition at line 99 of file chan_unistim.c.

Referenced by reload_config(), and send_retransmit().

◆ OUTPUT_HANDSET

#define OUTPUT_HANDSET   0xC0

◆ OUTPUT_HEADPHONE

#define OUTPUT_HEADPHONE   0xC1

◆ OUTPUT_SPEAKER

#define OUTPUT_SPEAKER   0xC2

◆ RETRANSMIT_TIMER

#define RETRANSMIT_TIMER   2000

Wait x milliseconds before resending a packet

Definition at line 103 of file chan_unistim.c.

Referenced by create_client(), reload_config(), send_client(), and send_retransmit().

◆ SELECTCODEC_MAX_LENGTH

#define SELECTCODEC_MAX_LENGTH   2

Definition at line 3730 of file chan_unistim.c.

Referenced by key_select_codec().

◆ SELECTCODEC_MSG

#define SELECTCODEC_MSG   "Codec number : .."

Definition at line 3731 of file chan_unistim.c.

Referenced by handle_select_codec(), and key_select_codec().

◆ SELECTCODEC_START_ENTRY_POS

#define SELECTCODEC_START_ENTRY_POS   15

Definition at line 3729 of file chan_unistim.c.

Referenced by handle_select_codec(), and key_select_codec().

◆ SELECTEXTENSION_MAX_LENGTH

#define SELECTEXTENSION_MAX_LENGTH   10

Definition at line 3874 of file chan_unistim.c.

Referenced by key_select_extension().

◆ SELECTEXTENSION_MSG

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

Definition at line 3875 of file chan_unistim.c.

Referenced by key_select_extension(), and show_extension_page().

◆ SELECTEXTENSION_START_ENTRY_POS

#define SELECTEXTENSION_START_ENTRY_POS   0

Definition at line 3873 of file chan_unistim.c.

Referenced by key_select_extension(), and show_extension_page().

◆ SIZE_HEADER

#define SIZE_HEADER   6

◆ 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.

Referenced by load_module(), and unistimsock_read().

◆ STATUS_LENGTH_MAX

#define STATUS_LENGTH_MAX   28

Definition at line 175 of file chan_unistim.c.

Referenced by send_text_status(), and show_entry_history().

◆ SUB_REAL

#define SUB_REAL   0

◆ SUB_RING

#define SUB_RING   1

◆ SUB_THREEWAY

#define SUB_THREEWAY   2

◆ TEXT_INVERSE

#define TEXT_INVERSE   0x25

Definition at line 174 of file chan_unistim.c.

Referenced by handle_select_codec(), and key_select_codec().

◆ TEXT_LENGTH_MAX

#define TEXT_LENGTH_MAX   24

◆ TEXT_LINE0

#define TEXT_LINE0   0x00

◆ TEXT_LINE1

#define TEXT_LINE1   0x20

◆ TEXT_LINE2

#define TEXT_LINE2   0x40

◆ TEXT_NORMAL

#define TEXT_NORMAL   0x05

◆ TIMER_MWI

#define TIMER_MWI   5000

How often the mailbox is checked for new messages

Definition at line 105 of file chan_unistim.c.

Referenced by unistim_send_mwi_to_peer().

◆ USTM_LANG_DIR

#define USTM_LANG_DIR   "unistimLang"

Definition at line 88 of file chan_unistim.c.

Referenced by ustmtext().

◆ USTM_LOG_DIR

#define USTM_LOG_DIR   "unistimHistory"

Definition at line 87 of file chan_unistim.c.

Referenced by open_history(), and write_history().

◆ 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.

Referenced by build_device(), and send_select_output().

◆ VOLUME_LOW_SPEAKER

#define VOLUME_LOW_SPEAKER   0x03

Definition at line 143 of file chan_unistim.c.

Referenced by send_select_output().

◆ 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 };

◆ autoprovision

Enumerator
AUTOPROVISIONING_NO 
AUTOPROVISIONING_YES 
AUTOPROVISIONING_TN 

Definition at line 122 of file chan_unistim.c.

◆ 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.

◆ handset_state

Enumerator
STATE_ONHOOK 
STATE_OFFHOOK 

Definition at line 290 of file chan_unistim.c.

290  {
291  STATE_ONHOOK,
293 };

◆ 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 };

◆ 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.

Function Documentation

◆ __reg_module()

static void __reg_module ( void  )
static

Definition at line 7208 of file chan_unistim.c.

◆ __unreg_module()

static void __unreg_module ( void  )
static

Definition at line 7208 of file chan_unistim.c.

◆ AST_MODULE_SELF_SYM()

struct ast_module* AST_MODULE_SELF_SYM ( void  )

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

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

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 }
struct ast_channel * owner
Definition: chan_unistim.c:356
Main Channel structure associated with a channel.
enum ast_transfer_result ast_bridge_transfer_attended(struct ast_channel *to_transferee, struct ast_channel *to_transfer_target)
Attended transfer.
Definition: bridge.c:4709
#define ast_channel_unref(c)
Decrease channel reference count.
Definition: channel.h:2873
#define LOG_WARNING
Definition: logger.h:274
#define NULL
Definition: resample.c:96
#define ast_log
Definition: astobj2.c:42
#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:851
int ast_softhangup_nolock(struct ast_channel *chan, int reason)
Softly hangup up a channel (no channel lock)
Definition: channel.c:2438
#define ast_channel_ref(c)
Increase channel reference count.
Definition: channel.h:2862

◆ 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.

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_device::callhistory, unistim_line::cap, unistim_device::context, unistim_device::contrast, unistim_device::country, unistim_device::cwstyle, unistim_device::cwvolume, d, dateformat, unistim_device::datetimeformat, DEFAULT_INTERDIGIT_TIMER, DEFAULTCONTEXT, DEFAULTHEIGHT, delete_device(), devicelock, devices, unistim_device::dtmfduration, unistim_device::extension, EXTENSION_ASK, EXTENSION_LINE, EXTENSION_NONE, unistim_device::extension_number, EXTENSION_TN, FAV_ICON_NONE, FAV_LINE_ICON, find_line_by_number(), unistim_line::fullname, unistim_device::ha, unistim_device::hasexp, unistim_device::height, unistim_device::id, unistim_device::interdigit_timer, unistim_device::language, len(), ast_variable::lineno, unistim_device::lines, unistim_line::list, unistim_line::lock, unistim_device::lock, LOG_ERROR, LOG_WARNING, unistim_line::mailbox, unistim_device::maintext0, unistim_device::maintext1, unistim_device::maintext2, unistim_device::microphone, MUTE_OFF, ast_variable::name, unistim_line::name, unistim_device::name, unistim_device::nat, ast_variable::next, unistim_device::next, NULL, unistim_device::output, OUTPUT_HANDSET, unistim_line::parent, parse_bookmark(), unistim_device::previous_output, unistim_device::ringstyle, unistim_device::ringvolume, unistim_device::rtp_method, unistim_device::rtp_port, unistim_device::selected, unistim_device::sharp_dial, unistim_device::sline, unistim_device::softkeydevice, unistim_device::softkeyicon, unistim_device::softkeylabel, unistim_device::softkeynumber, unistim_device::sp, unistim_device::ssub, unistim_device::status_method, unistim_device::titledefault, ast_tm::tm_zone, unistim_device::to_delete, unistim_device::tz, unistim_line_alloc(), unistim_line_destroy(), unistimdebug, unistimsock, unquote(), ast_variable::value, unistim_device::volume, and VOLUME_LOW.

Referenced by reload_config().

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;
6544  d->volume = VOLUME_LOW;
6545  d->microphone = MUTE_OFF;
6546  d->height = DEFAULTHEIGHT;
6547  d->selected = -1;
6549  } else {
6550  /* Delete existing line information */
6551  AST_LIST_LOCK(&d->lines);
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")) {
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")) {
6679  } else if (!strcasecmp(v->value, "ask")) {
6680  d->extension = EXTENSION_ASK;
6681  } else if (!strcasecmp(v->value, "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;
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;
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 }
char * tm_zone
Definition: localtime.h:46
struct ast_variable * next
struct unistim_device * sp[FAVNUM]
Definition: chan_unistim.c:411
#define AST_LIST_LOCK(head)
Locks a list.
Definition: linkedlists.h:39
char softkeylabel[FAVNUM][11]
Definition: chan_unistim.c:405
static struct unistim_line * unistim_line_alloc(void)
A device containing one or more lines.
Definition: chan_unistim.c:394
char name[DEVICE_NAME_LEN]
Definition: chan_unistim.c:402
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
static struct unistim_line * unistim_line_destroy(struct unistim_line *l)
static int unistimsock
Definition: chan_unistim.c:247
static struct unistim_line * find_line_by_number(struct unistim_device *d, const char *val)
#define LOG_WARNING
Definition: logger.h:274
#define AST_LIST_UNLOCK(head)
Attempts to unlock a list.
Definition: linkedlists.h:139
static struct test_val d
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
static void unquote(char *out, const char *src, int maxlen)
signed char ringvolume
Definition: chan_unistim.c:422
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
Definition: time.h:150
char softkeynumber[FAVNUM][AST_MAX_EXTENSION]
Definition: chan_unistim.c:406
#define ast_mutex_lock(a)
Definition: lock.h:187
#define NULL
Definition: resample.c:96
signed char ringstyle
Definition: chan_unistim.c:423
#define AST_LIST_TRAVERSE_SAFE_END
Closes a safe loop traversal block.
Definition: linkedlists.h:614
#define ast_verb(level,...)
Definition: logger.h:455
#define VOLUME_LOW
Definition: chan_unistim.c:142
static int unistimdebug
Definition: chan_unistim.c:243
struct ast_ha * ha
Definition: chan_unistim.c:453
char name[80]
Definition: chan_unistim.c:374
enum ama_flags ast_channel_string2amaflag(const char *flag)
Convert a string to a detail record AMA flag.
Definition: channel.c:4354
char titledefault[13]
Definition: chan_unistim.c:417
#define MUTE_OFF
Definition: chan_unistim.c:147
static ast_mutex_t devicelock
Definition: chan_unistim.c:273
signed char cwstyle
Definition: chan_unistim.c:425
#define ast_log
Definition: astobj2.c:42
ast_mutex_t lock
Definition: chan_unistim.c:373
#define OUTPUT_HANDSET
Definition: chan_unistim.c:138
signed char to_delete
Definition: chan_unistim.c:449
struct unistim_device * next
Definition: chan_unistim.c:455
#define AST_MAX_EXTENSION
Definition: channel.h:135
#define AST_LIST_REMOVE_CURRENT(field)
Removes the current entry from a list during a traversal.
Definition: linkedlists.h:556
char mailbox[AST_MAX_EXTENSION]
Definition: chan_unistim.c:378
#define FAV_ICON_NONE
Definition: chan_unistim.c:177
signed char cwvolume
Definition: chan_unistim.c:424
char maintext0[25]
Definition: chan_unistim.c:414
ast_group_t ast_get_group(const char *s)
Definition: channel.c:7557
struct ast_tone_zone * tz
Definition: chan_unistim.c:421
#define FAV_LINE_ICON
Definition: chan_unistim.c:218
enum autoprov_extn extension
Definition: chan_unistim.c:447
#define LOG_ERROR
Definition: logger.h:285
#define AST_LIST_INSERT_TAIL(head, elm, field)
Appends a list entry to the tail of a list.
Definition: linkedlists.h:730
int attribute_pure ast_true(const char *val)
Make sure something is true. Determine if a string containing a boolean value is "true". This function checks to see whether a string passed to it is an indication of an "true" value. It checks to see if the string is "yes", "true", "y", "t", "on" or "1".
Definition: main/utils.c:1822
#define DEFAULT_INTERDIGIT_TIMER
Definition: chan_unistim.c:107
struct ast_tone_zone * ast_get_indication_zone(const char *country)
locate ast_tone_zone
Definition: indications.c:433
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
char softkeydevice[FAVNUM][16]
Definition: chan_unistim.c:408
struct unistim_line * sline[FAVNUM]
Definition: chan_unistim.c:410
ast_mutex_t lock
Definition: chan_unistim.c:395
char softkeyicon[FAVNUM]
Definition: chan_unistim.c:407
#define ast_strlen_zero(a)
Definition: muted.c:73
signed char contrast
Definition: chan_unistim.c:419
#define ast_free(a)
Definition: astmm.h:182
#define ast_calloc(num, len)
A wrapper for calloc()
Definition: astmm.h:204
#define DEFAULTHEIGHT
Definition: chan_unistim.c:86
struct unistim_line::@148 list
static struct unistim_device * devices
static int parse_bookmark(const char *text, struct unistim_device *d)
struct ast_format_cap * global_cap
Definition: chan_unistim.c:120
char context[AST_MAX_EXTENSION]
Definition: chan_unistim.c:398
static char dateformat[256]
Definition: logger.c:76
struct unistim_device::@150 lines
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:401
char fullname[101]
Definition: chan_unistim.c:375
static enum autoprovision autoprovisioning
Definition: chan_unistim.c:245
static void delete_device(struct unistim_device *d)
struct unistim_device * parent
Definition: chan_unistim.c:387
char maintext1[25]
Definition: chan_unistim.c:415
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
char language[MAX_LANGUAGE]
Definition: chan_unistim.c:412
#define AST_LIST_TRAVERSE_SAFE_BEGIN(head, var, field)
Loops safely over (traverses) the entries in a list.
Definition: linkedlists.h:528
#define ast_mutex_init(pmutex)
Definition: lock.h:184
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
struct unistim_subchannel * ssub[FAVNUM]
Definition: chan_unistim.c:409
struct ast_format_cap * cap
Definition: chan_unistim.c:384
char extension_number[11]
Definition: chan_unistim.c:448
#define DEFAULTCONTEXT
Definition: chan_unistim.c:83
#define ast_mutex_unlock(a)
Definition: lock.h:188
char maintext2[25]
Definition: chan_unistim.c:416

◆ change_callerid()

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

Definition at line 2472 of file chan_unistim.c.

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

Referenced by close_call(), and send_callerid_screen().

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
char lst_cnm[TEXT_LENGTH_MAX]
Definition: chan_unistim.c:437
#define TEXT_LENGTH_MAX
Definition: chan_unistim.c:169
struct unistim_device * device
Definition: chan_unistim.c:476
char lst_cid[TEXT_LENGTH_MAX]
Definition: chan_unistim.c:436

◆ change_favorite_icon()

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

Definition at line 1418 of file chan_unistim.c.

References d, unistimsession::device, devices, FAVNUM, get_active_softkey(), unistim_device::next, send_favorite(), send_favorite_short(), unistim_device::session, unistim_device::softkeyicon, unistim_device::softkeylabel, unistim_device::sp, unistimsession::state, STATE_CLEANING, and status.

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

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 }
struct unistim_device * sp[FAVNUM]
Definition: chan_unistim.c:411
char softkeylabel[FAVNUM][11]
Definition: chan_unistim.c:405
A device containing one or more lines.
Definition: chan_unistim.c:394
#define FAVNUM
Definition: chan_unistim.c:216
static struct test_val d
struct unistim_device * device
Definition: chan_unistim.c:476
struct unistim_device * next
Definition: chan_unistim.c:455
struct unistimsession * session
Definition: chan_unistim.c:454
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)
char softkeyicon[FAVNUM]
Definition: chan_unistim.c:407
static int get_active_softkey(struct unistimsession *pte)
static struct unistim_device * devices
jack_status_t status
Definition: app_jack.c:146

◆ channel_to_session()

static struct unistimsession* channel_to_session ( struct ast_channel ast)
static

Definition at line 4794 of file chan_unistim.c.

References ast_channel_tech_pvt(), ast_log, ast_mutex_lock, ast_mutex_unlock, unistim_device::lock, LOG_WARNING, NULL, unistim_subchannel::parent, unistim_line::parent, unistim_device::session, and sub.

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

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");
4819  return NULL;
4820  }
4822  return sub->parent->parent->session;
4823 }
void * ast_channel_tech_pvt(const struct ast_channel *chan)
#define LOG_WARNING
Definition: logger.h:274
#define ast_mutex_lock(a)
Definition: lock.h:187
#define NULL
Definition: resample.c:96
#define ast_log
Definition: astobj2.c:42
struct unistimsession * session
Definition: chan_unistim.c:454
ast_mutex_t lock
Definition: chan_unistim.c:395
struct unistim_line * parent
Definition: chan_unistim.c:357
struct unistim_device * parent
Definition: chan_unistim.c:387
struct stasis_forward * sub
Definition: res_corosync.c:240
#define ast_mutex_unlock(a)
Definition: lock.h:188

◆ check_send_queue()

static void check_send_queue ( struct unistimsession pte)
static

Definition at line 1101 of file chan_unistim.c.

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

Referenced by parsing().

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 }
unsigned short seq_server
Definition: chan_unistim.c:464
static void set_ping_timer(struct unistimsession *pte)
#define ast_verb(level,...)
Definition: logger.h:455
unsigned short last_seq_ack
Definition: chan_unistim.c:465
static int unistimdebug
Definition: chan_unistim.c:243

◆ close_call()

static void close_call ( struct unistimsession pte)
static

Definition at line 2599 of file chan_unistim.c.

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_line::name, unistim_device::name, unistim_subchannel::owner, unistim_subchannel::parent, unistim_device::redial_number, send_favorite_short(), send_stop_timer(), show_main_page(), unistim_subchannel::softkey, sub, SUB_REAL, SUB_THREEWAY, and write_history().

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

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  }
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 }
struct ast_channel * owner
Definition: chan_unistim.c:356
int ast_queue_hangup(struct ast_channel *chan)
Queue a hangup frame.
Definition: channel.c:1146
static int write_history(struct unistimsession *pte, char way, char ismissed)
char name[DEVICE_NAME_LEN]
Definition: chan_unistim.c:402
#define LOG_WARNING
Definition: logger.h:274
#define SUB_THREEWAY
Definition: chan_unistim.c:118
static int attempt_transfer(struct unistim_subchannel *p1, struct unistim_subchannel *p2)
#define ast_verb(level,...)
Definition: logger.h:455
int ast_queue_hangup_with_cause(struct ast_channel *chan, int cause)
Queue a hangup frame with hangupcause set.
Definition: channel.c:1162
struct unistim_device * device
Definition: chan_unistim.c:476
char name[80]
Definition: chan_unistim.c:374
#define ast_log
Definition: astobj2.c:42
#define AST_CAUSE_NORMAL_CLEARING
Definition: causes.h:105
#define FAV_LINE_ICON
Definition: chan_unistim.c:218
static void send_favorite_short(unsigned char pos, unsigned char status, struct unistimsession *pte)
static void send_stop_timer(struct unistimsession *pte)
static void show_main_page(struct unistimsession *pte)
static struct unistim_subchannel * get_sub(struct unistim_device *device, int type)
#define SUB_REAL
Definition: chan_unistim.c:116
struct unistim_line * parent
Definition: chan_unistim.c:357
struct stasis_forward * sub
Definition: res_corosync.c:240
static void change_callerid(struct unistimsession *pte, int type, char *callerid)
char redial_number[AST_MAX_EXTENSION]
Definition: chan_unistim.c:400

◆ close_client()

static void close_client ( struct unistimsession s)
static

Definition at line 1470 of file chan_unistim.c.

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_line::name, unistim_device::name, unistimsession::next, NULL, unistim_subchannel::owner, unistim_subchannel::parent, unistim_device::session, sessionlock, sessions, unistimsession::state, STATE_CLEANING, sub, unistim_device::subs, unistim_subchannel::subtype, unistim_free_sub(), unistimdebug, and unregister_extension().

Referenced by parsing(), and send_retransmit().

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);
1493  AST_LIST_TRAVERSE_SAFE_BEGIN(&s->device->subs, sub, list) {
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  }
1507  unistim_free_sub(sub);
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 }
struct ast_channel * owner
Definition: chan_unistim.c:356
static struct unistimsession * sessions
#define AST_LIST_LOCK(head)
Locks a list.
Definition: linkedlists.h:39
char name[DEVICE_NAME_LEN]
Definition: chan_unistim.c:402
#define AST_CAUSE_NETWORK_OUT_OF_ORDER
Definition: causes.h:120
#define LOG_WARNING
Definition: logger.h:274
#define AST_LIST_UNLOCK(head)
Attempts to unlock a list.
Definition: linkedlists.h:139
static void change_favorite_icon(struct unistimsession *pte, unsigned char status)
static int unregister_extension(const struct unistimsession *pte)
#define ast_mutex_lock(a)
Definition: lock.h:187
#define NULL
Definition: resample.c:96
#define AST_LIST_TRAVERSE_SAFE_END
Closes a safe loop traversal block.
Definition: linkedlists.h:614
#define ast_verb(level,...)
Definition: logger.h:455
static ast_mutex_t sessionlock
Definition: chan_unistim.c:271
ast_mutex_t lock
Definition: chan_unistim.c:459
static int unistimdebug
Definition: chan_unistim.c:243
int ast_queue_hangup_with_cause(struct ast_channel *chan, int cause)
Queue a hangup frame with hangupcause set.
Definition: channel.c:1162
struct unistim_device * device
Definition: chan_unistim.c:476
unsigned int subtype
Definition: chan_unistim.c:355
struct unistimsession * next
Definition: chan_unistim.c:477
char name[80]
Definition: chan_unistim.c:374
#define ast_debug(level,...)
Log a DEBUG message.
Definition: logger.h:444
#define ast_log
Definition: astobj2.c:42
struct unistimsession * session
Definition: chan_unistim.c:454
#define AST_LIST_REMOVE_CURRENT(field)
Removes the current entry from a list during a traversal.
Definition: linkedlists.h:556
#define FAV_ICON_NONE
Definition: chan_unistim.c:177
static int unistim_free_sub(struct unistim_subchannel *)
ast_mutex_t lock
Definition: chan_unistim.c:395
#define ast_strlen_zero(a)
Definition: muted.c:73
#define ast_free(a)
Definition: astmm.h:182
struct unistim_line * parent
Definition: chan_unistim.c:357
struct stasis_forward * sub
Definition: res_corosync.c:240
#define AST_LIST_TRAVERSE_SAFE_BEGIN(head, var, field)
Loops safely over (traverses) the entries in a list.
Definition: linkedlists.h:528
#define ast_mutex_destroy(a)
Definition: lock.h:186
char extension_number[11]
Definition: chan_unistim.c:448
struct unistim_device::@149 subs
#define ast_mutex_unlock(a)
Definition: lock.h:188

◆ control2str()

static char* control2str ( int  ind)
static

Definition at line 5279 of file chan_unistim.c.

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

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 }

◆ create_client()

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

Definition at line 1046 of file chan_unistim.c.

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

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 struct unistimsession * sessions
struct sockaddr_in sout
Definition: chan_unistim.c:461
static int unistimsock
Definition: chan_unistim.c:247
struct wsabuf wsabufsend[MAX_BUF_NUMBER]
Definition: chan_unistim.c:474
static int tmp()
Definition: bt_open.c:389
unsigned char buf[MAX_BUF_NUMBER][MAX_BUF_SIZE]
Definition: chan_unistim.c:475
#define ast_mutex_lock(a)
Definition: lock.h:187
#define MAX_BUF_NUMBER
Definition: chan_unistim.c:93
#define NULL
Definition: resample.c:96
#define ast_verb(level,...)
Definition: logger.h:455
static ast_mutex_t sessionlock
Definition: chan_unistim.c:271
ast_mutex_t lock
Definition: chan_unistim.c:459
static int unistimdebug
Definition: chan_unistim.c:243
#define RETRANSMIT_TIMER
Definition: chan_unistim.c:103
struct unistimsession * next
Definition: chan_unistim.c:477
unsigned long tick_next_ping
Definition: chan_unistim.c:466
static int get_to_address(int fd, struct sockaddr_in *toAddr)
static int unistim_keepalive
Definition: chan_unistim.c:246
const char * ast_inet_ntoa(struct in_addr ia)
thread-safe replacement for inet_ntoa().
Definition: main/utils.c:653
#define ast_free(a)
Definition: astmm.h:182
#define ast_calloc(num, len)
A wrapper for calloc()
Definition: astmm.h:204
struct sockaddr_in sin
Definition: chan_unistim.c:460
unsigned char * buf
Definition: chan_unistim.c:350
static unsigned int get_tick_count(void)
Definition: chan_unistim.c:895
#define ast_mutex_init(pmutex)
Definition: lock.h:184
#define ast_mutex_unlock(a)
Definition: lock.h:188

◆ delete_device()

static void delete_device ( struct unistim_device d)
static

Definition at line 6422 of file chan_unistim.c.

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, devices, unistim_device::lines, unistim_subchannel::lock, unistim_line::lock, unistim_device::lock, unistimsession::lock, LOG_WARNING, unistim_device::name, unistim_device::next, unistimsession::next, unistim_subchannel::owner, unistim_device::session, sessions, sub, SUB_REAL, SUB_THREEWAY, unistim_device::subs, unistim_subchannel::subtype, unistim_device::tz, unistim_line_destroy(), and unistimdebug.

Referenced by build_device(), and reload_config().

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  }
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 }
ast_mutex_t lock
Definition: chan_unistim.c:354
struct ast_channel * owner
Definition: chan_unistim.c:356
static struct unistimsession * sessions
#define AST_LIST_LOCK(head)
Locks a list.
Definition: linkedlists.h:39
A device containing one or more lines.
Definition: chan_unistim.c:394
char name[DEVICE_NAME_LEN]
Definition: chan_unistim.c:402
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
static struct unistim_line * unistim_line_destroy(struct unistim_line *l)
#define LOG_WARNING
Definition: logger.h:274
#define AST_LIST_UNLOCK(head)
Attempts to unlock a list.
Definition: linkedlists.h:139
#define SUB_THREEWAY
Definition: chan_unistim.c:118
#define AST_LIST_TRAVERSE_SAFE_END
Closes a safe loop traversal block.
Definition: linkedlists.h:614
#define ast_verb(level,...)
Definition: logger.h:455
ast_mutex_t lock
Definition: chan_unistim.c:459
static int unistimdebug
Definition: chan_unistim.c:243
unsigned int subtype
Definition: chan_unistim.c:355
struct unistimsession * next
Definition: chan_unistim.c:477
#define ast_log
Definition: astobj2.c:42
ast_mutex_t lock
Definition: chan_unistim.c:373
struct unistim_device * next
Definition: chan_unistim.c:455
struct unistimsession * session
Definition: chan_unistim.c:454
#define AST_LIST_REMOVE_CURRENT(field)
Removes the current entry from a list during a traversal.
Definition: linkedlists.h:556
struct ast_tone_zone * tz
Definition: chan_unistim.c:421
ast_mutex_t lock
Definition: chan_unistim.c:395
#define ast_free(a)
Definition: astmm.h:182
static struct unistim_device * devices
#define SUB_REAL
Definition: chan_unistim.c:116
struct unistim_device::@150 lines
struct stasis_forward * sub
Definition: res_corosync.c:240
#define AST_LIST_TRAVERSE_SAFE_BEGIN(head, var, field)
Loops safely over (traverses) the entries in a list.
Definition: linkedlists.h:528
#define ast_mutex_destroy(a)
Definition: lock.h:186
struct unistim_device::@149 subs

◆ discard_call()

static void discard_call ( struct unistimsession pte)
static

Definition at line 2647 of file chan_unistim.c.

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

Referenced by key_ringing().

2648 {
2649  struct unistim_subchannel* sub;
2650  sub = get_sub(pte->device, SUB_RING);
2651  if (!sub) {
2652  return;
2653  }
2654 
2656  return;
2657 }
struct ast_channel * owner
Definition: chan_unistim.c:356
#define SUB_RING
Definition: chan_unistim.c:117
int ast_queue_hangup_with_cause(struct ast_channel *chan, int cause)
Queue a hangup frame with hangupcause set.
Definition: channel.c:1162
struct unistim_device * device
Definition: chan_unistim.c:476
#define AST_CAUSE_NORMAL_CLEARING
Definition: causes.h:105
static struct unistim_subchannel * get_sub(struct unistim_device *device, int type)
struct stasis_forward * sub
Definition: res_corosync.c:240

◆ display_last_error()

static void display_last_error ( const char *  sz_msg)
static

Definition at line 889 of file chan_unistim.c.

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

890 {
891  /* Display the error message */
892  ast_log(LOG_WARNING, "%s : (%d) %s\n", sz_msg, errno, strerror(errno));
893 }
#define LOG_WARNING
Definition: logger.h:274
#define ast_log
Definition: astobj2.c:42
int errno

◆ do_monitor()

static void* do_monitor ( void *  data)
static

Definition at line 5835 of file chan_unistim.c.

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, 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().

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 }
int ast_io_wait(struct io_context *ioc, int howlong)
Waits for IO.
Definition: io.c:278
static struct unistimsession * sessions
#define AST_LIST_LOCK(head)
Locks a list.
Definition: linkedlists.h:39
static int unistimsock
Definition: chan_unistim.c:247
static int send_retransmit(struct unistimsession *pte)
#define AST_LIST_UNLOCK(head)
Attempts to unlock a list.
Definition: linkedlists.h:139
static struct io_context * io
Definition: chan_unistim.c:256
static void send_ping(struct unistimsession *pte)
Definition: chan_unistim.c:991
#define DEBUG_TIMER
Definition: chan_unistim.c:241
#define AST_IO_IN
Definition: io.h:34
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 IDLE_WAIT
Definition: chan_unistim.c:101
#define ast_mutex_lock(a)
Definition: lock.h:187
#define NULL
Definition: resample.c:96
#define ast_verb(level,...)
Definition: logger.h:455
static ast_mutex_t sessionlock
Definition: chan_unistim.c:271
struct unistim_device * device
Definition: chan_unistim.c:476
struct unistimsession * next
Definition: chan_unistim.c:477
static int reload_config(void)
char mailbox[AST_MAX_EXTENSION]
Definition: chan_unistim.c:378
time_t nextmsgcheck
Definition: chan_unistim.c:445
#define AST_LIST_TRAVERSE(head, var, field)
Loops over (traverses) the entries in a list.
Definition: linkedlists.h:490
#define ast_strlen_zero(a)
Definition: muted.c:73
static int unistim_send_mwi_to_peer(struct unistim_line *peer, unsigned int tick)
static void handle_call_outgoing(struct unistimsession *s)
struct unistim_line::@148 list
static int unistim_reloading
Definition: chan_unistim.c:260
struct unistim_device::@150 lines
struct unistim_device * parent
Definition: chan_unistim.c:387
static unsigned int get_tick_count(void)
Definition: chan_unistim.c:895
static int unistimsock_read(int *id, int fd, short events, void *ignore)
static ast_mutex_t unistim_reload_lock
Definition: chan_unistim.c:261
#define ast_mutex_unlock(a)
Definition: lock.h:188

◆ 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.

References NULL.

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

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
#define NULL
Definition: resample.c:96

◆ 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.

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

Referenced by build_device().

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 }
#define AST_LIST_LOCK(head)
Locks a list.
Definition: linkedlists.h:39
Definition: ast_expr2.c:325
#define AST_LIST_UNLOCK(head)
Attempts to unlock a list.
Definition: linkedlists.h:139
#define NULL
Definition: resample.c:96
char name[80]
Definition: chan_unistim.c:374
#define AST_LIST_TRAVERSE(head, var, field)
Loops over (traverses) the entries in a list.
Definition: linkedlists.h:490
struct unistim_line::@148 list
struct unistim_device::@150 lines

◆ find_rtp_port()

static int find_rtp_port ( struct unistim_subchannel s)
static

Definition at line 2685 of file chan_unistim.c.

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_subchannel::rtp, unistim_device::rtp_port, sub, and unistim_device::subs.

Referenced by start_rtp().

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_LIST_LOCK(head)
Locks a list.
Definition: linkedlists.h:39
struct ast_rtp_instance * rtp
Definition: chan_unistim.c:358
#define AST_LIST_UNLOCK(head)
Attempts to unlock a list.
Definition: linkedlists.h:139
#define NULL
Definition: resample.c:96
Socket address structure.
Definition: netsock2.h:97
#define AST_LIST_TRAVERSE(head, var, field)
Loops over (traverses) the entries in a list.
Definition: linkedlists.h:490
struct unistim_line * parent
Definition: chan_unistim.c:357
struct unistim_device * parent
Definition: chan_unistim.c:387
struct stasis_forward * sub
Definition: res_corosync.c:240
#define ast_sockaddr_to_sin(addr, sin)
Converts a struct ast_sockaddr to a struct sockaddr_in.
Definition: netsock2.h:769
#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:1191
struct unistim_device::@149 subs

◆ 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.

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::holding, unistim_device::lines, unistim_subchannel::list, LOG_NOTICE, LOG_WARNING, unistim_line::name, unistim_device::name, unistim_device::next, NULL, unistim_subchannel::owner, unistim_subchannel::parent, unistim_subchannel::ringstyle, unistim_subchannel::ringvolume, sub, SUB_REAL, unistim_alloc_sub(), and unistimdebug.

Referenced by unistim_request(), and unistim_sp().

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) {
5460  sub = unistim_alloc_sub(d, SUB_REAL);
5461  }
5462  if (sub->owner) {
5463  /* Allocate additional channel if asterisk channel already here */
5464  sub = unistim_alloc_sub(d, SUB_REAL);
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 }
struct ast_channel * owner
Definition: chan_unistim.c:356
#define AST_LIST_LOCK(head)
Locks a list.
Definition: linkedlists.h:39
A device containing one or more lines.
Definition: chan_unistim.c:394
char name[DEVICE_NAME_LEN]
Definition: chan_unistim.c:402
signed char ringvolume
Definition: chan_unistim.c:363
signed char ringstyle
Definition: chan_unistim.c:364
#define LOG_WARNING
Definition: logger.h:274
#define AST_LIST_UNLOCK(head)
Attempts to unlock a list.
Definition: linkedlists.h:139
static struct test_val d
struct unistim_subchannel::@147 list
#define ast_mutex_lock(a)
Definition: lock.h:187
#define NULL
Definition: resample.c:96
#define ast_verb(level,...)
Definition: logger.h:455
static int unistimdebug
Definition: chan_unistim.c:243
char name[80]
Definition: chan_unistim.c:374
static ast_mutex_t devicelock
Definition: chan_unistim.c:273
#define ast_log
Definition: astobj2.c:42
static struct unistim_subchannel * unistim_alloc_sub(struct unistim_device *d, int x)
struct unistim_device * next
Definition: chan_unistim.c:455
#define LOG_NOTICE
Definition: logger.h:263
#define AST_LIST_TRAVERSE(head, var, field)
Loops over (traverses) the entries in a list.
Definition: linkedlists.h:490
static struct unistim_device * devices
static struct unistim_subchannel * get_sub(struct unistim_device *device, int type)
#define SUB_REAL
Definition: chan_unistim.c:116
struct unistim_device::@150 lines
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:401
struct unistim_line * parent
Definition: chan_unistim.c:357
struct stasis_forward * sub
Definition: res_corosync.c:240
#define ast_mutex_unlock(a)
Definition: lock.h:188

◆ finish_bookmark()

static void finish_bookmark ( void  )
static

Definition at line 6380 of file chan_unistim.c.

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

Referenced by reload_config().

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 }
struct unistim_device * sp[FAVNUM]
Definition: chan_unistim.c:411
A device containing one or more lines.
Definition: chan_unistim.c:394
char name[DEVICE_NAME_LEN]
Definition: chan_unistim.c:402
static struct test_val d
#define ast_mutex_lock(a)
Definition: lock.h:187
#define NULL
Definition: resample.c:96
static ast_mutex_t devicelock
Definition: chan_unistim.c:273
#define ast_log
Definition: astobj2.c:42
struct unistim_device * next
Definition: chan_unistim.c:455
char softkeydevice[FAVNUM][16]
Definition: chan_unistim.c:408
char softkeyicon[FAVNUM]
Definition: chan_unistim.c:407
#define LOG_NOTICE
Definition: logger.h:263
static struct unistim_device * devices
#define ast_mutex_unlock(a)
Definition: lock.h:188

◆ get_active_softkey()

static int get_active_softkey ( struct unistimsession pte)
static

Definition at line 1380 of file chan_unistim.c.

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

Referenced by change_favorite_icon().

1381 {
1382  return pte->device->selected;
1383 }
struct unistim_device * device
Definition: chan_unistim.c:476

◆ get_avail_softkey()

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

Definition at line 1385 of file chan_unistim.c.

References ast_verb, unistimsession::device, FAVNUM, is_key_line(), unistim_line::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().

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 soft_key_visible(struct unistim_device *d, unsigned char num)
#define FAVNUM
Definition: chan_unistim.c:216
#define ast_verb(level,...)
Definition: logger.h:455
static int unistimdebug
Definition: chan_unistim.c:243
struct unistim_device * device
Definition: chan_unistim.c:476
char name[80]
Definition: chan_unistim.c:374
struct unistim_line * sline[FAVNUM]
Definition: chan_unistim.c:410
static const char name[]
Definition: cdr_mysql.c:74
struct unistim_subchannel * ssub[FAVNUM]
Definition: chan_unistim.c:409
static int is_key_line(struct unistim_device *d, int fav)

◆ get_sub()

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

Definition at line 2493 of file chan_unistim.c.

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

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

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 }
static const char type[]
Definition: chan_ooh323.c:109
#define AST_LIST_LOCK(head)
Locks a list.
Definition: linkedlists.h:39
#define AST_LIST_UNLOCK(head)
Attempts to unlock a list.
Definition: linkedlists.h:139
struct unistim_subchannel::@147 list
#define NULL
Definition: resample.c:96
unsigned int subtype
Definition: chan_unistim.c:355
#define AST_LIST_TRAVERSE(head, var, field)
Loops over (traverses) the entries in a list.
Definition: linkedlists.h:490
struct stasis_forward * sub
Definition: res_corosync.c:240
struct unistim_device::@149 subs

◆ 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.

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

Referenced by handle_key_fav().

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 }
static const char type[]
Definition: chan_ooh323.c:109
#define AST_LIST_LOCK(head)
Locks a list.
Definition: linkedlists.h:39
#define AST_LIST_UNLOCK(head)
Attempts to unlock a list.
Definition: linkedlists.h:139
struct unistim_subchannel::@147 list
#define NULL
Definition: resample.c:96
unsigned int subtype
Definition: chan_unistim.c:355
#define AST_LIST_TRAVERSE(head, var, field)
Loops over (traverses) the entries in a list.
Definition: linkedlists.h:490
struct stasis_forward * sub
Definition: res_corosync.c:240
struct unistim_device::@149 subs

◆ get_tick_count()

static unsigned int get_tick_count ( void  )
static

Definition at line 895 of file chan_unistim.c.

References ast_tvnow().

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

896 {
897  struct timeval now = ast_tvnow();
898 
899  return (now.tv_sec * 1000) + (now.tv_usec / 1000);
900 }
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
Definition: time.h:150

◆ get_to_address()

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

Definition at line 1002 of file chan_unistim.c.

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

Referenced by create_client().

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 }
#define LOG_WARNING
Definition: logger.h:274
#define NULL
Definition: resample.c:96
#define ast_verb(level,...)
Definition: logger.h:455
static int unistimdebug
Definition: chan_unistim.c:243
#define ast_log
Definition: astobj2.c:42
static struct sockaddr_in public_ip
Definition: chan_unistim.c:258
int errno
const char * ast_inet_ntoa(struct in_addr ia)
thread-safe replacement for inet_ntoa().
Definition: main/utils.c:653

◆ handle_call_incoming()

static void handle_call_incoming ( struct unistimsession s)
static

Definition at line 3262 of file chan_unistim.c.

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_line::name, unistim_device::name, NULL, unistim_device::output, OUTPUT_HANDSET, OUTPUT_SPEAKER, unistim_subchannel::owner, unistim_subchannel::parent, unistim_device::receiver_state, unistim_subchannel::rtp, send_favorite_short(), send_no_ring(), send_select_output(), send_start_timer(), send_text(), send_text_status(), unistim_device::sline, unistim_subchannel::softkey, 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().

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 }
struct ast_channel * owner
Definition: chan_unistim.c:356
static int write_history(struct unistimsession *pte, char way, char ismissed)
int ast_queue_control(struct ast_channel *chan, enum ast_control_frame_type control)
Queue a control frame without payload.
Definition: channel.c:1227
char name[DEVICE_NAME_LEN]
Definition: chan_unistim.c:402
#define TEXT_LINE2
Definition: chan_unistim.c:172
struct ast_rtp_instance * rtp
Definition: chan_unistim.c:358
#define FAVNUM
Definition: chan_unistim.c:216
#define LOG_WARNING
Definition: logger.h:274
#define SUB_RING
Definition: chan_unistim.c:117
static void sub_hold(struct unistimsession *pte, struct unistim_subchannel *sub)
static void send_select_output(struct unistimsession *pte, unsigned char output, unsigned char volume, unsigned char mute)
#define NULL
Definition: resample.c:96
#define TEXT_NORMAL
Definition: chan_unistim.c:173
static const char * ustmtext(const char *str, struct unistimsession *pte)
Definition: chan_unistim.c:800
#define ast_verb(level,...)
Definition: logger.h:455
static int unistimdebug
Definition: chan_unistim.c:243
struct unistim_device * device
Definition: chan_unistim.c:476
unsigned int subtype
Definition: chan_unistim.c:355
char name[80]
Definition: chan_unistim.c:374
#define MUTE_OFF
Definition: chan_unistim.c:147
static void start_rtp(struct unistim_subchannel *sub)
#define ast_log
Definition: astobj2.c:42
#define OUTPUT_HANDSET
Definition: chan_unistim.c:138
#define FAV_LINE_ICON
Definition: chan_unistim.c:218
static void send_favorite_short(unsigned char pos, unsigned char status, struct unistimsession *pte)
static void send_text_status(struct unistimsession *pte, const char *text)
struct unistim_line * sline[FAVNUM]
Definition: chan_unistim.c:410
static struct unistim_subchannel * get_sub(struct unistim_device *device, int type)
static void send_text(unsigned char pos, unsigned char inverse, struct unistimsession *pte, const char *text)
#define SUB_REAL
Definition: chan_unistim.c:116
static void send_no_ring(struct unistimsession *pte)
struct unistim_line * parent
Definition: chan_unistim.c:357
#define OUTPUT_SPEAKER
Definition: chan_unistim.c:140
struct stasis_forward * sub
Definition: res_corosync.c:240
static void send_start_timer(struct unistimsession *pte)
struct unistim_subchannel * ssub[FAVNUM]
Definition: chan_unistim.c:409
#define FAV_ICON_OFFHOOK_BLACK
Definition: chan_unistim.c:182

◆ handle_call_outgoing()

static void handle_call_outgoing ( struct unistimsession s)
static

Definition at line 3111 of file chan_unistim.c.

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_line::name, unistim_device::name, NULL, unistim_device::output, unistim_subchannel::owner, unistim_subchannel::parent, unistim_device::phone_number, RAII_VAR, unistim_subchannel::rtp, 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_subchannel::ss_thread, 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().

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 behaviuor */
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);
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) {
3205  ast_channel_lock(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  }
3213  ast_channel_unlock(c);
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");
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 }
struct ast_channel * owner
Definition: chan_unistim.c:356
#define ast_channel_lock(chan)
Definition: channel.h:2837
Main Channel structure associated with a channel.
struct ast_features_pickup_config * ast_get_chan_features_pickup_config(struct ast_channel *chan)
Get the pickup configuration options for a channel.
A device containing one or more lines.
Definition: chan_unistim.c:394
char name[DEVICE_NAME_LEN]
Definition: chan_unistim.c:402
#define TEXT_LINE2
Definition: chan_unistim.c:172
static struct ast_channel * unistim_new(struct unistim_subchannel *sub, int state, const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor)
struct ast_rtp_instance * rtp
Definition: chan_unistim.c:358
#define AST_CAUSE_SWITCH_CONGESTION
Definition: causes.h:122
void ast_channel_hangupcause_set(struct ast_channel *chan, int value)
#define TEXT_LINE1
Definition: chan_unistim.c:171
#define LOG_WARNING
Definition: logger.h:274
static void sub_hold(struct unistimsession *pte, struct unistim_subchannel *sub)
char phone_number[AST_MAX_EXTENSION]
Definition: chan_unistim.c:399
static struct test_val d
#define SUB_THREEWAY
Definition: chan_unistim.c:118
static void swap_subs(struct unistim_subchannel *a, struct unistim_subchannel *b)
static void send_select_output(struct unistimsession *pte, unsigned char output, unsigned char volume, unsigned char mute)
static struct test_val c
#define NULL
Definition: resample.c:96
#define TEXT_NORMAL
Definition: chan_unistim.c:173
static void * unistim_ss(void *data)
static const char * ustmtext(const char *str, struct unistimsession *pte)
Definition: chan_unistim.c:800
#define ast_verb(level,...)
Definition: logger.h:455
static int unistimdebug
Definition: chan_unistim.c:243
int ast_queue_hangup_with_cause(struct ast_channel *chan, int cause)
Queue a hangup frame with hangupcause set.
Definition: channel.c:1162
struct unistim_device * device
Definition: chan_unistim.c:476
unsigned int subtype
Definition: chan_unistim.c:355
char name[80]
Definition: chan_unistim.c:374
static void send_tone(struct unistimsession *pte, uint16_t tone1, uint16_t tone2)
#define MUTE_OFF
Definition: chan_unistim.c:147
static void start_rtp(struct unistim_subchannel *sub)
#define ast_debug(level,...)
Log a DEBUG message.
Definition: logger.h:444
#define ast_log
Definition: astobj2.c:42
#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:851
#define AST_PTHREADT_NULL
Definition: lock.h:66
static struct unistim_subchannel * unistim_alloc_sub(struct unistim_device *d, int x)
#define AST_CAUSE_NORMAL_CLEARING
Definition: causes.h:105
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: astmm.h:300
static int get_avail_softkey(struct unistimsession *pte, const char *name)
#define TEXT_LINE0
Definition: chan_unistim.c:170
static void send_favorite_short(unsigned char pos, unsigned char status, struct unistimsession *pte)
#define LOG_ERROR
Definition: logger.h:285
static void send_text_status(struct unistimsession *pte, const char *text)
int ast_pickup_call(struct ast_channel *chan)
Pickup a call.
Definition: pickup.c:200
struct unistim_line * sline[FAVNUM]
Definition: chan_unistim.c:410
#define LOG_NOTICE
Definition: logger.h:263
#define ast_channel_unlock(chan)
Definition: channel.h:2838
#define ast_pthread_create(a, b, c, d)
Definition: utils.h:499
void ast_hangup(struct ast_channel *chan)
Hang up a channel.
Definition: channel.c:2523
static struct unistim_subchannel * get_sub(struct unistim_device *device, int type)
static void send_text(unsigned char pos, unsigned char inverse, struct unistimsession *pte, const char *text)
#define SUB_REAL
Definition: chan_unistim.c:116
#define ao2_cleanup(obj)
Definition: astobj2.h:1958
struct unistim_line * parent
Definition: chan_unistim.c:357
const char * ast_channel_name(const struct ast_channel *chan)
struct stasis_forward * sub
Definition: res_corosync.c:240
static void send_start_timer(struct unistimsession *pte)
struct unistim_subchannel * ssub[FAVNUM]
Definition: chan_unistim.c:409
#define AST_CAUSE_CALL_REJECTED
Definition: causes.h:110
static void sub_stop_silence(struct unistimsession *pte, struct unistim_subchannel *sub)
#define FAV_ICON_OFFHOOK_BLACK
Definition: chan_unistim.c:182
Configuration relating to call pickup.

◆ handle_dial_page()

static void handle_dial_page ( struct unistimsession pte)
static

Definition at line 2983 of file chan_unistim.c.

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

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 }
char call_forward[AST_MAX_EXTENSION]
Definition: chan_unistim.c:438
static void send_dial_tone(struct unistimsession *pte)
#define TEXT_LINE1
Definition: chan_unistim.c:171
char phone_number[AST_MAX_EXTENSION]
Definition: chan_unistim.c:399
static void change_favorite_icon(struct unistimsession *pte, unsigned char status)
static void send_select_output(struct unistimsession *pte, unsigned char output, unsigned char volume, unsigned char mute)
#define TEXT_NORMAL
Definition: chan_unistim.c:173
static const char * ustmtext(const char *str, struct unistimsession *pte)
Definition: chan_unistim.c:800
struct unistim_device * device
Definition: chan_unistim.c:476
static void send_icon(unsigned char pos, unsigned char status, struct unistimsession *pte)
#define MUTE_OFF
Definition: chan_unistim.c:147
#define FAV_ICON_PHONE_BLACK
Definition: chan_unistim.c:188
#define OUTPUT_HANDSET
Definition: chan_unistim.c:138
#define FAV_ICON_NONE
Definition: chan_unistim.c:177
static void show_phone_number(struct unistimsession *pte)
#define TEXT_LINE0
Definition: chan_unistim.c:170
static void send_text_status(struct unistimsession *pte, const char *text)
#define ast_strlen_zero(a)
Definition: muted.c:73
static void send_led_update(struct unistimsession *pte, unsigned char led)
static void send_text(unsigned char pos, unsigned char inverse, struct unistimsession *pte, const char *text)
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:401
#define OUTPUT_SPEAKER
Definition: chan_unistim.c:140
#define LED_BAR_OFF
Definition: chan_unistim.c:151
char redial_number[AST_MAX_EXTENSION]
Definition: chan_unistim.c:400

◆ handle_key_fav()

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

Definition at line 3380 of file chan_unistim.c.

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

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