Asterisk - The Open Source Telephony Project  18.5.0
Data Structures | Macros | Enumerations | Functions | Variables
chan_misdn.c File Reference

the chan_misdn channel driver for Asterisk More...

#include "asterisk.h"
#include <pthread.h>
#include <sys/socket.h>
#include <sys/time.h>
#include <arpa/inet.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <signal.h>
#include <sys/file.h>
#include <semaphore.h>
#include <ctype.h>
#include <time.h>
#include "asterisk/channel.h"
#include "asterisk/config.h"
#include "asterisk/module.h"
#include "asterisk/pbx.h"
#include "asterisk/io.h"
#include "asterisk/frame.h"
#include "asterisk/translate.h"
#include "asterisk/cli.h"
#include "asterisk/musiconhold.h"
#include "asterisk/dsp.h"
#include "asterisk/file.h"
#include "asterisk/callerid.h"
#include "asterisk/indications.h"
#include "asterisk/app.h"
#include "asterisk/features.h"
#include "asterisk/term.h"
#include "asterisk/sched.h"
#include "asterisk/stringfields.h"
#include "asterisk/abstract_jb.h"
#include "asterisk/causes.h"
#include "asterisk/format.h"
#include "asterisk/format_cap.h"
#include "asterisk/features_config.h"
#include "asterisk/bridge.h"
#include "asterisk/pickup.h"
#include "asterisk/format_cache.h"
#include "chan_misdn_config.h"
#include "isdn_lib.h"
#include "asterisk/strings.h"
Include dependency graph for chan_misdn.c:

Go to the source code of this file.

Data Structures

struct  allowed_bearers
 
struct  chan_list
 Channel call record structure. More...
 
struct  hold_info
 
struct  misdn_jb
 
struct  robin_list
 
struct  state_struct
 

Macros

#define chan_list_ref(obj, debug)   ao2_t_ref((obj), +1, (debug))
 
#define chan_list_unref(obj, debug)   ao2_t_ref((obj), -1, (debug))
 
#define MISDN_ASTERISK_TECH_PVT(ast)   ast_channel_tech_pvt(ast)
 
#define MISDN_ASTERISK_TECH_PVT_SET(ast, value)   ast_channel_tech_pvt_set(ast, value)
 
#define ORG_AST   1
 
#define ORG_MISDN   2
 
#define TRANSFER_ON_HELD_CALL_HANGUP   1
 

Enumerations

enum  misdn_chan_state {
  MISDN_NOTHING = 0, MISDN_WAITING4DIGS, MISDN_EXTCANTMATCH, MISDN_INCOMING_SETUP,
  MISDN_DIALING, MISDN_PROGRESS, MISDN_PROCEEDING, MISDN_CALLING,
  MISDN_CALLING_ACKNOWLEDGE, MISDN_ALERTING, MISDN_BUSY, MISDN_CONNECTED,
  MISDN_DISCONNECTED, MISDN_CLEANING
}
 
enum  misdn_hold_state { MISDN_HOLD_IDLE, MISDN_HOLD_ACTIVE, MISDN_HOLD_TRANSFER, MISDN_HOLD_DISCONNECT }
 

Functions

static void __reg_module (void)
 
static void __unreg_module (void)
 
static int _misdn_tasks_add_variable (int timeout, ast_sched_cb callback, const void *data, int variable)
 
int add_in_calls (int port)
 
int add_out_calls (int port)
 
struct ast_moduleAST_MODULE_SELF_SYM (void)
 
static enum mISDN_NUMBER_PLAN ast_to_misdn_plan (unsigned ast_number_plan)
 
static int ast_to_misdn_pres (int presentation)
 
static enum mISDN_REDIRECTING_REASON ast_to_misdn_reason (const enum AST_REDIRECTING_REASON ast)
 
static int ast_to_misdn_screen (int screening)
 
static enum mISDN_NUMBER_TYPE ast_to_misdn_ton (unsigned ast_number_type)
 
static const char * bearer2str (int cap)
 
static enum event_response_e cb_events (enum event_e event, struct misdn_bchannel *bc, void *user_data)
 
static void chan_list_destructor (void *obj)
 
static struct chan_listchan_list_init (int orig)
 
int chan_misdn_jb_empty (struct misdn_bchannel *bc, char *buf, int len)
 
static void chan_misdn_log (int level, int port, char *tmpl,...)
 
static int cl_dequeue_chan (struct chan_list *chan)
 
static void cl_queue_chan (struct chan_list *chan)
 
static char * complete_ch (struct ast_cli_args *a)
 
static char * complete_debug_port (struct ast_cli_args *a)
 
static char * complete_show_config (struct ast_cli_args *a)
 
static void config_jitterbuffer (struct chan_list *ch)
 
void debug_numtype (int port, int numtype, char *type)
 
static int dialtone_indicate (struct chan_list *cl)
 
static void do_immediate_setup (struct misdn_bchannel *bc, struct chan_list *ch, struct ast_channel *ast)
 
static void export_aoc_vars (int originator, struct ast_channel *ast, struct misdn_bchannel *bc)
 
void export_ch (struct ast_channel *chan, struct misdn_bchannel *bc, struct chan_list *ch)
 Export parameters to the dialplan environment variables. More...
 
static struct chan_listfind_chan_by_bc (struct misdn_bchannel *bc)
 
static struct chan_listfind_hold_active_call (struct misdn_bchannel *bc)
 
static struct chan_listfind_hold_call (struct misdn_bchannel *bc)
 
static struct chan_listfind_hold_call_l3 (unsigned long l3_id)
 
static void free_robin_list (void)
 
static struct chan_listget_chan_by_ast_name (const char *name)
 
static struct robin_listget_robin_position (char *group)
 
