Wed Jan 8 2020 09:50:08

Asterisk developer's documentation


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/event.h"
#include "asterisk/rtp_engine.h"
#include "asterisk/netsock.h"
#include "asterisk/acl.h"
#include "asterisk/callerid.h"
#include "asterisk/cli.h"
#include "asterisk/app.h"
#include "asterisk/musiconhold.h"
#include "asterisk/causes.h"
#include "asterisk/indications.h"

Go to the source code of this file.

Data Structures

struct  systemtime
 
struct  tone_zone_unistim
 
struct  unistim_device
 A device containing one or more lines. More...
 
struct  unistim_line
 
struct  unistim_subchannel
 
struct  unistimsession
 
struct  wsabuf
 

Macros

#define AST_CONFIG_MAX_PATH   255
 
#define BUFFSEND   unsigned char buffsend[64] = { 0x00, 0x00, 0xaa, 0xbb, 0x02, 0x01 }
 
#define CAPABILITY   AST_FORMAT_ALAW | AST_FORMAT_ULAW /* | AST_FORMAT_G729A | AST_FORMAT_G723_1 */
 
#define DEBUG_TIMER   dummy
 
#define DEFAULT_CODEC   0x00
 
#define DEFAULTCALLERID   "Unknown"
 
#define DEFAULTCALLERNAME   " "
 
#define DEFAULTCONTEXT   "default"
 
#define DEFAULTHEIGHT   3
 
#define DEVICE_NAME_LEN   16
 
#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_MAX_LENGTH   0x0A
 
#define IDLE_WAIT   1000
 
#define MAX_BUF_NUMBER   50
 
#define MAX_BUF_SIZE   64
 
#define MAX_ENTRY_LOG   30
 
#define MAX_SUBS   2
 
#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_THREEWAY   1
 
#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   10000
 
#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_DB, AUTOPROVISIONING_TN }
 
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_SELECTCODEC,
  STATE_CLEANING, STATE_HISTORY
}
 

Functions

static void __reg_module (void)
 
static void __unreg_module (void)
 
static int alloc_sub (struct unistim_line *l, int x)
 
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 cancel_dial (struct unistimsession *pte)
 
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 display_last_error (const char *sz_msg)
 
static void * do_monitor (void *data)
 
static void dummy (char *unused,...)
 
static struct unistim_subchannelfind_subchannel_by_name (const char *dest)
 
static void finish_bookmark (void)
 
static unsigned int get_tick_count (void)
 
static int get_to_address (int fd, struct sockaddr_in *toAddr)
 
static void handle_dial_page (struct unistimsession *pte)
 
static void HandleCallIncoming (struct unistimsession *s)
 
static void HandleCallOutgoing (struct unistimsession *s)
 
static void HandleSelectCodec (struct unistimsession *pte)
 
static void IgnoreCall (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 void key_call (struct unistimsession *pte, char keycode)
 
static void key_dial_page (struct unistimsession *pte, char keycode)
 
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 Keyfavorite (struct unistimsession *pte, char keycode)
 
static int load_module (void)
 
static char OpenHistory (struct unistimsession *pte, char way, FILE **f)
 
static int ParseBookmark (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 void rcv_mac_addr (struct unistimsession *pte, const unsigned char *buf)
 
static void rcv_resume_connection_with_server (struct unistimsession *pte)
 
static int ReformatNumber (char *number)
 
static void refresh_all_favorite (struct unistimsession *pte)
 
static int RegisterExtension (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_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_end_call (struct unistimsession *pte)
 
static void send_favorite (unsigned char pos, unsigned char status, struct unistimsession *pte, const char *text)
 
static void send_led_update (struct unistimsession *pte, unsigned char led)
 
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, char volume, char style)
 
static void send_select_output (struct unistimsession *pte, unsigned char output, unsigned char volume, unsigned char mute)
 
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 SendDialTone (struct unistimsession *pte)
 
static void Sendicon (unsigned char pos, unsigned char status, struct unistimsession *pte)
 
static void set_ping_timer (struct unistimsession *pte)
 
static void show_entry_history (struct unistimsession *pte, FILE **f)
 
static void show_history (struct unistimsession *pte, char way)
 
static void show_main_page (struct unistimsession *pte)
 
static void ShowExtensionPage (struct unistimsession *pte)
 
static void start_rtp (struct unistim_subchannel *sub)
 
static void swap_subs (struct unistim_line *p, int a, int b)
 
static void TransferCallStep1 (struct unistimsession *pte)
 
static int unalloc_sub (struct unistim_line *p, int x)
 
static int unistim_answer (struct ast_channel *ast)
 
static int unistim_call (struct ast_channel *ast, 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 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_indicate (struct ast_channel *ast, int ind, const void *data, size_t datalen)
 
static char * unistim_info (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 
static struct ast_channelunistim_new (struct unistim_subchannel *sub, int state, const char *linkedid)
 
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, format_t format, const struct ast_channel *requestor, void *data, 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 unistimsession *s, 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 int unistim_set_rtp_peer (struct ast_channel *chan, struct ast_rtp_instance *rtp, struct ast_rtp_instance *vrtp, struct ast_rtp_instance *trtp, format_t codecs, int nat_active)
 
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_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 UnregisterExtension (const 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 = "ac1f6a56484a8820659555499174e588" , .load = load_module, .unload = unload_module, .reload = reload, }
 
static struct sockaddr_in address_from
 
static 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 }
 
static struct unistim_devicedevices = NULL
 
static struct tone_zone_unistim frequency []
 
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 }
 
static const unsigned char packet_rcv_discovery []
 
static const unsigned char packet_recv_firm_version []
 
static const unsigned char packet_recv_hangup []
 
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_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_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 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_StartTimer []
 
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_dial_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 sched_contextsched
 
static ast_mutex_t sessionlock = { PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP , NULL, 1 }
 
static struct unistimsessionsessions = NULL
 
static unsigned int size_addr_from = sizeof(address_from)
 
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 }
 
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 int usecnt = 0
 
static ast_mutex_t usecnt_lock = { PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP , NULL, 1 }
 

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

#define AST_CONFIG_MAX_PATH   255

Definition at line 102 of file chan_unistim.c.

Referenced by OpenHistory(), and write_history().

Beware, G729 and G723 are not supported by asterisk, except with the proper licence

Definition at line 78 of file chan_unistim.c.

Referenced by build_device(), unistim_new(), and unistim_request().

#define DEBUG_TIMER   dummy

Definition at line 209 of file chan_unistim.c.

Referenced by do_monitor(), and set_ping_timer().

#define DEFAULT_CODEC   0x00

Not used

Definition at line 99 of file chan_unistim.c.

Referenced by key_select_extension(), and unistim_register().

#define DEFAULTCALLERID   "Unknown"

Definition at line 81 of file chan_unistim.c.

Referenced by unistim_call().

#define DEFAULTCALLERNAME   " "

Definition at line 82 of file chan_unistim.c.

Referenced by unistim_call().

#define DEFAULTCONTEXT   "default"

Definition at line 80 of file chan_unistim.c.

Referenced by build_device().

#define DEFAULTHEIGHT   3

Definition at line 83 of file chan_unistim.c.

Referenced by build_device().

#define DEVICE_NAME_LEN   16

Definition at line 101 of file chan_unistim.c.

#define FAV_BLINK_FAST   0x20

Definition at line 183 of file chan_unistim.c.

Referenced by unistim_call().

#define FAV_BLINK_SLOW   0x40

Definition at line 184 of file chan_unistim.c.

Referenced by show_main_page().

#define FAV_ICON_BOX   0x3F

Definition at line 181 of file chan_unistim.c.

#define FAV_ICON_CALL_CENTER   0x34

Definition at line 170 of file chan_unistim.c.

Referenced by show_main_page().

#define FAV_ICON_CITY   0x31

Definition at line 167 of file chan_unistim.c.

#define FAV_ICON_COMPUTER   0x38

Definition at line 174 of file chan_unistim.c.

#define FAV_ICON_FAX   0x35

Definition at line 171 of file chan_unistim.c.

#define FAV_ICON_FORWARD   0x39

Definition at line 175 of file chan_unistim.c.

#define FAV_ICON_HEADPHONES   0x2E

Definition at line 164 of file chan_unistim.c.

Referenced by send_select_output().

#define FAV_ICON_HEADPHONES_ONHOLD   0x2F

Definition at line 165 of file chan_unistim.c.

Referenced by refresh_all_favorite(), and send_select_output().

#define FAV_ICON_HOME   0x30

Definition at line 166 of file chan_unistim.c.

#define FAV_ICON_INBOX   0x3C

Definition at line 178 of file chan_unistim.c.

#define FAV_ICON_LOCKED   0x3A

Definition at line 176 of file chan_unistim.c.

#define FAV_ICON_MAILBOX   0x36

Definition at line 172 of file chan_unistim.c.

#define FAV_ICON_MEETING   0x3E

Definition at line 180 of file chan_unistim.c.

#define FAV_ICON_NONE   0x00

Definition at line 149 of file chan_unistim.c.

Referenced by close_client(), handle_dial_page(), key_main_page(), and unistim_call().

#define FAV_ICON_OFFHOOK_BLACK   0x24

Definition at line 154 of file chan_unistim.c.

Referenced by send_select_output().

#define FAV_ICON_OFFHOOK_WHITE   0x25

Definition at line 155 of file chan_unistim.c.

#define FAV_ICON_ONHOLD_BLACK   0x26

Definition at line 156 of file chan_unistim.c.

Referenced by send_select_output().

#define FAV_ICON_ONHOLD_WHITE   0x27

Definition at line 157 of file chan_unistim.c.

#define FAV_ICON_ONHOOK_BLACK   0x20

Definition at line 150 of file chan_unistim.c.

Referenced by build_device(), and show_main_page().

#define FAV_ICON_ONHOOK_WHITE   0x21

Definition at line 151 of file chan_unistim.c.

#define FAV_ICON_OUTBOX   0x3D

Definition at line 179 of file chan_unistim.c.

#define FAV_ICON_PAGER   0x33

Definition at line 169 of file chan_unistim.c.

#define FAV_ICON_PHONE_BLACK   0x2A

Definition at line 160 of file chan_unistim.c.

Referenced by handle_dial_page().

#define FAV_ICON_PHONE_WHITE   0x2B

Definition at line 161 of file chan_unistim.c.

#define FAV_ICON_REFLECT   0x37

Definition at line 173 of file chan_unistim.c.

Referenced by show_main_page().

#define FAV_ICON_SHARP   0x32

Definition at line 168 of file chan_unistim.c.

Referenced by ParseBookmark().

#define FAV_ICON_SPEAKER_OFFHOOK_BLACK   0x28

Definition at line 158 of file chan_unistim.c.

Referenced by send_select_output().

#define FAV_ICON_SPEAKER_OFFHOOK_WHITE   0x29

Definition at line 159 of file chan_unistim.c.

#define FAV_ICON_SPEAKER_ONHOLD_BLACK   0x2C

Definition at line 162 of file chan_unistim.c.

Referenced by send_select_output().

#define FAV_ICON_SPEAKER_ONHOLD_WHITE   0x2D

Definition at line 163 of file chan_unistim.c.

#define FAV_ICON_SPEAKER_ONHOOK_BLACK   0x22

Definition at line 152 of file chan_unistim.c.

Referenced by send_select_output(), and unistim_call().

#define FAV_ICON_SPEAKER_ONHOOK_WHITE   0x23

Definition at line 153 of file chan_unistim.c.

#define FAV_ICON_TRASH   0x3B

Definition at line 177 of file chan_unistim.c.

#define FAV_MAX_LENGTH   0x0A

Definition at line 186 of file chan_unistim.c.

Referenced by send_favorite().

#define IDLE_WAIT   1000

Nb of milliseconds waited when no events are scheduled

Definition at line 93 of file chan_unistim.c.

Referenced by do_monitor().

#define MAX_BUF_NUMBER   50

Number of slots for the transmit queue

Definition at line 89 of file chan_unistim.c.

Referenced by create_client(), and send_client().

#define MAX_BUF_SIZE   64

Size of the transmit buffer

Definition at line 87 of file chan_unistim.c.

#define MAX_ENTRY_LOG   30

Definition at line 103 of file chan_unistim.c.

Referenced by OpenHistory(), and write_history().

#define MAX_SUBS   2

Definition at line 107 of file chan_unistim.c.

Referenced by reload_config(), and unistim_info().

#define MUTE_ON   0xFF

Definition at line 136 of file chan_unistim.c.

Referenced by key_call(), and send_select_output().

#define MUTE_ON_DISCRET   0xCE

Definition at line 137 of file chan_unistim.c.

Referenced by send_select_output(), and show_main_page().

#define NB_MAX_RETRANSMIT   8

Try x times before removing the phone

Definition at line 91 of file chan_unistim.c.

Referenced by reload_config(), and send_retransmit().

#define OUTPUT_HANDSET   0xC0
#define OUTPUT_HEADPHONE   0xC1
#define OUTPUT_SPEAKER   0xC2
#define RETRANSMIT_TIMER   2000

Wait x milliseconds before resending a packet

Definition at line 95 of file chan_unistim.c.

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

#define SELECTCODEC_MAX_LENGTH   2

Definition at line 2817 of file chan_unistim.c.

Referenced by key_select_codec().

#define SELECTCODEC_MSG   "Codec number : .."

Definition at line 2818 of file chan_unistim.c.

Referenced by HandleSelectCodec(), and key_select_codec().

#define SELECTCODEC_START_ENTRY_POS   15

Definition at line 2816 of file chan_unistim.c.

Referenced by HandleSelectCodec(), and key_select_codec().

#define SELECTEXTENSION_MAX_LENGTH   10

Definition at line 2894 of file chan_unistim.c.

Referenced by key_select_extension().

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

Definition at line 2895 of file chan_unistim.c.

Referenced by key_select_extension(), and ShowExtensionPage().

#define SELECTEXTENSION_START_ENTRY_POS   0

Definition at line 2893 of file chan_unistim.c.

Referenced by key_select_extension(), and ShowExtensionPage().

#define SIZE_MAC_ADDR   17

Definition at line 140 of file chan_unistim.c.

#define SIZE_PAGE   4096

Definition at line 100 of file chan_unistim.c.

Referenced by load_module(), and unistimsock_read().

#define STATUS_LENGTH_MAX   28

Definition at line 147 of file chan_unistim.c.

Referenced by send_text_status(), and show_entry_history().

#define SUB_THREEWAY   1
#define TEXT_INVERSE   0x25

Definition at line 146 of file chan_unistim.c.

Referenced by HandleSelectCodec(), and key_select_codec().

#define TIMER_MWI   10000

How often the mailbox is checked for new messages

Definition at line 97 of file chan_unistim.c.

Referenced by unistim_send_mwi_to_peer().

#define USTM_LOG_DIR   "unistimHistory"

Definition at line 84 of file chan_unistim.c.

Referenced by OpenHistory(), and write_history().

#define VOLUME_INSANELY_LOUD   0x07

Definition at line 133 of file chan_unistim.c.

#define VOLUME_LOW   0x01

Definition at line 130 of file chan_unistim.c.

Referenced by build_device(), and send_select_output().

#define VOLUME_LOW_SPEAKER   0x03

Definition at line 131 of file chan_unistim.c.

Referenced by send_select_output().

#define VOLUME_NORMAL   0x02

Definition at line 132 of file chan_unistim.c.

Enumeration Type Documentation

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 116 of file chan_unistim.c.

116  {
117  /*! Do not create an extension into the default dialplan */
118  EXTENSION_NONE = 0,
119  /*! Prompt user for an extension number and register it */
121  /*! Register an extension with the line=> value */
123  /*! Used with AUTOPROVISIONING_TN */
125 };
Enumerator
AUTOPROVISIONING_NO 
AUTOPROVISIONING_YES 
AUTOPROVISIONING_DB 
AUTOPROVISIONING_TN 

Definition at line 109 of file chan_unistim.c.

Enumerator
STATE_ONHOOK 
STATE_OFFHOOK 

Definition at line 264 of file chan_unistim.c.

264  {
265  STATE_ONHOOK,
267 };
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 269 of file chan_unistim.c.

269  {
270  KEY_0 = 0x40,
271  KEY_1 = 0x41,
272  KEY_2 = 0x42,
273  KEY_3 = 0x43,
274  KEY_4 = 0x44,
275  KEY_5 = 0x45,
276  KEY_6 = 0x46,
277  KEY_7 = 0x47,
278  KEY_8 = 0x48,
279  KEY_9 = 0x49,
280  KEY_STAR = 0x4a,
281  KEY_SHARP = 0x4b,
282  KEY_UP = 0x4c,
283  KEY_DOWN = 0x4d,
284  KEY_RIGHT = 0x4e,
285  KEY_LEFT = 0x4f,
286  KEY_QUIT = 0x50,
287  KEY_COPY = 0x51,
288  KEY_FUNC1 = 0x54,
289  KEY_FUNC2 = 0x55,
290  KEY_FUNC3 = 0x56,
291  KEY_FUNC4 = 0x57,
292  KEY_ONHOLD = 0x5b,
293  KEY_HANGUP = 0x5c,
294  KEY_MUTE = 0x5d,
295  KEY_HEADPHN = 0x5e,
296  KEY_LOUDSPK = 0x5f,
297  KEY_FAV0 = 0x60,
298  KEY_FAV1 = 0x61,
299  KEY_FAV2 = 0x62,
300  KEY_FAV3 = 0x63,
301  KEY_FAV4 = 0x64,
302  KEY_FAV5 = 0x65,
303  KEY_COMPUTR = 0x7b,
304  KEY_CONF = 0x7c,
305  KEY_SNDHIST = 0x7d,
306  KEY_RCVHIST = 0x7e,
307  KEY_INDEX = 0x7f
308 };
Enumerator
STATE_INIT 
STATE_AUTHDENY 
STATE_MAINPAGE 
STATE_EXTENSION 
STATE_DIALPAGE 
STATE_RINGING 
STATE_CALL 
STATE_SELECTCODEC 
STATE_CLEANING 
STATE_HISTORY 

Definition at line 251 of file chan_unistim.c.

Function Documentation

static void __reg_module ( void  )
static

Definition at line 5756 of file chan_unistim.c.

static void __unreg_module ( void  )
static

Definition at line 5756 of file chan_unistim.c.

static int alloc_sub ( struct unistim_line l,
int  x 
)
static

Definition at line 1492 of file chan_unistim.c.

References ast_calloc, ast_mutex_init, ast_verb, unistim_subchannel::lock, unistim_line::name, unistim_device::name, unistim_subchannel::parent, unistim_line::parent, unistim_line::subs, and unistim_subchannel::subtype.

Referenced by build_device(), HandleCallOutgoing(), and rcv_mac_addr().

1493 {
1494  struct unistim_subchannel *sub;
1495  if (!(sub = ast_calloc(1, sizeof(*sub))))
1496  return 0;
1497 
1498  if (unistimdebug)
1499  ast_verb(3, "Allocating UNISTIM subchannel #%d on %s@%s ptr=%p\n", x, l->name, l->parent->name, sub);
1500  sub->parent = l;
1501  sub->subtype = x;
1502  l->subs[x] = sub;
1503  ast_mutex_init(&sub->lock);
1504  return 1;
1505 }
ast_mutex_t lock
Definition: chan_unistim.c:367
char name[DEVICE_NAME_LEN]
Definition: chan_unistim.c:435
#define ast_verb(level,...)
Definition: logger.h:243
struct unistim_subchannel * subs[MAX_SUBS]
Definition: chan_unistim.c:391
static int unistimdebug
Definition: chan_unistim.c:211
unsigned int subtype
Definition: chan_unistim.c:369
char name[80]
Definition: chan_unistim.c:387
#define ast_calloc(a, b)
Definition: astmm.h:82
struct unistim_line * parent
Definition: chan_unistim.c:373
struct unistim_device * parent
Definition: chan_unistim.c:421
#define ast_mutex_init(pmutex)
Definition: lock.h:152
static int attempt_transfer ( struct unistim_subchannel p1,
struct unistim_subchannel p2 
)
static

Definition at line 1895 of file chan_unistim.c.

References ast_bridged_channel(), ast_channel_masquerade(), ast_log(), AST_SOFTHANGUP_DEV, ast_softhangup_nolock(), LOG_NOTICE, LOG_WARNING, and unistim_subchannel::owner.

Referenced by close_call().

1896 {
1897  int res = 0;
1898  struct ast_channel
1899  *chana = NULL, *chanb = NULL, *bridgea = NULL, *bridgeb = NULL, *peera =
1900  NULL, *peerb = NULL, *peerc = NULL;
1901 
1902  if (!p1->owner || !p2->owner) {
1903  ast_log(LOG_WARNING, "Transfer attempted without dual ownership?\n");
1904  return -1;
1905  }
1906  chana = p1->owner;
1907  chanb = p2->owner;
1908  bridgea = ast_bridged_channel(chana);
1909  bridgeb = ast_bridged_channel(chanb);
1910 
1911  if (bridgea) {
1912  peera = chana;
1913  peerb = chanb;
1914  peerc = bridgea;
1915  } else if (bridgeb) {
1916  peera = chanb;
1917  peerb = chana;
1918  peerc = bridgeb;
1919  }
1920 
1921  if (peera && peerb && peerc && (peerb != peerc)) {
1922  /*ast_quiet_chan(peera);
1923  ast_quiet_chan(peerb);
1924  ast_quiet_chan(peerc);
1925  ast_quiet_chan(peerd); */
1926 
1927  if (ast_channel_masquerade(peerb, peerc)) {
1928  ast_log(LOG_WARNING, "Failed to masquerade %s into %s\n", peerb->name,
1929  peerc->name);
1930  res = -1;
1931  }
1932  return res;
1933  } else {
1935  "Transfer attempted with no appropriate bridged calls to transfer\n");
1936  if (chana)
1938  if (chanb)
1940  return -1;
1941  }
1942  return 0;
1943 }
struct ast_channel * owner
Definition: chan_unistim.c:371
Main Channel structure associated with a channel.
Definition: channel.h:742
int ast_channel_masquerade(struct ast_channel *original, struct ast_channel *clone)
Weird function made for call transfers.
Definition: channel.c:6110
#define LOG_WARNING
Definition: logger.h:144
struct ast_channel * ast_bridged_channel(struct ast_channel *chan)
Find bridged channel.
Definition: channel.c:7160
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
#define LOG_NOTICE
Definition: logger.h:133
int ast_softhangup_nolock(struct ast_channel *chan, int reason)
Softly hangup up a channel (no channel lock)
Definition: channel.c:2733
static struct unistim_device* build_device ( const char *  cat,
const struct ast_variable v 
)
static

Definition at line 5078 of file chan_unistim.c.

References unistim_line::accountcode, alloc_sub(), unistim_line::amaflags, ast_append_ha(), ast_calloc, ast_cdr_amaflags2int(), ast_copy_string(), ast_free, ast_get_group(), ast_get_indication_zone(), ast_localtime(), ast_log(), AST_MAX_EXTENSION, ast_mutex_destroy, ast_mutex_init, ast_mutex_lock, ast_mutex_unlock, ast_strlen_zero(), ast_tone_zone_unref(), ast_true(), ast_tvnow(), ast_verb, AUTOPROVISIONING_TN, unistim_line::callgroup, unistim_device::callhistory, CAPABILITY, unistim_line::capability, unistim_line::cid_num, context, unistim_line::context, unistim_device::contrast, unistim_device::country, dateformat, unistim_device::datetimeformat, DEFAULTCONTEXT, DEFAULTHEIGHT, devicelock, devices, display_last_error(), unistim_device::extension, EXTENSION_ASK, EXTENSION_LINE, EXTENSION_NONE, unistim_device::extension_number, EXTENSION_TN, FAV_ICON_ONHOOK_BLACK, unistim_line::fullname, unistim_device::ha, unistim_device::height, unistim_device::id, unistim_line::language, len(), ast_variable::lineno, unistim_device::lines, unistim_line::lock, LOG_ERROR, LOG_WARNING, unistim_line::mailbox, unistim_device::maintext0, unistim_device::maintext1, unistim_device::maintext2, unistim_line::musicclass, unistim_device::mute, MUTE_OFF, ast_variable::name, unistim_line::name, unistim_device::name, unistim_device::nat, ast_variable::next, unistim_line::next, unistim_device::next, unistim_device::output, OUTPUT_HANDSET, unistim_line::parent, unistim_line::parkinglot, ParseBookmark(), unistim_line::pickupgroup, unistim_device::previous_output, unistim_device::ringstyle, unistim_device::ringvolume, unistim_device::rtp_method, unistim_device::rtp_port, unistim_device::softkeydevice, unistim_device::softkeyicon, unistim_device::softkeylabel, unistim_device::softkeylinepos, unistim_device::softkeynumber, unistim_device::sp, unistim_device::status_method, SUB_REAL, unistim_device::titledefault, ast_tm::tm_zone, unistim_device::to_delete, unistim_device::tz, unquote(), ast_variable::value, unistim_device::volume, and VOLUME_LOW.

Referenced by reload_config().

5079 {
5080  struct unistim_device *d;
5081  struct unistim_line *l = NULL;
5082  int create = 1;
5083  int nbsoftkey, dateformat, timeformat, callhistory;
5084  char linelabel[AST_MAX_EXTENSION];
5085  char context[AST_MAX_EXTENSION];
5086  char ringvolume, ringstyle;
5087 
5088  /* First, we need to know if we already have this name in our list */
5089  /* Get a lock for the device chained list */
5091  d = devices;
5092  while (d) {
5093  if (!strcmp(d->name, cat)) {
5094  /* Yep, we alreay have this one */
5095  if (unistimsock < 0) {
5096  /* It's a dupe */
5097  ast_log(LOG_WARNING, "Duplicate entry found (%s), ignoring.\n", cat);
5099  return NULL;
5100  }
5101  /* we're reloading right now */
5102  create = 0;
5103  l = d->lines;
5104  break;
5105  }
5106  d = d->next;
5107  }
5109  if (create) {
5110  if (!(d = ast_calloc(1, sizeof(*d))))
5111  return NULL;
5112 
5113  if (!(l = ast_calloc(1, sizeof(*l)))) {
5114  ast_free(d);
5115  return NULL;
5116  }
5117  ast_copy_string(d->name, cat, sizeof(d->name));
5118  d->contrast = -1;
5119  d->output = OUTPUT_HANDSET;
5121  d->volume = VOLUME_LOW;
5122  d->mute = MUTE_OFF;
5123  d->height = DEFAULTHEIGHT;
5124  }
5125  ast_copy_string(context, DEFAULTCONTEXT, sizeof(context));
5126  linelabel[0] = '\0';
5127  dateformat = 1;
5128  timeformat = 1;
5129  ringvolume = 2;
5130  callhistory = 1;
5131  ringstyle = 3;
5132  nbsoftkey = 0;
5133  while (v) {
5134  if (!strcasecmp(v->name, "rtp_port"))
5135  d->rtp_port = atoi(v->value);
5136  else if (!strcasecmp(v->name, "rtp_method"))
5137  d->rtp_method = atoi(v->value);
5138  else if (!strcasecmp(v->name, "status_method"))
5139  d->status_method = atoi(v->value);
5140  else if (!strcasecmp(v->name, "device"))
5141  ast_copy_string(d->id, v->value, sizeof(d->id));
5142  else if (!strcasecmp(v->name, "tn"))
5144  else if (!strcasecmp(v->name, "permit") || !strcasecmp(v->name, "deny"))
5145  d->ha = ast_append_ha(v->name, v->value, d->ha, NULL);
5146  else if (!strcasecmp(v->name, "context"))
5147  ast_copy_string(context, v->value, sizeof(context));
5148  else if (!strcasecmp(v->name, "maintext0"))
5149  unquote(d->maintext0, v->value, sizeof(d->maintext0) - 1);
5150  else if (!strcasecmp(v->name, "maintext1"))
5151  unquote(d->maintext1, v->value, sizeof(d->maintext1) - 1);
5152  else if (!strcasecmp(v->name, "maintext2"))
5153  unquote(d->maintext2, v->value, sizeof(d->maintext2) - 1);
5154  else if (!strcasecmp(v->name, "titledefault"))
5155  unquote(d->titledefault, v->value, sizeof(d->titledefault) - 1);
5156  else if (!strcasecmp(v->name, "dateformat"))
5157  dateformat = atoi(v->value);
5158  else if (!strcasecmp(v->name, "timeformat"))
5159  timeformat = atoi(v->value);
5160  else if (!strcasecmp(v->name, "contrast")) {
5161  d->contrast = atoi(v->value);
5162  if ((d->contrast < 0) || (d->contrast > 15)) {
5163  ast_log(LOG_WARNING, "contrast must be beetween 0 and 15\n");
5164  d->contrast = 8;
5165  }
5166  } else if (!strcasecmp(v->name, "nat"))
5167  d->nat = ast_true(v->value);
5168  else if (!strcasecmp(v->name, "ringvolume"))
5169  ringvolume = atoi(v->value);
5170  else if (!strcasecmp(v->name, "ringstyle"))
5171  ringstyle = atoi(v->value);
5172  else if (!strcasecmp(v->name, "callhistory"))
5173  callhistory = atoi(v->value);
5174  else if (!strcasecmp(v->name, "callerid")) {
5175  if (!strcasecmp(v->value, "asreceived"))
5176  l->cid_num[0] = '\0';
5177  else
5178  ast_copy_string(l->cid_num, v->value, sizeof(l->cid_num));
5179  } else if (!strcasecmp(v->name, "language"))
5180  ast_copy_string(l->language, v->value, sizeof(l->language));
5181  else if (!strcasecmp(v->name, "country"))
5182  ast_copy_string(d->country, v->value, sizeof(d->country));
5183  else if (!strcasecmp(v->name, "accountcode"))
5184  ast_copy_string(l->accountcode, v->value, sizeof(l->accountcode));
5185  else if (!strcasecmp(v->name, "amaflags")) {
5186  int y;
5187  y = ast_cdr_amaflags2int(v->value);
5188  if (y < 0)
5189  ast_log(LOG_WARNING, "Invalid AMA flags: %s at line %d\n", v->value,
5190  v->lineno);
5191  else
5192  l->amaflags = y;
5193  } else if (!strcasecmp(v->name, "musiconhold"))
5194  ast_copy_string(l->musicclass, v->value, sizeof(l->musicclass));
5195  else if (!strcasecmp(v->name, "callgroup"))
5196  l->callgroup = ast_get_group(v->value);
5197  else if (!strcasecmp(v->name, "pickupgroup"))
5198  l->pickupgroup = ast_get_group(v->value);
5199  else if (!strcasecmp(v->name, "mailbox"))
5200  ast_copy_string(l->mailbox, v->value, sizeof(l->mailbox));
5201  else if (!strcasecmp(v->name, "parkinglot"))
5202  ast_copy_string(l->parkinglot, v->value, sizeof(l->parkinglot));
5203  else if (!strcasecmp(v->name, "linelabel"))
5204  unquote(linelabel, v->value, sizeof(linelabel) - 1);
5205  else if (!strcasecmp(v->name, "extension")) {
5206  if (!strcasecmp(v->value, "none"))
5208  else if (!strcasecmp(v->value, "ask"))
5209  d->extension = EXTENSION_ASK;
5210  else if (!strcasecmp(v->value, "line"))
5212  else
5213  ast_log(LOG_WARNING, "Unknown extension option.\n");
5214  } else if (!strcasecmp(v->name, "bookmark")) {
5215  if (nbsoftkey > 5)
5217  "More than 6 softkeys defined. Ignoring new entries.\n");
5218  else {
5219  if (ParseBookmark(v->value, d))
5220  nbsoftkey++;
5221  }
5222  } else if (!strcasecmp(v->name, "line")) {
5223  int len = strlen(linelabel);
5224 
5225  if (nbsoftkey) {
5227  "You must use bookmark AFTER line=>. Only one line is supported in this version\n");
5228  if (create) {
5229  ast_free(d);
5230  ast_free(l);
5231  }
5232  return NULL;
5233  }
5234  if (create) {
5235  ast_mutex_init(&l->lock);
5236  } else {
5237  d->to_delete = 0;
5238  /* reset bookmarks */
5239  memset(d->softkeylabel, 0, sizeof(d->softkeylabel));
5240  memset(d->softkeynumber, 0, sizeof(d->softkeynumber));
5241  memset(d->softkeyicon, 0, sizeof(d->softkeyicon));
5242  memset(d->softkeydevice, 0, sizeof(d->softkeydevice));
5243  memset(d->sp, 0, sizeof(d->sp));
5244  }
5245  ast_copy_string(l->name, v->value, sizeof(l->name));
5246  snprintf(l->fullname, sizeof(l->fullname), "USTM/%s@%s", l->name, d->name);
5248  if (!len) /* label is undefined ? */
5249  ast_copy_string(d->softkeylabel[0], v->value, sizeof(d->softkeylabel[0]));
5250  else {
5251  if ((len > 2) && (linelabel[1] == '@')) {
5252  d->softkeylinepos = linelabel[0];
5253  if ((d->softkeylinepos >= '0') && (d->softkeylinepos <= '5')) {
5254  d->softkeylinepos -= '0';
5255  d->softkeyicon[0] = 0;
5256  } else {
5258  "Invalid position for linelabel : must be between 0 and 5\n");
5259  d->softkeylinepos = 0;
5260  }
5261  ast_copy_string(d->softkeylabel[d->softkeylinepos], linelabel + 2,
5262  sizeof(d->softkeylabel[d->softkeylinepos]));
5264  } else
5265  ast_copy_string(d->softkeylabel[0], linelabel,
5266  sizeof(d->softkeylabel[0]));
5267  }
5268  nbsoftkey++;
5269  ast_copy_string(l->context, context, sizeof(l->context));
5270  if (!ast_strlen_zero(l->mailbox)) {
5271  if (unistimdebug)
5272  ast_verb(3, "Setting mailbox '%s' on %s@%s\n", l->mailbox, d->name, l->name);
5273  }
5274 
5275  l->capability = CAPABILITY;
5276  l->parent = d;
5277 
5278  if (create) {
5279  if (!alloc_sub(l, SUB_REAL)) {
5280  ast_mutex_destroy(&l->lock);
5281  ast_free(l);
5282  ast_free(d);
5283  return NULL;
5284  }
5285  l->next = d->lines;
5286  d->lines = l;
5287  }
5288  } else if (!strcasecmp(v->name, "height")) {
5289  /* Allow the user to lower the expected display lines on the phone
5290  * For example the Nortal I2001 and I2002 only have one ! */
5291  d->height = atoi(v->value);
5292  } else
5293  ast_log(LOG_WARNING, "Don't know keyword '%s' at line %d\n", v->name,
5294  v->lineno);
5295  v = v->next;
5296  }
5297  d->ringvolume = ringvolume;
5298  d->ringstyle = ringstyle;
5299  d->callhistory = callhistory;
5301  if ((d->tz == NULL) && !ast_strlen_zero(d->country))
5302  ast_log(LOG_WARNING, "Country '%s' was not found in indications.conf\n",
5303  d->country);
5304  d->datetimeformat = 56 + (dateformat * 4);
5305  d->datetimeformat += timeformat;
5306  if (!d->lines) {
5307  ast_log(LOG_ERROR, "An Unistim device must have at least one line!\n");
5308  ast_mutex_destroy(&l->lock);
5309  ast_free(l);
5310  if (d->tz) {
5311  d->tz = ast_tone_zone_unref(d->tz);
5312  }
5313  ast_free(d);
5314  return NULL;
5315  }
5318  d->extension = EXTENSION_TN;
5319  if (!ast_strlen_zero(d->id))
5321  "tn= and device= can't be used together. Ignoring device= entry\n");
5322  d->id[0] = 'T'; /* magic : this is a tn entry */
5323  ast_copy_string((d->id) + 1, d->extension_number, sizeof(d->id) - 1);
5324  d->extension_number[0] = '\0';
5325  } else if (ast_strlen_zero(d->id)) {
5326  if (strcmp(d->name, "template")) {
5327  ast_log(LOG_ERROR, "You must specify the mac address with device=\n");
5328  ast_mutex_destroy(&l->lock);
5329  ast_free(l);
5330  if (d->tz) {
5331  d->tz = ast_tone_zone_unref(d->tz);
5332  }
5333  ast_free(d);
5334  return NULL;
5335  } else
5336  strcpy(d->id, "000000000000");
5337  }
5338  if (!d->rtp_port)
5339  d->rtp_port = 10000;
5340  if (d->contrast == -1)
5341  d->contrast = 8;
5342  if (ast_strlen_zero(d->maintext0))
5343  strcpy(d->maintext0, "Welcome");
5344  if (ast_strlen_zero(d->maintext1))
5345  strcpy(d->maintext1, d->name);
5346  if (ast_strlen_zero(d->titledefault)) {
5347  struct ast_tm tm = { 0, };
5348  struct timeval cur_time = ast_tvnow();
5349 
5350  if ((ast_localtime(&cur_time, &tm, 0)) == 0 || ast_strlen_zero(tm.tm_zone)) {
5351  display_last_error("Error in ast_localtime()");
5352  ast_copy_string(d->titledefault, "UNISTIM for*", 12);
5353  } else {
5354  if (strlen(tm.tm_zone) < 4) {
5355  strcpy(d->titledefault, "TimeZone ");
5356  strcat(d->titledefault, tm.tm_zone);
5357  } else if (strlen(tm.tm_zone) < 9) {
5358  strcpy(d->titledefault, "TZ ");
5359  strcat(d->titledefault, tm.tm_zone);
5360  } else
5361  ast_copy_string(d->titledefault, tm.tm_zone, 12);
5362  }
5363  }
5364  /* Update the chained link if it's a new device */
5365  if (create) {
5367  d->next = devices;
5368  devices = d;
5370  ast_verb(3, "Added device '%s'\n", d->name);
5371  } else {
5372  ast_verb(3, "Device '%s' reloaded\n", d->name);
5373  }
5374  return d;
5375 }
char * tm_zone
Definition: localtime.h:46
char softkeynumber[6][16]
Definition: chan_unistim.c:438
static int alloc_sub(struct unistim_line *l, int x)
A device containing one or more lines.
Definition: chan_unistim.c:427
char name[DEVICE_NAME_LEN]
Definition: chan_unistim.c:435
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:204
unsigned int pickupgroup
Definition: chan_unistim.c:411
char parkinglot[AST_MAX_CONTEXT]
Definition: chan_unistim.c:419
static int unistimsock
Definition: chan_unistim.c:215
char language[MAX_LANGUAGE]
Definition: chan_unistim.c:397
unsigned int callgroup
Definition: chan_unistim.c:409
#define LOG_WARNING
Definition: logger.h:144
int lineno
Definition: config.h:87
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:1570
static void unquote(char *out, const char *src, int maxlen)
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
Definition: time.h:142
#define ast_mutex_lock(a)
Definition: lock.h:155
#define FAV_ICON_ONHOOK_BLACK
Definition: chan_unistim.c:150
static int ParseBookmark(const char *text, struct unistim_device *d)
#define ast_verb(level,...)
Definition: logger.h:243
#define VOLUME_LOW
Definition: chan_unistim.c:130
static int unistimdebug
Definition: chan_unistim.c:211
char accountcode[80]
Definition: chan_unistim.c:413
struct ast_ha * ha
Definition: chan_unistim.c:474
char name[80]
Definition: chan_unistim.c:387
struct unistim_line * next
Definition: chan_unistim.c:420
char titledefault[13]
Definition: chan_unistim.c:446
#define MUTE_OFF
Definition: chan_unistim.c:135
static ast_mutex_t devicelock
Definition: chan_unistim.c:249
ast_mutex_t lock
Definition: chan_unistim.c:385
const char * value
Definition: config.h:79
#define OUTPUT_HANDSET
Definition: chan_unistim.c:126
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition: strings.h:63
struct unistim_device * next
Definition: chan_unistim.c:476
char softkeydevice[6][16]
Definition: chan_unistim.c:440
#define AST_MAX_EXTENSION
Definition: channel.h:135
char mailbox[AST_MAX_EXTENSION]
Definition: chan_unistim.c:401
char softkeylabel[6][11]
Definition: chan_unistim.c:437
const char * name
Definition: config.h:77
char maintext0[25]
Definition: chan_unistim.c:443
ast_group_t ast_get_group(const char *s)
Definition: channel.c:7987
struct ast_tone_zone * tz
Definition: chan_unistim.c:450
enum autoprov_extn extension
Definition: chan_unistim.c:468
char cid_num[AST_MAX_EXTENSION]
Definition: chan_unistim.c:399
char musicclass[MAX_MUSICCLASS]
Definition: chan_unistim.c:407
#define LOG_ERROR
Definition: logger.h:155
int attribute_pure ast_true(const char *val)
Make sure something is true. Determine if a string containing a boolean value is &quot;true&quot;. This function checks to see whether a string passed to it is an indication of an &quot;true&quot; value. It checks to see if the string is &quot;yes&quot;, &quot;true&quot;, &quot;y&quot;, &quot;t&quot;, &quot;on&quot; or &quot;1&quot;.
Definition: utils.c:1533
struct ast_tone_zone * ast_get_indication_zone(const char *country)
locate ast_tone_zone
Definition: indications.c:451
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
int ast_cdr_amaflags2int(const char *flag)
Convert a string to a detail record AMA flag.
Definition: cdr.c:1105
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
struct unistim_line * lines
Definition: chan_unistim.c:473
#define ast_free(a)
Definition: astmm.h:97
#define DEFAULTHEIGHT
Definition: chan_unistim.c:83
static struct unistim_device * devices
char context[AST_MAX_EXTENSION]
Definition: chan_unistim.c:395
char fullname[80]
Definition: chan_unistim.c:389
#define SUB_REAL
Definition: chan_unistim.c:105
static char dateformat[256]
Definition: logger.c:69
#define ast_calloc(a, b)
Definition: astmm.h:82
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:223
static enum autoprovision autoprovisioning
Definition: chan_unistim.c:213
struct unistim_device * parent
Definition: chan_unistim.c:421
char maintext1[25]
Definition: chan_unistim.c:444
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:399
struct ast_variable * next
Definition: config.h:82
#define ast_mutex_init(pmutex)
Definition: lock.h:152
static char context[AST_MAX_CONTEXT]
Definition: chan_alsa.c:107
#define ast_mutex_destroy(a)
Definition: lock.h:154
static void display_last_error(const char *sz_msg)
Definition: chan_unistim.c:725
#define CAPABILITY
Definition: chan_unistim.c:78
char extension_number[11]
Definition: chan_unistim.c:469
struct unistim_device * sp[6]
Definition: chan_unistim.c:441
#define DEFAULTCONTEXT
Definition: chan_unistim.c:80
format_t capability
Definition: chan_unistim.c:417
#define ast_mutex_unlock(a)
Definition: lock.h:156
char maintext2[25]
Definition: chan_unistim.c:445
char softkeyicon[6]
Definition: chan_unistim.c:439
static void cancel_dial ( struct unistimsession pte)
static

Definition at line 1858 of file chan_unistim.c.

References unistimsession::device, unistim_device::missed_call, send_no_ring(), show_main_page(), and write_history().

Referenced by unistim_hangup().

1859 {
1860  send_no_ring(pte);
1861  pte->device->missed_call++;
1862  write_history(pte, 'i', 1);
1863  show_main_page(pte);
1864  return;
1865 }
static int write_history(struct unistimsession *pte, char way, char ismissed)
struct unistim_device * device
Definition: chan_unistim.c:496
static void show_main_page(struct unistimsession *pte)
static void send_no_ring(struct unistimsession *pte)
void change_callerid ( struct unistimsession pte,
int  type,
char *  callerid 
)
static

Definition at line 1945 of file chan_unistim.c.

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

Referenced by close_call(), and unistim_call().

1946 {
1947  char *data;
1948  int size;
1949 
1950  if (type)
1951  data = pte->device->lst_cnm;
1952  else
1953  data = pte->device->lst_cid;
1954 
1955  /* This is very nearly strncpy(), except that the remaining buffer
1956  * is padded with ' ', instead of '\0' */
1957  memset(data, ' ', TEXT_LENGTH_MAX);
1958  size = strlen(callerid);
1959  if (size > TEXT_LENGTH_MAX)
1960  size = TEXT_LENGTH_MAX;
1961  memcpy(data, callerid, size);
1962 }
char lst_cnm[TEXT_LENGTH_MAX]
Definition: chan_unistim.c:460
#define TEXT_LENGTH_MAX
Definition: chan_unistim.c:141
struct unistim_device * device
Definition: chan_unistim.c:496
char lst_cid[TEXT_LENGTH_MAX]
Definition: chan_unistim.c:459
static const char type[]
Definition: chan_nbs.c:57
static void change_favorite_icon ( struct unistimsession pte,
unsigned char  status 
)
static

Definition at line 1076 of file chan_unistim.c.

References unistimsession::device, devices, unistim_device::next, send_favorite(), unistim_device::session, unistim_device::softkeyicon, unistim_device::softkeylabel, unistim_device::softkeylinepos, 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().

1077 {
1078  struct unistim_device *d = devices;
1079  int i;
1080  /* Update the current phone */
1081  if (pte->state != STATE_CLEANING)
1083  pte->device->softkeylabel[pte->device->softkeylinepos]);
1084  /* Notify other phones if we're in their bookmark */
1085  while (d) {
1086  for (i = 0; i < 6; i++) {
1087  if (d->sp[i] == pte->device) { /* It's us ? */
1088  if (d->softkeyicon[i] != status) { /* Avoid resending the same icon */
1089  d->softkeyicon[i] = status;
1090  if (d->session)
1091  send_favorite(i, status + 1, d->session, d->softkeylabel[i]);
1092  }
1093  }
1094  }
1095  d = d->next;
1096  }
1097 }
A device containing one or more lines.
Definition: chan_unistim.c:427
struct unistim_device * device
Definition: chan_unistim.c:496
struct unistim_device * next
Definition: chan_unistim.c:476
struct unistimsession * session
Definition: chan_unistim.c:475
char softkeylabel[6][11]
Definition: chan_unistim.c:437
static void send_favorite(unsigned char pos, unsigned char status, struct unistimsession *pte, const char *text)
static struct unistim_device * devices
struct unistim_device * sp[6]
Definition: chan_unistim.c:441
jack_status_t status
Definition: app_jack.c:143
char softkeyicon[6]
Definition: chan_unistim.c:439
static struct unistimsession* channel_to_session ( struct ast_channel ast)
static

Definition at line 3670 of file chan_unistim.c.

References ast_log(), LOG_WARNING, unistim_subchannel::parent, unistim_line::parent, unistim_device::session, and ast_channel::tech_pvt.

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

3671 {
3672  struct unistim_subchannel *sub;
3673  if (!ast) {
3674  ast_log(LOG_WARNING, "Unistim callback function called with a null channel\n");
3675  return NULL;
3676  }
3677  if (!ast->tech_pvt) {
3678  ast_log(LOG_WARNING, "Unistim callback function called without a tech_pvt\n");
3679  return NULL;
3680  }
3681  sub = ast->tech_pvt;
3682 
3683  if (!sub->parent) {
3684  ast_log(LOG_WARNING, "Unistim callback function called without a line\n");
3685  return NULL;
3686  }
3687  if (!sub->parent->parent) {
3688  ast_log(LOG_WARNING, "Unistim callback function called without a device\n");
3689  return NULL;
3690  }
3691  if (!sub->parent->parent->session) {
3692  ast_log(LOG_WARNING, "Unistim callback function called without a session\n");
3693  return NULL;
3694  }
3695  return sub->parent->parent->session;
3696 }
void * tech_pvt
Definition: channel.h:744
#define LOG_WARNING
Definition: logger.h:144
struct unistimsession * session
Definition: chan_unistim.c:475
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
struct unistim_line * parent
Definition: chan_unistim.c:373
struct unistim_device * parent
Definition: chan_unistim.c:421
static void check_send_queue ( struct unistimsession pte)
static

Definition at line 931 of file chan_unistim.c.

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

Referenced by parsing().

932 {
933  /* Check if our send queue contained only one element */
934  if (pte->last_buf_available == 1) {
935  if (unistimdebug)
936  ast_verb(6, "Our single packet was ACKed.\n");
937  pte->last_buf_available--;
938  set_ping_timer(pte);
939  return;
940  }
941  /* Check if this ACK catch up our latest packet */
942  else if (pte->last_seq_ack + 1 == pte->seq_server + 1) {
943  if (unistimdebug)
944  ast_verb(6, "Our send queue is completely ACKed.\n");
945  pte->last_buf_available = 0; /* Purge the send queue */
946  set_ping_timer(pte);
947  return;
948  }
949  if (unistimdebug)
950  ast_verb(6, "We still have packets in our send queue\n");
951  return;
952 }
unsigned short seq_server
Definition: chan_unistim.c:485
static void set_ping_timer(struct unistimsession *pte)
Definition: chan_unistim.c:920
#define ast_verb(level,...)
Definition: logger.h:243
unsigned short last_seq_ack
Definition: chan_unistim.c:486
static int unistimdebug
Definition: chan_unistim.c:211
static void close_call ( struct unistimsession pte)
static

Definition at line 1964 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, unistim_device::lines, LOG_WARNING, unistim_device::missed_call, unistim_line::name, unistim_device::name, unistim_subchannel::owner, unistim_subchannel::parent, unistim_line::parent, unistim_device::redial_number, send_stop_timer(), show_main_page(), SUB_REAL, SUB_THREEWAY, unistim_line::subs, unistim_subchannel::subtype, and write_history().

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

1965 {
1966  struct unistim_subchannel *sub;
1967  struct unistim_line *l = pte->device->lines;
1968 
1969  sub = pte->device->lines->subs[SUB_REAL];
1970  send_stop_timer(pte);
1971  if (sub->owner) {
1972  sub->alreadygone = 1;
1973  if (l->subs[SUB_THREEWAY]) {
1974  l->subs[SUB_THREEWAY]->alreadygone = 1;
1975  if (attempt_transfer(sub, l->subs[SUB_THREEWAY]) < 0)
1976  ast_verb(0, "attempt_transfer failed.\n");
1977  } else
1978  ast_queue_hangup(sub->owner);
1979  } else {
1980  if (l->subs[SUB_THREEWAY]) {
1981  if (l->subs[SUB_THREEWAY]->owner)
1983  else
1984  ast_log(LOG_WARNING, "threeway sub without owner\n");
1985  } else
1986  ast_verb(0, "USTM(%s@%s-%u) channel already destroyed\n", sub->parent->name,
1987  sub->parent->parent->name, sub->subtype);
1988  }
1989  change_callerid(pte, 0, pte->device->redial_number);
1990  change_callerid(pte, 1, "");
1991  write_history(pte, 'o', pte->device->missed_call);
1992  pte->device->missed_call = 0;
1993  show_main_page(pte);
1994  return;
1995 }
struct ast_channel * owner
Definition: chan_unistim.c:371
int ast_queue_hangup(struct ast_channel *chan)
Queue a hangup frame.
Definition: channel.c:1569
static int write_history(struct unistimsession *pte, char way, char ismissed)
char name[DEVICE_NAME_LEN]
Definition: chan_unistim.c:435
#define LOG_WARNING
Definition: logger.h:144
#define SUB_THREEWAY
Definition: chan_unistim.c:106
static int attempt_transfer(struct unistim_subchannel *p1, struct unistim_subchannel *p2)
#define ast_verb(level,...)
Definition: logger.h:243
struct unistim_subchannel * subs[MAX_SUBS]
Definition: chan_unistim.c:391
int ast_queue_hangup_with_cause(struct ast_channel *chan, int cause)
Queue a hangup frame with hangupcause set.
Definition: channel.c:1581
struct unistim_device * device
Definition: chan_unistim.c:496
unsigned int subtype
Definition: chan_unistim.c:369
char name[80]
Definition: chan_unistim.c:387
#define AST_CAUSE_NORMAL_CLEARING
Definition: causes.h:105
static void send_stop_timer(struct unistimsession *pte)
Definition: chan_unistim.c:963
static void show_main_page(struct unistimsession *pte)
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
char redial_number[16]
Definition: chan_unistim.c:431
struct unistim_line * lines
Definition: chan_unistim.c:473
#define SUB_REAL
Definition: chan_unistim.c:105
struct unistim_line * parent
Definition: chan_unistim.c:373
struct unistim_device * parent
Definition: chan_unistim.c:421
static void change_callerid(struct unistimsession *pte, int type, char *callerid)
static void close_client ( struct unistimsession s)
static

Definition at line 1120 of file chan_unistim.c.

References AST_CAUSE_NETWORK_OUT_OF_ORDER, ast_free, 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::lines, unistimsession::lock, LOG_WARNING, unistimsession::next, unistim_subchannel::owner, unistim_device::session, sessionlock, sessions, unistimsession::state, STATE_CLEANING, SUB_REAL, unistim_line::subs, and UnregisterExtension().

Referenced by parsing(), and send_retransmit().

1121 {
1122  struct unistim_subchannel *sub;
1123  struct unistimsession *cur, *prev = NULL;
1125  cur = sessions;
1126  /* Looking for the session in the linked chain */
1127  while (cur) {
1128  if (cur == s)
1129  break;
1130  prev = cur;
1131  cur = cur->next;
1132  }
1133  if (cur) { /* Session found ? */
1134  if (cur->device) { /* This session was registered ? */
1135  s->state = STATE_CLEANING;
1136  if (unistimdebug)
1137  ast_verb(0, "close_client session %p device %p lines %p sub %p\n",
1138  s, s->device, s->device->lines,
1139  s->device->lines->subs[SUB_REAL]);
1141  sub = s->device->lines->subs[SUB_REAL];
1142  if (sub) {
1143  if (sub->owner) { /* Call in progress ? */
1144  if (unistimdebug)
1145  ast_verb(0, "Aborting call\n");
1147  }
1148  } else
1149  ast_log(LOG_WARNING, "Freeing a client with no subchannel !\n");
1152  cur->device->session = NULL;
1153  } else {
1154  if (unistimdebug)
1155  ast_verb(0, "Freeing an unregistered client\n");
1156  }
1157  if (prev)
1158  prev->next = cur->next;
1159  else
1160  sessions = cur->next;
1161  ast_mutex_destroy(&s->lock);
1162  ast_free(s);
1163  } else
1164  ast_log(LOG_WARNING, "Trying to delete non-existent session %p?\n", s);
1166  return;
1167 }
struct ast_channel * owner
Definition: chan_unistim.c:371
static struct unistimsession * sessions
static int UnregisterExtension(const struct unistimsession *pte)
#define AST_CAUSE_NETWORK_OUT_OF_ORDER
Definition: causes.h:120
#define LOG_WARNING
Definition: logger.h:144
static void change_favorite_icon(struct unistimsession *pte, unsigned char status)
#define ast_mutex_lock(a)
Definition: lock.h:155
#define ast_verb(level,...)
Definition: logger.h:243
struct unistim_subchannel * subs[MAX_SUBS]
Definition: chan_unistim.c:391
static ast_mutex_t sessionlock
Definition: chan_unistim.c:247
ast_mutex_t lock
Definition: chan_unistim.c:480
static int unistimdebug
Definition: chan_unistim.c:211
int ast_queue_hangup_with_cause(struct ast_channel *chan, int cause)
Queue a hangup frame with hangupcause set.
Definition: channel.c:1581
struct unistim_device * device
Definition: chan_unistim.c:496
struct unistimsession * next
Definition: chan_unistim.c:497
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition: strings.h:63
struct unistimsession * session
Definition: chan_unistim.c:475
#define FAV_ICON_NONE
Definition: chan_unistim.c:149
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
struct unistim_line * lines
Definition: chan_unistim.c:473
#define ast_free(a)
Definition: astmm.h:97
#define SUB_REAL
Definition: chan_unistim.c:105
#define ast_mutex_destroy(a)
Definition: lock.h:154
char extension_number[11]
Definition: chan_unistim.c:469
#define ast_mutex_unlock(a)
Definition: lock.h:156
static char* control2str ( int  ind)
static

Definition at line 4087 of file chan_unistim.c.

References AST_CONTROL_ANSWER, AST_CONTROL_BUSY, AST_CONTROL_CONGESTION, 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_TAKEOFFHOOK, and AST_CONTROL_WINK.

Referenced by unistim_indicate().

4088 {
4089  switch (ind) {
4090  case AST_CONTROL_HANGUP:
4091  return "Other end has hungup";
4092  case AST_CONTROL_RING:
4093  return "Local ring";
4094  case AST_CONTROL_RINGING:
4095  return "Remote end is ringing";
4096  case AST_CONTROL_ANSWER:
4097  return "Remote end has answered";
4098  case AST_CONTROL_BUSY:
4099  return "Remote end is busy";
4101  return "Make it go off hook";
4102  case AST_CONTROL_OFFHOOK:
4103  return "Line is off hook";
4105  return "Congestion (circuits busy)";
4106  case AST_CONTROL_FLASH:
4107  return "Flash hook";
4108  case AST_CONTROL_WINK:
4109  return "Wink";
4110  case AST_CONTROL_OPTION:
4111  return "Set a low-level option";
4112  case AST_CONTROL_RADIO_KEY:
4113  return "Key Radio";
4115  return "Un-Key Radio";
4116  case -1:
4117  return "Stop tone";
4118  }
4119  return "UNKNOWN";
4120 }
static struct unistimsession* create_client ( const struct sockaddr_in *  addr_from)
static

Definition at line 875 of file chan_unistim.c.

References ast_calloc, 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::last_buf_available, unistimsession::last_seq_ack, unistimsession::lock, MAX_BUF_NUMBER, unistimsession::nb_retransmit, unistimsession::next, RETRANSMIT_TIMER, unistimsession::seq_phone, unistimsession::seq_server, sessionlock, sessions, unistimsession::sin, unistimsession::sout, unistimsession::state, STATE_INIT, unistimsession::tick_next_ping, unistimsession::timeout, unistim_keepalive, and unistimsession::wsabufsend.

Referenced by parsing().

876 {
877  int tmp;
878  struct unistimsession *s;
879 
880  if (!(s = ast_calloc(1, sizeof(*s))))
881  return NULL;
882 
883  memcpy(&s->sin, addr_from, sizeof(struct sockaddr_in));
885  s->sout.sin_family = AF_INET;
886  if (unistimdebug) {
887  ast_verb(0, "Creating a new entry for the phone from %s received via server ip %s\n",
888  ast_inet_ntoa(addr_from->sin_addr), ast_inet_ntoa(s->sout.sin_addr));
889  }
890  ast_mutex_init(&s->lock);
892  s->next = sessions;
893  sessions = s;
894 
896  s->seq_phone = (short) 0x0000;
897  s->seq_server = (short) 0x0000;
898  s->last_seq_ack = (short) 0x000;
899  s->last_buf_available = 0;
900  s->nb_retransmit = 0;
901  s->state = STATE_INIT;
903  /* Initialize struct wsabuf */
904  for (tmp = 0; tmp < MAX_BUF_NUMBER; tmp++) {
905  s->wsabufsend[tmp].buf = s->buf[tmp];
906  }
908  return s;
909 }
static struct unistimsession * sessions
struct sockaddr_in sout
Definition: chan_unistim.c:482
static int unistimsock
Definition: chan_unistim.c:215
struct wsabuf wsabufsend[MAX_BUF_NUMBER]
Definition: chan_unistim.c:494
unsigned short seq_server
Definition: chan_unistim.c:485
unsigned char buf[MAX_BUF_NUMBER][MAX_BUF_SIZE]
Definition: chan_unistim.c:495
#define ast_mutex_lock(a)
Definition: lock.h:155
#define MAX_BUF_NUMBER
Definition: chan_unistim.c:89
#define ast_verb(level,...)
Definition: logger.h:243
static ast_mutex_t sessionlock
Definition: chan_unistim.c:247
ast_mutex_t lock
Definition: chan_unistim.c:480
unsigned short last_seq_ack
Definition: chan_unistim.c:486
static int unistimdebug
Definition: chan_unistim.c:211
#define RETRANSMIT_TIMER
Definition: chan_unistim.c:95
struct unistimsession * next
Definition: chan_unistim.c:497
unsigned long tick_next_ping
Definition: chan_unistim.c:487
static int get_to_address(int fd, struct sockaddr_in *toAddr)
Definition: chan_unistim.c:842
static int unistim_keepalive
Definition: chan_unistim.c:214
const char * ast_inet_ntoa(struct in_addr ia)
thread-safe replacement for inet_ntoa().
Definition: utils.c:564
struct sockaddr_in sin
Definition: chan_unistim.c:481
unsigned short seq_phone
Definition: chan_unistim.c:484
#define ast_calloc(a, b)
Definition: astmm.h:82
unsigned char * buf
Definition: chan_unistim.c:352
static unsigned int get_tick_count(void)
Definition: chan_unistim.c:736
#define ast_mutex_init(pmutex)
Definition: lock.h:152
#define ast_mutex_unlock(a)
Definition: lock.h:156
static void display_last_error ( const char *  sz_msg)
static

Definition at line 725 of file chan_unistim.c.

References ast_log(), errno, and LOG_WARNING.

Referenced by build_device(), HandleCallOutgoing(), key_history(), OpenHistory(), send_raw_client(), show_entry_history(), write_entry_history(), and write_history().

726 {
727  time_t cur_time;
728 
729  time(&cur_time);
730 
731  /* Display the error message */
732  ast_log(LOG_WARNING, "%s %s : (%d) %s\n", ctime(&cur_time), sz_msg, errno,
733  strerror(errno));
734 }
#define LOG_WARNING
Definition: logger.h:144
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
int errno
static void* do_monitor ( void *  data)
static

Definition at line 4587 of file chan_unistim.c.

References ast_io_add(), AST_IO_IN, ast_io_wait(), ast_mutex_lock, ast_mutex_unlock, ast_strlen_zero(), ast_verb, DEBUG_TIMER, unistimsession::device, get_tick_count(), IDLE_WAIT, unistimsession::last_buf_available, unistim_device::lines, unistim_line::mailbox, unistimsession::next, unistim_line::nextmsgcheck, reload_config(), send_ping(), send_retransmit(), sessionlock, sessions, unistimsession::timeout, unistim_reload_lock, unistim_reloading, unistim_send_mwi_to_peer(), and unistimsock_read().

Referenced by restart_monitor().

4588 {
4589  struct unistimsession *cur = NULL;
4590  unsigned int dw_timeout = 0;
4591  unsigned int tick;
4592  int res;
4593  int reloading;
4594 
4595  /* Add an I/O event to our UDP socket */
4596  if (unistimsock > -1)
4598 
4599  /* This thread monitors our UDP socket and timers */
4600  for (;;) {
4601  /* This loop is executed at least every IDLE_WAITus (1s) or every time a packet is received */
4602  /* Looking for the smallest time-out value */
4603  tick = get_tick_count();
4604  dw_timeout = UINT_MAX;
4606  cur = sessions;
4607  DEBUG_TIMER("checking timeout for session %p with tick = %u\n", cur, tick);
4608  while (cur) {
4609  DEBUG_TIMER("checking timeout for session %p timeout = %u\n", cur,
4610  cur->timeout);
4611  /* Check if we have miss something */
4612  if (cur->timeout <= tick) {
4613  DEBUG_TIMER("Event for session %p\n", cur);
4614  /* If the queue is empty, send a ping */
4615  if (cur->last_buf_available == 0)
4616  send_ping(cur);
4617  else {
4618  if (send_retransmit(cur)) {
4619  DEBUG_TIMER("The chained link was modified, restarting...\n");
4620  cur = sessions;
4621  dw_timeout = UINT_MAX;
4622  continue;
4623  }
4624  }
4625  }
4626  if (dw_timeout > cur->timeout - tick)
4627  dw_timeout = cur->timeout - tick;
4628  /* Checking if the phone is logged on for a new MWI */
4629  if (cur->device) {
4630  if ((!ast_strlen_zero(cur->device->lines->mailbox)) &&
4631  ((tick >= cur->device->lines->nextmsgcheck))) {
4632  DEBUG_TIMER("Checking mailbox for MWI\n");
4633  unistim_send_mwi_to_peer(cur, tick);
4634  break;
4635  }
4636  }
4637  cur = cur->next;
4638  }
4640  DEBUG_TIMER("Waiting for %dus\n", dw_timeout);
4641  res = dw_timeout;
4642  /* We should not wait more than IDLE_WAIT */
4643  if ((res < 0) || (res > IDLE_WAIT))
4644  res = IDLE_WAIT;
4645  /* Wait for UDP messages for a maximum of res us */
4646  res = ast_io_wait(io, res); /* This function will call unistimsock_read if a packet is received */
4647  /* Check for a reload request */
4649  reloading = unistim_reloading;
4650  unistim_reloading = 0;
4652  if (reloading) {
4653  ast_verb(1, "Reloading unistim.conf...\n");
4654  reload_config();
4655  }
4656  pthread_testcancel();
4657  }
4658  /* Never reached */
4659  return NULL;
4660 }
int ast_io_wait(struct io_context *ioc, int howlong)
Waits for IO.
Definition: io.c:273
static struct unistimsession * sessions
static int unistimsock
Definition: chan_unistim.c:215
static int send_retransmit(struct unistimsession *pte)
static struct io_context * io
Definition: chan_unistim.c:224
static void send_ping(struct unistimsession *pte)
Definition: chan_unistim.c:832
#define DEBUG_TIMER
Definition: chan_unistim.c:209
#define AST_IO_IN
Definition: io.h:33
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:157
#define IDLE_WAIT
Definition: chan_unistim.c:93
#define ast_mutex_lock(a)
Definition: lock.h:155
#define ast_verb(level,...)
Definition: logger.h:243
static ast_mutex_t sessionlock
Definition: chan_unistim.c:247
static int unistim_send_mwi_to_peer(struct unistimsession *s, unsigned int tick)
struct unistim_device * device
Definition: chan_unistim.c:496
struct unistimsession * next
Definition: chan_unistim.c:497
static int reload_config(void)
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition: strings.h:63
char mailbox[AST_MAX_EXTENSION]
Definition: chan_unistim.c:401
time_t nextmsgcheck
Definition: chan_unistim.c:405
struct unistim_line * lines
Definition: chan_unistim.c:473
static int unistim_reloading
Definition: chan_unistim.c:233
static unsigned int get_tick_count(void)
Definition: chan_unistim.c:736
static int unistimsock_read(int *id, int fd, short events, void *ignore)
static ast_mutex_t unistim_reload_lock
Definition: chan_unistim.c:234
#define ast_mutex_unlock(a)
Definition: lock.h:156
static struct unistim_subchannel* find_subchannel_by_name ( const char *  dest)
static

Definition at line 4209 of file chan_unistim.c.

References ast_copy_string(), ast_log(), ast_mutex_lock, ast_mutex_unlock, ast_verb, devicelock, devices, unistim_device::lines, LOG_NOTICE, LOG_WARNING, unistim_line::name, unistim_device::name, unistim_line::next, unistim_device::next, unistim_subchannel::ringstyle, unistim_subchannel::ringvolume, SUB_REAL, and unistim_line::subs.

Referenced by unistim_request(), and unistim_sp().

4210 {
4211  struct unistim_line *l;
4212  struct unistim_device *d;
4213  char line[256];
4214  char *at;
4215  char *device;
4216 
4217  ast_copy_string(line, dest, sizeof(line));
4218  at = strchr(line, '@');
4219  if (!at) {
4220  ast_log(LOG_NOTICE, "Device '%s' has no @ (at) sign!\n", dest);
4221  return NULL;
4222  }
4223  *at = '\0';
4224  at++;
4225  device = at;
4227  d = devices;
4228  at = strchr(device, '/'); /* Extra options ? */
4229  if (at)
4230  *at = '\0';
4231  while (d) {
4232  if (!strcasecmp(d->name, device)) {
4233  if (unistimdebug)
4234  ast_verb(0, "Found device: %s\n", d->name);
4235  /* Found the device */
4236  l = d->lines;
4237  while (l) {
4238  /* Search for the right line */
4239  if (!strcasecmp(l->name, line)) {
4240  l->subs[SUB_REAL]->ringvolume = -1;
4241  l->subs[SUB_REAL]->ringstyle = -1;
4242  if (at) { /* Other options ? */
4243  at++; /* Skip slash */
4244  if (*at == 'r') { /* distinctive ring */
4245  at++;
4246  if ((*at < '0') || (*at > '7')) /* ring style */
4247  ast_log(LOG_WARNING, "Invalid ring selection (%s)", at);
4248  else {
4249  char ring_volume = -1;
4250  char ring_style = *at - '0';
4251  at++;
4252  if ((*at >= '0') && (*at <= '3')) /* ring volume */
4253  ring_volume = *at - '0';
4254  if (unistimdebug)
4255  ast_verb(0, "Distinctive ring : style #%d volume %d\n",
4256  ring_style, ring_volume);
4257  l->subs[SUB_REAL]->ringvolume = ring_volume;
4258  l->subs[SUB_REAL]->ringstyle = ring_style;
4259  }
4260  }
4261  }
4263  return l->subs[SUB_REAL];
4264  }
4265  l = l->next;
4266  }
4267  }
4268  d = d->next;
4269  }
4270  /* Device not found */
4272 
4273  return NULL;
4274 }
A device containing one or more lines.
Definition: chan_unistim.c:427
char name[DEVICE_NAME_LEN]
Definition: chan_unistim.c:435
#define LOG_WARNING
Definition: logger.h:144
#define ast_mutex_lock(a)
Definition: lock.h:155
#define ast_verb(level,...)
Definition: logger.h:243
struct unistim_subchannel * subs[MAX_SUBS]
Definition: chan_unistim.c:391
static int unistimdebug
Definition: chan_unistim.c:211
char name[80]
Definition: chan_unistim.c:387
struct unistim_line * next
Definition: chan_unistim.c:420
static ast_mutex_t devicelock
Definition: chan_unistim.c:249
struct unistim_device * next
Definition: chan_unistim.c:476
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
#define LOG_NOTICE
Definition: logger.h:133
struct unistim_line * lines
Definition: chan_unistim.c:473
static struct unistim_device * devices
#define SUB_REAL
Definition: chan_unistim.c:105
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:223
#define ast_mutex_unlock(a)
Definition: lock.h:156
static void finish_bookmark ( void  )
static

Definition at line 5053 of file chan_unistim.c.

References ast_log(), devices, LOG_NOTICE, unistim_device::name, unistim_device::next, unistim_device::softkeydevice, unistim_device::softkeyicon, and unistim_device::sp.

Referenced by reload_config().

5054 {
5055  struct unistim_device *d = devices;
5056  int i;
5057  while (d) {
5058  for (i = 0; i < 6; i++) {
5059  if (d->softkeyicon[i] == 1) { /* Something for us */
5060  struct unistim_device *d2 = devices;
5061  while (d2) {
5062  if (!strcmp(d->softkeydevice[i], d2->name)) {
5063  d->sp[i] = d2;
5064  d->softkeyicon[i] = 0;
5065  break;
5066  }
5067  d2 = d2->next;
5068  }
5069  if (d->sp[i] == NULL)
5070  ast_log(LOG_NOTICE, "Bookmark entry with device %s not found\n",
5071  d->softkeydevice[i]);
5072  }
5073  }
5074  d = d->next;
5075  }
5076 }
A device containing one or more lines.
Definition: chan_unistim.c:427
char name[DEVICE_NAME_LEN]
Definition: chan_unistim.c:435
struct unistim_device * next
Definition: chan_unistim.c:476
char softkeydevice[6][16]
Definition: chan_unistim.c:440
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
#define LOG_NOTICE
Definition: logger.h:133
static struct unistim_device * devices
struct unistim_device * sp[6]
Definition: chan_unistim.c:441
char softkeyicon[6]
Definition: chan_unistim.c:439
static unsigned int get_tick_count ( void  )
static

Definition at line 736 of file chan_unistim.c.

References ast_tvnow().

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

737 {
738  struct timeval now = ast_tvnow();
739 
740  return (now.tv_sec * 1000) + (now.tv_usec / 1000);
741 }
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
Definition: time.h:142
static int get_to_address ( int  fd,
struct sockaddr_in *  toAddr 
)
static

Definition at line 842 of file chan_unistim.c.

References ast_log(), errno, len(), and LOG_WARNING.

Referenced by create_client().

843 {
844 #ifdef HAVE_PKTINFO
845  int err;
846  struct msghdr msg;
847  struct {
848  struct cmsghdr cm;
849  int len;
850  struct in_addr address;
851  } ip_msg;
852 
853  /* Zero out the structures before we use them */
854  /* This sets several key values to NULL */
855  memset(&msg, 0, sizeof(msg));
856  memset(&ip_msg, 0, sizeof(ip_msg));
857 
858  /* Initialize the message structure */
859  msg.msg_control = &ip_msg;
860  msg.msg_controllen = sizeof(ip_msg);
861  /* Get info about the incoming packet */
862  err = recvmsg(fd, &msg, MSG_PEEK);
863  if (err == -1)
864  ast_log(LOG_WARNING, "recvmsg returned an error: %s\n", strerror(errno));
865  memcpy(&toAddr->sin_addr, &ip_msg.address, sizeof(struct in_addr));
866  return err;
867 #else
868  memcpy(&toAddr, &public_ip, sizeof(&toAddr));
869  return 0;
870 #endif
871 }
#define LOG_WARNING
Definition: logger.h:144
static struct sockaddr_in public_ip
Definition: chan_unistim.c:226
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
int errno
static void handle_dial_page ( struct unistimsession pte)
static

Definition at line 2257 of file chan_unistim.c.

References ast_copy_string(), unistim_device::call_forward, change_favorite_icon(), unistimsession::device, FAV_ICON_NONE, FAV_ICON_PHONE_BLACK, unistim_device::height, unistim_device::missed_call, MUTE_OFF, unistim_device::output, OUTPUT_HANDSET, OUTPUT_SPEAKER, unistim_device::phone_number, unistim_device::receiver_state, send_blink_cursor(), send_cursor_pos(), send_led_update(), send_select_output(), send_text(), send_text_status(), SendDialTone(), Sendicon(), unistim_device::size_phone_number, unistimsession::state, STATE_DIALPAGE, STATE_ONHOOK, TEXT_LENGTH_MAX, TEXT_LINE0, TEXT_LINE1, TEXT_LINE2, TEXT_NORMAL, and unistim_device::volume.

Referenced by key_main_page(), process_request(), and TransferCallStep1().

2258 {
2259  pte->state = STATE_DIALPAGE;
2260  if (pte->device->call_forward[0] == -1) {
2261  send_text(TEXT_LINE0, TEXT_NORMAL, pte, "");
2262  send_text(TEXT_LINE1, TEXT_NORMAL, pte, "Enter forward");
2263  send_text_status(pte, "ForwardCancel BackSpcErase");
2264  if (pte->device->call_forward[1] != 0) {
2265  char tmp[TEXT_LENGTH_MAX + 1];
2266 
2268  sizeof(pte->device->phone_number));
2269  pte->device->size_phone_number = strlen(pte->device->phone_number);
2270  if (pte->device->size_phone_number > 15)
2271  pte->device->size_phone_number = 15;
2272  strcpy(tmp, "Number : ...............");
2273  memcpy(tmp + 9, pte->device->phone_number, pte->device->size_phone_number);
2274 
2275  if (pte->device->height == 1) {
2276  send_text(TEXT_LINE0, TEXT_NORMAL, pte, tmp);
2277  send_blink_cursor(pte);
2278  send_cursor_pos(pte,
2279  (unsigned char) (TEXT_LINE0 + 0x09 +
2280  pte->device->size_phone_number));
2281  } else {
2282  send_text(TEXT_LINE2, TEXT_NORMAL, pte, tmp);
2283  send_blink_cursor(pte);
2284  send_cursor_pos(pte,
2285  (unsigned char) (TEXT_LINE2 + 0x09 +
2286  pte->device->size_phone_number));
2287  }
2288 
2289  send_led_update(pte, 0);
2290  return;
2291  }
2292  } else {
2293  if ((pte->device->output == OUTPUT_HANDSET) &&
2294  (pte->device->receiver_state == STATE_ONHOOK))
2296  else
2297  send_select_output(pte, pte->device->output, pte->device->volume, MUTE_OFF);
2298  SendDialTone(pte);
2299 
2300  if (pte->device->height > 1) {
2301  send_text(TEXT_LINE0, TEXT_NORMAL, pte, "Enter the number to dial");
2302  send_text(TEXT_LINE1, TEXT_NORMAL, pte, "and press Call");
2303  }
2304  send_text_status(pte, "Call Redial BackSpcErase");
2305  }
2306 
2307  if (pte->device->height == 1) {
2308  send_text(TEXT_LINE0, TEXT_NORMAL, pte, "Number : ...............");
2309  send_blink_cursor(pte);
2310  send_cursor_pos(pte, TEXT_LINE0 + 0x09);
2311  } else {
2312  send_text(TEXT_LINE2, TEXT_NORMAL, pte, "Number : ...............");
2313  send_blink_cursor(pte);
2314  send_cursor_pos(pte, TEXT_LINE2 + 0x09);
2315  }
2316  pte->device->size_phone_number = 0;
2317  pte->device->phone_number[0] = 0;
2320  pte->device->missed_call = 0;
2321  send_led_update(pte, 0);
2322  return;
2323 }
char call_forward[AST_MAX_EXTENSION]
Definition: chan_unistim.c:461
#define TEXT_LINE2
Definition: chan_unistim.c:144
#define TEXT_LINE1
Definition: chan_unistim.c:143
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)
char phone_number[16]
Definition: chan_unistim.c:430
#define TEXT_NORMAL
Definition: chan_unistim.c:145
#define TEXT_LENGTH_MAX
Definition: chan_unistim.c:141
static void send_blink_cursor(struct unistimsession *pte)
struct unistim_device * device
Definition: chan_unistim.c:496
#define MUTE_OFF
Definition: chan_unistim.c:135
#define FAV_ICON_PHONE_BLACK
Definition: chan_unistim.c:160
#define OUTPUT_HANDSET
Definition: chan_unistim.c:126
#define FAV_ICON_NONE
Definition: chan_unistim.c:149
#define TEXT_LINE0
Definition: chan_unistim.c:142
static void SendDialTone(struct unistimsession *pte)
static void send_text_status(struct unistimsession *pte, const char *text)
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)
static void send_cursor_pos(struct unistimsession *pte, unsigned char pos)
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:223
#define OUTPUT_SPEAKER
Definition: chan_unistim.c:128
static void Sendicon(unsigned char pos, unsigned char status, struct unistimsession *pte)
Definition: chan_unistim.c:972
static void HandleCallIncoming ( struct unistimsession s)
static

Definition at line 2472 of file chan_unistim.c.

References AST_CONTROL_ANSWER, ast_log(), ast_queue_control(), ast_verb, unistimsession::device, unistim_device::lines, LOG_NOTICE, LOG_WARNING, unistim_device::missed_call, MUTE_OFF, unistim_line::name, unistim_device::name, unistim_device::output, OUTPUT_HANDSET, OUTPUT_SPEAKER, unistim_subchannel::owner, unistim_subchannel::parent, unistim_device::receiver_state, unistim_subchannel::rtp, send_no_ring(), send_select_output(), send_start_timer(), send_text(), send_text_status(), unistim_device::start_call_timestamp, start_rtp(), unistimsession::state, STATE_CALL, STATE_ONHOOK, SUB_REAL, unistim_line::subs, TEXT_LINE2, TEXT_NORMAL, unistim_device::volume, and write_history().

Referenced by key_ringing(), and process_request().

2473 {
2474  struct unistim_subchannel *sub;
2475  s->state = STATE_CALL;
2476  s->device->missed_call = 0;
2477  send_no_ring(s);
2478  sub = s->device->lines->subs[SUB_REAL];
2479  if (!sub) {
2480  ast_log(LOG_NOTICE, "No available lines on: %s\n", s->device->name);
2481  return;
2482  } else if (unistimdebug)
2483  ast_verb(0, "Handle Call Incoming for %s@%s\n", sub->parent->name,
2484  s->device->name);
2485  start_rtp(sub);
2486  if (!sub->rtp)
2487  ast_log(LOG_WARNING, "Unable to create channel for %s@%s\n", sub->parent->name,
2488  s->device->name);
2490  send_text(TEXT_LINE2, TEXT_NORMAL, s, "is on-line");
2491  send_text_status(s, "Hangup Transf");
2492  send_start_timer(s);
2493 
2494  if ((s->device->output == OUTPUT_HANDSET) &&
2497  else
2499  s->device->start_call_timestamp = time(0);
2500  write_history(s, 'i', 0);
2501  return;
2502 }
struct ast_channel * owner
Definition: chan_unistim.c:371
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 with payload.
Definition: channel.c:1601
char name[DEVICE_NAME_LEN]
Definition: chan_unistim.c:435
#define TEXT_LINE2
Definition: chan_unistim.c:144
time_t start_call_timestamp
Definition: chan_unistim.c:471
struct ast_rtp_instance * rtp
Definition: chan_unistim.c:375
#define LOG_WARNING
Definition: logger.h:144
static void send_select_output(struct unistimsession *pte, unsigned char output, unsigned char volume, unsigned char mute)
#define TEXT_NORMAL
Definition: chan_unistim.c:145
#define ast_verb(level,...)
Definition: logger.h:243
struct unistim_subchannel * subs[MAX_SUBS]
Definition: chan_unistim.c:391
static int unistimdebug
Definition: chan_unistim.c:211
struct unistim_device * device
Definition: chan_unistim.c:496
char name[80]
Definition: chan_unistim.c:387
#define MUTE_OFF
Definition: chan_unistim.c:135
static void start_rtp(struct unistim_subchannel *sub)
#define OUTPUT_HANDSET
Definition: chan_unistim.c:126
static void send_text_status(struct unistimsession *pte, const char *text)
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
#define LOG_NOTICE
Definition: logger.h:133
struct unistim_line * lines
Definition: chan_unistim.c:473
static void send_text(unsigned char pos, unsigned char inverse, struct unistimsession *pte, const char *text)
#define SUB_REAL
Definition: chan_unistim.c:105
static void send_no_ring(struct unistimsession *pte)
struct unistim_line * parent
Definition: chan_unistim.c:373
#define OUTPUT_SPEAKER
Definition: chan_unistim.c:128
static void send_start_timer(struct unistimsession *pte)
Definition: chan_unistim.c:954
static void HandleCallOutgoing ( struct unistimsession s)
static

Definition at line 2372 of file chan_unistim.c.

References alloc_sub(), AST_CAUSE_SWITCH_CONGESTION, ast_channel_stop_silence_generator(), ast_debug, ast_hangup(), ast_log(), ast_pthread_create, ast_queue_hangup_with_cause(), AST_STATE_DOWN, ast_verb, unistimsession::device, display_last_error(), unistim_device::height, unistim_device::lines, LOG_NOTICE, LOG_WARNING, unistim_device::moh, MUTE_OFF, unistim_line::name, unistim_device::name, ast_channel::name, unistim_device::output, unistim_subchannel::owner, unistim_subchannel::parent, unistim_device::phone_number, unistim_subchannel::rtp, send_select_output(), send_text(), send_text_status(), send_tone(), unistim_device::silence_generator, start_rtp(), unistimsession::state, STATE_CALL, SUB_REAL, SUB_THREEWAY, unistim_line::subs, unistim_subchannel::subtype, swap_subs(), TEXT_LINE0, TEXT_LINE1, TEXT_LINE2, TEXT_NORMAL, unistim_new(), unistim_ss(), and unistim_device::volume.

Referenced by key_dial_page(), key_main_page(), and Keyfavorite().

2373 {
2374  struct ast_channel *c;
2375  struct unistim_subchannel *sub;
2376  pthread_t t;
2377  s->state = STATE_CALL;
2378  sub = s->device->lines->subs[SUB_REAL];
2379  if (!sub) {
2380  ast_log(LOG_NOTICE, "No available lines on: %s\n", s->device->name);
2381  return;
2382  }
2383  if (!sub->owner) { /* A call is already in progress ? */
2384  c = unistim_new(sub, AST_STATE_DOWN, NULL); /* No, starting a new one */
2385  if (c) {
2386  /* Need to start RTP before calling ast_pbx_run */
2387  if (!sub->rtp)
2388  start_rtp(sub);
2390 
2391  if (s->device->height == 1) {
2393  } else {
2394  send_text(TEXT_LINE0, TEXT_NORMAL, s, "Calling :");
2396  send_text(TEXT_LINE2, TEXT_NORMAL, s, "Dialing...");
2397  }
2398  send_text_status(s, "Hangup");
2399 
2400  /* start switch */
2401  if (ast_pthread_create(&t, NULL, unistim_ss, c)) {
2402  display_last_error("Unable to create switch thread");
2404  }
2405  } else
2406  ast_log(LOG_WARNING, "Unable to create channel for %s@%s\n",
2407  sub->parent->name, s->device->name);
2408  } else { /* We already have a call, so we switch in a threeway call */
2409 
2410  if (s->device->moh) {
2411  struct unistim_subchannel *subchannel;
2412  struct unistim_line *p = s->device->lines;
2413  subchannel = p->subs[SUB_REAL];
2414 
2415  if (!subchannel->owner) {
2416  ast_log(LOG_WARNING, "Unable to find subchannel for music on hold\n");
2417  return;
2418  }
2419  if (p->subs[SUB_THREEWAY]) {
2421  "Can't transfer while an another transfer is taking place\n");
2422  return;
2423  }
2424  if (!alloc_sub(p, SUB_THREEWAY)) {
2425  ast_log(LOG_WARNING, "Unable to allocate three-way subchannel\n");
2426  return;
2427  }
2428  /* Stop the silence generator */
2429  if (s->device->silence_generator) {
2430  if (unistimdebug)
2431  ast_verb(0, "Stopping silence generator\n");
2434  s->device->silence_generator = NULL;
2435  }
2436  send_tone(s, 0, 0);
2437  /* Make new channel */
2438  c = unistim_new(p->subs[SUB_THREEWAY], AST_STATE_DOWN, NULL);
2439  if (!c) {
2440  ast_log(LOG_WARNING, "Cannot allocate new structure on channel %p\n", p);
2441  return;
2442  }
2443  /* Swap things around between the three-way and real call */
2446 
2447  if (s->device->height == 1) {
2449  } else {
2450  send_text(TEXT_LINE0, TEXT_NORMAL, s, "Calling (pre-transfer)");
2452  send_text(TEXT_LINE2, TEXT_NORMAL, s, "Dialing...");
2453  }
2454  send_text_status(s, "TransfrCancel");
2455 
2456  if (ast_pthread_create(&t, NULL, unistim_ss, p->subs[SUB_THREEWAY]->owner)) {
2457  ast_log(LOG_WARNING, "Unable to start simple switch on channel %p\n", p);
2458  ast_hangup(c);
2459  return;
2460  }
2461  if (unistimdebug)
2462  ast_verb(0, "Started three way call on channel %p (%s) subchan %u\n",
2464  p->subs[SUB_THREEWAY]->subtype);
2465  } else
2466  ast_debug(1, "Current sub [%s] already has owner\n", sub->owner->name);
2467  }
2468  return;
2469 }
struct ast_channel * owner
Definition: chan_unistim.c:371
int ast_hangup(struct ast_channel *chan)
Hang up a channel.
Definition: channel.c:2804
static int alloc_sub(struct unistim_line *l, int x)
Main Channel structure associated with a channel.
Definition: channel.h:742
char name[DEVICE_NAME_LEN]
Definition: chan_unistim.c:435
#define TEXT_LINE2
Definition: chan_unistim.c:144
static struct ast_channel * unistim_new(struct unistim_subchannel *sub, int state, const char *linkedid)
struct ast_rtp_instance * rtp
Definition: chan_unistim.c:375
#define AST_CAUSE_SWITCH_CONGESTION
Definition: causes.h:122
#define TEXT_LINE1
Definition: chan_unistim.c:143
#define LOG_WARNING
Definition: logger.h:144
#define SUB_THREEWAY
Definition: chan_unistim.c:106
static void send_select_output(struct unistimsession *pte, unsigned char output, unsigned char volume, unsigned char mute)
char phone_number[16]
Definition: chan_unistim.c:430
#define TEXT_NORMAL
Definition: chan_unistim.c:145
static void * unistim_ss(void *data)
#define ast_verb(level,...)
Definition: logger.h:243
struct unistim_subchannel * subs[MAX_SUBS]
Definition: chan_unistim.c:391
static int unistimdebug
Definition: chan_unistim.c:211
int ast_queue_hangup_with_cause(struct ast_channel *chan, int cause)
Queue a hangup frame with hangupcause set.
Definition: channel.c:1581
struct unistim_device * device
Definition: chan_unistim.c:496
unsigned int subtype
Definition: chan_unistim.c:369
char name[80]
Definition: chan_unistim.c:387
static void send_tone(struct unistimsession *pte, uint16_t tone1, uint16_t tone2)
Definition: chan_unistim.c:983
#define MUTE_OFF
Definition: chan_unistim.c:135
static void start_rtp(struct unistim_subchannel *sub)
#define ast_debug(level,...)
Log a DEBUG message.
Definition: logger.h:236
#define TEXT_LINE0
Definition: chan_unistim.c:142
static void send_text_status(struct unistimsession *pte, const char *text)
static void swap_subs(struct unistim_line *p, int a, int b)
const ast_string_field name
Definition: channel.h:787
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
#define LOG_NOTICE
Definition: logger.h:133
struct unistim_line * lines
Definition: chan_unistim.c:473
void ast_channel_stop_silence_generator(struct ast_channel *chan, struct ast_silence_generator *state)
Stops a previously-started silence generator on the given channel.
Definition: channel.c:8355
#define ast_pthread_create(a, b, c, d)
Definition: utils.h:418
static void send_text(unsigned char pos, unsigned char inverse, struct unistimsession *pte, const char *text)
#define SUB_REAL
Definition: chan_unistim.c:105
struct unistim_line * parent
Definition: chan_unistim.c:373
static void display_last_error(const char *sz_msg)
Definition: chan_unistim.c:725
struct ast_silence_generator * silence_generator
Definition: chan_unistim.c:472
static void HandleSelectCodec ( struct unistimsession pte)
static

Definition at line 2819 of file chan_unistim.c.

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

Referenced by key_main_page().

2820 {
2821  char buf[30], buf2[5];
2822 
2823  pte->state = STATE_SELECTCODEC;
2824  strcpy(buf, "Using codec ");
2825  sprintf(buf2, "%d", pte->device->codec_number);
2826  strcat(buf, buf2);
2827  strcat(buf, " (G711u=0,");
2828 
2829  send_text(TEXT_LINE0, TEXT_NORMAL, pte, buf);
2830  send_text(TEXT_LINE1, TEXT_NORMAL, pte, "G723=4,G711a=8,G729A=18)");
2832  send_blink_cursor(pte);
2834  pte->size_buff_entry = 0;
2835  send_text_status(pte, "Select BackSpcErase Cancel");
2836  return;
2837 }
#define TEXT_LINE2
Definition: chan_unistim.c:144
#define TEXT_LINE1
Definition: chan_unistim.c:143
static struct ast_threadstorage buf2
#define TEXT_NORMAL
Definition: chan_unistim.c:145
static void send_blink_cursor(struct unistimsession *pte)
struct unistim_device * device
Definition: chan_unistim.c:496
#define TEXT_LINE0
Definition: chan_unistim.c:142
static void send_text_status(struct unistimsession *pte, const char *text)
#define TEXT_INVERSE
Definition: chan_unistim.c:146
static void send_text(unsigned char pos, unsigned char inverse, struct unistimsession *pte, const char *text)
static void send_cursor_pos(struct unistimsession *pte, unsigned char pos)
#define SELECTCODEC_START_ENTRY_POS
#define SELECTCODEC_MSG
static void IgnoreCall ( struct unistimsession pte)
static

Definition at line 1997 of file chan_unistim.c.

References send_no_ring().

Referenced by key_ringing().

1998 {
1999  send_no_ring(pte);
2000  return;
2001 }
static void send_no_ring(struct unistimsession *pte)
static void in_band_indication ( struct ast_channel ast,
const struct ast_tone_zone tz,
const char *  indication 
)
static

Definition at line 4122 of file chan_unistim.c.

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

Referenced by unistim_indicate().

4124 {
4125  struct ast_tone_zone_sound *ts = NULL;
4126 
4127  if ((ts = ast_get_indication_tone(tz, indication))) {
4128  ast_playtones_start(ast, 0, ts->data, 1);
4129  ts = ast_tone_zone_sound_unref(ts);
4130  } else {
4131  ast_log(LOG_WARNING, "Unable to get indication tone for %s\n", indication);
4132  }
4133 }
#define LOG_WARNING
Definition: logger.h:144
static struct ast_tone_zone_sound * ast_tone_zone_sound_unref(struct ast_tone_zone_sound *ts)
Release a reference to an ast_tone_zone_sound.
Definition: indications.h:226
Description of a tone.
Definition: indications.h:36
struct ast_tone_zone_sound * ast_get_indication_tone(const struct ast_tone_zone *zone, const char *indication)
Locate a tone zone sound.
Definition: indications.c:473
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
int ast_playtones_start(struct ast_channel *chan, int vol, const char *tonelist, int interruptible)
Start playing a list of tones on a channel.
Definition: indications.c:319
const char * data
Description of a tone.
Definition: indications.h:53
static void init_phone_step2 ( struct unistimsession pte)
static

Definition at line 3335 of file chan_unistim.c.

References ast_verb, AUTOPROVISIONING_TN, BUFFSEND, unistim_device::contrast, unistimsession::device, unistimsession::macaddr, refresh_all_favorite(), send_client(), send_date_time2(), send_date_time3(), send_favorite(), send_led_update(), send_no_ring(), send_ping(), send_text(), send_text_status(), send_texttitle(), show_main_page(), ShowExtensionPage(), SIZE_HEADER, unistimsession::state, STATE_MAINPAGE, TEXT_LINE0, TEXT_LINE1, TEXT_LINE2, and TEXT_NORMAL.

Referenced by process_request().

3336 {
3337  BUFFSEND;
3338  if (unistimdebug)
3339  ast_verb(0, "Sending S4\n");
3340  memcpy(buffsend + SIZE_HEADER, packet_send_s4, sizeof(packet_send_s4));
3341  send_client(SIZE_HEADER + sizeof(packet_send_s4), buffsend, pte);
3342  send_date_time2(pte);
3343  send_date_time3(pte);
3344  if (unistimdebug)
3345  ast_verb(0, "Sending S7\n");
3346  memcpy(buffsend + SIZE_HEADER, packet_send_S7, sizeof(packet_send_S7));
3347  send_client(SIZE_HEADER + sizeof(packet_send_S7), buffsend, pte);
3348  if (unistimdebug)
3349  ast_verb(0, "Sending Contrast\n");
3350  memcpy(buffsend + SIZE_HEADER, packet_send_Contrast, sizeof(packet_send_Contrast));
3351  if (pte->device != NULL)
3352  buffsend[9] = pte->device->contrast;
3353  send_client(SIZE_HEADER + sizeof(packet_send_Contrast), buffsend, pte);
3354 
3355  if (unistimdebug)
3356  ast_verb(0, "Sending S9\n");
3357  memcpy(buffsend + SIZE_HEADER, packet_send_s9, sizeof(packet_send_s9));
3358  send_client(SIZE_HEADER + sizeof(packet_send_s9), buffsend, pte);
3359  send_no_ring(pte);
3360 
3361  if (unistimdebug)
3362  ast_verb(0, "Sending S7\n");
3363  memcpy(buffsend + SIZE_HEADER, packet_send_S7, sizeof(packet_send_S7));
3364  send_client(SIZE_HEADER + sizeof(packet_send_S7), buffsend, pte);
3365  send_led_update(pte, 0);
3366  send_ping(pte);
3367  if (pte->state < STATE_MAINPAGE) {
3369  ShowExtensionPage(pte);
3370  return;
3371  } else {
3372  int i;
3373  char tmp[30];
3374 
3375  for (i = 1; i < 6; i++)
3376  send_favorite(i, 0, pte, "");
3377  send_text(TEXT_LINE0, TEXT_NORMAL, pte, "Sorry, this phone is not");
3378  send_text(TEXT_LINE1, TEXT_NORMAL, pte, "registered in unistim.cfg");
3379  strcpy(tmp, "MAC = ");
3380  strcat(tmp, pte->macaddr);
3381  send_text(TEXT_LINE2, TEXT_NORMAL, pte, tmp);
3382  send_text_status(pte, "");
3383  send_texttitle(pte, "UNISTIM for*");
3384  return;
3385  }
3386  }
3387  show_main_page(pte);
3388  refresh_all_favorite(pte);
3389  if (unistimdebug)
3390  ast_verb(0, "Sending arrow\n");
3391  memcpy(buffsend + SIZE_HEADER, packet_send_arrow, sizeof(packet_send_arrow));
3392  send_client(SIZE_HEADER + sizeof(packet_send_arrow), buffsend, pte);
3393  return;
3394 }
static void send_client(int size, const unsigned char *data, struct unistimsession *pte)
Definition: chan_unistim.c:801
#define TEXT_LINE2
Definition: chan_unistim.c:144
static const unsigned char packet_send_s4[]
Definition: chan_unistim.c:545
#define TEXT_LINE1
Definition: chan_unistim.c:143
static const unsigned char packet_send_Contrast[]
Definition: chan_unistim.c:629
static void send_ping(struct unistimsession *pte)
Definition: chan_unistim.c:832
#define BUFFSEND
Definition: chan_unistim.c:675
#define TEXT_NORMAL
Definition: chan_unistim.c:145
static void send_date_time3(struct unistimsession *pte)
static const unsigned char packet_send_S7[]
Definition: chan_unistim.c:636
#define ast_verb(level,...)
Definition: logger.h:243
static int unistimdebug
Definition: chan_unistim.c:211
struct unistim_device * device
Definition: chan_unistim.c:496
static void send_texttitle(struct unistimsession *pte, const char *text)
static void refresh_all_favorite(struct unistimsession *pte)
char macaddr[18]
Definition: chan_unistim.c:493
#define SIZE_HEADER
Definition: chan_unistim.c:139
#define TEXT_LINE0
Definition: chan_unistim.c:142
static void send_favorite(unsigned char pos, unsigned char status, struct unistimsession *pte, const char *text)
static void ShowExtensionPage(struct unistimsession *pte)
static void send_text_status(struct unistimsession *pte, const char *text)
static void show_main_page(struct unistimsession *pte)
static const unsigned char packet_send_s9[]
Definition: chan_unistim.c:585
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)
static void send_no_ring(struct unistimsession *pte)
static enum autoprovision autoprovisioning
Definition: chan_unistim.c:213
static const unsigned char packet_send_arrow[]
Definition: chan_unistim.c:624
static void send_date_time2(struct unistimsession *pte)
static void key_call ( struct unistimsession pte,
char  keycode 
)
static

Definition at line 2576 of file chan_unistim.c.

References ast_bridged_channel(), ast_log(), ast_moh_start(), ast_moh_stop(), close_call(), unistimsession::device, KEY_0, KEY_FUNC1, KEY_FUNC2, KEY_HANGUP, KEY_HEADPHN, KEY_LOUDSPK, KEY_MUTE, KEY_ONHOLD, KEY_SHARP, KEY_STAR, unistim_device::lines, LOG_WARNING, unistim_device::moh, unistim_line::musicclass, unistim_device::mute, MUTE_OFF, MUTE_ON, unistim_device::output, OUTPUT_HANDSET, OUTPUT_HEADPHONE, OUTPUT_SPEAKER, unistim_subchannel::owner, unistim_device::previous_output, send_select_output(), SUB_REAL, unistim_line::subs, TransferCallStep1(), unistim_do_senddigit(), and unistim_device::volume.

Referenced by process_request().

2577 {
2578  if ((keycode >= KEY_0) && (keycode <= KEY_SHARP)) {
2579  if (keycode == KEY_SHARP)
2580  keycode = '#';
2581  else if (keycode == KEY_STAR)
2582  keycode = '*';
2583  else
2584  keycode -= 0x10;
2585  unistim_do_senddigit(pte, keycode);
2586  return;
2587  }
2588  switch (keycode) {
2589  case KEY_HANGUP:
2590  case KEY_FUNC1:
2591  close_call(pte);
2592  break;
2593  case KEY_FUNC2:
2594  TransferCallStep1(pte);
2595  break;
2596  case KEY_HEADPHN:
2597  if (pte->device->output == OUTPUT_HEADPHONE)
2599  else
2601  break;
2602  case KEY_LOUDSPK:
2603  if (pte->device->output != OUTPUT_SPEAKER)
2605  else
2607  MUTE_OFF);
2608  break;
2609  case KEY_MUTE:
2610  if (!pte->device->moh) {
2611  if (pte->device->mute == MUTE_ON)
2612  send_select_output(pte, pte->device->output, pte->device->volume, MUTE_OFF);
2613  else
2614  send_select_output(pte, pte->device->output, pte->device->volume, MUTE_ON);
2615  break;
2616  }
2617  case KEY_ONHOLD:
2618  {
2619  struct unistim_subchannel *sub;
2620  struct ast_channel *bridgepeer = NULL;
2621  sub = pte->device->lines->subs[SUB_REAL];
2622  if (!sub->owner) {
2623  ast_log(LOG_WARNING, "Unable to find subchannel for music on hold\n");
2624  return;
2625  }
2626  if ((bridgepeer = ast_bridged_channel(sub->owner))) {
2627  if (pte->device->moh) {
2628  ast_moh_stop(bridgepeer);
2629  pte->device->moh = 0;
2630  send_select_output(pte, pte->device->output, pte->device->volume,
2631  MUTE_OFF);
2632  } else {
2633  ast_moh_start(bridgepeer, pte->device->lines->musicclass, NULL);
2634  pte->device->moh = 1;
2635  send_select_output(pte, pte->device->output, pte->device->volume,
2636  MUTE_ON);
2637  }
2638  } else
2640  "Unable to find peer subchannel for music on hold\n");
2641  break;
2642  }
2643  }
2644  return;
2645 }
struct ast_channel * owner
Definition: chan_unistim.c:371
Main Channel structure associated with a channel.
Definition: channel.h:742
#define LOG_WARNING
Definition: logger.h:144
static void send_select_output(struct unistimsession *pte, unsigned char output, unsigned char volume, unsigned char mute)
static void close_call(struct unistimsession *pte)
void ast_moh_stop(struct ast_channel *chan)
Turn off music on hold on a given channel.
Definition: channel.c:8051
struct unistim_subchannel * subs[MAX_SUBS]
Definition: chan_unistim.c:391
struct unistim_device * device
Definition: chan_unistim.c:496
#define MUTE_OFF
Definition: chan_unistim.c:135
#define OUTPUT_HEADPHONE
Definition: chan_unistim.c:127
#define OUTPUT_HANDSET
Definition: chan_unistim.c:126
char musicclass[MAX_MUSICCLASS]
Definition: chan_unistim.c:407
static int unistim_do_senddigit(struct unistimsession *pte, char digit)
struct ast_channel * ast_bridged_channel(struct ast_channel *chan)
Find bridged channel.
Definition: channel.c:7160
int ast_moh_start(struct ast_channel *chan, const char *mclass, const char *interpclass)
Turn on music on hold on a given channel.
Definition: channel.c:8040
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
struct unistim_line * lines
Definition: chan_unistim.c:473
#define MUTE_ON
Definition: chan_unistim.c:136
#define SUB_REAL
Definition: chan_unistim.c:105
#define OUTPUT_SPEAKER
Definition: chan_unistim.c:128
static void TransferCallStep1(struct unistimsession *pte)
static void key_dial_page ( struct unistimsession pte,
char  keycode 
)
static

Definition at line 2684 of file chan_unistim.c.

References ast_bridged_channel(), ast_channel_stop_silence_generator(), ast_copy_string(), ast_moh_stop(), ast_strlen_zero(), ast_verb, unistim_device::call_forward, unistimsession::device, HandleCallOutgoing(), unistim_device::height, KEY_0, KEY_FAV1, KEY_FAV2, KEY_FAV3, KEY_FAV4, KEY_FAV5, KEY_FUNC1, KEY_FUNC2, KEY_FUNC3, KEY_FUNC4, KEY_HANGUP, KEY_HEADPHN, KEY_LOUDSPK, KEY_SHARP, KEY_STAR, Keyfavorite(), unistim_device::lines, unistim_device::moh, MUTE_OFF, unistim_device::output, OUTPUT_HANDSET, OUTPUT_HEADPHONE, OUTPUT_SPEAKER, unistim_subchannel::owner, unistim_device::phone_number, unistim_device::previous_output, unistim_device::receiver_state, unistim_device::redial_number, send_blink_cursor(), send_cursor_pos(), send_select_output(), send_text(), send_text_status(), send_tone(), show_main_page(), unistim_device::silence_generator, unistim_device::size_phone_number, unistimsession::state, STATE_CALL, STATE_OFFHOOK, SUB_REAL, unistim_line::subs, TEXT_LINE0, TEXT_LINE1, TEXT_LINE2, TEXT_NORMAL, and unistim_device::volume.

Referenced by key_main_page(), and process_request().

2685 {
2686  if (keycode == KEY_FUNC3) {
2687  if (pte->device->size_phone_number <= 1)
2688  keycode = KEY_FUNC4;
2689  else {
2690  pte->device->size_phone_number -= 2;
2691  keycode = pte->device->phone_number[pte->device->size_phone_number] + 0x10;
2692  }
2693  }
2694  if ((keycode >= KEY_0) && (keycode <= KEY_SHARP)) {
2695  char tmpbuf[] = "Number : ...............";
2696  unsigned int i = 0; /* changed to unsigned due to weird gcc 4.8.1 compiler complaint */
2697 
2698  if (pte->device->size_phone_number >= 15)
2699  return;
2700  if (pte->device->size_phone_number == 0)
2701  send_tone(pte, 0, 0);
2702  while (i < pte->device->size_phone_number) {
2703  tmpbuf[i + 9] = pte->device->phone_number[i];
2704  i++;
2705  }
2706  if (keycode == KEY_SHARP)
2707  keycode = '#';
2708  else if (keycode == KEY_STAR)
2709  keycode = '*';
2710  else
2711  keycode -= 0x10;
2712  tmpbuf[i + 9] = keycode;
2713  pte->device->phone_number[i] = keycode;
2714  pte->device->size_phone_number++;
2715  pte->device->phone_number[i + 1] = 0;
2716  if (pte->device->height == 1) {
2717  send_text(TEXT_LINE0, TEXT_NORMAL, pte, tmpbuf);
2718  } else {
2719  send_text(TEXT_LINE2, TEXT_NORMAL, pte, tmpbuf);
2720  }
2721  send_blink_cursor(pte);
2722  send_cursor_pos(pte, (unsigned char) (TEXT_LINE2 + 0x0a + i));
2723  return;
2724  }
2725  if (keycode == KEY_FUNC4) {
2726 
2727  pte->device->size_phone_number = 0;
2728  if (pte->device->height == 1) {
2729  send_text(TEXT_LINE0, TEXT_NORMAL, pte, "Number : ...............");
2730  send_blink_cursor(pte);
2731  send_cursor_pos(pte, TEXT_LINE0 + 0x09);
2732  } else {
2733  send_text(TEXT_LINE2, TEXT_NORMAL, pte, "Number : ...............");
2734  send_blink_cursor(pte);
2735  send_cursor_pos(pte, TEXT_LINE2 + 0x09);
2736  }
2737  return;
2738  }
2739 
2740  if (pte->device->call_forward[0] == -1) {
2741  if (keycode == KEY_FUNC1) {
2743  sizeof(pte->device->call_forward));
2744  show_main_page(pte);
2745  } else if ((keycode == KEY_FUNC2) || (keycode == KEY_HANGUP)) {
2746  pte->device->call_forward[0] = '\0';
2747  show_main_page(pte);
2748  }
2749  return;
2750  }
2751  switch (keycode) {
2752  case KEY_FUNC2:
2754  break;
2756  sizeof(pte->device->phone_number));
2757  case KEY_FUNC1:
2758  HandleCallOutgoing(pte);
2759  break;
2760  case KEY_HANGUP:
2761  if (pte->device->lines->subs[SUB_REAL]->owner) {
2762  /* Stop the silence generator */
2763  if (pte->device->silence_generator) {
2764  if (unistimdebug)
2765  ast_verb(0, "Stopping silence generator\n");
2767  owner, pte->device->silence_generator);
2768  pte->device->silence_generator = NULL;
2769  }
2770  send_tone(pte, 0, 0);
2772  pte->device->moh = 0;
2773  pte->state = STATE_CALL;
2774 
2775  if (pte->device->height == 1) {
2776  send_text(TEXT_LINE0, TEXT_NORMAL, pte, "Dial Cancel,back to priv. call.");
2777  } else {
2778  send_text(TEXT_LINE0, TEXT_NORMAL, pte, "Dialing canceled,");
2779  send_text(TEXT_LINE1, TEXT_NORMAL, pte, "switching back to");
2780  send_text(TEXT_LINE2, TEXT_NORMAL, pte, "previous call.");
2781  }
2782  send_text_status(pte, "Hangup Transf");
2783  } else
2784  show_main_page(pte);
2785  break;
2786  case KEY_FAV1:
2787  case KEY_FAV2:
2788  case KEY_FAV3:
2789  case KEY_FAV4:
2790  case KEY_FAV5:
2791  Keyfavorite(pte, keycode);
2792  break;
2793  case KEY_LOUDSPK:
2794  if (pte->device->output == OUTPUT_SPEAKER) {
2795  if (pte->device->receiver_state == STATE_OFFHOOK)
2797  MUTE_OFF);
2798  else
2799  show_main_page(pte);
2800  } else
2802  break;
2803  case KEY_HEADPHN:
2804  if (pte->device->output == OUTPUT_HEADPHONE) {
2805  if (pte->device->receiver_state == STATE_OFFHOOK)
2807  else
2808  show_main_page(pte);
2809  } else
2811  break;
2812  }
2813  return;
2814 }
struct ast_channel * owner
Definition: chan_unistim.c:371
char call_forward[AST_MAX_EXTENSION]
Definition: chan_unistim.c:461
#define TEXT_LINE2
Definition: chan_unistim.c:144
#define TEXT_LINE1
Definition: chan_unistim.c:143
static void Keyfavorite(struct unistimsession *pte, char keycode)
static void send_select_output(struct unistimsession *pte, unsigned char output, unsigned char volume, unsigned char mute)
char phone_number[16]
Definition: chan_unistim.c:430
#define TEXT_NORMAL
Definition: chan_unistim.c:145
void ast_moh_stop(struct ast_channel *chan)
Turn off music on hold on a given channel.
Definition: channel.c:8051
static void HandleCallOutgoing(struct unistimsession *s)
#define ast_verb(level,...)
Definition: logger.h:243
struct unistim_subchannel * subs[MAX_SUBS]
Definition: chan_unistim.c:391
static int unistimdebug
Definition: chan_unistim.c:211
static void send_blink_cursor(struct unistimsession *pte)
struct unistim_device * device
Definition: chan_unistim.c:496
static void send_tone(struct unistimsession *pte, uint16_t tone1, uint16_t tone2)
Definition: chan_unistim.c:983
#define MUTE_OFF
Definition: chan_unistim.c:135
#define OUTPUT_HEADPHONE
Definition: chan_unistim.c:127
#define OUTPUT_HANDSET
Definition: chan_unistim.c:126
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition: strings.h:63
#define TEXT_LINE0
Definition: chan_unistim.c:142
static void send_text_status(struct unistimsession *pte, const char *text)
static void show_main_page(struct unistimsession *pte)
struct ast_channel * ast_bridged_channel(struct ast_channel *chan)
Find bridged channel.
Definition: channel.c:7160
char redial_number[16]
Definition: chan_unistim.c:431
struct unistim_line * lines
Definition: chan_unistim.c:473
void ast_channel_stop_silence_generator(struct ast_channel *chan, struct ast_silence_generator *state)
Stops a previously-started silence generator on the given channel.
Definition: channel.c:8355
static void send_text(unsigned char pos, unsigned char inverse, struct unistimsession *pte, const char *text)
#define SUB_REAL
Definition: chan_unistim.c:105
static void send_cursor_pos(struct unistimsession *pte, unsigned char pos)
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:223
#define OUTPUT_SPEAKER
Definition: chan_unistim.c:128
struct ast_silence_generator * silence_generator
Definition: chan_unistim.c:472
static void key_history ( struct unistimsession pte,
char  keycode 
)
static

Definition at line 3267 of file chan_unistim.c.

References ast_copy_string(), unistimsession::buff_entry, unistimsession::device, display_last_error(), f, KEY_DOWN, KEY_FUNC1, KEY_FUNC2, KEY_FUNC3, KEY_FUNC4, KEY_HANGUP, KEY_LEFT, key_main_page(), KEY_RCVHIST, KEY_RIGHT, KEY_SNDHIST, KEY_UP, unistim_device::lst_cid, OpenHistory(), unistim_device::redial_number, ReformatNumber(), show_entry_history(), show_history(), show_main_page(), and TEXT_LENGTH_MAX.

Referenced by process_request().

3268 {
3269  FILE *f;
3270  char count;
3271  long offset;
3272 
3273  switch (keycode) {
3274  case KEY_UP:
3275  case KEY_LEFT:
3276  case KEY_FUNC1:
3277  if (pte->buff_entry[2] <= 1)
3278  return;
3279  pte->buff_entry[2]--;
3280  count = OpenHistory(pte, pte->buff_entry[0], &f);
3281  if (!count)
3282  return;
3283  offset = ((pte->buff_entry[2] - 1) * TEXT_LENGTH_MAX * 3);
3284  if (fseek(f, offset, SEEK_CUR)) {
3285  display_last_error("Unable to seek history entry.");
3286  fclose(f);
3287  return;
3288  }
3289  show_entry_history(pte, &f);
3290  break;
3291  case KEY_DOWN:
3292  case KEY_RIGHT:
3293  case KEY_FUNC2:
3294  if (pte->buff_entry[2] >= pte->buff_entry[1])
3295  return;
3296  pte->buff_entry[2]++;
3297  count = OpenHistory(pte, pte->buff_entry[0], &f);
3298  if (!count)
3299  return;
3300  offset = ((pte->buff_entry[2] - 1) * TEXT_LENGTH_MAX * 3);
3301  if (fseek(f, offset, SEEK_CUR)) {
3302  display_last_error("Unable to seek history entry.");
3303  fclose(f);
3304  return;
3305  }
3306  show_entry_history(pte, &f);
3307  break;
3308  case KEY_FUNC3:
3309  if (!ReformatNumber(pte->device->lst_cid))
3310  break;
3312  sizeof(pte->device->redial_number));
3313  key_main_page(pte, KEY_FUNC2);
3314  break;
3315  case KEY_FUNC4:
3316  case KEY_HANGUP:
3317  show_main_page(pte);
3318  break;
3319  case KEY_SNDHIST:
3320  if (pte->buff_entry[0] == 'i')
3321  show_history(pte, 'o');
3322  else
3323  show_main_page(pte);
3324  break;
3325  case KEY_RCVHIST:
3326  if (pte->buff_entry[0] == 'i')
3327  show_main_page(pte);
3328  else
3329  show_history(pte, 'i');
3330  break;
3331  }
3332  return;
3333 }
static void show_history(struct unistimsession *pte, char way)
static void key_main_page(struct unistimsession *pte, char keycode)
#define TEXT_LENGTH_MAX
Definition: chan_unistim.c:141
static char OpenHistory(struct unistimsession *pte, char way, FILE **f)
struct unistim_device * device
Definition: chan_unistim.c:496
static int ReformatNumber(char *number)
static void show_main_page(struct unistimsession *pte)
char redial_number[16]
Definition: chan_unistim.c:431
static struct ast_format f[]
Definition: format_g726.c:181
char lst_cid[TEXT_LENGTH_MAX]
Definition: chan_unistim.c:459
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:223
char buff_entry[16]
Definition: chan_unistim.c:492
static void show_entry_history(struct unistimsession *pte, FILE **f)
static void display_last_error(const char *sz_msg)
Definition: chan_unistim.c:725
static void key_main_page ( struct unistimsession pte,
char  keycode 
)
static

Definition at line 3173 of file chan_unistim.c.

References ast_copy_string(), ast_mutex_lock, ast_mutex_unlock, ast_strlen_zero(), unistimsession::buff_entry, unistim_device::call_forward, unistimsession::device, devicelock, unistim_device::extension, EXTENSION_ASK, unistim_device::extension_number, EXTENSION_TN, FAV_ICON_NONE, handle_dial_page(), HandleCallOutgoing(), HandleSelectCodec(), unistim_device::id, KEY_0, KEY_CONF, key_dial_page(), KEY_FAV0, KEY_FAV1, KEY_FAV2, KEY_FAV3, KEY_FAV4, KEY_FAV5, KEY_FUNC1, KEY_FUNC2, KEY_FUNC3, KEY_FUNC4, KEY_HEADPHN, KEY_LOUDSPK, KEY_RCVHIST, KEY_SHARP, KEY_SNDHIST, Keyfavorite(), unistim_device::missed_call, MUTE_OFF, unistim_device::output, OUTPUT_HANDSET, OUTPUT_HEADPHONE, OUTPUT_SPEAKER, unistim_device::phone_number, unistim_device::receiver_state, unistim_device::redial_number, send_select_output(), Sendicon(), unistim_device::session, show_history(), show_main_page(), ShowExtensionPage(), unistimsession::size_buff_entry, STATE_ONHOOK, TEXT_LINE0, UnregisterExtension(), and unistim_device::volume.

Referenced by key_history(), and process_request().

3174 {
3175  if (pte->device->missed_call) {
3177  pte->device->missed_call = 0;
3178  }
3179  if ((keycode >= KEY_0) && (keycode <= KEY_SHARP)) {
3180  handle_dial_page(pte);
3181  key_dial_page(pte, keycode);
3182  return;
3183  }
3184  switch (keycode) {
3185  case KEY_FUNC1:
3186  handle_dial_page(pte);
3187  break;
3188  case KEY_FUNC2:
3190  break;
3191  if ((pte->device->output == OUTPUT_HANDSET) &&
3192  (pte->device->receiver_state == STATE_ONHOOK))
3194  else
3195  send_select_output(pte, pte->device->output, pte->device->volume, MUTE_OFF);
3196 
3198  sizeof(pte->device->phone_number));
3199  HandleCallOutgoing(pte);
3200  break;
3201  case KEY_FUNC3:
3202  if (!ast_strlen_zero(pte->device->call_forward)) {
3203  /* Cancel call forwarding */
3204  memmove(pte->device->call_forward + 1, pte->device->call_forward,
3205  sizeof(pte->device->call_forward) - 1);
3206  pte->device->call_forward[0] = '\0';
3208  pte->device->output = OUTPUT_HANDSET; /* Seems to be reseted somewhere */
3209  show_main_page(pte);
3210  break;
3211  }
3212  pte->device->call_forward[0] = -1;
3213  handle_dial_page(pte);
3214  break;
3215  case KEY_FUNC4:
3216  if (pte->device->extension == EXTENSION_ASK) {
3217  UnregisterExtension(pte);
3218  pte->device->extension_number[0] = '\0';
3219  ShowExtensionPage(pte);
3220  } else if (pte->device->extension == EXTENSION_TN) {
3222  strcpy(pte->device->id, pte->device->extension_number);
3223  pte->buff_entry[0] = '\0';
3224  pte->size_buff_entry = 0;
3225  pte->device->session = NULL;
3226  pte->device = NULL;
3228  ShowExtensionPage(pte);
3229  }
3230  break;
3231  case KEY_FAV0:
3232  handle_dial_page(pte);
3233  break;
3234  case KEY_FAV1:
3235  case KEY_FAV2:
3236  case KEY_FAV3:
3237  case KEY_FAV4:
3238  case KEY_FAV5:
3239  if ((pte->device->output == OUTPUT_HANDSET) &&
3240  (pte->device->receiver_state == STATE_ONHOOK))
3242  else
3243  send_select_output(pte, pte->device->output, pte->device->volume, MUTE_OFF);
3244  Keyfavorite(pte, keycode);
3245  break;
3246  case KEY_CONF:
3247  HandleSelectCodec(pte);
3248  break;
3249  case KEY_LOUDSPK:
3251  handle_dial_page(pte);
3252  break;
3253  case KEY_HEADPHN:
3255  handle_dial_page(pte);
3256  break;
3257  case KEY_SNDHIST:
3258  show_history(pte, 'o');
3259  break;
3260  case KEY_RCVHIST:
3261  show_history(pte, 'i');
3262  break;
3263  }
3264  return;
3265 }
char call_forward[AST_MAX_EXTENSION]
Definition: chan_unistim.c:461
static void show_history(struct unistimsession *pte, char way)
static int UnregisterExtension(const struct unistimsession *pte)
static void Keyfavorite(struct unistimsession *pte, char keycode)
static void send_select_output(struct unistimsession *pte, unsigned char output, unsigned char volume, unsigned char mute)
char phone_number[16]
Definition: chan_unistim.c:430
#define ast_mutex_lock(a)
Definition: lock.h:155
static void HandleSelectCodec(struct unistimsession *pte)
static void HandleCallOutgoing(struct unistimsession *s)
struct unistim_device * device
Definition: chan_unistim.c:496
#define MUTE_OFF
Definition: chan_unistim.c:135
static ast_mutex_t devicelock
Definition: chan_unistim.c:249
#define OUTPUT_HEADPHONE
Definition: chan_unistim.c:127
#define OUTPUT_HANDSET
Definition: chan_unistim.c:126
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition: strings.h:63
struct unistimsession * session
Definition: chan_unistim.c:475
#define FAV_ICON_NONE
Definition: chan_unistim.c:149
static void handle_dial_page(struct unistimsession *pte)
#define TEXT_LINE0
Definition: chan_unistim.c:142
enum autoprov_extn extension
Definition: chan_unistim.c:468
static void ShowExtensionPage(struct unistimsession *pte)
static void show_main_page(struct unistimsession *pte)
char redial_number[16]
Definition: chan_unistim.c:431
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:223
char buff_entry[16]
Definition: chan_unistim.c:492
#define OUTPUT_SPEAKER
Definition: chan_unistim.c:128
static void key_dial_page(struct unistimsession *pte, char keycode)
char extension_number[11]
Definition: chan_unistim.c:469
#define ast_mutex_unlock(a)
Definition: lock.h:156
static void Sendicon(unsigned char pos, unsigned char status, struct unistimsession *pte)
Definition: chan_unistim.c:972
static void key_ringing ( struct unistimsession pte,
char  keycode 
)
static

Definition at line 2647 of file chan_unistim.c.

References unistimsession::device, HandleCallIncoming(), IgnoreCall(), KEY_FAV0, KEY_FUNC1, KEY_FUNC4, KEY_HANGUP, and unistim_device::softkeylinepos.

Referenced by process_request().

2648 {
2649  if (keycode == KEY_FAV0 + pte->device->softkeylinepos) {
2650  HandleCallIncoming(pte);
2651  return;
2652  }
2653  switch (keycode) {
2654  case KEY_HANGUP:
2655  case KEY_FUNC4:
2656  IgnoreCall(pte);
2657  break;
2658  case KEY_FUNC1:
2659  HandleCallIncoming(pte);
2660  break;
2661  }
2662  return;
2663 }
struct unistim_device * device
Definition: chan_unistim.c:496
static void IgnoreCall(struct unistimsession *pte)
static void HandleCallIncoming(struct unistimsession *s)
static void key_select_codec ( struct unistimsession pte,
char  keycode 
)
static

Definition at line 2839 of file chan_unistim.c.

References unistimsession::buff_entry, unistim_device::codec_number, unistimsession::device, KEY_0, KEY_9, KEY_FUNC1, KEY_FUNC2, KEY_FUNC3, KEY_FUNC4, KEY_HANGUP, SELECTCODEC_MAX_LENGTH, SELECTCODEC_MSG, SELECTCODEC_START_ENTRY_POS, send_blink_cursor(), send_cursor_pos(), send_text(), show_main_page(), unistimsession::size_buff_entry, TEXT_INVERSE, and TEXT_LINE2.

Referenced by process_request().

2840 {
2841  if (keycode == KEY_FUNC2) {
2842  if (pte->size_buff_entry <= 1)
2843  keycode = KEY_FUNC3;
2844  else {
2845  pte->size_buff_entry -= 2;
2846  keycode = pte->buff_entry[pte->size_buff_entry] + 0x10;
2847  }
2848  }
2849  if ((keycode >= KEY_0) && (keycode <= KEY_9)) {
2850  char tmpbuf[] = SELECTCODEC_MSG;
2851  int i = 0;
2852 
2854  return;
2855 
2856  while (i < pte->size_buff_entry) {
2857  tmpbuf[i + SELECTCODEC_START_ENTRY_POS] = pte->buff_entry[i];
2858  i++;
2859  }
2860  tmpbuf[i + SELECTCODEC_START_ENTRY_POS] = keycode - 0x10;
2861  pte->buff_entry[i] = keycode - 0x10;
2862  pte->size_buff_entry++;
2863  send_text(TEXT_LINE2, TEXT_INVERSE, pte, tmpbuf);
2864  send_blink_cursor(pte);
2865  send_cursor_pos(pte,
2866  (unsigned char) (TEXT_LINE2 + SELECTCODEC_START_ENTRY_POS + 1 + i));
2867  return;
2868  }
2869 
2870  switch (keycode) {
2871  case KEY_FUNC1:
2872  if (pte->size_buff_entry == 1)
2873  pte->device->codec_number = pte->buff_entry[0] - 48;
2874  else if (pte->size_buff_entry == 2)
2875  pte->device->codec_number =
2876  ((pte->buff_entry[0] - 48) * 10) + (pte->buff_entry[1] - 48);
2877  show_main_page(pte);
2878  break;
2879  case KEY_FUNC3:
2880  pte->size_buff_entry = 0;
2882  send_blink_cursor(pte);
2884  break;
2885  case KEY_HANGUP:
2886  case KEY_FUNC4:
2887  show_main_page(pte);
2888  break;
2889  }
2890  return;
2891 }
#define TEXT_LINE2
Definition: chan_unistim.c:144
static void send_blink_cursor(struct unistimsession *pte)
struct unistim_device * device
Definition: chan_unistim.c:496
static void show_main_page(struct unistimsession *pte)
#define TEXT_INVERSE
Definition: chan_unistim.c:146
static void send_text(unsigned char pos, unsigned char inverse, struct unistimsession *pte, const char *text)
static void send_cursor_pos(struct unistimsession *pte, unsigned char pos)
char buff_entry[16]
Definition: chan_unistim.c:492
#define SELECTCODEC_START_ENTRY_POS
#define SELECTCODEC_MAX_LENGTH
#define SELECTCODEC_MSG
static void key_select_extension ( struct unistimsession pte,
char  keycode 
)
static

Definition at line 2910 of file chan_unistim.c.

References ast_copy_string(), ast_mutex_lock, ast_mutex_unlock, AUTOPROVISIONING_TN, unistimsession::buff_entry, unistim_device::codec_number, DEFAULT_CODEC, unistimsession::device, devicelock, devices, unistim_device::extension, unistim_device::extension_number, EXTENSION_TN, unistim_device::id, KEY_0, KEY_9, KEY_FUNC1, KEY_FUNC2, KEY_FUNC3, unistimsession::macaddr, unistim_device::missed_call, unistim_device::next, unistim_device::pos_fav, unistim_device::receiver_state, refresh_all_favorite(), RegisterExtension(), SELECTEXTENSION_MAX_LENGTH, SELECTEXTENSION_MSG, SELECTEXTENSION_START_ENTRY_POS, send_blink_cursor(), send_cursor_pos(), send_text(), unistim_device::session, show_main_page(), unistimsession::size_buff_entry, STATE_ONHOOK, TEXT_LINE0, TEXT_LINE1, TEXT_LINE2, and TEXT_NORMAL.

Referenced by process_request().

2911 {
2912  if (keycode == KEY_FUNC2) {
2913  if (pte->size_buff_entry <= 1)
2914  keycode = KEY_FUNC3;
2915  else {
2916  pte->size_buff_entry -= 2;
2917  keycode = pte->buff_entry[pte->size_buff_entry] + 0x10;
2918  }
2919  }
2920  if ((keycode >= KEY_0) && (keycode <= KEY_9)) {
2921  char tmpbuf[] = SELECTEXTENSION_MSG;
2922  int i = 0;
2923 
2925  return;
2926 
2927  while (i < pte->size_buff_entry) {
2928  tmpbuf[i + SELECTEXTENSION_START_ENTRY_POS] = pte->buff_entry[i];
2929  i++;
2930  }
2931  tmpbuf[i + SELECTEXTENSION_START_ENTRY_POS] = keycode - 0x10;
2932  pte->buff_entry[i] = keycode - 0x10;
2933  pte->size_buff_entry++;
2934  send_text(TEXT_LINE2, TEXT_NORMAL, pte, tmpbuf);
2935  send_blink_cursor(pte);
2936  send_cursor_pos(pte,
2937  (unsigned char) (TEXT_LINE2 + SELECTEXTENSION_START_ENTRY_POS + 1 +
2938  i));
2939  return;
2940  }
2941 
2942  switch (keycode) {
2943  case KEY_FUNC1:
2944  if (pte->size_buff_entry < 1)
2945  return;
2947  struct unistim_device *d;
2948 
2949  /* First step : looking for this TN in our device list */
2951  d = devices;
2952  pte->buff_entry[pte->size_buff_entry] = '\0';
2953  while (d) {
2954  if (d->id[0] == 'T') { /* It's a TN device ? */
2955  /* It's the TN we're looking for ? */
2956  if (!strcmp((d->id) + 1, pte->buff_entry)) {
2957  pte->device = d;
2958  d->session = pte;
2960  d->pos_fav = 0;
2961  d->missed_call = 0;
2963  strcpy(d->id, pte->macaddr);
2964  pte->device->extension_number[0] = 'T';
2965  pte->device->extension = EXTENSION_TN;
2967  pte->buff_entry, pte->size_buff_entry + 1);
2969  show_main_page(pte);
2970  refresh_all_favorite(pte);
2971  return;
2972  }
2973  }
2974  d = d->next;
2975  }
2977  send_text(TEXT_LINE0, TEXT_NORMAL, pte, "Invalid Terminal Number.");
2978  send_text(TEXT_LINE1, TEXT_NORMAL, pte, "Please try again :");
2979  send_cursor_pos(pte,
2980  (unsigned char) (TEXT_LINE2 + SELECTEXTENSION_START_ENTRY_POS +
2981  pte->size_buff_entry));
2982  send_blink_cursor(pte);
2983  } else {
2985  pte->size_buff_entry + 1);
2986  if (RegisterExtension(pte)) {
2987  send_text(TEXT_LINE0, TEXT_NORMAL, pte, "Invalid extension.");
2988  send_text(TEXT_LINE1, TEXT_NORMAL, pte, "Please try again :");
2989  send_cursor_pos(pte,
2990  (unsigned char) (TEXT_LINE2 +
2992  pte->size_buff_entry));
2993  send_blink_cursor(pte);
2994  } else
2995  show_main_page(pte);
2996  }
2997  break;
2998  case KEY_FUNC3:
2999  pte->size_buff_entry = 0;
3001  send_blink_cursor(pte);
3003  break;
3004  }
3005  return;
3006 }
#define SELECTEXTENSION_START_ENTRY_POS
A device containing one or more lines.
Definition: chan_unistim.c:427
#define TEXT_LINE2
Definition: chan_unistim.c:144
#define TEXT_LINE1
Definition: chan_unistim.c:143
#define ast_mutex_lock(a)
Definition: lock.h:155
#define TEXT_NORMAL
Definition: chan_unistim.c:145
static void send_blink_cursor(struct unistimsession *pte)
struct unistim_device * device
Definition: chan_unistim.c:496
static void refresh_all_favorite(struct unistimsession *pte)
static ast_mutex_t devicelock
Definition: chan_unistim.c:249
char macaddr[18]
Definition: chan_unistim.c:493
#define DEFAULT_CODEC
Definition: chan_unistim.c:99
struct unistim_device * next
Definition: chan_unistim.c:476
struct unistimsession * session
Definition: chan_unistim.c:475
#define TEXT_LINE0
Definition: chan_unistim.c:142
enum autoprov_extn extension
Definition: chan_unistim.c:468
static void show_main_page(struct unistimsession *pte)
#define SELECTEXTENSION_MAX_LENGTH
static struct unistim_device * devices
static void send_text(unsigned char pos, unsigned char inverse, struct unistimsession *pte, const char *text)
static void send_cursor_pos(struct unistimsession *pte, unsigned char pos)
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:223
char buff_entry[16]
Definition: chan_unistim.c:492
static enum autoprovision autoprovisioning
Definition: chan_unistim.c:213
static int RegisterExtension(const struct unistimsession *pte)
#define SELECTEXTENSION_MSG
char extension_number[11]
Definition: chan_unistim.c:469
#define ast_mutex_unlock(a)
Definition: lock.h:156
static void Keyfavorite ( struct unistimsession pte,
char  keycode 
)
static

Definition at line 2665 of file chan_unistim.c.

References ast_copy_string(), ast_log(), unistimsession::device, HandleCallOutgoing(), KEY_FAV0, KEY_FAV1, KEY_FAV5, LOG_WARNING, unistim_device::phone_number, unistim_device::softkeyicon, and unistim_device::softkeynumber.

Referenced by key_dial_page(), and key_main_page().

2666 {
2667  int fav;
2668 
2669  if ((keycode < KEY_FAV1) && (keycode > KEY_FAV5)) {
2670  ast_log(LOG_WARNING, "It's not a favorite key\n");
2671  return;
2672  }
2673  if (keycode == KEY_FAV0)
2674  return;
2675  fav = keycode - KEY_FAV0;
2676  if (pte->device->softkeyicon[fav] == 0)
2677  return;
2679  sizeof(pte->device->phone_number));
2680  HandleCallOutgoing(pte);
2681  return;
2682 }
char softkeynumber[6][16]
Definition: chan_unistim.c:438
#define LOG_WARNING
Definition: logger.h:144
char phone_number[16]
Definition: chan_unistim.c:430
static void HandleCallOutgoing(struct unistimsession *s)
struct unistim_device * device
Definition: chan_unistim.c:496
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:223
char softkeyicon[6]
Definition: chan_unistim.c:439
int load_module ( void  )
static

XXX

Todo:
Leaking anything allocated by reload_config() ...

Definition at line 5666 of file chan_unistim.c.

References ARRAY_LEN, ast_channel_register(), ast_cli_register_multiple(), ast_free, ast_log(), ast_malloc, AST_MODULE_LOAD_DECLINE, AST_MODULE_LOAD_FAILURE, AST_MODULE_LOAD_SUCCESS, ast_rtp_glue_register, io_context_create(), io_context_destroy(), LOG_ERROR, reload_config(), restart_monitor(), sched_context_create(), sched_context_destroy(), and SIZE_PAGE.

5667 {
5668  int res;
5669 
5670  if (!(buff = ast_malloc(SIZE_PAGE)))
5671  goto buff_failed;
5672 
5673  io = io_context_create();
5674  if (!io) {
5675  ast_log(LOG_ERROR, "Failed to allocate IO context\n");
5676  goto io_failed;
5677  }
5678 
5680  if (!sched) {
5681  ast_log(LOG_ERROR, "Failed to allocate scheduler context\n");
5682  goto sched_failed;
5683  }
5684 
5685  res = reload_config();
5686  if (res)
5687  return AST_MODULE_LOAD_DECLINE;
5688 
5689  /* Make sure we can register our unistim channel type */
5691  ast_log(LOG_ERROR, "Unable to register channel type '%s'\n", channel_type);
5692  goto chanreg_failed;
5693  }
5694 
5696 
5698 
5699  restart_monitor();
5700 
5701  return AST_MODULE_LOAD_SUCCESS;
5702 
5703 chanreg_failed:
5704  /*! XXX \todo Leaking anything allocated by reload_config() ... */
5706  sched = NULL;
5707 sched_failed:
5709  io = NULL;
5710 io_failed:
5711  ast_free(buff);
5712  buff = NULL;
5713 buff_failed:
5714  return AST_MODULE_LOAD_FAILURE;
5715 }
static const char channel_type[]
Definition: chan_unistim.c:678
#define ARRAY_LEN(a)
Definition: isdn_lib.c:42
static struct ast_cli_entry unistim_cli[]
static struct io_context * io
Definition: chan_unistim.c:224
#define ast_rtp_glue_register(glue)
Definition: rtp_engine.h:476
Definition: sched.c:57
int ast_channel_register(const struct ast_channel_tech *tech)
Register a channel technology (a new channel driver) Called by a channel module to register the kind ...
Definition: channel.c:907
void io_context_destroy(struct io_context *ioc)
Destroys a context.
Definition: io.c:102
static int reload_config(void)
#define LOG_ERROR
Definition: logger.h:155
void sched_context_destroy(struct sched_context *c)
destroys a schedule context Destroys (free&#39;s) the given sched_context structure
Definition: sched.c:267
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
#define ast_free(a)
Definition: astmm.h:97
struct sched_context * sched_context_create(void)
New schedule context.
Definition: sched.c:246
static unsigned char * buff
Definition: chan_unistim.c:232
int ast_cli_register_multiple(struct ast_cli_entry *e, int len)
Register multiple commands.
Definition: cli.c:2167
static int restart_monitor(void)
#define ast_malloc(a)
Definition: astmm.h:91
#define SIZE_PAGE
Definition: chan_unistim.c:100
static struct ast_channel_tech unistim_tech
Definition: chan_unistim.c:706
static struct ast_rtp_glue unistim_rtp_glue
struct io_context * io_context_create(void)
Creates a context Create a context for I/O operations Basically mallocs an IO structure and sets up s...
Definition: io.c:76
static char OpenHistory ( struct unistimsession pte,
char  way,
FILE **  f 
)
static

Definition at line 3075 of file chan_unistim.c.

References ast_config_AST_LOG_DIR, AST_CONFIG_MAX_PATH, ast_log(), unistimsession::device, display_last_error(), LOG_WARNING, MAX_ENTRY_LOG, unistim_device::name, and USTM_LOG_DIR.

Referenced by key_history(), and show_history().

3076 {
3077  char tmp[AST_CONFIG_MAX_PATH];
3078  char count;
3079 
3080  snprintf(tmp, sizeof(tmp), "%s/%s/%s-%c.csv", ast_config_AST_LOG_DIR,
3081  USTM_LOG_DIR, pte->device->name, way);
3082  *f = fopen(tmp, "r");
3083  if (!*f) {
3084  display_last_error("Unable to open history file");
3085  return 0;
3086  }
3087  if (fread(&count, 1, 1, *f) != 1) {
3088  display_last_error("Unable to read history header - display.");
3089  fclose(*f);
3090  return 0;
3091  }
3092  if (count > MAX_ENTRY_LOG) {
3093  ast_log(LOG_WARNING, "Invalid count in history header of %s (%d max %d)\n", tmp,
3094  count, MAX_ENTRY_LOG);
3095  fclose(*f);
3096  return 0;
3097  }
3098  return count;
3099 }
char name[DEVICE_NAME_LEN]
Definition: chan_unistim.c:435
#define LOG_WARNING
Definition: logger.h:144
#define AST_CONFIG_MAX_PATH
Definition: chan_unistim.c:102
#define USTM_LOG_DIR
Definition: chan_unistim.c:84
struct unistim_device * device
Definition: chan_unistim.c:496
#define MAX_ENTRY_LOG
Definition: chan_unistim.c:103
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
const char * ast_config_AST_LOG_DIR
Definition: asterisk.c:263
static struct ast_format f[]
Definition: format_g726.c:181
static void display_last_error(const char *sz_msg)
Definition: chan_unistim.c:725
static int ParseBookmark ( const char *  text,
struct unistim_device d 
)
static

Definition at line 4972 of file chan_unistim.c.

References ast_copy_string(), ast_log(), ast_strlen_zero(), ast_verb, FAV_ICON_SHARP, len(), LOG_NOTICE, LOG_WARNING, unistim_device::softkeydevice, unistim_device::softkeyicon, unistim_device::softkeylabel, and unistim_device::softkeynumber.

Referenced by build_device().

4973 {
4974  char line[256];
4975  char *at;
4976  char *number;
4977  char *icon;
4978  int p;
4979  int len = strlen(text);
4980 
4981  ast_copy_string(line, text, sizeof(line));
4982  /* Position specified ? */
4983  if ((len > 2) && (line[1] == '@')) {
4984  p = line[0];
4985  if ((p >= '0') && (p <= '5'))
4986  p -= '0';
4987  else {
4989  "Invalid position for bookmark : must be between 0 and 5\n");
4990  return 0;
4991  }
4992  if (d->softkeyicon[p] != 0) {
4993  ast_log(LOG_WARNING, "Invalid position %d for bookmark : already used\n:", p);
4994  return 0;
4995  }
4996  memmove(line, line + 2, sizeof(line) - 2);
4997  } else {
4998  /* No position specified, looking for a free slot */
4999  for (p = 0; p <= 5; p++) {
5000  if (!d->softkeyicon[p])
5001  break;
5002  }
5003  if (p > 5) {
5004  ast_log(LOG_WARNING, "No more free bookmark position\n");
5005  return 0;
5006  }
5007  }
5008  at = strchr(line, '@');
5009  if (!at) {
5010  ast_log(LOG_NOTICE, "Bookmark entry '%s' has no @ (at) sign!\n", text);
5011  return 0;
5012  }
5013  *at = '\0';
5014  at++;
5015  number = at;
5016  at = strchr(at, '@');
5017  if (ast_strlen_zero(number)) {
5018  ast_log(LOG_NOTICE, "Bookmark entry '%s' has no number\n", text);
5019  return 0;
5020  }
5021  if (ast_strlen_zero(line)) {
5022  ast_log(LOG_NOTICE, "Bookmark entry '%s' has no description\n", text);
5023  return 0;
5024  }
5025 
5026  at = strchr(number, '@');
5027  if (!at)
5028  d->softkeyicon[p] = FAV_ICON_SHARP; /* default icon */
5029  else {
5030  *at = '\0';
5031  at++;
5032  icon = at;
5033  if (ast_strlen_zero(icon)) {
5034  ast_log(LOG_NOTICE, "Bookmark entry '%s' has no icon value\n", text);
5035  return 0;
5036  }
5037  if (strncmp(icon, "USTM/", 5))
5038  d->softkeyicon[p] = atoi(icon);
5039  else {
5040  d->softkeyicon[p] = 1;
5041  ast_copy_string(d->softkeydevice[p], icon + 5, sizeof(d->softkeydevice[p]));
5042  }
5043  }
5044  ast_copy_string(d->softkeylabel[p], line, sizeof(d->softkeylabel[p]));
5045  ast_copy_string(d->softkeynumber[p], number, sizeof(d->softkeynumber[p]));
5046  if (unistimdebug)
5047  ast_verb(0, "New bookmark at pos %d label='%s' number='%s' icon=%x\n",
5048  p, d->softkeylabel[p], d->softkeynumber[p], (unsigned)d->softkeyicon[p]);
5049  return 1;
5050 }
char softkeynumber[6][16]
Definition: chan_unistim.c:438
#define LOG_WARNING
Definition: logger.h:144
#define FAV_ICON_SHARP
Definition: chan_unistim.c:168
char * text
Definition: app_queue.c:1091
#define ast_verb(level,...)
Definition: logger.h:243
static int unistimdebug
Definition: chan_unistim.c:211
Number structure.
Definition: app_followme.c:109
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition: strings.h:63
char softkeydevice[6][16]
Definition: chan_unistim.c:440
char softkeylabel[6][11]
Definition: chan_unistim.c:437
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
#define LOG_NOTICE
Definition: logger.h:133
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:223
char softkeyicon[6]
Definition: chan_unistim.c:439
static void parsing ( int  size,
unsigned char *  buf,
struct unistimsession pte,
struct sockaddr_in *  addr_from 
)
static

Definition at line 3515 of file chan_unistim.c.

References ast_inet_ntoa(), ast_log(), ast_mutex_lock, ast_mutex_unlock, ast_verb, check_send_queue(), close_client(), create_client(), unistimsession::last_seq_ack, unistimsession::lock, LOG_NOTICE, LOG_WARNING, unistimsession::nb_retransmit, process_request(), send_raw_client(), send_retransmit(), seq, unistimsession::seq_phone, unistimsession::seq_server, SIZE_HEADER, unistimsession::sout, unistimsession::state, and STATE_INIT.

Referenced by unistimsock_read().

3517 {
3518  unsigned short *sbuf = (unsigned short *) buf;
3519  unsigned short seq;
3520  char tmpbuf[255];
3521 
3522  strcpy(tmpbuf, ast_inet_ntoa(addr_from->sin_addr));
3523 
3524  if (size < 10) {
3525  if (size == 0) {
3526  ast_log(LOG_WARNING, "%s Read error\n", tmpbuf);
3527  } else {
3528  ast_log(LOG_NOTICE, "%s Packet too short - ignoring\n", tmpbuf);
3529  }
3530  return;
3531  }
3532  if (sbuf[0] == 0xffff) { /* Starting with 0xffff ? *//* Yes, discovery packet ? */
3533  if (size != sizeof(packet_rcv_discovery)) {
3534  ast_log(LOG_NOTICE, "%s Invalid size of a discovery packet\n", tmpbuf);
3535  } else {
3536  if (memcmp(buf, packet_rcv_discovery, sizeof(packet_rcv_discovery)) == 0) {
3537  if (unistimdebug)
3538  ast_verb(0, "Discovery packet received - Sending Discovery ACK\n");
3539  if (pte) { /* A session was already active for this IP ? */
3540  if (pte->state == STATE_INIT) { /* Yes, but it's a dupe */
3541  if (unistimdebug)
3542  ast_verb(1, "Duplicated Discovery packet\n");
3544  packet_send_discovery_ack, addr_from, &pte->sout);
3545  pte->seq_phone = (short) 0x0000; /* reset sequence number */
3546  } else { /* No, probably a reboot, phone side */
3547  close_client(pte); /* Cleanup the previous session */
3548  if (create_client(addr_from))
3550  packet_send_discovery_ack, addr_from, &pte->sout);
3551  }
3552  } else {
3553  /* Creating new entry in our phone list */
3554  if ((pte = create_client(addr_from)))
3556  packet_send_discovery_ack, addr_from, &pte->sout);
3557  }
3558  return;
3559  }
3560  ast_log(LOG_NOTICE, "%s Invalid discovery packet\n", tmpbuf);
3561  }
3562  return;
3563  }
3564  if (!pte) {
3565  if (unistimdebug)
3566  ast_verb(0, "%s Not a discovery packet from an unknown source : ignoring\n",
3567  tmpbuf);
3568  return;
3569  }
3570 
3571  if (sbuf[0] != 0) { /* Starting with something else than 0x0000 ? */
3572  ast_log(LOG_NOTICE, "Unknown packet received - ignoring\n");
3573  return;
3574  }
3575  if (buf[5] != 2) {
3576  ast_log(LOG_NOTICE, "%s Wrong direction : got 0x%.2x expected 0x02\n", tmpbuf,
3577  (unsigned)buf[5]);
3578  return;
3579  }
3580  seq = ntohs(sbuf[1]);
3581  if (buf[4] == 1) {
3582  ast_mutex_lock(&pte->lock);
3583  if (unistimdebug)
3584  ast_verb(6, "ACK received for packet #0x%.4x\n", (unsigned)seq);
3585  pte->nb_retransmit = 0;
3586 
3587  if ((pte->last_seq_ack) + 1 == seq) {
3588  pte->last_seq_ack++;
3589  check_send_queue(pte);
3590  ast_mutex_unlock(&pte->lock);
3591  return;
3592  }
3593  if (pte->last_seq_ack > seq) {
3594  if (pte->last_seq_ack == 0xffff) {
3595  ast_verb(0, "ACK at 0xffff, restarting counter.\n");
3596  pte->last_seq_ack = 0;
3597  } else
3599  "%s Warning : ACK received for an already ACKed packet : #0x%.4x we are at #0x%.4x\n",
3600  tmpbuf, (unsigned)seq, (unsigned)pte->last_seq_ack);
3601  ast_mutex_unlock(&pte->lock);
3602  return;
3603  }
3604  if (pte->seq_server < seq) {
3606  "%s Error : ACK received for a non-existent packet : #0x%.4x\n",
3607  tmpbuf, (unsigned)pte->seq_server);
3608  ast_mutex_unlock(&pte->lock);
3609  return;
3610  }
3611  if (unistimdebug)
3612  ast_verb(0, "%s ACK gap : Received ACK #0x%.4x, previous was #0x%.4x\n",
3613  tmpbuf, (unsigned)seq, (unsigned)pte->last_seq_ack);
3614  pte->last_seq_ack = seq;
3615  check_send_queue(pte);
3616  ast_mutex_unlock(&pte->lock);
3617  return;
3618  }
3619  if (buf[4] == 2) {
3620  if (unistimdebug)
3621  ast_verb(0, "Request received\n");
3622  if (pte->seq_phone == seq) {
3623  /* Send ACK */
3624  buf[4] = 1;
3625  buf[5] = 1;
3626  send_raw_client(SIZE_HEADER, buf, addr_from, &pte->sout);
3627  pte->seq_phone++;
3628 
3629  process_request(size, buf, pte);
3630  return;
3631  }
3632  if (pte->seq_phone > seq) {
3634  "%s Warning : received a retransmitted packet : #0x%.4x (we are at #0x%.4x)\n",
3635  tmpbuf, (unsigned)seq, (unsigned)pte->seq_phone);
3636  /* BUG ? pte->device->seq_phone = seq; */
3637  /* Send ACK */
3638  buf[4] = 1;
3639  buf[5] = 1;
3640  send_raw_client(SIZE_HEADER, buf, addr_from, &pte->sout);
3641  return;
3642  }
3644  "%s Warning : we lost a packet : received #0x%.4x (we are at #0x%.4x)\n",
3645  tmpbuf, (unsigned)seq, (unsigned)pte->seq_phone);
3646  return;
3647  }
3648  if (buf[4] == 0) {
3649  ast_log(LOG_NOTICE, "%s Retransmit request for packet #0x%.4x\n", tmpbuf, (unsigned)seq);
3650  if (pte->last_seq_ack > seq) {
3652  "%s Error : received a request for an already ACKed packet : #0x%.4x\n",
3653  tmpbuf, (unsigned)pte->last_seq_ack);
3654  return;
3655  }
3656  if (pte->seq_server < seq) {
3658  "%s Error : received a request for a non-existent packet : #0x%.4x\n",
3659  tmpbuf, (unsigned)pte->seq_server);
3660  return;
3661  }
3662  send_retransmit(pte);
3663  return;
3664  }
3665  ast_log(LOG_NOTICE, "%s Unknown request : got 0x%.2x expected 0x00,0x01 or 0x02\n",
3666  tmpbuf, (unsigned)buf[4]);
3667  return;
3668 }
struct sockaddr_in sout
Definition: chan_unistim.c:482
static void check_send_queue(struct unistimsession *pte)
Definition: chan_unistim.c:931
#define LOG_WARNING
Definition: logger.h:144
static int send_retransmit(struct unistimsession *pte)
unsigned short seq_server
Definition: chan_unistim.c:485
#define ast_mutex_lock(a)
Definition: lock.h:155
static void close_client(struct unistimsession *s)
#define ast_verb(level,...)
Definition: logger.h:243
ast_mutex_t lock
Definition: chan_unistim.c:480
unsigned short last_seq_ack
Definition: chan_unistim.c:486
static int unistimdebug
Definition: chan_unistim.c:211
#define SIZE_HEADER
Definition: chan_unistim.c:139
static struct unistimsession * create_client(const struct sockaddr_in *addr_from)
Definition: chan_unistim.c:875
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
#define LOG_NOTICE
Definition: logger.h:133
const char * ast_inet_ntoa(struct in_addr ia)
thread-safe replacement for inet_ntoa().
Definition: utils.c:564
unsigned short seq_phone
Definition: chan_unistim.c:484
static volatile unsigned int seq
Definition: app_sms.c:118
static void process_request(int size, unsigned char *buf, struct unistimsession *pte)
static const unsigned char packet_rcv_discovery[]
Definition: chan_unistim.c:511
static const unsigned char packet_send_discovery_ack[]
Definition: chan_unistim.c:513
#define ast_mutex_unlock(a)
Definition: lock.h:156
static void send_raw_client(int size, const unsigned char *data, struct sockaddr_in *addr_to, const struct sockaddr_in *addr_ourip)
Definition: chan_unistim.c:744
static void process_request ( int  size,
unsigned char *  buf,
struct unistimsession pte 
)
static

Definition at line 3396 of file chan_unistim.c.

References ast_debug, ast_inet_ntoa(), ast_log(), ast_verb, close_call(), unistimsession::device, handle_dial_page(), HandleCallIncoming(), init_phone_step2(), key_call(), key_dial_page(), key_history(), key_main_page(), key_ringing(), key_select_codec(), key_select_extension(), unistim_device::lines, LOG_WARNING, MUTE_OFF, unistim_device::output, OUTPUT_HANDSET, OUTPUT_HEADPHONE, unistim_subchannel::owner, rcv_mac_addr(), rcv_resume_connection_with_server(), unistim_device::receiver_state, send_select_output(), show_main_page(), unistimsession::sin, SIZE_HEADER, unistimsession::state, STATE_AUTHDENY, STATE_CALL, STATE_DIALPAGE, STATE_EXTENSION, STATE_HISTORY, STATE_INIT, STATE_MAINPAGE, STATE_OFFHOOK, STATE_ONHOOK, STATE_RINGING, STATE_SELECTCODEC, SUB_REAL, unistim_line::subs, and unistim_device::volume.

Referenced by parsing().

3397 {
3398  char tmpbuf[255];
3399  if (memcmp
3403  return;
3404  }
3405  if (memcmp(buf + SIZE_HEADER, packet_recv_firm_version, sizeof(packet_recv_firm_version)) ==
3406  0) {
3407  buf[size] = 0;
3408  if (unistimdebug)
3409  ast_verb(0, "Got the firmware version : '%s'\n", buf + 13);
3410  init_phone_step2(pte);
3411  return;
3412  }
3413  if (memcmp(buf + SIZE_HEADER, packet_recv_mac_addr, sizeof(packet_recv_mac_addr)) == 0) {
3414  rcv_mac_addr(pte, buf);
3415  return;
3416  }
3417  if (memcmp(buf + SIZE_HEADER, packet_recv_r2, sizeof(packet_recv_r2)) == 0) {
3418  if (unistimdebug)
3419  ast_verb(0, "R2 received\n");
3420  return;
3421  }
3422 
3423  if (pte->state < STATE_MAINPAGE) {
3424  if (unistimdebug)
3425  ast_verb(0, "Request not authorized in this state\n");
3426  return;
3427  }
3428  if (!memcmp(buf + SIZE_HEADER, packet_recv_pressed_key, sizeof(packet_recv_pressed_key))) {
3429  char keycode = buf[13];
3430 
3431  if (unistimdebug)
3432  ast_verb(0, "Key pressed : keycode = 0x%.2x - current state : %d\n", (unsigned)keycode,
3433  pte->state);
3434 
3435  switch (pte->state) {
3436  case STATE_INIT:
3437  if (unistimdebug)
3438  ast_verb(0, "No keys allowed in the init state\n");
3439  break;
3440  case STATE_AUTHDENY:
3441  if (unistimdebug)
3442  ast_verb(0, "No keys allowed in authdeny state\n");
3443  break;
3444  case STATE_MAINPAGE:
3445  key_main_page(pte, keycode);
3446  break;
3447  case STATE_DIALPAGE:
3448  key_dial_page(pte, keycode);
3449  break;
3450  case STATE_RINGING:
3451  key_ringing(pte, keycode);
3452  break;
3453  case STATE_CALL:
3454  key_call(pte, keycode);
3455  break;
3456  case STATE_EXTENSION:
3457  key_select_extension(pte, keycode);
3458  break;
3459  case STATE_SELECTCODEC:
3460  key_select_codec(pte, keycode);
3461  break;
3462  case STATE_HISTORY:
3463  key_history(pte, keycode);
3464  break;
3465  default:
3466  ast_log(LOG_WARNING, "Key : Unknown state\n");
3467  }
3468  return;
3469  }
3470  if (memcmp(buf + SIZE_HEADER, packet_recv_pick_up, sizeof(packet_recv_pick_up)) == 0) {
3471  if (unistimdebug)
3472  ast_verb(0, "Handset off hook\n");
3473  if (!pte->device) /* We are not yet registered (asking for a TN in AUTOPROVISIONING_TN) */
3474  return;
3476  if (pte->device->output == OUTPUT_HEADPHONE)
3478  else
3480  if (pte->state == STATE_RINGING)
3481  HandleCallIncoming(pte);
3482  else if ((pte->state == STATE_DIALPAGE) || (pte->state == STATE_CALL))
3484  else if (pte->state == STATE_EXTENSION) /* We must have a TN before calling */
3485  return;
3486  else {
3488  handle_dial_page(pte);
3489  }
3490  return;
3491  }
3492  if (memcmp(buf + SIZE_HEADER, packet_recv_hangup, sizeof(packet_recv_hangup)) == 0) {
3493  if (unistimdebug)
3494  ast_verb(0, "Handset on hook\n");
3495  if (!pte->device)
3496  return;
3498  if (pte->state == STATE_CALL)
3499  close_call(pte);
3500  else if (pte->device->lines->subs[SUB_REAL]->owner)
3501  close_call(pte);
3502  else if (pte->state == STATE_EXTENSION)
3503  return;
3504  else
3505  show_main_page(pte);
3506  return;
3507  }
3508  strcpy(tmpbuf, ast_inet_ntoa(pte->sin.sin_addr));
3509  strcat(tmpbuf, " Unknown request packet\n");
3510  if (unistimdebug)
3511  ast_debug(1, "%s", tmpbuf);
3512  return;
3513 }
static void rcv_mac_addr(struct unistimsession *pte, const unsigned char *buf)
struct ast_channel * owner
Definition: chan_unistim.c:371
static void rcv_resume_connection_with_server(struct unistimsession *pte)
#define LOG_WARNING
Definition: logger.h:144
static const unsigned char packet_recv_pick_up[]
Definition: chan_unistim.c:520
static void send_select_output(struct unistimsession *pte, unsigned char output, unsigned char volume, unsigned char mute)
static void key_main_page(struct unistimsession *pte, char keycode)
static void close_call(struct unistimsession *pte)
#define ast_verb(level,...)
Definition: logger.h:243
struct unistim_subchannel * subs[MAX_SUBS]
Definition: chan_unistim.c:391
static int unistimdebug
Definition: chan_unistim.c:211
struct unistim_device * device
Definition: chan_unistim.c:496
#define MUTE_OFF
Definition: chan_unistim.c:135
static const unsigned char packet_recv_firm_version[]
Definition: chan_unistim.c:516
#define ast_debug(level,...)
Log a DEBUG message.
Definition: logger.h:236
#define OUTPUT_HEADPHONE
Definition: chan_unistim.c:127
#define OUTPUT_HANDSET
Definition: chan_unistim.c:126
#define SIZE_HEADER
Definition: chan_unistim.c:139
static void key_select_extension(struct unistimsession *pte, char keycode)
static void handle_dial_page(struct unistimsession *pte)
static const unsigned char packet_recv_resume_connection_with_server[]
Definition: chan_unistim.c:527
static const unsigned char packet_recv_hangup[]
Definition: chan_unistim.c:522
static void show_main_page(struct unistimsession *pte)
static const unsigned char packet_recv_pressed_key[]
Definition: chan_unistim.c:518
static void key_history(struct unistimsession *pte, char keycode)
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
struct unistim_line * lines
Definition: chan_unistim.c:473
const char * ast_inet_ntoa(struct in_addr ia)
thread-safe replacement for inet_ntoa().
Definition: utils.c:564
struct sockaddr_in sin
Definition: chan_unistim.c:481
#define SUB_REAL
Definition: chan_unistim.c:105
static void HandleCallIncoming(struct unistimsession *s)
static void key_select_codec(struct unistimsession *pte, char keycode)
static void key_call(struct unistimsession *pte, char keycode)
static const unsigned char packet_recv_mac_addr[]
Definition: chan_unistim.c:529
static void key_ringing(struct unistimsession *pte, char keycode)
static void key_dial_page(struct unistimsession *pte, char keycode)
static void init_phone_step2(struct unistimsession *pte)
static const unsigned char packet_recv_r2[]
Definition: chan_unistim.c:524
static void rcv_mac_addr ( struct unistimsession pte,
const unsigned char *  buf 
)
static

Definition at line 1523 of file chan_unistim.c.

References alloc_sub(), ast_copy_string(), ast_free, ast_log(), ast_malloc, ast_mutex_lock, ast_mutex_unlock, ast_strlen_zero(), ast_verb, AUTOPROVISIONING_DB, AUTOPROVISIONING_NO, AUTOPROVISIONING_TN, AUTOPROVISIONING_YES, BUFFSEND, unistimsession::device, devicelock, devices, unistim_device::extension, EXTENSION_ASK, EXTENSION_LINE, EXTENSION_NONE, unistim_device::extension_number, EXTENSION_TN, unistim_line::fullname, unistim_device::id, unistim_device::lines, LOG_WARNING, unistimsession::macaddr, unistim_line::name, unistim_device::name, unistim_device::next, unistim_line::parent, unistim_device::receiver_state, RegisterExtension(), send_client(), send_date_time(), unistim_device::session, SIZE_HEADER, unistimsession::state, STATE_AUTHDENY, STATE_EXTENSION, STATE_MAINPAGE, STATE_ONHOOK, SUB_REAL, unistim_device::to_delete, and unistim_register().

Referenced by process_request().

1524 {
1525  BUFFSEND;
1526  int tmp, i = 0;
1527  char addrmac[19];
1528  int res = 0;
1529  for (tmp = 15; tmp < 15 + SIZE_HEADER; tmp++) {
1530  sprintf(&addrmac[i], "%.2x", (unsigned) buf[tmp]);
1531  i += 2;
1532  }
1533  if (unistimdebug) {
1534  ast_verb(0, "Mac Address received : %s\n", addrmac);
1535  }
1536  strcpy(pte->macaddr, addrmac);
1537  res = unistim_register(pte);
1538  if (!res) {
1539  switch (autoprovisioning) {
1540  case AUTOPROVISIONING_NO:
1541  ast_log(LOG_WARNING, "No entry found for this phone : %s\n", addrmac);
1542  pte->state = STATE_AUTHDENY;
1543  break;
1544  case AUTOPROVISIONING_YES:
1545  {
1546  struct unistim_device *d, *newd;
1547  struct unistim_line *newl;
1548  if (unistimdebug)
1549  ast_verb(0, "New phone, autoprovisioning on\n");
1550  /* First : locate the [template] section */
1552  d = devices;
1553  while (d) {
1554  if (!strcasecmp(d->name, "template")) {
1555  /* Found, cloning this entry */
1556  if (!(newd = ast_malloc(sizeof(*newd)))) {
1558  return;
1559  }
1560 
1561  memcpy(newd, d, sizeof(*newd));
1562  if (!(newl = ast_malloc(sizeof(*newl)))) {
1563  ast_free(newd);
1565  return;
1566  }
1567 
1568  memcpy(newl, d->lines, sizeof(*newl));
1569  if (!alloc_sub(newl, SUB_REAL)) {
1570  ast_free(newd);
1571  ast_free(newl);
1573  return;
1574  }
1575  /* Ok, now updating some fields */
1576  ast_copy_string(newd->id, addrmac, sizeof(newd->id));
1577  ast_copy_string(newd->name, addrmac, sizeof(newd->name));
1578  if (newd->extension == EXTENSION_NONE)
1579  newd->extension = EXTENSION_ASK;
1580  newd->lines = newl;
1581  newd->receiver_state = STATE_ONHOOK;
1582  newd->session = pte;
1583  newd->to_delete = -1;
1584  pte->device = newd;
1585  newd->next = NULL;
1586  newl->parent = newd;
1587  strcpy(newl->name, d->lines->name);
1588  snprintf(d->lines->name, sizeof(d->lines->name), "%d",
1589  atoi(d->lines->name) + 1);
1590  snprintf(newl->fullname, sizeof(newl->fullname), "USTM/%s@%s",
1591  newl->name, newd->name);
1592  /* Go to the end of the linked chain */
1593  while (d->next) {
1594  d = d->next;
1595  }
1596  d->next = newd;
1597  d = newd;
1598  break;
1599  }
1600  d = d->next;
1601  }
1603  if (!d) {
1604  ast_log(LOG_WARNING, "No entry [template] found in unistim.conf\n");
1605  pte->state = STATE_AUTHDENY;
1606  }
1607  }
1608  break;
1609  case AUTOPROVISIONING_TN:
1610  pte->state = STATE_AUTHDENY;
1611  break;
1612  case AUTOPROVISIONING_DB:
1614  "Autoprovisioning with database is not yet functional\n");
1615  break;
1616  default:
1617  ast_log(LOG_WARNING, "Internal error : unknown autoprovisioning value = %u\n",
1619  }
1620  }
1621  if (pte->state != STATE_AUTHDENY) {
1622  ast_verb(3, "Device '%s' successfuly registered\n", pte->device->name);
1623  switch (pte->device->extension) {
1624  case EXTENSION_NONE:
1625  pte->state = STATE_MAINPAGE;
1626  break;
1627  case EXTENSION_ASK:
1628  /* Checking if we already have an extension number */
1630  pte->state = STATE_EXTENSION;
1631  else {
1632  /* Yes, because of a phone reboot. We don't ask again for the TN */
1633  if (RegisterExtension(pte))
1634  pte->state = STATE_EXTENSION;
1635  else
1636  pte->state = STATE_MAINPAGE;
1637  }
1638  break;
1639  case EXTENSION_LINE:
1641  sizeof(pte->device->extension_number));
1642  if (RegisterExtension(pte))
1643  pte->state = STATE_EXTENSION;
1644  else
1645  pte->state = STATE_MAINPAGE;
1646  break;
1647  case EXTENSION_TN:
1648  /* If we are here, it's because of a phone reboot */
1649  pte->state = STATE_MAINPAGE;
1650  break;
1651  default:
1652  ast_log(LOG_WARNING, "Internal error, extension value unknown : %u\n",
1653  pte->device->extension);
1654  pte->state = STATE_AUTHDENY;
1655  break;
1656  }
1657  }
1658  if (pte->state == STATE_EXTENSION) {
1659  if (pte->device->extension != EXTENSION_TN)
1660  pte->device->extension = EXTENSION_ASK;
1661  pte->device->extension_number[0] = '\0';
1662  }
1663  if (unistimdebug)
1664  ast_verb(0, "\nSending S1\n");
1665  memcpy(buffsend + SIZE_HEADER, packet_send_S1, sizeof(packet_send_S1));
1666  send_client(SIZE_HEADER + sizeof(packet_send_S1), buffsend, pte);
1667 
1668  if (unistimdebug)
1669  ast_verb(0, "Sending query_basic_manager_04\n");
1670  memcpy(buffsend + SIZE_HEADER, packet_send_query_basic_manager_04,
1672  send_client(SIZE_HEADER + sizeof(packet_send_query_basic_manager_04), buffsend, pte);
1673 
1674  if (unistimdebug)
1675  ast_verb(0, "Sending query_basic_manager_10\n");
1676  memcpy(buffsend + SIZE_HEADER, packet_send_query_basic_manager_10,
1678  send_client(SIZE_HEADER + sizeof(packet_send_query_basic_manager_10), buffsend, pte);
1679 
1680  send_date_time(pte);
1681  return;
1682 }
static const unsigned char packet_send_query_basic_manager_10[]
Definition: chan_unistim.c:669
static int alloc_sub(struct unistim_line *l, int x)
static const unsigned char packet_send_S1[]
Definition: chan_unistim.c:670
static void send_client(int size, const unsigned char *data, struct unistimsession *pte)
Definition: chan_unistim.c:801
A device containing one or more lines.
Definition: chan_unistim.c:427
char name[DEVICE_NAME_LEN]
Definition: chan_unistim.c:435
#define LOG_WARNING
Definition: logger.h:144
#define BUFFSEND
Definition: chan_unistim.c:675
#define ast_mutex_lock(a)
Definition: lock.h:155
#define ast_verb(level,...)
Definition: logger.h:243
static int unistim_register(struct unistimsession *s)
static int unistimdebug
Definition: chan_unistim.c:211
struct unistim_device * device
Definition: chan_unistim.c:496
char name[80]
Definition: chan_unistim.c:387
static ast_mutex_t devicelock
Definition: chan_unistim.c:249
char macaddr[18]
Definition: chan_unistim.c:493
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition: strings.h:63
struct unistim_device * next
Definition: chan_unistim.c:476
#define SIZE_HEADER
Definition: chan_unistim.c:139
struct unistimsession * session
Definition: chan_unistim.c:475
static const unsigned char packet_send_query_basic_manager_04[]
Definition: chan_unistim.c:667
enum autoprov_extn extension
Definition: chan_unistim.c:468
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
struct unistim_line * lines
Definition: chan_unistim.c:473
#define ast_free(a)
Definition: astmm.h:97
static struct unistim_device * devices
char fullname[80]
Definition: chan_unistim.c:389
#define SUB_REAL
Definition: chan_unistim.c:105
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:223
static enum autoprovision autoprovisioning
Definition: chan_unistim.c:213
static void send_date_time(struct unistimsession *pte)
struct unistim_device * parent
Definition: chan_unistim.c:421
static int RegisterExtension(const struct unistimsession *pte)
#define ast_malloc(a)
Definition: astmm.h:91
char extension_number[11]
Definition: chan_unistim.c:469
#define ast_mutex_unlock(a)
Definition: lock.h:156
static void rcv_resume_connection_with_server ( struct unistimsession pte)
static

Definition at line 1452 of file chan_unistim.c.

References ast_verb, BUFFSEND, send_client(), and SIZE_HEADER.

Referenced by process_request().

1453 {
1454  BUFFSEND;
1455  if (unistimdebug) {
1456  ast_verb(0, "ResumeConnectionWithServer received\n");
1457  ast_verb(0, "Sending packet_send_query_mac_address\n");
1458  }
1459  memcpy(buffsend + SIZE_HEADER, packet_send_query_mac_address,
1461  send_client(SIZE_HEADER + sizeof(packet_send_query_mac_address), buffsend, pte);
1462  return;
1463 }
static void send_client(int size, const unsigned char *data, struct unistimsession *pte)
Definition: chan_unistim.c:801
#define BUFFSEND
Definition: chan_unistim.c:675
static const unsigned char packet_send_query_mac_address[]
Definition: chan_unistim.c:668
#define ast_verb(level,...)
Definition: logger.h:243
static int unistimdebug
Definition: chan_unistim.c:211
#define SIZE_HEADER
Definition: chan_unistim.c:139
static int ReformatNumber ( char *  number)
static

Definition at line 3008 of file chan_unistim.c.

Referenced by key_history(), and show_entry_history().

3009 {
3010  int pos = 0, i = 0, size = strlen(number);
3011 
3012  for (; i < size; i++) {
3013  if ((number[i] >= '0') && (number[i] <= '9')) {
3014  if (i == pos) {
3015  pos++;
3016  continue;
3017  }
3018  number[pos] = number[i];
3019  pos++;
3020  }
3021  }
3022  number[pos] = 0;
3023  return pos;
3024 }
Number structure.
Definition: app_followme.c:109
static void refresh_all_favorite ( struct unistimsession pte)
static

Definition at line 1056 of file chan_unistim.c.

References ast_verb, unistimsession::device, FAV_ICON_HEADPHONES_ONHOLD, send_favorite(), unistim_device::softkeyicon, unistim_device::softkeylabel, and unistim_device::softkeylinepos.

Referenced by init_phone_step2(), key_select_extension(), and reload_config().

1057 {
1058  int i = 0;
1059 
1060  if (unistimdebug)
1061  ast_verb(0, "Refreshing all favorite\n");
1062  for (i = 0; i < 6; i++) {
1063  if ((pte->device->softkeyicon[i] <= FAV_ICON_HEADPHONES_ONHOLD) &&
1064  (pte->device->softkeylinepos != i))
1065  send_favorite((unsigned char) i, pte->device->softkeyicon[i] + 1, pte,
1066  pte->device->softkeylabel[i]);
1067  else
1068  send_favorite((unsigned char) i, pte->device->softkeyicon[i], pte,
1069  pte->device->softkeylabel[i]);
1070 
1071  }
1072 }
#define FAV_ICON_HEADPHONES_ONHOLD
Definition: chan_unistim.c:165
#define ast_verb(level,...)
Definition: logger.h:243
static int unistimdebug
Definition: chan_unistim.c:211
struct unistim_device * device
Definition: chan_unistim.c:496
char softkeylabel[6][11]
Definition: chan_unistim.c:437
static void send_favorite(unsigned char pos, unsigned char status, struct unistimsession *pte, const char *text)
char softkeyicon[6]
Definition: chan_unistim.c:439
static int RegisterExtension ( const struct unistimsession pte)
static

Definition at line 1099 of file chan_unistim.c.

References ast_add_extension(), ast_verb, unistim_line::context, unistimsession::device, unistim_device::extension_number, unistim_line::fullname, and unistim_device::lines.

Referenced by key_select_extension(), and rcv_mac_addr().

1100 {
1101  if (unistimdebug)
1102  ast_verb(0, "Trying to register extension '%s' into context '%s' to %s\n",
1103  pte->device->extension_number, pte->device->lines->context,
1104  pte->device->lines->fullname);
1105  return ast_add_extension(pte->device->lines->context, 0,
1106  pte->device->extension_number, 1, NULL, NULL, "Dial",
1107  pte->device->lines->fullname, 0, "Unistim");
1108 }
#define ast_verb(level,...)
Definition: logger.h:243
static int unistimdebug
Definition: chan_unistim.c:211
struct unistim_device * device
Definition: chan_unistim.c:496
struct unistim_line * lines
Definition: chan_unistim.c:473
char context[AST_MAX_EXTENSION]
Definition: chan_unistim.c:395
char fullname[80]
Definition: chan_unistim.c:389
int ast_add_extension(const char *context, int replace, const char *extension, int priority, const char *label, const char *callerid, const char *application, void *data, void(*datad)(void *), const char *registrar)
Add and extension to an extension context.
Definition: pbx.c:8691
char extension_number[11]
Definition: chan_unistim.c:469
int reload ( void  )
static

reload: Part of Asterisk module interface —

Definition at line 5746 of file chan_unistim.c.

References unistim_reload().

5747 {
5748  unistim_reload(NULL, 0, NULL);
5749  return 0;
5750 }
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&#39;t do anything useful but setting a flag and waiting for do_monitor to do the job in our thread
static int reload_config ( void  )
static

Definition at line 5378 of file chan_unistim.c.

References ast_category_browse(), ast_config_destroy(), ast_config_load, ast_free, ast_gethostbyname(), ast_inet_ntoa(), ast_jb_read_conf(), ast_log(), ast_mutex_destroy, ast_mutex_lock, ast_mutex_unlock, ast_netsock_set_qos(), ast_str2cos(), ast_str2tos(), ast_strlen_zero(), ast_tone_zone_unref(), ast_variable_browse(), ast_verb, AUTOPROVISIONING_DB, AUTOPROVISIONING_NO, AUTOPROVISIONING_TN, AUTOPROVISIONING_YES, build_device(), config, CONFIG_STATUS_FILEINVALID, unistimsession::device, devicelock, devices, errno, finish_bookmark(), global_jbconf, hp, ast_variable::lineno, unistim_device::lines, unistim_subchannel::lock, unistim_line::lock, unistimsession::lock, LOG_ERROR, LOG_WARNING, MAX_SUBS, ast_variable::name, unistim_device::name, NB_MAX_RETRANSMIT, ast_variable::next, unistim_device::next, unistimsession::next, unistim_subchannel::owner, qos, refresh_all_favorite(), RETRANSMIT_TIMER, unistim_device::session, sessionlock, sessions, unistim_line::subs, unistim_device::to_delete, unistim_device::tz, and ast_variable::value.

Referenced by do_monitor(), and load_module().

5379 {
5380  struct ast_config *cfg;
5381  struct ast_variable *v;
5382  struct ast_hostent ahp;
5383  struct hostent *hp;
5384  struct sockaddr_in bindaddr = { 0, };
5385  char *config = "unistim.conf";
5386  char *cat;
5387  struct unistim_device *d;
5388  const int reuseFlag = 1;
5389  struct unistimsession *s;
5390  struct ast_flags config_flags = { 0, };
5391 
5392  cfg = ast_config_load(config, config_flags);
5393  /* We *must* have a config file otherwise stop immediately */
5394  if (!cfg) {
5395  ast_log(LOG_ERROR, "Unable to load config %s\n", config);
5396  return -1;
5397  } else if (cfg == CONFIG_STATUS_FILEINVALID) {
5398  ast_log(LOG_ERROR, "Config file %s is in an invalid format. Aborting.\n", config);
5399  return -1;
5400  }
5401 
5402  /* Copy the default jb config over global_jbconf */
5403  memcpy(&global_jbconf, &default_jbconf, sizeof(struct ast_jb_conf));
5404 
5405  unistim_keepalive = 120;
5406  unistim_port = 0;
5407  v = ast_variable_browse(cfg, "general");
5408  while (v) {
5409  /* handle jb conf */
5410  if (!ast_jb_read_conf(&global_jbconf, v->name, v->value))
5411  continue;
5412 
5413  if (!strcasecmp(v->name, "keepalive"))
5414  unistim_keepalive = atoi(v->value);
5415  else if (!strcasecmp(v->name, "port"))
5416  unistim_port = atoi(v->value);
5417  else if (!strcasecmp(v->name, "tos")) {
5418  if (ast_str2tos(v->value, &qos.tos))
5419  ast_log(LOG_WARNING, "Invalid tos value at line %d, refer to QoS documentation\n", v->lineno);
5420  } else if (!strcasecmp(v->name, "tos_audio")) {
5421  if (ast_str2tos(v->value, &qos.tos_audio))
5422  ast_log(LOG_WARNING, "Invalid tos_audio value at line %d, refer to QoS documentation\n", v->lineno);
5423  } else if (!strcasecmp(v->name, "cos")) {
5424  if (ast_str2cos(v->value, &qos.cos))
5425  ast_log(LOG_WARNING, "Invalid cos value at line %d, refer to QoS documentation\n", v->lineno);
5426  } else if (!strcasecmp(v->name, "cos_audio")) {
5427  if (ast_str2cos(v->value, &qos.cos_audio))
5428  ast_log(LOG_WARNING, "Invalid cos_audio value at line %d, refer to QoS documentation\n", v->lineno);
5429  } else if (!strcasecmp(v->name, "autoprovisioning")) {
5430  if (!strcasecmp(v->value, "no"))
5432  else if (!strcasecmp(v->value, "yes"))
5434  else if (!strcasecmp(v->value, "db"))
5436  else if (!strcasecmp(v->value, "tn"))
5438  else
5439  ast_log(LOG_WARNING, "Unknown autoprovisioning option.\n");
5440  } else if (!strcasecmp(v->name, "public_ip")) {
5441  if (!ast_strlen_zero(v->value)) {
5442  if (!(hp = ast_gethostbyname(v->value, &ahp)))
5443  ast_log(LOG_WARNING, "Invalid address: %s\n", v->value);
5444  else {
5445  memcpy(&public_ip.sin_addr, hp->h_addr, sizeof(public_ip.sin_addr));
5446  public_ip.sin_family = AF_INET;
5447  }
5448  }
5449  }
5450  v = v->next;
5451  }
5452  if ((unistim_keepalive < 10) ||
5454  255 - (((NB_MAX_RETRANSMIT + 1) * RETRANSMIT_TIMER) / 1000))) {
5455  ast_log(LOG_ERROR, "keepalive is invalid in %s\n", config);
5456  ast_config_destroy(cfg);
5457  return -1;
5458  }
5459  packet_send_ping[4] =
5461  if ((unistim_port < 1) || (unistim_port > 65535)) {
5462  ast_log(LOG_ERROR, "port is not set or invalid in %s\n", config);
5463  ast_config_destroy(cfg);
5464  return -1;
5465  }
5466  unistim_keepalive *= 1000;
5467 
5469  d = devices;
5470  while (d) {
5471  if (d->to_delete >= 0)
5472  d->to_delete = 1;
5473  d = d->next;
5474  }
5476  /* load the device sections */
5477  cat = ast_category_browse(cfg, NULL);
5478  while (cat) {
5479  if (strcasecmp(cat, "general")) {
5480  d = build_device(cat, ast_variable_browse(cfg, cat));
5481  }
5482  cat = ast_category_browse(cfg, cat);
5483  }
5485  d = devices;
5486  while (d) {
5487  if (d->to_delete) {
5488  int i;
5489 
5490  if (unistimdebug)
5491  ast_verb(0, "Removing device '%s'\n", d->name);
5492  if (!d->lines) {
5493  ast_log(LOG_ERROR, "Device '%s' without a line !, aborting\n", d->name);
5494  ast_config_destroy(cfg);
5495  return 0;
5496  }
5497  if (!d->lines->subs[0]) {
5498  ast_log(LOG_ERROR, "Device '%s' without a subchannel !, aborting\n",
5499  d->name);
5500  ast_config_destroy(cfg);
5501  return 0;
5502  }
5503  if (d->lines->subs[0]->owner) {
5505  "Device '%s' was not deleted : a call is in progress. Try again later.\n",
5506  d->name);
5507  d = d->next;
5508  continue;
5509  }
5510  ast_mutex_destroy(&d->lines->subs[0]->lock);
5511  ast_free(d->lines->subs[0]);
5512  for (i = 1; i < MAX_SUBS; i++) {
5513  if (d->lines->subs[i]) {
5515  "Device '%s' with threeway call subchannels allocated, aborting.\n",
5516  d->name);
5517  break;
5518  }
5519  }
5520  if (i < MAX_SUBS) {
5521  d = d->next;
5522  continue;
5523  }
5525  ast_free(d->lines);
5526  if (d->session) {
5527  if (sessions == d->session)
5528  sessions = d->session->next;
5529  else {
5530  s = sessions;
5531  while (s) {
5532  if (s->next == d->session) {
5533  s->next = d->session->next;
5534  break;
5535  }
5536  s = s->next;
5537  }
5538  }
5540  ast_free(d->session);
5541  }
5542  if (devices == d)
5543  devices = d->next;
5544  else {
5545  struct unistim_device *d2 = devices;
5546  while (d2) {
5547  if (d2->next == d) {
5548  d2->next = d->next;
5549  break;
5550  }
5551  d2 = d2->next;
5552  }
5553  }
5554  if (d->tz) {
5555  d->tz = ast_tone_zone_unref(d->tz);
5556  }
5557  ast_free(d);
5558  d = devices;
5559  continue;
5560  }
5561  d = d->next;
5562  }
5563  finish_bookmark();
5565  ast_config_destroy(cfg);
5567  s = sessions;
5568  while (s) {
5569  if (s->device)
5571  s = s->next;
5572  }
5574  /* We don't recreate a socket when reloading (locks would be necessary). */
5575  if (unistimsock > -1)
5576  return 0;
5577  bindaddr.sin_addr.s_addr = INADDR_ANY;
5578  bindaddr.sin_port = htons(unistim_port);
5579  bindaddr.sin_family = AF_INET;
5580  unistimsock = socket(AF_INET, SOCK_DGRAM, 0);
5581  if (unistimsock < 0) {
5582  ast_log(LOG_WARNING, "Unable to create UNISTIM socket: %s\n", strerror(errno));
5583  return -1;
5584  }
5585 #ifdef HAVE_PKTINFO
5586  {
5587  const int pktinfoFlag = 1;
5588  setsockopt(unistimsock, IPPROTO_IP, IP_PKTINFO, &pktinfoFlag,
5589  sizeof(pktinfoFlag));
5590  }
5591 #else
5592  if (public_ip.sin_family == 0) {
5594  "Your OS does not support IP_PKTINFO, you must set public_ip.\n");
5595  unistimsock = -1;
5596  return -1;
5597  }
5598 #endif
5599  setsockopt(unistimsock, SOL_SOCKET, SO_REUSEADDR, (const char *) &reuseFlag,
5600  sizeof(reuseFlag));
5601  if (bind(unistimsock, (struct sockaddr *) &bindaddr, sizeof(bindaddr)) < 0) {
5602  ast_log(LOG_WARNING, "Failed to bind to %s:%d: %s\n",
5603  ast_inet_ntoa(bindaddr.sin_addr), htons(bindaddr.sin_port),
5604  strerror(errno));
5605  close(unistimsock);
5606  unistimsock = -1;
5607  } else {
5608  ast_verb(2, "UNISTIM Listening on %s:%d\n", ast_inet_ntoa(bindaddr.sin_addr), htons(bindaddr.sin_port));
5609  ast_netsock_set_qos(unistimsock, qos.tos, qos.cos, "UNISTIM");
5610  }
5611  return 0;
5612 }
ast_mutex_t lock
Definition: chan_unistim.c:367
struct ast_channel * owner
Definition: chan_unistim.c:371
static int unistim_port
Definition: chan_unistim.c:212
static struct unistimsession * sessions
static const char config[]
Definition: cdr_csv.c:57
A device containing one or more lines.
Definition: chan_unistim.c:427
char name[DEVICE_NAME_LEN]
Definition: chan_unistim.c:435
static struct @114 qos
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:204
static int unistimsock
Definition: chan_unistim.c:215
#define LOG_WARNING
Definition: logger.h:144
struct ast_variable * ast_variable_browse(const struct ast_config *config, const char *category)
Goes through variables.
Definition: config.c:597
int ast_jb_read_conf(struct ast_jb_conf *conf, const char *varname, const char *value)
Sets jitterbuffer configuration property.
Definition: abstract_jb.c:577
int lineno
Definition: config.h:87
Structure for variables, used for configurations and for channel variables.
Definition: config.h:75
static struct unistim_device * build_device(const char *cat, const struct ast_variable *v)
int ast_netsock_set_qos(int netsocket, int tos, int cos, const char *desc)
Definition: netsock.c:158
#define ast_mutex_lock(a)
Definition: lock.h:155
int ast_str2tos(const char *value, unsigned int *tos)
Convert a string to the appropriate TOS value.
Definition: acl.c:667
#define MAX_SUBS
Definition: chan_unistim.c:107
#define ast_verb(level,...)
Definition: logger.h:243
void ast_config_destroy(struct ast_config *config)
Destroys a config.
Definition: config.c:1037
struct unistim_subchannel * subs[MAX_SUBS]
Definition: chan_unistim.c:391
static ast_mutex_t sessionlock
Definition: chan_unistim.c:247
ast_mutex_t lock
Definition: chan_unistim.c:480
static int unistimdebug
Definition: chan_unistim.c:211
#define RETRANSMIT_TIMER
Definition: chan_unistim.c:95
struct unistim_device * device
Definition: chan_unistim.c:496
struct unistimsession * next
Definition: chan_unistim.c:497
static void refresh_all_favorite(struct unistimsession *pte)
static ast_mutex_t devicelock
Definition: chan_unistim.c:249
ast_mutex_t lock
Definition: chan_unistim.c:385
const char * value
Definition: config.h:79
static struct sockaddr_in public_ip
Definition: chan_unistim.c:226
#define ast_config_load(filename, flags)
Load a config file.
Definition: config.h:170
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition: strings.h:63
struct unistim_device * next
Definition: chan_unistim.c:476
struct unistimsession * session
Definition: chan_unistim.c:475
#define NB_MAX_RETRANSMIT
Definition: chan_unistim.c:91
char * ast_category_browse(struct ast_config *config, const char *prev)
Goes through categories.
Definition: config.c:810
static struct ast_jb_conf default_jbconf
Global jitterbuffer configuration - by default, jb is disabled.
Definition: chan_unistim.c:195
static int unistim_keepalive
Definition: chan_unistim.c:214
const char * name
Definition: config.h:77
struct ast_tone_zone * tz
Definition: chan_unistim.c:450
static struct ast_hostent ahp
Definition: chan_skinny.c:1047
static struct ast_jb_conf global_jbconf
Definition: chan_unistim.c:203
#define LOG_ERROR
Definition: logger.h:155
struct ast_sockaddr bindaddr
Definition: chan_sip.c:1146
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
struct unistim_line * lines
Definition: chan_unistim.c:473
int errno
const char * ast_inet_ntoa(struct in_addr ia)
thread-safe replacement for inet_ntoa().
Definition: utils.c:564
#define ast_free(a)
Definition: astmm.h:97
int ast_str2cos(const char *value, unsigned int *cos)
Convert a string to the appropriate COS value.
Definition: acl.c:653
static struct unistim_device * devices
Structure used to handle boolean flags.
Definition: utils.h:200
struct hostent * ast_gethostbyname(const char *host, struct ast_hostent *hp)
Thread-safe gethostbyname function to use in Asterisk.
Definition: utils.c:195
static enum autoprovision autoprovisioning
Definition: chan_unistim.c:213
static void finish_bookmark(void)
struct ast_variable * next
Definition: config.h:82
#define CONFIG_STATUS_FILEINVALID
Definition: config.h:52
#define ast_mutex_destroy(a)
Definition: lock.h:154
static struct hostent * hp
Definition: chan_skinny.c:1048
General jitterbuffer configuration.
Definition: abstract_jb.h:55
#define ast_mutex_unlock(a)
Definition: lock.h:156
static unsigned char packet_send_ping[]
Definition: chan_unistim.c:672
static int restart_monitor ( void  )
static

Definition at line 4663 of file chan_unistim.c.

References ast_log(), ast_mutex_lock, ast_mutex_unlock, ast_pthread_create, AST_PTHREADT_NULL, AST_PTHREADT_STOP, do_monitor(), LOG_ERROR, LOG_WARNING, and monlock.

Referenced by load_module(), unistim_reload(), and unistim_request().

4664 {
4665  pthread_attr_t attr;
4666  /* If we're supposed to be stopped -- stay stopped */
4668  return 0;
4669  if (ast_mutex_lock(&monlock)) {
4670  ast_log(LOG_WARNING, "Unable to lock monitor\n");
4671  return -1;
4672  }
4673  if (monitor_thread == pthread_self()) {
4675  ast_log(LOG_WARNING, "Cannot kill myself\n");
4676  return -1;
4677  }
4679  /* Wake up the thread */
4680  pthread_kill(monitor_thread, SIGURG);
4681  } else {
4682  pthread_attr_init(&attr);
4683  pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
4684  /* Start a new monitor */
4685  if (ast_pthread_create(&monitor_thread, &attr, do_monitor, NULL) < 0) {
4687  ast_log(LOG_ERROR, "Unable to start monitor thread.\n");
4688  return -1;
4689  }
4690  }
4692  return 0;
4693 }
static pthread_t monitor_thread
Definition: chan_unistim.c:241
#define LOG_WARNING
Definition: logger.h:144
#define ast_mutex_lock(a)
Definition: lock.h:155
static void * do_monitor(void *data)
#define AST_PTHREADT_NULL
Definition: lock.h:65
#define LOG_ERROR
Definition: logger.h:155
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
#define ast_pthread_create(a, b, c, d)
Definition: utils.h:418
#define AST_PTHREADT_STOP
Definition: lock.h:66
#define ast_mutex_unlock(a)
Definition: lock.h:156
static ast_mutex_t monlock
Definition: chan_unistim.c:245
static void send_blink_cursor ( struct unistimsession pte)
static

Definition at line 1429 of file chan_unistim.c.

References ast_verb, BUFFSEND, send_client(), and SIZE_HEADER.

Referenced by handle_dial_page(), HandleSelectCodec(), key_dial_page(), key_select_codec(), key_select_extension(), and ShowExtensionPage().

1430 {
1431  BUFFSEND;
1432  if (unistimdebug)
1433  ast_verb(0, "Sending set blink\n");
1434  memcpy(buffsend + SIZE_HEADER, packet_send_blink_cursor, sizeof(packet_send_blink_cursor));
1435  send_client(SIZE_HEADER + sizeof(packet_send_blink_cursor), buffsend, pte);
1436  return;
1437 }
static void send_client(int size, const unsigned char *data, struct unistimsession *pte)
Definition: chan_unistim.c:801
#define BUFFSEND
Definition: chan_unistim.c:675
#define ast_verb(level,...)
Definition: logger.h:243
static int unistimdebug
Definition: chan_unistim.c:211
#define SIZE_HEADER
Definition: chan_unistim.c:139
static const unsigned char packet_send_blink_cursor[]
Definition: chan_unistim.c:625
static void send_client ( int  size,
const unsigned char *  data,
struct unistimsession pte 
)
static

Definition at line 801 of file chan_unistim.c.

References ast_log(), ast_mutex_lock, ast_mutex_unlock, ast_verb, wsabuf::buf, get_tick_count(), unistimsession::last_buf_available, wsabuf::len, unistimsession::lock, LOG_WARNING, MAX_BUF_NUMBER, RETRANSMIT_TIMER, send_raw_client(), seq, unistimsession::seq_server, unistimsession::sin, unistimsession::sout, unistimsession::timeout, and unistimsession::wsabufsend.

Referenced by init_phone_step2(), rcv_mac_addr(), rcv_resume_connection_with_server(), send_blink_cursor(), send_cursor_pos(), send_date_time(), send_date_time2(), send_date_time3(), send_end_call(), send_favorite(), send_led_update(), send_no_ring(), send_ping(), send_ring(), send_select_output(), send_start_timer(), send_stop_timer(), send_text(), send_text_status(), send_texttitle(), send_tone(), Sendicon(), start_rtp(), and unistim_sp().

802 {
803  unsigned int tick;
804  int buf_pos;
805  unsigned short seq = ntohs(++pte->seq_server);
806 
807  ast_mutex_lock(&pte->lock);
808  buf_pos = pte->last_buf_available;
809 
810  if (buf_pos >= MAX_BUF_NUMBER) {
811  ast_log(LOG_WARNING, "Error : send queue overflow\n");
812  ast_mutex_unlock(&pte->lock);
813  return;
814  }
815  memcpy((void *)data + sizeof(unsigned short), (void *)&seq, sizeof(unsigned short));
816  pte->wsabufsend[buf_pos].len = size;
817  memcpy(pte->wsabufsend[buf_pos].buf, data, size);
818 
819  tick = get_tick_count();
820  pte->timeout = tick + RETRANSMIT_TIMER;
821 
822 /*#ifdef DUMP_PACKET */
823  if (unistimdebug)
824  ast_verb(6, "Sending datas with seq #0x%.4x Using slot #%d :\n", (unsigned)pte->seq_server, buf_pos);
825 /*#endif */
826  send_raw_client(pte->wsabufsend[buf_pos].len, pte->wsabufsend[buf_pos].buf, &(pte->sin),
827  &(pte->sout));
828  pte->last_buf_available++;
829  ast_mutex_unlock(&pte->lock);
830 }
struct sockaddr_in sout
Definition: chan_unistim.c:482
struct wsabuf wsabufsend[MAX_BUF_NUMBER]
Definition: chan_unistim.c:494
#define LOG_WARNING
Definition: logger.h:144
unsigned short seq_server
Definition: chan_unistim.c:485
#define ast_mutex_lock(a)
Definition: lock.h:155
#define MAX_BUF_NUMBER
Definition: chan_unistim.c:89
#define ast_verb(level,...)
Definition: logger.h:243
ast_mutex_t lock
Definition: chan_unistim.c:480
static int unistimdebug
Definition: chan_unistim.c:211
#define RETRANSMIT_TIMER
Definition: chan_unistim.c:95
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
u_long len
Definition: chan_unistim.c:351
struct sockaddr_in sin
Definition: chan_unistim.c:481
static volatile unsigned int seq
Definition: app_sms.c:118
unsigned char * buf
Definition: chan_unistim.c:352
static unsigned int get_tick_count(void)
Definition: chan_unistim.c:736
#define ast_mutex_unlock(a)
Definition: lock.h:156
static void send_raw_client(int size, const unsigned char *data, struct sockaddr_in *addr_to, const struct sockaddr_in *addr_ourip)
Definition: chan_unistim.c:744
static void send_cursor_pos ( struct unistimsession pte,
unsigned char  pos 
)
static

Definition at line 1440 of file chan_unistim.c.

References ast_verb, BUFFSEND, send_client(), and SIZE_HEADER.

Referenced by handle_dial_page(), HandleSelectCodec(), key_dial_page(), key_select_codec(), key_select_extension(), and ShowExtensionPage().

1441 {
1442  BUFFSEND;
1443  if (unistimdebug)
1444  ast_verb(0, "Sending set cursor position\n");
1445  memcpy(buffsend + SIZE_HEADER, packet_send_set_pos_cursor,
1446  sizeof(packet_send_set_pos_cursor));
1447  buffsend[11] = pos;
1448  send_client(SIZE_HEADER + sizeof(packet_send_set_pos_cursor), buffsend, pte);
1449  return;
1450 }
static void send_client(int size, const unsigned char *data, struct unistimsession *pte)
Definition: chan_unistim.c:801
#define BUFFSEND
Definition: chan_unistim.c:675
static const unsigned char packet_send_set_pos_cursor[]
Definition: chan_unistim.c:637
#define ast_verb(level,...)
Definition: logger.h:243
static int unistimdebug
Definition: chan_unistim.c:211
#define SIZE_HEADER
Definition: chan_unistim.c:139
static void send_date_time ( struct unistimsession pte)
static

Definition at line 1374 of file chan_unistim.c.

References ast_localtime(), ast_tvnow(), ast_verb, BUFFSEND, send_client(), SIZE_HEADER, ast_tm::tm_hour, ast_tm::tm_mday, ast_tm::tm_min, and ast_tm::tm_mon.

Referenced by rcv_mac_addr().

1375 {
1376  BUFFSEND;
1377  struct timeval now = ast_tvnow();
1378  struct ast_tm atm = { 0, };
1379 
1380  if (unistimdebug)
1381  ast_verb(0, "Sending Time & Date\n");
1382  memcpy(buffsend + SIZE_HEADER, packet_send_date_time, sizeof(packet_send_date_time));
1383  ast_localtime(&now, &atm, NULL);
1384  buffsend[10] = (unsigned char) atm.tm_mon + 1;
1385  buffsend[11] = (unsigned char) atm.tm_mday;
1386  buffsend[12] = (unsigned char) atm.tm_hour;
1387  buffsend[13] = (unsigned char) atm.tm_min;
1388  send_client(SIZE_HEADER + sizeof(packet_send_date_time), buffsend, pte);
1389 }
static void send_client(int size, const unsigned char *data, struct unistimsession *pte)
Definition: chan_unistim.c:801
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:1570
#define BUFFSEND
Definition: chan_unistim.c:675
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
Definition: time.h:142
static const unsigned char packet_send_date_time[]
Definition: chan_unistim.c:536
#define ast_verb(level,...)
Definition: logger.h:243
static int unistimdebug
Definition: chan_unistim.c:211
#define SIZE_HEADER
Definition: chan_unistim.c:139
int tm_mon
Definition: localtime.h:40
int tm_mday
Definition: localtime.h:39
int tm_hour
Definition: localtime.h:38
int tm_min
Definition: localtime.h:37
static void send_date_time2 ( struct unistimsession pte)
static

Definition at line 1391 of file chan_unistim.c.

References ast_localtime(), ast_tvnow(), ast_verb, BUFFSEND, unistim_device::datetimeformat, unistimsession::device, send_client(), SIZE_HEADER, ast_tm::tm_hour, ast_tm::tm_mday, ast_tm::tm_min, and ast_tm::tm_mon.

Referenced by init_phone_step2().

1392 {
1393  BUFFSEND;
1394  struct timeval now = ast_tvnow();
1395  struct ast_tm atm = { 0, };
1396 
1397  if (unistimdebug)
1398  ast_verb(0, "Sending Time & Date #2\n");
1399  memcpy(buffsend + SIZE_HEADER, packet_send_date_time2, sizeof(packet_send_date_time2));
1400  ast_localtime(&now, &atm, NULL);
1401  if (pte->device)
1402  buffsend[9] = pte->device->datetimeformat;
1403  else
1404  buffsend[9] = 61;
1405  buffsend[14] = (unsigned char) atm.tm_mon + 1;
1406  buffsend[15] = (unsigned char) atm.tm_mday;
1407  buffsend[16] = (unsigned char) atm.tm_hour;
1408  buffsend[17] = (unsigned char) atm.tm_min;
1409  send_client(SIZE_HEADER + sizeof(packet_send_date_time2), buffsend, pte);
1410 }
static void send_client(int size, const unsigned char *data, struct unistimsession *pte)
Definition: chan_unistim.c:801
static const unsigned char packet_send_date_time2[]
Definition: chan_unistim.c:626
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:1570
#define BUFFSEND
Definition: chan_unistim.c:675
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
Definition: time.h:142
#define ast_verb(level,...)
Definition: logger.h:243
static int unistimdebug
Definition: chan_unistim.c:211
struct unistim_device * device
Definition: chan_unistim.c:496
#define SIZE_HEADER
Definition: chan_unistim.c:139
int tm_mon
Definition: localtime.h:40
int tm_mday
Definition: localtime.h:39
int tm_hour
Definition: localtime.h:38
int tm_min
Definition: localtime.h:37
static void send_date_time3 ( struct unistimsession pte)
static

Definition at line 1412 of file chan_unistim.c.

References ast_localtime(), ast_tvnow(), ast_verb, BUFFSEND, send_client(), SIZE_HEADER, ast_tm::tm_hour, ast_tm::tm_mday, ast_tm::tm_min, and ast_tm::tm_mon.

Referenced by init_phone_step2().

1413 {
1414  BUFFSEND;
1415  struct timeval now = ast_tvnow();
1416  struct ast_tm atm = { 0, };
1417 
1418  if (unistimdebug)
1419  ast_verb(0, "Sending Time & Date #3\n");
1420  memcpy(buffsend + SIZE_HEADER, packet_send_date_time3, sizeof(packet_send_date_time3));
1421  ast_localtime(&now, &atm, NULL);
1422  buffsend[10] = (unsigned char) atm.tm_mon + 1;
1423  buffsend[11] = (unsigned char) atm.tm_mday;
1424  buffsend[12] = (unsigned char) atm.tm_hour;
1425  buffsend[13] = (unsigned char) atm.tm_min;
1426  send_client(SIZE_HEADER + sizeof(packet_send_date_time3), buffsend, pte);
1427 }
static void send_client(int size, const unsigned char *data, struct unistimsession *pte)
Definition: chan_unistim.c:801
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:1570
#define BUFFSEND
Definition: chan_unistim.c:675
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
Definition: time.h:142
#define ast_verb(level,...)
Definition: logger.h:243
static int unistimdebug
Definition: chan_unistim.c:211
static const unsigned char packet_send_date_time3[]
Definition: chan_unistim.c:532
#define SIZE_HEADER
Definition: chan_unistim.c:139
int tm_mon
Definition: localtime.h:40
int tm_mday
Definition: localtime.h:39
int tm_hour
Definition: localtime.h:38
int tm_min
Definition: localtime.h:37
static void send_end_call ( struct unistimsession pte)
static

Definition at line 911 of file chan_unistim.c.

References ast_verb, BUFFSEND, send_client(), and SIZE_HEADER.

Referenced by unistim_hangup().

912 {
913  BUFFSEND;
914  if (unistimdebug)
915  ast_verb(0, "Sending end call\n");
916  memcpy(buffsend + SIZE_HEADER, packet_send_end_call, sizeof(packet_send_end_call));
917  send_client(SIZE_HEADER + sizeof(packet_send_end_call), buffsend, pte);
918 }
static void send_client(int size, const unsigned char *data, struct unistimsession *pte)
Definition: chan_unistim.c:801
#define BUFFSEND
Definition: chan_unistim.c:675
#define ast_verb(level,...)
Definition: logger.h:243
static int unistimdebug
Definition: chan_unistim.c:211
#define SIZE_HEADER
Definition: chan_unistim.c:139
static const unsigned char packet_send_end_call[]
Definition: chan_unistim.c:580
static void send_favorite ( unsigned char  pos,
unsigned char  status,
struct unistimsession pte,
const char *  text 
)
static

Definition at line 1037 of file chan_unistim.c.

References ast_verb, BUFFSEND, FAV_MAX_LENGTH, send_client(), SIZE_HEADER, and status.

Referenced by change_favorite_icon(), init_phone_step2(), refresh_all_favorite(), show_main_page(), and unistim_sendtext().

1039 {
1040  BUFFSEND;
1041  int i;
1042 
1043  if (unistimdebug)
1044  ast_verb(0, "Sending favorite pos %d with status 0x%.2x\n", pos, (unsigned)status);
1045  memcpy(buffsend + SIZE_HEADER, packet_send_favorite, sizeof(packet_send_favorite));
1046  buffsend[10] = pos;
1047  buffsend[24] = pos;
1048  buffsend[25] = status;
1049  i = strlen(text);
1050  if (i > FAV_MAX_LENGTH)
1051  i = FAV_MAX_LENGTH;
1052  memcpy(buffsend + FAV_MAX_LENGTH + 1, text, i);
1053  send_client(SIZE_HEADER + sizeof(packet_send_favorite), buffsend, pte);
1054 }
static void send_client(int size, const unsigned char *data, struct unistimsession *pte)
Definition: chan_unistim.c:801
#define BUFFSEND
Definition: chan_unistim.c:675
char * text
Definition: app_queue.c:1091
#define ast_verb(level,...)
Definition: logger.h:243
static int unistimdebug
Definition: chan_unistim.c:211
static const unsigned char packet_send_favorite[]
Definition: chan_unistim.c:642
#define SIZE_HEADER
Definition: chan_unistim.c:139
#define FAV_MAX_LENGTH
Definition: chan_unistim.c:186
jack_status_t status
Definition: app_jack.c:143
static void send_led_update ( struct unistimsession pte,
unsigned char  led 
)
static

Definition at line 1265 of file chan_unistim.c.

References ast_verb, BUFFSEND, send_client(), and SIZE_HEADER.

Referenced by handle_dial_page(), init_phone_step2(), send_select_output(), and unistim_send_mwi_to_peer().

1266 {
1267  BUFFSEND;
1268  if (unistimdebug)
1269  ast_verb(0, "Sending led_update (%x)\n", (unsigned)led);
1270  memcpy(buffsend + SIZE_HEADER, packet_send_led_update, sizeof(packet_send_led_update));
1271  buffsend[9] = led;
1272  send_client(SIZE_HEADER + sizeof(packet_send_led_update), buffsend, pte);
1273 }
static void send_client(int size, const unsigned char *data, struct unistimsession *pte)
Definition: chan_unistim.c:801
#define BUFFSEND
Definition: chan_unistim.c:675
static const unsigned char packet_send_led_update[]
Definition: chan_unistim.c:665
#define ast_verb(level,...)
Definition: logger.h:243
static int unistimdebug
Definition: chan_unistim.c:211
#define SIZE_HEADER
Definition: chan_unistim.c:139
static void send_no_ring ( struct unistimsession pte)
static

Definition at line 1350 of file chan_unistim.c.

References ast_verb, BUFFSEND, send_client(), and SIZE_HEADER.

Referenced by cancel_dial(), HandleCallIncoming(), IgnoreCall(), init_phone_step2(), and unistim_hangup().

1351 {
1352  BUFFSEND;
1353  if (unistimdebug)
1354  ast_verb(0, "Sending no ring packet\n");
1355  memcpy(buffsend + SIZE_HEADER, packet_send_no_ring, sizeof(packet_send_no_ring));
1356  send_client(SIZE_HEADER + sizeof(packet_send_no_ring), buffsend, pte);
1357 }
static void send_client(int size, const unsigned char *data, struct unistimsession *pte)
Definition: chan_unistim.c:801
#define BUFFSEND
Definition: chan_unistim.c:675
#define ast_verb(level,...)
Definition: logger.h:243
static int unistimdebug
Definition: chan_unistim.c:211
#define SIZE_HEADER
Definition: chan_unistim.c:139
static const unsigned char packet_send_no_ring[]
Definition: chan_unistim.c:543
static void send_ping ( struct unistimsession pte)
static

Definition at line 832 of file chan_unistim.c.

References ast_verb, BUFFSEND, get_tick_count(), send_client(), SIZE_HEADER, unistimsession::tick_next_ping, and unistim_keepalive.

Referenced by do_monitor(), and init_phone_step2().

833 {
834  BUFFSEND;
835  if (unistimdebug)
836  ast_verb(6, "Sending ping\n");
838  memcpy(buffsend + SIZE_HEADER, packet_send_ping, sizeof(packet_send_ping));
839  send_client(SIZE_HEADER + sizeof(packet_send_ping), buffsend, pte);
840 }
static void send_client(int size, const unsigned char *data, struct unistimsession *pte)
Definition: chan_unistim.c:801
#define BUFFSEND
Definition: chan_unistim.c:675
#define ast_verb(level,...)
Definition: logger.h:243
static int unistimdebug
Definition: chan_unistim.c:211
unsigned long tick_next_ping
Definition: chan_unistim.c:487
#define SIZE_HEADER
Definition: chan_unistim.c:139
static int unistim_keepalive
Definition: chan_unistim.c:214
static unsigned int get_tick_count(void)
Definition: chan_unistim.c:736
static unsigned char packet_send_ping[]
Definition: chan_unistim.c:672
static void send_raw_client ( int  size,
const unsigned char *  data,
struct sockaddr_in *  addr_to,
const struct sockaddr_in *  addr_ourip 
)
static

Definition at line 744 of file chan_unistim.c.

References ast_inet_ntoa(), ast_verb, and display_last_error().

Referenced by parsing(), send_client(), and send_retransmit().

746 {
747 #ifdef HAVE_PKTINFO
748  struct iovec msg_iov;
749  struct msghdr msg;
750  char buffer[CMSG_SPACE(sizeof(struct in_pktinfo))];
751  struct cmsghdr *ip_msg = (struct cmsghdr *) buffer;
752  struct in_pktinfo *pki = (struct in_pktinfo *) CMSG_DATA(ip_msg);
753 
754  /* cast this to a non-const pointer, since the sendmsg() API
755  * does not provide read-only and write-only flavors of the
756  * structures used for its arguments, but in this case we know
757  * the data will not be modified
758  */
759  msg_iov.iov_base = (char *) data;
760  msg_iov.iov_len = size;
761 
762  msg.msg_name = addr_to; /* optional address */
763  msg.msg_namelen = sizeof(struct sockaddr_in); /* size of address */
764  msg.msg_iov = &msg_iov; /* scatter/gather array */
765  msg.msg_iovlen = 1; /* # elements in msg_iov */
766  msg.msg_control = ip_msg; /* ancillary data */
767  msg.msg_controllen = sizeof(buffer); /* ancillary data buffer len */
768  msg.msg_flags = 0; /* flags on received message */
769 
770  ip_msg->cmsg_len = CMSG_LEN(sizeof(*pki));
771  ip_msg->cmsg_level = IPPROTO_IP;
772  ip_msg->cmsg_type = IP_PKTINFO;
773  pki->ipi_ifindex = 0; /* Interface index, 0 = use interface specified in routing table */
774  pki->ipi_spec_dst.s_addr = addr_ourip->sin_addr.s_addr; /* Local address */
775  /* pki->ipi_addr = ; Header Destination address - ignored by kernel */
776 
777 #ifdef DUMP_PACKET
778  if (unistimdebug) {
779  int tmp;
780  char iabuf[INET_ADDRSTRLEN];
781  char iabuf2[INET_ADDRSTRLEN];
782  ast_verb(0, "\n**> From %s sending %d bytes to %s ***\n",
783  ast_inet_ntoa(addr_ourip->sin_addr), (int) size,
784  ast_inet_ntoa(addr_to->sin_addr));
785  for (tmp = 0; tmp < size; tmp++)
786  ast_verb(0, "%.2x ", (unsigned char) data[tmp]);
787  ast_verb(0, "\n******************************************\n");
788 
789  }
790 #endif
791 
792  if (sendmsg(unistimsock, &msg, 0) == -1)
793  display_last_error("Error sending datas");
794 #else
795  if (sendto(unistimsock, data, size, 0, (struct sockaddr *) addr_to, sizeof(*addr_to))
796  == -1)
797  display_last_error("Error sending datas");
798 #endif
799 }
static int unistimsock
Definition: chan_unistim.c:215
#define ast_verb(level,...)
Definition: logger.h:243
static int unistimdebug
Definition: chan_unistim.c:211
const char * ast_inet_ntoa(struct in_addr ia)
thread-safe replacement for inet_ntoa().
Definition: utils.c:564
static void display_last_error(const char *sz_msg)
Definition: chan_unistim.c:725
static int send_retransmit ( struct unistimsession pte)
static

Definition at line 1170 of file chan_unistim.c.

References ast_log(), ast_mutex_lock, ast_mutex_unlock, ast_verb, wsabuf::buf, close_client(), get_tick_count(), unistimsession::last_buf_available, unistimsession::last_seq_ack, wsabuf::len, unistimsession::lock, LOG_WARNING, NB_MAX_RETRANSMIT, unistimsession::nb_retransmit, RETRANSMIT_TIMER, send_raw_client(), seq, unistimsession::seq_server, unistimsession::sin, unistimsession::sout, unistimsession::timeout, and unistimsession::wsabufsend.

Referenced by do_monitor(), and parsing().

1171 {
1172  int i;
1173 
1174  ast_mutex_lock(&pte->lock);
1175  if (++pte->nb_retransmit >= NB_MAX_RETRANSMIT) {
1176  if (unistimdebug)
1177  ast_verb(0, "Too many retransmit - freeing client\n");
1178  ast_mutex_unlock(&pte->lock);
1179  close_client(pte);
1180  return 1;
1181  }
1183 
1184  for (i = pte->last_buf_available - (pte->seq_server - pte->last_seq_ack);
1185  i < pte->last_buf_available; i++) {
1186  if (i < 0) {
1188  "Asked to retransmit an ACKed slot ! last_buf_available=%d, seq_server = #0x%.4x last_seq_ack = #0x%.4x\n",
1189  pte->last_buf_available, (unsigned)pte->seq_server, (unsigned)pte->last_seq_ack);
1190  continue;
1191  }
1192 
1193  if (unistimdebug) {
1194  unsigned short *sbuf = (unsigned short *) pte->wsabufsend[i].buf;
1195  unsigned short seq;
1196 
1197  seq = ntohs(sbuf[1]);
1198  ast_verb(0, "Retransmit slot #%d (seq=#0x%.4x), last ack was #0x%.4x\n", i,
1199  (unsigned)seq, (unsigned)pte->last_seq_ack);
1200  }
1201  send_raw_client(pte->wsabufsend[i].len, pte->wsabufsend[i].buf, &pte->sin,
1202  &pte->sout);
1203  }
1204  ast_mutex_unlock(&pte->lock);
1205  return 0;
1206 }
struct sockaddr_in sout
Definition: chan_unistim.c:482
struct wsabuf wsabufsend[MAX_BUF_NUMBER]
Definition: chan_unistim.c:494
#define LOG_WARNING
Definition: logger.h:144
unsigned short seq_server
Definition: chan_unistim.c:485
#define ast_mutex_lock(a)
Definition: lock.h:155
static void close_client(struct unistimsession *s)
#define ast_verb(level,...)
Definition: logger.h:243
ast_mutex_t lock
Definition: chan_unistim.c:480
unsigned short last_seq_ack
Definition: chan_unistim.c:486
static int unistimdebug
Definition: chan_unistim.c:211
#define RETRANSMIT_TIMER
Definition: chan_unistim.c:95
#define NB_MAX_RETRANSMIT
Definition: chan_unistim.c:91
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
u_long len
Definition: chan_unistim.c:351
struct sockaddr_in sin
Definition: chan_unistim.c:481
static volatile unsigned int seq
Definition: app_sms.c:118
unsigned char * buf
Definition: chan_unistim.c:352
static unsigned int get_tick_count(void)
Definition: chan_unistim.c:736
#define ast_mutex_unlock(a)
Definition: lock.h:156
static void send_raw_client(int size, const unsigned char *data, struct sockaddr_in *addr_to, const struct sockaddr_in *addr_ourip)
Definition: chan_unistim.c:744
static void send_ring ( struct unistimsession pte,
char  volume,
char  style 
)
static

Definition at line 1339 of file chan_unistim.c.

References ast_verb, BUFFSEND, send_client(), and SIZE_HEADER.

Referenced by unistim_call().

1340 {
1341  BUFFSEND;
1342  if (unistimdebug)
1343  ast_verb(0, "Sending ring packet\n");
1344  memcpy(buffsend + SIZE_HEADER, packet_send_ring, sizeof(packet_send_ring));
1345  buffsend[24] = style + 0x10;
1346  buffsend[29] = volume * 0x10;
1347  send_client(SIZE_HEADER + sizeof(packet_send_ring), buffsend, pte);
1348 }
static void send_client(int size, const unsigned char *data, struct unistimsession *pte)
Definition: chan_unistim.c:801
#define BUFFSEND
Definition: chan_unistim.c:675
#define ast_verb(level,...)
Definition: logger.h:243
static int unistimdebug
Definition: chan_unistim.c:211
static const unsigned char packet_send_ring[]
Definition: chan_unistim.c:575
#define SIZE_HEADER
Definition: chan_unistim.c:139
static void send_select_output ( struct unistimsession pte,
unsigned char  output,
unsigned char  volume,
unsigned char  mute 
)
static

Definition at line 1279 of file chan_unistim.c.

References ast_log(), ast_verb, BUFFSEND, change_favorite_icon(), unistimsession::device, FAV_ICON_HEADPHONES, FAV_ICON_HEADPHONES_ONHOLD, FAV_ICON_OFFHOOK_BLACK, FAV_ICON_ONHOLD_BLACK, FAV_ICON_SPEAKER_OFFHOOK_BLACK, FAV_ICON_SPEAKER_ONHOLD_BLACK, FAV_ICON_SPEAKER_ONHOOK_BLACK, LOG_WARNING, mute, unistim_device::mute, MUTE_OFF, MUTE_ON, MUTE_ON_DISCRET, unistim_device::output, OUTPUT_HANDSET, OUTPUT_HEADPHONE, OUTPUT_SPEAKER, unistim_device::previous_output, unistim_device::receiver_state, send_client(), send_led_update(), SIZE_HEADER, STATE_OFFHOOK, VOLUME_LOW, and VOLUME_LOW_SPEAKER.

Referenced by handle_dial_page(), HandleCallIncoming(), HandleCallOutgoing(), key_call(), key_dial_page(), key_main_page(), process_request(), and show_main_page().

1281 {
1282  BUFFSEND;
1283  if (unistimdebug)
1284  ast_verb(0, "Sending select output packet output=%x volume=%x mute=%x\n", (unsigned)output,
1285  (unsigned)volume, (unsigned)mute);
1286  memcpy(buffsend + SIZE_HEADER, packet_send_select_output,
1287  sizeof(packet_send_select_output));
1288  buffsend[9] = output;
1289  if (output == OUTPUT_SPEAKER)
1290  volume = VOLUME_LOW_SPEAKER;
1291  else
1292  volume = VOLUME_LOW;
1293  buffsend[10] = volume;
1294  if (mute == MUTE_ON_DISCRET)
1295  buffsend[11] = MUTE_ON;
1296  else
1297  buffsend[11] = mute;
1298  send_client(SIZE_HEADER + sizeof(packet_send_select_output), buffsend, pte);
1299  if (mute == MUTE_OFF)
1300  send_led_update(pte, 0x18);
1301  else if (mute == MUTE_ON)
1302  send_led_update(pte, 0x19);
1303  pte->device->mute = mute;
1304  if (output == OUTPUT_HANDSET) {
1305  if (mute == MUTE_ON)
1307  else
1309  send_led_update(pte, 0x08);
1310  send_led_update(pte, 0x10);
1311  } else if (output == OUTPUT_HEADPHONE) {
1312  if (mute == MUTE_ON)
1314  else
1316  send_led_update(pte, 0x08);
1317  send_led_update(pte, 0x11);
1318  } else if (output == OUTPUT_SPEAKER) {
1319  send_led_update(pte, 0x10);
1320  send_led_update(pte, 0x09);
1321  if (pte->device->receiver_state == STATE_OFFHOOK) {
1322  if (mute == MUTE_ON)
1324  else
1326  } else {
1327  if (mute == MUTE_ON)
1329  else
1331  }
1332  } else
1333  ast_log(LOG_WARNING, "Invalid output (%d)\n", output);
1334  if (output != pte->device->output)
1335  pte->device->previous_output = pte->device->output;
1336  pte->device->output = output;
1337 }
static const unsigned char packet_send_select_output[]
Definition: chan_unistim.c:573
static void send_client(int size, const unsigned char *data, struct unistimsession *pte)
Definition: chan_unistim.c:801
#define FAV_ICON_ONHOLD_BLACK
Definition: chan_unistim.c:156
#define FAV_ICON_HEADPHONES_ONHOLD
Definition: chan_unistim.c:165
#define LOG_WARNING
Definition: logger.h:144
static void change_favorite_icon(struct unistimsession *pte, unsigned char status)
#define BUFFSEND
Definition: chan_unistim.c:675
#define ast_verb(level,...)
Definition: logger.h:243
static int mute
Definition: chan_alsa.c:135
#define VOLUME_LOW
Definition: chan_unistim.c:130
static int unistimdebug
Definition: chan_unistim.c:211
#define FAV_ICON_HEADPHONES
Definition: chan_unistim.c:164
struct unistim_device * device
Definition: chan_unistim.c:496
#define MUTE_OFF
Definition: chan_unistim.c:135
#define VOLUME_LOW_SPEAKER
Definition: chan_unistim.c:131
#define OUTPUT_HEADPHONE
Definition: chan_unistim.c:127
#define OUTPUT_HANDSET
Definition: chan_unistim.c:126
#define SIZE_HEADER
Definition: chan_unistim.c:139
#define FAV_ICON_SPEAKER_ONHOLD_BLACK
Definition: chan_unistim.c:162
#define FAV_ICON_SPEAKER_ONHOOK_BLACK
Definition: chan_unistim.c:152
#define FAV_ICON_SPEAKER_OFFHOOK_BLACK
Definition: chan_unistim.c:158
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
static void send_led_update(struct unistimsession *pte, unsigned char led)
#define MUTE_ON
Definition: chan_unistim.c:136
#define MUTE_ON_DISCRET
Definition: chan_unistim.c:137
#define OUTPUT_SPEAKER
Definition: chan_unistim.c:128
#define FAV_ICON_OFFHOOK_BLACK
Definition: chan_unistim.c:154
static void send_start_timer ( struct unistimsession pte)
static

Definition at line 954 of file chan_unistim.c.

References ast_verb, BUFFSEND, send_client(), and SIZE_HEADER.

Referenced by HandleCallIncoming(), and unistim_answer().

955 {
956  BUFFSEND;
957  if (unistimdebug)
958  ast_verb(0, "Sending start timer\n");
959  memcpy(buffsend + SIZE_HEADER, packet_send_StartTimer, sizeof(packet_send_StartTimer));
960  send_client(SIZE_HEADER + sizeof(packet_send_StartTimer), buffsend, pte);
961 }
static const unsigned char packet_send_StartTimer[]
Definition: chan_unistim.c:631
static void send_client(int size, const unsigned char *data, struct unistimsession *pte)
Definition: chan_unistim.c:801
#define BUFFSEND
Definition: chan_unistim.c:675
#define ast_verb(level,...)
Definition: logger.h:243
static int unistimdebug
Definition: chan_unistim.c:211
#define SIZE_HEADER
Definition: chan_unistim.c:139
static void send_stop_timer ( struct unistimsession pte)
static

Definition at line 963 of file chan_unistim.c.

References ast_verb, BUFFSEND, send_client(), and SIZE_HEADER.

Referenced by close_call().

964 {
965  BUFFSEND;
966  if (unistimdebug)
967  ast_verb(0, "Sending stop timer\n");
968  memcpy(buffsend + SIZE_HEADER, packet_send_stop_timer, sizeof(packet_send_stop_timer));
969  send_client(SIZE_HEADER + sizeof(packet_send_stop_timer), buffsend, pte);
970 }
static void send_client(int size, const unsigned char *data, struct unistimsession *pte)
Definition: chan_unistim.c:801
#define BUFFSEND
Definition: chan_unistim.c:675
#define ast_verb(level,...)
Definition: logger.h:243
static int unistimdebug
Definition: chan_unistim.c:211
static const unsigned char packet_send_stop_timer[]
Definition: chan_unistim.c:634
#define SIZE_HEADER
Definition: chan_unistim.c:139
static void send_text ( unsigned char  pos,
unsigned char  inverse,
struct unistimsession pte,
const char *  text 
)
static

Definition at line 1210 of file chan_unistim.c.

References ast_verb, BUFFSEND, send_client(), SIZE_HEADER, and TEXT_LENGTH_MAX.

Referenced by handle_dial_page(), HandleCallIncoming(), HandleCallOutgoing(), HandleSelectCodec(), init_phone_step2(), key_dial_page(), key_select_codec(), key_select_extension(), show_entry_history(), show_main_page(), ShowExtensionPage(), unistim_answer(), unistim_call(), unistim_hangup(), unistim_indicate(), and unistim_sendtext().

1212 {
1213  int i;
1214  BUFFSEND;
1215  if (unistimdebug)
1216  ast_verb(0, "Sending text at pos %d, inverse flag %d\n", pos, inverse);
1217  memcpy(buffsend + SIZE_HEADER, packet_send_text, sizeof(packet_send_text));
1218  buffsend[10] = pos;
1219  buffsend[11] = inverse;
1220  i = strlen(text);
1221  if (i > TEXT_LENGTH_MAX)
1222  i = TEXT_LENGTH_MAX;
1223  memcpy(buffsend + 12, text, i);
1224  send_client(SIZE_HEADER + sizeof(packet_send_text), buffsend, pte);
1225 }
static void send_client(int size, const unsigned char *data, struct unistimsession *pte)
Definition: chan_unistim.c:801
#define BUFFSEND
Definition: chan_unistim.c:675
char * text
Definition: app_queue.c:1091
#define ast_verb(level,...)
Definition: logger.h:243
#define TEXT_LENGTH_MAX
Definition: chan_unistim.c:141
static int unistimdebug
Definition: chan_unistim.c:211
#define SIZE_HEADER
Definition: chan_unistim.c:139
static const unsigned char packet_send_text[]
Definition: chan_unistim.c:650
static void send_text_status ( struct unistimsession pte,
const char *  text 
)
static

Definition at line 1227 of file chan_unistim.c.

References ast_verb, BUFFSEND, unistimsession::device, send_client(), SIZE_HEADER, STATUS_LENGTH_MAX, and unistim_device::status_method.

Referenced by handle_dial_page(), HandleCallIncoming(), HandleCallOutgoing(), HandleSelectCodec(), init_phone_step2(), key_dial_page(), show_entry_history(), show_main_page(), ShowExtensionPage(), unistim_answer(), unistim_call(), and unistim_hangup().

1228 {
1229  BUFFSEND;
1230  int i;
1231  if (unistimdebug)
1232  ast_verb(0, "Sending status text\n");
1233  if (pte->device) {
1234  if (pte->device->status_method == 1) { /* For new firmware and i2050 soft phone */
1235  int n = strlen(text);
1236  /* Must send individual button separately */
1237  int j;
1238  for (i = 0, j = 0; i < 4; i++, j += 7) {
1239  int pos = 0x08 + (i * 0x20);
1240  memcpy(buffsend + SIZE_HEADER, packet_send_status2,
1241  sizeof(packet_send_status2));
1242 
1243  buffsend[9] = pos;
1244  memcpy(buffsend + 10, (j < n) ? (text + j) : " ", 7);
1245  send_client(SIZE_HEADER + sizeof(packet_send_status2), buffsend, pte);
1246  }
1247  return;
1248  }
1249  }
1250 
1251 
1252  memcpy(buffsend + SIZE_HEADER, packet_send_status, sizeof(packet_send_status));
1253  i = strlen(text);
1254  if (i > STATUS_LENGTH_MAX)
1255  i = STATUS_LENGTH_MAX;
1256  memcpy(buffsend + 10, text, i);
1257  send_client(SIZE_HEADER + sizeof(packet_send_status), buffsend, pte);
1258 
1259 }
static void send_client(int size, const unsigned char *data, struct unistimsession *pte)
Definition: chan_unistim.c:801
#define BUFFSEND
Definition: chan_unistim.c:675
char * text
Definition: app_queue.c:1091
#define ast_verb(level,...)
Definition: logger.h:243
static int unistimdebug
Definition: chan_unistim.c:211
#define STATUS_LENGTH_MAX
Definition: chan_unistim.c:147
struct unistim_device * device
Definition: chan_unistim.c:496
#define SIZE_HEADER
Definition: chan_unistim.c:139
static const unsigned char packet_send_status2[]
Definition: chan_unistim.c:661
static const unsigned char packet_send_status[]
Definition: chan_unistim.c:656
static void send_texttitle ( struct unistimsession pte,
const char *  text 
)
static

Definition at line 1359 of file chan_unistim.c.

References ast_verb, BUFFSEND, send_client(), and SIZE_HEADER.

Referenced by init_phone_step2(), show_entry_history(), and show_main_page().

1360 {
1361  BUFFSEND;
1362  int i;
1363  if (unistimdebug)
1364  ast_verb(0, "Sending title text\n");
1365  memcpy(buffsend + SIZE_HEADER, packet_send_title, sizeof(packet_send_title));
1366  i = strlen(text);
1367  if (i > 12)
1368  i = 12;
1369  memcpy(buffsend + 10, text, i);
1370  send_client(SIZE_HEADER + sizeof(packet_send_title), buffsend, pte);
1371 
1372 }
static void send_client(int size, const unsigned char *data, struct unistimsession *pte)
Definition: chan_unistim.c:801
#define BUFFSEND
Definition: chan_unistim.c:675
char * text
Definition: app_queue.c:1091
#define ast_verb(level,...)
Definition: logger.h:243
static int unistimdebug
Definition: chan_unistim.c:211
#define SIZE_HEADER
Definition: chan_unistim.c:139
static const unsigned char packet_send_title[]
Definition: chan_unistim.c:647
static void send_tone ( struct unistimsession pte,
uint16_t  tone1,
uint16_t  tone2 
)
static

Definition at line 983 of file chan_unistim.c.

References ast_verb, BUFFSEND, send_client(), and SIZE_HEADER.

Referenced by HandleCallOutgoing(), key_dial_page(), SendDialTone(), show_main_page(), unistim_do_senddigit(), unistim_senddigit_end(), and unistim_ss().

984 {
985  BUFFSEND;
986  if (!tone1) {
987  if (unistimdebug)
988  ast_verb(0, "Sending Stream Based Tone Off\n");
992  return;
993  }
994  /* Since most of the world use a continuous tone, it's useless
995  if (unistimdebug)
996  ast_verb(0, "Sending Stream Based Tone Cadence Download\n");
997  memcpy (buffsend + SIZE_HEADER, packet_send_StreamBasedToneCad, sizeof (packet_send_StreamBasedToneCad));
998  send_client (SIZE_HEADER + sizeof (packet_send_StreamBasedToneCad), buffsend, pte); */
999  if (unistimdebug)
1000  ast_verb(0, "Sending Stream Based Tone Frequency Component List Download %d %d\n", tone1, tone2);
1001  tone1 *= 8;
1002  if (!tone2) {
1005  buffsend[10] = (tone1 & 0xff00) >> 8;
1006  buffsend[11] = (tone1 & 0x00ff);
1008  pte);
1009  } else {
1010  tone2 *= 8;
1013  buffsend[10] = (tone1 & 0xff00) >> 8;
1014  buffsend[11] = (tone1 & 0x00ff);
1015  buffsend[12] = (tone2 & 0xff00) >> 8;
1016  buffsend[13] = (tone2 & 0x00ff);
1018  pte);
1019  }
1020 
1021  if (unistimdebug)
1022  ast_verb(0, "Sending Stream Based Tone On\n");
1023  memcpy(buffsend + SIZE_HEADER, packet_send_stream_based_tone_on,
1025  send_client(SIZE_HEADER + sizeof(packet_send_stream_based_tone_on), buffsend, pte);
1026 }
static void send_client(int size, const unsigned char *data, struct unistimsession *pte)
Definition: chan_unistim.c:801
static const unsigned char packet_send_stream_based_tone_off[]
Definition: chan_unistim.c:561
static const unsigned char packet_send_stream_based_tone_single_freq[]
Definition: chan_unistim.c:569
#define BUFFSEND
Definition: chan_unistim.c:675
static const unsigned char packet_send_stream_based_tone_on[]
Definition: chan_unistim.c:567
#define ast_verb(level,...)
Definition: logger.h:243
static int unistimdebug
Definition: chan_unistim.c:211
#define SIZE_HEADER
Definition: chan_unistim.c:139
static const unsigned char packet_send_stream_based_tone_dial_freq[]
Definition: chan_unistim.c:571
static void SendDialTone ( struct unistimsession pte)
static

Definition at line 2228 of file chan_unistim.c.

References ast_strlen_zero(), ast_verb, country, tone_zone_unistim::country, unistim_device::country, unistimsession::device, and send_tone().

Referenced by handle_dial_page().

2229 {
2230  int i;
2231  /* No country defined ? Using US tone */
2232  if (ast_strlen_zero(pte->device->country)) {
2233  if (unistimdebug)
2234  ast_verb(0, "No country defined, using US tone\n");
2235  send_tone(pte, 350, 440);
2236  return;
2237  }
2238  if (strlen(pte->device->country) != 2) {
2239  if (unistimdebug)
2240  ast_verb(0, "Country code != 2 char, using US tone\n");
2241  send_tone(pte, 350, 440);
2242  return;
2243  }
2244  i = 0;
2245  while (frequency[i].freq1) {
2246  if ((frequency[i].country[0] == pte->device->country[0]) &&
2247  (frequency[i].country[1] == pte->device->country[1])) {
2248  if (unistimdebug)
2249  ast_verb(0, "Country code found (%s), freq1=%d freq2=%d\n",
2250  frequency[i].country, frequency[i].freq1, frequency[i].freq2);
2251  send_tone(pte, frequency[i].freq1, frequency[i].freq2);
2252  }
2253  i++;
2254  }
2255 }
static struct tone_zone_unistim frequency[]
Definition: chan_unistim.c:316
#define ast_verb(level,...)
Definition: logger.h:243
static int unistimdebug
Definition: chan_unistim.c:211
struct unistim_device * device
Definition: chan_unistim.c:496
static void send_tone(struct unistimsession *pte, uint16_t tone1, uint16_t tone2)
Definition: chan_unistim.c:983
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition: strings.h:63
static char country[80]
Definition: pbx_dundi.c:196
static void Sendicon ( unsigned char  pos,
unsigned char  status,
struct unistimsession pte 
)
static

Definition at line 972 of file chan_unistim.c.

References ast_verb, BUFFSEND, send_client(), SIZE_HEADER, and status.

Referenced by handle_dial_page(), key_main_page(), show_main_page(), and unistim_call().

973 {
974  BUFFSEND;
975  if (unistimdebug)
976  ast_verb(0, "Sending icon pos %d with status 0x%.2x\n", pos, (unsigned)status);
977  memcpy(buffsend + SIZE_HEADER, packet_send_icon, sizeof(packet_send_icon));
978  buffsend[9] = pos;
979  buffsend[10] = status;
980  send_client(SIZE_HEADER + sizeof(packet_send_icon), buffsend, pte);
981 }
static const unsigned char packet_send_icon[]
Definition: chan_unistim.c:635
static void send_client(int size, const unsigned char *data, struct unistimsession *pte)
Definition: chan_unistim.c:801
#define BUFFSEND
Definition: chan_unistim.c:675
#define ast_verb(level,...)
Definition: logger.h:243
static int unistimdebug
Definition: chan_unistim.c:211
#define SIZE_HEADER
Definition: chan_unistim.c:139
jack_status_t status
Definition: app_jack.c:143
static void set_ping_timer ( struct unistimsession pte)
static

Definition at line 920 of file chan_unistim.c.

References DEBUG_TIMER, unistimsession::tick_next_ping, and unistimsession::timeout.

Referenced by check_send_queue().

921 {
922  unsigned int tick = 0; /* XXX what is this for, anyways */
923 
924  pte->timeout = pte->tick_next_ping;
925  DEBUG_TIMER("tick = %u next ping at %u tick\n", tick, pte->timeout);
926  return;
927 }
#define DEBUG_TIMER
Definition: chan_unistim.c:209
unsigned long tick_next_ping
Definition: chan_unistim.c:487
static void show_entry_history ( struct unistimsession pte,
FILE **  f 
)
static

Definition at line 3026 of file chan_unistim.c.

References ast_copy_string(), unistimsession::buff_entry, unistimsession::device, display_last_error(), unistim_device::lst_cid, ReformatNumber(), send_text(), send_text_status(), send_texttitle(), status, STATUS_LENGTH_MAX, TEXT_LENGTH_MAX, TEXT_LINE0, TEXT_LINE1, TEXT_LINE2, and TEXT_NORMAL.

Referenced by key_history(), and show_history().

3027 {
3028  char line[TEXT_LENGTH_MAX + 1], status[STATUS_LENGTH_MAX + 1], func1[10], func2[10],
3029  func3[10];
3030 
3031  if (fread(line, TEXT_LENGTH_MAX, 1, *f) != 1) {
3032  display_last_error("Can't read history date entry");
3033  fclose(*f);
3034  return;
3035  }
3036  line[sizeof(line) - 1] = '\0';
3037  send_text(TEXT_LINE0, TEXT_NORMAL, pte, line);
3038  if (fread(line, TEXT_LENGTH_MAX, 1, *f) != 1) {
3039  display_last_error("Can't read callerid entry");
3040  fclose(*f);
3041  return;
3042  }
3043  line[sizeof(line) - 1] = '\0';
3044  ast_copy_string(pte->device->lst_cid, line, sizeof(pte->device->lst_cid));
3045  send_text(TEXT_LINE1, TEXT_NORMAL, pte, line);
3046  if (fread(line, TEXT_LENGTH_MAX, 1, *f) != 1) {
3047  display_last_error("Can't read callername entry");
3048  fclose(*f);
3049  return;
3050  }
3051  line[sizeof(line) - 1] = '\0';
3052  send_text(TEXT_LINE2, TEXT_NORMAL, pte, line);
3053  fclose(*f);
3054 
3055  snprintf(line, sizeof(line), "Call %03d/%03d", pte->buff_entry[2],
3056  pte->buff_entry[1]);
3057  send_texttitle(pte, line);
3058 
3059  if (pte->buff_entry[2] == 1)
3060  strcpy(func1, " ");
3061  else
3062  strcpy(func1, "Prvious");
3063  if (pte->buff_entry[2] >= pte->buff_entry[1])
3064  strcpy(func2, " ");
3065  else
3066  strcpy(func2, "Next ");
3067  if (ReformatNumber(pte->device->lst_cid))
3068  strcpy(func3, "Redial ");
3069  else
3070  strcpy(func3, " ");
3071  snprintf(status, sizeof(status), "%s%s%sCancel", func1, func2, func3);
3072  send_text_status(pte, status);
3073 }
#define TEXT_LINE2
Definition: chan_unistim.c:144
#define TEXT_LINE1
Definition: chan_unistim.c:143
#define TEXT_NORMAL
Definition: chan_unistim.c:145
#define TEXT_LENGTH_MAX
Definition: chan_unistim.c:141
#define STATUS_LENGTH_MAX
Definition: chan_unistim.c:147
struct unistim_device * device
Definition: chan_unistim.c:496
static void send_texttitle(struct unistimsession *pte, const char *text)
#define TEXT_LINE0
Definition: chan_unistim.c:142
static int ReformatNumber(char *number)
static void send_text_status(struct unistimsession *pte, const char *text)
static struct ast_format f[]
Definition: format_g726.c:181
char lst_cid[TEXT_LENGTH_MAX]
Definition: chan_unistim.c:459
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:223
char buff_entry[16]
Definition: chan_unistim.c:492
static void display_last_error(const char *sz_msg)
Definition: chan_unistim.c:725
jack_status_t status
Definition: app_jack.c:143
static void show_history ( struct unistimsession pte,
char  way 
)
static

Definition at line 3101 of file chan_unistim.c.

References unistimsession::buff_entry, unistim_device::callhistory, unistimsession::device, f, OpenHistory(), show_entry_history(), unistimsession::state, and STATE_HISTORY.

Referenced by key_history(), and key_main_page().

3102 {
3103  FILE *f;
3104  char count;
3105 
3106  if (!pte->device)
3107  return;
3108  if (!pte->device->callhistory)
3109  return;
3110  count = OpenHistory(pte, way, &f);
3111  if (!count)
3112  return;
3113  pte->buff_entry[0] = way;
3114  pte->buff_entry[1] = count;
3115  pte->buff_entry[2] = 1;
3116  show_entry_history(pte, &f);
3117  pte->state = STATE_HISTORY;
3118 }
static char OpenHistory(struct unistimsession *pte, char way, FILE **f)
struct unistim_device * device
Definition: chan_unistim.c:496
static struct ast_format f[]
Definition: format_g726.c:181
char buff_entry[16]
Definition: chan_unistim.c:492
static void show_entry_history(struct unistimsession *pte, FILE **f)
static void show_main_page ( struct unistimsession pte)
static

Definition at line 3120 of file chan_unistim.c.

References ast_inet_ntoa(), ast_strlen_zero(), unistim_device::call_forward, change_favorite_icon(), unistimsession::device, unistim_device::extension, EXTENSION_ASK, unistim_device::extension_number, EXTENSION_TN, FAV_BLINK_SLOW, FAV_ICON_CALL_CENTER, FAV_ICON_ONHOOK_BLACK, FAV_ICON_REFLECT, unistim_device::height, unistim_line::lastmsgssent, unistim_device::lines, unistim_device::maintext0, unistim_device::maintext1, unistim_device::maintext2, unistim_device::missed_call, MUTE_ON_DISCRET, unistim_device::output, send_favorite(), send_select_output(), send_text(), send_text_status(), send_texttitle(), send_tone(), Sendicon(), ShowExtensionPage(), unistimsession::sin, unistim_device::softkeylabel, unistim_device::softkeylinepos, unistimsession::state, STATE_MAINPAGE, TEXT_LENGTH_MAX, TEXT_LINE0, TEXT_LINE1, TEXT_LINE2, TEXT_NORMAL, unistim_device::titledefault, and unistim_device::volume.

Referenced by cancel_dial(), close_call(), init_phone_step2(), key_dial_page(), key_history(), key_main_page(), key_select_codec(), key_select_extension(), and process_request().

3121 {
3122  char tmpbuf[TEXT_LENGTH_MAX + 1];
3123 
3124 
3125  if ((pte->device->extension == EXTENSION_ASK) &&
3127  ShowExtensionPage(pte);
3128  return;
3129  }
3130 
3131  pte->state = STATE_MAINPAGE;
3132 
3133  send_tone(pte, 0, 0);
3135  pte->device->lines->lastmsgssent = 0;
3137  pte->device->softkeylabel[pte->device->softkeylinepos]);
3138  if (!ast_strlen_zero(pte->device->call_forward)) {
3139  if (pte->device->height == 1) {
3140  send_text(TEXT_LINE0, TEXT_NORMAL, pte, "Forwarding ON");
3141  } else {
3142  send_text(TEXT_LINE0, TEXT_NORMAL, pte, "Call forwarded to :");
3144  }
3146  send_text_status(pte, "Dial Redial NoForwd");
3147  } else {
3148  if ((pte->device->extension == EXTENSION_ASK) ||
3149  (pte->device->extension == EXTENSION_TN))
3150  send_text_status(pte, "Dial Redial ForwardUnregis");
3151  else
3152  send_text_status(pte, "Dial Redial Forward");
3153 
3155  if (pte->device->missed_call == 0)
3157  else {
3158  sprintf(tmpbuf, "%d unanswered call(s)", pte->device->missed_call);
3159  send_text(TEXT_LINE0, TEXT_NORMAL, pte, tmpbuf);
3161  }
3162  }
3163  if (ast_strlen_zero(pte->device->maintext2)) {
3164  strcpy(tmpbuf, "IP : ");
3165  strcat(tmpbuf, ast_inet_ntoa(pte->sin.sin_addr));
3166  send_text(TEXT_LINE2, TEXT_NORMAL, pte, tmpbuf);
3167  } else
3169  send_texttitle(pte, pte->device->titledefault);
3171 }
char call_forward[AST_MAX_EXTENSION]
Definition: chan_unistim.c:461
#define TEXT_LINE2
Definition: chan_unistim.c:144
#define TEXT_LINE1
Definition: chan_unistim.c:143
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:145
#define FAV_ICON_ONHOOK_BLACK
Definition: chan_unistim.c:150
#define TEXT_LENGTH_MAX
Definition: chan_unistim.c:141
struct unistim_device * device
Definition: chan_unistim.c:496
static void send_texttitle(struct unistimsession *pte, const char *text)
char titledefault[13]
Definition: chan_unistim.c:446
static void send_tone(struct unistimsession *pte, uint16_t tone1, uint16_t tone2)
Definition: chan_unistim.c:983
#define FAV_BLINK_SLOW
Definition: chan_unistim.c:184
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition: strings.h:63
char softkeylabel[6][11]
Definition: chan_unistim.c:437
#define TEXT_LINE0
Definition: chan_unistim.c:142
char maintext0[25]
Definition: chan_unistim.c:443
enum autoprov_extn extension
Definition: chan_unistim.c:468
static void send_favorite(unsigned char pos, unsigned char status, struct unistimsession *pte, const char *text)
static void ShowExtensionPage(struct unistimsession *pte)
static void send_text_status(struct unistimsession *pte, const char *text)
#define FAV_ICON_CALL_CENTER
Definition: chan_unistim.c:170
struct unistim_line * lines
Definition: chan_unistim.c:473
const char * ast_inet_ntoa(struct in_addr ia)
thread-safe replacement for inet_ntoa().
Definition: utils.c:564
struct sockaddr_in sin
Definition: chan_unistim.c:481
static void send_text(unsigned char pos, unsigned char inverse, struct unistimsession *pte, const char *text)
#define MUTE_ON_DISCRET
Definition: chan_unistim.c:137
char maintext1[25]
Definition: chan_unistim.c:444
#define FAV_ICON_REFLECT
Definition: chan_unistim.c:173
char extension_number[11]
Definition: chan_unistim.c:469
char maintext2[25]
Definition: chan_unistim.c:445
static void Sendicon(unsigned char pos, unsigned char status, struct unistimsession *pte)
Definition: chan_unistim.c:972
static void ShowExtensionPage ( struct unistimsession pte)
static

Definition at line 2896 of file chan_unistim.c.

References SELECTEXTENSION_MSG, SELECTEXTENSION_START_ENTRY_POS, send_blink_cursor(), send_cursor_pos(), send_text(), send_text_status(), unistimsession::size_buff_entry, unistimsession::state, STATE_EXTENSION, TEXT_LINE0, TEXT_LINE1, TEXT_LINE2, and TEXT_NORMAL.

Referenced by init_phone_step2(), key_main_page(), and show_main_page().

2897 {
2898  pte->state = STATE_EXTENSION;
2899 
2900  send_text(TEXT_LINE0, TEXT_NORMAL, pte, "Please enter a Terminal");
2901  send_text(TEXT_LINE1, TEXT_NORMAL, pte, "Number (TN) :");
2903  send_blink_cursor(pte);
2905  send_text_status(pte, "Enter BackSpcErase");
2906  pte->size_buff_entry = 0;
2907  return;
2908 }
#define SELECTEXTENSION_START_ENTRY_POS
#define TEXT_LINE2
Definition: chan_unistim.c:144
#define TEXT_LINE1
Definition: chan_unistim.c:143
#define TEXT_NORMAL
Definition: chan_unistim.c:145
static void send_blink_cursor(struct unistimsession *pte)
#define TEXT_LINE0
Definition: chan_unistim.c:142
static void send_text_status(struct unistimsession *pte, const char *text)
static void send_text(unsigned char pos, unsigned char inverse, struct unistimsession *pte, const char *text)
static void send_cursor_pos(struct unistimsession *pte, unsigned char pos)
#define SELECTEXTENSION_MSG
static void start_rtp ( struct unistim_subchannel sub)
static

Definition at line 2024 of file chan_unistim.c.

References ast_best_codec(), AST_FORMAT_ALAW, AST_FORMAT_G723_1, AST_FORMAT_G729A, AST_FORMAT_ULAW, ast_getformatname(), ast_getformatname_multiple(), ast_inet_ntoa(), ast_log(), ast_mutex_lock, ast_mutex_unlock, ast_rtp_codecs_payload_code(), ast_rtp_instance_fd(), ast_rtp_instance_get_codecs(), ast_rtp_instance_get_local_address(), ast_rtp_instance_new(), ast_rtp_instance_set_prop(), ast_rtp_instance_set_qos(), ast_rtp_instance_set_remote_address(), AST_RTP_PROPERTY_NAT, AST_RTP_PROPERTY_RTCP, ast_sockaddr_from_sin, ast_sockaddr_to_sin, ast_verb, BUFFSEND, errno, ast_channel::fds, unistim_subchannel::lock, LOG_WARNING, unistim_device::nat, ast_channel::nativeformats, unistim_subchannel::owner, unistim_subchannel::parent, unistim_line::parent, qos, ast_channel::readformat, unistim_subchannel::rtp, unistim_device::rtp_method, unistim_device::rtp_port, send_client(), unistim_device::session, unistimsession::sin, SIZE_HEADER, unistimsession::sout, and ast_channel::writeformat.

Referenced by HandleCallIncoming(), HandleCallOutgoing(), and unistim_answer().

2025 {
2026  BUFFSEND;
2027  struct sockaddr_in us = { 0, };
2028  struct sockaddr_in public = { 0, };
2029  struct sockaddr_in sin = { 0, };
2030  format_t codec;
2031  struct sockaddr_in sout = { 0, };
2032  struct ast_sockaddr us_tmp;
2033  struct ast_sockaddr sin_tmp;
2034  struct ast_sockaddr sout_tmp;
2035 
2036  /* Sanity checks */
2037  if (!sub) {
2038  ast_log(LOG_WARNING, "start_rtp with a null subchannel !\n");
2039  return;
2040  }
2041  if (!sub->parent) {
2042  ast_log(LOG_WARNING, "start_rtp with a null line !\n");
2043  return;
2044  }
2045  if (!sub->parent->parent) {
2046  ast_log(LOG_WARNING, "start_rtp with a null device !\n");
2047  return;
2048  }
2049  if (!sub->parent->parent->session) {
2050  ast_log(LOG_WARNING, "start_rtp with a null session !\n");
2051  return;
2052  }
2053  sout = sub->parent->parent->session->sout;
2054 
2055  ast_mutex_lock(&sub->lock);
2056  /* Allocate the RTP */
2057  if (unistimdebug)
2058  ast_verb(0, "Starting RTP. Bind on %s\n", ast_inet_ntoa(sout.sin_addr));
2059  ast_sockaddr_from_sin(&sout_tmp, &sout);
2060  sub->rtp = ast_rtp_instance_new("asterisk", sched, &sout_tmp, NULL);
2061  if (!sub->rtp) {
2062  ast_log(LOG_WARNING, "Unable to create RTP session: %s binaddr=%s\n",
2063  strerror(errno), ast_inet_ntoa(sout.sin_addr));
2064  ast_mutex_unlock(&sub->lock);
2065  return;
2066  }
2068  if (sub->owner) {
2069  sub->owner->fds[0] = ast_rtp_instance_fd(sub->rtp, 0);
2070  sub->owner->fds[1] = ast_rtp_instance_fd(sub->rtp, 1);
2071  }
2072  ast_rtp_instance_set_qos(sub->rtp, qos.tos_audio, qos.cos_audio, "UNISTIM RTP");
2074 
2075  /* Create the RTP connection */
2076  ast_rtp_instance_get_local_address(sub->rtp, &us_tmp);
2077  ast_sockaddr_to_sin(&us_tmp, &us);
2078  sin.sin_family = AF_INET;
2079  /* Setting up RTP for our side */
2080  memcpy(&sin.sin_addr, &sub->parent->parent->session->sin.sin_addr,
2081  sizeof(sin.sin_addr));
2082  sin.sin_port = htons(sub->parent->parent->rtp_port);
2083  ast_sockaddr_from_sin(&sin_tmp, &sin);
2084  ast_rtp_instance_set_remote_address(sub->rtp, &sin_tmp);
2085  if (!(sub->owner->nativeformats & sub->owner->readformat)) {
2086  format_t fmt;
2087  char tmp[256];
2088  fmt = ast_best_codec(sub->owner->nativeformats);
2090  "Our read/writeformat has been changed to something incompatible: %s, using %s best codec from %s\n",
2092  ast_getformatname(fmt),
2093  ast_getformatname_multiple(tmp, sizeof(tmp), sub->owner->nativeformats));
2094  sub->owner->readformat = fmt;
2095  sub->owner->writeformat = fmt;
2096  }
2098  /* Setting up RTP of the phone */
2099  if (public_ip.sin_family == 0) /* NAT IP override ? */
2100  memcpy(&public, &us, sizeof(public)); /* No defined, using IP from recvmsg */
2101  else
2102  memcpy(&public, &public_ip, sizeof(public)); /* override */
2103  if (unistimdebug) {
2104  ast_verb(0, "RTP started : Our IP/port is : %s:%hd with codec %s\n",
2105  ast_inet_ntoa(us.sin_addr),
2106  htons(us.sin_port), ast_getformatname(sub->owner->readformat));
2107  ast_verb(0, "Starting phone RTP stack. Our public IP is %s\n",
2108  ast_inet_ntoa(public.sin_addr));
2109  }
2110  if ((sub->owner->readformat == AST_FORMAT_ULAW) ||
2111  (sub->owner->readformat == AST_FORMAT_ALAW)) {
2112  if (unistimdebug)
2113  ast_verb(0, "Sending packet_send_rtp_packet_size for codec %s\n", ast_getformatname(codec));
2114  memcpy(buffsend + SIZE_HEADER, packet_send_rtp_packet_size,
2115  sizeof(packet_send_rtp_packet_size));
2116  buffsend[10] = (int) codec & 0xffffffffLL;
2118  sub->parent->parent->session);
2119  }
2120  if (unistimdebug)
2121  ast_verb(0, "Sending Jitter Buffer Parameters Configuration\n");
2122  memcpy(buffsend + SIZE_HEADER, packet_send_jitter_buffer_conf,
2125  sub->parent->parent->session);
2126  if (sub->parent->parent->rtp_method != 0) {
2127  uint16_t rtcpsin_port = htons(us.sin_port) + 1; /* RTCP port is RTP + 1 */
2128 
2129  if (unistimdebug)
2130  ast_verb(0, "Sending OpenAudioStreamTX using method #%d\n",
2131  sub->parent->parent->rtp_method);
2132  if (sub->parent->parent->rtp_method == 3)
2135  else
2136  memcpy(buffsend + SIZE_HEADER, packet_send_open_audio_stream_tx,
2138  if (sub->parent->parent->rtp_method != 2) {
2139  memcpy(buffsend + 28, &public.sin_addr, sizeof(public.sin_addr));
2140  buffsend[20] = (htons(sin.sin_port) & 0xff00) >> 8;
2141  buffsend[21] = (htons(sin.sin_port) & 0x00ff);
2142  buffsend[23] = (rtcpsin_port & 0x00ff);
2143  buffsend[22] = (rtcpsin_port & 0xff00) >> 8;
2144  buffsend[25] = (us.sin_port & 0xff00) >> 8;
2145  buffsend[24] = (us.sin_port & 0x00ff);
2146  buffsend[27] = (rtcpsin_port & 0x00ff);
2147  buffsend[26] = (rtcpsin_port & 0xff00) >> 8;
2148  } else {
2149  memcpy(buffsend + 23, &public.sin_addr, sizeof(public.sin_addr));
2150  buffsend[15] = (htons(sin.sin_port) & 0xff00) >> 8;
2151  buffsend[16] = (htons(sin.sin_port) & 0x00ff);
2152  buffsend[20] = (us.sin_port & 0xff00) >> 8;
2153  buffsend[19] = (us.sin_port & 0x00ff);
2154  }
2155  buffsend[11] = codec; /* rx */
2156  buffsend[12] = codec; /* tx */
2158  sub->parent->parent->session);
2159 
2160  if (unistimdebug)
2161  ast_verb(0, "Sending OpenAudioStreamRX\n");
2162  if (sub->parent->parent->rtp_method == 3)
2165  else
2166  memcpy(buffsend + SIZE_HEADER, packet_send_open_audio_stream_rx,
2168  if (sub->parent->parent->rtp_method != 2) {
2169  memcpy(buffsend + 28, &public.sin_addr, sizeof(public.sin_addr));
2170  buffsend[20] = (htons(sin.sin_port) & 0xff00) >> 8;
2171  buffsend[21] = (htons(sin.sin_port) & 0x00ff);
2172  buffsend[23] = (rtcpsin_port & 0x00ff);
2173  buffsend[22] = (rtcpsin_port & 0xff00) >> 8;
2174  buffsend[25] = (us.sin_port & 0xff00) >> 8;
2175  buffsend[24] = (us.sin_port & 0x00ff);
2176  buffsend[27] = (rtcpsin_port & 0x00ff);
2177  buffsend[26] = (rtcpsin_port & 0xff00) >> 8;
2178  } else {
2179  memcpy(buffsend + 23, &public.sin_addr, sizeof(public.sin_addr));
2180  buffsend[15] = (htons(sin.sin_port) & 0xff00) >> 8;
2181  buffsend[16] = (htons(sin.sin_port) & 0x00ff);
2182  buffsend[20] = (us.sin_port & 0xff00) >> 8;
2183  buffsend[19] = (us.sin_port & 0x00ff);
2184  }
2185  buffsend[11] = codec; /* rx */
2186  buffsend[12] = codec; /* tx */
2188  sub->parent->parent->session);
2189  } else {
2190  uint16_t rtcpsin_port = htons(us.sin_port) + 1; /* RTCP port is RTP + 1 */
2191 
2192  if (unistimdebug)
2193  ast_verb(0, "Sending packet_send_call default method\n");
2194 
2195  memcpy(buffsend + SIZE_HEADER, packet_send_call, sizeof(packet_send_call));
2196  memcpy(buffsend + 53, &public.sin_addr, sizeof(public.sin_addr));
2197  /* Destination port when sending RTP */
2198  buffsend[49] = (us.sin_port & 0x00ff);
2199  buffsend[50] = (us.sin_port & 0xff00) >> 8;
2200  /* Destination port when sending RTCP */
2201  buffsend[52] = (rtcpsin_port & 0x00ff);
2202  buffsend[51] = (rtcpsin_port & 0xff00) >> 8;
2203  /* Codec */
2204  buffsend[40] = codec;
2205  buffsend[41] = codec;
2206  if (sub->owner->readformat == AST_FORMAT_ULAW)
2207  buffsend[42] = 1; /* 1 = 20ms (160 bytes), 2 = 40ms (320 bytes) */
2208  else if (sub->owner->readformat == AST_FORMAT_ALAW)
2209  buffsend[42] = 1; /* 1 = 20ms (160 bytes), 2 = 40ms (320 bytes) */
2210  else if (sub->owner->readformat == AST_FORMAT_G723_1)
2211  buffsend[42] = 2; /* 1 = 30ms (24 bytes), 2 = 60 ms (48 bytes) */
2212  else if (sub->owner->readformat == AST_FORMAT_G729A)
2213  buffsend[42] = 2; /* 1 = 10ms (10 bytes), 2 = 20ms (20 bytes) */
2214  else
2215  ast_log(LOG_WARNING, "Unsupported codec %s!\n",
2217  /* Source port for transmit RTP and Destination port for receiving RTP */
2218  buffsend[45] = (htons(sin.sin_port) & 0xff00) >> 8;
2219  buffsend[46] = (htons(sin.sin_port) & 0x00ff);
2220  buffsend[47] = (rtcpsin_port & 0xff00) >> 8;
2221  buffsend[48] = (rtcpsin_port & 0x00ff);
2222  send_client(SIZE_HEADER + sizeof(packet_send_call), buffsend,
2223  sub->parent->parent->session);
2224  }
2225  ast_mutex_unlock(&sub->lock);
2226 }
ast_mutex_t lock
Definition: chan_unistim.c:367
struct ast_channel * owner
Definition: chan_unistim.c:371
struct sockaddr_in sout
Definition: chan_unistim.c:482
static void send_client(int size, const unsigned char *data, struct unistimsession *pte)
Definition: chan_unistim.c:801
static struct @114 qos
format_t writeformat
Definition: channel.h:854
struct ast_rtp_instance * rtp
Definition: chan_unistim.c:375
#define AST_FORMAT_G723_1
Definition: frame.h:242
struct ast_rtp_codecs * ast_rtp_instance_get_codecs(struct ast_rtp_instance *instance)
Get the codecs structure of an RTP instance.
Definition: rtp_engine.c:483
#define LOG_WARNING
Definition: logger.h:144
int ast_rtp_instance_set_qos(struct ast_rtp_instance *instance, int tos, int cos, const char *desc)
Set QoS parameters on an RTP session.
Definition: rtp_engine.c:774
Definition: sched.c:57
#define BUFFSEND
Definition: chan_unistim.c:675
format_t ast_best_codec(format_t fmts)
Pick the best audio codec.
Definition: channel.c:1062
#define ast_mutex_lock(a)
Definition: lock.h:155
format_t nativeformats
Definition: channel.h:852
static const unsigned char packet_send_open_audio_stream_tx[]
Definition: chan_unistim.c:604
Socket address structure.
Definition: netsock2.h:63
#define ast_verb(level,...)
Definition: logger.h:243
static const unsigned char packet_send_open_audio_stream_rx3[]
Definition: chan_unistim.c:610
#define AST_FORMAT_G729A
Definition: frame.h:258
static int unistimdebug
Definition: chan_unistim.c:211
static const unsigned char packet_send_jitter_buffer_conf[]
Definition: chan_unistim.c:590
static struct sockaddr_in public_ip
Definition: chan_unistim.c:226
#define ast_sockaddr_from_sin(addr, sin)
Converts a struct sockaddr_in to a struct ast_sockaddr.
Definition: netsock2.h:642
#define AST_FORMAT_ALAW
Definition: frame.h:248
#define SIZE_HEADER
Definition: chan_unistim.c:139
struct unistimsession * session
Definition: chan_unistim.c:475
int ast_rtp_instance_set_remote_address(struct ast_rtp_instance *instance, const struct ast_sockaddr *address)
Set the address of the remote endpoint that we are sending RTP to.
Definition: rtp_engine.c:391
static const unsigned char packet_send_open_audio_stream_tx3[]
Definition: chan_unistim.c:617
int fds[AST_MAX_FDS]
Definition: channel.h:829
char * ast_getformatname(format_t format)
Get the name of a format.
Definition: frame.c:578
static const unsigned char packet_send_call[]
Definition: chan_unistim.c:552
int64_t format_t
Definition: frame_defs.h:32
#define AST_FORMAT_ULAW
Definition: frame.h:246
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
int errno
const char * ast_inet_ntoa(struct in_addr ia)
thread-safe replacement for inet_ntoa().
Definition: utils.c:564
static const unsigned char packet_send_rtp_packet_size[]
Definition: chan_unistim.c:588
int ast_rtp_instance_fd(struct ast_rtp_instance *instance, int rtcp)
Get the file descriptor for an RTP session (or RTCP)
Definition: rtp_engine.c:786
struct sockaddr_in sin
Definition: chan_unistim.c:481
struct ast_rtp_instance * ast_rtp_instance_new(const char *engine_name, struct sched_context *sched, const struct ast_sockaddr *sa, void *data)
Create a new RTP instance.
Definition: rtp_engine.c:308
void ast_rtp_instance_get_local_address(struct ast_rtp_instance *instance, struct ast_sockaddr *address)
Get the local address that we are expecting RTP on.
Definition: rtp_engine.c:430
static const unsigned char packet_send_open_audio_stream_rx[]
Definition: chan_unistim.c:599
format_t readformat
Definition: channel.h:853
struct unistim_line * parent
Definition: chan_unistim.c:373
char * ast_getformatname_multiple(char *buf, size_t size, format_t format)
Get the names of a set of formats.
Definition: frame.c:591
struct unistim_device * parent
Definition: chan_unistim.c:421
void ast_rtp_instance_set_prop(struct ast_rtp_instance *instance, enum ast_rtp_property property, int value)
Set the value of an RTP instance property.
Definition: rtp_engine.c:469
#define ast_sockaddr_to_sin(addr, sin)
Converts a struct ast_sockaddr to a struct sockaddr_in.
Definition: netsock2.h:629
int ast_rtp_codecs_payload_code(struct ast_rtp_codecs *codecs, const int asterisk_format, const format_t code)
Retrieve a payload based on whether it is an Asterisk format and the code.
Definition: rtp_engine.c:654
#define ast_mutex_unlock(a)
Definition: lock.h:156
static void swap_subs ( struct unistim_line p,
int  a,
int  b 
)
static

Definition at line 1867 of file chan_unistim.c.

References ast_log(), ast_verb, ast_channel::fds, LOG_WARNING, unistim_subchannel::owner, unistim_subchannel::rtp, and unistim_line::subs.

Referenced by HandleCallOutgoing(), and unistim_hangup().

1868 {
1869 /* struct ast_channel *towner; */
1870  struct ast_rtp_instance *rtp;
1871  int fds;
1872 
1873  if (unistimdebug)
1874  ast_verb(0, "Swapping %d and %d\n", a, b);
1875 
1876  if ((!p->subs[a]->owner) || (!p->subs[b]->owner)) {
1878  "Attempted to swap subchannels with a null owner : sub #%d=%p sub #%d=%p\n",
1879  a, p->subs[a]->owner, b, p->subs[b]->owner);
1880  return;
1881  }
1882  rtp = p->subs[a]->rtp;
1883  p->subs[a]->rtp = p->subs[b]->rtp;
1884  p->subs[b]->rtp = rtp;
1885 
1886  fds = p->subs[a]->owner->fds[0];
1887  p->subs[a]->owner->fds[0] = p->subs[b]->owner->fds[0];
1888  p->subs[b]->owner->fds[0] = fds;
1889 
1890  fds = p->subs[a]->owner->fds[1];
1891  p->subs[a]->owner->fds[1] = p->subs[b]->owner->fds[1];
1892  p->subs[b]->owner->fds[1] = fds;
1893 }
struct ast_channel * owner
Definition: chan_unistim.c:371
struct ast_rtp_instance * rtp
Definition: chan_unistim.c:375
#define LOG_WARNING
Definition: logger.h:144
#define ast_verb(level,...)
Definition: logger.h:243
struct unistim_subchannel * subs[MAX_SUBS]
Definition: chan_unistim.c:391
static int unistimdebug
Definition: chan_unistim.c:211
int fds[AST_MAX_FDS]
Definition: channel.h:829
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
static void TransferCallStep1 ( struct unistimsession pte)
static

Definition at line 2326 of file chan_unistim.c.

References ast_bridged_channel(), AST_CAUSE_NORMAL_CLEARING, ast_channel_start_silence_generator(), ast_log(), ast_moh_start(), ast_queue_hangup_with_cause(), ast_verb, unistimsession::device, handle_dial_page(), unistim_device::lines, LOG_WARNING, unistim_device::moh, unistim_line::musicclass, unistim_subchannel::owner, unistim_device::silence_generator, SUB_REAL, SUB_THREEWAY, and unistim_line::subs.

Referenced by key_call().

2327 {
2328  struct unistim_subchannel *sub;
2329  struct unistim_line *p = pte->device->lines;
2330 
2331  sub = p->subs[SUB_REAL];
2332 
2333  if (!sub->owner) {
2334  ast_log(LOG_WARNING, "Unable to find subchannel for music on hold\n");
2335  return;
2336  }
2337  if (p->subs[SUB_THREEWAY]) {
2338  if (unistimdebug)
2339  ast_verb(0, "Transfer canceled, hangup our threeway channel\n");
2340  if (p->subs[SUB_THREEWAY]->owner)
2342  else
2343  ast_log(LOG_WARNING, "Canceling a threeway channel without owner\n");
2344  return;
2345  }
2346  /* Start music on hold if appropriate */
2347  if (pte->device->moh)
2348  ast_log(LOG_WARNING, "Transfer with peer already listening music on hold\n");
2349  else {
2350  if (ast_bridged_channel(p->subs[SUB_REAL]->owner)) {
2352  pte->device->lines->musicclass, NULL);
2353  pte->device->moh = 1;
2354  } else {
2355  ast_log(LOG_WARNING, "Unable to find peer subchannel for music on hold\n");
2356  return;
2357  }
2358  }
2359  /* Silence our channel */
2360  if (!pte->device->silence_generator) {
2361  pte->device->silence_generator =
2363  if (pte->device->silence_generator == NULL)
2364  ast_log(LOG_WARNING, "Unable to start a silence generator.\n");
2365  else if (unistimdebug)
2366  ast_verb(0, "Starting silence generator\n");
2367  }
2368  handle_dial_page(pte);
2369 }
struct ast_channel * owner
Definition: chan_unistim.c:371
#define LOG_WARNING
Definition: logger.h:144
#define SUB_THREEWAY
Definition: chan_unistim.c:106
#define ast_verb(level,...)
Definition: logger.h:243
struct unistim_subchannel * subs[MAX_SUBS]
Definition: chan_unistim.c:391
static int unistimdebug
Definition: chan_unistim.c:211
int ast_queue_hangup_with_cause(struct ast_channel *chan, int cause)
Queue a hangup frame with hangupcause set.
Definition: channel.c:1581
struct unistim_device * device
Definition: chan_unistim.c:496
#define AST_CAUSE_NORMAL_CLEARING
Definition: causes.h:105
static void handle_dial_page(struct unistimsession *pte)
char musicclass[MAX_MUSICCLASS]
Definition: chan_unistim.c:407
struct ast_silence_generator * ast_channel_start_silence_generator(struct ast_channel *chan)
Starts a silence generator on the given channel.
Definition: channel.c:8309
struct ast_channel * ast_bridged_channel(struct ast_channel *chan)
Find bridged channel.
Definition: channel.c:7160
int ast_moh_start(struct ast_channel *chan, const char *mclass, const char *interpclass)
Turn on music on hold on a given channel.
Definition: channel.c:8040
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
struct unistim_line * lines
Definition: chan_unistim.c:473
#define SUB_REAL
Definition: chan_unistim.c:105
struct ast_silence_generator * silence_generator
Definition: chan_unistim.c:472
static int unalloc_sub ( struct unistim_line p,
int  x 
)
static

Definition at line 1507 of file chan_unistim.c.

References ast_debug, ast_free, ast_log(), ast_mutex_destroy, unistim_line::lock, LOG_WARNING, unistim_line::name, unistim_device::name, unistim_line::parent, and unistim_line::subs.

Referenced by unistim_hangup().

1508 {
1509  if (!x) {
1510  ast_log(LOG_WARNING, "Trying to unalloc the real channel %s@%s?!?\n", p->name,
1511  p->parent->name);
1512  return -1;
1513  }
1514  if (unistimdebug)
1515  ast_debug(1, "Released sub %d of channel %s@%s\n", x, p->name,
1516  p->parent->name);
1517  ast_mutex_destroy(&p->lock);
1518  ast_free(p->subs[x]);
1519  p->subs[x] = 0;
1520  return 0;
1521 }
char name[DEVICE_NAME_LEN]
Definition: chan_unistim.c:435
#define LOG_WARNING
Definition: logger.h:144
struct unistim_subchannel * subs[MAX_SUBS]
Definition: chan_unistim.c:391
static int unistimdebug
Definition: chan_unistim.c:211
char name[80]
Definition: chan_unistim.c:387
#define ast_debug(level,...)
Log a DEBUG message.
Definition: logger.h:236
ast_mutex_t lock
Definition: chan_unistim.c:385
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
#define ast_free(a)
Definition: astmm.h:97
struct unistim_device * parent
Definition: chan_unistim.c:421
#define ast_mutex_destroy(a)
Definition: lock.h:154
static int unistim_answer ( struct ast_channel ast)
static

Definition at line 3876 of file chan_unistim.c.

References ast_channel::_state, ast_log(), ast_setstate(), AST_STATE_UP, ast_verb, channel_to_session(), LOG_WARNING, unistim_line::name, unistim_device::name, ast_channel::name, unistim_subchannel::parent, unistim_line::parent, unistim_subchannel::rtp, send_start_timer(), send_text(), send_text_status(), unistim_device::session, start_rtp(), SUB_THREEWAY, unistim_line::subs, unistim_subchannel::subtype, ast_channel::tech_pvt, TEXT_LINE2, and TEXT_NORMAL.

3877 {
3878  int res = 0;
3879  struct unistim_subchannel *sub;
3880  struct unistim_line *l;
3881  struct unistimsession *s;
3882 
3883  s = channel_to_session(ast);
3884  if (!s) {
3885  ast_log(LOG_WARNING, "unistim_answer on a disconnected device ?\n");
3886  return -1;
3887  }
3888  sub = ast->tech_pvt;
3889  l = sub->parent;
3890 
3891  if ((!sub->rtp) && (!l->subs[SUB_THREEWAY]))
3892  start_rtp(sub);
3893  if (unistimdebug)
3894  ast_verb(0, "unistim_answer(%s) on %s@%s-%u\n", ast->name, l->name,
3895  l->parent->name, sub->subtype);
3896  send_text(TEXT_LINE2, TEXT_NORMAL, l->parent->session, "is now on-line");
3897  if (l->subs[SUB_THREEWAY])
3898  send_text_status(l->parent->session, "Transf Cancel");
3899  else
3900  send_text_status(l->parent->session, "Hangup Transf");
3902  if (ast->_state != AST_STATE_UP)
3903  ast_setstate(ast, AST_STATE_UP);
3904  return res;
3905 }
char name[DEVICE_NAME_LEN]
Definition: chan_unistim.c:435
#define TEXT_LINE2
Definition: chan_unistim.c:144
struct ast_rtp_instance * rtp
Definition: chan_unistim.c:375
void * tech_pvt
Definition: channel.h:744
#define LOG_WARNING
Definition: logger.h:144
#define SUB_THREEWAY
Definition: chan_unistim.c:106
#define TEXT_NORMAL
Definition: chan_unistim.c:145
#define ast_verb(level,...)
Definition: logger.h:243
struct unistim_subchannel * subs[MAX_SUBS]
Definition: chan_unistim.c:391
static int unistimdebug
Definition: chan_unistim.c:211
unsigned int subtype
Definition: chan_unistim.c:369
char name[80]
Definition: chan_unistim.c:387
static void start_rtp(struct unistim_subchannel *sub)
struct unistimsession * session
Definition: chan_unistim.c:475
static void send_text_status(struct unistimsession *pte, const char *text)
enum ast_channel_state _state
Definition: channel.h:839
const ast_string_field name
Definition: channel.h:787
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
static void send_text(unsigned char pos, unsigned char inverse, struct unistimsession *pte, const char *text)
struct unistim_line * parent
Definition: chan_unistim.c:373
int ast_setstate(struct ast_channel *chan, enum ast_channel_state)
Change the state of a channel.
Definition: channel.c:7119
struct unistim_device * parent
Definition: chan_unistim.c:421
static void send_start_timer(struct unistimsession *pte)
Definition: chan_unistim.c:954
static struct unistimsession * channel_to_session(struct ast_channel *ast)
static int unistim_call ( struct ast_channel ast,
char *  dest,
int  timeout 
)
static

Definition at line 3700 of file chan_unistim.c.

References ast_channel::_state, AST_CONTROL_RINGING, ast_log(), ast_queue_control(), ast_setstate(), AST_STATE_DOWN, AST_STATE_RESERVED, AST_STATE_RINGING, ast_verb, change_callerid(), change_favorite_icon(), channel_to_session(), ast_channel::connected, DEFAULTCALLERID, DEFAULTCALLERNAME, unistimsession::device, FAV_BLINK_FAST, FAV_ICON_NONE, FAV_ICON_SPEAKER_ONHOOK_BLACK, unistim_device::height, ast_party_connected_line::id, LOG_ERROR, LOG_WARNING, ast_party_id::name, ast_channel::name, ast_party_id::number, unistim_subchannel::owner, unistim_subchannel::ringstyle, unistim_device::ringstyle, unistim_subchannel::ringvolume, unistim_device::ringvolume, send_ring(), send_text(), send_text_status(), Sendicon(), unistimsession::state, STATE_RINGING, ast_party_name::str, ast_party_number::str, ast_channel::tech_pvt, TEXT_LINE0, TEXT_LINE1, TEXT_LINE2, TEXT_NORMAL, ast_party_name::valid, and ast_party_number::valid.

3701 {
3702  int res = 0;
3703  struct unistim_subchannel *sub;
3704  struct unistimsession *session;
3705 
3706  session = channel_to_session(ast);
3707  if (!session) {
3708  ast_log(LOG_ERROR, "Device not registered, cannot call %s\n", dest);
3709  return -1;
3710  }
3711 
3712  sub = ast->tech_pvt;
3713  if ((ast->_state != AST_STATE_DOWN) && (ast->_state != AST_STATE_RESERVED)) {
3714  ast_log(LOG_WARNING, "unistim_call called on %s, neither down nor reserved\n",
3715  ast->name);
3716  return -1;
3717  }
3718 
3719  if (unistimdebug)
3720  ast_verb(3, "unistim_call(%s)\n", ast->name);
3721 
3722  session->state = STATE_RINGING;
3723  Sendicon(TEXT_LINE0, FAV_ICON_NONE, session);
3724 
3725  if (sub->owner) {
3726  if (sub->owner->connected.id.number.valid
3727  && sub->owner->connected.id.number.str) {
3728  if (session->device->height == 1) {
3730  } else {
3732  }
3733  change_callerid(session, 0, sub->owner->connected.id.number.str);
3734  } else {
3735  if (session->device->height == 1) {
3737  } else {
3739  }
3740  change_callerid(session, 0, DEFAULTCALLERID);
3741  }
3742  if (sub->owner->connected.id.name.valid
3743  && sub->owner->connected.id.name.str) {
3745  change_callerid(session, 1, sub->owner->connected.id.name.str);
3746  } else {
3748  change_callerid(session, 1, DEFAULTCALLERNAME);
3749  }
3750  }
3751  send_text(TEXT_LINE2, TEXT_NORMAL, session, "is calling you.");
3752  send_text_status(session, "Accept Ignore");
3753 
3754  if (sub->ringstyle == -1)
3755  send_ring(session, session->device->ringvolume, session->device->ringstyle);
3756  else {
3757  if (sub->ringvolume == -1)
3758  send_ring(session, session->device->ringvolume, sub->ringstyle);
3759  else
3760  send_ring(session, sub->ringvolume, sub->ringstyle);
3761  }
3763 
3766  return res;
3767 }
struct ast_channel * owner
Definition: chan_unistim.c:371
char * str
Subscriber phone number (Malloced)
Definition: channel.h:241
struct ast_party_connected_line connected
Channel Connected Line ID information.
Definition: channel.h:811
int ast_queue_control(struct ast_channel *chan, enum ast_control_frame_type control)
Queue a control frame with payload.
Definition: channel.c:1601
#define TEXT_LINE2
Definition: chan_unistim.c:144
struct ast_party_id id
Connected party ID.
Definition: channel.h:403
struct ast_party_name name
Subscriber name.
Definition: channel.h:290
void * tech_pvt
Definition: channel.h:744
#define TEXT_LINE1
Definition: chan_unistim.c:143
#define LOG_WARNING
Definition: logger.h:144
static void change_favorite_icon(struct unistimsession *pte, unsigned char status)
char * str
Subscriber name (Malloced)
Definition: channel.h:214
#define TEXT_NORMAL
Definition: chan_unistim.c:145
#define ast_verb(level,...)
Definition: logger.h:243
static int unistimdebug
Definition: chan_unistim.c:211
struct unistim_device * device
Definition: chan_unistim.c:496
#define DEFAULTCALLERNAME
Definition: chan_unistim.c:82
#define DEFAULTCALLERID
Definition: chan_unistim.c:81
#define FAV_ICON_NONE
Definition: chan_unistim.c:149
#define TEXT_LINE0
Definition: chan_unistim.c:142
#define FAV_BLINK_FAST
Definition: chan_unistim.c:183
#define FAV_ICON_SPEAKER_ONHOOK_BLACK
Definition: chan_unistim.c:152
#define LOG_ERROR
Definition: logger.h:155
static void send_text_status(struct unistimsession *pte, const char *text)
enum ast_channel_state _state
Definition: channel.h:839
const ast_string_field name
Definition: channel.h:787
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
static void send_ring(struct unistimsession *pte, char volume, char style)
static void send_text(unsigned char pos, unsigned char inverse, struct unistimsession *pte, const char *text)
int ast_setstate(struct ast_channel *chan, enum ast_channel_state)
Change the state of a channel.
Definition: channel.c:7119
unsigned char valid
TRUE if the name information is valid/present.
Definition: channel.h:229
static void change_callerid(struct unistimsession *pte, int type, char *callerid)
static struct unistimsession * channel_to_session(struct ast_channel *ast)
unsigned char valid
TRUE if the number information is valid/present.
Definition: channel.h:247
static void Sendicon(unsigned char pos, unsigned char status, struct unistimsession *pte)
Definition: chan_unistim.c:972
struct ast_party_number number
Subscriber phone number.
Definition: channel.h:292
static char* unistim_do_debug ( struct ast_cli_entry e,
int  cmd,
struct ast_cli_args a 
)
static

Definition at line 4883 of file chan_unistim.c.

References ast_cli_args::argc, ast_cli_entry::args, ast_cli_args::argv, ast_cli(), CLI_GENERATE, CLI_INIT, CLI_SHOWUSAGE, CLI_SUCCESS, ast_cli_entry::command, ast_cli_args::fd, and ast_cli_entry::usage.

4884 {
4885  switch (cmd) {
4886  case CLI_INIT:
4887  e->command = "unistim set debug {on|off}";
4888  e->usage =
4889  "Usage: unistim set debug\n"
4890  " Display debug messages.\n";
4891  return NULL;
4892 
4893  case CLI_GENERATE:
4894  return NULL; /* no completion */
4895  }
4896 
4897  if (a->argc != e->args)
4898  return CLI_SHOWUSAGE;
4899 
4900  if (!strcasecmp(a->argv[3], "on")) {
4901  unistimdebug = 1;
4902  ast_cli(a->fd, "UNISTIM Debugging Enabled\n");
4903  } else if (!strcasecmp(a->argv[3], "off")) {
4904  unistimdebug = 0;
4905  ast_cli(a->fd, "UNISTIM Debugging Disabled\n");
4906  } else
4907  return CLI_SHOWUSAGE;
4908 
4909  return CLI_SUCCESS;
4910 }
const int argc
Definition: cli.h:154
Definition: cli.h:146
void ast_cli(int fd, const char *fmt,...)
Definition: cli.c:105
static int unistimdebug
Definition: chan_unistim.c:211
int args
This gets set in ast_cli_register()
Definition: cli.h:179
const int fd
Definition: cli.h:153
const char *const * argv
Definition: cli.h:155
#define CLI_SHOWUSAGE
Definition: cli.h:44
char * command
Definition: cli.h:180
const char * usage
Definition: cli.h:171
#define CLI_SUCCESS
Definition: cli.h:43
static int unistim_do_senddigit ( struct unistimsession pte,
char  digit 
)
static

Definition at line 2504 of file chan_unistim.c.

References unistim_subchannel::alreadygone, AST_FRAME_DTMF, ast_log(), ast_queue_frame(), ast_verb, unistimsession::device, ast_frame::frametype, unistim_device::lines, LOG_WARNING, unistim_subchannel::owner, send_tone(), SUB_REAL, and unistim_line::subs.

Referenced by key_call(), and unistim_senddigit_begin().

2505 {
2506  struct ast_frame f = { .frametype = AST_FRAME_DTMF, .subclass.integer = digit, .src = "unistim" };
2507  struct unistim_subchannel *sub;
2508  sub = pte->device->lines->subs[SUB_REAL];
2509  if (!sub->owner || sub->alreadygone) {
2510  ast_log(LOG_WARNING, "Unable to find subchannel in dtmf senddigit\n");
2511  return -1;
2512  }
2513 
2514  /* Send DTMF indication _before_ playing sounds */
2515  ast_queue_frame(sub->owner, &f);
2516 
2517  if (unistimdebug)
2518  ast_verb(0, "Send Digit %c\n", digit);
2519  switch (digit) {
2520  case '0':
2521  send_tone(pte, 941, 1336);
2522  break;
2523  case '1':
2524  send_tone(pte, 697, 1209);
2525  break;
2526  case '2':
2527  send_tone(pte, 697, 1336);
2528  break;
2529  case '3':
2530  send_tone(pte, 697, 1477);
2531  break;
2532  case '4':
2533  send_tone(pte, 770, 1209);
2534  break;
2535  case '5':
2536  send_tone(pte, 770, 1336);
2537  break;
2538  case '6':
2539  send_tone(pte, 770, 1477);
2540  break;
2541  case '7':
2542  send_tone(pte, 852, 1209);
2543  break;
2544  case '8':
2545  send_tone(pte, 852, 1336);
2546  break;
2547  case '9':
2548  send_tone(pte, 852, 1477);
2549  break;
2550  case 'A':
2551  send_tone(pte, 697, 1633);
2552  break;
2553  case 'B':
2554  send_tone(pte, 770, 1633);
2555  break;
2556  case 'C':
2557  send_tone(pte, 852, 1633);
2558  break;
2559  case 'D':
2560  send_tone(pte, 941, 1633);
2561  break;
2562  case '*':
2563  send_tone(pte, 941, 1209);
2564  break;
2565  case '#':
2566  send_tone(pte, 941, 1477);
2567  break;
2568  default:
2569  send_tone(pte, 500, 2000);
2570  }
2571  usleep(150000); /* XXX Less than perfect, blocking an important thread is not a good idea */
2572  send_tone(pte, 0, 0);
2573  return 0;
2574 }
struct ast_channel * owner
Definition: chan_unistim.c:371
#define LOG_WARNING
Definition: logger.h:144
#define AST_FRAME_DTMF
Definition: frame.h:128
#define ast_verb(level,...)
Definition: logger.h:243
struct unistim_subchannel * subs[MAX_SUBS]
Definition: chan_unistim.c:391
static int unistimdebug
Definition: chan_unistim.c:211
struct unistim_device * device
Definition: chan_unistim.c:496
static void send_tone(struct unistimsession *pte, uint16_t tone1, uint16_t tone2)
Definition: chan_unistim.c:983
int ast_queue_frame(struct ast_channel *chan, struct ast_frame *f)
Queue one or more frames to a channel&#39;s frame queue.
Definition: channel.c:1558
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
struct unistim_line * lines
Definition: chan_unistim.c:473
static struct ast_format f[]
Definition: format_g726.c:181
#define SUB_REAL
Definition: chan_unistim.c:105
Data structure associated with a single frame of data.
Definition: frame.h:142
static int unistim_fixup ( struct ast_channel oldchan,
struct ast_channel newchan 
)
static

Definition at line 4062 of file chan_unistim.c.

References ast_debug, ast_log(), ast_mutex_lock, ast_mutex_unlock, unistim_subchannel::lock, LOG_WARNING, unistim_line::name, unistim_device::name, ast_channel::name, unistim_subchannel::owner, unistim_subchannel::parent, unistim_line::parent, unistim_subchannel::subtype, and ast_channel::tech_pvt.

4063 {
4064  struct unistim_subchannel *p = newchan->tech_pvt;
4065  struct unistim_line *l = p->parent;
4066 
4067  ast_mutex_lock(&p->lock);
4068 
4069  ast_debug(1, "New owner for channel USTM/%s@%s-%u is %s\n", l->name,
4070  l->parent->name, p->subtype, newchan->name);
4071 
4072  if (p->owner != oldchan) {
4073  ast_log(LOG_WARNING, "old channel wasn't %s (%p) but was %s (%p)\n",
4074  oldchan->name, oldchan, p->owner->name, p->owner);
4075  ast_mutex_unlock(&p->lock);
4076  return -1;
4077  }
4078 
4079  p->owner = newchan;
4080 
4081  ast_mutex_unlock(&p->lock);
4082 
4083  return 0;
4084 
4085 }
ast_mutex_t lock
Definition: chan_unistim.c:367
struct ast_channel * owner
Definition: chan_unistim.c:371
char name[DEVICE_NAME_LEN]
Definition: chan_unistim.c:435
void * tech_pvt
Definition: channel.h:744
#define LOG_WARNING
Definition: logger.h:144
#define ast_mutex_lock(a)
Definition: lock.h:155
unsigned int subtype
Definition: chan_unistim.c:369
char name[80]
Definition: chan_unistim.c:387
#define ast_debug(level,...)
Log a DEBUG message.
Definition: logger.h:236
const ast_string_field name
Definition: channel.h:787
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
struct unistim_line * parent
Definition: chan_unistim.c:373
struct unistim_device * parent
Definition: chan_unistim.c:421
#define ast_mutex_unlock(a)
Definition: lock.h:156
static enum ast_rtp_glue_result unistim_get_rtp_peer ( struct ast_channel chan,
struct ast_rtp_instance **  instance 
)
static

Definition at line 5614 of file chan_unistim.c.

References ao2_ref, AST_RTP_GLUE_RESULT_FORBID, AST_RTP_GLUE_RESULT_LOCAL, unistim_subchannel::rtp, and ast_channel::tech_pvt.

5615 {
5616  struct unistim_subchannel *sub = chan->tech_pvt;
5617 
5618  if (!sub) {
5620  }
5621  if (!sub->rtp) {
5623  }
5624 
5625  ao2_ref(sub->rtp, +1);
5626  *instance = sub->rtp;
5627 
5629 }
struct ast_rtp_instance * rtp
Definition: chan_unistim.c:375
void * tech_pvt
Definition: channel.h:744
#define ao2_ref(o, delta)
Definition: astobj2.h:472
static int unistim_hangup ( struct ast_channel ast)
static

Definition at line 3770 of file chan_unistim.c.

References unistim_subchannel::alreadygone, ast_bridged_channel(), ast_channel_stop_silence_generator(), ast_debug, ast_log(), ast_moh_stop(), ast_mutex_lock, ast_mutex_unlock, ast_rtp_instance_destroy(), ast_verb, cancel_dial(), channel_to_session(), close_call(), unistimsession::device, unistim_subchannel::lock, LOG_WARNING, unistim_device::moh, unistim_line::name, unistim_device::name, ast_channel::name, unistim_subchannel::owner, unistim_subchannel::parent, unistim_line::parent, unistim_subchannel::rtp, send_end_call(), send_no_ring(), send_text(), send_text_status(), unistim_device::silence_generator, unistimsession::state, STATE_CALL, STATE_RINGING, SUB_REAL, SUB_THREEWAY, unistim_line::subs, unistim_subchannel::subtype, swap_subs(), ast_channel::tech_pvt, TEXT_LINE0, TEXT_LINE1, TEXT_LINE2, TEXT_NORMAL, and unalloc_sub().

3771 {
3772  struct unistim_subchannel *sub;
3773  struct unistim_line *l;
3774  struct unistimsession *s;
3775 
3776  s = channel_to_session(ast);
3777  sub = ast->tech_pvt;
3778  if (!s) {
3779  ast_debug(1, "Asked to hangup channel not connected\n");
3780  ast_mutex_lock(&sub->lock);
3781  sub->owner = NULL;
3782  ast->tech_pvt = NULL;
3783  sub->alreadygone = 0;
3784  ast_mutex_unlock(&sub->lock);
3785  if (sub->rtp) {
3786  if (unistimdebug)
3787  ast_verb(0, "Destroying RTP session\n");
3789  sub->rtp = NULL;
3790  }
3791  return 0;
3792  }
3793  l = sub->parent;
3794  if (unistimdebug)
3795  ast_verb(0, "unistim_hangup(%s) on %s@%s\n", ast->name, l->name, l->parent->name);
3796 
3797  if ((l->subs[SUB_THREEWAY]) && (sub->subtype == SUB_REAL)) {
3798  if (unistimdebug)
3799  ast_verb(0, "Real call disconnected while talking to threeway\n");
3800  sub->owner = NULL;
3801  ast->tech_pvt = NULL;
3802  return 0;
3803  }
3804  if ((l->subs[SUB_REAL]->owner) && (sub->subtype == SUB_THREEWAY) &&
3805  (sub->alreadygone == 0)) {
3806  if (unistimdebug)
3807  ast_verb(0, "threeway call disconnected, switching to real call\n");
3808  send_text(TEXT_LINE0, TEXT_NORMAL, s, "Three way call canceled,");
3809  send_text(TEXT_LINE1, TEXT_NORMAL, s, "switching back to");
3810  send_text(TEXT_LINE2, TEXT_NORMAL, s, "previous call.");
3811  send_text_status(s, "Hangup Transf");
3814  l->parent->moh = 0;
3815  ast_mutex_lock(&sub->lock);
3816  sub->owner = NULL;
3817  ast->tech_pvt = NULL;
3818  ast_mutex_unlock(&sub->lock);
3820  return 0;
3821  }
3822  ast_mutex_lock(&sub->lock);
3823  sub->owner = NULL;
3824  ast->tech_pvt = NULL;
3825  sub->alreadygone = 0;
3826  ast_mutex_unlock(&sub->lock);
3827  if (!s) {
3828  if (unistimdebug)
3829  ast_verb(0, "Asked to hangup channel not connected (no session)\n");
3830  if (sub->rtp) {
3831  if (unistimdebug)
3832  ast_verb(0, "Destroying RTP session\n");
3834  sub->rtp = NULL;
3835  }
3836  return 0;
3837  }
3838  if (sub->subtype == SUB_REAL) {
3839  /* Stop the silence generator */
3840  if (s->device->silence_generator) {
3841  if (unistimdebug)
3842  ast_verb(0, "Stopping silence generator\n");
3843  if (sub->owner)
3846  else
3848  "Trying to stop silence generator on a null channel !\n");
3849  s->device->silence_generator = NULL;
3850  }
3851  }
3852  l->parent->moh = 0;
3853  send_no_ring(s);
3854  send_end_call(s);
3855  if (sub->rtp) {
3856  if (unistimdebug)
3857  ast_verb(0, "Destroying RTP session\n");
3859  sub->rtp = NULL;
3860  } else if (unistimdebug)
3861  ast_verb(0, "No RTP session to destroy\n");
3862  if (l->subs[SUB_THREEWAY]) {
3863  if (unistimdebug)
3864  ast_verb(0, "Cleaning other subchannels\n");
3866  }
3867  if (s->state == STATE_RINGING)
3868  cancel_dial(s);
3869  else if (s->state == STATE_CALL)
3870  close_call(s);
3871 
3872  return 0;
3873 }
ast_mutex_t lock
Definition: chan_unistim.c:367
struct ast_channel * owner
Definition: chan_unistim.c:371
char name[DEVICE_NAME_LEN]
Definition: chan_unistim.c:435
#define TEXT_LINE2
Definition: chan_unistim.c:144
struct ast_rtp_instance * rtp
Definition: chan_unistim.c:375
void * tech_pvt
Definition: channel.h:744
#define TEXT_LINE1
Definition: chan_unistim.c:143
#define LOG_WARNING
Definition: logger.h:144
#define SUB_THREEWAY
Definition: chan_unistim.c:106
static void close_call(struct unistimsession *pte)
#define ast_mutex_lock(a)
Definition: lock.h:155
#define TEXT_NORMAL
Definition: chan_unistim.c:145
void ast_moh_stop(struct ast_channel *chan)
Turn off music on hold on a given channel.
Definition: channel.c:8051
#define ast_verb(level,...)
Definition: logger.h:243
struct unistim_subchannel * subs[MAX_SUBS]
Definition: chan_unistim.c:391
static int unistimdebug
Definition: chan_unistim.c:211
struct unistim_device * device
Definition: chan_unistim.c:496
unsigned int subtype
Definition: chan_unistim.c:369
static int unalloc_sub(struct unistim_line *p, int x)
char name[80]
Definition: chan_unistim.c:387
#define ast_debug(level,...)
Log a DEBUG message.
Definition: logger.h:236
#define TEXT_LINE0
Definition: chan_unistim.c:142
static void send_text_status(struct unistimsession *pte, const char *text)
static void swap_subs(struct unistim_line *p, int a, int b)
struct ast_channel * ast_bridged_channel(struct ast_channel *chan)
Find bridged channel.
Definition: channel.c:7160
const ast_string_field name
Definition: channel.h:787
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
static void cancel_dial(struct unistimsession *pte)
void ast_channel_stop_silence_generator(struct ast_channel *chan, struct ast_silence_generator *state)
Stops a previously-started silence generator on the given channel.
Definition: channel.c:8355
int ast_rtp_instance_destroy(struct ast_rtp_instance *instance)
Destroy an RTP instance.
Definition: rtp_engine.c:301
static void send_text(unsigned char pos, unsigned char inverse, struct unistimsession *pte, const char *text)
#define SUB_REAL
Definition: chan_unistim.c:105
static void send_no_ring(struct unistimsession *pte)
struct unistim_line * parent
Definition: chan_unistim.c:373
struct unistim_device * parent
Definition: chan_unistim.c:421
static struct unistimsession * channel_to_session(struct ast_channel *ast)
static void send_end_call(struct unistimsession *pte)
Definition: chan_unistim.c:911
struct ast_silence_generator * silence_generator
Definition: chan_unistim.c:472
#define ast_mutex_unlock(a)
Definition: lock.h:156
static int unistim_indicate ( struct ast_channel ast,
int  ind,
const void *  data,
size_t  datalen 
)
static

Definition at line 4135 of file chan_unistim.c.

References ast_channel::_state, unistim_subchannel::alreadygone, AST_CONTROL_BUSY, AST_CONTROL_CONGESTION, AST_CONTROL_HOLD, AST_CONTROL_INCOMPLETE, AST_CONTROL_PROCEEDING, AST_CONTROL_PROGRESS, AST_CONTROL_RINGING, AST_CONTROL_SRCUPDATE, AST_CONTROL_UNHOLD, AST_CONTROL_UPDATE_RTP_PEER, ast_log(), ast_moh_start(), ast_moh_stop(), ast_playtones_stop(), AST_STATE_UP, ast_verb, channel_to_session(), control2str(), unistimsession::device, in_band_indication(), LOG_WARNING, unistim_device::missed_call, ast_channel::name, unistim_subchannel::parent, unistim_line::parent, send_text(), ast_channel::tech_pvt, TEXT_LINE2, TEXT_NORMAL, and unistim_device::tz.

4137 {
4138  struct unistim_subchannel *sub;
4139  struct unistim_line *l;
4140  struct unistimsession *s;
4141 
4142  if (unistimdebug) {
4143  ast_verb(3, "Asked to indicate '%s' condition on channel %s\n",
4144  control2str(ind), ast->name);
4145  }
4146 
4147  s = channel_to_session(ast);
4148  if (!s)
4149  return -1;
4150 
4151  sub = ast->tech_pvt;
4152  l = sub->parent;
4153 
4154  switch (ind) {
4155  case AST_CONTROL_RINGING:
4156  if (ast->_state != AST_STATE_UP) {
4157  send_text(TEXT_LINE2, TEXT_NORMAL, s, "Ringing...");
4158  in_band_indication(ast, l->parent->tz, "ring");
4159  s->device->missed_call = -1;
4160  break;
4161  }
4162  return -1;
4163  case AST_CONTROL_BUSY:
4164  if (ast->_state != AST_STATE_UP) {
4165  sub->alreadygone = 1;
4166  send_text(TEXT_LINE2, TEXT_NORMAL, s, "Busy");
4167  in_band_indication(ast, l->parent->tz, "busy");
4168  s->device->missed_call = -1;
4169  break;
4170  }
4171  return -1;
4173  /* Overlapped dialing is not currently supported for UNIStim. Treat an indication
4174  * of incomplete as congestion
4175  */
4177  if (ast->_state != AST_STATE_UP) {
4178  sub->alreadygone = 1;
4179  send_text(TEXT_LINE2, TEXT_NORMAL, s, "Congestion");
4180  in_band_indication(ast, l->parent->tz, "congestion");
4181  s->device->missed_call = -1;
4182  break;
4183  }
4184  return -1;
4185  case AST_CONTROL_HOLD:
4186  ast_moh_start(ast, data, NULL);
4187  break;
4188  case AST_CONTROL_UNHOLD:
4189  ast_moh_stop(ast);
4190  break;
4191  case AST_CONTROL_PROGRESS:
4192  case AST_CONTROL_SRCUPDATE:
4193  break;
4194  case -1:
4195  ast_playtones_stop(ast);
4196  s->device->missed_call = 0;
4197  break;
4200  break;
4201  default:
4202  ast_log(LOG_WARNING, "Don't know how to indicate condition %d\n", ind);
4203  return -1;
4204  }
4205 
4206  return 0;
4207 }
#define TEXT_LINE2
Definition: chan_unistim.c:144
void * tech_pvt
Definition: channel.h:744
#define LOG_WARNING
Definition: logger.h:144
static void in_band_indication(struct ast_channel *ast, const struct ast_tone_zone *tz, const char *indication)
void ast_playtones_stop(struct ast_channel *chan)
Stop playing tones on a channel.
Definition: indications.c:411
#define TEXT_NORMAL
Definition: chan_unistim.c:145
void ast_moh_stop(struct ast_channel *chan)
Turn off music on hold on a given channel.
Definition: channel.c:8051
#define ast_verb(level,...)
Definition: logger.h:243
static int unistimdebug
Definition: chan_unistim.c:211
struct unistim_device * device
Definition: chan_unistim.c:496
static char * control2str(int ind)
struct ast_tone_zone * tz
Definition: chan_unistim.c:450
enum ast_channel_state _state
Definition: channel.h:839
const ast_string_field name
Definition: channel.h:787
int ast_moh_start(struct ast_channel *chan, const char *mclass, const char *interpclass)
Turn on music on hold on a given channel.
Definition: channel.c:8040
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
static void send_text(unsigned char pos, unsigned char inverse, struct unistimsession *pte, const char *text)
struct unistim_line * parent
Definition: chan_unistim.c:373
struct unistim_device * parent
Definition: chan_unistim.c:421
static struct unistimsession * channel_to_session(struct ast_channel *ast)
static char* unistim_info ( struct ast_cli_entry e,
int  cmd,
struct ast_cli_args a 
)
static

Definition at line 4753 of file chan_unistim.c.

References ast_channel::_bridge, unistim_subchannel::alreadygone, ast_cli_args::argc, ast_cli_entry::args, ast_cli(), ast_inet_ntoa(), ast_mutex_lock, ast_mutex_unlock, unistim_line::capability, unistim_line::cid_num, CLI_GENERATE, CLI_INIT, CLI_SHOWUSAGE, CLI_SUCCESS, ast_cli_entry::command, unistimsession::device, devices, unistim_line::exten, ast_cli_args::fd, unistim_line::fullname, unistim_device::ha, unistim_device::id, unistim_device::lines, unistimsession::macaddr, MAX_SUBS, unistim_line::name, unistim_device::name, unistim_line::next, unistim_device::next, unistimsession::next, unistim_subchannel::owner, unistim_subchannel::parent, unistim_line::parent, unistim_subchannel::rtp, unistim_device::session, sessionlock, sessions, unistimsession::sin, unistimsession::state, unistim_line::subs, unistim_subchannel::subtype, unistimsession::timeout, and ast_cli_entry::usage.

4754 {
4755  struct unistim_device *device = devices;
4756  struct unistim_line *line;
4757  struct unistim_subchannel *sub;
4758  struct unistimsession *s;
4759  int i;
4760  struct ast_channel *tmp;
4761 
4762  switch (cmd) {
4763  case CLI_INIT:
4764  e->command = "unistim show info";
4765  e->usage =
4766  "Usage: unistim show info\n"
4767  " Dump internal structures.\n";
4768  return NULL;
4769 
4770  case CLI_GENERATE:
4771  return NULL; /* no completion */
4772  }
4773 
4774  if (a->argc != e->args)
4775  return CLI_SHOWUSAGE;
4776 
4777  ast_cli(a->fd, "Dumping internal structures :\ndevice\n->line\n-->sub\n");
4778  while (device) {
4779  ast_cli(a->fd, "\nname=%s id=%s line=%p ha=%p sess=%p device=%p\n",
4780  device->name, device->id, device->lines, device->ha, device->session,
4781  device);
4782  line = device->lines;
4783  while (line) {
4784  ast_cli(a->fd,
4785  "->name=%s fullname=%s exten=%s callid=%s cap=%" PRId64 " device=%p line=%p\n",
4786  line->name, line->fullname, line->exten, line->cid_num,
4787  line->capability, line->parent, line);
4788  for (i = 0; i < MAX_SUBS; i++) {
4789  sub = line->subs[i];
4790  if (!sub)
4791  continue;
4792  if (!sub->owner)
4793  tmp = (void *) -42;
4794  else
4795  tmp = sub->owner->_bridge;
4796  if (sub->subtype != i)
4797  ast_cli(a->fd, "Warning ! subchannel->subs[%d] have a subtype=%u\n", i,
4798  sub->subtype);
4799  ast_cli(a->fd,
4800  "-->subtype=%u chan=%p rtp=%p bridge=%p line=%p alreadygone=%d\n",
4801  sub->subtype, sub->owner, sub->rtp, tmp, sub->parent,
4802  sub->alreadygone);
4803  }
4804  line = line->next;
4805  }
4806  device = device->next;
4807  }
4808  ast_cli(a->fd, "\nSessions:\n");
4810  s = sessions;
4811  while (s) {
4812  ast_cli(a->fd,
4813  "sin=%s timeout=%d state=%d macaddr=%s device=%p session=%p\n",
4814  ast_inet_ntoa(s->sin.sin_addr), s->timeout, s->state, s->macaddr,
4815  s->device, s);
4816  s = s->next;
4817  }
4819 
4820  return CLI_SUCCESS;
4821 }
struct ast_channel * owner
Definition: chan_unistim.c:371
static struct unistimsession * sessions
Main Channel structure associated with a channel.
Definition: channel.h:742
A device containing one or more lines.
Definition: chan_unistim.c:427
char name[DEVICE_NAME_LEN]
Definition: chan_unistim.c:435
struct ast_rtp_instance * rtp
Definition: chan_unistim.c:375
const int argc
Definition: cli.h:154
Definition: cli.h:146
#define ast_mutex_lock(a)
Definition: lock.h:155
void ast_cli(int fd, const char *fmt,...)
Definition: cli.c:105
#define MAX_SUBS
Definition: chan_unistim.c:107
struct unistim_subchannel * subs[MAX_SUBS]
Definition: chan_unistim.c:391
static ast_mutex_t sessionlock
Definition: chan_unistim.c:247
int args
This gets set in ast_cli_register()
Definition: cli.h:179
struct unistim_device * device
Definition: chan_unistim.c:496
unsigned int subtype
Definition: chan_unistim.c:369
struct unistimsession * next
Definition: chan_unistim.c:497
struct ast_ha * ha
Definition: chan_unistim.c:474
char name[80]
Definition: chan_unistim.c:387
struct unistim_line * next
Definition: chan_unistim.c:420
char macaddr[18]
Definition: chan_unistim.c:493
const int fd
Definition: cli.h:153
struct unistim_device * next
Definition: chan_unistim.c:476
struct unistimsession * session
Definition: chan_unistim.c:475
struct ast_channel * _bridge
Definition: channel.h:748
char cid_num[AST_MAX_EXTENSION]
Definition: chan_unistim.c:399
#define CLI_SHOWUSAGE
Definition: cli.h:44
struct unistim_line * lines
Definition: chan_unistim.c:473
const char * ast_inet_ntoa(struct in_addr ia)
thread-safe replacement for inet_ntoa().
Definition: utils.c:564
char * command
Definition: cli.h:180
static struct unistim_device * devices
struct sockaddr_in sin
Definition: chan_unistim.c:481
char fullname[80]
Definition: chan_unistim.c:389
char exten[AST_MAX_EXTENSION]
Definition: chan_unistim.c:393
const char * usage
Definition: cli.h:171
#define CLI_SUCCESS
Definition: cli.h:43
struct unistim_line * parent
Definition: chan_unistim.c:373
struct unistim_device * parent
Definition: chan_unistim.c:421
format_t capability
Definition: chan_unistim.c:417
#define ast_mutex_unlock(a)
Definition: lock.h:156
static struct ast_channel * unistim_new ( struct unistim_subchannel sub,
int  state,
const char *  linkedid 
)
static

Protos

Definition at line 4493 of file chan_unistim.c.

References unistim_line::accountcode, ast_channel::adsicpe, unistim_line::amaflags, AST_ADSI_UNAVAILABLE, ast_best_codec(), ast_callerid_parse(), ast_channel_alloc(), ast_free, ast_getformatname(), ast_getformatname_multiple(), ast_hangup(), ast_jb_configure(), ast_log(), ast_mutex_lock, ast_mutex_unlock, ast_pbx_start(), ast_rtp_instance_fd(), ast_setstate(), AST_STATE_DOWN, AST_STATE_RING, ast_strdup, ast_string_field_set, ast_strlen_zero(), ast_update_use_count(), ast_verb, unistim_device::call_forward, ast_channel::caller, unistim_line::callgroup, ast_channel::callgroup, CAPABILITY, unistim_line::capability, unistim_line::cid_num, unistim_line::context, unistim_line::exten, ast_channel::fds, global_jbconf, ast_party_caller::id, language, unistim_line::language, LOG_WARNING, name, ast_party_id::name, unistim_line::name, unistim_device::name, ast_channel::name, ast_channel::nativeformats, ast_party_id::number, unistim_subchannel::owner, unistim_subchannel::parent, unistim_line::parent, unistim_line::pickupgroup, ast_channel::pickupgroup, ast_channel::priority, ast_channel::rawreadformat, ast_channel::rawwriteformat, ast_channel::readformat, ast_channel::rings, unistim_subchannel::rtp, ast_party_name::str, ast_party_number::str, unistim_subchannel::subtype, ast_channel::tech, ast_channel::tech_pvt, unistim_tech, usecnt_lock, ast_party_name::valid, ast_party_number::valid, and ast_channel::writeformat.

Referenced by HandleCallOutgoing(), and unistim_request().

4494 {
4495  struct ast_channel *tmp;
4496  struct unistim_line *l;
4497  int fmt;
4498 
4499  if (!sub) {
4500  ast_log(LOG_WARNING, "subchannel null in unistim_new\n");
4501  return NULL;
4502  }
4503  if (!sub->parent) {
4504  ast_log(LOG_WARNING, "no line for subchannel %p\n", sub);
4505  return NULL;
4506  }
4507  l = sub->parent;
4508  tmp = ast_channel_alloc(1, state, l->cid_num, NULL, l->accountcode, l->exten,
4509  l->context, linkedid, l->amaflags, "%s@%s-%u", l->name, l->parent->name, sub->subtype);
4510  if (unistimdebug)
4511  ast_verb(0, "unistim_new sub=%u (%p) chan=%p\n", sub->subtype, sub, tmp);
4512  if (!tmp) {
4513  ast_log(LOG_WARNING, "Unable to allocate channel structure\n");
4514  return NULL;
4515  }
4516 
4517  tmp->nativeformats = l->capability;
4518  if (!tmp->nativeformats)
4519  tmp->nativeformats = CAPABILITY;
4520  fmt = ast_best_codec(tmp->nativeformats);
4521  if (unistimdebug) {
4522  char tmp1[256], tmp2[256], tmp3[256];
4523  ast_verb(0, "Best codec = %s from nativeformats %s (line cap=%s global=%s)\n",
4524  ast_getformatname(fmt),
4525  ast_getformatname_multiple(tmp1, sizeof(tmp1), tmp->nativeformats),
4526  ast_getformatname_multiple(tmp2, sizeof(tmp2), l->capability),
4527  ast_getformatname_multiple(tmp3, sizeof(tmp3), CAPABILITY));
4528  }
4529  if ((sub->rtp) && (sub->subtype == 0)) {
4530  if (unistimdebug)
4531  ast_verb(0, "New unistim channel with a previous rtp handle ?\n");
4532  tmp->fds[0] = ast_rtp_instance_fd(sub->rtp, 0);
4533  tmp->fds[1] = ast_rtp_instance_fd(sub->rtp, 1);
4534  }
4535  if (sub->rtp)
4537 
4538 /* tmp->type = type; */
4539  ast_setstate(tmp, state);
4540  if (state == AST_STATE_RING)
4541  tmp->rings = 1;
4543  tmp->writeformat = fmt;
4544  tmp->rawwriteformat = fmt;
4545  tmp->readformat = fmt;
4546  tmp->rawreadformat = fmt;
4547  tmp->tech_pvt = sub;
4548  tmp->tech = &unistim_tech;
4549  if (!ast_strlen_zero(l->language))
4551  sub->owner = tmp;
4553  usecnt++;
4556  tmp->callgroup = l->callgroup;
4557  tmp->pickupgroup = l->pickupgroup;
4558  ast_string_field_set(tmp, call_forward, l->parent->call_forward);
4559  if (!ast_strlen_zero(l->cid_num)) {
4560  char *name, *loc, *instr;
4561  instr = ast_strdup(l->cid_num);
4562  if (instr) {
4563  ast_callerid_parse(instr, &name, &loc);
4564  tmp->caller.id.number.valid = 1;
4565  ast_free(tmp->caller.id.number.str);
4566  tmp->caller.id.number.str = ast_strdup(loc);
4567  tmp->caller.id.name.valid = 1;
4568  ast_free(tmp->caller.id.name.str);
4569  tmp->caller.id.name.str = ast_strdup(name);
4570  ast_free(instr);
4571  }
4572  }
4573  tmp->priority = 1;
4574  if (state != AST_STATE_DOWN) {
4575  if (unistimdebug)
4576  ast_verb(0, "Starting pbx in unistim_new\n");
4577  if (ast_pbx_start(tmp)) {
4578  ast_log(LOG_WARNING, "Unable to start PBX on %s\n", tmp->name);
4579  ast_hangup(tmp);
4580  tmp = NULL;
4581  }
4582  }
4583 
4584  return tmp;
4585 }
struct ast_channel * owner
Definition: chan_unistim.c:371
char call_forward[AST_MAX_EXTENSION]
Definition: chan_unistim.c:461
int ast_hangup(struct ast_channel *chan)
Hang up a channel.
Definition: channel.c:2804
Main Channel structure associated with a channel.
Definition: channel.h:742
char * str
Subscriber phone number (Malloced)
Definition: channel.h:241
int rings
Definition: channel.h:840
struct ast_party_caller caller
Channel Caller ID information.
Definition: channel.h:804
char name[DEVICE_NAME_LEN]
Definition: chan_unistim.c:435
int priority
Definition: channel.h:841
unsigned int pickupgroup
Definition: chan_unistim.c:411
#define ast_strdup(a)
Definition: astmm.h:109
format_t writeformat
Definition: channel.h:854
struct ast_rtp_instance * rtp
Definition: chan_unistim.c:375
char language[MAX_LANGUAGE]
Definition: chan_unistim.c:397
struct ast_party_name name
Subscriber name.
Definition: channel.h:290
unsigned int callgroup
Definition: chan_unistim.c:409
void * tech_pvt
Definition: channel.h:744
#define LOG_WARNING
Definition: logger.h:144
enum ast_pbx_result ast_pbx_start(struct ast_channel *c)
Create a new thread and start the PBX.
Definition: pbx.c:5879
format_t rawwriteformat
Definition: channel.h:856
char * str
Subscriber name (Malloced)
Definition: channel.h:214
format_t ast_best_codec(format_t fmts)
Pick the best audio codec.
Definition: channel.c:1062
#define ast_mutex_lock(a)
Definition: lock.h:155
format_t nativeformats
Definition: channel.h:852
void ast_update_use_count(void)
Notify when usecount has been changed.
Definition: loader.c:1222
enum ast_channel_adsicpe adsicpe
Definition: channel.h:844
format_t rawreadformat
Definition: channel.h:855
ast_group_t pickupgroup
Definition: channel.h:819
#define ast_verb(level,...)
Definition: logger.h:243
ast_group_t callgroup
Definition: channel.h:818
struct ast_channel * ast_channel_alloc(int needqueue, int state, const char *cid_num, const char *cid_name, const char *acctcode, const char *exten, const char *context, const char *linkedid, const int amaflag, const char *name_fmt,...)
Definition: channel.c:9825
static int unistimdebug
Definition: chan_unistim.c:211
unsigned int subtype
Definition: chan_unistim.c:369
char accountcode[80]
Definition: chan_unistim.c:413
char name[80]
Definition: chan_unistim.c:387
struct ast_party_id id
Caller party ID.
Definition: channel.h:370
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition: strings.h:63
static char language[MAX_LANGUAGE]
Definition: chan_alsa.c:108
char cid_num[AST_MAX_EXTENSION]
Definition: chan_unistim.c:399
int fds[AST_MAX_FDS]
Definition: channel.h:829
static struct ast_jb_conf global_jbconf
Definition: chan_unistim.c:203
char * ast_getformatname(format_t format)
Get the name of a format.
Definition: frame.c:578
const ast_string_field name
Definition: channel.h:787
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
static const char name[]
#define ast_free(a)
Definition: astmm.h:97
int ast_rtp_instance_fd(struct ast_rtp_instance *instance, int rtcp)
Get the file descriptor for an RTP session (or RTCP)
Definition: rtp_engine.c:786
char context[AST_MAX_EXTENSION]
Definition: chan_unistim.c:395
char exten[AST_MAX_EXTENSION]
Definition: chan_unistim.c:393
void ast_jb_configure(struct ast_channel *chan, const struct ast_jb_conf *conf)
Configures a jitterbuffer on a channel.
Definition: abstract_jb.c:616
format_t readformat
Definition: channel.h:853
struct unistim_line * parent
Definition: chan_unistim.c:373
int ast_setstate(struct ast_channel *chan, enum ast_channel_state)
Change the state of a channel.
Definition: channel.c:7119
char * ast_getformatname_multiple(char *buf, size_t size, format_t format)
Get the names of a set of formats.
Definition: frame.c:591
struct unistim_device * parent
Definition: chan_unistim.c:421
static ast_mutex_t usecnt_lock
Definition: chan_unistim.c:235
unsigned char valid
TRUE if the name information is valid/present.
Definition: channel.h:229
#define CAPABILITY
Definition: chan_unistim.c:78
struct ast_channel_tech * tech
Definition: channel.h:743
static int usecnt
Definition: chan_unistim.c:236
unsigned char valid
TRUE if the number information is valid/present.
Definition: channel.h:247
format_t capability
Definition: chan_unistim.c:417
static struct ast_channel_tech unistim_tech
Definition: chan_unistim.c:706
#define ast_mutex_unlock(a)
Definition: lock.h:156
int ast_callerid_parse(char *instr, char **name, char **location)
Destructively parse inbuf into name and location (or number)
Definition: callerid.c:1009
#define ast_string_field_set(x, field, data)
Set a field to a simple string value.
Definition: stringfields.h:344
struct ast_party_number number
Subscriber phone number.
Definition: channel.h:292
static struct ast_frame * unistim_read ( struct ast_channel ast)
static

Definition at line 4013 of file chan_unistim.c.

References ast_mutex_lock, ast_mutex_unlock, unistim_subchannel::lock, ast_channel::tech_pvt, and unistim_rtp_read().

4014 {
4015  struct ast_frame *fr;
4016  struct unistim_subchannel *sub = ast->tech_pvt;
4017 
4018  ast_mutex_lock(&sub->lock);
4019  fr = unistim_rtp_read(ast, sub);
4020  ast_mutex_unlock(&sub->lock);
4021 
4022  return fr;
4023 }
ast_mutex_t lock
Definition: chan_unistim.c:367
static struct ast_frame * unistim_rtp_read(const struct ast_channel *ast, const struct unistim_subchannel *sub)
void * tech_pvt
Definition: channel.h:744
#define ast_mutex_lock(a)
Definition: lock.h:155
Data structure associated with a single frame of data.
Definition: frame.h:142
#define ast_mutex_unlock(a)
Definition: lock.h:156
static int unistim_register ( struct unistimsession s)
static

Definition at line 1465 of file chan_unistim.c.

References ast_mutex_lock, ast_mutex_unlock, unistim_device::codec_number, DEFAULT_CODEC, unistimsession::device, devicelock, devices, unistim_device::id, unistimsession::macaddr, unistim_device::missed_call, unistim_device::next, unistim_device::pos_fav, unistim_device::receiver_state, unistim_device::session, and STATE_ONHOOK.

Referenced by rcv_mac_addr().

1466 {
1467  struct unistim_device *d;
1468 
1470  d = devices;
1471  while (d) {
1472  if (!strcasecmp(s->macaddr, d->id)) {
1473  /* XXX Deal with IP authentication */
1474  s->device = d;
1475  d->session = s;
1477  d->pos_fav = 0;
1478  d->missed_call = 0;
1480  break;
1481  }
1482  d = d->next;
1483  }
1485 
1486  if (!d)
1487  return 0;
1488 
1489  return 1;
1490 }
A device containing one or more lines.
Definition: chan_unistim.c:427
#define ast_mutex_lock(a)
Definition: lock.h:155
struct unistim_device * device
Definition: chan_unistim.c:496
static ast_mutex_t devicelock
Definition: chan_unistim.c:249
char macaddr[18]
Definition: chan_unistim.c:493
#define DEFAULT_CODEC
Definition: chan_unistim.c:99
struct unistim_device * next
Definition: chan_unistim.c:476
struct unistimsession * session
Definition: chan_unistim.c:475
static struct unistim_device * devices
#define ast_mutex_unlock(a)
Definition: lock.h:156
static char* unistim_reload ( struct ast_cli_entry e,
int  cmd,
struct ast_cli_args a 
)
static

— 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

Definition at line 4916 of file chan_unistim.c.

References ast_cli_args::argc, ast_cli_entry::args, ast_mutex_lock, ast_mutex_unlock, ast_verb, CLI_GENERATE, CLI_INIT, CLI_SHOWUSAGE, CLI_SUCCESS, ast_cli_entry::command, restart_monitor(), unistim_reload_lock, and ast_cli_entry::usage.

Referenced by reload().

4917 {
4918  switch (cmd) {
4919  case CLI_INIT:
4920  e->command = "unistim reload";
4921  e->usage =
4922  "Usage: unistim reload\n"
4923  " Reloads UNISTIM configuration from unistim.conf\n";
4924  return NULL;
4925 
4926  case CLI_GENERATE:
4927  return NULL; /* no completion */
4928  }
4929 
4930  if (e && a && a->argc != e->args)
4931  return CLI_SHOWUSAGE;
4932 
4933  if (unistimdebug)
4934  ast_verb(0, "reload unistim\n");
4935 
4937  if (!unistim_reloading)
4938  unistim_reloading = 1;
4940 
4941  restart_monitor();
4942 
4943  return CLI_SUCCESS;
4944 }
const int argc
Definition: cli.h:154
Definition: cli.h:146
#define ast_mutex_lock(a)
Definition: lock.h:155
#define ast_verb(level,...)
Definition: logger.h:243
static int unistimdebug
Definition: chan_unistim.c:211
int args
This gets set in ast_cli_register()
Definition: cli.h:179
#define CLI_SHOWUSAGE
Definition: cli.h:44
char * command
Definition: cli.h:180
static int unistim_reloading
Definition: chan_unistim.c:233
const char * usage
Definition: cli.h:171
#define CLI_SUCCESS
Definition: cli.h:43
static int restart_monitor(void)
static ast_mutex_t unistim_reload_lock
Definition: chan_unistim.c:234
#define ast_mutex_unlock(a)
Definition: lock.h:156
static struct ast_channel * unistim_request ( const char *  type,
format_t  format,
const struct ast_channel requestor,
void *  data,
int *  cause 
)
static

Definition at line 4697 of file chan_unistim.c.

References AST_CAUSE_BUSY, AST_CAUSE_CONGESTION, ast_copy_string(), ast_getformatname(), ast_getformatname_multiple(), ast_log(), AST_STATE_DOWN, ast_strlen_zero(), ast_verb, CAPABILITY, unistim_line::capability, ast_channel::data, find_subchannel_by_name(), format, ast_channel::linkedid, LOG_NOTICE, LOG_WARNING, unistim_subchannel::owner, unistim_subchannel::parent, restart_monitor(), and unistim_new().

4699 {
4700  format_t oldformat;
4701  struct unistim_subchannel *sub;
4702  struct ast_channel *tmpc = NULL;
4703  char tmp[256];
4704  char *dest = data;
4705 
4706  oldformat = format;
4707  format &= CAPABILITY;
4709  "Asked to get a channel of format %s while capability is %s result : %s\n",
4710  ast_getformatname(oldformat),
4711  ast_getformatname_multiple(tmp, sizeof(tmp), CAPABILITY),
4713  if (!format) {
4715  "Asked to get a channel of unsupported format %s while capability is %s\n",
4716  ast_getformatname(oldformat), ast_getformatname_multiple(tmp, sizeof(tmp), CAPABILITY));
4717  return NULL;
4718  }
4719 
4720  ast_copy_string(tmp, dest, sizeof(tmp));
4721  if (ast_strlen_zero(tmp)) {
4722  ast_log(LOG_NOTICE, "Unistim channels require a device\n");
4723  return NULL;
4724  }
4725 
4726  sub = find_subchannel_by_name(tmp);
4727  if (!sub) {
4728  ast_log(LOG_NOTICE, "No available lines on: %s\n", dest);
4729  *cause = AST_CAUSE_CONGESTION;
4730  return NULL;
4731  }
4732 
4733  ast_verb(3, "unistim_request(%s)\n", tmp);
4734  /* Busy ? */
4735  if (sub->owner) {
4736  if (unistimdebug)
4737  ast_verb(0, "Can't create channel : Busy !\n");
4738  *cause = AST_CAUSE_BUSY;
4739  return NULL;
4740  }
4741  sub->parent->capability = format;
4742  tmpc = unistim_new(sub, AST_STATE_DOWN, requestor ? requestor->linkedid : NULL);
4743  if (!tmpc)
4744  ast_log(LOG_WARNING, "Unable to make channel for '%s'\n", tmp);
4745  if (unistimdebug)
4746  ast_verb(0, "unistim_request owner = %p\n", sub->owner);
4747  restart_monitor();
4748 
4749  /* and finish */
4750  return tmpc;
4751 }
struct ast_channel * owner
Definition: chan_unistim.c:371
Main Channel structure associated with a channel.
Definition: channel.h:742
static struct ast_channel * unistim_new(struct unistim_subchannel *sub, int state, const char *linkedid)
#define LOG_WARNING
Definition: logger.h:144
const char * data
Definition: channel.h:755
const ast_string_field linkedid
Definition: channel.h:787
#define ast_verb(level,...)
Definition: logger.h:243
static int unistimdebug
Definition: chan_unistim.c:211
static struct unistim_subchannel * find_subchannel_by_name(const char *dest)
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition: strings.h:63
char * ast_getformatname(format_t format)
Get the name of a format.
Definition: frame.c:578
int64_t format_t
Definition: frame_defs.h:32
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
#define LOG_NOTICE
Definition: logger.h:133
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:223
struct unistim_line * parent
Definition: chan_unistim.c:373
#define AST_CAUSE_BUSY
Definition: causes.h:148
char * ast_getformatname_multiple(char *buf, size_t size, format_t format)
Get the names of a set of formats.
Definition: frame.c:591
static int restart_monitor(void)
#define CAPABILITY
Definition: chan_unistim.c:78
static snd_pcm_format_t format
Definition: chan_alsa.c:93
#define AST_CAUSE_CONGESTION
Definition: causes.h:152
format_t capability
Definition: chan_unistim.c:417
static struct ast_frame* unistim_rtp_read ( const struct ast_channel ast,
const struct unistim_subchannel sub 
)
static

Definition at line 3966 of file chan_unistim.c.

References ast_debug, AST_FRAME_VOICE, ast_getformatname(), ast_log(), ast_null_frame, ast_rtp_instance_read(), ast_set_read_format(), ast_set_write_format(), ast_frame_subclass::codec, f, ast_channel::fdno, ast_frame::frametype, LOG_WARNING, ast_channel::nativeformats, unistim_subchannel::owner, ast_channel::readformat, unistim_subchannel::rtp, ast_frame::subclass, unistim_subchannel::subtype, and ast_channel::writeformat.

Referenced by unistim_read().

3968 {
3969  /* Retrieve audio/etc from channel. Assumes sub->lock is already held. */
3970  struct ast_frame *f;
3971 
3972  if (!ast) {
3973  ast_log(LOG_WARNING, "Channel NULL while reading\n");
3974  return &ast_null_frame;
3975  }
3976 
3977  if (!sub->rtp) {
3978  ast_log(LOG_WARNING, "RTP handle NULL while reading on subchannel %u\n",
3979  sub->subtype);
3980  return &ast_null_frame;
3981  }
3982 
3983  switch (ast->fdno) {
3984  case 0:
3985  f = ast_rtp_instance_read(sub->rtp, 0); /* RTP Audio */
3986  break;
3987  case 1:
3988  f = ast_rtp_instance_read(sub->rtp, 1); /* RTCP Control Channel */
3989  break;
3990  default:
3991  f = &ast_null_frame;
3992  }
3993 
3994  if (sub->owner) {
3995  /* We already hold the channel lock */
3996  if (f->frametype == AST_FRAME_VOICE) {
3997  if (f->subclass.codec != sub->owner->nativeformats) {
3998  ast_debug(1,
3999  "Oooh, format changed from %s to %s\n",
4002 
4003  sub->owner->nativeformats = f->subclass.codec;
4006  }
4007  }
4008  }
4009 
4010  return f;
4011 }
struct ast_channel * owner
Definition: chan_unistim.c:371
union ast_frame_subclass subclass
Definition: frame.h:146
struct ast_frame ast_null_frame
Definition: frame.c:131
format_t writeformat
Definition: channel.h:854
struct ast_rtp_instance * rtp
Definition: chan_unistim.c:375
#define LOG_WARNING
Definition: logger.h:144
format_t nativeformats
Definition: channel.h:852
format_t codec
Definition: frame.h:137
unsigned int subtype
Definition: chan_unistim.c:369
int ast_set_write_format(struct ast_channel *chan, format_t format)
Sets write format on channel chan Set write format for channel to whichever component of &quot;format&quot; is ...
Definition: channel.c:5307
int ast_set_read_format(struct ast_channel *chan, format_t format)
Sets read format on channel chan Set read format for channel to whichever component of &quot;format&quot; is be...
Definition: channel.c:5301
#define ast_debug(level,...)
Log a DEBUG message.
Definition: logger.h:236
char * ast_getformatname(format_t format)
Get the name of a format.
Definition: frame.c:578
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
int fdno
Definition: channel.h:834
static struct ast_format f[]
Definition: format_g726.c:181
format_t readformat
Definition: channel.h:853
Data structure associated with a single frame of data.
Definition: frame.h:142
enum ast_frame_type frametype
Definition: frame.h:144
struct ast_frame * ast_rtp_instance_read(struct ast_rtp_instance *instance, int rtcp)
Receive a frame over RTP.
Definition: rtp_engine.c:379
static int unistim_send_mwi_to_peer ( struct unistimsession s,
unsigned int  tick 
)
static

Definition at line 4450 of file chan_unistim.c.

References ast_app_has_voicemail(), ast_event_destroy(), ast_event_get_cached(), ast_event_get_ie_uint(), AST_EVENT_IE_CONTEXT, AST_EVENT_IE_END, AST_EVENT_IE_MAILBOX, AST_EVENT_IE_NEWMSGS, AST_EVENT_IE_PLTYPE_STR, AST_EVENT_MWI, ast_strdupa, ast_strlen_zero(), context, unistimsession::device, unistim_line::lastmsgssent, unistim_device::lines, mailbox, unistim_line::mailbox, unistim_line::nextmsgcheck, send_led_update(), strsep(), and TIMER_MWI.

Referenced by do_monitor().

4451 {
4452  struct ast_event *event;
4453  int new;
4454  char *mailbox, *context;
4455  struct unistim_line *peer = s->device->lines;
4456 
4457  context = mailbox = ast_strdupa(peer->mailbox);
4458  strsep(&context, "@");
4459  if (ast_strlen_zero(context))
4460  context = "default";
4461 
4466 
4467  if (event) {
4469  ast_event_destroy(event);
4470  } else { /* Fall back on checking the mailbox directly */
4471  new = ast_app_has_voicemail(peer->mailbox, "INBOX");
4472  }
4473 
4474  peer->nextmsgcheck = tick + TIMER_MWI;
4475 
4476  /* Return now if it's the same thing we told them last time */
4477  if (new == peer->lastmsgssent) {
4478  return 0;
4479  }
4480 
4481  peer->lastmsgssent = new;
4482  if (new == 0) {
4483  send_led_update(s, 0);
4484  } else {
4485  send_led_update(s, 1);
4486  }
4487 
4488  return 0;
4489 }
#define TIMER_MWI
Definition: chan_unistim.c:97
An event.
Definition: event.c:85
char * strsep(char **str, const char *delims)
int ast_app_has_voicemail(const char *mailbox, const char *folder)
Determine if a given mailbox has any voicemail If folder is NULL, defaults to &quot;INBOX&quot;. If folder is &quot;INBOX&quot;, includes the number of messages in the &quot;Urgent&quot; folder.
Definition: app.c:421
struct ast_event * ast_event_get_cached(enum ast_event_type,...)
Retrieve an event from the cache.
Definition: event.c:1342
Number of new messages Used by: AST_EVENT_MWI Payload type: UINT.
Definition: event_defs.h:71
struct unistim_device * device
Definition: chan_unistim.c:496
Context IE Used by AST_EVENT_MWI Payload type: str.
Definition: event_defs.h:121
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition: strings.h:63
char mailbox[AST_MAX_EXTENSION]
Definition: chan_unistim.c:401
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: utils.h:663
time_t nextmsgcheck
Definition: chan_unistim.c:405
struct unistim_line * lines
Definition: chan_unistim.c:473
static void send_led_update(struct unistimsession *pte, unsigned char led)
uint32_t ast_event_get_ie_uint(const struct ast_event *event, enum ast_event_ie_type ie_type)
Get the value of an information element that has an integer payload.
Definition: event.c:1075
void ast_event_destroy(struct ast_event *event)
Destroy an event.
Definition: event.c:1314
static char context[AST_MAX_CONTEXT]
Definition: chan_alsa.c:107
static char mailbox[AST_MAX_EXTENSION]
Definition: chan_mgcp.c:197
Mailbox name.
Definition: event_defs.h:83
static int unistim_senddigit_begin ( struct ast_channel ast,
char  digit 
)
static

Definition at line 4276 of file chan_unistim.c.

References channel_to_session(), and unistim_do_senddigit().

4277 {
4278  struct unistimsession *pte = channel_to_session(ast);
4279 
4280  if (!pte)
4281  return -1;
4282 
4283  return unistim_do_senddigit(pte, digit);
4284 }
static int unistim_do_senddigit(struct unistimsession *pte, char digit)
static struct unistimsession * channel_to_session(struct ast_channel *ast)
static int unistim_senddigit_end ( struct ast_channel ast,
char  digit,
unsigned int  duration 
)
static

Definition at line 4286 of file chan_unistim.c.

References unistim_subchannel::alreadygone, AST_FRAME_DTMF, ast_log(), ast_queue_frame(), ast_verb, channel_to_session(), unistimsession::device, ast_frame::frametype, ast_frame_subclass::integer, unistim_device::lines, LOG_WARNING, unistim_subchannel::owner, send_tone(), ast_frame::src, SUB_REAL, ast_frame::subclass, and unistim_line::subs.

4287 {
4288  struct unistimsession *pte = channel_to_session(ast);
4289  struct ast_frame f = { 0, };
4290  struct unistim_subchannel *sub;
4291 
4292  sub = pte->device->lines->subs[SUB_REAL];
4293 
4294  if (!sub->owner || sub->alreadygone) {
4295  ast_log(LOG_WARNING, "Unable to find subchannel in dtmf senddigit_end\n");
4296  return -1;
4297  }
4298 
4299  if (unistimdebug)
4300  ast_verb(0, "Send Digit off %c\n", digit);
4301 
4302  if (!pte)
4303  return -1;
4304 
4305  send_tone(pte, 0, 0);
4307  f.subclass.integer = digit;
4308  f.src = "unistim";
4309  ast_queue_frame(sub->owner, &f);
4310 
4311  return 0;
4312 }
struct ast_channel * owner
Definition: chan_unistim.c:371
union ast_frame_subclass subclass
Definition: frame.h:146
#define LOG_WARNING
Definition: logger.h:144
#define AST_FRAME_DTMF
Definition: frame.h:128
#define ast_verb(level,...)
Definition: logger.h:243
struct unistim_subchannel * subs[MAX_SUBS]
Definition: chan_unistim.c:391
static int unistimdebug
Definition: chan_unistim.c:211
struct unistim_device * device
Definition: chan_unistim.c:496
static void send_tone(struct unistimsession *pte, uint16_t tone1, uint16_t tone2)
Definition: chan_unistim.c:983
const char * src
Definition: frame.h:158
int ast_queue_frame(struct ast_channel *chan, struct ast_frame *f)
Queue one or more frames to a channel&#39;s frame queue.
Definition: channel.c:1558
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
struct unistim_line * lines
Definition: chan_unistim.c:473
static struct ast_format f[]
Definition: format_g726.c:181
#define SUB_REAL
Definition: chan_unistim.c:105
Data structure associated with a single frame of data.
Definition: frame.h:142
enum ast_frame_type frametype
Definition: frame.h:144
static struct unistimsession * channel_to_session(struct ast_channel *ast)
static int unistim_sendtext ( struct ast_channel ast,
const char *  text 
)
static

Definition at line 4316 of file chan_unistim.c.

References ast_log(), ast_verb, channel_to_session(), unistimsession::device, unistim_device::height, LOG_WARNING, send_favorite(), send_text(), unistim_device::softkeyicon, unistim_device::softkeylabel, unistim_device::softkeynumber, TEXT_LENGTH_MAX, TEXT_LINE0, TEXT_LINE1, TEXT_LINE2, and TEXT_NORMAL.

4317 {
4318  struct unistimsession *pte = channel_to_session(ast);
4319  int size;
4320  char tmp[TEXT_LENGTH_MAX + 1];
4321 
4322  if (unistimdebug)
4323  ast_verb(0, "unistim_sendtext called\n");
4324 
4325  if (!text) {
4326  ast_log(LOG_WARNING, "unistim_sendtext called with a null text\n");
4327  return 1;
4328  }
4329 
4330  size = strlen(text);
4331  if (text[0] == '@') {
4332  int pos = 0, i = 1, tok = 0, sz = 0;
4333  char label[11];
4334  char number[16];
4335  char icon = '\0';
4336  char cur = '\0';
4337 
4338  memset(label, 0, 11);
4339  memset(number, 0, 16);
4340  while (text[i]) {
4341  cur = text[i++];
4342  switch (tok) {
4343  case 0:
4344  if ((cur < '0') && (cur > '5')) {
4346  "sendtext failed : position must be a number beetween 0 and 5\n");
4347  return 1;
4348  }
4349  pos = cur - '0';
4350  tok = 1;
4351  continue;
4352  case 1:
4353  if (cur != '@') {
4354  ast_log(LOG_WARNING, "sendtext failed : invalid position\n");
4355  return 1;
4356  }
4357  tok = 2;
4358  continue;
4359  case 2:
4360  if ((cur < '3') && (cur > '6')) {
4362  "sendtext failed : icon must be a number beetween 32 and 63 (first digit invalid)\n");
4363  return 1;
4364  }
4365  icon = (cur - '0') * 10;
4366  tok = 3;
4367  continue;
4368  case 3:
4369  if ((cur < '0') && (cur > '9')) {
4371  "sendtext failed : icon must be a number beetween 32 and 63 (second digit invalid)\n");
4372  return 1;
4373  }
4374  icon += (cur - '0');
4375  tok = 4;
4376  continue;
4377  case 4:
4378  if (cur != '@') {
4380  "sendtext failed : icon must be a number beetween 32 and 63 (too many digits)\n");
4381  return 1;
4382  }
4383  tok = 5;
4384  continue;
4385  case 5:
4386  if (cur == '@') {
4387  tok = 6;
4388  sz = 0;
4389  continue;
4390  }
4391  if (sz > 10)
4392  continue;
4393  label[sz] = cur;
4394  sz++;
4395  continue;
4396  case 6:
4397  if (sz > 15) {
4399  "sendtext failed : extension too long = %d (15 car max)\n",
4400  sz);
4401  return 1;
4402  }
4403  number[sz] = cur;
4404  sz++;
4405  continue;
4406  }
4407  }
4408  if (tok != 6) {
4409  ast_log(LOG_WARNING, "sendtext failed : incomplet command\n");
4410  return 1;
4411  }
4412  if (!pte->device) {
4413  ast_log(LOG_WARNING, "sendtext failed : no device ?\n");
4414  return 1;
4415  }
4416  strcpy(pte->device->softkeylabel[pos], label);
4417  strcpy(pte->device->softkeynumber[pos], number);
4418  pte->device->softkeyicon[pos] = icon;
4419  send_favorite(pos, icon, pte, label);
4420  return 0;
4421  }
4422 
4423  if (size <= TEXT_LENGTH_MAX * 2) {
4424  if (pte->device->height == 1) {
4426  } else {
4427  send_text(TEXT_LINE0, TEXT_NORMAL, pte, "Message :");
4429  }
4430  if (size <= TEXT_LENGTH_MAX) {
4431  send_text(TEXT_LINE2, TEXT_NORMAL, pte, "");
4432  return 0;
4433  }
4434  memcpy(tmp, text + TEXT_LENGTH_MAX, TEXT_LENGTH_MAX);
4435  tmp[sizeof(tmp) - 1] = '\0';
4436  send_text(TEXT_LINE2, TEXT_NORMAL, pte, tmp);
4437  return 0;
4438  }
4440  memcpy(tmp, text + TEXT_LENGTH_MAX, TEXT_LENGTH_MAX);
4441  tmp[sizeof(tmp) - 1] = '\0';
4442  send_text(TEXT_LINE1, TEXT_NORMAL, pte, tmp);
4443  memcpy(tmp, text + TEXT_LENGTH_MAX * 2, TEXT_LENGTH_MAX);
4444  tmp[sizeof(tmp) - 1] = '\0';
4445  send_text(TEXT_LINE2, TEXT_NORMAL, pte, tmp);
4446  return 0;
4447 }
char softkeynumber[6][16]
Definition: chan_unistim.c:438
#define TEXT_LINE2
Definition: chan_unistim.c:144
#define TEXT_LINE1
Definition: chan_unistim.c:143
#define LOG_WARNING
Definition: logger.h:144
char * text
Definition: app_queue.c:1091
#define TEXT_NORMAL
Definition: chan_unistim.c:145
#define ast_verb(level,...)
Definition: logger.h:243
#define TEXT_LENGTH_MAX
Definition: chan_unistim.c:141
static int unistimdebug
Definition: chan_unistim.c:211
struct unistim_device * device
Definition: chan_unistim.c:496
Number structure.
Definition: app_followme.c:109
char softkeylabel[6][11]
Definition: chan_unistim.c:437
#define TEXT_LINE0
Definition: chan_unistim.c:142
static void send_favorite(unsigned char pos, unsigned char status, struct unistimsession *pte, const char *text)
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
static void send_text(unsigned char pos, unsigned char inverse, struct unistimsession *pte, const char *text)
static struct unistimsession * channel_to_session(struct ast_channel *ast)
char softkeyicon[6]
Definition: chan_unistim.c:439
static int unistim_set_rtp_peer ( struct ast_channel chan,
struct ast_rtp_instance rtp,
struct ast_rtp_instance vrtp,
struct ast_rtp_instance trtp,
format_t  codecs,
int  nat_active 
)
static

Definition at line 5631 of file chan_unistim.c.

References ast_log(), ast_rtp_instance_get_local_address(), ast_rtp_instance_get_remote_address(), ast_sockaddr_to_sin, LOG_ERROR, and ast_channel::tech_pvt.

5632 {
5633  struct unistim_subchannel *sub;
5634  struct sockaddr_in them = { 0, };
5635  struct sockaddr_in us = { 0, };
5636 
5637  if (!rtp) {
5638  return 0;
5639  }
5640 
5641  sub = chan->tech_pvt;
5642  if (!sub) {
5643  ast_log(LOG_ERROR, "No Private Structure, this is bad\n");
5644  return -1;
5645  }
5646  {
5647  struct ast_sockaddr tmp;
5649  ast_sockaddr_to_sin(&tmp, &them);
5651  ast_sockaddr_to_sin(&tmp, &us);
5652  }
5653 
5654  /* TODO: Set rtp on phone in case of direct rtp (not implemented) */
5655 
5656  return 0;
5657 }
void * tech_pvt
Definition: channel.h:744
Socket address structure.
Definition: netsock2.h:63
#define LOG_ERROR
Definition: logger.h:155
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
void ast_rtp_instance_get_remote_address(struct ast_rtp_instance *instance, struct ast_sockaddr *address)
Get the address of the remote endpoint that we are sending RTP to.
Definition: rtp_engine.c:447
void ast_rtp_instance_get_local_address(struct ast_rtp_instance *instance, struct ast_sockaddr *address)
Get the local address that we are expecting RTP on.
Definition: rtp_engine.c:430
#define ast_sockaddr_to_sin(addr, sin)
Converts a struct ast_sockaddr to a struct sockaddr_in.
Definition: netsock2.h:629
static char* unistim_sp ( struct ast_cli_entry e,
int  cmd,
struct ast_cli_args a 
)
static

Definition at line 4823 of file chan_unistim.c.

References ast_cli_args::argc, ast_cli_args::argv, ast_cli(), ast_copy_string(), BUFFSEND, CLI_GENERATE, CLI_INIT, CLI_SHOWUSAGE, CLI_SUCCESS, ast_cli_entry::command, ast_cli_args::fd, find_subchannel_by_name(), len(), unistim_subchannel::parent, unistim_line::parent, send_client(), unistim_device::session, SIZE_HEADER, and ast_cli_entry::usage.

4824 {
4825  BUFFSEND;
4826  struct unistim_subchannel *sub;
4827  int i, j = 0, len;
4828  unsigned char c, cc;
4829  char tmp[256];
4830 
4831  switch (cmd) {
4832  case CLI_INIT:
4833  e->command = "unistim send packet";
4834  e->usage =
4835  "Usage: unistim send packet USTM/line@name hexa\n"
4836  " unistim send packet USTM/1000@hans 19040004\n";
4837  return NULL;
4838 
4839  case CLI_GENERATE:
4840  return NULL; /* no completion */
4841  }
4842 
4843  if (a->argc < 5)
4844  return CLI_SHOWUSAGE;
4845 
4846  if (strlen(a->argv[3]) < 9)
4847  return CLI_SHOWUSAGE;
4848 
4849  len = strlen(a->argv[4]);
4850  if (len % 2)
4851  return CLI_SHOWUSAGE;
4852 
4853  ast_copy_string(tmp, a->argv[3] + 5, sizeof(tmp));
4854  sub = find_subchannel_by_name(tmp);
4855  if (!sub) {
4856  ast_cli(a->fd, "Can't find '%s'\n", tmp);
4857  return CLI_SUCCESS;
4858  }
4859  if (!sub->parent->parent->session) {
4860  ast_cli(a->fd, "'%s' is not connected\n", tmp);
4861  return CLI_SUCCESS;
4862  }
4863  ast_cli(a->fd, "Sending '%s' to %s (%p)\n", a->argv[4], tmp, sub->parent->parent->session);
4864  for (i = 0; i < len; i++) {
4865  c = a->argv[4][i];
4866  if (c >= 'a')
4867  c -= 'a' - 10;
4868  else
4869  c -= '0';
4870  i++;
4871  cc = a->argv[4][i];
4872  if (cc >= 'a')
4873  cc -= 'a' - 10;
4874  else
4875  cc -= '0';
4876  tmp[j++] = (c << 4) | cc;
4877  }
4878  memcpy(buffsend + SIZE_HEADER, tmp, j);
4879  send_client(SIZE_HEADER + j, buffsend, sub->parent->parent->session);
4880  return CLI_SUCCESS;
4881 }
static void send_client(int size, const unsigned char *data, struct unistimsession *pte)
Definition: chan_unistim.c:801
const int argc
Definition: cli.h:154
Definition: cli.h:146
#define BUFFSEND
Definition: chan_unistim.c:675
void ast_cli(int fd, const char *fmt,...)
Definition: cli.c:105
static struct unistim_subchannel * find_subchannel_by_name(const char *dest)
const int fd
Definition: cli.h:153
#define SIZE_HEADER
Definition: chan_unistim.c:139
struct unistimsession * session
Definition: chan_unistim.c:475
const char *const * argv
Definition: cli.h:155
#define CLI_SHOWUSAGE
Definition: cli.h:44
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
char * command
Definition: cli.h:180
const char * usage
Definition: cli.h:171
#define CLI_SUCCESS
Definition: cli.h:43
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:223
struct unistim_line * parent
Definition: chan_unistim.c:373
struct unistim_device * parent
Definition: chan_unistim.c:421
static void* unistim_ss ( void *  data)
static

Definition at line 2003 of file chan_unistim.c.

References ast_copy_string(), ast_log(), ast_pbx_run(), ast_setstate(), AST_STATE_RING, ast_verb, ast_channel::data, unistimsession::device, ast_channel::exten, LOG_WARNING, unistim_line::name, unistim_device::name, unistim_subchannel::parent, unistim_line::parent, unistim_device::phone_number, unistim_device::redial_number, send_tone(), unistim_device::session, unistim_subchannel::subtype, and ast_channel::tech_pvt.

Referenced by HandleCallOutgoing().

2004 {
2005  struct ast_channel *chan = data;
2006  struct unistim_subchannel *sub = chan->tech_pvt;
2007  struct unistim_line *l = sub->parent;
2008  struct unistimsession *s = l->parent->session;
2009  int res;
2010 
2011  ast_verb(3, "Starting switch on '%s@%s-%u' to %s\n", l->name, l->parent->name, sub->subtype, s->device->phone_number);
2012  ast_copy_string(chan->exten, s->device->phone_number, sizeof(chan->exten));
2014  sizeof(s->device->redial_number));
2016  res = ast_pbx_run(chan);
2017  if (res) {
2018  ast_log(LOG_WARNING, "PBX exited non-zero\n");
2019  send_tone(s, 1000, 0);;
2020  }
2021  return NULL;
2022 }
Main Channel structure associated with a channel.
Definition: channel.h:742
char name[DEVICE_NAME_LEN]
Definition: chan_unistim.c:435
void * tech_pvt
Definition: channel.h:744
#define LOG_WARNING
Definition: logger.h:144
char phone_number[16]
Definition: chan_unistim.c:430
const char * data
Definition: channel.h:755
#define ast_verb(level,...)
Definition: logger.h:243
struct unistim_device * device
Definition: chan_unistim.c:496
unsigned int subtype
Definition: chan_unistim.c:369
char name[80]
Definition: chan_unistim.c:387
static void send_tone(struct unistimsession *pte, uint16_t tone1, uint16_t tone2)
Definition: chan_unistim.c:983
struct unistimsession * session
Definition: chan_unistim.c:475
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
char redial_number[16]
Definition: chan_unistim.c:431
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:223
struct unistim_line * parent
Definition: chan_unistim.c:373
int ast_setstate(struct ast_channel *chan, enum ast_channel_state)
Change the state of a channel.
Definition: channel.c:7119
enum ast_pbx_result ast_pbx_run(struct ast_channel *c)
Execute the PBX in the current thread.
Definition: pbx.c:5926
struct unistim_device * parent
Definition: chan_unistim.c:421
char exten[AST_MAX_EXTENSION]
Definition: channel.h:869
static int unistim_write ( struct ast_channel ast,
struct ast_frame frame 
)
static

Definition at line 4025 of file chan_unistim.c.

References AST_FRAME_IMAGE, AST_FRAME_VOICE, ast_getformatname(), ast_getformatname_multiple(), ast_log(), ast_mutex_lock, ast_mutex_unlock, ast_rtp_instance_write(), ast_frame_subclass::codec, ast_frame::frametype, unistim_subchannel::lock, LOG_WARNING, ast_channel::nativeformats, ast_channel::readformat, unistim_subchannel::rtp, ast_frame::subclass, ast_channel::tech_pvt, and ast_channel::writeformat.

4026 {
4027  struct unistim_subchannel *sub = ast->tech_pvt;
4028  int res = 0;
4029 
4030  if (frame->frametype != AST_FRAME_VOICE) {
4031  if (frame->frametype == AST_FRAME_IMAGE)
4032  return 0;
4033  else {
4034  ast_log(LOG_WARNING, "Can't send %u type frames with unistim_write\n",
4035  frame->frametype);
4036  return 0;
4037  }
4038  } else {
4039  if (!(frame->subclass.codec & ast->nativeformats)) {
4040  char tmp[256];
4042  "Asked to transmit frame type %s, while native formats is %s (read/write = (%s/%s)\n",
4044  ast_getformatname_multiple(tmp, sizeof(tmp), ast->nativeformats),
4047  return -1;
4048  }
4049  }
4050 
4051  if (sub) {
4052  ast_mutex_lock(&sub->lock);
4053  if (sub->rtp) {
4054  res = ast_rtp_instance_write(sub->rtp, frame);
4055  }
4056  ast_mutex_unlock(&sub->lock);
4057  }
4058 
4059  return res;
4060 }
ast_mutex_t lock
Definition: chan_unistim.c:367
union ast_frame_subclass subclass
Definition: frame.h:146
format_t writeformat
Definition: channel.h:854
struct ast_rtp_instance * rtp
Definition: chan_unistim.c:375
void * tech_pvt
Definition: channel.h:744
#define LOG_WARNING
Definition: logger.h:144
int ast_rtp_instance_write(struct ast_rtp_instance *instance, struct ast_frame *frame)
Send a frame out over RTP.
Definition: rtp_engine.c:374
#define ast_mutex_lock(a)
Definition: lock.h:155
format_t nativeformats
Definition: channel.h:852
format_t codec
Definition: frame.h:137
char * ast_getformatname(format_t format)
Get the name of a format.
Definition: frame.c:578
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
format_t readformat
Definition: channel.h:853
char * ast_getformatname_multiple(char *buf, size_t size, format_t format)
Get the names of a set of formats.
Definition: frame.c:591
enum ast_frame_type frametype
Definition: frame.h:144
#define ast_mutex_unlock(a)
Definition: lock.h:156
static int unistimsock_read ( int *  id,
int  fd,
short  events,
void *  ignore 
)
static

Definition at line 3909 of file chan_unistim.c.

References ast_inet_ntoa(), ast_log(), ast_mutex_lock, ast_mutex_unlock, ast_verb, errno, LOG_NOTICE, LOG_WARNING, unistimsession::next, parsing(), sessionlock, sessions, unistimsession::sin, and SIZE_PAGE.

Referenced by do_monitor().

3910 {
3911  struct sockaddr_in addr_from = { 0, };
3912  struct unistimsession *cur = NULL;
3913  int found = 0;
3914  int tmp = 0;
3915  int dw_num_bytes_rcvd;
3916 #ifdef DUMP_PACKET
3917  int dw_num_bytes_rcvdd;
3918  char iabuf[INET_ADDRSTRLEN];
3919 #endif
3920 
3921  dw_num_bytes_rcvd =
3922  recvfrom(unistimsock, buff, SIZE_PAGE, 0, (struct sockaddr *) &addr_from,
3923  &size_addr_from);
3924  if (dw_num_bytes_rcvd == -1) {
3925  if (errno == EAGAIN)
3926  ast_log(LOG_NOTICE, "UNISTIM: Received packet with bad UDP checksum\n");
3927  else if (errno != ECONNREFUSED)
3928  ast_log(LOG_WARNING, "Recv error %d (%s)\n", errno, strerror(errno));
3929  return 1;
3930  }
3931 
3932  /* Looking in the phone list if we already have a registration for him */
3934  cur = sessions;
3935  while (cur) {
3936  if (cur->sin.sin_addr.s_addr == addr_from.sin_addr.s_addr) {
3937  found = 1;
3938  break;
3939  }
3940  tmp++;
3941  cur = cur->next;
3942  }
3944 
3945 #ifdef DUMP_PACKET
3946  if (unistimdebug)
3947  ast_verb(0, "\n*** Dump %d bytes from %s - phone_table[%d] ***\n",
3948  dw_num_bytes_rcvd, ast_inet_ntoa(addr_from.sin_addr), tmp);
3949  for (dw_num_bytes_rcvdd = 0; dw_num_bytes_rcvdd < dw_num_bytes_rcvd;
3950  dw_num_bytes_rcvdd++)
3951  ast_verb(0, "%.2x ", (unsigned char) buff[dw_num_bytes_rcvdd]);
3952  ast_verb(0, "\n******************************************\n");
3953 #endif
3954 
3955  if (!found) {
3956  if (unistimdebug)
3957  ast_verb(0, "Received a packet from an unknown source\n");
3958  parsing(dw_num_bytes_rcvd, buff, NULL, (struct sockaddr_in *) &addr_from);
3959 
3960  } else
3961  parsing(dw_num_bytes_rcvd, buff, cur, (struct sockaddr_in *) &addr_from);
3962 
3963  return 1;
3964 }
static struct unistimsession * sessions
static int unistimsock
Definition: chan_unistim.c:215
#define LOG_WARNING
Definition: logger.h:144
#define ast_mutex_lock(a)
Definition: lock.h:155
#define ast_verb(level,...)
Definition: logger.h:243
static ast_mutex_t sessionlock
Definition: chan_unistim.c:247
static int unistimdebug
Definition: chan_unistim.c:211
struct unistimsession * next
Definition: chan_unistim.c:497
static unsigned int size_addr_from
Definition: chan_unistim.c:230
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
#define LOG_NOTICE
Definition: logger.h:133
int errno
const char * ast_inet_ntoa(struct in_addr ia)
thread-safe replacement for inet_ntoa().
Definition: utils.c:564
struct sockaddr_in sin
Definition: chan_unistim.c:481
static void parsing(int size, unsigned char *buf, struct unistimsession *pte, struct sockaddr_in *addr_from)
static unsigned char * buff
Definition: chan_unistim.c:232
#define SIZE_PAGE
Definition: chan_unistim.c:100
#define ast_mutex_unlock(a)
Definition: lock.h:156
static int unload_module ( void  )
static

Definition at line 5717 of file chan_unistim.c.

References ARRAY_LEN, ast_channel_unregister(), ast_cli_unregister_multiple(), ast_free, ast_mutex_lock, ast_mutex_unlock, AST_PTHREADT_NULL, AST_PTHREADT_STOP, ast_rtp_glue_unregister(), monlock, and sched_context_destroy().

5718 {
5719  /* First, take us out of the channel loop */
5720  if (sched)
5722 
5724 
5727 
5730  pthread_cancel(monitor_thread);
5731  pthread_kill(monitor_thread, SIGURG);
5732  pthread_join(monitor_thread, NULL);
5733  }
5736 
5737  if (buff)
5738  ast_free(buff);
5739  if (unistimsock > -1)
5740  close(unistimsock);
5741 
5742  return 0;
5743 }
#define ARRAY_LEN(a)
Definition: isdn_lib.c:42
static pthread_t monitor_thread
Definition: chan_unistim.c:241
int ast_cli_unregister_multiple(struct ast_cli_entry *e, int len)
Unregister multiple commands.
Definition: cli.c:2177
static int unistimsock
Definition: chan_unistim.c:215
void ast_channel_unregister(const struct ast_channel_tech *tech)
Unregister a channel technology.
Definition: channel.c:938
static struct ast_cli_entry unistim_cli[]
Definition: sched.c:57
#define ast_mutex_lock(a)
Definition: lock.h:155
#define AST_PTHREADT_NULL
Definition: lock.h:65
void sched_context_destroy(struct sched_context *c)
destroys a schedule context Destroys (free&#39;s) the given sched_context structure
Definition: sched.c:267
#define ast_free(a)
Definition: astmm.h:97
static unsigned char * buff
Definition: chan_unistim.c:232
#define AST_PTHREADT_STOP
Definition: lock.h:66
int ast_rtp_glue_unregister(struct ast_rtp_glue *glue)
Unregister RTP glue.
Definition: rtp_engine.c:266
static struct ast_channel_tech unistim_tech
Definition: chan_unistim.c:706
#define ast_mutex_unlock(a)
Definition: lock.h:156
static ast_mutex_t monlock
Definition: chan_unistim.c:245
static struct ast_rtp_glue unistim_rtp_glue
static void unquote ( char *  out,
const char *  src,
int  maxlen 
)
static

Definition at line 4953 of file chan_unistim.c.

References len().

Referenced by build_device().

4954 {
4955  int len = strlen(src);
4956  if (!len)
4957  return;
4958  if ((len > 1) && src[0] == '\"') {
4959  /* This is a quoted string */
4960  src++;
4961  /* Don't take more than what's there */
4962  len--;
4963  if (maxlen > len - 1)
4964  maxlen = len - 1;
4965  memcpy(out, src, maxlen);
4966  ((char *) out)[maxlen] = '\0';
4967  } else
4968  memcpy(out, src, maxlen);
4969  return;
4970 }
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
static int UnregisterExtension ( const struct unistimsession pte)
static

Definition at line 1110 of file chan_unistim.c.

References ast_context_remove_extension(), ast_verb, unistim_line::context, unistimsession::device, unistim_device::extension_number, and unistim_device::lines.

Referenced by close_client(), and key_main_page().

1111 {
1112  if (unistimdebug)
1113  ast_verb(0, "Trying to unregister extension '%s' context '%s'\n",
1114  pte->device->extension_number, pte->device->lines->context);
1116  pte->device->extension_number, 1, "Unistim");
1117 }
#define ast_verb(level,...)
Definition: logger.h:243
int ast_context_remove_extension(const char *context, const char *extension, int priority, const char *registrar)
Simply remove extension from context.
Definition: pbx.c:6114
static int unistimdebug
Definition: chan_unistim.c:211
struct unistim_device * device
Definition: chan_unistim.c:496
struct unistim_line * lines
Definition: chan_unistim.c:473
char context[AST_MAX_EXTENSION]
Definition: chan_unistim.c:395
char extension_number[11]
Definition: chan_unistim.c:469
static int write_entry_history ( struct unistimsession pte,
FILE *  f,
char  c,
char *  line1 
)
static

Definition at line 1684 of file chan_unistim.c.

References unistimsession::device, display_last_error(), unistim_device::lst_cid, unistim_device::lst_cnm, and TEXT_LENGTH_MAX.

Referenced by write_history().

1685 {
1686  if (fwrite(&c, 1, 1, f) != 1) {
1687  display_last_error("Unable to write history log header.");
1688  return -1;
1689  }
1690  if (fwrite(line1, TEXT_LENGTH_MAX, 1, f) != 1) {
1691  display_last_error("Unable to write history entry - date.");
1692  return -1;
1693  }
1694  if (fwrite(pte->device->lst_cid, TEXT_LENGTH_MAX, 1, f) != 1) {
1695  display_last_error("Unable to write history entry - callerid.");
1696  return -1;
1697  }
1698  if (fwrite(pte->device->lst_cnm, TEXT_LENGTH_MAX, 1, f) != 1) {
1699  display_last_error("Unable to write history entry - callername.");
1700  return -1;
1701  }
1702  return 0;
1703 }
char lst_cnm[TEXT_LENGTH_MAX]
Definition: chan_unistim.c:460
#define TEXT_LENGTH_MAX
Definition: chan_unistim.c:141
struct unistim_device * device
Definition: chan_unistim.c:496
static struct ast_format f[]
Definition: format_g726.c:181
char lst_cid[TEXT_LENGTH_MAX]
Definition: chan_unistim.c:459
static void display_last_error(const char *sz_msg)
Definition: chan_unistim.c:725
static int write_history ( struct unistimsession pte,
char  way,
char  ismissed 
)
static

Definition at line 1705 of file chan_unistim.c.

References ast_config_AST_LOG_DIR, AST_CONFIG_MAX_PATH, ast_free, ast_localtime(), ast_log(), ast_malloc, ast_mkdir(), ast_tvnow(), unistim_device::callhistory, unistimsession::device, display_last_error(), errno, f, LOG_WARNING, MAX_ENTRY_LOG, unistim_device::name, TEXT_LENGTH_MAX, ast_tm::tm_hour, ast_tm::tm_mday, ast_tm::tm_min, ast_tm::tm_mon, ast_tm::tm_sec, ast_tm::tm_year, USTM_LOG_DIR, and write_entry_history().

Referenced by cancel_dial(), close_call(), and HandleCallIncoming().

1706 {
1707  char tmp[AST_CONFIG_MAX_PATH], tmp2[AST_CONFIG_MAX_PATH];
1708  char line1[TEXT_LENGTH_MAX + 1];
1709  char count = 0, *histbuf;
1710  int size;
1711  FILE *f, *f2;
1712  struct timeval now = ast_tvnow();
1713  struct ast_tm atm = { 0, };
1714 
1715  if (!pte->device)
1716  return -1;
1717  if (!pte->device->callhistory)
1718  return 0;
1719  if (strchr(pte->device->name, '/') || (pte->device->name[0] == '.')) {
1720  ast_log(LOG_WARNING, "Account code '%s' insecure for writing file\n",
1721  pte->device->name);
1722  return -1;
1723  }
1724 
1725  snprintf(tmp, sizeof(tmp), "%s/%s", ast_config_AST_LOG_DIR, USTM_LOG_DIR);
1726  if (ast_mkdir(tmp, 0770)) {
1727  if (errno != EEXIST) {
1728  display_last_error("Unable to create directory for history");
1729  return -1;
1730  }
1731  }
1732 
1733  ast_localtime(&now, &atm, NULL);
1734  if (ismissed) {
1735  if (way == 'i')
1736  strcpy(tmp2, "Miss");
1737  else
1738  strcpy(tmp2, "Fail");
1739  } else
1740  strcpy(tmp2, "Answ");
1741  snprintf(line1, sizeof(line1), "%04d/%02d/%02d %02d:%02d:%02d %s",
1742  atm.tm_year + 1900, atm.tm_mon + 1, atm.tm_mday, atm.tm_hour,
1743  atm.tm_min, atm.tm_sec, tmp2);
1744 
1745  snprintf(tmp, sizeof(tmp), "%s/%s/%s-%c.csv", ast_config_AST_LOG_DIR,
1746  USTM_LOG_DIR, pte->device->name, way);
1747  if ((f = fopen(tmp, "r"))) {
1748  struct stat bufstat;
1749 
1750  if (stat(tmp, &bufstat)) {
1751  display_last_error("Unable to stat history log.");
1752  fclose(f);
1753  return -1;
1754  }
1755  size = 1 + (MAX_ENTRY_LOG * TEXT_LENGTH_MAX * 3);
1756  if (bufstat.st_size != size) {
1758  "History file %s has an incorrect size (%d instead of %d). It will be replaced by a new one.",
1759  tmp, (int) bufstat.st_size, size);
1760  fclose(f);
1761  f = NULL;
1762  count = 1;
1763  }
1764  }
1765 
1766  /* If we can't open the log file, we create a brand new one */
1767  if (!f) {
1768  char c = 1;
1769  int i;
1770 
1771  if ((errno != ENOENT) && (count == 0)) {
1772  display_last_error("Unable to open history log.");
1773  return -1;
1774  }
1775  f = fopen(tmp, "w");
1776  if (!f) {
1777  display_last_error("Unable to create history log.");
1778  return -1;
1779  }
1780  if (write_entry_history(pte, f, c, line1)) {
1781  fclose(f);
1782  return -1;
1783  }
1784  memset(line1, ' ', TEXT_LENGTH_MAX);
1785  for (i = 3; i < MAX_ENTRY_LOG * 3; i++) {
1786  if (fwrite(line1, TEXT_LENGTH_MAX, 1, f) != 1) {
1787  display_last_error("Unable to write history entry - stuffing.");
1788  fclose(f);
1789  return -1;
1790  }
1791  }
1792  if (fclose(f))
1793  display_last_error("Unable to close history - creation.");
1794  return 0;
1795  }
1796  /* We can open the log file, we create a temporary one, we add our entry and copy the rest */
1797  if (fread(&count, 1, 1, f) != 1) {
1798  display_last_error("Unable to read history header.");
1799  fclose(f);
1800  return -1;
1801  }
1802  if (count > MAX_ENTRY_LOG) {
1803  ast_log(LOG_WARNING, "Invalid count in history header of %s (%d max %d)\n", tmp,
1804  count, MAX_ENTRY_LOG);
1805  fclose(f);
1806  return -1;
1807  }
1808  snprintf(tmp2, sizeof(tmp2), "%s/%s/%s-%c.csv.tmp", ast_config_AST_LOG_DIR,
1809  USTM_LOG_DIR, pte->device->name, way);
1810  if (!(f2 = fopen(tmp2, "w"))) {
1811  display_last_error("Unable to create temporary history log.");
1812  fclose(f);
1813  return -1;
1814  }
1815 
1816  if (++count > MAX_ENTRY_LOG)
1817  count = MAX_ENTRY_LOG;
1818 
1819  if (write_entry_history(pte, f2, count, line1)) {
1820  fclose(f);
1821  fclose(f2);
1822  return -1;
1823  }
1824 
1825  size = (MAX_ENTRY_LOG - 1) * TEXT_LENGTH_MAX * 3;
1826  if (!(histbuf = ast_malloc(size))) {
1827  fclose(f);
1828  fclose(f2);
1829  return -1;
1830  }
1831 
1832  if (fread(histbuf, size, 1, f) != 1) {
1833  ast_free(histbuf);
1834  fclose(f);
1835  fclose(f2);
1836  display_last_error("Unable to read previous history entries.");
1837  return -1;
1838  }
1839  if (fwrite(histbuf, size, 1, f2) != 1) {
1840  ast_free(histbuf);
1841  fclose(f);
1842  fclose(f2);
1843  display_last_error("Unable to write previous history entries.");
1844  return -1;
1845  }
1846  ast_free(histbuf);
1847  if (fclose(f))
1848  display_last_error("Unable to close history log.");
1849  if (fclose(f2))
1850  display_last_error("Unable to close temporary history log.");
1851  if (unlink(tmp))
1852  display_last_error("Unable to remove old history log.");
1853  if (rename(tmp2, tmp))
1854  display_last_error("Unable to rename new history log.");
1855  return 0;
1856 }
char name[DEVICE_NAME_LEN]
Definition: chan_unistim.c:435
#define LOG_WARNING
Definition: logger.h:144
#define AST_CONFIG_MAX_PATH
Definition: chan_unistim.c:102
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:1570
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
Definition: time.h:142
int tm_year
Definition: localtime.h:41
#define TEXT_LENGTH_MAX
Definition: chan_unistim.c:141
#define USTM_LOG_DIR
Definition: chan_unistim.c:84
struct unistim_device * device
Definition: chan_unistim.c:496
int tm_mon
Definition: localtime.h:40
#define MAX_ENTRY_LOG
Definition: chan_unistim.c:103
int tm_mday
Definition: localtime.h:39
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
const char * ast_config_AST_LOG_DIR
Definition: asterisk.c:263
int errno
#define ast_free(a)
Definition: astmm.h:97
static struct ast_format f[]
Definition: format_g726.c:181
int tm_hour
Definition: localtime.h:38
static int write_entry_history(struct unistimsession *pte, FILE *f, char c, char *line1)
int tm_sec
Definition: localtime.h:36
static void display_last_error(const char *sz_msg)
Definition: chan_unistim.c:725
#define ast_malloc(a)
Definition: astmm.h:91
int tm_min
Definition: localtime.h:37
int ast_mkdir(const char *path, int mode)
Recursively create directory path.
Definition: utils.c:2151

Variable Documentation

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 = "ac1f6a56484a8820659555499174e588" , .load = load_module, .unload = unload_module, .reload = reload, }
static

Definition at line 5756 of file chan_unistim.c.

struct sockaddr_in address_from
static

give the IP address for the last packet received

Definition at line 228 of file chan_unistim.c.

Definition at line 5756 of file chan_unistim.c.

enum autoprovision autoprovisioning = AUTOPROVISIONING_NO
static

Definition at line 213 of file chan_unistim.c.

unsigned char* buff
static
const char channel_type[] = "USTM"
static

Definition at line 678 of file chan_unistim.c.

unsigned int cos

Definition at line 220 of file chan_unistim.c.

unsigned int cos_audio

Definition at line 221 of file chan_unistim.c.

struct ast_jb_conf default_jbconf
static

Global jitterbuffer configuration - by default, jb is disabled.

Note
Values shown here match the defaults shown in unistim.conf.sample

Definition at line 195 of file chan_unistim.c.

ast_mutex_t devicelock = { PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP , NULL, 1 }
static
struct tone_zone_unistim frequency[]
static

Definition at line 316 of file chan_unistim.c.

struct ast_jb_conf global_jbconf
static

Definition at line 203 of file chan_unistim.c.

Referenced by reload_config(), and unistim_new().

struct io_context* io
static

Definition at line 224 of file chan_unistim.c.

pthread_t monitor_thread = AST_PTHREADT_NULL
static

This is the thread for the monitor which checks for input on the channels which are not currently in use.

Definition at line 241 of file chan_unistim.c.

ast_mutex_t monlock = { PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP , NULL, 1 }
static

Protect the monitoring thread, so only one process can kill or start it, and not when it's doing something critical.

Definition at line 245 of file chan_unistim.c.

Referenced by restart_monitor(), and unload_module().

const unsigned char packet_rcv_discovery[]
static
Initial value:
=
{ 0xff, 0xff, 0xff, 0xff, 0x02, 0x02, 0xff, 0xff, 0xff, 0xff, 0x9e, 0x03, 0x08 }

Definition at line 511 of file chan_unistim.c.

const unsigned char packet_recv_firm_version[]
static
Initial value:
=
{ 0x00, 0x00, 0x00, 0x13, 0x9a, 0x0a, 0x02 }

Definition at line 516 of file chan_unistim.c.

const unsigned char packet_recv_hangup[]
static
Initial value:
=
{ 0x00, 0x00, 0x00, 0x13, 0x99, 0x03, 0x03 }

Definition at line 522 of file chan_unistim.c.

const unsigned char packet_recv_mac_addr[]
static
Initial value:
=
{ 0xff, 0xff, 0xff, 0xff, 0x9a, 0x0d, 0x07 }

Definition at line 529 of file chan_unistim.c.

const unsigned char packet_recv_pick_up[]
static
Initial value:
=
{ 0x00, 0x00, 0x00, 0x13, 0x99, 0x03, 0x04 }

Definition at line 520 of file chan_unistim.c.

const unsigned char packet_recv_pressed_key[]
static
Initial value:
=
{ 0x00, 0x00, 0x00, 0x13, 0x99, 0x04, 0x00 }

Definition at line 518 of file chan_unistim.c.

const unsigned char packet_recv_r2[] = { 0x00, 0x00, 0x00, 0x13, 0x96, 0x03, 0x03 }
static

Definition at line 524 of file chan_unistim.c.

const unsigned char packet_recv_resume_connection_with_server[]
static
Initial value:
=
{ 0xff, 0xff, 0xff, 0xff, 0x9e, 0x03, 0x08 }

TransportAdapter

Definition at line 527 of file chan_unistim.c.

const unsigned char packet_send_arrow[] = { 0x17, 0x04, 0x04, 0x00 }
static

Definition at line 624 of file chan_unistim.c.

const unsigned char packet_send_blink_cursor[] = { 0x17, 0x04, 0x10, 0x86 }
static

Definition at line 625 of file chan_unistim.c.

const unsigned char packet_send_call[]
static

Definition at line 552 of file chan_unistim.c.

const unsigned char packet_send_Contrast[]
static
Initial value:
=
{ 0x17, 0x04, 0x24, 0x08 }

Definition at line 629 of file chan_unistim.c.

const unsigned char packet_send_date_time[]
static

Definition at line 536 of file chan_unistim.c.

const unsigned char packet_send_date_time2[]
static
Initial value:
= { 0x17, 0x04, 0x17, 0x3d, 0x11, 0x09, 0x02, 0x0a, 0x05,
0x06, 0x07, 0x08, 0x32
}

Definition at line 626 of file chan_unistim.c.

const unsigned char packet_send_date_time3[]
static
Initial value:
=
{ 0x11, 0x09, 0x02, 0x02, 0x05, 0x06, 0x07,
0x08, 0x32
}

Definition at line 532 of file chan_unistim.c.

const unsigned char packet_send_discovery_ack[]
static
Initial value:
=
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }

Definition at line 513 of file chan_unistim.c.

const unsigned char packet_send_end_call[]
static
Initial value:
=
{ 0x16, 0x06, 0x32, 0xdf, 0x00, 0xff, 0x16, 0x05, 0x31, 0x00, 0x00, 0x19, 0x04, 0x00,
0x10, 0x19, 0x04, 0x00, 0x18, 0x16, 0x05,
0x04, 0x00, 0x00, 0x16, 0x04, 0x37, 0x10
}

Definition at line 580 of file chan_unistim.c.

const unsigned char packet_send_favorite[]
static
Initial value:
=
{ 0x17, 0x0f, 0x19, 0x10, 0x01, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x19,
0x05, 0x0f, 0x01, 0x00
}

Definition at line 642 of file chan_unistim.c.

const unsigned char packet_send_icon[] = { 0x17, 0x05, 0x14, 0x00, 0x25 }
static

Definition at line 635 of file chan_unistim.c.

const unsigned char packet_send_jitter_buffer_conf[]
static
Initial value:
=
{ 0x16, 0x0e, 0x3a, 0x00, 0x02, 0x04, 0x00, 0x00,
0x3e, 0x80,
0x00, 0x00, 0x3e, 0x80
}

Definition at line 590 of file chan_unistim.c.

const unsigned char packet_send_led_update[] = { 0x19, 0x04, 0x00, 0x00 }
static

Definition at line 665 of file chan_unistim.c.

const unsigned char packet_send_no_ring[]
static
Initial value:
=
{ 0x16, 0x04, 0x1a, 0x00, 0x16, 0x04, 0x11, 0x00 }

Definition at line 543 of file chan_unistim.c.

const unsigned char packet_send_open_audio_stream_rx[]
static
Initial value:
=
{ 0x16, 0x1a, 0x30, 0x00, 0xff, 0x00, 0x00, 0x01, 0x00, 0xb8, 0xb8, 0x0e,
0x0e, 0x01, 0x14, 0x50, 0x00,
0x00, 0x14, 0x50, 0x00, 0x00, 0x0a, 0x93, 0x69, 0x05
}

Definition at line 599 of file chan_unistim.c.

const unsigned char packet_send_open_audio_stream_rx3[]
static

Definition at line 610 of file chan_unistim.c.

const unsigned char packet_send_open_audio_stream_tx[]
static
Initial value:
=
{ 0x16, 0x1a, 0x30, 0xff, 0x00, 0x00, 0x00, 0x01, 0x00, 0xb8, 0xb8, 0x0e,
0x0e, 0x01, 0x14, 0x50,
0x00, 0x00, 0x14, 0x50, 0x00, 0x00, 0x0a, 0x93, 0x69, 0x05
}

Definition at line 604 of file chan_unistim.c.

const unsigned char packet_send_open_audio_stream_tx3[]
static

Definition at line 617 of file chan_unistim.c.

unsigned char packet_send_ping[]
static
Initial value:
=
{ 0x1e, 0x05, 0x12, 0x00, 0x78 }

Definition at line 672 of file chan_unistim.c.

const unsigned char packet_send_query_basic_manager_04[] = { 0x1a, 0x04, 0x01, 0x04 }
static

Definition at line 667 of file chan_unistim.c.

const unsigned char packet_send_query_basic_manager_10[] = { 0x1a, 0x04, 0x01, 0x10 }
static

Definition at line 669 of file chan_unistim.c.

const unsigned char packet_send_query_mac_address[] = { 0x1a, 0x04, 0x01, 0x08 }
static

Definition at line 668 of file chan_unistim.c.

const unsigned char packet_send_ring[]
static
Initial value:
=
{ 0x16, 0x06, 0x32, 0xdf, 0x00, 0xff, 0x16, 0x05, 0x1c, 0x00, 0x00, 0x16,
0x04, 0x1a, 0x01, 0x16, 0x05, 0x12, 0x13 , 0x18, 0x16, 0x04, 0x18,
0x20, 0x16, 0x04, 0x10, 0x00
}

Definition at line 575 of file chan_unistim.c.

const unsigned char packet_send_rtp_packet_size[]
static
Initial value:
=
{ 0x16, 0x08, 0x38, 0x00, 0x00, 0xe0, 0x00, 0xa0 }

Definition at line 588 of file chan_unistim.c.

const unsigned char packet_send_S1[] = { 0x1a, 0x07, 0x07, 0x00, 0x00, 0x00, 0x13 }
static

Definition at line 670 of file chan_unistim.c.

const unsigned char packet_send_s4[]
static

Definition at line 545 of file chan_unistim.c.

const unsigned char packet_send_S7[] = { 0x17, 0x06, 0x0f, 0x30, 0x07, 0x07 }
static

Definition at line 636 of file chan_unistim.c.

const unsigned char packet_send_s9[]
static
Initial value:
=
{ 0x16, 0x06, 0x32, 0xdf, 0x00, 0xff, 0x19, 0x04, 0x00, 0x10, 0x16, 0x05, 0x1c, 0x00,
0x00 }

Definition at line 585 of file chan_unistim.c.

const unsigned char packet_send_select_output[]
static
Initial value:
=
{ 0x16, 0x06, 0x32, 0xc0, 0x01, 0x00 }

Definition at line 573 of file chan_unistim.c.

const unsigned char packet_send_set_pos_cursor[]
static
Initial value:
=
{ 0x17, 0x06, 0x10, 0x81, 0x04, 0x20 }

Definition at line 637 of file chan_unistim.c.

const unsigned char packet_send_StartTimer[]
static
Initial value:
=
{ 0x17, 0x05, 0x0b, 0x05, 0x00, 0x17, 0x08, 0x16, 0x44, 0x75, 0x72, 0xe9,
0x65 }

Definition at line 631 of file chan_unistim.c.

const unsigned char packet_send_status[]
static
Initial value:
=
{ 0x17, 0x20, 0x19, 0x08, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20
}

Definition at line 656 of file chan_unistim.c.

const unsigned char packet_send_status2[]
static
Initial value:
=
{ 0x17, 0x0b, 0x19, 0x00, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20 }

Definition at line 661 of file chan_unistim.c.

const unsigned char packet_send_stop_timer[] = { 0x17, 0x05, 0x0b, 0x02, 0x00 }
static

Definition at line 634 of file chan_unistim.c.

const unsigned char packet_send_stream_based_tone_dial_freq[]
static
Initial value:
=
{ 0x16, 0x08, 0x1d, 0x00, 0x01, 0xb8, 0x01, 0x5e }

Definition at line 571 of file chan_unistim.c.

const unsigned char packet_send_stream_based_tone_off[]
static
Initial value:
=
{ 0x16, 0x05, 0x1c, 0x00, 0x00 }

Definition at line 561 of file chan_unistim.c.

const unsigned char packet_send_stream_based_tone_on[]
static
Initial value:
=
{ 0x16, 0x06, 0x1b, 0x00, 0x00, 0x05 }

Definition at line 567 of file chan_unistim.c.

const unsigned char packet_send_stream_based_tone_single_freq[]
static
Initial value:
=
{ 0x16, 0x06, 0x1d, 0x00, 0x01, 0xb8 }

Definition at line 569 of file chan_unistim.c.

const unsigned char packet_send_text[]
static

Definition at line 650 of file chan_unistim.c.

const unsigned char packet_send_title[]
static
Initial value:
=
{ 0x17, 0x10, 0x19, 0x02, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20 }

Definition at line 647 of file chan_unistim.c.

struct sockaddr_in public_ip = { 0, }
static

Definition at line 226 of file chan_unistim.c.

struct { ... } qos

Referenced by reload_config(), and start_rtp().

struct sched_context* sched
static

Definition at line 225 of file chan_unistim.c.

ast_mutex_t sessionlock = { PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP , NULL, 1 }
static

Protect the session list

Definition at line 247 of file chan_unistim.c.

Referenced by close_client(), create_client(), do_monitor(), reload_config(), unistim_info(), and unistimsock_read().

unsigned int size_addr_from = sizeof(address_from)
static

size of the sockaddr_in (in WSARecvFrom)

Definition at line 230 of file chan_unistim.c.

const char tdesc[] = "UNISTIM Channel Driver"
static

Definition at line 677 of file chan_unistim.c.

unsigned int tos

Definition at line 218 of file chan_unistim.c.

unsigned int tos_audio

Definition at line 219 of file chan_unistim.c.

struct ast_cli_entry unistim_cli[]
static

Definition at line 4946 of file chan_unistim.c.

int unistim_keepalive
static

Definition at line 214 of file chan_unistim.c.

Referenced by create_client(), and send_ping().

int unistim_port
static

Definition at line 212 of file chan_unistim.c.

ast_mutex_t unistim_reload_lock = { PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP , NULL, 1 }
static

Definition at line 234 of file chan_unistim.c.

Referenced by do_monitor(), and unistim_reload().

int unistim_reloading = 0
static

Definition at line 233 of file chan_unistim.c.

Referenced by do_monitor().

struct ast_rtp_glue unistim_rtp_glue
static
Initial value:
= {
.type = channel_type,
.get_rtp_info = unistim_get_rtp_peer,
.update_peer = unistim_set_rtp_peer,
}
static const char channel_type[]
Definition: chan_unistim.c:678
static int unistim_set_rtp_peer(struct ast_channel *chan, struct ast_rtp_instance *rtp, struct ast_rtp_instance *vrtp, struct ast_rtp_instance *trtp, format_t codecs, int nat_active)
static enum ast_rtp_glue_result unistim_get_rtp_peer(struct ast_channel *chan, struct ast_rtp_instance **instance)

Definition at line 5659 of file chan_unistim.c.

struct ast_channel_tech unistim_tech
static

Definition at line 706 of file chan_unistim.c.

Referenced by unistim_new().

int unistimdebug = 0
static

Enable verbose output. can also be set with the CLI

Definition at line 211 of file chan_unistim.c.

int unistimsock = -1
static

Definition at line 215 of file chan_unistim.c.

int usecnt = 0
static

Definition at line 236 of file chan_unistim.c.

ast_mutex_t usecnt_lock = { PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP , NULL, 1 }
static

Definition at line 235 of file chan_unistim.c.

Referenced by unistim_new().