static char * handle_cli_misdn_port_block (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 
static char * handle_cli_misdn_port_down (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 
static char * handle_cli_misdn_port_unblock (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 
static char * handle_cli_misdn_port_up (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 
static char * handle_cli_misdn_reload (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 
static char * handle_cli_misdn_restart_pid (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 
static char * handle_cli_misdn_restart_port (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 
static char * handle_cli_misdn_send_digit (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 
static char * handle_cli_misdn_send_display (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 
static char * handle_cli_misdn_send_facility (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 
static char * handle_cli_misdn_send_restart (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 
static char * handle_cli_misdn_set_crypt_debug (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 
static char * handle_cli_misdn_set_debug (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 
static char * handle_cli_misdn_set_tics (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 
static char * handle_cli_misdn_show_channel (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 
static char * handle_cli_misdn_show_channels (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 
static char * handle_cli_misdn_show_config (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 
static char * handle_cli_misdn_show_port (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 
static char * handle_cli_misdn_show_ports_stats (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 
static char * handle_cli_misdn_show_stacks (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 
static char * handle_cli_misdn_toggle_echocancel (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 
static void hangup_chan (struct chan_list *ch, struct misdn_bchannel *bc)
 
static void hanguptone_indicate (struct chan_list *cl)
 
void import_ch (struct ast_channel *chan, struct misdn_bchannel *bc, struct chan_list *ch)
 Import parameters from the dialplan environment variables. More...
 
static int load_module (void)
 Load the module. More...
 
static void misdn_add_number_prefix (int port, enum mISDN_NUMBER_TYPE number_type, char *number, size_t size)
 
static int misdn_answer (struct ast_channel *ast)
 
static int misdn_attempt_transfer (struct chan_list *active_ch, struct chan_list *held_ch)
 
static int misdn_call (struct ast_channel *ast, const char *dest, int timeout)
 
static int misdn_chan_is_valid (struct chan_list *ch)
 
static int misdn_check_l2l1 (struct ast_channel *chan, const char *data)
 
static void misdn_copy_redirecting_from_ast (struct misdn_bchannel *bc, struct ast_channel *ast)
 
static void misdn_copy_redirecting_to_ast (struct ast_channel *ast, const struct misdn_party_redirecting *redirect, char *tag)
 
static int misdn_digit_begin (struct ast_channel *chan, char digit)
 
static int misdn_digit_end (struct ast_channel *ast, char digit, unsigned int duration)
 
static int misdn_facility_exec (struct ast_channel *chan, const char *data)
 
static void misdn_facility_ie_handler (enum event_e event, struct misdn_bchannel *bc, struct chan_list *ch)
 
static int misdn_fixup (struct ast_channel *oldast, struct ast_channel *ast)
 
static const char * misdn_get_ch_state (struct chan_list *p)
 
static void misdn_get_connected_line (struct ast_channel *ast, struct misdn_bchannel *bc, int originator)
 
static int misdn_hangup (struct ast_channel *ast)
 
static int misdn_indication (struct ast_channel *ast, int cond, const void *data, size_t datalen)
 
static int misdn_is_msn_valid (int port, const struct misdn_party_dialing *dialed)
 
void misdn_jb_destroy (struct misdn_jb *jb)
 frees the data and destroys the given jitterbuffer struct More...
 
int misdn_jb_empty (struct misdn_jb *jb, char *data, int len)
 gets len bytes out of the jitterbuffer if available, else only the available data is returned and the return value indicates the number of data. More...
 
int misdn_jb_fill (struct misdn_jb *jb, const char *data, int len)
 fills the jitterbuffer with len data returns < 0 if there was an error (buffer overrun). More...
 
struct misdn_jbmisdn_jb_init (int size, int upper_threshold)
 allocates the jb-structure and initialize the elements More...
 
static int misdn_l1_task (const void *vdata)
 
static struct ast_channelmisdn_new (struct chan_list *cl, int state, char *exten, char *callerid, struct ast_format_cap *cap, const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor, int port, int c)
 
static int misdn_overlap_dial_task (const void *data)
 
static void misdn_prefix_string (const char *str_prefix, char *str_main, size_t size)
 
static void misdn_queue_connected_line_update (struct ast_channel *ast, const struct misdn_party_id *id, enum AST_CONNECTED_LINE_UPDATE_SOURCE source, char *cid_tag)
 
static struct ast_framemisdn_read (struct ast_channel *ast)
 
static struct ast_channelmisdn_request (const char *type, struct ast_format_cap *cap, const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor, const char *data, int *cause)
 
static int misdn_send_text (struct ast_channel *chan, const char *text)
 
static int misdn_set_opt_exec (struct ast_channel *chan, const char *data)
 
static int misdn_tasks_add (int timeout, ast_sched_cb callback, const void *data)
 
static int misdn_tasks_add_variable (int timeout, ast_sched_cb callback, const void *data)
 
static void misdn_tasks_destroy (void)
 
static void misdn_tasks_init (void)
 
static void misdn_tasks_remove (int task_id)
 
static void * misdn_tasks_thread_func (void *data)
 
static void misdn_tasks_wakeup (void)
 
static int misdn_to_ast_plan (enum mISDN_NUMBER_PLAN number_plan)
 
static int misdn_to_ast_pres (int presentation)
 
static enum AST_REDIRECTING_REASON misdn_to_ast_reason (const enum mISDN_REDIRECTING_REASON q931)
 
static int misdn_to_ast_screen (int screening)
 
static int misdn_to_ast_ton (enum mISDN_NUMBER_TYPE number_type)
 
static const char * misdn_to_str_plan (enum mISDN_NUMBER_PLAN number_plan)
 
static const char * misdn_to_str_pres (int presentation)
 
static const char * misdn_to_str_screen (int screening)
 
static const char * misdn_to_str_ton (enum mISDN_NUMBER_TYPE number_type)
 
static void misdn_update_caller_id (struct ast_channel *ast, const struct misdn_party_id *id, char *cid_tag)
 
static void misdn_update_connected_line (struct ast_channel *ast, struct misdn_bchannel *bc, int originator)
 
static void misdn_update_redirecting (struct ast_channel *ast, struct misdn_bchannel *bc, int originator)
 
static void misdn_update_remote_party (struct ast_channel *ast, const struct misdn_party_id *id, enum AST_CONNECTED_LINE_UPDATE_SOURCE source, char *cid_tag)
 
static int misdn_write (struct ast_channel *ast, struct ast_frame *frame)
 
static int pbx_start_chan (struct chan_list *ch)
 
static void print_bc_info (int fd, struct chan_list *help, struct misdn_bchannel *bc)
 
static void print_bearer (struct misdn_bchannel *bc)
 
static void print_facility (const struct FacParm *fac, const struct misdn_bchannel *bc)
 
static struct ast_frameprocess_ast_dsp (struct chan_list *tmp, struct ast_frame *frame)
 
static int read_config (struct chan_list *ch)
 
static void release_chan (struct chan_list *ch, struct misdn_bchannel *bc)
 
static void release_chan_early (struct chan_list *ch)
 
static int reload (void)
 
static void reload_config (void)
 
static int send_cause2ast (struct ast_channel *ast, struct misdn_bchannel *bc, struct chan_list *ch)
 
static void send_digit_to_chan (struct chan_list *cl, char digit)
 
static void show_config_description (int fd, enum misdn_cfg_elements elem)
 
static void sighandler (int sig)
 
static int start_bc_tones (struct chan_list *cl)
 
static void start_pbx (struct chan_list *ch, struct misdn_bchannel *bc, struct ast_channel *chan)
 
static int stop_bc_tones (struct chan_list *cl)
 
static int stop_indicate (struct chan_list *cl)
 
static int unload_module (void)
 
static void update_config (struct chan_list *ch)
 Updates caller ID information from config. More...
 
static int update_ec_config (struct misdn_bchannel *bc)
 
static void update_name (struct ast_channel *tmp, int port, int c)
 
static void wait_for_digits (struct chan_list *ch, struct misdn_bchannel *bc, struct ast_channel *chan)
 

Variables

static struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "Channel driver for mISDN Support (BRI/PRI)" , .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 = "30ef0c93b36035ec78c9cfd712d36d9b" , .support_level = AST_MODULE_SUPPORT_DEPRECATED, .load = load_module, .unload = unload_module, .reload = reload, .load_pri = AST_MODPRI_CHANNEL_DRIVER, }
 
static const struct allowed_bearers allowed_bearers_array []
 
static const struct ast_module_infoast_module_info = &__mod_info
 
static struct ast_cli_entry chan_misdn_clis []
 
static struct chan_listcl_te =NULL
 Global channel call record list head. More...
 
static ast_mutex_t cl_te_lock
 
static int g_config_initialized = 0
 
static int glob_channel = 0
 
static char global_tracefile [BUFFERSIZE+1]
 
static int max_ports
 
int MAXTICS = 8
 
static int * misdn_debug
 
static int * misdn_debug_only
 
static int * misdn_in_calls
 
static int * misdn_out_calls
 
static int * misdn_ports
 
static struct ast_sched_contextmisdn_tasks = NULL
 the main schedule context for stuff like l1 watcher, overlap dial, ... More...
 
static pthread_t misdn_tasks_thread
 
static struct ast_channel_tech misdn_tech
 
static const char misdn_type [] = "mISDN"
 
static ast_mutex_t release_lock
 
static struct robin_listrobin = NULL
 
static const struct state_struct state_array []
 
static int tracing = 0
 

Detailed Description

the chan_misdn channel driver for Asterisk

Author
Christian Richter crich.nosp@m.@ber.nosp@m.onet..nosp@m.com

MISDN http://www.misdn.org/

Definition in file chan_misdn.c.

Macro Definition Documentation

◆ chan_list_ref

#define chan_list_ref (   obj,
  debug 
)    ao2_t_ref((obj), +1, (debug))

◆ chan_list_unref

#define chan_list_unref (   obj,
  debug 
)    ao2_t_ref((obj), -1, (debug))

◆ MISDN_ASTERISK_TECH_PVT

#define MISDN_ASTERISK_TECH_PVT (   ast)    ast_channel_tech_pvt(ast)

◆ MISDN_ASTERISK_TECH_PVT_SET

#define MISDN_ASTERISK_TECH_PVT_SET (   ast,
  value 
)    ast_channel_tech_pvt_set(ast, value)

Definition at line 684 of file chan_misdn.c.

Referenced by misdn_hangup(), misdn_new(), release_chan(), and release_chan_early().

◆ ORG_AST

#define ORG_AST   1

Asterisk created the channel (outgoing call)

Definition at line 343 of file chan_misdn.c.

Referenced by cb_events(), export_aoc_vars(), misdn_hangup(), misdn_request(), print_bc_info(), read_config(), release_chan(), and release_chan_early().

◆ ORG_MISDN

#define ORG_MISDN   2

mISDN created the channel (incoming call)

Definition at line 345 of file chan_misdn.c.

Referenced by cb_events(), misdn_get_connected_line(), misdn_indication(), misdn_update_connected_line(), and misdn_update_redirecting().

◆ TRANSFER_ON_HELD_CALL_HANGUP

#define TRANSFER_ON_HELD_CALL_HANGUP   1

Definition at line 8334 of file chan_misdn.c.

Enumeration Type Documentation

◆ misdn_chan_state

Enumerator
MISDN_NOTHING 

at beginning

MISDN_WAITING4DIGS 

when waiting for info

MISDN_EXTCANTMATCH 

when asterisk couldn't match our ext

MISDN_INCOMING_SETUP 

for incoming setup

MISDN_DIALING 

when pbx_start

MISDN_PROGRESS 

we have progress

MISDN_PROCEEDING 

we have progress

MISDN_CALLING 

when misdn_call is called

MISDN_CALLING_ACKNOWLEDGE 

when we get SETUP_ACK

MISDN_ALERTING 

when Alerting

MISDN_BUSY 

when BUSY

MISDN_CONNECTED 

when connected

MISDN_DISCONNECTED 

when connected

MISDN_CLEANING 

when hangup from * but we were connected before

Definition at line 325 of file chan_misdn.c.

325  {
326  MISDN_NOTHING = 0, /*!< at beginning */
327  MISDN_WAITING4DIGS, /*!< when waiting for info */
328  MISDN_EXTCANTMATCH, /*!< when asterisk couldn't match our ext */
329  MISDN_INCOMING_SETUP, /*!< for incoming setup */
330  MISDN_DIALING, /*!< when pbx_start */
331  MISDN_PROGRESS, /*!< we have progress */
332  MISDN_PROCEEDING, /*!< we have progress */
333  MISDN_CALLING, /*!< when misdn_call is called */
334  MISDN_CALLING_ACKNOWLEDGE, /*!< when we get SETUP_ACK */
335  MISDN_ALERTING, /*!< when Alerting */
336  MISDN_BUSY, /*!< when BUSY */
337  MISDN_CONNECTED, /*!< when connected */
338  MISDN_DISCONNECTED, /*!< when connected */
339  MISDN_CLEANING, /*!< when hangup from * but we were connected before */
340 };

◆ misdn_hold_state

Enumerator
MISDN_HOLD_IDLE 

HOLD not active

MISDN_HOLD_ACTIVE 

Call is held

MISDN_HOLD_TRANSFER 

Held call is being transferred

MISDN_HOLD_DISCONNECT 

Held call is being disconnected

Definition at line 347 of file chan_misdn.c.

347  {
348  MISDN_HOLD_IDLE, /*!< HOLD not active */
349  MISDN_HOLD_ACTIVE, /*!< Call is held */
350  MISDN_HOLD_TRANSFER, /*!< Held call is being transferred */
351  MISDN_HOLD_DISCONNECT, /*!< Held call is being disconnected */
352 };

Function Documentation

◆ __reg_module()

static void __reg_module ( void  )
static

Definition at line 12838 of file chan_misdn.c.

◆ __unreg_module()

static void __unreg_module ( void  )
static

Definition at line 12838 of file chan_misdn.c.

◆ _misdn_tasks_add_variable()

static int _misdn_tasks_add_variable ( int  timeout,
ast_sched_cb  callback,
const void *  data,
int  variable 
)
inlinestatic

Definition at line 3591 of file chan_misdn.c.

References ast_sched_add_variable(), misdn_tasks_init(), and misdn_tasks_wakeup().

Referenced by misdn_tasks_add(), and misdn_tasks_add_variable().

3592 {
3593  int task_id;
3594 
3595  if (!misdn_tasks) {
3596  misdn_tasks_init();
3597  }
3598  task_id = ast_sched_add_variable(misdn_tasks, timeout, callback, data, variable);
3600 
3601  return task_id;
3602 }
static int timeout
Definition: cdr_mysql.c:86
int ast_sched_add_variable(struct ast_sched_context *con, int when, ast_sched_cb callback, const void *data, int variable) attribute_warn_unused_result
Adds a scheduled event with rescheduling support.
Definition: sched.c:524
static void misdn_tasks_init(void)
Definition: chan_misdn.c:3554
static struct ast_sched_context * misdn_tasks
the main schedule context for stuff like l1 watcher, overlap dial, ...
Definition: chan_misdn.c:670
static void misdn_tasks_wakeup(void)
Definition: chan_misdn.c:3586

◆ add_in_calls()

int add_in_calls ( int  port)

Definition at line 8844 of file chan_misdn.c.

References ast_log, LOG_NOTICE, misdn_cfg_get(), and MISDN_CFG_MAX_IN.

Referenced by cb_events().

8845 {
8846  int max_in_calls;
8847 
8848  misdn_cfg_get(port, MISDN_CFG_MAX_IN, &max_in_calls, sizeof(max_in_calls));
8849  misdn_in_calls[port]++;
8850 
8851  if (max_in_calls >= 0 && max_in_calls < misdn_in_calls[port]) {
8852  ast_log(LOG_NOTICE, "Marking Incoming Call on port[%d]\n", port);
8853  return misdn_in_calls[port] - max_in_calls;
8854  }
8855 
8856  return 0;
8857 }
#define ast_log
Definition: astobj2.c:42
void misdn_cfg_get(int port, enum misdn_cfg_elements elem, void *buf, int bufsize)
Definition: misdn_config.c:569
#define LOG_NOTICE
Definition: logger.h:263
static int * misdn_in_calls
Definition: chan_misdn.c:698

◆ add_out_calls()

int add_out_calls ( int  port)

Definition at line 8859 of file chan_misdn.c.

References ast_log, LOG_NOTICE, misdn_cfg_get(), and MISDN_CFG_MAX_OUT.

Referenced by misdn_call().

8860 {
8861  int max_out_calls;
8862 
8863  misdn_cfg_get(port, MISDN_CFG_MAX_OUT, &max_out_calls, sizeof(max_out_calls));
8864 
8865  if (max_out_calls >= 0 && max_out_calls <= misdn_out_calls[port]) {
8866  ast_log(LOG_NOTICE, "Rejecting Outgoing Call on port[%d]\n", port);
8867  return (misdn_out_calls[port] + 1) - max_out_calls;
8868  }
8869 
8870  misdn_out_calls[port]++;
8871 
8872  return 0;
8873 }
#define ast_log
Definition: astobj2.c:42
void misdn_cfg_get(int port, enum misdn_cfg_elements elem, void *buf, int bufsize)
Definition: misdn_config.c:569
#define LOG_NOTICE
Definition: logger.h:263
static int * misdn_out_calls
Definition: chan_misdn.c:699

◆ AST_MODULE_SELF_SYM()

struct ast_module* AST_MODULE_SELF_SYM ( void  )

Definition at line 12838 of file chan_misdn.c.

◆ ast_to_misdn_plan()

static enum mISDN_NUMBER_PLAN ast_to_misdn_plan ( unsigned  ast_number_plan)
static

Definition at line 2042 of file chan_misdn.c.

References NUMPLAN_DATA, NUMPLAN_ISDN, NUMPLAN_NATIONAL, NUMPLAN_PRIVATE, NUMPLAN_TELEX, and NUMPLAN_UNKNOWN.

Referenced by misdn_call(), misdn_copy_redirecting_from_ast(), and misdn_get_connected_line().

2043 {
2044  enum mISDN_NUMBER_PLAN number_plan;
2045 
2046  switch (ast_number_plan & 0x0F) {
2047  default:
2048  case NUMPLAN_UNKNOWN:
2049  number_plan = NUMPLAN_UNKNOWN;
2050  break;
2051 
2052  case NUMPLAN_ISDN:
2053  number_plan = NUMPLAN_ISDN;
2054  break;
2055 
2056  case NUMPLAN_DATA:
2057  number_plan = NUMPLAN_DATA;
2058  break;
2059 
2060  case NUMPLAN_TELEX:
2061  number_plan = NUMPLAN_TELEX;
2062  break;
2063 
2064  case NUMPLAN_NATIONAL:
2065  number_plan = NUMPLAN_NATIONAL;
2066  break;
2067 
2068  case NUMPLAN_PRIVATE:
2069  number_plan = NUMPLAN_PRIVATE;
2070  break;
2071  }
2072 
2073  return number_plan;
2074 }
mISDN_NUMBER_PLAN
Definition: isdn_lib.h:92

◆ ast_to_misdn_pres()

static int ast_to_misdn_pres ( int  presentation)
static

Definition at line 2145 of file chan_misdn.c.

References AST_PRES_ALLOWED, AST_PRES_RESTRICTED, AST_PRES_RESTRICTION, and AST_PRES_UNAVAILABLE.

Referenced by misdn_copy_redirecting_from_ast(), misdn_get_connected_line(), and update_config().

2146 {
2147  switch (presentation & AST_PRES_RESTRICTION) {
2148  default:
2149  case AST_PRES_ALLOWED:
2150  presentation = 0;
2151  break;
2152 
2153  case AST_PRES_RESTRICTED:
2154  presentation = 1;
2155  break;
2156 
2157  case AST_PRES_UNAVAILABLE:
2158  presentation = 2;
2159  break;
2160  }
2161 
2162  return presentation;
2163 }
#define AST_PRES_RESTRICTED
Definition: callerid.h:325
#define AST_PRES_RESTRICTION
Definition: callerid.h:323
#define AST_PRES_ALLOWED
Definition: callerid.h:324
#define AST_PRES_UNAVAILABLE
Definition: callerid.h:326

◆ ast_to_misdn_reason()

static enum mISDN_REDIRECTING_REASON ast_to_misdn_reason ( const enum AST_REDIRECTING_REASON  ast)
static

Definition at line 2274 of file chan_misdn.c.

References ARRAY_LEN, AST_REDIRECTING_REASON_AWAY, AST_REDIRECTING_REASON_CALL_FWD_DTE, AST_REDIRECTING_REASON_DEFLECTION, AST_REDIRECTING_REASON_DO_NOT_DISTURB, AST_REDIRECTING_REASON_FOLLOW_ME, AST_REDIRECTING_REASON_NO_ANSWER, AST_REDIRECTING_REASON_OUT_OF_ORDER, AST_REDIRECTING_REASON_TIME_OF_DAY, AST_REDIRECTING_REASON_UNAVAILABLE, AST_REDIRECTING_REASON_UNCONDITIONAL, AST_REDIRECTING_REASON_UNKNOWN, AST_REDIRECTING_REASON_USER_BUSY, mISDN_REDIRECTING_REASON_CALL_FWD, mISDN_REDIRECTING_REASON_CALL_FWD_BUSY, mISDN_REDIRECTING_REASON_CALL_FWD_DTE, mISDN_REDIRECTING_REASON_DEFLECTION, mISDN_REDIRECTING_REASON_NO_REPLY, mISDN_REDIRECTING_REASON_OUT_OF_ORDER, and mISDN_REDIRECTING_REASON_UNKNOWN.

Referenced by misdn_copy_redirecting_from_ast().

2275 {
2276  unsigned index;
2277 
2278  static const struct misdn_reasons {
2279  enum AST_REDIRECTING_REASON ast;
2280  enum mISDN_REDIRECTING_REASON q931;
2281  } misdn_reason_table[] = {
2282  /* *INDENT-OFF* */
2286  { AST_REDIRECTING_REASON_UNAVAILABLE, mISDN_REDIRECTING_REASON_NO_REPLY },
2288  { AST_REDIRECTING_REASON_TIME_OF_DAY, mISDN_REDIRECTING_REASON_UNKNOWN },
2289  { AST_REDIRECTING_REASON_DO_NOT_DISTURB, mISDN_REDIRECTING_REASON_UNKNOWN },
2291  { AST_REDIRECTING_REASON_FOLLOW_ME, mISDN_REDIRECTING_REASON_UNKNOWN },
2293  { AST_REDIRECTING_REASON_AWAY, mISDN_REDIRECTING_REASON_UNKNOWN },
2295  /* *INDENT-ON* */
2296  };
2297 
2298  for (index = 0; index < ARRAY_LEN(misdn_reason_table); ++index) {
2299  if (misdn_reason_table[index].ast == ast) {
2300  return misdn_reason_table[index].q931;
2301  }
2302  }
2304 }
#define ARRAY_LEN(a)
Definition: isdn_lib.c:42
mISDN_REDIRECTING_REASON
Q.931 encoded redirecting reason.
Definition: isdn_lib.h:197
AST_REDIRECTING_REASON
redirecting reason codes.
Definition: callerid.h:390

◆ ast_to_misdn_screen()

static int ast_to_misdn_screen ( int  screening)
static

Definition at line 2242 of file chan_misdn.c.

References AST_PRES_NETWORK_NUMBER, AST_PRES_NUMBER_TYPE, AST_PRES_USER_NUMBER_FAILED_SCREEN, AST_PRES_USER_NUMBER_PASSED_SCREEN, and AST_PRES_USER_NUMBER_UNSCREENED.

Referenced by misdn_copy_redirecting_from_ast(), misdn_get_connected_line(), and update_config().

2243 {
2244  switch (screening & AST_PRES_NUMBER_TYPE) {
2245  default:
2247  screening = 0;
2248  break;
2249 
2251  screening = 1;
2252  break;
2253 
2255  screening = 2;
2256  break;
2257 
2259  screening = 3;
2260  break;
2261  }
2262 
2263  return screening;
2264 }
#define AST_PRES_USER_NUMBER_FAILED_SCREEN
Definition: callerid.h:320
#define AST_PRES_NETWORK_NUMBER
Definition: callerid.h:321
#define AST_PRES_USER_NUMBER_UNSCREENED
Definition: callerid.h:318
#define AST_PRES_NUMBER_TYPE
Definition: callerid.h:317
#define AST_PRES_USER_NUMBER_PASSED_SCREEN
Definition: callerid.h:319

◆ ast_to_misdn_ton()

static enum mISDN_NUMBER_TYPE ast_to_misdn_ton ( unsigned  ast_number_type)
static

Definition at line 1916 of file chan_misdn.c.

References NUMTYPE_ABBREVIATED, NUMTYPE_INTERNATIONAL, NUMTYPE_NATIONAL, NUMTYPE_NETWORK_SPECIFIC, NUMTYPE_SUBSCRIBER, and NUMTYPE_UNKNOWN.

Referenced by misdn_call(), misdn_copy_redirecting_from_ast(), and misdn_get_connected_line().

1917 {
1918  enum mISDN_NUMBER_TYPE number_type;
1919 
1920  switch ((ast_number_type >> 4) & 0x07) {
1921  default:
1922  case NUMTYPE_UNKNOWN:
1923  number_type = NUMTYPE_UNKNOWN;
1924  break;
1925 
1926  case NUMTYPE_INTERNATIONAL:
1927  number_type = NUMTYPE_INTERNATIONAL;
1928  break;
1929 
1930  case NUMTYPE_NATIONAL:
1931  number_type = NUMTYPE_NATIONAL;
1932  break;
1933 
1935  number_type = NUMTYPE_NETWORK_SPECIFIC;
1936  break;
1937 
1938  case NUMTYPE_SUBSCRIBER:
1939  number_type = NUMTYPE_SUBSCRIBER;
1940  break;
1941 
1942  case NUMTYPE_ABBREVIATED:
1943  number_type = NUMTYPE_ABBREVIATED;
1944  break;
1945  }
1946 
1947  return number_type;
1948 }
mISDN_NUMBER_TYPE
Definition: isdn_lib.h:101

◆ bearer2str()

static const char* bearer2str ( int  cap)
static

Definition at line 2373 of file chan_misdn.c.

References ARRAY_LEN, ast_copy_string(), chan_misdn_log(), allowed_bearers::display, misdn_party_id::number, misdn_party_id::number_plan, misdn_party_id::number_type, NUMPLAN_ISDN, NUMTYPE_UNKNOWN, misdn_bchannel::port, and misdn_party_id::presentation.

Referenced by cb_events(), print_bc_info(), and print_bearer().

2374 {
2375  unsigned index;
2376 
2377  for (index = 0; index < ARRAY_LEN(allowed_bearers_array); ++index) {
2378  if (allowed_bearers_array[index].cap == cap) {
2379  return allowed_bearers_array[index].display;
2380  }
2381  }
2382 
2383  return "Unknown Bearer";
2384 }
#define ARRAY_LEN(a)
Definition: isdn_lib.c:42
static const struct allowed_bearers allowed_bearers_array[]
Definition: chan_misdn.c:2362

◆ cb_events()

static enum event_response_e cb_events ( enum event_e  event,
struct misdn_bchannel bc,
void *  user_data 
)
static

queue new chan

Supplementary Services

Definition at line 9917 of file chan_misdn.c.

References add_in_calls(), misdn_bchannel::addr, chan_list::addr, chan_list::allowed_bearers, ao2_cleanup, ao2_ref, misdn_bchannel::AOCD_need_export, args, ARRAY_LEN, chan_list::ast, AST_APP_ARG, ast_canmatch_extension(), AST_CAUSE_DESTINATION_OUT_OF_ORDER, AST_CAUSE_INCOMPATIBLE_DESTINATION, AST_CAUSE_NORMAL_CLEARING, AST_CAUSE_UNALLOCATED, AST_CAUSE_USER_BUSY, ast_channel_bridge_peer(), ast_channel_caller(), ast_channel_cleanup, ast_channel_exten(), ast_channel_exten_set(), ast_channel_generator(), ast_channel_generatordata(), ast_channel_generatordata_set(), ast_channel_hangupcause_set(), ast_channel_lock, ast_channel_queue_redirecting_update(), ast_channel_redirecting(), ast_channel_rings_set(), ast_channel_transfercapability_set(), ast_channel_unlock, AST_CONNECTED_LINE_UPDATE_SOURCE_ANSWER, AST_CONNECTED_LINE_UPDATE_SOURCE_TRANSFER, AST_CONNECTED_LINE_UPDATE_SOURCE_TRANSFER_ALERTING, AST_CONTROL_ANSWER, AST_CONTROL_BUSY, AST_CONTROL_PROCEEDING, AST_CONTROL_PROGRESS, AST_CONTROL_RINGING, ast_copy_string(), ast_deactivate_generator(), AST_DECLARE_APP_ARGS, ast_exists_extension(), ast_format_alaw, ast_format_cap_alloc, ast_format_cap_append, AST_FORMAT_CAP_FLAG_DEFAULT, AST_FRAME_DTMF, AST_FRAME_VOICE, ast_get_chan_features_pickup_config(), AST_LIST_LOCK, AST_LIST_UNLOCK, ast_log, ast_mutex_lock, ast_mutex_unlock, ast_named_caller_presentation(), ast_party_id_reset(), ast_party_redirecting_copy(), ast_party_redirecting_free(), ast_party_redirecting_init(), ast_pickup_call(), ast_poll, AST_PRES_RESTRICTED, AST_PRES_USER_NUMBER_UNSCREENED, ast_queue_control(), ast_queue_frame(), ast_queue_hold(), ast_queue_unhold(), ast_set_callerid(), ast_setstate(), AST_STANDARD_APP_ARGS, AST_STATE_RESERVED, AST_STATE_RINGING, ast_strdup, ast_strdupa, ast_strlen_zero, ast_transfercapability2str(), ast_tv(), ast_tvnow(), bc, chan_list::bc, misdn_bchannel::bc_state, bc_state2str(), bearer2str(), misdn_bchannel::bframe, misdn_bchannel::bframe_len, buf, misdn_bchannel::caller, misdn_bchannel::capability, misdn_bchannel::cause, cb_log, chan_list_init(), chan_list_unref, chan_misdn_log(), hold_info::channel, misdn_bchannel::channel, cl_queue_chan(), misdn_bchannel::connected, chan_list::context, misdn_bchannel::cw, ast_frame::data, ast_frame::datalen, ast_frame::delivery, misdn_bchannel::dialed, do_immediate_setup(), misdn_bchannel::dtmf, misdn_bchannel::dummy, errno, EVENT_ALERTING, EVENT_BCHAN_ACTIVATED, EVENT_BCHAN_DATA, EVENT_BCHAN_ERROR, EVENT_CLEANUP, EVENT_CONNECT, EVENT_CONNECT_ACKNOWLEDGE, EVENT_DISCONNECT, EVENT_DTMF_TONE, EVENT_FACILITY, EVENT_HOLD, EVENT_HOLD_ACKNOWLEDGE, EVENT_HOLD_REJECT, EVENT_INFORMATION, EVENT_NEW_BC, EVENT_NEW_CHANNEL, EVENT_NEW_L3ID, EVENT_NOTIFY, EVENT_PORT_ALARM, EVENT_PROCEEDING, EVENT_PROGRESS, EVENT_REGISTER, EVENT_RELEASE, EVENT_RELEASE_COMPLETE, EVENT_RESTART, EVENT_RETRIEVE, EVENT_RETRIEVE_ACKNOWLEDGE, EVENT_RETRIEVE_REJECT, EVENT_SETUP, EVENT_SETUP_ACKNOWLEDGE, EVENT_STATUS, EVENT_TIMEOUT, EVENT_TONE_GENERATE, export_aoc_vars(), export_ch(), misdn_bchannel::fac_in, misdn_bchannel::fac_out, chan_list::far_alerting, find_chan_by_bc(), find_hold_active_call(), find_hold_call(), find_hold_call_l3(), ast_frame_subclass::format, ast_frame::frametype, misdn_party_redirecting::from, ast_generator::generate, hangup_chan(), hanguptone_indicate(), chan_list::hold, ast_party_caller::id, chan_list::ignore_dtmf, misdn_bchannel::incoming_cid_tag, INFO_CAPABILITY_DIGITAL_UNRESTRICTED, misdn_bchannel::info_dad, INFO_PI_INBAND_AVAILABLE, misdn_bchannel::infos_pending, ast_frame_subclass::integer, misdn_bchannel::keypad, misdn_bchannel::l3_id, chan_list::l3id, LOG_ERROR, LOG_NOTICE, LOG_WARNING, ast_frame::mallocd, manager_isdn_get_info(), misdn_add_number_prefix(), MISDN_ALERTING, MISDN_ASTERISK_TECH_PVT, misdn_attempt_transfer(), MISDN_CALLING, MISDN_CALLING_ACKNOWLEDGE, misdn_cap_is_speech(), MISDN_CFG_ALARM_BLOCK, MISDN_CFG_ALWAYS_IMMEDIATE, MISDN_CFG_APPEND_MSN_TO_CALLERID_TAG, misdn_cfg_get(), MISDN_CFG_HOLD_ALLOWED, MISDN_CFG_IMMEDIATE, MISDN_CFG_REJECT_CAUSE, MISDN_CLEANING, MISDN_CONNECTED, misdn_copy_redirecting_to_ast(), MISDN_DIALING, MISDN_DISCONNECTED, MISDN_EXTCANTMATCH, misdn_facility_ie_handler(), MISDN_GEN_APPEND_DIGITS2EXTEN, misdn_get_ch_state(), MISDN_HOLD_ACTIVE, MISDN_HOLD_DISCONNECT, MISDN_HOLD_IDLE, misdn_inband_avail(), MISDN_INCOMING_SETUP, misdn_is_msn_valid(), misdn_lib_is_ptp(), misdn_lib_log_ies(), misdn_lib_port_block(), misdn_lib_send_event(), misdn_new(), MISDN_NOTHING, mISDN_NOTIFY_CODE_CALL_IS_DIVERTING, mISDN_NOTIFY_CODE_CALL_TRANSFER_ACTIVE, mISDN_NOTIFY_CODE_CALL_TRANSFER_ALERTING, mISDN_NOTIFY_CODE_DIVERSION_ACTIVATED, mISDN_NOTIFY_CODE_INVALID, misdn_overlap_dial_task(), MISDN_PROCEEDING, MISDN_PROGRESS, mISDN_REDIRECTING_REASON_NO_REPLY, mISDN_REDIRECTING_REASON_UNKNOWN, misdn_tasks_add_variable(), misdn_to_ast_plan(), misdn_to_ast_pres(), misdn_to_ast_screen(), misdn_to_ast_ton(), misdn_to_str_plan(), misdn_to_str_pres(), misdn_to_str_screen(), misdn_to_str_ton(), misdn_update_remote_party(), MISDN_WAITING4DIGS, ast_custom_function::name, misdn_party_id::name, allowed_bearers::name, chan_list::need_busy, misdn_bchannel::need_disconnect, misdn_bchannel::need_more_infos, misdn_bchannel::need_release, misdn_bchannel::need_release_complete, chan_list::noautorespond_on_setup, misdn_bchannel::notify_description_code, misdn_bchannel::nt, chan_list::nttimeout, NULL, misdn_party_dialing::number, misdn_party_id::number, ast_party_id::number, misdn_party_id::number_plan, misdn_party_id::number_type, ast_frame::offset, ORG_AST, ORG_MISDN, chan_list::originator, misdn_bchannel::out_cause, chan_list::overlap_dial, chan_list::overlap_dial_task, chan_list::overlap_tv, chan_list::overlap_tv_lock, parse(), pbx_builtin_setvar_helper(), misdn_bchannel::pid, chan_list::pipe, ast_party_number::plan, hold_info::port, misdn_bchannel::port, misdn_party_id::presentation, ast_party_number::presentation, print_bearer(), ast_party_redirecting::priv_from, ast_party_redirecting::priv_orig, ast_party_redirecting::priv_to, misdn_bchannel::progress_indicator, ast_frame::ptr, RAII_VAR, read_config(), misdn_party_redirecting::reason, misdn_bchannel::redirecting, release_chan(), RESPONSE_ERR, RESPONSE_IGNORE_SETUP, RESPONSE_IGNORE_SETUP_WITHOUT_CLOSE, RESPONSE_OK, RESPONSE_RELEASE_SETUP, misdn_jb::samples, ast_frame::samples, misdn_party_id::screening, misdn_bchannel::sending_complete, misdn_jb::size, ast_frame::src, start_bc_tones(), start_pbx(), hold_info::state, chan_list::state, stop_bc_tones(), stop_indicate(), ast_frame::subclass, ast_party_id::tag, tmp(), misdn_party_redirecting::to, ast_party_redirecting::to, misdn_party_redirecting::to_changed, misdn_bchannel::tone_cnt, update_name(), and wait_for_digits().

Referenced by load_module().

9918 {
9919 #if defined(AST_MISDN_ENHANCEMENTS)
9920  struct misdn_cc_record *cc_record;
9921 #endif /* defined(AST_MISDN_ENHANCEMENTS) */
9922  struct chan_list *held_ch;
9923  struct chan_list *ch = find_chan_by_bc(bc);
9924 
9926  int debuglevel = 1;
9927 
9928  /* Debug Only Non-Bchan */
9929  if (event == EVENT_CLEANUP && !user_data) {
9930  debuglevel = 5;
9931  }
9932 
9933  chan_misdn_log(debuglevel, bc->port,
9934  "I IND :%s caller:\"%s\" <%s> dialed:%s pid:%d state:%s\n",
9936  bc->caller.name,
9937  bc->caller.number,
9938  bc->dialed.number,
9939  bc->pid,
9940  ch ? misdn_get_ch_state(ch) : "none");
9941  if (debuglevel == 1) {
9942  misdn_lib_log_ies(bc);
9943  chan_misdn_log(4, bc->port, " --> bc_state:%s\n", bc_state2str(bc->bc_state));
9944  }
9945  }
9946 
9947  if (!ch) {
9948  switch(event) {
9949  case EVENT_SETUP:
9950  case EVENT_DISCONNECT:
9951  case EVENT_RELEASE:
9953  case EVENT_PORT_ALARM:
9954  case EVENT_RETRIEVE:
9955  case EVENT_NEW_BC:
9956  case EVENT_FACILITY:
9957  case EVENT_REGISTER:
9958  break;
9959  case EVENT_CLEANUP:
9960  case EVENT_TONE_GENERATE:
9961  case EVENT_BCHAN_DATA:
9962  return -1;
9963  default:
9964  chan_misdn_log(1, bc->port, "Chan not existing at the moment bc->l3id:%x bc:%p event:%s port:%d channel:%d\n", bc->l3_id, bc, manager_isdn_get_info(event), bc->port, bc->channel);
9965  return -1;
9966  }
9967  } else {
9968  switch (event) {
9969  case EVENT_TONE_GENERATE:
9970  break;
9971  case EVENT_DISCONNECT:
9972  case EVENT_RELEASE:
9974  case EVENT_CLEANUP:
9975  case EVENT_TIMEOUT:
9976  if (!ch->ast) {
9977  chan_misdn_log(3, bc->port, "ast_hangup already called, so we have no ast ptr anymore in event(%s)\n", manager_isdn_get_info(event));
9978  }
9979  break;
9980  default:
9981  if (!ch->ast || !MISDN_ASTERISK_TECH_PVT(ch->ast)) {
9982  if (event != EVENT_BCHAN_DATA) {
9983  ast_log(LOG_NOTICE, "No Ast or No private Pointer in Event (%d:%s)\n", event, manager_isdn_get_info(event));
9984  }
9985  chan_list_unref(ch, "No Ast or Ast private pointer");
9986  return -1;
9987  }
9988  break;
9989  }
9990  }
9991 
9992 
9993  switch (event) {
9994  case EVENT_PORT_ALARM:
9995  {
9996  int boa = 0;
9997  misdn_cfg_get(bc->port, MISDN_CFG_ALARM_BLOCK, &boa, sizeof(boa));
9998  if (boa) {
9999  cb_log(1, bc->port, " --> blocking\n");
10001  }
10002  }
10003  break;
10004  case EVENT_BCHAN_ACTIVATED:
10005  break;
10006 
10007  case EVENT_NEW_CHANNEL:
10008  update_name(ch->ast,bc->port,bc->channel);
10009  break;
10010 
10011  case EVENT_NEW_L3ID:
10012  ch->l3id=bc->l3_id;
10013  ch->addr=bc->addr;
10014  break;
10015 
10016  case EVENT_NEW_BC:
10017  if (!ch) {
10018  ch = find_hold_call(bc);
10019  }
10020 
10021  if (!ch) {
10022  ast_log(LOG_WARNING, "NEW_BC without chan_list?\n");
10023  break;
10024  }
10025 
10026  if (bc) {
10027  ch->bc = (struct misdn_bchannel *) user_data;
10028  }
10029  break;
10030 
10031  case EVENT_DTMF_TONE:
10032  {
10033  /* sending INFOS as DTMF-Frames :) */
10034  struct ast_frame fr;
10035 
10036  memset(&fr, 0, sizeof(fr));
10037  fr.frametype = AST_FRAME_DTMF;
10038  fr.subclass.integer = bc->dtmf ;
10039  fr.src = NULL;
10040  fr.data.ptr = NULL;
10041  fr.datalen = 0;
10042  fr.samples = 0;
10043  fr.mallocd = 0;
10044  fr.offset = 0;
10045  fr.delivery = ast_tv(0,0);
10046 
10047  if (!ch->ignore_dtmf) {
10048  chan_misdn_log(2, bc->port, " --> DTMF:%c\n", bc->dtmf);
10049  ast_queue_frame(ch->ast, &fr);
10050  } else {
10051  chan_misdn_log(2, bc->port, " --> Ignoring DTMF:%c due to bridge flags\n", bc->dtmf);
10052  }
10053  break;
10054  }
10055  case EVENT_STATUS:
10056  break;
10057 
10058  case EVENT_INFORMATION:
10059  if (ch->state != MISDN_CONNECTED) {
10060  stop_indicate(ch);
10061  }
10062 
10063  if (!ch->ast) {
10064  break;
10065  }
10066 
10067  if (ch->state == MISDN_WAITING4DIGS) {
10068  RAII_VAR(struct ast_features_pickup_config *, pickup_cfg, NULL, ao2_cleanup);
10069  const char *pickupexten;
10070 
10071  /* Ok, incomplete Setup, waiting till extension exists */
10072  if (ast_strlen_zero(bc->info_dad) && ! ast_strlen_zero(bc->keypad)) {
10073  chan_misdn_log(1, bc->port, " --> using keypad as info\n");
10074  ast_copy_string(bc->info_dad, bc->keypad, sizeof(bc->info_dad));
10075  }
10076 
10077  strncat(bc->dialed.number, bc->info_dad, sizeof(bc->dialed.number) - strlen(bc->dialed.number) - 1);
10079 
10080  ast_channel_lock(ch->ast);
10081  pickup_cfg = ast_get_chan_features_pickup_config(ch->ast);
10082  if (!pickup_cfg) {
10083  ast_log(LOG_ERROR, "Unable to retrieve pickup configuration options. Unable to detect call pickup extension\n");
10084  pickupexten = "";
10085  } else {
10086  pickupexten = ast_strdupa(pickup_cfg->pickupexten);
10087  }
10088  ast_channel_unlock(ch->ast);
10089 
10090  /* Check for Pickup Request first */
10091  if (!strcmp(ast_channel_exten(ch->ast), pickupexten)) {
10092  if (ast_pickup_call(ch->ast)) {
10093  hangup_chan(ch, bc);
10094  } else {
10096  hangup_chan(ch, bc);
10097  ch->ast = NULL;
10098  break;
10099  }
10100  }
10101 
10102  if (!ast_canmatch_extension(ch->ast, ch->context, bc->dialed.number, 1, bc->caller.number)) {
10103  if (ast_exists_extension(ch->ast, ch->context, "i", 1, bc->caller.number)) {
10105  "Extension '%s@%s' can never match. Jumping to 'i' extension. port:%d\n",
10106  bc->dialed.number, ch->context, bc->port);
10107  pbx_builtin_setvar_helper(ch->ast, "INVALID_EXTEN", bc->dialed.number);
10108  ast_channel_exten_set(ch->ast, "i");
10109  ch->state = MISDN_DIALING;
10110  start_pbx(ch, bc, ch->ast);
10111  break;
10112  }
10113 
10115  "Extension '%s@%s' can never match. Disconnecting. port:%d\n"
10116  "\tMaybe you want to add an 'i' extension to catch this case.\n",
10117  bc->dialed.number, ch->context, bc->port);
10118 
10119  if (bc->nt) {
10120  hanguptone_indicate(ch);
10121  }
10122  ch->state = MISDN_EXTCANTMATCH;
10124 
10126  break;
10127  }
10128 
10129  if (ch->overlap_dial) {
10131  ch->overlap_tv = ast_tvnow();
10133  if (ch->overlap_dial_task == -1) {
10134  ch->overlap_dial_task =
10136  }
10137  break;
10138  }
10139 
10140  if (ast_exists_extension(ch->ast, ch->context, bc->dialed.number, 1, bc->caller.number)) {
10141  ch->state = MISDN_DIALING;
10142  start_pbx(ch, bc, ch->ast);
10143  }
10144  } else {
10145  /* sending INFOS as DTMF-Frames :) */
10146  struct ast_frame fr;
10147  int digits;
10148 
10149  memset(&fr, 0, sizeof(fr));
10150  fr.frametype = AST_FRAME_DTMF;
10151  fr.subclass.integer = bc->info_dad[0] ;
10152  fr.src = NULL;
10153  fr.data.ptr = NULL;
10154  fr.datalen = 0;
10155  fr.samples = 0;
10156  fr.mallocd = 0;
10157  fr.offset = 0;
10158  fr.delivery = ast_tv(0,0);
10159 
10160  misdn_cfg_get(0, MISDN_GEN_APPEND_DIGITS2EXTEN, &digits, sizeof(digits));
10161  if (ch->state != MISDN_CONNECTED) {
10162  if (digits) {
10163  strncat(bc->dialed.number, bc->info_dad, sizeof(bc->dialed.number) - strlen(bc->dialed.number) - 1);
10165  }
10166 
10167  ast_queue_frame(ch->ast, &fr);
10168  }
10169  }
10170  break;
10171  case EVENT_SETUP:
10172  {
10173  struct ast_channel *chan;
10174  int exceed;
10175  int ai;
10176  int im;
10177  int append_msn = 0;
10178  RAII_VAR(struct ast_features_pickup_config *, pickup_cfg, NULL, ao2_cleanup);
10179  const char *pickupexten;
10180 
10181  if (ch) {
10182  switch (ch->state) {
10183  case MISDN_NOTHING:
10184  chan_list_unref(ch, "Ignore found ch. Is it for an outgoing call?");
10185  ch = NULL;
10186  break;
10187  default:
10188  chan_list_unref(ch, "Already have a call.");
10189  chan_misdn_log(1, bc->port, " --> Ignoring Call we have already one\n");
10190  return RESPONSE_IGNORE_SETUP_WITHOUT_CLOSE; /* Ignore MSNs which are not in our List */
10191  }
10192  }
10193 
10194  if (!bc->nt && !misdn_is_msn_valid(bc->port, &bc->dialed)) {
10195  chan_misdn_log(1, bc->port, " --> Ignoring Call, its not in our MSN List\n");
10196  return RESPONSE_IGNORE_SETUP; /* Ignore MSNs which are not in our List */
10197  }
10198 
10199  if (bc->cw) {
10200  int cause;
10201  chan_misdn_log(0, bc->port, " --> Call Waiting on PMP sending RELEASE_COMPLETE\n");
10202  misdn_cfg_get(bc->port, MISDN_CFG_REJECT_CAUSE, &cause, sizeof(cause));
10203  bc->out_cause = cause ? cause : AST_CAUSE_NORMAL_CLEARING;
10204  return RESPONSE_RELEASE_SETUP;
10205  }
10206 
10207  print_bearer(bc);
10208 
10209  ch = chan_list_init(ORG_MISDN);
10210  if (!ch) {
10211  chan_misdn_log(-1, bc->port, "cb_events: malloc for chan_list failed!\n");
10212  return RESPONSE_RELEASE_SETUP;
10213  }
10214 
10215  ch->bc = bc;
10216  ch->l3id = bc->l3_id;
10217  ch->addr = bc->addr;
10218 
10219  {
10221  if (!(cap)) {
10222  return RESPONSE_ERR;
10223  }
10225  chan = misdn_new(ch, AST_STATE_RESERVED, bc->dialed.number, bc->caller.number, cap, NULL, NULL, bc->port, bc->channel);
10226  ao2_ref(cap, -1);
10227  }
10228  if (!chan) {
10229  chan_list_unref(ch, "Failed to create a new channel");
10230  ast_log(LOG_ERROR, "cb_events: misdn_new failed!\n");
10231  return RESPONSE_RELEASE_SETUP;
10232  }
10233 
10234  ast_channel_lock(chan);
10235  pickup_cfg = ast_get_chan_features_pickup_config(chan);
10236  if (!pickup_cfg) {
10237  ast_log(LOG_ERROR, "Unable to retrieve pickup configuration options. Unable to detect call pickup extension\n");
10238  pickupexten = "";
10239  } else {
10240  pickupexten = ast_strdupa(pickup_cfg->pickupexten);
10241  }
10242  ast_channel_unlock(chan);
10243 
10244  if ((exceed = add_in_calls(bc->port))) {
10245  char tmp[16];
10246  snprintf(tmp, sizeof(tmp), "%d", exceed);
10247  pbx_builtin_setvar_helper(chan, "MAX_OVERFLOW", tmp);
10248  }
10249 
10250  read_config(ch);
10251 
10252  export_ch(chan, bc, ch);
10253 
10254  ast_channel_lock(ch->ast);
10255  ast_channel_rings_set(ch->ast, 1);
10257  ast_channel_unlock(ch->ast);
10258 
10259  /* Update asterisk channel caller information */
10260  chan_misdn_log(2, bc->port, " --> TON: %s(%d)\n", misdn_to_str_ton(bc->caller.number_type), bc->caller.number_type);
10261  chan_misdn_log(2, bc->port, " --> PLAN: %s(%d)\n", misdn_to_str_plan(bc->caller.number_plan), bc->caller.number_plan);
10264 
10265  chan_misdn_log(2, bc->port, " --> PRES: %s(%d)\n", misdn_to_str_pres(bc->caller.presentation), bc->caller.presentation);
10266  chan_misdn_log(2, bc->port, " --> SCREEN: %s(%d)\n", misdn_to_str_screen(bc->caller.screening), bc->caller.screening);
10269 
10270  ast_set_callerid(chan, bc->caller.number, NULL, bc->caller.number);
10271 
10272  misdn_cfg_get(bc->port, MISDN_CFG_APPEND_MSN_TO_CALLERID_TAG, &append_msn, sizeof(append_msn));
10273  if (append_msn) {
10274  strncat(bc->incoming_cid_tag, "_", sizeof(bc->incoming_cid_tag) - strlen(bc->incoming_cid_tag) - 1);
10275  strncat(bc->incoming_cid_tag, bc->dialed.number, sizeof(bc->incoming_cid_tag) - strlen(bc->incoming_cid_tag) - 1);
10276  }
10277 
10278  ast_channel_lock(chan);
10280  ast_channel_unlock(chan);
10281 
10282  if (!ast_strlen_zero(bc->redirecting.from.number)) {
10283  /* Add configured prefix to redirecting.from.number */
10285 
10286  /* Update asterisk channel redirecting information */
10288  }
10289 
10290  pbx_builtin_setvar_helper(chan, "TRANSFERCAPABILITY", ast_transfercapability2str(bc->capability));
10292 
10293  switch (bc->capability) {
10295  pbx_builtin_setvar_helper(chan, "CALLTYPE", "DIGITAL");
10296  break;
10297  default:
10298  pbx_builtin_setvar_helper(chan, "CALLTYPE", "SPEECH");
10299  break;
10300  }
10301 
10302  if (!strstr(ch->allowed_bearers, "all")) {
10303  int i;
10304 
10305  for (i = 0; i < ARRAY_LEN(allowed_bearers_array); ++i) {
10306  if (allowed_bearers_array[i].cap == bc->capability) {
10307  if (strstr(ch->allowed_bearers, allowed_bearers_array[i].name)) {
10308  /* The bearer capability is allowed */
10309  if (allowed_bearers_array[i].deprecated) {
10310  chan_misdn_log(0, bc->port, "%s in allowed_bearers list is deprecated\n",
10312  }
10313  break;
10314  }
10315  }
10316  }
10317  if (i == ARRAY_LEN(allowed_bearers_array)) {
10318  /* We did not find the bearer capability */
10319  chan_misdn_log(0, bc->port, "Bearer capability not allowed: %s(%d)\n",
10320  bearer2str(bc->capability), bc->capability);
10321 
10322  ch->state = MISDN_EXTCANTMATCH;
10323  chan_list_unref(ch, "BC not allowed, releasing call");
10325  return RESPONSE_RELEASE_SETUP;
10326  }
10327  }
10328 
10329  /** queue new chan **/
10330  cl_queue_chan(ch);
10331 
10332  if (bc->fac_in.Function != Fac_None) {
10334  }
10335 
10336  /* Check for Pickup Request first */
10337  if (!strcmp(ast_channel_exten(chan), pickupexten)) {
10338  if (!ch->noautorespond_on_setup) {
10339  /* Sending SETUP_ACK */
10341  } else {
10343  }
10344  if (ast_pickup_call(chan)) {
10345  hangup_chan(ch, bc);
10346  } else {
10348  hangup_chan(ch, bc);
10349  ch->ast = NULL;
10350  break;
10351  }
10352  }
10353 
10354  /*
10355  * added support for s extension hope it will help those poor cretains
10356  * which haven't overlap dial.
10357  */
10358  misdn_cfg_get(bc->port, MISDN_CFG_ALWAYS_IMMEDIATE, &ai, sizeof(ai));
10359  if (ai) {
10360  do_immediate_setup(bc, ch, chan);
10361  break;
10362  }
10363 
10364  /* check if we should jump into s when we have no dialed.number */
10365  misdn_cfg_get(bc->port, MISDN_CFG_IMMEDIATE, &im, sizeof(im));
10366  if (im && ast_strlen_zero(bc->dialed.number)) {
10367  do_immediate_setup(bc, ch, chan);
10368  break;
10369  }
10370 
10371  chan_misdn_log(5, bc->port, "CONTEXT:%s\n", ch->context);
10372  if (!ast_canmatch_extension(ch->ast, ch->context, bc->dialed.number, 1, bc->caller.number)) {
10373  if (ast_exists_extension(ch->ast, ch->context, "i", 1, bc->caller.number)) {
10375  "Extension '%s@%s' can never match. Jumping to 'i' extension. port:%d\n",
10376  bc->dialed.number, ch->context, bc->port);
10377  pbx_builtin_setvar_helper(ch->ast, "INVALID_EXTEN", bc->dialed.number);
10378  ast_channel_exten_set(ch->ast, "i");
10380  ch->state = MISDN_DIALING;
10381  start_pbx(ch, bc, chan);
10382  break;
10383  }
10384 
10386  "Extension '%s@%s' can never match. Disconnecting. port:%d\n"
10387  "\tMaybe you want to add an 'i' extension to catch this case.\n",
10388  bc->dialed.number, ch->context, bc->port);
10389  if (bc->nt) {
10390  hanguptone_indicate(ch);
10391  }
10392 
10393  ch->state = MISDN_EXTCANTMATCH;
10395 
10397  break;
10398  }
10399 
10400  /* Whatever happens, when sending_complete is set or we are PTMP TE, we will definitely
10401  * jump into the dialplan, when the dialed extension does not exist, the 's' extension
10402  * will be used by Asterisk automatically. */
10403  if (bc->sending_complete || (!bc->nt && !misdn_lib_is_ptp(bc->port))) {
10404  if (!ch->noautorespond_on_setup) {
10405  ch->state=MISDN_DIALING;
10407  } else {
10409  }
10410  start_pbx(ch, bc, chan);
10411  break;
10412  }
10413 
10414 
10415  /*
10416  * When we are NT and overlapdial is set and if
10417  * the number is empty, we wait for the ISDN timeout
10418  * instead of our own timer.
10419  */
10420  if (ch->overlap_dial && bc->nt && !bc->dialed.number[0]) {
10421  wait_for_digits(ch, bc, chan);
10422  break;
10423  }
10424 
10425  /*
10426  * If overlapdial we will definitely send a SETUP_ACKNOWLEDGE and wait for more
10427  * Infos with a Interdigit Timeout.
10428  * */
10429  if (ch->overlap_dial) {
10431  ch->overlap_tv = ast_tvnow();
10433 
10434  wait_for_digits(ch, bc, chan);
10435  if (ch->overlap_dial_task == -1) {
10436  ch->overlap_dial_task =
10438  }
10439  break;
10440  }
10441 
10442  /* If the extension does not exist and we're not TE_PTMP we wait for more digits
10443  * without interdigit timeout.
10444  * */
10445  if (!ast_exists_extension(ch->ast, ch->context, bc->dialed.number, 1, bc->caller.number)) {
10446  wait_for_digits(ch, bc, chan);
10447  break;
10448  }
10449 
10450  /*
10451  * If the extension exists let's just jump into it.
10452  * */
10453  if (ast_exists_extension(ch->ast, ch->context, bc->dialed.number, 1, bc->caller.number)) {
10455  ch->state = MISDN_DIALING;
10456  start_pbx(ch, bc, chan);
10457  break;
10458  }
10459  break;
10460  }
10461 #if defined(AST_MISDN_ENHANCEMENTS)
10462  case EVENT_REGISTER:
10463  if (bc->fac_in.Function != Fac_None) {
10465  }
10466  /*
10467  * Shut down this connection immediately.
10468  * The current design of chan_misdn data structures
10469  * does not allow the proper handling of inbound call records
10470  * without an assigned B channel. Therefore, we cannot
10471  * be the CCBS User-B party in a point-to-point setup.
10472  */
10473  bc->fac_out.Function = Fac_None;
10476  break;
10477 #endif /* defined(AST_MISDN_ENHANCEMENTS) */
10480 
10481  if (bc->channel) {
10482  update_name(ch->ast,bc->port,bc->channel);
10483  }
10484 
10485  if (bc->fac_in.Function != Fac_None) {
10487  }
10488 
10489  if (!ast_strlen_zero(bc->infos_pending)) {
10490  /* TX Pending Infos */
10491  strncat(bc->dialed.number, bc->infos_pending, sizeof(bc->dialed.number) - strlen(bc->dialed.number) - 1);
10492 
10493  if (!ch->ast) {
10494  break;
10495  }
10497  ast_copy_string(bc->info_dad, bc->infos_pending, sizeof(bc->info_dad));
10498  ast_copy_string(bc->infos_pending, "", sizeof(bc->infos_pending));
10499 
10501  }
10502  break;
10503  case EVENT_PROCEEDING:
10504  if (misdn_cap_is_speech(bc->capability) &&
10505  misdn_inband_avail(bc)) {
10506  start_bc_tones(ch);
10507  }
10508 
10509  ch->state = MISDN_PROCEEDING;
10510 
10511  if (bc->fac_in.Function != Fac_None) {
10513  }
10514 
10515  if (!ch->ast) {
10516  break;
10517  }
10518 
10520  break;
10521  case EVENT_PROGRESS:
10522  if (bc->channel) {
10523  update_name(ch->ast, bc->port, bc->channel);
10524  }
10525 
10526  if (bc->fac_in.Function != Fac_None) {
10528  }
10529 
10530  if (!bc->nt) {
10531  if (misdn_cap_is_speech(bc->capability) &&
10532  misdn_inband_avail(bc)) {
10533  start_bc_tones(ch);
10534  }
10535 
10536  ch->state = MISDN_PROGRESS;
10537 
10538  if (!ch->ast) {
10539  break;
10540  }
10542  }
10543  break;
10544  case EVENT_ALERTING:
10545  ch->state = MISDN_ALERTING;
10546 
10547  if (!ch->ast) {
10548  break;
10549  }
10550 
10551  if (bc->fac_in.Function != Fac_None) {
10553  }
10554 
10556  ast_channel_lock(ch->ast);
10558  ast_channel_unlock(ch->ast);
10559 
10560  cb_log(7, bc->port, " --> Set State Ringing\n");
10561 
10563  cb_log(1, bc->port, "Starting Tones, we have inband Data\n");
10564  start_bc_tones(ch);
10565  } else {
10566  cb_log(3, bc->port, " --> We have no inband Data, the other end must create ringing\n");
10567  if (ch->far_alerting) {
10568  cb_log(1, bc->port, " --> The other end can not do ringing eh ?.. we must do all ourself..");
10569  start_bc_tones(ch);
10570  /*tone_indicate(ch, TONE_FAR_ALERTING);*/
10571  }
10572  }
10573  break;
10574  case EVENT_CONNECT:
10575  if (bc->fac_in.Function != Fac_None) {
10577  }
10578 #if defined(AST_MISDN_ENHANCEMENTS)
10579  if (bc->div_leg_3_rx_wanted) {
10580  bc->div_leg_3_rx_wanted = 0;
10581 
10582  if (ch->ast) {
10583  struct ast_party_redirecting redirecting;
10584 
10587  ast_party_redirecting_init(&redirecting);
10589 
10590  /*
10591  * Reset any earlier private redirecting id representations and
10592  * make sure that it is invalidated at the remote end.
10593  */
10594  ast_party_id_reset(&redirecting.priv_orig);
10595  ast_party_id_reset(&redirecting.priv_from);
10596  ast_party_id_reset(&redirecting.priv_to);
10597 
10598  ast_channel_queue_redirecting_update(ch->ast, &redirecting, NULL);
10599  ast_party_redirecting_free(&redirecting);
10600  }
10601  }
10602 #endif /* defined(AST_MISDN_ENHANCEMENTS) */
10603 
10604  /* we answer when we've got our very new L3 ID from the NT stack */
10606 
10607  if (!ch->ast) {
10608  break;
10609  }
10610 
10611  stop_indicate(ch);
10612 
10613 #if defined(AST_MISDN_ENHANCEMENTS)
10614  if (ch->record_id != -1) {
10615  /*
10616  * We will delete the associated call completion
10617  * record since we now have a completed call.
10618  * We will not wait/depend on the network to tell
10619  * us to delete it.
10620  */
10621  AST_LIST_LOCK(&misdn_cc_records_db);
10622  cc_record = misdn_cc_find_by_id(ch->record_id);
10623  if (cc_record) {
10624  if (cc_record->ptp && cc_record->mode.ptp.bc) {
10625  /* Close the call-completion signaling link */
10626  cc_record->mode.ptp.bc->fac_out.Function = Fac_None;
10627  cc_record->mode.ptp.bc->out_cause = AST_CAUSE_NORMAL_CLEARING;
10628  misdn_lib_send_event(cc_record->mode.ptp.bc, EVENT_RELEASE_COMPLETE);
10629  }
10630  misdn_cc_delete(cc_record);
10631  }
10632  AST_LIST_UNLOCK(&misdn_cc_records_db);
10633  ch->record_id = -1;
10634  if (ch->peer) {
10635  misdn_cc_set_peer_var(ch->peer, MISDN_CC_RECORD_ID, "");
10636 
10637  ao2_ref(ch->peer, -1);
10638  ch->peer = NULL;
10639  }
10640  }
10641 #endif /* defined(AST_MISDN_ENHANCEMENTS) */
10642 
10643  if (!ast_strlen_zero(bc->connected.number)) {
10644  /* Add configured prefix to connected.number */
10646 
10647  /* Update the connected line information on the other channel */
10649  }
10650 
10651  ch->l3id = bc->l3_id;
10652  ch->addr = bc->addr;
10653 
10654  start_bc_tones(ch);
10655 
10656  ch->state = MISDN_CONNECTED;
10657 
10659  break;
10661  ch->l3id = bc->l3_id;
10662  ch->addr = bc->addr;
10663 
10664  start_bc_tones(ch);
10665 
10666  ch->state = MISDN_CONNECTED;
10667  break;
10668  case EVENT_DISCONNECT:
10669  /* we might not have an ch->ast ptr here anymore */
10670  if (ch) {
10671  if (bc->fac_in.Function != Fac_None) {
10673  }
10674 
10675  chan_misdn_log(3, bc->port, " --> org:%d nt:%d, inbandavail:%d state:%d\n", ch->originator, bc->nt, misdn_inband_avail(bc), ch->state);
10676  if (ch->originator == ORG_AST && !bc->nt && misdn_inband_avail(bc) && ch->state != MISDN_CONNECTED) {
10677  /* If there's inband information available (e.g. a
10678  recorded message saying what was wrong with the
10679  dialled number, or perhaps even giving an
10680  alternative number, then play it instead of
10681  immediately releasing the call */
10682  chan_misdn_log(1, bc->port, " --> Inband Info Avail, not sending RELEASE\n");
10683 
10684  ch->state = MISDN_DISCONNECTED;
10685  start_bc_tones(ch);
10686 
10687  if (ch->ast) {
10689  if (bc->cause == AST_CAUSE_USER_BUSY) {
10691  }
10692  }
10693  ch->need_busy = 0;
10694  break;
10695  }
10696 
10697  bc->need_disconnect = 0;
10698  stop_bc_tones(ch);
10699 
10700  /* Check for held channel, to implement transfer */
10701  held_ch = find_hold_call(bc);
10702  if (!held_ch || !ch->ast || misdn_attempt_transfer(ch, held_ch)) {
10703  hangup_chan(ch, bc);
10704  }
10705  } else {
10706  held_ch = find_hold_call_l3(bc->l3_id);
10707  if (held_ch) {
10708  if (bc->fac_in.Function != Fac_None) {
10709  misdn_facility_ie_handler(event, bc, held_ch);
10710  }
10711 
10712  if (held_ch->hold.state == MISDN_HOLD_ACTIVE) {
10713  bc->need_disconnect = 0;
10714 
10715 #if defined(TRANSFER_ON_HELD_CALL_HANGUP)
10716  /*
10717  * Some phones disconnect the held call and the active call at the
10718  * same time to do the transfer. Unfortunately, either call could
10719  * be disconnected first.
10720  */
10721  ch = find_hold_active_call(bc);
10722  if (!ch || misdn_attempt_transfer(ch, held_ch)) {
10723  held_ch->hold.state = MISDN_HOLD_DISCONNECT;
10724  hangup_chan(held_ch, bc);
10725  }
10726 #else
10727  hangup_chan(held_ch, bc);
10728 #endif /* defined(TRANSFER_ON_HELD_CALL_HANGUP) */
10729  }
10730  }
10731  }
10732  if (held_ch) {
10733  chan_list_unref(held_ch, "Done with held call");
10734  }
10735  bc->out_cause = -1;
10736  if (bc->need_release) {
10738  }
10739  break;
10740  case EVENT_RELEASE:
10741  if (!ch) {
10742  ch = find_hold_call_l3(bc->l3_id);
10743  if (!ch) {
10744  chan_misdn_log(1, bc->port,
10745  " --> no Ch, so we've already released. (%s)\n",
10747  return -1;
10748  }
10749  }
10750  if (bc->fac_in.Function != Fac_None) {
10752  }
10753 
10754  bc->need_disconnect = 0;
10755  bc->need_release = 0;
10756 
10757  hangup_chan(ch, bc);
10758  release_chan(ch, bc);
10759  break;
10761  if (!ch) {
10762  ch = find_hold_call_l3(bc->l3_id);
10763  }
10764 
10765  bc->need_disconnect = 0;
10766  bc->need_release = 0;
10767  bc->need_release_complete = 0;
10768 
10769  if (ch) {
10770  if (bc->fac_in.Function != Fac_None) {
10772  }
10773 
10774  stop_bc_tones(ch);
10775  hangup_chan(ch, bc);
10776  release_chan(ch, bc);
10777  } else {
10778 #if defined(AST_MISDN_ENHANCEMENTS)
10779  /*
10780  * A call-completion signaling link established with
10781  * REGISTER does not have a struct chan_list record
10782  * associated with it.
10783  */
10784  AST_LIST_LOCK(&misdn_cc_records_db);
10785  cc_record = misdn_cc_find_by_bc(bc);
10786  if (cc_record) {
10787  /* The call-completion signaling link is closed. */
10788  misdn_cc_delete(cc_record);
10789  }
10790  AST_LIST_UNLOCK(&misdn_cc_records_db);
10791 #endif /* defined(AST_MISDN_ENHANCEMENTS) */
10792 
10793  chan_misdn_log(1, bc->port,
10794  " --> no Ch, so we've already released. (%s)\n",
10796  }
10797  break;
10798  case EVENT_BCHAN_ERROR:
10799  case EVENT_CLEANUP:
10800  stop_bc_tones(ch);
10801 
10802  switch (ch->state) {
10803  case MISDN_CALLING:
10805  break;
10806  default:
10807  break;
10808  }
10809 
10810  hangup_chan(ch, bc);
10811  release_chan(ch, bc);
10812  break;
10813  case EVENT_TONE_GENERATE:
10814  {
10815  int tone_len = bc->tone_cnt;
10816  struct ast_channel *ast = ch->ast;
10817  void *tmp;
10818  int res;
10819  int (*generate)(struct ast_channel *chan, void *tmp, int datalen, int samples);
10820 
10821  chan_misdn_log(9, bc->port, "TONE_GEN: len:%d\n", tone_len);
10822 
10823  if (!ast) {
10824  break;
10825  }
10826 
10827  if (!ast_channel_generator(ast)) {
10828  break;
10829  }
10830 
10831  tmp = ast_channel_generatordata(ast);
10833  generate = ast_channel_generator(ast)->generate;
10834 
10835  if (tone_len < 0 || tone_len > 512) {
10836  ast_log(LOG_NOTICE, "TONE_GEN: len was %d, set to 128\n", tone_len);
10837  tone_len = 128;
10838  }
10839 
10840  res = generate(ast, tmp, tone_len, tone_len);
10842 
10843  if (res) {
10844  ast_log(LOG_WARNING, "Auto-deactivating generator\n");
10846  } else {
10847  bc->tone_cnt = 0;
10848  }
10849  break;
10850  }
10851  case EVENT_BCHAN_DATA:
10852  if (ch->bc->AOCD_need_export) {
10853  export_aoc_vars(ch->originator, ch->ast, ch->bc);
10854  }
10855  if (!misdn_cap_is_speech(ch->bc->capability)) {
10856  struct ast_frame frame;
10857 
10858  /* In Data Modes we queue frames */
10859  memset(&frame, 0, sizeof(frame));
10860  frame.frametype = AST_FRAME_VOICE; /* we have no data frames yet */
10861  frame.subclass.format = ast_format_alaw;
10862  frame.datalen = bc->bframe_len;
10863  frame.samples = bc->bframe_len;
10864  frame.mallocd = 0;
10865  frame.offset = 0;
10866  frame.delivery = ast_tv(0, 0);
10867  frame.src = NULL;
10868  frame.data.ptr = bc->bframe;
10869 
10870  if (ch->ast) {
10871  ast_queue_frame(ch->ast, &frame);
10872  }
10873  } else {
10874  struct pollfd pfd = { .fd = ch->pipe[1], .events = POLLOUT };
10875  int t;
10876 
10877  t = ast_poll(&pfd, 1, 0);
10878 
10879  if (t < 0) {
10880  chan_misdn_log(-1, bc->port, "poll() error (err=%s)\n", strerror(errno));
10881  break;
10882  }
10883  if (!t) {
10884  chan_misdn_log(9, bc->port, "poll() timed out\n");
10885  break;
10886  }
10887 
10888  if (pfd.revents & POLLOUT) {
10889  chan_misdn_log(9, bc->port, "writing %d bytes to asterisk\n", bc->bframe_len);
10890  if (write(ch->pipe[1], bc->bframe, bc->bframe_len) <= 0) {
10891  chan_misdn_log(0, bc->port, "Write returned <=0 (err=%s) --> hanging up channel\n", strerror(errno));
10892 
10893  stop_bc_tones(ch);
10894  hangup_chan(ch, bc);
10895  release_chan(ch, bc);
10896  }
10897  } else {
10898  chan_misdn_log(1, bc->port, "Write Pipe full!\n");
10899  }
10900  }
10901  break;
10902  case EVENT_TIMEOUT:
10903  if (ch && bc) {
10904  chan_misdn_log(1, bc->port, "--> state: %s\n", misdn_get_ch_state(ch));
10905  }
10906 
10907  switch (ch->state) {
10908  case MISDN_DIALING:
10909  case MISDN_PROGRESS:
10910  if (bc->nt && !ch->nttimeout) {
10911  break;
10912  }
10913  /* fall-through */
10914  case MISDN_CALLING:
10915  case MISDN_ALERTING:
10916  case MISDN_PROCEEDING:
10918  if (bc->nt) {
10920  hanguptone_indicate(ch);
10921  }
10922 
10925  break;
10926  case MISDN_WAITING4DIGS:
10927  if (bc->nt) {
10930  hanguptone_indicate(ch);
10932  } else {
10935  }
10936  break;
10937  case MISDN_CLEANING:
10938  chan_misdn_log(1, bc->port, " --> in state cleaning .. so ignoring, the stack should clean it for us\n");
10939  break;
10940  default:
10942  break;
10943  }
10944  break;
10945 
10946  /****************************/
10947  /** Supplementary Services **/
10948  /****************************/
10949  case EVENT_RETRIEVE:
10950  if (!ch) {
10951  chan_misdn_log(4, bc->port, " --> no CH, searching for held call\n");
10952  ch = find_hold_call_l3(bc->l3_id);
10953  if (!ch || ch->hold.state != MISDN_HOLD_ACTIVE) {
10954  ast_log(LOG_WARNING, "No held call found, cannot Retrieve\n");
10956  break;
10957  }
10958  }
10959 
10960  /* remember the channel again */
10961  ch->bc = bc;
10962 
10963  ch->hold.state = MISDN_HOLD_IDLE;
10964  ch->hold.port = 0;
10965  ch->hold.channel = 0;
10966 
10967  ast_queue_unhold(ch->ast);
10968 
10970  chan_misdn_log(4, bc->port, " --> RETRIEVE_ACK failed\n");
10972  }
10973  break;
10974  case EVENT_HOLD:
10975  {
10976  int hold_allowed;
10977  RAII_VAR(struct ast_channel *, bridged, NULL, ast_channel_cleanup);
10978 
10979  misdn_cfg_get(bc->port, MISDN_CFG_HOLD_ALLOWED, &hold_allowed, sizeof(hold_allowed));
10980  if (!hold_allowed) {
10981  chan_misdn_log(-1, bc->port, "Hold not allowed this port.\n");
10983  break;
10984  }
10985 
10986  bridged = ast_channel_bridge_peer(ch->ast);
10987  if (bridged) {
10988  chan_misdn_log(2, bc->port, "Bridge Partner is of type: %s\n", ast_channel_tech(bridged)->type);
10989  ch->l3id = bc->l3_id;
10990 
10991  /* forget the channel now */
10992  ch->bc = NULL;
10994  ch->hold.port = bc->port;
10995  ch->hold.channel = bc->channel;
10996 
10997  ast_queue_hold(ch->ast, NULL);
10998 
11000  } else {
11002  chan_misdn_log(0, bc->port, "We aren't bridged to anybody\n");
11003  }
11004  break;
11005  }
11006  case EVENT_NOTIFY:
11007  if (bc->redirecting.to_changed) {
11008  /* Add configured prefix to redirecting.to.number */
11010  bc->redirecting.to.number, sizeof(bc->redirecting.to.number));
11011  }
11012  switch (bc->notify_description_code) {
11014  /* Ignore for now. */
11015  bc->redirecting.to_changed = 0;
11016  break;
11018  {
11019  struct ast_party_redirecting redirecting;
11020 
11021  if (!bc->redirecting.to_changed) {
11022  break;
11023  }
11024  bc->redirecting.to_changed = 0;
11025  if (!ch || !ch->ast) {
11026  break;
11027  }
11028  switch (ch->state) {
11029  case MISDN_ALERTING:
11030  /* Call is deflecting after we have seen an ALERTING message */
11032  break;
11033  default:
11034  /* Call is deflecting for call forwarding unconditional or busy reason. */
11036  break;
11037  }
11039  ast_party_redirecting_init(&redirecting);
11041 
11042  /*
11043  * Reset any earlier private redirecting id representations and
11044  * make sure that it is invalidated at the remote end.
11045  */
11046  ast_party_id_reset(&redirecting.priv_orig);
11047  ast_party_id_reset(&redirecting.priv_from);
11048  ast_party_id_reset(&redirecting.priv_to);
11049 
11050  ast_channel_queue_redirecting_update(ch->ast, &redirecting, NULL);
11051  ast_party_redirecting_free(&redirecting);
11052  break;
11053  }
11055  /*
11056  * It would be preferable to update the connected line information
11057  * only when the message callStatus is active. However, the
11058  * optional redirection number may not be present in the active
11059  * message if an alerting message were received earlier.
11060  *
11061  * The consequences if we wind up sending two updates is benign.
11062  * The other end will think that it got transferred twice.
11063  */
11064  if (!bc->redirecting.to_changed) {
11065  break;
11066  }
11067  bc->redirecting.to_changed = 0;
11068  if (!ch || !ch->ast) {
11069  break;
11070  }
11073  bc->incoming_cid_tag);
11074  break;
11076  if (!bc->redirecting.to_changed) {
11077  break;
11078  }
11079  bc->redirecting.to_changed = 0;
11080  if (!ch || !ch->ast) {
11081  break;
11082  }
11085  break;
11086  default:
11087  bc->redirecting.to_changed = 0;
11088  chan_misdn_log(0, bc->port," --> not yet handled: notify code:0x%02X\n",
11090  break;
11091  }
11093  break;
11094  case EVENT_FACILITY:
11095  if (bc->fac_in.Function == Fac_None) {
11096  /* This is a FACILITY message so we MUST have a facility ie */
11097  chan_misdn_log(0, bc->port," --> Missing facility ie or unknown facility ie contents.\n");
11098  } else {
11100  }
11101 
11102  /* In case it came in on a FACILITY message and we did not handle it. */
11103  bc->redirecting.to_changed = 0;
11105  break;
11106  case EVENT_RESTART:
11107  if (!bc->dummy) {
11108  stop_bc_tones(ch);
11109  release_chan(ch, bc);
11110  }
11111  break;
11112  default:
11113  chan_misdn_log(1, 0, "Got Unknown Event\n");
11114  break;
11115  }
11116 
11117  if (ch) {
11118  chan_list_unref(ch, "cb_event complete OK");
11119  }
11120  return RESPONSE_OK;
11121 }
struct ast_party_caller * ast_channel_caller(struct ast_channel *chan)
int need_busy
TRUE if we could send an AST_CONTROL_BUSY if needed.
Definition: chan_misdn.c:402
static void chan_misdn_log(int level, int port, char *tmpl,...)
Definition: chan_misdn.c:12768
static const char type[]
Definition: chan_ooh323.c:109
char keypad[MISDN_MAX_KEYPAD_LEN]
Q.931 Keypad Facility IE contents.
Definition: isdn_lib.h:647
void ast_set_callerid(struct ast_channel *chan, const char *cid_num, const char *cid_name, const char *cid_ani)
Set caller ID number, name and ANI and generate AMI event.
Definition: channel.c:7434
#define ast_channel_lock(chan)
Definition: channel.h:2945
Main Channel structure associated with a channel.
static int stop_indicate(struct chan_list *cl)
Definition: chan_misdn.c:7743
static struct chan_list * find_hold_call(struct misdn_bchannel *bc)
Definition: chan_misdn.c:8283
struct FacParm fac_out
Outbound FACILITY message function type and contents.
Definition: isdn_lib.h:512
#define AST_LIST_LOCK(head)
Locks a list.
Definition: linkedlists.h:39
static void hanguptone_indicate(struct chan_list *cl)
Definition: chan_misdn.c:7738
static void wait_for_digits(struct chan_list *ch, struct misdn_bchannel *bc, struct ast_channel *chan)
Definition: chan_misdn.c:8889
#define AST_CAUSE_INCOMPATIBLE_DESTINATION
Definition: causes.h:134
static const char * misdn_to_str_ton(enum mISDN_NUMBER_TYPE number_type)
Definition: chan_misdn.c:1832
char number[MISDN_MAX_NUMBER_LEN]
Phone number (Address)
Definition: isdn_lib.h:298
#define ARRAY_LEN(a)
Definition: isdn_lib.c:42
struct ast_features_pickup_config * ast_get_chan_features_pickup_config(struct ast_channel *chan)
Get the pickup configuration options for a channel.
int ast_queue_control(struct ast_channel *chan, enum ast_control_frame_type control)
Queue a control frame without payload.
Definition: channel.c:1231
void * ast_channel_generatordata(const struct ast_channel *chan)
static int read_config(struct chan_list *ch)
Definition: chan_misdn.c:5922
static int misdn_to_ast_plan(enum mISDN_NUMBER_PLAN number_plan)
Definition: chan_misdn.c:2000
int presentation
Q.931 presentation-indicator and screening-indicator encoded fields.
Definition: channel.h:296
void ast_party_id_reset(struct ast_party_id *id)
Destroy and initialize the given party id structure.
Definition: channel.c:1896
int addr
From associated B channel: B Channel mISDN driver layer ID from mISDN_get_layerid() ...
Definition: chan_misdn.c:547
static struct ast_channel * misdn_new(struct chan_list *cl, int state, char *exten, char *callerid, struct ast_format_cap *cap, const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor, int port, int c)
Definition: chan_misdn.c:8174
int tone_cnt
Number of tone samples to generate.
Definition: isdn_lib.h:544
int ignore_dtmf
TRUE if DTMF digits are to be passed inband only.
Definition: chan_misdn.c:438
#define bc
#define AST_CAUSE_UNALLOCATED
Definition: causes.h:97
void ast_channel_hangupcause_set(struct ast_channel *chan, int value)
static int misdn_attempt_transfer(struct chan_list *active_ch, struct chan_list *held_ch)
Definition: chan_misdn.c:8619
int dummy
TRUE if this is a dummy BC record.
Definition: isdn_lib.h:361
int pipe[2]
Pipe file descriptor handles array. Read from pipe[0], write to pipe[1].
Definition: chan_misdn.c:444
int ast_queue_unhold(struct ast_channel *chan)
Queue an unhold frame.
Definition: channel.c:1216
static int misdn_to_ast_pres(int presentation)
Definition: chan_misdn.c:2117
static void cl_queue_chan(struct chan_list *chan)
Definition: chan_misdn.c:8377
int bframe_len
B channel speech sample data buffer size.
Definition: isdn_lib.h:435
#define LOG_WARNING
Definition: logger.h:274
#define AST_LIST_UNLOCK(head)
Attempts to unlock a list.
Definition: linkedlists.h:139
char * manager_isdn_get_info(enum event_e event)
Definition: isdn_lib.c:4324
char incoming_cid_tag[MISDN_MAX_NAME_LEN]
Incoming Caller ID string tag for special purpose.
Definition: isdn_lib.h:348
static const struct allowed_bearers allowed_bearers_array[]
Definition: chan_misdn.c:2362
int cw
TRUE if call waiting.
Definition: isdn_lib.h:426
static int tmp()
Definition: bt_open.c:389
static void release_chan(struct chan_list *ch, struct misdn_bchannel *bc)
Definition: chan_misdn.c:8495
struct hold_info hold
HELD channel call information.
Definition: chan_misdn.c:535
B channel control structure.
Definition: isdn_lib.h:324
int presentation
Number presentation restriction code 0=Allowed, 1=Restricted, 2=Unavailable.
Definition: isdn_lib.h:277
int sending_complete
TRUE if all digits necessary to complete the call are available. No more INFORMATION messages are nee...
Definition: isdn_lib.h:470
static const char * misdn_get_ch_state(struct chan_list *p)
Definition: chan_misdn.c:4102
static struct chan_list * find_hold_active_call(struct misdn_bchannel *bc)
Definition: chan_misdn.c:8351
Definition: astman.c:222
static void misdn_copy_redirecting_to_ast(struct ast_channel *ast, const struct misdn_party_redirecting *redirect, char *tag)
Definition: chan_misdn.c:6437
#define MISDN_ASTERISK_TECH_PVT(ast)
Definition: chan_misdn.c:683
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
Definition: time.h:150
int(* generate)(struct ast_channel *chan, void *data, int len, int samples)
Definition: channel.h:234
static void start_pbx(struct chan_list *ch, struct misdn_bchannel *bc, struct ast_channel *chan)
Definition: chan_misdn.c:8875
int capability
SETUP message bearer capability field code value.
Definition: isdn_lib.h:609
#define ast_mutex_lock(a)
Definition: lock.h:187
#define ast_strdup(str)
A wrapper for strdup()
Definition: astmm.h:243
static const char * misdn_to_str_pres(int presentation)
Definition: chan_misdn.c:2084
int AOCD_need_export
TRUE if AOCDtype and AOCD data are ready to export to Asterisk.
Definition: isdn_lib.h:521
#define NULL
Definition: resample.c:96
char context[AST_MAX_CONTEXT]
Incoming call dialplan context identifier.
Definition: chan_misdn.c:553
#define AST_FRAME_DTMF
struct ast_channel * ast
Associated Asterisk channel structure.
Definition: chan_misdn.c:515
static const char * misdn_to_str_plan(enum mISDN_NUMBER_PLAN number_plan)
Definition: chan_misdn.c:1958
struct misdn_party_id to
Where the call is being redirected toward (Sent to the calling party)
Definition: isdn_lib.h:310
int ast_canmatch_extension(struct ast_channel *c, const char *context, const char *exten, int priority, const char *callerid)
Looks for a valid matching extension.
Definition: pbx.c:4194
static void do_immediate_setup(struct misdn_bchannel *bc, struct chan_list *ch, struct ast_channel *ast)
Definition: chan_misdn.c:8659
int misdn_cap_is_speech(int cap)
Definition: isdn_lib.c:436
static int misdn_tasks_add_variable(int timeout, ast_sched_cb callback, const void *data)
Definition: chan_misdn.c:3609
static int misdn_is_msn_valid(int port, const struct misdn_party_dialing *dialed)
Definition: chan_misdn.c:9904
struct timeval overlap_tv
Overlap timer start time. Timer restarted for every digit received.
Definition: chan_misdn.c:603
#define AST_PRES_RESTRICTED
Definition: callerid.h:325
#define ast_strlen_zero(foo)
Definition: strings.h:52
static int stop_bc_tones(struct chan_list *cl)
Definition: chan_misdn.c:7772
struct ast_party_id id
Caller party ID.
Definition: channel.h:421
int misdn_inband_avail(struct misdn_bchannel *bc)
Definition: isdn_lib.c:444
#define ast_log
Definition: astobj2.c:42
char number[MISDN_MAX_NUMBER_LEN]
Dialed/Called Phone Number (Address)
Definition: isdn_lib.h:266
#define AST_PRES_USER_NUMBER_UNSCREENED
Definition: callerid.h:318
static int misdn_to_ast_ton(enum mISDN_NUMBER_TYPE number_type)
Definition: chan_misdn.c:1874
void ast_channel_rings_set(struct ast_channel *chan, int value)
int misdn_lib_port_block(int port)
Definition: isdn_lib.c:91
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
Definition: utils.h:911
void ast_channel_generatordata_set(struct ast_channel *chan, void *value)
int need_release_complete
TRUE if RELEASE_COMPLETE needs to be sent to clear a call.
Definition: isdn_lib.h:392
#define ast_poll(a, b, c)
Definition: poll-compat.h:88
void misdn_cfg_get(int port, enum misdn_cfg_elements elem, void *buf, int bufsize)
Definition: misdn_config.c:569
int overlap_dial_task
Overlap dialing timeout Task ID. -1 if not running.
Definition: chan_misdn.c:593
#define AST_CAUSE_NORMAL_CLEARING
Definition: causes.h:105
#define ast_channel_cleanup(c)
Cleanup a channel reference.
Definition: channel.h:2992
#define ao2_ref(o, delta)
Definition: astobj2.h:464
static const char * misdn_to_str_screen(int screening)
Definition: chan_misdn.c:2173
int nt
TRUE if NT side of protocol (TE otherwise)
Definition: isdn_lib.h:364
enum mISDN_NUMBER_TYPE number_type
Type-of-number in ISDN terms for the number.
Definition: isdn_lib.h:285
void misdn_lib_log_ies(struct misdn_bchannel *bc)
Definition: isdn_lib.c:3431
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: astmm.h:300
#define ast_format_cap_append(cap, format, framing)
Definition: format_cap.h:103
char infos_pending[MISDN_MAX_NUMBER_LEN]
Collected digits to go into info_dad[] while waiting for a SETUP_ACKNOWLEDGE to come in...
Definition: isdn_lib.h:653
struct misdn_party_id caller
Originating/Caller ID information struct.
Definition: isdn_lib.h:343
static struct chan_list * find_chan_by_bc(struct misdn_bchannel *bc)
Definition: chan_misdn.c:8259
char name[MISDN_MAX_NAME_LEN]
Subscriber Name.
Definition: isdn_lib.h:295
int ast_exists_extension(struct ast_channel *c, const char *context, const char *exten, int priority, const char *callerid)
Determine whether an extension exists.
Definition: pbx.c:4179
#define ast_format_cap_alloc(flags)
Definition: format_cap.h:52
char * bc_state2str(enum bchannel_state state)
Definition: isdn_lib.c:617
int ast_queue_hold(struct ast_channel *chan, const char *musicclass)
Queue a hold frame.
Definition: channel.c:1191
enum misdn_chan_state state
State of the channel.
Definition: chan_misdn.c:386
int far_alerting
TRUE if we must do the ringback tones.
Definition: chan_misdn.c:570
Structure to describe a channel "technology", ie a channel driver See for examples: ...
Definition: channel.h:629
const char * ast_channel_exten(const struct ast_channel *chan)
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:1139
#define AST_CAUSE_DESTINATION_OUT_OF_ORDER
Definition: causes.h:114
int port
Logical port the channel call record is HELD on because the B channel is no longer associated...
Definition: chan_misdn.c:362
int misdn_lib_is_ptp(int port)
Definition: isdn_lib.c:128
struct misdn_party_id connected
Connected-Party/Connected-Line ID information struct.
Definition: isdn_lib.h:353
void export_ch(struct ast_channel *chan, struct misdn_bchannel *bc, struct chan_list *ch)
Export parameters to the dialplan environment variables.
Definition: chan_misdn.c:8811
char allowed_bearers[BUFFERSIZE+1]
The "allowed_bearers" string read in from /etc/asterisk/misdn.conf.
Definition: chan_misdn.c:381
int pid
B channel process ID (1-5000)
Definition: isdn_lib.h:402
int originator
Who originally created this channel. ORG_AST or ORG_MISDN.
Definition: chan_misdn.c:407
struct misdn_party_id from
Who is redirecting the call (Sent to the party the call is redirected toward)
Definition: isdn_lib.h:307
static const char * bearer2str(int cap)
Definition: chan_misdn.c:2373
#define LOG_ERROR
Definition: logger.h:285
struct ast_generator * ast_channel_generator(const struct ast_channel *chan)
int ast_pickup_call(struct ast_channel *chan)
Pickup a call.
Definition: pickup.c:200
Format capabilities structure, holds formats + preference order + etc.
Definition: format_cap.c:54
static void misdn_add_number_prefix(int port, enum mISDN_NUMBER_TYPE number_type, char *number, size_t size)
Definition: chan_misdn.c:3424
int plan
Q.931 Type-Of-Number and Numbering-Plan encoded fields.
Definition: channel.h:294
static struct chan_list * find_hold_call_l3(unsigned long l3_id)
Definition: chan_misdn.c:8317
static void misdn_update_remote_party(struct ast_channel *ast, const struct misdn_party_id *id, enum AST_CONNECTED_LINE_UPDATE_SOURCE source, char *cid_tag)
Definition: chan_misdn.c:6210
int errno
struct misdn_party_redirecting redirecting
Redirecting information struct (Where a call diversion or transfer was invoked)
Definition: isdn_lib.h:358
static int misdn_overlap_dial_task(const void *data)
Definition: chan_misdn.c:3628
int port
Logical Layer 1 port associated with this B channel.
Definition: isdn_lib.h:370
int add_in_calls(int port)
Definition: chan_misdn.c:8844
Redirecting Line information. RDNIS (Redirecting Directory Number Information Service) Where a call d...
Definition: channel.h:523
#define LOG_NOTICE
Definition: logger.h:263
struct misdn_party_dialing dialed
Dialed/Called information struct.
Definition: isdn_lib.h:337
ast_mutex_t overlap_tv_lock
overlap_tv access lock.
Definition: chan_misdn.c:598
#define ORG_MISDN
Definition: chan_misdn.c:345
#define ast_channel_unlock(chan)
Definition: channel.h:2946
int addr
B Channel mISDN driver layer ID from mISDN_get_layerid()
Definition: isdn_lib.h:429
Channel call record structure.
Definition: chan_misdn.c:377
unsigned int l3id
From associated B channel: Layer 3 process ID.
Definition: chan_misdn.c:541
int to_changed
TRUE if the redirecting.to information has changed.
Definition: isdn_lib.h:319
enum misdn_hold_state state
Call HOLD state.
Definition: chan_misdn.c:357
static struct chan_list * chan_list_init(int orig)
Definition: chan_misdn.c:7831
int channel
Original B channel number the HELD call was using.
Definition: chan_misdn.c:368
struct ast_party_redirecting * ast_channel_redirecting(struct ast_channel *chan)
int channel
Assigned B channel number B1, B2... 0 if not assigned.
Definition: isdn_lib.h:411
static void hangup_chan(struct chan_list *ch, struct misdn_bchannel *bc)
Definition: chan_misdn.c:8447
void ast_channel_exten_set(struct ast_channel *chan, const char *value)
int pbx_builtin_setvar_helper(struct ast_channel *chan, const char *name, const char *value)
Add a variable to the channel variable stack, removing the most recently set value for the same name...
static void print_bearer(struct misdn_bchannel *bc)
Definition: chan_misdn.c:3355
static void export_aoc_vars(int originator, struct ast_channel *ast, struct misdn_bchannel *bc)
Definition: chan_misdn.c:3458
int out_cause
Q.931 Cause for disconnection code (sent)
Definition: isdn_lib.h:677
char * tag
User-set "tag".
Definition: channel.h:355
void ast_deactivate_generator(struct ast_channel *chan)
Definition: channel.c:2902
void ast_party_redirecting_free(struct ast_party_redirecting *doomed)
Destroy the redirecting information contents.
Definition: channel.c:2179
enum mISDN_REDIRECTING_REASON reason
Reason a call is being redirected (Q.931 field value)
Definition: isdn_lib.h:313
int need_release
TRUE if RELEASE needs to be sent to clear a call.
Definition: isdn_lib.h:389
int need_more_infos
TRUE if we send SETUP_ACKNOWLEDGE on incoming calls anyway (instead of PROCEEDING).
Definition: isdn_lib.h:465
int dtmf
Last decoded DTMF digit from mISDN driver.
Definition: isdn_lib.h:452
enum bchannel_state bc_state
Current B Channel state.
Definition: isdn_lib.h:547
#define ao2_cleanup(obj)
Definition: astobj2.h:1958
static int start_bc_tones(struct chan_list *cl)
Definition: chan_misdn.c:7764
struct ast_party_id to
Call is redirecting to a new party (Sent to the caller)
Definition: channel.h:531
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:401
struct ast_format * ast_format_alaw
Built-in cached alaw format.
Definition: format_cache.c:91
struct timeval ast_tv(ast_time_t sec, ast_suseconds_t usec)
Returns a timeval from sec, usec.
Definition: time.h:226
int need_disconnect
TRUE if DISCONNECT needs to be sent to clear a call.
Definition: isdn_lib.h:386
struct ast_channel * ast_channel_bridge_peer(struct ast_channel *chan)
Get the channel&#39;s bridge peer only if the bridge is two-party.
Definition: channel.c:10765
void ast_party_redirecting_init(struct ast_party_redirecting *init)
Initialize the given redirecting structure.
Definition: channel.c:2122
#define AST_CAUSE_USER_BUSY
Definition: causes.h:106
void ast_channel_transfercapability_set(struct ast_channel *chan, unsigned short value)
int ast_setstate(struct ast_channel *chan, enum ast_channel_state)
Change the state of a channel.
Definition: channel.c:7486
enum mISDN_NOTIFY_CODE notify_description_code
Notification indicator ie description code.
Definition: isdn_lib.h:606
char * ast_transfercapability2str(int transfercapability) attribute_const
Gives the string form of a given transfer capability.
Definition: channel.c:678
Data structure associated with a single frame of data.
int progress_indicator
Progress Indicator IE progress description field. Used to determine if there is an inband audio messa...
Definition: isdn_lib.h:492
int misdn_lib_send_event(struct misdn_bchannel *bc, enum event_e event)
Definition: isdn_lib.c:3523
#define ORG_AST
Definition: chan_misdn.c:343
char * bframe
B channel speech sample data buffer.
Definition: isdn_lib.h:432
void ast_channel_queue_redirecting_update(struct ast_channel *chan, const struct ast_party_redirecting *redirecting, const struct ast_set_party_redirecting *update)
Queue a redirecting update frame on a channel.
Definition: channel.c:10392
int cause
Q.931 Cause for disconnection code (received)
Definition: isdn_lib.h:671
char info_dad[MISDN_MAX_NUMBER_LEN]
Current overlap dialing digits to/from INFORMATION messages.
Definition: isdn_lib.h:650
static void update_name(struct ast_channel *tmp, int port, int c)
Definition: chan_misdn.c:8150
struct misdn_bchannel * bc
Associated B channel structure.
Definition: chan_misdn.c:520
int screening
Number screening code 0=Unscreened, 1=Passed Screen, 2=Failed Screen, 3=Network Number.
Definition: isdn_lib.h:282
#define chan_list_unref(obj, debug)
Definition: chan_misdn.c:372
static int misdn_to_ast_screen(int screening)
Definition: chan_misdn.c:2210
void(* cb_log)(int level, int port, char *tmpl,...)
Definition: isdn_lib.c:32
struct FacParm fac_in
Inbound FACILITY message function type and contents.
Definition: isdn_lib.h:507
int overlap_dial
Enables overlap dialing for the set amount of seconds. (0 = Disabled)
Definition: chan_misdn.c:588
enum mISDN_NUMBER_PLAN number_plan
Type-of-number numbering plan.
Definition: isdn_lib.h:288
void ast_party_redirecting_copy(struct ast_party_redirecting *dest, const struct ast_party_redirecting *src)
Copy the source redirecting information to the destination redirecting.
Definition: channel.c:2135
int noautorespond_on_setup
TRUE of we are not to respond immediately to a SETUP message. Check the dialplan first.
Definition: chan_misdn.c:413
int l3_id
Layer 3 process ID.
Definition: isdn_lib.h:399
static void misdn_facility_ie_handler(enum event_e event, struct misdn_bchannel *bc, struct chan_list *ch)
Definition: chan_misdn.c:9095
#define ast_mutex_unlock(a)
Definition: lock.h:188
Configuration relating to call pickup.
int nttimeout
TRUE if NT should disconnect an overlap dialing call when a timeout occurs.
Definition: chan_misdn.c:576
struct ast_party_number number
Subscriber phone number.
Definition: channel.h:343

◆ chan_list_destructor()

static void chan_list_destructor ( void *  obj)
static

Definition at line 7792 of file chan_misdn.c.

References ao2_ref, ast_dsp_free(), ast_mutex_destroy, chan_list::dsp, chan_list::jb, misdn_jb_destroy(), misdn_tasks_remove(), NULL, chan_list::overlap_dial, chan_list::overlap_dial_task, chan_list::overlap_tv_lock, and chan_list::pipe.

Referenced by chan_list_init().

7793 {
7794  struct chan_list *ch = obj;
7795 
7796 #if defined(AST_MISDN_ENHANCEMENTS)
7797  if (ch->peer) {
7798  ao2_ref(ch->peer, -1);
7799  ch->peer = NULL;
7800  }
7801 #endif /* AST_MISDN_ENHANCEMENTS */
7802 
7803  if (ch->dsp) {
7804  ast_dsp_free(ch->dsp);
7805  ch->dsp = NULL;
7806  }
7807 
7808  /* releasing jitterbuffer */
7809  if (ch->jb) {
7810  misdn_jb_destroy(ch->jb);
7811  ch->jb = NULL;
7812  }
7813 
7814  if (ch->overlap_dial) {
7815  if (ch->overlap_dial_task != -1) {
7817  ch->overlap_dial_task = -1;
7818  }
7820  }
7821 
7822  if (-1 < ch->pipe[0]) {
7823  close(ch->pipe[0]);
7824  }
7825  if (-1 < ch->pipe[1]) {
7826  close(ch->pipe[1]);
7827  }
7828 }
struct ast_dsp * dsp
Allocated DSP controller.
Definition: chan_misdn.c:510
void ast_dsp_free(struct ast_dsp *dsp)
Definition: dsp.c:1770
int pipe[2]
Pipe file descriptor handles array. Read from pipe[0], write to pipe[1].
Definition: chan_misdn.c:444
struct misdn_jb * jb
Allocated jitterbuffer controller.
Definition: chan_misdn.c:503
void misdn_jb_destroy(struct misdn_jb *jb)
frees the data and destroys the given jitterbuffer struct
Definition: chan_misdn.c:12639
#define NULL
Definition: resample.c:96
static void misdn_tasks_remove(int task_id)
Definition: chan_misdn.c:3614
int overlap_dial_task
Overlap dialing timeout Task ID. -1 if not running.
Definition: chan_misdn.c:593
#define ao2_ref(o, delta)
Definition: astobj2.h:464
ast_mutex_t overlap_tv_lock
overlap_tv access lock.
Definition: chan_misdn.c:598
Channel call record structure.
Definition: chan_misdn.c:377
#define ast_mutex_destroy(a)
Definition: lock.h:186
int overlap_dial
Enables overlap dialing for the set amount of seconds. (0 = Disabled)
Definition: chan_misdn.c:588

◆ chan_list_init()

static struct chan_list* chan_list_init ( int  orig)
static

Returns a reference to the new chan_list.

Definition at line 7831 of file chan_misdn.c.

References ao2_alloc, chan_list_destructor(), chan_misdn_log(), chan_list::need_busy, chan_list::need_hangup, chan_list::need_queue_hangup, NULL, chan_list::originator, chan_list::overlap_dial_task, and chan_list::pipe.

Referenced by cb_events(), and misdn_request().

7832 {
7833  struct chan_list *cl;
7834 
7835  cl = ao2_alloc(sizeof(*cl), chan_list_destructor);
7836  if (!cl) {
7837  chan_misdn_log(-1, 0, "misdn_request: malloc failed!");
7838  return NULL;
7839  }
7840 
7841  cl->originator = orig;
7842  cl->need_queue_hangup = 1;
7843  cl->need_hangup = 1;
7844  cl->need_busy = 1;
7845  cl->overlap_dial_task = -1;
7846 #if defined(AST_MISDN_ENHANCEMENTS)
7847  cl->record_id = -1;
7848 #endif /* defined(AST_MISDN_ENHANCEMENTS) */
7849  cl->pipe[0] = -1;
7850  cl->pipe[1] = -1;
7851 
7852  return cl;
7853 }
int need_busy
TRUE if we could send an AST_CONTROL_BUSY if needed.
Definition: chan_misdn.c:402
static void chan_misdn_log(int level, int port, char *tmpl,...)
Definition: chan_misdn.c:12768
int need_hangup
TRUE if a channel can be hung up by calling asterisk directly when done.
Definition: chan_misdn.c:397
int need_queue_hangup
TRUE if a hangup needs to be queued.
Definition: chan_misdn.c:392
int pipe[2]
Pipe file descriptor handles array. Read from pipe[0], write to pipe[1].
Definition: chan_misdn.c:444
#define NULL
Definition: resample.c:96
static void chan_list_destructor(void *obj)
Definition: chan_misdn.c:7792
int overlap_dial_task
Overlap dialing timeout Task ID. -1 if not running.
Definition: chan_misdn.c:593
int originator
Who originally created this channel. ORG_AST or ORG_MISDN.
Definition: chan_misdn.c:407
#define ao2_alloc(data_size, destructor_fn)
Definition: astobj2.h:411
Channel call record structure.
Definition: chan_misdn.c:377

◆ chan_misdn_jb_empty()

int chan_misdn_jb_empty ( struct misdn_bchannel bc,
char *  buf,
int  len 
)

Definition at line 12574 of file chan_misdn.c.

References chan_list_unref, find_chan_by_bc(), chan_list::jb, and misdn_jb_empty().

Referenced by load_module().

12575 {
12576  struct chan_list *ch;
12577  int res;
12578 
12579  ch = find_chan_by_bc(bc);
12580  if (!ch) {
12581  return 0;
12582  }
12583 
12584  if (ch->jb) {
12585  res = misdn_jb_empty(ch->jb, buf, len);
12586  } else {
12587  res = 0;
12588  }
12589  chan_list_unref(ch, "Done emptying jb");
12590 
12591  return res;
12592 }
char buf[BUFSIZE]
Definition: eagi_proxy.c:66
struct misdn_jb * jb
Allocated jitterbuffer controller.
Definition: chan_misdn.c:503
static struct chan_list * find_chan_by_bc(struct misdn_bchannel *bc)
Definition: chan_misdn.c:8259
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
Channel call record structure.
Definition: chan_misdn.c:377
#define chan_list_unref(obj, debug)
Definition: chan_misdn.c:372
int misdn_jb_empty(struct misdn_jb *jb, char *data, int len)
gets len bytes out of the jitterbuffer if available, else only the available data is returned and the...
Definition: chan_misdn.c:12716

◆ chan_misdn_log()

static void chan_misdn_log ( int  level,
int  port,
char *  tmpl,
  ... 
)
static

Definition at line 12768 of file chan_misdn.c.

References ast_log, AST_MODFLAG_LOAD_ORDER, AST_MODPRI_CHANNEL_DRIVER, AST_MODULE_INFO(), AST_MODULE_SUPPORT_DEPRECATED, ast_strlen_zero, ast_verbose(), ASTERISK_GPL_KEY, errno, global_tracefile, load_module(), LOG_WARNING, NULL, reload(), tmp(), and unload_module().

Referenced by bearer2str(), cb_events(), chan_list_init(), cl_queue_chan(), config_jitterbuffer(), debug_numtype(), dialtone_indicate(), do_immediate_setup(), export_ch(), find_chan_by_bc(), find_hold_call(), get_chan_by_ast_name(), load_module(), misdn_answer(), misdn_attempt_transfer(), misdn_call(), misdn_check_l2l1(), misdn_digit_end(), misdn_facility_exec(), misdn_facility_ie_handler(), misdn_fixup(), misdn_hangup(), misdn_indication(), misdn_jb_empty(), misdn_jb_fill(), misdn_jb_init(), misdn_l1_task(), misdn_new(), misdn_overlap_dial_task(), misdn_read(), misdn_request(), misdn_set_opt_exec(), misdn_tasks_destroy(), misdn_tasks_init(), misdn_tasks_thread_func(), misdn_write(), print_bearer(), print_facility(), process_ast_dsp(), read_config(), release_chan(), send_cause2ast(), start_pbx(), stop_indicate(), update_config(), update_name(), and wait_for_digits().

12769 {
12770  va_list ap;
12771  char buf[1024];
12772  char port_buf[8];
12773 
12774  if (!(0 <= port && port <= max_ports)) {
12775  ast_log(LOG_WARNING, "chan_misdn_log called with out-of-range port number! (%d)\n", port);
12776  port = 0;
12777  level = -1;
12778  } else if (!(level == -1
12779  || (misdn_debug_only[port]
12780  ? (level == 1 && misdn_debug[port]) || level == misdn_debug[port]
12781  : level <= misdn_debug[port])
12782  || (level <= misdn_debug[0] && !ast_strlen_zero(global_tracefile)))) {
12783  /*
12784  * We are not going to print anything so lets not
12785  * go to all the work of generating a string.
12786  */
12787  return;
12788  }
12789 
12790  snprintf(port_buf, sizeof(port_buf), "P[%2d] ", port);
12791  va_start(ap, tmpl);
12792  vsnprintf(buf, sizeof(buf), tmpl, ap);
12793  va_end(ap);
12794 
12795  if (level == -1) {
12796  ast_log(LOG_WARNING, "%s", buf);
12797  } else if (misdn_debug_only[port]
12798  ? (level == 1 && misdn_debug[port]) || level == misdn_debug[port]
12799  : level <= misdn_debug[port]) {
12800  ast_verbose("%s%s", port_buf, buf);
12801  }
12802 
12803  if (level <= misdn_debug[0] && !ast_strlen_zero(global_tracefile)) {
12804  char ctimebuf[30];
12805  time_t tm;
12806  char *tmp;
12807  char *p;
12808  FILE *fp;
12809 
12810  fp = fopen(global_tracefile, "a+");
12811  if (!fp) {
12812  ast_verbose("Error opening Tracefile: [ %s ] %s\n", global_tracefile, strerror(errno));
12813  return;
12814  }
12815 
12816  tm = time(NULL);
12817  tmp = ctime_r(&tm, ctimebuf);
12818  p = strchr(tmp, '\n');
12819  if (p) {
12820  *p = ':';
12821  }
12822  fputs(tmp, fp);
12823  fputs(" ", fp);
12824  fputs(port_buf, fp);
12825  fputs(" ", fp);
12826  fputs(buf, fp);
12827 
12828  fclose(fp);
12829  }
12830 }
char buf[BUFSIZE]
Definition: eagi_proxy.c:66
#define LOG_WARNING
Definition: logger.h:274
static int tmp()
Definition: bt_open.c:389
void ast_verbose(const char *fmt,...)
Definition: extconf.c:2207
static int * misdn_debug_only
Definition: chan_misdn.c:695
#define NULL
Definition: resample.c:96
#define ast_strlen_zero(foo)
Definition: strings.h:52
#define ast_log
Definition: astobj2.c:42
static int max_ports
Definition: chan_misdn.c:696
static char global_tracefile[BUFFERSIZE+1]
Definition: chan_misdn.c:127
static int * misdn_debug
Definition: chan_misdn.c:694
int errno

◆ cl_dequeue_chan()

static int cl_dequeue_chan ( struct chan_list chan)
static

Definition at line 8398 of file chan_misdn.c.

References ast_mutex_lock, ast_mutex_unlock, chan_list_unref, and chan_list::next.

Referenced by release_chan(), and release_chan_early().

8399 {
8400  int found_it;
8401  struct chan_list *help;
8402 
8404  if (!cl_te) {
8405  /* List is empty. */
8407  return 0;
8408  }
8409 
8410  if (cl_te == chan) {
8411  /* What we want is the head of the list. */
8412  cl_te = cl_te->next;
8414  chan_list_unref(chan, "Removed chan_list from list head");
8415  return 1;
8416  }
8417 
8418  found_it = 0;
8419  for (help = cl_te; help->next; help = help->next) {
8420  if (help->next == chan) {
8421  /* Found it in the list. */
8422  help->next = help->next->next;
8423  found_it = 1;
8424  break;
8425  }
8426  }
8427 
8429  if (found_it) {
8430  chan_list_unref(chan, "Removed chan_list from list");
8431  }
8432  return found_it;
8433 }
struct chan_list * next
Next channel call record in the list.
Definition: chan_misdn.c:608
#define ast_mutex_lock(a)
Definition: lock.h:187
static struct chan_list * cl_te
Global channel call record list head.
Definition: chan_misdn.c:704
Channel call record structure.
Definition: chan_misdn.c:377
#define chan_list_unref(obj, debug)
Definition: chan_misdn.c:372
static ast_mutex_t cl_te_lock
Definition: chan_misdn.c:705
#define ast_mutex_unlock(a)
Definition: lock.h:188

◆ cl_queue_chan()

static void cl_queue_chan ( struct chan_list chan)
static

Definition at line 8377 of file chan_misdn.c.

References ast_mutex_lock, ast_mutex_unlock, chan_list::bc, chan_list_ref, chan_misdn_log(), chan_list::next, NULL, and misdn_bchannel::port.

Referenced by cb_events(), and misdn_request().

8378 {
8379  chan_misdn_log(4, chan->bc ? chan->bc->port : 0, "* Queuing chan %p\n", chan);
8380 
8381  chan_list_ref(chan, "Adding chan_list to list");
8383  chan->next = NULL;
8384  if (!cl_te) {
8385  /* List is empty, make head of list. */
8386  cl_te = chan;
8387  } else {
8388  struct chan_list *help;
8389 
8390  /* Put at end of list. */
8391  for (help = cl_te; help->next; help = help->next) {
8392  }
8393  help->next = chan;
8394  }
8396 }
static void chan_misdn_log(int level, int port, char *tmpl,...)
Definition: chan_misdn.c:12768
struct chan_list * next
Next channel call record in the list.
Definition: chan_misdn.c:608
#define ast_mutex_lock(a)
Definition: lock.h:187
#define NULL
Definition: resample.c:96
static struct chan_list * cl_te
Global channel call record list head.
Definition: chan_misdn.c:704
int port
Logical Layer 1 port associated with this B channel.
Definition: isdn_lib.h:370
Channel call record structure.
Definition: chan_misdn.c:377
#define chan_list_ref(obj, debug)
Definition: chan_misdn.c:371
struct misdn_bchannel * bc
Associated B channel structure.
Definition: chan_misdn.c:520
static ast_mutex_t cl_te_lock
Definition: chan_misdn.c:705
#define ast_mutex_unlock(a)
Definition: lock.h:188

◆ complete_ch()

static char * complete_ch ( struct ast_cli_args a)
static

Definition at line 5654 of file chan_misdn.c.

References ast_complete_channels(), ast_cli_args::line, ast_cli_args::n, ast_cli_args::pos, and ast_cli_args::word.

Referenced by handle_cli_misdn_send_digit(), handle_cli_misdn_send_display(), handle_cli_misdn_send_facility(), handle_cli_misdn_show_channel(), and handle_cli_misdn_toggle_echocancel().

5655 {
5656  return ast_complete_channels(a->line, a->word, a->pos, a->n, 3);
5657 }
const char * line
Definition: cli.h:162
const int n
Definition: cli.h:165
const char * word
Definition: cli.h:163
const int pos
Definition: cli.h:164
char * ast_complete_channels(const char *line, const char *word, int pos, int state, int rpos)
Command completion for the list of active channels.
Definition: main/cli.c:1830

◆ complete_debug_port()

static char * complete_debug_port ( struct ast_cli_args a)
static

Definition at line 5659 of file chan_misdn.c.

References ast_strdup, ast_cli_args::n, NULL, ast_cli_args::pos, and ast_cli_args::word.

Referenced by handle_cli_misdn_set_debug().

5660 {
5661  if (a->n) {
5662  return NULL;
5663  }
5664 
5665  switch (a->pos) {
5666  case 4:
5667  if (a->word[0] == 'p') {
5668  return ast_strdup("port");
5669  } else if (a->word[0] == 'o') {
5670  return ast_strdup("only");
5671  }
5672  break;
5673  case 6:
5674  if (a->word[0] == 'o') {
5675  return ast_strdup("only");
5676  }
5677  break;
5678  }
5679  return NULL;
5680 }
#define ast_strdup(str)
A wrapper for strdup()
Definition: astmm.h:243
#define NULL
Definition: resample.c:96
const int n
Definition: cli.h:165
const char * word
Definition: cli.h:163
const int pos
Definition: cli.h:164

◆ complete_show_config()

static char * complete_show_config ( struct ast_cli_args a)
static

Definition at line 5682 of file chan_misdn.c.

References ast_strdup, BUFFERSIZE, ast_cli_args::line, MISDN_CFG_FIRST, misdn_cfg_get_name(), misdn_cfg_get_next_port(), MISDN_CFG_LAST, MISDN_GEN_FIRST, MISDN_GEN_LAST, ast_cli_args::n, NULL, ast_cli_args::pos, and ast_cli_args::word.

Referenced by handle_cli_misdn_show_config().

5683 {
5684  char buffer[BUFFERSIZE];
5685  enum misdn_cfg_elements elem;
5686  int wordlen = strlen(a->word);
5687  int which = 0;
5688  int port = 0;
5689 
5690  switch (a->pos) {
5691  case 3:
5692  if ((!strncmp(a->word, "description", wordlen)) && (++which > a->n)) {
5693  return ast_strdup("description");
5694  }
5695  if ((!strncmp(a->word, "descriptions", wordlen)) && (++which > a->n)) {
5696  return ast_strdup("descriptions");
5697  }
5698  if ((!strncmp(a->word, "0", wordlen)) && (++which > a->n)) {
5699  return ast_strdup("0");
5700  }
5701  while ((port = misdn_cfg_get_next_port(port)) != -1) {
5702  snprintf(buffer, sizeof(buffer), "%d", port);
5703  if ((!strncmp(a->word, buffer, wordlen)) && (++which > a->n)) {
5704  return ast_strdup(buffer);
5705  }
5706  }
5707  break;
5708  case 4:
5709  if (strstr(a->line, "description ")) {
5710  for (elem = MISDN_CFG_FIRST + 1; elem < MISDN_GEN_LAST; ++elem) {
5711  if ((elem == MISDN_CFG_LAST) || (elem == MISDN_GEN_FIRST)) {
5712  continue;
5713  }
5714  misdn_cfg_get_name(elem, buffer, sizeof(buffer));
5715  if (!wordlen || !strncmp(a->word, buffer, wordlen)) {
5716  if (++which > a->n) {
5717  return ast_strdup(buffer);
5718  }
5719  }
5720  }
5721  } else if (strstr(a->line, "descriptions ")) {
5722  if ((!wordlen || !strncmp(a->word, "general", wordlen)) && (++which > a->n)) {
5723  return ast_strdup("general");
5724  }
5725  if ((!wordlen || !strncmp(a->word, "ports", wordlen)) && (++which > a->n)) {
5726  return ast_strdup("ports");
5727  }
5728  }
5729  break;
5730  }
5731  return NULL;
5732 }
int misdn_cfg_get_next_port(int port)
Definition: misdn_config.c:929
misdn_cfg_elements
#define ast_strdup(str)
A wrapper for strdup()
Definition: astmm.h:243
#define NULL
Definition: resample.c:96
void misdn_cfg_get_name(enum misdn_cfg_elements elem, void *buf, int bufsize)
Definition: misdn_config.c:655
const char * line
Definition: cli.h:162
#define BUFFERSIZE
const int n
Definition: cli.h:165
const char * word
Definition: cli.h:163
const int pos
Definition: cli.h:164

◆ config_jitterbuffer()

static void config_jitterbuffer ( struct chan_list ch)
static

Definition at line 5817 of file chan_misdn.c.

References chan_list::bc, cb_log, chan_misdn_log(), chan_list::jb, chan_list::jb_len, chan_list::jb_upper_threshold, len(), misdn_jb_destroy(), misdn_jb_init(), misdn_bchannel::nojitter, NULL, and misdn_bchannel::port.

Referenced by misdn_set_opt_exec(), and read_config().

5818 {
5819  struct misdn_bchannel *bc = ch->bc;
5820  int len = ch->jb_len;
5821  int threshold = ch->jb_upper_threshold;
5822 
5823  chan_misdn_log(5, bc->port, "config_jb: Called\n");
5824 
5825  if (!len) {
5826  chan_misdn_log(1, bc->port, "config_jb: Deactivating Jitterbuffer\n");
5827  bc->nojitter = 1;
5828  } else {
5829  if (len <= 100 || len > 8000) {
5830  chan_misdn_log(0, bc->port, "config_jb: Jitterbuffer out of Bounds, setting to 1000\n");
5831  len = 1000;
5832  }
5833 
5834  if (threshold > len) {
5835  chan_misdn_log(0, bc->port, "config_jb: Jitterbuffer Threshold > Jitterbuffer setting to Jitterbuffer -1\n");
5836  }
5837 
5838  if (ch->jb) {
5839  cb_log(0, bc->port, "config_jb: We've got a Jitterbuffer Already on this port.\n");
5840  misdn_jb_destroy(ch->jb);
5841  ch->jb = NULL;
5842  }
5843 
5844  ch->jb = misdn_jb_init(len, threshold);
5845 
5846  if (!ch->jb) {
5847  bc->nojitter = 1;
5848  }
5849  }
5850 }
static void chan_misdn_log(int level, int port, char *tmpl,...)
Definition: chan_misdn.c:12768
int jb_len
Jitterbuffer length.
Definition: chan_misdn.c:490
#define bc
struct misdn_jb * jb
Allocated jitterbuffer controller.
Definition: chan_misdn.c:503
void misdn_jb_destroy(struct misdn_jb *jb)
frees the data and destroys the given jitterbuffer struct
Definition: chan_misdn.c:12639
int jb_upper_threshold
Jitterbuffer upper threshold.
Definition: chan_misdn.c:496
B channel control structure.
Definition: isdn_lib.h:324
#define NULL
Definition: resample.c:96
threshold
Definition: dsp.h:71
int nojitter
TRUE if we will not use the jitter buffer system.
Definition: isdn_lib.h:477
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
int port
Logical Layer 1 port associated with this B channel.
Definition: isdn_lib.h:370
struct misdn_bchannel * bc
Associated B channel structure.
Definition: chan_misdn.c:520
struct misdn_jb * misdn_jb_init(int size, int upper_threshold)
allocates the jb-structure and initialize the elements
Definition: chan_misdn.c:12602
void(* cb_log)(int level, int port, char *tmpl,...)
Definition: isdn_lib.c:32

◆ debug_numtype()

void debug_numtype ( int  port,
int  numtype,
char *  type 
)

Definition at line 5853 of file chan_misdn.c.

References ast_copy_string(), chan_misdn_log(), MISDN_CFG_ECHOCANCEL, misdn_cfg_get(), NUMTYPE_ABBREVIATED, NUMTYPE_INTERNATIONAL, NUMTYPE_NATIONAL, NUMTYPE_NETWORK_SPECIFIC, NUMTYPE_SUBSCRIBER, NUMTYPE_UNKNOWN, and misdn_bchannel::port.

Referenced by misdn_call(), misdn_get_connected_line(), and read_config().

5854 {
5855  switch (numtype) {
5856  case NUMTYPE_UNKNOWN:
5857  chan_misdn_log(2, port, " --> %s: Unknown\n", type);
5858  break;
5859  case NUMTYPE_INTERNATIONAL:
5860  chan_misdn_log(2, port, " --> %s: International\n", type);
5861  break;
5862  case NUMTYPE_NATIONAL:
5863  chan_misdn_log(2, port, " --> %s: National\n", type);
5864  break;
5866  chan_misdn_log(2, port, " --> %s: Network Specific\n", type);
5867  break;
5868  case NUMTYPE_SUBSCRIBER:
5869  chan_misdn_log(2, port, " --> %s: Subscriber\n", type);
5870  break;
5871  case NUMTYPE_ABBREVIATED:
5872  chan_misdn_log(2, port, " --> %s: Abbreviated\n", type);
5873  break;
5874  /* Maybe we should cut off the prefix if present ? */
5875  default:
5876  chan_misdn_log(0, port, " --> !!!! Wrong dialplan setting, please see the misdn.conf sample file\n ");
5877  break;
5878  }
5879 }
static void chan_misdn_log(int level, int port, char *tmpl,...)
Definition: chan_misdn.c:12768
static const char type[]
Definition: chan_ooh323.c:109
int port
Logical Layer 1 port associated with this B channel.
Definition: isdn_lib.h:370

◆ dialtone_indicate()

static int dialtone_indicate ( struct chan_list cl)
static

AST INDICATIONS END

Definition at line 7707 of file chan_misdn.c.

References chan_list::ast, ast_channel_zone(), ast_get_indication_tone(), ast_playtones_start(), chan_list::bc, chan_misdn_log(), ast_tone_zone_sound::data, misdn_cfg_get(), MISDN_CFG_NODIALTONE, chan_list::norxtone, chan_list::notxtone, misdn_bchannel::port, and chan_list::ts.

Referenced by wait_for_digits().

7708 {
7709  struct ast_channel *ast = cl->ast;
7710  int nd = 0;
7711 
7712  if (!ast) {
7713  chan_misdn_log(0, cl->bc->port, "No Ast in dialtone_indicate\n");
7714  return -1;
7715  }
7716 
7717  misdn_cfg_get(cl->bc->port, MISDN_CFG_NODIALTONE, &nd, sizeof(nd));
7718 
7719  if (nd) {
7720  chan_misdn_log(1, cl->bc->port, "Not sending Dialtone, because config wants it\n");
7721  return 0;
7722  }
7723 
7724  chan_misdn_log(3, cl->bc->port, " --> Dial\n");
7725 
7726  cl->ts = ast_get_indication_tone(ast_channel_zone(ast), "dial");
7727 
7728  if (cl->ts) {
7729  cl->notxtone = 0;
7730  cl->norxtone = 0;
7731  /* This prods us in misdn_write */
7732  ast_playtones_start(ast, 0, cl->ts->data, 0);
7733  }
7734 
7735  return 0;
7736 }
static void chan_misdn_log(int level, int port, char *tmpl,...)
Definition: chan_misdn.c:12768
Main Channel structure associated with a channel.
struct ast_tone_zone * ast_channel_zone(const struct ast_channel *chan)
int norxtone
Definition: chan_misdn.c:415
struct ast_channel * ast
Associated Asterisk channel structure.
Definition: chan_misdn.c:515
int notxtone
TRUE if we are not to generate tones (Playtones)
Definition: chan_misdn.c:420
void misdn_cfg_get(int port, enum misdn_cfg_elements elem, void *buf, int bufsize)
Definition: misdn_config.c:569
struct ast_tone_zone_sound * ast_get_indication_tone(const struct ast_tone_zone *zone, const char *indication)
Locate a tone zone sound.
Definition: indications.c:455
int port
Logical Layer 1 port associated with this B channel.
Definition: isdn_lib.h:370
struct ast_tone_zone_sound * ts
Tone zone sound used for dialtone generation.
Definition: chan_misdn.c:582
int ast_playtones_start(struct ast_channel *chan, int vol, const char *tonelist, int interruptible)
Start playing a list of tones on a channel.
Definition: indications.c:302
const char * data
Description of a tone.
Definition: indications.h:52
struct misdn_bchannel * bc
Associated B channel structure.
Definition: chan_misdn.c:520

◆ do_immediate_setup()

static void do_immediate_setup ( struct misdn_bchannel bc,
struct chan_list ch,
struct ast_channel ast 
)
static

Definition at line 8659 of file chan_misdn.c.

References chan_list::ast, ast_canmatch_extension(), AST_CAUSE_UNALLOCATED, ast_channel_caller(), ast_channel_context(), ast_channel_exten(), ast_channel_exten_set(), AST_FRAME_DTMF, ast_queue_frame(), ast_strdupa, ast_strlen_zero, ast_tv(), misdn_bchannel::caller, chan_misdn_log(), ast_frame::data, ast_frame::datalen, ast_frame::delivery, EVENT_DISCONNECT, EVENT_PROCEEDING, EVENT_RELEASE_COMPLETE, EVENT_SETUP_ACKNOWLEDGE, ast_frame::frametype, hangup_chan(), hanguptone_indicate(), ast_frame_subclass::integer, ast_frame::mallocd, MISDN_ASTERISK_TECH_PVT, MISDN_DIALING, MISDN_INCOMING_SETUP, misdn_lib_is_ptp(), misdn_lib_send_event(), name, chan_list::noautorespond_on_setup, misdn_bchannel::nt, NULL, misdn_party_id::number, ast_frame::offset, misdn_bchannel::out_cause, pbx_start_chan(), misdn_bchannel::port, ast_frame::ptr, ast_frame::samples, ast_frame::src, chan_list::state, and ast_frame::subclass.

Referenced by cb_events().

8660 {
8661  char *predial;
8662  struct ast_frame fr;
8663 
8664  predial = ast_strdupa(ast_channel_exten(ast));
8665 
8666  ch->state = MISDN_DIALING;
8667 
8668  if (!ch->noautorespond_on_setup) {
8669  if (bc->nt) {
8671  } else {
8672  if (misdn_lib_is_ptp(bc->port)) {
8674  } else {
8676  }
8677  }
8678  } else {
8680  }
8681 
8682  chan_misdn_log(1, bc->port,
8683  "* Starting Ast context:%s dialed:%s caller:\"%s\" <%s> with 's' extension\n",
8684  ast_channel_context(ast),
8685  ast_channel_exten(ast),
8686  (ast_channel_caller(ast)->id.name.valid && ast_channel_caller(ast)->id.name.str)
8687  ? ast_channel_caller(ast)->id.name.str : "",
8688  (ast_channel_caller(ast)->id.number.valid && ast_channel_caller(ast)->id.number.str)
8689  ? ast_channel_caller(ast)->id.number.str : "");
8690 
8691  ast_channel_exten_set(ast, "s");
8692 
8693  if (!ast_canmatch_extension(ast, ast_channel_context(ast), ast_channel_exten(ast), 1, bc->caller.number) || pbx_start_chan(ch) < 0) {
8694  ast = NULL;
8696  hangup_chan(ch, bc);
8697  hanguptone_indicate(ch);
8698 
8700  }
8701 
8702 
8703  while (!ast_strlen_zero(predial)) {
8704  fr.frametype = AST_FRAME_DTMF;
8705  fr.subclass.integer = *predial;
8706  fr.src = NULL;
8707  fr.data.ptr = NULL;
8708  fr.datalen = 0;
8709  fr.samples = 0;
8710  fr.mallocd = 0;
8711  fr.offset = 0;
8712  fr.delivery = ast_tv(0,0);
8713 
8714  if (ch->ast && MISDN_ASTERISK_TECH_PVT(ch->ast)) {
8715  ast_queue_frame(ch->ast, &fr);
8716  }
8717  predial++;
8718  }
8719 }
struct ast_party_caller * ast_channel_caller(struct ast_channel *chan)
static void chan_misdn_log(int level, int port, char *tmpl,...)
Definition: chan_misdn.c:12768
static void hanguptone_indicate(struct chan_list *cl)
Definition: chan_misdn.c:7738
char number[MISDN_MAX_NUMBER_LEN]
Phone number (Address)
Definition: isdn_lib.h:298
#define AST_CAUSE_UNALLOCATED
Definition: causes.h:97
static int pbx_start_chan(struct chan_list *ch)
Definition: chan_misdn.c:8438
#define MISDN_ASTERISK_TECH_PVT(ast)
Definition: chan_misdn.c:683
#define NULL
Definition: resample.c:96
#define AST_FRAME_DTMF
struct ast_channel * ast
Associated Asterisk channel structure.
Definition: chan_misdn.c:515
int ast_canmatch_extension(struct ast_channel *c, const char *context, const char *exten, int priority, const char *callerid)
Looks for a valid matching extension.
Definition: pbx.c:4194
#define ast_strlen_zero(foo)
Definition: strings.h:52
Number structure.
Definition: app_followme.c:154
int nt
TRUE if NT side of protocol (TE otherwise)
Definition: isdn_lib.h:364
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: astmm.h:300
struct misdn_party_id caller
Originating/Caller ID information struct.
Definition: isdn_lib.h:343
enum misdn_chan_state state
State of the channel.
Definition: chan_misdn.c:386
const char * ast_channel_exten(const struct ast_channel *chan)
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:1139
int misdn_lib_is_ptp(int port)
Definition: isdn_lib.c:128
int port
Logical Layer 1 port associated with this B channel.
Definition: isdn_lib.h:370
static const char name[]
Definition: cdr_mysql.c:74
static void hangup_chan(struct chan_list *ch, struct misdn_bchannel *bc)
Definition: chan_misdn.c:8447
void ast_channel_exten_set(struct ast_channel *chan, const char *value)
int out_cause
Q.931 Cause for disconnection code (sent)
Definition: isdn_lib.h:677
struct timeval ast_tv(ast_time_t sec, ast_suseconds_t usec)
Returns a timeval from sec, usec.
Definition: time.h:226
Data structure associated with a single frame of data.
int misdn_lib_send_event(struct misdn_bchannel *bc, enum event_e event)
Definition: isdn_lib.c:3523
const char * ast_channel_context(const struct ast_channel *chan)
int noautorespond_on_setup
TRUE of we are not to respond immediately to a SETUP message. Check the dialplan first.
Definition: chan_misdn.c:413

◆ export_aoc_vars()

static void export_aoc_vars ( int  originator,
struct ast_channel ast,
struct misdn_bchannel bc 
)
static

Definition at line 3458 of file chan_misdn.c.

References misdn_bchannel::AOCD, misdn_bchannel::AOCD_need_export, misdn_bchannel::AOCDtype, ast_channel_bridge_peer(), ast_channel_cleanup, ast_channel_ref, buf, misdn_bchannel::chargingUnit, misdn_bchannel::currency, NULL, ORG_AST, pbx_builtin_setvar_helper(), and RAII_VAR.

Referenced by cb_events(), and misdn_facility_ie_handler().

3459 {
3460  RAII_VAR(struct ast_channel *, chan, NULL, ast_channel_cleanup);
3461  char buf[128];
3462 
3463  if (!bc->AOCD_need_export || !ast) {
3464  return;
3465  }
3466 
3467  if (originator == ORG_AST) {
3468  chan = ast_channel_bridge_peer(ast);
3469  if (!chan) {
3470  return;
3471  }
3472  } else {
3473  chan = ast_channel_ref(ast);
3474  }
3475 
3476  switch (bc->AOCDtype) {
3477  case Fac_AOCDCurrency:
3478  pbx_builtin_setvar_helper(chan, "AOCD_Type", "currency");
3479  if (bc->AOCD.currency.chargeNotAvailable) {
3480  pbx_builtin_setvar_helper(chan, "AOCD_ChargeAvailable", "no");
3481  } else {
3482  pbx_builtin_setvar_helper(chan, "AOCD_ChargeAvailable", "yes");
3483  if (bc->AOCD.currency.freeOfCharge) {
3484  pbx_builtin_setvar_helper(chan, "AOCD_FreeOfCharge", "yes");
3485  } else {
3486  pbx_builtin_setvar_helper(chan, "AOCD_FreeOfCharge", "no");
3487  if (snprintf(buf, sizeof(buf), "%d %s", bc->AOCD.currency.currencyAmount * bc->AOCD.currency.multiplier, bc->AOCD.currency.currency) < sizeof(buf)) {
3488  pbx_builtin_setvar_helper(chan, "AOCD_Amount", buf);
3489  if (bc->AOCD.currency.billingId >= 0 && snprintf(buf, sizeof(buf), "%d", bc->AOCD.currency.billingId) < sizeof(buf)) {
3490  pbx_builtin_setvar_helper(chan, "AOCD_BillingId", buf);
3491  }
3492  }
3493  }
3494  }
3495  break;
3496  case Fac_AOCDChargingUnit:
3497  pbx_builtin_setvar_helper(chan, "AOCD_Type", "charging_unit");
3498  if (bc->AOCD.chargingUnit.chargeNotAvailable) {
3499  pbx_builtin_setvar_helper(chan, "AOCD_ChargeAvailable", "no");
3500  } else {
3501  pbx_builtin_setvar_helper(chan, "AOCD_ChargeAvailable", "yes");
3502  if (bc->AOCD.chargingUnit.freeOfCharge) {
3503  pbx_builtin_setvar_helper(chan, "AOCD_FreeOfCharge", "yes");
3504  } else {
3505  pbx_builtin_setvar_helper(chan, "AOCD_FreeOfCharge", "no");
3506  if (snprintf(buf, sizeof(buf), "%d", bc->AOCD.chargingUnit.recordedUnits) < sizeof(buf)) {
3507  pbx_builtin_setvar_helper(chan, "AOCD_RecordedUnits", buf);
3508  if (bc->AOCD.chargingUnit.billingId >= 0 && snprintf(buf, sizeof(buf), "%d", bc->AOCD.chargingUnit.billingId) < sizeof(buf)) {
3509  pbx_builtin_setvar_helper(chan, "AOCD_BillingId", buf);
3510  }
3511  }
3512  }
3513  }
3514  break;
3515  default:
3516  break;
3517  }
3518 
3519  bc->AOCD_need_export = 0;
3520 }
Main Channel structure associated with a channel.
union misdn_bchannel::@161 AOCD
enum FacFunction AOCDtype
Definition: isdn_lib.h:515
char buf[BUFSIZE]
Definition: eagi_proxy.c:66
int AOCD_need_export
TRUE if AOCDtype and AOCD data are ready to export to Asterisk.
Definition: isdn_lib.h:521
#define NULL
Definition: resample.c:96
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
Definition: utils.h:911
#define ast_channel_cleanup(c)
Cleanup a channel reference.
Definition: channel.h:2992
struct FacAOCDCurrency currency
Definition: isdn_lib.h:517
int pbx_builtin_setvar_helper(struct ast_channel *chan, const char *name, const char *value)
Add a variable to the channel variable stack, removing the most recently set value for the same name...
#define ast_channel_ref(c)
Increase channel reference count.
Definition: channel.h:2970
struct ast_channel * ast_channel_bridge_peer(struct ast_channel *chan)
Get the channel&#39;s bridge peer only if the bridge is two-party.
Definition: channel.c:10765
#define ORG_AST
Definition: chan_misdn.c:343
struct FacAOCDChargingUnit chargingUnit
Definition: isdn_lib.h:518

◆ export_ch()

void export_ch ( struct ast_channel chan,
struct misdn_bchannel bc,
struct chan_list ch 
)

Export parameters to the dialplan environment variables.

Definition at line 8811 of file chan_misdn.c.

References ast_strlen_zero, chan_misdn_log(), misdn_bchannel::keypad, pbx_builtin_setvar_helper(), misdn_bchannel::pid, misdn_bchannel::port, misdn_bchannel::sending_complete, tmp(), misdn_bchannel::urate, misdn_bchannel::uu, and misdn_bchannel::uulen.

Referenced by cb_events().

8812 {
8813  char tmp[32];
8814 
8815  /*
8816  * The only use for MISDN_PID is if there is a problem and you
8817  * have to use the "misdn restart pid" CLI command. Otherwise,
8818  * the pid is not used by anyone. The internal use of MISDN_PID
8819  * has been deleted.
8820  */
8821  chan_misdn_log(3, bc->port, " --> EXPORT_PID: pid:%d\n", bc->pid);
8822  snprintf(tmp, sizeof(tmp), "%d", bc->pid);
8823  pbx_builtin_setvar_helper(chan, "_MISDN_PID", tmp);
8824 
8825  if (bc->sending_complete) {
8826  snprintf(tmp, sizeof(tmp), "%d", bc->sending_complete);
8827  pbx_builtin_setvar_helper(chan, "MISDN_ADDRESS_COMPLETE", tmp);
8828  }
8829 
8830  if (bc->urate) {
8831  snprintf(tmp, sizeof(tmp), "%d", bc->urate);
8832  pbx_builtin_setvar_helper(chan, "MISDN_URATE", tmp);
8833  }
8834 
8835  if (bc->uulen) {
8836  pbx_builtin_setvar_helper(chan, "MISDN_USERUSER", bc->uu);
8837  }
8838 
8839  if (!ast_strlen_zero(bc->keypad)) {
8840  pbx_builtin_setvar_helper(chan, "MISDN_KEYPAD", bc->keypad);
8841  }
8842 }
static void chan_misdn_log(int level, int port, char *tmpl,...)
Definition: chan_misdn.c:12768
char keypad[MISDN_MAX_KEYPAD_LEN]
Q.931 Keypad Facility IE contents.
Definition: isdn_lib.h:647
int uulen
User-User information string length in uu[].
Definition: isdn_lib.h:666
char uu[256]
User-User information string.
Definition: isdn_lib.h:663
static int tmp()
Definition: bt_open.c:389
int sending_complete
TRUE if all digits necessary to complete the call are available. No more INFORMATION messages are nee...
Definition: isdn_lib.h:470
#define ast_strlen_zero(foo)
Definition: strings.h:52
int pid
B channel process ID (1-5000)
Definition: isdn_lib.h:402
int port
Logical Layer 1 port associated with this B channel.
Definition: isdn_lib.h:370
int urate
Q.931 Bearer Capability IE Layer 1 User Rate field.
Definition: isdn_lib.h:629
int pbx_builtin_setvar_helper(struct ast_channel *chan, const char *name, const char *value)
Add a variable to the channel variable stack, removing the most recently set value for the same name...

◆ find_chan_by_bc()

static struct chan_list* find_chan_by_bc ( struct misdn_bchannel bc)
static

Returns a reference to the found chan_list.

Definition at line 8259 of file chan_misdn.c.

References ast_mutex_lock, ast_mutex_unlock, chan_list::bc, misdn_bchannel::caller, chan_list_ref, chan_misdn_log(), misdn_bchannel::dialed, misdn_party_id::name, chan_list::next, NULL, misdn_party_dialing::number, misdn_party_id::number, and misdn_bchannel::port.

Referenced by cb_events(), and chan_misdn_jb_empty().

8260 {
8261  struct chan_list *help;
8262 
8264  for (help = cl_te; help; help = help->next) {
8265  if (help->bc == bc) {
8266  chan_list_ref(help, "Found chan_list by bc");
8268  return help;
8269  }
8270  }
8272 
8273  chan_misdn_log(6, bc->port,
8274  "$$$ find_chan_by_bc: No channel found for dialed:%s caller:\"%s\" <%s>\n",
8275  bc->dialed.number,
8276  bc->caller.name,
8277  bc->caller.number);
8278 
8279  return NULL;
8280 }
static void chan_misdn_log(int level, int port, char *tmpl,...)
Definition: chan_misdn.c:12768
struct chan_list * next
Next channel call record in the list.
Definition: chan_misdn.c:608
char number[MISDN_MAX_NUMBER_LEN]
Phone number (Address)
Definition: isdn_lib.h:298
#define ast_mutex_lock(a)
Definition: lock.h:187
#define NULL
Definition: resample.c:96
static struct chan_list * cl_te
Global channel call record list head.
Definition: chan_misdn.c:704
char number[MISDN_MAX_NUMBER_LEN]
Dialed/Called Phone Number (Address)
Definition: isdn_lib.h:266
struct misdn_party_id caller
Originating/Caller ID information struct.
Definition: isdn_lib.h:343
char name[MISDN_MAX_NAME_LEN]
Subscriber Name.
Definition: isdn_lib.h:295
int port
Logical Layer 1 port associated with this B channel.
Definition: isdn_lib.h:370
struct misdn_party_dialing dialed
Dialed/Called information struct.
Definition: isdn_lib.h:337
Channel call record structure.
Definition: chan_misdn.c:377
#define chan_list_ref(obj, debug)
Definition: chan_misdn.c:371
struct misdn_bchannel * bc
Associated B channel structure.
Definition: chan_misdn.c:520
static ast_mutex_t cl_te_lock
Definition: chan_misdn.c:705
#define ast_mutex_unlock(a)
Definition: lock.h:188

◆ find_hold_active_call()

static struct chan_list* find_hold_active_call ( struct misdn_bchannel bc)
static

Definition at line 8351 of file chan_misdn.c.

References chan_list::ast, ast_mutex_lock, ast_mutex_unlock, chan_list::bc, chan_list_ref, chan_list::hold, MISDN_ALERTING, MISDN_CONNECTED, MISDN_HOLD_IDLE, MISDN_PROCEEDING, MISDN_PROGRESS, chan_list::next, NULL, misdn_bchannel::port, hold_info::state, and chan_list::state.

Referenced by cb_events().

8352 {
8353  struct chan_list *list;
8354 
8356  for (list = cl_te; list; list = list->next) {
8357  if (list->hold.state == MISDN_HOLD_IDLE && list->bc && list->bc->port == bc->port
8358  && list->ast) {
8359  switch (list->state) {
8360  case MISDN_PROCEEDING:
8361  case MISDN_PROGRESS:
8362  case MISDN_ALERTING:
8363  case MISDN_CONNECTED:
8364  chan_list_ref(list, "Found chan_list hold active call");
8366  return list;
8367  default:
8368  break;
8369  }
8370  }
8371  }
8373  return NULL;
8374 }
struct chan_list * next
Next channel call record in the list.
Definition: chan_misdn.c:608
struct hold_info hold
HELD channel call information.
Definition: chan_misdn.c:535
#define ast_mutex_lock(a)
Definition: lock.h:187
#define NULL
Definition: resample.c:96
static struct chan_list * cl_te
Global channel call record list head.
Definition: chan_misdn.c:704
struct ast_channel * ast
Associated Asterisk channel structure.
Definition: chan_misdn.c:515
enum misdn_chan_state state
State of the channel.
Definition: chan_misdn.c:386
int port
Logical Layer 1 port associated with this B channel.
Definition: isdn_lib.h:370
Channel call record structure.
Definition: chan_misdn.c:377
#define chan_list_ref(obj, debug)
Definition: chan_misdn.c:371
enum misdn_hold_state state
Call HOLD state.
Definition: chan_misdn.c:357
struct misdn_bchannel * bc
Associated B channel structure.
Definition: chan_misdn.c:520
static ast_mutex_t cl_te_lock
Definition: chan_misdn.c:705
#define ast_mutex_unlock(a)
Definition: lock.h:188

◆ find_hold_call()

static struct chan_list* find_hold_call ( struct misdn_bchannel bc)
static

Returns a reference to the found chan_list.

Definition at line 8283 of file chan_misdn.c.

References ast_mutex_lock, ast_mutex_unlock, misdn_bchannel::caller, chan_list_ref, chan_misdn_log(), hold_info::channel, misdn_bchannel::channel, misdn_bchannel::dialed, chan_list::hold, MISDN_HOLD_ACTIVE, misdn_party_id::name, chan_list::next, NULL, misdn_party_dialing::number, misdn_party_id::number, hold_info::port, misdn_bchannel::port, misdn_bchannel::pri, and hold_info::state.

Referenced by cb_events().

8284 {
8285  struct chan_list *help;
8286 
8287  if (bc->pri) {
8288  return NULL;
8289  }
8290 
8291  chan_misdn_log(6, bc->port, "$$$ find_hold_call: channel:%d dialed:%s caller:\"%s\" <%s>\n",
8292  bc->channel,
8293  bc->dialed.number,
8294  bc->caller.name,
8295  bc->caller.number);
8297  for (help = cl_te; help; help = help->next) {
8298  chan_misdn_log(4, bc->port, "$$$ find_hold_call: --> hold:%d channel:%d\n", help->hold.state, help->hold.channel);
8299  if (help->hold.state == MISDN_HOLD_ACTIVE && help->hold.port == bc->port) {
8300  chan_list_ref(help, "Found chan_list hold call");
8302  return help;
8303  }
8304  }
8306  chan_misdn_log(6, bc->port,
8307  "$$$ find_hold_call: No channel found for dialed:%s caller:\"%s\" <%s>\n",
8308  bc->dialed.number,
8309  bc->caller.name,
8310  bc->caller.number);
8311 
8312  return NULL;
8313 }
static void chan_misdn_log(int level, int port, char *tmpl,...)
Definition: chan_misdn.c:12768
struct chan_list * next
Next channel call record in the list.
Definition: chan_misdn.c:608
char number[MISDN_MAX_NUMBER_LEN]
Phone number (Address)
Definition: isdn_lib.h:298
struct hold_info hold
HELD channel call information.
Definition: chan_misdn.c:535
#define ast_mutex_lock(a)
Definition: lock.h:187
#define NULL
Definition: resample.c:96
static struct chan_list * cl_te
Global channel call record list head.
Definition: chan_misdn.c:704
char number[MISDN_MAX_NUMBER_LEN]
Dialed/Called Phone Number (Address)
Definition: isdn_lib.h:266
int pri
TRUE if ISDN-PRI (ISDN-BRI otherwise)
Definition: isdn_lib.h:367
struct misdn_party_id caller
Originating/Caller ID information struct.
Definition: isdn_lib.h:343
char name[MISDN_MAX_NAME_LEN]
Subscriber Name.
Definition: isdn_lib.h:295
int port
Logical port the channel call record is HELD on because the B channel is no longer associated...
Definition: chan_misdn.c:362
int port
Logical Layer 1 port associated with this B channel.
Definition: isdn_lib.h:370
struct misdn_party_dialing dialed
Dialed/Called information struct.
Definition: isdn_lib.h:337
Channel call record structure.
Definition: chan_misdn.c:377
#define chan_list_ref(obj, debug)
Definition: chan_misdn.c:371
enum misdn_hold_state state
Call HOLD state.
Definition: chan_misdn.c:357
int channel
Original B channel number the HELD call was using.
Definition: chan_misdn.c:368
int channel
Assigned B channel number B1, B2... 0 if not assigned.
Definition: isdn_lib.h:411
static ast_mutex_t cl_te_lock
Definition: chan_misdn.c:705
#define ast_mutex_unlock(a)
Definition: lock.h:188

◆ find_hold_call_l3()

static struct chan_list* find_hold_call_l3 ( unsigned long  l3_id)
static

Returns a reference to the found chan_list.

Definition at line 8317 of file chan_misdn.c.

References ast_mutex_lock, ast_mutex_unlock, chan_list_ref, chan_list::hold, chan_list::l3id, MISDN_HOLD_IDLE, chan_list::next, NULL, and hold_info::state.

Referenced by cb_events().

8318 {
8319  struct chan_list *help;
8320 
8322  for (help = cl_te; help; help = help->next) {
8323  if (help->hold.state != MISDN_HOLD_IDLE && help->l3id == l3_id) {
8324  chan_list_ref(help, "Found chan_list hold call l3");
8326  return help;
8327  }
8328  }
8330 
8331  return NULL;
8332 }
struct chan_list * next
Next channel call record in the list.
Definition: chan_misdn.c:608
struct hold_info hold
HELD channel call information.
Definition: chan_misdn.c:535
#define ast_mutex_lock(a)
Definition: lock.h:187
#define NULL
Definition: resample.c:96
static struct chan_list * cl_te
Global channel call record list head.
Definition: chan_misdn.c:704
Channel call record structure.
Definition: chan_misdn.c:377
unsigned int l3id
From associated B channel: Layer 3 process ID.
Definition: chan_misdn.c:541
#define chan_list_ref(obj, debug)
Definition: chan_misdn.c:371
enum misdn_hold_state state
Call HOLD state.
Definition: chan_misdn.c:357
static ast_mutex_t cl_te_lock
Definition: chan_misdn.c:705
#define ast_mutex_unlock(a)
Definition: lock.h:188

◆ free_robin_list()

static void free_robin_list ( void  )
static

Definition at line 629 of file chan_misdn.c.

References ast_free, robin_list::group, robin_list::next, and NULL.

Referenced by reload_config(), and unload_module().

630 {
631  struct robin_list *r;
632  struct robin_list *next;
633 
634  for (r = robin, robin = NULL; r; r = next) {
635  next = r->next;
636  ast_free(r->group);
637  ast_free(r);
638  }
639 }
struct robin_list * next
Definition: chan_misdn.c:623
static struct robin_list * robin
Definition: chan_misdn.c:626
#define NULL
Definition: resample.c:96
char * group
Definition: chan_misdn.c:620
#define ast_free(a)
Definition: astmm.h:182

◆ get_chan_by_ast_name()

static struct chan_list* get_chan_by_ast_name ( const char *  name)
static

Returns a reference to the found chan_list.

Definition at line 786 of file chan_misdn.c.

References ao2_lock, ao2_ref, ao2_unlock, ARRAY_LEN, chan_list::ast, ast_calloc, AST_CAUSE_NORMAL_CLEARING, ast_channel_datastore_find(), ast_channel_lock, ast_channel_name(), ast_channel_trylock, ast_channel_unlock, ast_free, AST_LIST_INSERT_HEAD, AST_LIST_LOCK, AST_LIST_REMOVE_CURRENT, AST_LIST_REMOVE_HEAD, AST_LIST_TRAVERSE, AST_LIST_TRAVERSE_SAFE_BEGIN, AST_LIST_TRAVERSE_SAFE_END, AST_LIST_UNLOCK, ast_mutex_lock, ast_mutex_unlock, ast_safe_sleep_conditional(), bc, chan_list_ref, chan_misdn_log(), ast_datastore::data, EVENT_RELEASE_COMPLETE, misdn_lib_send_event(), mISDN_REDIRECTING_REASON_CALL_FWD, mISDN_REDIRECTING_REASON_CALL_FWD_BUSY, mISDN_REDIRECTING_REASON_NO_REPLY, mISDN_REDIRECTING_REASON_UNKNOWN, name, chan_list::next, NULL, NUMPLAN_DATA, NUMPLAN_ISDN, NUMPLAN_NATIONAL, NUMPLAN_PRIVATE, NUMPLAN_TELEX, NUMPLAN_UNKNOWN, NUMTYPE_ABBREVIATED, NUMTYPE_INTERNATIONAL, NUMTYPE_NATIONAL, NUMTYPE_NETWORK_SPECIFIC, NUMTYPE_SUBSCRIBER, NUMTYPE_UNKNOWN, pbx_builtin_setvar_helper(), tmp(), ast_datastore_info::type, type, value, and var.

Referenced by handle_cli_misdn_send_digit(), handle_cli_misdn_send_display(), handle_cli_misdn_send_facility(), and handle_cli_misdn_toggle_echocancel().

787 {
788  struct chan_list *tmp;
789 
791  for (tmp = cl_te; tmp; tmp = tmp->next) {
792  if (tmp->ast && strcmp(ast_channel_name(tmp->ast), name) == 0) {
793  chan_list_ref(tmp, "Found chan_list by ast name");
795  return tmp;
796  }
797  }
799 
800  return NULL;
801 }
struct chan_list * next
Next channel call record in the list.
Definition: chan_misdn.c:608
static int tmp()
Definition: bt_open.c:389
#define ast_mutex_lock(a)
Definition: lock.h:187
#define NULL
Definition: resample.c:96
static struct chan_list * cl_te
Global channel call record list head.
Definition: chan_misdn.c:704
struct ast_channel * ast
Associated Asterisk channel structure.
Definition: chan_misdn.c:515
static const char name[]
Definition: cdr_mysql.c:74
Channel call record structure.
Definition: chan_misdn.c:377
#define chan_list_ref(obj, debug)
Definition: chan_misdn.c:371
const char * ast_channel_name(const struct ast_channel *chan)
static ast_mutex_t cl_te_lock
Definition: chan_misdn.c:705
#define ast_mutex_unlock(a)
Definition: lock.h:188

◆ get_robin_position()

static struct robin_list* get_robin_position ( char *  group)
static

Definition at line 641 of file chan_misdn.c.

References ast_calloc, ast_free, ast_strdup, robin_list::group, robin_list::next, NULL, robin_list::prev, and robin.

Referenced by misdn_request().

642 {
643  struct robin_list *new;
644  struct robin_list *iter = robin;
645  for (; iter; iter = iter->next) {
646  if (!strcasecmp(iter->group, group)) {
647  return iter;
648  }
649  }
650  new = ast_calloc(1, sizeof(*new));
651  if (!new) {
652  return NULL;
653  }
654  new->group = ast_strdup(group);
655  if (!new->group) {
656  ast_free(new);
657  return NULL;
658  }
659  new->channel = 1;
660  if (robin) {
661  new->next = robin;
662  robin->prev = new;
663  }
664  robin = new;
665  return robin;
666 }
struct robin_list * next
Definition: chan_misdn.c:623
static struct robin_list * robin
Definition: chan_misdn.c:626
#define ast_strdup(str)
A wrapper for strdup()
Definition: astmm.h:243
#define NULL
Definition: resample.c:96
struct robin_list * prev
Definition: chan_misdn.c:624
char * group
Definition: chan_misdn.c:620
#define ast_free(a)
Definition: astmm.h:182
#define ast_calloc(num, len)
A wrapper for calloc()
Definition: astmm.h:204

◆ handle_cli_misdn_port_block()

static char* handle_cli_misdn_port_block ( struct ast_cli_entry e,
int  cmd,
struct ast_cli_args a 
)
static

Definition at line 3830 of file chan_misdn.c.

References ast_cli_args::argc, ast_cli_args::argv, CLI_GENERATE, CLI_INIT, CLI_SHOWUSAGE, CLI_SUCCESS, ast_cli_entry::command, misdn_lib_port_block(), NULL, and ast_cli_entry::usage.

3831 {
3832  switch (cmd) {
3833  case CLI_INIT:
3834  e->command = "misdn port block";
3835  e->usage =
3836  "Usage: misdn port block <port>\n"
3837  " Block the specified port by <port>.\n";
3838  return NULL;
3839  case CLI_GENERATE:
3840  return NULL;
3841  }
3842 
3843  if (a->argc != 4) {
3844  return CLI_SHOWUSAGE;
3845  }
3846 
3847  misdn_lib_port_block(atoi(a->argv[3]));
3848 
3849  return CLI_SUCCESS;
3850 }
const int argc
Definition: cli.h:160
Definition: cli.h:152
#define NULL
Definition: resample.c:96
int misdn_lib_port_block(int port)
Definition: isdn_lib.c:91
const char *const * argv
Definition: cli.h:161
#define CLI_SHOWUSAGE
Definition: cli.h:45
char * command
Definition: cli.h:186
const char * usage
Definition: cli.h:177
#define CLI_SUCCESS
Definition: cli.h:44

◆ handle_cli_misdn_port_down()

static char* handle_cli_misdn_port_down ( struct ast_cli_entry e,
int  cmd,
struct ast_cli_args a 
)
static

Definition at line 3940 of file chan_misdn.c.

References ast_cli_args::argc, ast_cli_args::argv, CLI_GENERATE, CLI_INIT, CLI_SHOWUSAGE, CLI_SUCCESS, ast_cli_entry::command, misdn_lib_get_port_down(), NULL, and ast_cli_entry::usage.

3941 {
3942  switch (cmd) {
3943  case CLI_INIT:
3944  e->command = "misdn port down";
3945  e->usage =
3946  "Usage: misdn port down <port>\n"
3947  " Try to deactivate the L1 on the given port.\n";
3948  return NULL;
3949  case CLI_GENERATE:
3950  return NULL;
3951  }
3952 
3953  if (a->argc != 4) {
3954  return CLI_SHOWUSAGE;
3955  }
3956 
3957  misdn_lib_get_port_down(atoi(a->argv[3]));
3958 
3959  return CLI_SUCCESS;
3960 }
const int argc
Definition: cli.h:160
Definition: cli.h:152
#define NULL
Definition: resample.c:96
const char *const * argv
Definition: cli.h:161
#define CLI_SHOWUSAGE
Definition: cli.h:45
char * command
Definition: cli.h:186
const char * usage
Definition: cli.h:177
#define CLI_SUCCESS
Definition: cli.h:44
int misdn_lib_get_port_down(int port)
Definition: isdn_lib.c:1805

◆ handle_cli_misdn_port_unblock()

static char* handle_cli_misdn_port_unblock ( struct ast_cli_entry e,
int  cmd,
struct ast_cli_args a 
)
static

Definition at line 3852 of file chan_misdn.c.

References ast_cli_args::argc, ast_cli_args::argv, CLI_GENERATE, CLI_INIT, CLI_SHOWUSAGE, CLI_SUCCESS, ast_cli_entry::command, misdn_lib_port_unblock(), NULL, and ast_cli_entry::usage.

3853 {
3854  switch (cmd) {
3855  case CLI_INIT:
3856  e->command = "misdn port unblock";
3857  e->usage =
3858  "Usage: misdn port unblock <port>\n"
3859  " Unblock the port specified by <port>.\n";
3860  return NULL;
3861  case CLI_GENERATE:
3862  return NULL;
3863  }
3864 
3865  if (a->argc != 4) {
3866  return CLI_SHOWUSAGE;
3867  }
3868 
3869  misdn_lib_port_unblock(atoi(a->argv[3]));
3870 
3871  return CLI_SUCCESS;
3872 }
const int argc
Definition: cli.h:160
Definition: cli.h:152
#define NULL
Definition: resample.c:96
int misdn_lib_port_unblock(int port)
Definition: isdn_lib.c:104
const char *const * argv
Definition: cli.h:161
#define CLI_SHOWUSAGE
Definition: cli.h:45
char * command
Definition: cli.h:186
const char * usage
Definition: cli.h:177
#define CLI_SUCCESS
Definition: cli.h:44

◆ handle_cli_misdn_port_up()

static char* handle_cli_misdn_port_up ( struct ast_cli_entry e,
int  cmd,
struct ast_cli_args a 
)
static

Definition at line 3918 of file chan_misdn.c.

References ast_cli_args::argc, ast_cli_args::argv, CLI_GENERATE, CLI_INIT, CLI_SHOWUSAGE, CLI_SUCCESS, ast_cli_entry::command, misdn_lib_get_port_up(), NULL, and ast_cli_entry::usage.

3919 {
3920  switch (cmd) {
3921  case CLI_INIT:
3922  e->command = "misdn port up";
3923  e->usage =
3924  "Usage: misdn port up <port>\n"
3925  " Try to establish L1 on the given port.\n";
3926  return NULL;
3927  case CLI_GENERATE:
3928  return NULL;
3929  }
3930 
3931  if (a->argc != 4) {
3932  return CLI_SHOWUSAGE;
3933  }
3934 
3935  misdn_lib_get_port_up(atoi(a->argv[3]));
3936 
3937  return CLI_SUCCESS;
3938 }
const int argc
Definition: cli.h:160
Definition: cli.h:152
#define NULL
Definition: resample.c:96
const char *const * argv
Definition: cli.h:161
#define CLI_SHOWUSAGE
Definition: cli.h:45
int misdn_lib_get_port_up(int port)
Definition: isdn_lib.c:1781
char * command
Definition: cli.h:186
const char * usage
Definition: cli.h:177
#define CLI_SUCCESS
Definition: cli.h:44

◆ handle_cli_misdn_reload()

static char* handle_cli_misdn_reload ( struct ast_cli_entry e,
int  cmd,
struct ast_cli_args a 
)
static

Definition at line 4144 of file chan_misdn.c.

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

4145 {
4146  switch (cmd) {
4147  case CLI_INIT:
4148  e->command = "misdn reload";
4149  e->usage =
4150  "Usage: misdn reload\n"
4151  " Reload internal mISDN config, read from the config\n"
4152  " file.\n";
4153  return NULL;
4154  case CLI_GENERATE:
4155  return NULL;
4156  }
4157 
4158  if (a->argc != 2) {
4159  return CLI_SHOWUSAGE;
4160  }
4161 
4162  ast_cli(a->fd, "Reloading mISDN configuration\n");
4163  reload_config();
4164  return CLI_SUCCESS;
4165 }
const int argc
Definition: cli.h:160
Definition: cli.h:152
#define NULL
Definition: resample.c:96
void ast_cli(int fd, const char *fmt,...)
Definition: clicompat.c:6
const int fd
Definition: cli.h:159
#define CLI_SHOWUSAGE
Definition: cli.h:45
char * command
Definition: cli.h:186
static void reload_config(void)
Definition: chan_misdn.c:4123
const char * usage
Definition: cli.h:177
#define CLI_SUCCESS
Definition: cli.h:44

◆ handle_cli_misdn_restart_pid()

static char* handle_cli_misdn_restart_pid ( struct ast_cli_entry e,
int  cmd,
struct ast_cli_args a 
)
static

Definition at line 3896 of file chan_misdn.c.

References ast_cli_args::argc, ast_cli_args::argv, CLI_GENERATE, CLI_INIT, CLI_SHOWUSAGE, CLI_SUCCESS, ast_cli_entry::command, misdn_lib_pid_restart(), NULL, and ast_cli_entry::usage.

3897 {
3898  switch (cmd) {
3899  case CLI_INIT:
3900  e->command = "misdn restart pid";
3901  e->usage =
3902  "Usage: misdn restart pid <pid>\n"
3903  " Restart the given pid\n";
3904  return NULL;
3905  case CLI_GENERATE:
3906  return NULL;
3907  }
3908 
3909  if (a->argc != 4) {
3910  return CLI_SHOWUSAGE;
3911  }
3912 
3913  misdn_lib_pid_restart(atoi(a->argv[3]));
3914 
3915  return CLI_SUCCESS;
3916 }
int misdn_lib_pid_restart(int pid)
Definition: isdn_lib.c:3932
const int argc
Definition: cli.h:160
Definition: cli.h:152
#define NULL
Definition: resample.c:96
const char *const * argv
Definition: cli.h:161
#define CLI_SHOWUSAGE
Definition: cli.h:45
char * command
Definition: cli.h:186
const char * usage
Definition: cli.h:177
#define CLI_SUCCESS
Definition: cli.h:44

◆ handle_cli_misdn_restart_port()

static char* handle_cli_misdn_restart_port ( struct ast_cli_entry e,
int  cmd,
struct ast_cli_args a 
)
static

Definition at line 3874 of file chan_misdn.c.

References ast_cli_args::argc, ast_cli_args::argv, CLI_GENERATE, CLI_INIT, CLI_SHOWUSAGE, CLI_SUCCESS, ast_cli_entry::command, misdn_lib_port_restart(), NULL, and ast_cli_entry::usage.

3875 {
3876  switch (cmd) {
3877  case CLI_INIT:
3878  e->command = "misdn restart port";
3879  e->usage =
3880  "Usage: misdn restart port <port>\n"
3881  " Restart the given port.\n";
3882  return NULL;
3883  case CLI_GENERATE:
3884  return NULL;
3885  }
3886 
3887  if (a->argc != 4) {
3888  return CLI_SHOWUSAGE;
3889  }
3890 
3891  misdn_lib_port_restart(atoi(a->argv[3]));
3892 
3893  return CLI_SUCCESS;
3894 }
const int argc
Definition: cli.h:160
Definition: cli.h:152
#define NULL
Definition: resample.c:96
const char *const * argv
Definition: cli.h:161
#define CLI_SHOWUSAGE
Definition: cli.h:45
char * command
Definition: cli.h:186
const char * usage
Definition: cli.h:177
#define CLI_SUCCESS
Definition: cli.h:44
int misdn_lib_port_restart(int port)
Definition: isdn_lib.c:3982

◆ handle_cli_misdn_send_digit()

static char* handle_cli_misdn_send_digit ( struct ast_cli_entry e,
int  cmd,
struct ast_cli_args a 
)
static

Definition at line 5509 of file chan_misdn.c.

References ast_cli_args::argc, ast_cli_args::argv, chan_list::ast, ast_cli(), ast_dtmf_stream(), chan_list_unref, CLI_GENERATE, CLI_INIT, CLI_SHOWUSAGE, CLI_SUCCESS, ast_cli_entry::command, complete_ch(), ast_cli_args::fd, get_chan_by_ast_name(), NULL, send_digit_to_chan(), tmp(), and ast_cli_entry::usage.

5510 {
5511  const char *channame;
5512  const char *msg;
5513  struct chan_list *tmp;
5514  int i, msglen;
5515 
5516  switch (cmd) {
5517  case CLI_INIT:
5518  e->command = "misdn send digit";
5519  e->usage =
5520  "Usage: misdn send digit <channel> \"<msg>\" \n"
5521  " Send <digit> to <channel> as DTMF Tone\n"
5522  " when channel is a mISDN channel\n";
5523  return NULL;
5524  case CLI_GENERATE:
5525  return complete_ch(a);
5526  }
5527 
5528  if (a->argc != 5) {
5529  return CLI_SHOWUSAGE;
5530  }
5531 
5532  channame = a->argv[3];
5533  msg = a->argv[4];
5534  msglen = strlen(msg);
5535 
5536  ast_cli(a->fd, "Sending %s to %s\n", msg, channame);
5537 
5538  tmp = get_chan_by_ast_name(channame);
5539  if (!tmp) {
5540  ast_cli(a->fd, "Sending %s to %s failed Channel does not exist\n", msg, channame);
5541  return CLI_SUCCESS;
5542  }
5543 #if 1
5544  for (i = 0; i < msglen; i++) {
5545  if (!tmp->ast) {
5546  break;
5547  }
5548  ast_cli(a->fd, "Sending: %c\n", msg[i]);
5549  send_digit_to_chan(tmp, msg[i]);
5550  /* res = ast_safe_sleep(tmp->ast, 250); */
5551  usleep(250000);
5552  /* res = ast_waitfor(tmp->ast,100); */
5553  }
5554 #else
5555  if (tmp->ast) {
5556  ast_dtmf_stream(tmp->ast, NULL, msg, 250);
5557  }
5558 #endif
5559  chan_list_unref(tmp, "Digit(s) sent");
5560 
5561  return CLI_SUCCESS;
5562 }
int ast_dtmf_stream(struct ast_channel *chan, struct ast_channel *peer, const char *digits, int between, unsigned int duration)
Send a string of DTMF digits to a channel.
Definition: main/app.c:981
const int argc
Definition: cli.h:160
static int tmp()
Definition: bt_open.c:389
Definition: cli.h:152
static struct chan_list * get_chan_by_ast_name(const char *name)
Definition: chan_misdn.c:786
#define NULL
Definition: resample.c:96
void ast_cli(int fd, const char *fmt,...)
Definition: clicompat.c:6
struct ast_channel * ast
Associated Asterisk channel structure.
Definition: chan_misdn.c:515
static char * complete_ch(struct ast_cli_args *a)
Definition: chan_misdn.c:5654
const int fd
Definition: cli.h:159
const char *const * argv
Definition: cli.h:161
#define CLI_SHOWUSAGE
Definition: cli.h:45
char * command
Definition: cli.h:186
Channel call record structure.
Definition: chan_misdn.c:377
const char * usage
Definition: cli.h:177
#define CLI_SUCCESS
Definition: cli.h:44
static void send_digit_to_chan(struct chan_list *cl, char digit)
Definition: chan_misdn.c:3681
#define chan_list_unref(obj, debug)
Definition: chan_misdn.c:372

◆ handle_cli_misdn_send_display()

static char* handle_cli_misdn_send_display ( struct ast_cli_entry e,
int  cmd,
struct ast_cli_args a 
)
static

Definition at line 5611 of file chan_misdn.c.

References ast_cli_args::argc, ast_cli_args::argv, ast_cli(), ast_copy_string(), chan_list::bc, chan_list_unref, CLI_GENERATE, CLI_INIT, CLI_SHOWUSAGE, CLI_SUCCESS, ast_cli_entry::command, complete_ch(), misdn_bchannel::display, EVENT_INFORMATION, ast_cli_args::fd, get_chan_by_ast_name(), misdn_lib_send_event(), NULL, tmp(), and ast_cli_entry::usage.

5612 {
5613  const char *channame;
5614  const char *msg;
5615  struct chan_list *tmp;
5616 
5617  switch (cmd) {
5618  case CLI_INIT:
5619  e->command = "misdn send display";
5620  e->usage =
5621  "Usage: misdn send display <channel> \"<msg>\" \n"
5622  " Send <msg> to <channel> as Display Message\n"
5623  " when channel is a mISDN channel\n";
5624  return NULL;
5625  case CLI_GENERATE:
5626  return complete_ch(a);
5627  }
5628 
5629  if (a->argc != 5) {
5630  return CLI_SHOWUSAGE;
5631  }
5632 
5633  channame = a->argv[3];
5634  msg = a->argv[4];
5635 
5636  ast_cli(a->fd, "Sending %s to %s\n", msg, channame);
5637 
5638  tmp = get_chan_by_ast_name(channame);
5639  if (tmp && tmp->bc) {
5640  ast_copy_string(tmp->bc->display, msg, sizeof(tmp->bc->display));
5642  chan_list_unref(tmp, "Done sending display");
5643  } else {
5644  if (tmp) {
5645  chan_list_unref(tmp, "Display failed");
5646  }
5647  ast_cli(a->fd, "No such channel %s\n", channame);
5648  return CLI_SUCCESS;
5649  }
5650 
5651  return CLI_SUCCESS;
5652 }
const int argc
Definition: cli.h:160
static int tmp()
Definition: bt_open.c:389
Definition: cli.h:152
static struct chan_list * get_chan_by_ast_name(const char *name)
Definition: chan_misdn.c:786
#define NULL
Definition: resample.c:96
void ast_cli(int fd, const char *fmt,...)
Definition: clicompat.c:6