Wed Oct 28 13:31:34 2009

Asterisk developer's documentation


app_rpt.c File Reference

Radio Repeater / Remote Base program version 0.115 5/12/08 2055 EDT. More...

#include "asterisk.h"
#include <signal.h>
#include <stdio.h>
#include <stdint.h>
#include <unistd.h>
#include <string.h>
#include <stdlib.h>
#include <search.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <errno.h>
#include <dirent.h>
#include <ctype.h>
#include <sys/time.h>
#include <sys/file.h>
#include <sys/ioctl.h>
#include <sys/vfs.h>
#include <math.h>
#include <dahdi/user.h>
#include <dahdi/tonezone.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include "asterisk/utils.h"
#include "asterisk/lock.h"
#include "asterisk/file.h"
#include "asterisk/logger.h"
#include "asterisk/channel.h"
#include "asterisk/callerid.h"
#include "asterisk/pbx.h"
#include "asterisk/module.h"
#include "asterisk/translate.h"
#include "asterisk/features.h"
#include "asterisk/options.h"
#include "asterisk/cli.h"
#include "asterisk/config.h"
#include "asterisk/say.h"
#include "asterisk/localtime.h"
#include "asterisk/cdr.h"
#include "asterisk/manager.h"
#include "asterisk/app.h"
#include <termios.h>

Include dependency graph for app_rpt.c:

Go to the source code of this file.

Data Structures

struct  function_table_tag
struct  morse_bits
struct  nodelog
struct  rpt
struct  rpt_chan_stat
struct  rpt_cmd_struct
struct  rpt_link
struct  rpt_lstat
struct  rpt_tele
struct  rpt_topkey
struct  rpt_xlat
struct  sysstate
struct  telem_defaults
struct  vox

Defines

#define ACTIONSIZE   32
#define ALLOW_LOCAL_CHANNELS
#define AUTHLOGOUTTIME   25000
#define AUTHTELLTIME   7000
#define AUTHTXTIME   1000
#define CMD_DEPTH   1
#define CMD_STATE_BUSY   1
#define CMD_STATE_EXECUTING   3
#define CMD_STATE_IDLE   0
#define CMD_STATE_READY   2
#define DEFAULT_CIV_ADDR   0x58
#define DEFAULT_IOBASE   0x378
#define DEFAULT_MONITOR_MIN_DISK_BLOCKS   10000
#define DEFAULT_REMOTE_INACT_TIMEOUT   (15 * 60)
#define DEFAULT_REMOTE_TIMEOUT   (60 * 60)
#define DEFAULT_REMOTE_TIMEOUT_WARNING   (3 * 60)
#define DEFAULT_REMOTE_TIMEOUT_WARNING_FREQ   30
#define DELIMCHR   ','
#define DISC_TIME   10000
#define DTMF_LOCAL_STARTTIME   500
#define DTMF_LOCAL_TIME   250
#define DTMF_TIMEOUT   3
#define ENDCHAR   '#'
#define EXTNODEFILE   "/var/lib/asterisk/rpt_extnodes"
#define EXTNODES   "extnodes"
#define FUNCCHAR   '*'
#define FUNCTDELAY   1500
#define FUNCTIONS   "functions"
#define HANGTIME   5000
#define IC706_PL_MEMORY_OFFSET   50
#define IDTIME   300000
#define IS_XPMR(x)   (!strncasecmp(x->rxchanname,"rad",3))
#define ISRIG_RTX(x)   ((!strcmp(x,remote_rig_rtx150)) || (!strcmp(x,remote_rig_rtx450)))
#define KENWOOD_RETRIES   5
#define KEYPOSTSHORTTIME   200
#define KEYPOSTTIME   30000
#define LINKLISTSHORTTIME   200
#define LINKLISTTIME   10000
#define LINKPOSTSHORTTIME   200
#define LINKPOSTTIME   30000
#define MACRO   "macro"
#define MACROPTIME   500
#define MACROTIME   100
#define MAX_RETRIES   5
#define MAX_RETRIES_PERM   1000000000
#define MAX_STAT_LINKS   32
#define MAX_SYSSTATES   10
#define MAXCONNECTTIME   5000
#define MAXDTMF   32
#define MAXIDENTLEN   32
#define MAXLINKLIST   512
#define MAXMACRO   2048
#define MAXNODELEN   16
#define MAXNODESTR   300
#define MAXPATCHCONTEXT   100
#define MAXPEERSTR   31
#define MAXREMSTR   15
#define MAXRPTS   20
#define MAXXLAT   20
#define MAXXLATTIME   3
#define MEMORY   "memory"
#define MONITOR_DISK_BLOCKS_PER_MINUTE   38
#define MORSE   "morse"
#define MSWAIT   200
#define mymax(x, y)   ((x > y) ? x : y)
#define mymin(x, y)   ((x < y) ? x : y)
#define NEW_ASTERISK
#define NODENAMES   "rpt/nodenames"
#define NODES   "nodes"
#define NRPTSTAT   7
#define PARROTFILE   "/tmp/parrot_%s_%u"
#define PARROTTIME   1000
#define PATCH_DIALPLAN_TIMEOUT   1500
#define POLITEID   30000
#define QUOTECHR   34
#define REDUNDANT_TX_TIME   2000
#define REM_SCANTIME   100
#define RETRY_TIMER_MS   5000
#define RPT_LOCKOUT_SECS   10
#define rpt_mutex_lock(x)   ast_mutex_lock(x)
#define rpt_mutex_unlock(x)   ast_mutex_unlock(x)
#define SIMPLEX_PATCH_DELAY   25
#define SIMPLEX_PHONE_DELAY   25
#define START_DELAY   2
#define STATPOST_PROGRAM   "/usr/bin/wget,-q,--output-document=/dev/null,--no-check-certificate"
#define TELEMETRY   "telemetry"
#define TELEPARAMSIZE   256
#define TONEMACRO   "tonemacro"
#define TOPKEYMAXSTR   30
#define TOPKEYN   32
#define TOPKEYWAIT   3
#define TOTIME   180000
#define VOX_MAX_THRESHOLD   10000.0
#define VOX_MIN_THRESHOLD   3000.0
#define VOX_OFF_DEBOUNCE_COUNT   20
#define VOX_ON_DEBOUNCE_COUNT   3
#define VOX_RECOVER_MS   500
#define VOX_TIMEOUT_MS   5000

Enumerations

enum  { REM_OFF, REM_MONITOR, REM_TX }
enum  {
  ID, PROC, TERM, COMPLETE,
  UNKEY, REMDISC, REMALREADY, REMNOTFOUND,
  REMGO, CONNECTED, CONNFAIL, STATUS,
  TIMEOUT, ID1, STATS_TIME, PLAYBACK,
  STATS_VERSION, IDTALKOVER, ARB_ALPHA, TEST_TONE,
  REV_PATCH, TAILMSG, MACRO_NOTFOUND, MACRO_BUSY,
  LASTNODEKEY, FULLSTATUS, MEMNOTFOUND, INVFREQ,
  REMMODE, REMLOGIN, REMXXX, REMSHORTSTATUS,
  REMLONGSTATUS, LOGINREQ, SCAN, SCANSTAT,
  TUNE, SETREMOTE, TOPKEY, TIMEOUT_WARNING,
  ACT_TIMEOUT_WARNING, LINKUNKEY, UNAUTHTX, PARROT,
  STATS_TIME_LOCAL
}
enum  { REM_SIMPLEX, REM_MINUS, REM_PLUS }
enum  { REM_LOWPWR, REM_MEDPWR, REM_HIPWR }
enum  {
  DC_INDETERMINATE, DC_REQ_FLUSH, DC_ERROR, DC_COMPLETE,
  DC_COMPLETEQUIET, DC_DOKEY
}
enum  {
  SOURCE_RPT, SOURCE_LNK, SOURCE_RMT, SOURCE_PHONE,
  SOURCE_DPHONE, SOURCE_ALT
}
enum  {
  DLY_TELEM, DLY_ID, DLY_UNKEY, DLY_CALLTERM,
  DLY_COMP, DLY_LINKUNKEY, DLY_PARROT
}
enum  { REM_MODE_FM, REM_MODE_USB, REM_MODE_LSB, REM_MODE_AM }
enum  {
  HF_SCAN_OFF, HF_SCAN_DOWN_SLOW, HF_SCAN_DOWN_QUICK, HF_SCAN_DOWN_FAST,
  HF_SCAN_UP_SLOW, HF_SCAN_UP_QUICK, HF_SCAN_UP_FAST
}
enum  { TOP_TOP, TOP_WON, WON_BEFREAD, BEFREAD_AFTERREAD }

Functions

static void __kickshort (struct rpt *myrpt)
static void __mklinklist (struct rpt *myrpt, struct rpt_link *mylink, char *buf)
static void __reg_module (void)
static void __unreg_module (void)
int ast_playtones_start (struct ast_channel *chan, int vol, const char *tonelist, int interruptible)
void ast_playtones_stop (struct ast_channel *chan)
static int attempt_reconnect (struct rpt *myrpt, struct rpt_link *l)
static void birdbath (struct rpt *myrpt)
static int channel_revert (struct rpt *myrpt)
static int channel_steer (struct rpt *myrpt, char *data)
static int check_freq (struct rpt *myrpt, int m, int d, int *defmode)
static int check_freq_ft897 (int m, int d, int *defmode)
static int check_freq_ic706 (int m, int d, int *defmode, char mars)
static int check_freq_kenwood (int m, int d, int *defmode)
static int check_freq_rbi (int m, int d, int *defmode)
static int check_freq_rtx (int m, int d, int *defmode, struct rpt *myrpt)
static int check_freq_tm271 (int m, int d, int *defmode)
static char check_tx_freq (struct rpt *myrpt)
static int civ_cmd (struct rpt *myrpt, unsigned char *cmd, int cmdlen)
static int closerem (struct rpt *myrpt)
static int closerem_ft897 (struct rpt *myrpt)
static int collect_function_digits (struct rpt *myrpt, char *digits, int command_source, struct rpt_link *mylink)
static int connect_link (struct rpt *myrpt, char *node, int mode, int perma)
static int decimals2int (char *fraction)
static long diskavail (struct rpt *myrpt)
static void do_dtmf_local (struct rpt *myrpt, char c)
static void do_dtmf_phone (struct rpt *myrpt, struct rpt_link *mylink, char c)
static void do_scheduler (struct rpt *myrpt)
static void donodelog (struct rpt *myrpt, char *str)
static int dovox (struct vox *v, short *buf, int bs)
static char * eatwhite (char *s)
static int finddelim (char *str, char *strp[], int limit)
static void flush_telem (struct rpt *myrpt)
static char func_xlat (struct rpt *myrpt, char c, struct rpt_xlat *xlat)
static int function_autopatchdn (struct rpt *myrpt, char *param, char *digitbuf, int command_source, struct rpt_link *mylink)
static int function_autopatchup (struct rpt *myrpt, char *param, char *digitbuf, int command_source, struct rpt_link *mylink)
static int function_cop (struct rpt *myrpt, char *param, char *digitbuf, int command_source, struct rpt_link *mylink)
static int function_ilink (struct rpt *myrpt, char *param, char *digitbuf, int command_source, struct rpt_link *mylink)
static int function_macro (struct rpt *myrpt, char *param, char *digitbuf, int command_source, struct rpt_link *mylink)
static int function_playback (struct rpt *myrpt, char *param, char *digitbuf, int command_source, struct rpt_link *mylink)
static int function_remote (struct rpt *myrpt, char *param, char *digitbuf, int command_source, struct rpt_link *mylink)
static int function_status (struct rpt *myrpt, char *param, char *digitbuf, int command_source, struct rpt_link *mylink)
static int get_mem_set (struct rpt *myrpt, char *digitbuf)
static int get_wait_interval (struct rpt *myrpt, int type)
static char * handle_cli_cmd (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
static char * handle_cli_debug (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
static char * handle_cli_dump (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
static char * handle_cli_fun (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
static char * handle_cli_fun1 (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
static char * handle_cli_local_nodes (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
static char * handle_cli_lstats (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
static char * handle_cli_nodes (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
static char * handle_cli_reload (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
static char * handle_cli_restart (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
static char * handle_cli_stats (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
static void handle_link_data (struct rpt *myrpt, struct rpt_link *mylink, char *str)
static void handle_link_phone_dtmf (struct rpt *myrpt, struct rpt_link *mylink, char c)
static int handle_remote_data (struct rpt *myrpt, char *str)
static int handle_remote_dtmf_digit (struct rpt *myrpt, char c, char *keyed, int phonemode)
static int handle_remote_phone_dtmf (struct rpt *myrpt, char c, char *keyed, int phonemode)
static int ic706_pltocode (char *str)
static int kenwood_pltocode (char *str)
static int linkcount (struct rpt *myrpt)
static int load_module (void)
static void load_rpt_vars (int n, int init)
static void local_dtmf_helper (struct rpt *myrpt, char c_in)
static int manager_rpt_local_nodes (struct mansession *s, const struct message *m)
static int manager_rpt_status (struct mansession *s, const struct message *m)
static int matchkeyword (char *string, char **param, char *keywords[])
static void mdc1200_notify (struct rpt *myrpt, char *fromnode, unsigned int unit)
static int mem2vfo_ic706 (struct rpt *myrpt)
static int multimode_bump_freq (struct rpt *myrpt, int interval)
static int multimode_bump_freq_ft897 (struct rpt *myrpt, int interval)
static int multimode_bump_freq_ic706 (struct rpt *myrpt, int interval)
static int multimode_capable (struct rpt *myrpt)
static int myatoi (const char *str)
static int mycompar (const void *a, const void *b)
static char * node_lookup (struct rpt *myrpt, char *digitbuf)
static int openserial (struct rpt *myrpt, char *fname)
static int play_silence (struct ast_channel *chan, int duration)
static int play_tone (struct ast_channel *chan, int freq, int duration, int amplitude)
static int play_tone_pair (struct ast_channel *chan, int f1, int f2, int duration, int amplitude)
static int priority_jump (struct rpt *myrpt, struct ast_channel *chan)
static void queue_id (struct rpt *myrpt)
static int rbi_mhztoband (char *str)
static void rbi_out (struct rpt *myrpt, unsigned char *data)
static void rbi_out_parallel (struct rpt *myrpt, unsigned char *data)
static int rbi_pltocode (char *str)
static int reload (void)
static char * res2cli (int r)
static int retreive_memory (struct rpt *myrpt, char *memory)
static int retrieve_astcfgint (struct rpt *myrpt, char *category, char *name, int min, int max, int defl)
static void * rpt (void *this)
static void * rpt_call (void *this)
static int rpt_do_cmd (int fd, int argc, const char *const *argv)
static int rpt_do_debug (int fd, int argc, const char *const *argv)
static int rpt_do_dump (int fd, int argc, const char *const *argv)
static int rpt_do_fun (int fd, int argc, const char *const *argv)
static int rpt_do_fun1 (int fd, int argc, const char *const *argv)
static int rpt_do_local_nodes (int fd, int argc, const char *const *argv)
static int rpt_do_lstats (int fd, int argc, const char *const *argv)
static int rpt_do_nodes (int fd, int argc, const char *const *argv)
static int rpt_do_reload (int fd, int argc, const char *const *argv)
static int rpt_do_restart (int fd, int argc, const char *const *argv)
static int rpt_do_stats (int fd, int argc, const char *const *argv)
static int rpt_exec (struct ast_channel *chan, const char *data)
static void rpt_localtime (time_t *t, struct ast_tm *lt)
static int rpt_manager_do_stats (struct mansession *s, const struct message *m, char *str)
static void rpt_manager_success (struct mansession *s, const struct message *m)
static void * rpt_master (void *ignore)
static int rpt_push_alt_macro (struct rpt *myrpt, char *sptr)
static void * rpt_tele_thread (void *this)
static void rpt_telemetry (struct rpt *myrpt, int mode, void *data)
static int saycharstr (struct ast_channel *mychannel, char *str)
static int sayfile (struct ast_channel *mychannel, char *fname)
static int saynode (struct rpt *myrpt, struct ast_channel *mychannel, char *name)
static int saynum (struct ast_channel *mychannel, int num)
static int select_mem_ic706 (struct rpt *myrpt, int slot)
static void send_link_dtmf (struct rpt *myrpt, char c)
static void send_link_keyquery (struct rpt *myrpt)
static int send_morse (struct ast_channel *chan, char *string, int speed, int freq, int amplitude)
static void send_newkey (struct ast_channel *chan)
static int send_tone_telemetry (struct ast_channel *chan, char *tonestring)
static int send_usb_txt (struct rpt *myrpt, char *txt)
static int sendkenwood (struct rpt *myrpt, char *txstr, char *rxstr)
static int sendrxkenwood (struct rpt *myrpt, char *txstr, char *rxstr, char *cmpstr)
static int serial_remote_io (struct rpt *myrpt, unsigned char *txbuf, int txbytes, unsigned char *rxbuf, int rxmaxbytes, int asciiflag)
static int service_scan (struct rpt *myrpt)
static int set_ctcss_freq_ft897 (struct rpt *myrpt, char *txtone, char *rxtone)
static int set_ctcss_mode_ft897 (struct rpt *myrpt, char txplon, char rxplon)
static int set_ctcss_mode_ic706 (struct rpt *myrpt, char txplon, char rxplon)
static int set_freq_ft897 (struct rpt *myrpt, char *newfreq)
static int set_freq_ic706 (struct rpt *myrpt, char *newfreq)
static int set_ft897 (struct rpt *myrpt)
static int set_ic706 (struct rpt *myrpt)
static int set_mode_ft897 (struct rpt *myrpt, char newmode)
static int set_mode_ic706 (struct rpt *myrpt, char newmode)
static int set_offset_ft897 (struct rpt *myrpt, char offset)
static int set_offset_ic706 (struct rpt *myrpt, char offset)
static int set_tm271 (struct rpt *myrpt)
static int setdtr (int fd, int enable)
static int setkenwood (struct rpt *myrpt)
static int setrbi (struct rpt *myrpt)
static int setrbi_check (struct rpt *myrpt)
static int setrem (struct rpt *myrpt)
static int setrtx (struct rpt *myrpt)
static int setrtx_check (struct rpt *myrpt)
static int simple_command_ft897 (struct rpt *myrpt, char command)
static int simple_command_ic706 (struct rpt *myrpt, char command, char subcommand)
static char * skipchars (char *string, char *charlist)
static int split_ctcss_freq (char *hertz, char *decimal, char *freq)
static int split_freq (char *mhz, char *decimals, char *freq)
static void statpost (struct rpt *myrpt, char *pairs)
static void stop_scan (struct rpt *myrpt)
static int telem_any (struct rpt *myrpt, struct ast_channel *chan, char *entry)
static int telem_lookup (struct rpt *myrpt, struct ast_channel *chan, char *node, char *name)
static int topcompar (const void *a, const void *b)
static int unload_module (void)
static int vfo_ic706 (struct rpt *myrpt)
static void voxinit_link (struct rpt_link *mylink, char enable)
static void voxinit_rpt (struct rpt *myrpt, char enable)
static void wait_interval (struct rpt *myrpt, int type, struct ast_channel *chan)

Variables

static struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_DEFAULT , .description = "Radio Repeater/Remote Base Application" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = AST_BUILDOPT_SUM, .load = load_module, .unload = unload_module, .reload = reload, }
static char * app = "Rpt"
static struct ast_module_infoast_module_info = &__mod_info
static char cmd_usage []
struct ast_flags config_flags = { CONFIG_FLAG_WITHCOMMENTS }
static int debug = 0
static char debug_usage []
static char * descrip
char * discstr = "!!DISCONNECT!!"
static char dump_lstats []
static char dump_nodes []
static char dump_stats []
static char dump_usage []
static char fun_usage []
static struct function_table_tag function_table []
int max_chan_stat [] = {22000,1000,22000,100,22000,2000,22000}
char * newkeystr = "!NEWKEY!"
static ast_mutex_t nodeloglock = ((ast_mutex_t) PTHREAD_MUTEX_INITIALIZER )
static ast_mutex_t nodelookuplock = ((ast_mutex_t) PTHREAD_MUTEX_INITIALIZER )
static int nrpts = 0
static char reload_usage []
static const char remdtmfstr [] = "0123456789*#ABCD"
static char * remote_rig_ft897 = "ft897"
static char * remote_rig_ic706 = "ic706"
static char * remote_rig_kenwood = "kenwood"
static char * remote_rig_ppp16 = "ppp16"
static char * remote_rig_rbi = "rbi"
static char * remote_rig_rtx150 = "rtx150"
static char * remote_rig_rtx450 = "rtx450"
static char * remote_rig_tm271 = "tm271"
static char restart_usage []
static struct ast_cli_entry rpt_cli []
static pthread_t rpt_master_thread
static struct rpt rpt_vars [MAXRPTS]
static time_t starttime = 0
static char * synopsis = "Radio Repeater/Remote Base Control System"
static char * tdesc = "Radio Repeater / Remote Base version 0.115 5/12/2008"
static struct telem_defaults tele_defs []
static char usage_local_nodes []


Detailed Description

Radio Repeater / Remote Base program version 0.115 5/12/08 2055 EDT.

Author:
Jim Dixon, WB6NIL <jim@lambdatel.com>
Note:
Serious contributions by Steve RoDgers, WA6ZFT <hwstar@rodgers.sdcoxmail.com>

Steven Henke, W9SH, <w9sh@arrl.net> added a few features here and there.

See http://www.zapatatelephony.org/app_rpt.html

Repeater / Remote Functions: "Simple" Mode: * - autopatch access, # - autopatch hangup Normal mode: See the function list in rpt.conf (autopatchup, autopatchdn) autopatchup can optionally take comma delimited setting=value pairs:

context=string : Override default context with "string" dialtime=ms : Specify the max number of milliseconds between phone number digits (1000 milliseconds = 1 second) farenddisconnect=1 : Automatically disconnect when called party hangs up noct=1 : Don't send repeater courtesy tone during autopatch calls quiet=1 : Don't send dial tone, or connect messages. Do not send patch down message when called party hangs up

Example: 123=autopatchup,dialtime=20000,noct=1,farenddisconnect=1

To send an asterisk (*) while dialing or talking on phone, use the autopatch acess code.

status cmds:

1 - Force ID (global) 2 - Give Time of Day (global) 3 - Give software Version (global) 11 - Force ID (local only) 12 - Give Time of Day (local only)

cop (control operator) cmds:

1 - System warm boot 2 - System enable 3 - System disable 4 - Test Tone On/Off 5 - Dump System Variables on Console (debug) 6 - PTT (phone mode only) 7 - Time out timer enable 8 - Time out timer disable 9 - Autopatch enable 10 - Autopatch disable 11 - Link enable 12 - Link disable 13 - Query System State 14 - Change System State 15 - Scheduler Enable 16 - Scheduler Disable 17 - User functions (time, id, etc) enable 18 - User functions (time, id, etc) disable 19 - Select alternate hang timer 20 - Select standard hang timer 21 - Enable Parrot Mode 22 - Disable Parrot Mode 23 - Birdbath (Current Parrot Cleanup/Flush) 24 - Flush all telemetry 25 - Query last node un-keyed 26 - Query all nodes keyed/unkeyed 30 - Recall Memory Setting in Attached Xcvr 31 - Channel Selector for Parallel Programmed Xcvr 32 - Touchtone pad test: command + Digit string + # to playback all digits pressed

ilink cmds:

1 - Disconnect specified link 2 - Connect specified link -- monitor only 3 - Connect specified link -- tranceive 4 - Enter command mode on specified link 5 - System status 6 - Disconnect all links 11 - Disconnect a previously permanently connected link 12 - Permanently connect specified link -- monitor only 13 - Permanently connect specified link -- tranceive 15 - Full system status (all nodes) 16 - Reconnect links disconnected with "disconnect all links" 200 thru 215 - (Send DTMF 0-9,*,#,A-D) (200=0, 201=1, 210=*, etc)

remote cmds:

1 - Recall Memory MM (*000-*099) (Gets memory from rpt.conf) 2 - Set VFO MMMMM*KKK*O (Mhz digits, Khz digits, Offset) 3 - Set Rx PL Tone HHH*D* 4 - Set Tx PL Tone HHH*D* (Not currently implemented with DHE RBI-1) 5 - Link Status (long) 6 - Set operating mode M (FM, USB, LSB, AM, etc) 100 - RX PL off (Default) 101 - RX PL On 102 - TX PL Off (Default) 103 - TX PL On 104 - Low Power 105 - Med Power 106 - Hi Power 107 - Bump Down 20 Hz 108 - Bump Down 100 Hz 109 - Bump Down 500 Hz 110 - Bump Up 20 Hz 111 - Bump Up 100 Hz 112 - Bump Up 500 Hz 113 - Scan Down Slow 114 - Scan Down Medium 115 - Scan Down Fast 116 - Scan Up Slow 117 - Scan Up Medium 118 - Scan Up Fast 119 - Transmit allowing auto-tune 140 - Link Status (brief) 200 thru 215 - (Send DTMF 0-9,*,#,A-D) (200=0, 201=1, 210=*, etc)

playback cmds: specify the name of the file to be played (for example, 25=rpt/foo)

'duplex' modes: (defaults to duplex=2)

0 - Only remote links key Tx and no main repeat audio. 1 - Everything other then main Rx keys Tx, no main repeat audio. 2 - Normal mode 3 - Normal except no main repeat audio. 4 - Normal except no main repeat audio during autopatch only

Definition in file app_rpt.c.


Define Documentation

#define ACTIONSIZE   32

Definition at line 264 of file app_rpt.c.

#define ALLOW_LOCAL_CHANNELS

Definition at line 286 of file app_rpt.c.

#define AUTHLOGOUTTIME   25000

Definition at line 196 of file app_rpt.c.

Referenced by rpt_exec().

#define AUTHTELLTIME   7000

Definition at line 194 of file app_rpt.c.

Referenced by rpt_exec().

#define AUTHTXTIME   1000

Definition at line 195 of file app_rpt.c.

Referenced by rpt_exec().

#define CMD_DEPTH   1

Definition at line 642 of file app_rpt.c.

#define CMD_STATE_BUSY   1

Definition at line 644 of file app_rpt.c.

Referenced by rpt_do_cmd().

#define CMD_STATE_EXECUTING   3

Definition at line 646 of file app_rpt.c.

Referenced by rpt().

#define CMD_STATE_IDLE   0

Definition at line 643 of file app_rpt.c.

Referenced by rpt(), and rpt_do_cmd().

#define CMD_STATE_READY   2

Definition at line 645 of file app_rpt.c.

Referenced by rpt(), and rpt_do_cmd().

#define DEFAULT_CIV_ADDR   0x58

Definition at line 252 of file app_rpt.c.

Referenced by load_rpt_vars().

#define DEFAULT_IOBASE   0x378

Definition at line 250 of file app_rpt.c.

Referenced by load_rpt_vars().

#define DEFAULT_MONITOR_MIN_DISK_BLOCKS   10000

Definition at line 228 of file app_rpt.c.

Referenced by load_rpt_vars().

#define DEFAULT_REMOTE_INACT_TIMEOUT   (15 * 60)

Definition at line 229 of file app_rpt.c.

Referenced by load_rpt_vars().

#define DEFAULT_REMOTE_TIMEOUT   (60 * 60)

Definition at line 230 of file app_rpt.c.

Referenced by load_rpt_vars().

#define DEFAULT_REMOTE_TIMEOUT_WARNING   (3 * 60)

Definition at line 231 of file app_rpt.c.

Referenced by load_rpt_vars().

#define DEFAULT_REMOTE_TIMEOUT_WARNING_FREQ   30

Definition at line 232 of file app_rpt.c.

Referenced by load_rpt_vars().

#define DELIMCHR   ','

Definition at line 223 of file app_rpt.c.

Referenced by finddelim().

#define DISC_TIME   10000

Definition at line 202 of file app_rpt.c.

Referenced by rpt().

#define DTMF_LOCAL_STARTTIME   500

Definition at line 271 of file app_rpt.c.

Referenced by do_dtmf_local().

#define DTMF_LOCAL_TIME   250

Definition at line 270 of file app_rpt.c.

Referenced by do_dtmf_local().

#define DTMF_TIMEOUT   3

Definition at line 188 of file app_rpt.c.

Referenced by handle_remote_dtmf_digit(), and rpt().

#define ENDCHAR   '#'

Definition at line 243 of file app_rpt.c.

Referenced by load_rpt_vars().

#define EXTNODEFILE   "/var/lib/asterisk/rpt_extnodes"

Definition at line 244 of file app_rpt.c.

Referenced by load_rpt_vars().

#define EXTNODES   "extnodes"

Definition at line 235 of file app_rpt.c.

Referenced by load_rpt_vars().

#define FUNCCHAR   '*'

Definition at line 242 of file app_rpt.c.

Referenced by load_rpt_vars().

#define FUNCTDELAY   1500

Definition at line 485 of file app_rpt.c.

#define FUNCTIONS   "functions"

Definition at line 238 of file app_rpt.c.

Referenced by load_rpt_vars().

#define HANGTIME   5000

Definition at line 479 of file app_rpt.c.

Referenced by load_rpt_vars().

#define IC706_PL_MEMORY_OFFSET   50

Definition at line 273 of file app_rpt.c.

Referenced by set_ic706().

#define IDTIME   300000

Definition at line 481 of file app_rpt.c.

Referenced by load_rpt_vars().

#define IS_XPMR (  )     (!strncasecmp(x->rxchanname,"rad",3))

Definition at line 471 of file app_rpt.c.

Referenced by setkenwood(), and setrtx().

#define ISRIG_RTX (  )     ((!strcmp(x,remote_rig_rtx150)) || (!strcmp(x,remote_rig_rtx450)))

Definition at line 470 of file app_rpt.c.

Referenced by check_freq(), function_remote(), rpt(), setrem(), and setrtx().

#define KENWOOD_RETRIES   5

Definition at line 189 of file app_rpt.c.

Referenced by sendrxkenwood().

#define KEYPOSTSHORTTIME   200

Definition at line 185 of file app_rpt.c.

Referenced by rpt().

#define KEYPOSTTIME   30000

Definition at line 184 of file app_rpt.c.

Referenced by rpt().

#define LINKLISTSHORTTIME   200

Definition at line 181 of file app_rpt.c.

Referenced by __kickshort().

#define LINKLISTTIME   10000

Definition at line 180 of file app_rpt.c.

Referenced by rpt().

#define LINKPOSTSHORTTIME   200

Definition at line 183 of file app_rpt.c.

Referenced by __kickshort().

#define LINKPOSTTIME   30000

Definition at line 182 of file app_rpt.c.

Referenced by rpt().

#define MACRO   "macro"

Definition at line 237 of file app_rpt.c.

Referenced by load_rpt_vars().

#define MACROPTIME   500

Definition at line 187 of file app_rpt.c.

Referenced by rpt(), and rpt_exec().

#define MACROTIME   100

Definition at line 186 of file app_rpt.c.

Referenced by do_scheduler(), function_macro(), rpt(), rpt_do_fun(), rpt_exec(), and rpt_push_alt_macro().

#define MAX_RETRIES   5

Definition at line 203 of file app_rpt.c.

Referenced by connect_link(), function_ilink(), and rpt_exec().

#define MAX_RETRIES_PERM   1000000000

Definition at line 204 of file app_rpt.c.

Referenced by connect_link().

#define MAX_STAT_LINKS   32

Definition at line 483 of file app_rpt.c.

Referenced by linkcount(), rpt_do_stats(), and rpt_manager_do_stats().

#define MAX_SYSSTATES   10

Definition at line 490 of file app_rpt.c.

Referenced by load_rpt_vars().

#define MAXCONNECTTIME   5000

Definition at line 254 of file app_rpt.c.

Referenced by rpt().

#define MAXDTMF   32

#define MAXIDENTLEN   32

Definition at line 260 of file app_rpt.c.

#define MAXLINKLIST   512

#define MAXMACRO   2048

Definition at line 178 of file app_rpt.c.

Referenced by do_scheduler(), function_macro(), rpt(), rpt_do_fun(), rpt_exec(), and rpt_push_alt_macro().

#define MAXNODELEN   16

Definition at line 258 of file app_rpt.c.

#define MAXNODESTR   300

Definition at line 256 of file app_rpt.c.

Referenced by connect_link(), function_ilink(), and rpt_exec().

#define MAXPATCHCONTEXT   100

Definition at line 262 of file app_rpt.c.

Referenced by function_autopatchup(), and local_dtmf_helper().

#define MAXPEERSTR   31

Definition at line 220 of file app_rpt.c.

Referenced by rpt_do_lstats().

#define MAXREMSTR   15

#define MAXRPTS   20

Definition at line 482 of file app_rpt.c.

#define MAXXLAT   20

Definition at line 487 of file app_rpt.c.

Referenced by load_rpt_vars().

#define MAXXLATTIME   3

Definition at line 488 of file app_rpt.c.

Referenced by func_xlat().

#define MEMORY   "memory"

Definition at line 236 of file app_rpt.c.

Referenced by load_rpt_vars().

#define MONITOR_DISK_BLOCKS_PER_MINUTE   38

Definition at line 226 of file app_rpt.c.

Referenced by rpt_exec().

#define MORSE   "morse"

Definition at line 240 of file app_rpt.c.

Referenced by telem_any().

#define MSWAIT   200

Definition at line 478 of file app_rpt.c.

Referenced by rpt(), rpt_call(), and rpt_exec().

#define mymax ( x,
 )     ((x > y) ? x : y)

Definition at line 502 of file app_rpt.c.

Referenced by dovox().

#define mymin ( x,
 )     ((x < y) ? x : y)

Definition at line 503 of file app_rpt.c.

Referenced by dovox().

#define NEW_ASTERISK

Definition at line 1 of file app_rpt.c.

#define NODENAMES   "rpt/nodenames"

Definition at line 245 of file app_rpt.c.

Referenced by saynode().

#define NODES   "nodes"

Definition at line 234 of file app_rpt.c.

Referenced by load_rpt_vars().

#define NRPTSTAT   7

Definition at line 448 of file app_rpt.c.

Referenced by rpt_do_lstats().

#define PARROTFILE   "/tmp/parrot_%s_%u"

Definition at line 246 of file app_rpt.c.

Referenced by rpt(), and rpt_tele_thread().

#define PARROTTIME   1000

Definition at line 248 of file app_rpt.c.

Referenced by load_rpt_vars().

#define PATCH_DIALPLAN_TIMEOUT   1500

Definition at line 210 of file app_rpt.c.

Referenced by rpt_call().

#define POLITEID   30000

Definition at line 484 of file app_rpt.c.

Referenced by load_rpt_vars().

#define QUOTECHR   34

Definition at line 224 of file app_rpt.c.

Referenced by finddelim().

#define REDUNDANT_TX_TIME   2000

Definition at line 206 of file app_rpt.c.

Referenced by rpt(), and rpt_exec().

#define REM_SCANTIME   100

Definition at line 268 of file app_rpt.c.

Referenced by function_remote(), and rpt_exec().

#define RETRY_TIMER_MS   5000

Definition at line 208 of file app_rpt.c.

Referenced by rpt().

#define RPT_LOCKOUT_SECS   10

Definition at line 218 of file app_rpt.c.

Referenced by rpt(), and rpt_exec().

#define rpt_mutex_lock (  )     ast_mutex_lock(x)

#define rpt_mutex_unlock (  )     ast_mutex_unlock(x)

#define SIMPLEX_PATCH_DELAY   25

Definition at line 281 of file app_rpt.c.

Referenced by load_rpt_vars().

#define SIMPLEX_PHONE_DELAY   25

Definition at line 282 of file app_rpt.c.

Referenced by load_rpt_vars().

#define START_DELAY   2

Definition at line 215 of file app_rpt.c.

Referenced by rpt(), and rpt_exec().

#define STATPOST_PROGRAM   "/usr/bin/wget,-q,--output-document=/dev/null,--no-check-certificate"

Definition at line 284 of file app_rpt.c.

Referenced by load_rpt_vars().

#define TELEMETRY   "telemetry"

Definition at line 239 of file app_rpt.c.

Referenced by telem_lookup().

#define TELEPARAMSIZE   256

Definition at line 266 of file app_rpt.c.

Referenced by rpt_telemetry().

#define TONEMACRO   "tonemacro"

Definition at line 241 of file app_rpt.c.

Referenced by load_rpt_vars().

#define TOPKEYMAXSTR   30

Definition at line 192 of file app_rpt.c.

Referenced by handle_link_data().

#define TOPKEYN   32

Definition at line 190 of file app_rpt.c.

Referenced by handle_link_data(), rpt(), and rpt_tele_thread().

#define TOPKEYWAIT   3

Definition at line 191 of file app_rpt.c.

Referenced by rpt().

#define TOTIME   180000

Definition at line 480 of file app_rpt.c.

Referenced by load_rpt_vars().

#define VOX_MAX_THRESHOLD   10000.0

Definition at line 277 of file app_rpt.c.

Referenced by dovox().

#define VOX_MIN_THRESHOLD   3000.0

Definition at line 278 of file app_rpt.c.

Referenced by dovox().

#define VOX_OFF_DEBOUNCE_COUNT   20

Definition at line 276 of file app_rpt.c.

Referenced by voxinit_link(), and voxinit_rpt().

#define VOX_ON_DEBOUNCE_COUNT   3

Definition at line 275 of file app_rpt.c.

Referenced by voxinit_link(), and voxinit_rpt().

#define VOX_RECOVER_MS   500

Definition at line 280 of file app_rpt.c.

Referenced by load_rpt_vars().

#define VOX_TIMEOUT_MS   5000

Definition at line 279 of file app_rpt.c.

Referenced by load_rpt_vars().


Enumeration Type Documentation

anonymous enum

Enumerator:
REM_OFF 
REM_MONITOR 
REM_TX 

Definition at line 288 of file app_rpt.c.

anonymous enum

Enumerator:
ID 
PROC 
TERM 
COMPLETE 
UNKEY 
REMDISC 
REMALREADY 
REMNOTFOUND 
REMGO 
CONNECTED 
CONNFAIL 
STATUS 
TIMEOUT 
ID1 
STATS_TIME 
PLAYBACK 
STATS_VERSION 
IDTALKOVER 
ARB_ALPHA 
TEST_TONE 
REV_PATCH 
TAILMSG 
MACRO_NOTFOUND 
MACRO_BUSY 
LASTNODEKEY 
FULLSTATUS 
MEMNOTFOUND 
INVFREQ 
REMMODE 
REMLOGIN 
REMXXX 
REMSHORTSTATUS 
REMLONGSTATUS 
LOGINREQ 
SCAN 
SCANSTAT 
TUNE 
SETREMOTE 
TOPKEY 
TIMEOUT_WARNING 
ACT_TIMEOUT_WARNING 
LINKUNKEY 
UNAUTHTX 
PARROT 
STATS_TIME_LOCAL 

Definition at line 290 of file app_rpt.c.

anonymous enum

Enumerator:
REM_SIMPLEX 
REM_MINUS 
REM_PLUS 

Definition at line 300 of file app_rpt.c.

anonymous enum

Enumerator:
REM_LOWPWR 
REM_MEDPWR 
REM_HIPWR 

Definition at line 302 of file app_rpt.c.

anonymous enum

Enumerator:
DC_INDETERMINATE 
DC_REQ_FLUSH 
DC_ERROR 
DC_COMPLETE 
DC_COMPLETEQUIET 
DC_DOKEY 

Definition at line 304 of file app_rpt.c.

anonymous enum

Enumerator:
SOURCE_RPT 
SOURCE_LNK 
SOURCE_RMT 
SOURCE_PHONE 
SOURCE_DPHONE 
SOURCE_ALT 

Definition at line 306 of file app_rpt.c.

anonymous enum

Enumerator:
DLY_TELEM 
DLY_ID 
DLY_UNKEY 
DLY_CALLTERM 
DLY_COMP 
DLY_LINKUNKEY 
DLY_PARROT 

Definition at line 308 of file app_rpt.c.

anonymous enum

Enumerator:
REM_MODE_FM 
REM_MODE_USB 
REM_MODE_LSB 
REM_MODE_AM 

Definition at line 310 of file app_rpt.c.

anonymous enum

Enumerator:
HF_SCAN_OFF 
HF_SCAN_DOWN_SLOW 
HF_SCAN_DOWN_QUICK 
HF_SCAN_DOWN_FAST 
HF_SCAN_UP_SLOW 
HF_SCAN_UP_QUICK 
HF_SCAN_UP_FAST 

Definition at line 312 of file app_rpt.c.

anonymous enum

Enumerator:
TOP_TOP 
TOP_WON 
WON_BEFREAD 
BEFREAD_AFTERREAD 

Definition at line 444 of file app_rpt.c.


Function Documentation

static void __kickshort ( struct rpt myrpt  )  [static]

Definition at line 1935 of file app_rpt.c.

References LINKLISTSHORTTIME, rpt_link::linklisttimer, LINKPOSTSHORTTIME, rpt::linkposttimer, rpt::links, rpt_link::name, and rpt_link::next.

Referenced by connect_link(), rpt(), and rpt_exec().

01936 {
01937 struct rpt_link *l;
01938 
01939    for(l = myrpt->links.next; l != &myrpt->links; l = l->next)
01940    {
01941       /* if is not a real link, ignore it */
01942       if (l->name[0] == '0') continue;
01943       l->linklisttimer = LINKLISTSHORTTIME;
01944    }
01945    myrpt->linkposttimer = LINKPOSTSHORTTIME;
01946    return;
01947 }

static void __mklinklist ( struct rpt myrpt,
struct rpt_link mylink,
char *  buf 
) [static]

Definition at line 1885 of file app_rpt.c.

References rpt_link::linklist, rpt::links, MAXLINKLIST, rpt_link::mode, rpt_link::name, rpt_link::next, rpt::remote, and rpt_link::thisconnected.

Referenced by connect_link(), rpt(), rpt_do_nodes(), and rpt_tele_thread().

01886 {
01887 struct rpt_link *l;
01888 char mode;
01889 int   i,spos;
01890 
01891    buf[0] = 0; /* clear output buffer */
01892    if (myrpt->remote) return;
01893    /* go thru all links */
01894    for(l = myrpt->links.next; l != &myrpt->links; l = l->next)
01895    {
01896       /* if is not a real link, ignore it */
01897       if (l->name[0] == '0') continue;
01898       /* dont count our stuff */
01899       if (l == mylink) continue;
01900       if (mylink && (!strcmp(l->name,mylink->name))) continue;
01901       /* figure out mode to report */
01902       mode = 'T'; /* use Tranceive by default */
01903       if (!l->mode) mode = 'R'; /* indicate RX for our mode */
01904       if (!l->thisconnected)  mode = 'C'; /* indicate connecting */
01905       spos = strlen(buf); /* current buf size (b4 we add our stuff) */
01906       if (spos)
01907       {
01908          strcat(buf,",");
01909          spos++;
01910       }
01911       /* add nodes into buffer */
01912       if (l->linklist[0])
01913       {
01914          snprintf(buf + spos,MAXLINKLIST - spos,
01915             "%c%s,%s",mode,l->name,l->linklist);
01916       }
01917       else /* if no nodes, add this node into buffer */
01918       {
01919          snprintf(buf + spos,MAXLINKLIST - spos,
01920             "%c%s",mode,l->name);
01921       }
01922       /* if we are in tranceive mode, let all modes stand */
01923       if (mode == 'T') continue;
01924       /* downgrade everyone on this node if appropriate */
01925       for(i = spos; buf[i]; i++)
01926       {
01927          if (buf[i] == 'T') buf[i] = mode;
01928          if ((buf[i] == 'R') && (mode == 'C')) buf[i] = mode;
01929       }
01930    }
01931    return;
01932 }

static void __reg_module ( void   )  [static]

Definition at line 15219 of file app_rpt.c.

static void __unreg_module ( void   )  [static]

Definition at line 15219 of file app_rpt.c.

int ast_playtones_start ( struct ast_channel chan,
int  vol,
const char *  tonelist,
int  interruptible 
)

Definition at line 301 of file indications.c.

Referenced by ast_app_dtget(), ast_indicate_data(), ast_senddigit_begin(), dialtone_indicate(), do_dtmf_local(), handle_playtones(), in_band_indication(), milliwatt_exec(), pbx_builtin_waitexten(), play_dialtone(), playtone(), read_exec(), readexten_exec(), send_digit_to_chan(), and skinny_transfer().

00302 {
00303    char *s, *data = ast_strdupa(playlst);
00304    struct playtones_def d = { vol, -1, 0, 1, NULL };
00305    char *stringp;
00306    char *separator;
00307    static const float sample_rate = 8000.0;
00308    static const float max_sample_val = 32768.0;
00309 
00310    if (vol < 1) {
00311       d.vol = 7219; /* Default to -8db */
00312    }
00313 
00314    d.interruptible = interruptible;
00315 
00316    stringp = data;
00317 
00318    /* check if the data is separated with '|' or with ',' by default */
00319    if (strchr(stringp,'|')) {
00320       separator = "|";
00321    } else {
00322       separator = ",";
00323    }
00324 
00325    while ((s = strsep(&stringp, separator)) && !ast_strlen_zero(s)) {
00326       struct ast_tone_zone_part tone_data = {
00327          .time = 0,
00328       };
00329 
00330       s = ast_strip(s);
00331 
00332       if (s[0]=='!') {
00333          s++;
00334       } else if (d.reppos == -1) {
00335          d.reppos = d.nitems;
00336       }
00337 
00338       if (ast_tone_zone_part_parse(s, &tone_data)) {
00339          ast_log(LOG_ERROR, "Failed to parse tone part '%s'\n", s);
00340          continue;
00341       }
00342 
00343       if (tone_data.midinote) {
00344          /* midi notes must be between 0 and 127 */
00345 
00346          if (tone_data.freq1 >= 0 && tone_data.freq1 <= 127) {
00347             tone_data.freq1 = midi_tohz[tone_data.freq1];
00348          } else {
00349             tone_data.freq1 = 0;
00350          }
00351 
00352          if (tone_data.freq2 >= 0 && tone_data.freq2 <= 127) {
00353             tone_data.freq2 = midi_tohz[tone_data.freq2];
00354          } else {
00355             tone_data.freq2 = 0;
00356          }
00357       }
00358 
00359       if (!(d.items = ast_realloc(d.items, (d.nitems + 1) * sizeof(*d.items)))) {
00360          return -1;
00361       }
00362 
00363       d.items[d.nitems].fac1 = 2.0 * cos(2.0 * M_PI * (tone_data.freq1 / sample_rate)) * max_sample_val;
00364       d.items[d.nitems].init_v2_1 = sin(-4.0 * M_PI * (tone_data.freq1 / sample_rate)) * d.vol;
00365       d.items[d.nitems].init_v3_1 = sin(-2.0 * M_PI * (tone_data.freq1 / sample_rate)) * d.vol;
00366 
00367       d.items[d.nitems].fac2 = 2.0 * cos(2.0 * M_PI * (tone_data.freq2 / sample_rate)) * max_sample_val;
00368       d.items[d.nitems].init_v2_2 = sin(-4.0 * M_PI * (tone_data.freq2 / sample_rate)) * d.vol;
00369       d.items[d.nitems].init_v3_2 = sin(-2.0 * M_PI * (tone_data.freq2 / sample_rate)) * d.vol;
00370 
00371       d.items[d.nitems].duration = tone_data.time;
00372       d.items[d.nitems].modulate = tone_data.modulate;
00373 
00374       d.nitems++;
00375    }
00376 
00377    if (!d.nitems) {
00378       ast_log(LOG_ERROR, "No valid tone parts\n");
00379       return -1;
00380    }
00381 
00382    if (ast_activate_generator(chan, &playtones, &d)) {
00383       ast_free(d.items);
00384       return -1;
00385    }
00386 
00387    return 0;
00388 }

void ast_playtones_stop ( struct ast_channel chan  ) 

static int attempt_reconnect ( struct rpt myrpt,
struct rpt_link l 
) [static]

Definition at line 10339 of file app_rpt.c.

References ast_call(), AST_FORMAT_SLINEAR, ast_free, ast_log(), ast_request(), ast_set_read_format(), ast_set_write_format(), ast_strdup, ast_verbose, rpt::links, rpt::lock, LOG_WARNING, rpt::name, rpt_link::name, rpt_link::next, node_lookup(), option_verbose, rpt_mutex_lock, rpt_mutex_unlock, s, send_newkey(), strsep(), and VERBOSE_PREFIX_3.

Referenced by rpt().

10340 {
10341    char *val, *s, *s1, *s2, *tele;
10342    char tmp[300], deststr[300] = "";
10343    char sx[320],*sy;
10344 
10345 
10346    val = node_lookup(myrpt,l->name);
10347    if (!val)
10348    {
10349       fprintf(stderr,"attempt_reconnect: cannot find node %s\n",l->name);
10350       return -1;
10351    }
10352 
10353    rpt_mutex_lock(&myrpt->lock);
10354    /* remove from queue */
10355    remque((struct qelem *) l);
10356    rpt_mutex_unlock(&myrpt->lock);
10357    strncpy(tmp,val,sizeof(tmp) - 1);
10358    s = tmp;
10359    s1 = strsep(&s,",");
10360    if (!strchr(s1,':') && strchr(s1,'/') && strncasecmp(s1, "local/", 6))
10361    {
10362       sy = strchr(s1,'/');    
10363       *sy = 0;
10364       sprintf(sx,"%s:4569/%s",s1,sy + 1);
10365       s1 = sx;
10366    }
10367    s2 = strsep(&s,",");
10368    snprintf(deststr, sizeof(deststr), "IAX2/%s", s1);
10369    tele = strchr(deststr, '/');
10370    if (!tele) {
10371       fprintf(stderr,"attempt_reconnect:Dial number (%s) must be in format tech/number\n",deststr);
10372       return -1;
10373    }
10374    *tele++ = 0;
10375    l->elaptime = 0;
10376    l->connecttime = 0;
10377    l->thisconnected = 0;
10378    l->newkey = 0;
10379    l->chan = ast_request(deststr, AST_FORMAT_SLINEAR, NULL, tele, NULL);
10380    if (l->chan){
10381       ast_set_read_format(l->chan, AST_FORMAT_SLINEAR);
10382       ast_set_write_format(l->chan, AST_FORMAT_SLINEAR);
10383 #ifndef  NEW_ASTERISK
10384       l->chan->whentohangup = 0;
10385 #endif
10386       l->chan->appl = "Apprpt";
10387       l->chan->data = "(Remote Rx)";
10388       if (option_verbose > 2)
10389          ast_verbose(VERBOSE_PREFIX_3 "rpt (attempt_reconnect) initiating call to %s/%s on %s\n",
10390             deststr, tele, l->chan->name);
10391       if(l->chan->cid.cid_num)
10392          ast_free(l->chan->cid.cid_num);
10393       l->chan->cid.cid_num = ast_strdup(myrpt->name);
10394                 ast_call(l->chan,tele,999); 
10395 
10396    }
10397    else 
10398    {
10399       if (option_verbose > 2)
10400          ast_verbose(VERBOSE_PREFIX_3 "Unable to place call to %s/%s on %s\n",
10401             deststr,tele,l->chan->name);
10402       return -1;
10403    }
10404    rpt_mutex_lock(&myrpt->lock);
10405    /* put back in queue */
10406    insque((struct qelem *)l,(struct qelem *)myrpt->links.next);
10407    rpt_mutex_unlock(&myrpt->lock);
10408    ast_log(LOG_WARNING,"Reconnect Attempt to %s in process\n",l->name);
10409    if (!l->phonemode) send_newkey(l->chan);
10410    return 0;
10411 }

static void birdbath ( struct rpt myrpt  )  [static]

Definition at line 1509 of file app_rpt.c.

References ast_log(), ast_softhangup(), AST_SOFTHANGUP_DEV, rpt_tele::chan, rpt::lock, LOG_NOTICE, rpt_tele::mode, rpt_tele::next, PARROT, rpt_mutex_lock, rpt_mutex_unlock, and rpt::tele.

Referenced by function_cop().

01510 {
01511    struct rpt_tele *telem;
01512    if(debug > 2)
01513       ast_log(LOG_NOTICE, "birdbath!!");
01514    rpt_mutex_lock(&myrpt->lock);
01515    telem = myrpt->tele.next;
01516    while(telem != &myrpt->tele)
01517    {
01518       if (telem->mode == PARROT) ast_softhangup(telem->chan,AST_SOFTHANGUP_DEV);
01519       telem = telem->next;
01520    }
01521    rpt_mutex_unlock(&myrpt->lock);
01522 }

static int channel_revert ( struct rpt myrpt  )  [static]

Definition at line 9621 of file app_rpt.c.

References ast_log(), channel_steer(), LOG_NOTICE, rpt::nowchan, rpt::remoterig, and rpt::waschan.

Referenced by function_autopatchdn(), local_dtmf_helper(), rpt(), rpt_call(), and rpt_exec().

09622 {
09623    int res=0;
09624    if(debug)ast_log(LOG_NOTICE,"remoterig=%s, nowchan=%02d, waschan=%02d\n",myrpt->remoterig,myrpt->nowchan,myrpt->waschan);
09625    if (!myrpt->remoterig) return(0);
09626    if(myrpt->nowchan!=myrpt->waschan)
09627    {
09628       char data[8];
09629         if(debug)ast_log(LOG_NOTICE,"reverting.\n");
09630       sprintf(data,"%02d",myrpt->waschan);
09631       myrpt->nowchan=myrpt->waschan;
09632       channel_steer(myrpt,data);
09633       res=1;
09634    }
09635    return(res);
09636 }

static int channel_steer ( struct rpt myrpt,
char *  data 
) [static]

Definition at line 9592 of file app_rpt.c.

References ast_log(), get_mem_set(), LOG_NOTICE, rpt::nowchan, rpt::remoterig, and send_usb_txt().

Referenced by channel_revert(), function_cop(), and rpt_exec().

09593 {
09594    int res=0;
09595 
09596    if(debug)ast_log(LOG_NOTICE,"remoterig=%s, data=%s\n",myrpt->remoterig,data);
09597    if (!myrpt->remoterig) return(0);
09598    if(data<=0)
09599    {
09600       res=-1;
09601    }
09602    else
09603    {
09604       myrpt->nowchan=strtod(data,NULL);
09605       if(!strcmp(myrpt->remoterig, remote_rig_ppp16))
09606       {
09607          char string[16];
09608          sprintf(string,"SETCHAN %d ",myrpt->nowchan);
09609          send_usb_txt(myrpt,string);   
09610       }
09611       else
09612       {
09613          if(get_mem_set(myrpt, data))res=-1;
09614       }
09615    }
09616    if(debug)ast_log(LOG_NOTICE,"nowchan=%i  res=%i\n",myrpt->nowchan, res);
09617    return res;
09618 }

static int check_freq ( struct rpt myrpt,
int  m,
int  d,
int *  defmode 
) [static]

Definition at line 9316 of file app_rpt.c.

References check_freq_ft897(), check_freq_ic706(), check_freq_kenwood(), check_freq_rbi(), check_freq_rtx(), check_freq_tm271(), ISRIG_RTX, rpt::p, rpt::remote_mars, and rpt::remoterig.

Referenced by function_remote().

09317 {
09318    if(!strcmp(myrpt->remoterig, remote_rig_ft897))
09319       return check_freq_ft897(m, d, defmode);
09320    else if(!strcmp(myrpt->remoterig, remote_rig_ic706))
09321       return check_freq_ic706(m, d, defmode,myrpt->p.remote_mars);
09322    else if(!strcmp(myrpt->remoterig, remote_rig_rbi))
09323       return check_freq_rbi(m, d, defmode);
09324    else if(!strcmp(myrpt->remoterig, remote_rig_kenwood))
09325       return check_freq_kenwood(m, d, defmode);
09326    else if(!strcmp(myrpt->remoterig, remote_rig_tm271))
09327       return check_freq_tm271(m, d, defmode);
09328    else if(ISRIG_RTX(myrpt->remoterig))
09329       return check_freq_rtx(m, d, defmode, myrpt);
09330    else
09331       return -1;
09332 }

static int check_freq_ft897 ( int  m,
int  d,
int *  defmode 
) [static]

Definition at line 8277 of file app_rpt.c.

References REM_MODE_FM, REM_MODE_LSB, and REM_MODE_USB.

Referenced by check_freq(), and multimode_bump_freq_ft897().

08278 {
08279    int dflmd = REM_MODE_FM;
08280 
08281    if(m == 1){ /* 160 meters */
08282       dflmd =  REM_MODE_LSB; 
08283       if(d < 80000)
08284          return -1;
08285    }
08286    else if(m == 3){ /* 80 meters */
08287       dflmd = REM_MODE_LSB;
08288       if(d < 50000)
08289          return -1;
08290    }
08291    else if(m == 7){ /* 40 meters */
08292       dflmd = REM_MODE_LSB;
08293       if(d > 30000)
08294          return -1;
08295    }
08296    else if(m == 14){ /* 20 meters */
08297       dflmd = REM_MODE_USB;
08298       if(d > 35000)
08299          return -1;
08300    }
08301    else if(m == 18){ /* 17 meters */
08302       dflmd = REM_MODE_USB;
08303       if((d < 6800) || (d > 16800))
08304          return -1;
08305    }
08306    else if(m == 21){ /* 15 meters */
08307       dflmd = REM_MODE_USB;
08308       if((d < 20000) || (d > 45000))
08309          return -1;
08310    }
08311    else if(m == 24){ /* 12 meters */
08312       dflmd = REM_MODE_USB;
08313       if((d < 89000) || (d > 99000))
08314          return -1;
08315    }
08316    else if(m == 28){ /* 10 meters */
08317       dflmd = REM_MODE_USB;
08318    }
08319    else if(m == 29){ 
08320       if(d >= 51000)
08321          dflmd = REM_MODE_FM;
08322       else
08323          dflmd = REM_MODE_USB;
08324       if(d > 70000)
08325          return -1;
08326    }
08327    else if(m == 50){ /* 6 meters */
08328       if(d >= 30000)
08329          dflmd = REM_MODE_FM;
08330       else
08331          dflmd = REM_MODE_USB;
08332 
08333    }
08334    else if((m >= 51) && ( m < 54)){
08335       dflmd = REM_MODE_FM;
08336    }
08337    else if(m == 144){ /* 2 meters */
08338       if(d >= 30000)
08339          dflmd = REM_MODE_FM;
08340       else
08341          dflmd = REM_MODE_USB;
08342    }
08343    else if((m >= 145) && (m < 148)){
08344       dflmd = REM_MODE_FM;
08345    }
08346    else if((m >= 430) && (m < 450)){ /* 70 centimeters */
08347       if(m  < 438)
08348          dflmd = REM_MODE_USB;
08349       else
08350          dflmd = REM_MODE_FM;
08351       ;
08352    }
08353    else
08354       return -1;
08355 
08356    if(defmode)
08357       *defmode = dflmd;
08358 
08359    return 0;
08360 }

static int check_freq_ic706 ( int  m,
int  d,
int *  defmode,
char  mars 
) [static]

Definition at line 8647 of file app_rpt.c.

References ast_log(), LOG_NOTICE, REM_MODE_AM, REM_MODE_FM, REM_MODE_LSB, and REM_MODE_USB.

Referenced by check_freq(), and multimode_bump_freq_ic706().

08648 {
08649    int dflmd = REM_MODE_FM;
08650    int rv=0;
08651 
08652    if(debug > 6)
08653       ast_log(LOG_NOTICE,"(%i,%i,%i,%i)\n",m,d,*defmode,mars);
08654 
08655    /* first test for standard amateur radio bands */
08656 
08657    if(m == 1){                /* 160 meters */
08658       dflmd =  REM_MODE_LSB; 
08659       if(d < 80000)rv=-1;
08660    }
08661    else if(m == 3){           /* 80 meters */
08662       dflmd = REM_MODE_LSB;
08663       if(d < 50000)rv=-1;
08664    }
08665    else if(m == 7){           /* 40 meters */
08666       dflmd = REM_MODE_LSB;
08667       if(d > 30000)rv=-1;
08668    }
08669    else if(m == 14){             /* 20 meters */
08670       dflmd = REM_MODE_USB;
08671       if(d > 35000)rv=-1;
08672    }
08673    else if(m == 18){                      /* 17 meters */
08674       dflmd = REM_MODE_USB;
08675       if((d < 6800) || (d > 16800))rv=-1;
08676    }
08677    else if(m == 21){ /* 15 meters */
08678       dflmd = REM_MODE_USB;
08679       if((d < 20000) || (d > 45000))rv=-1;
08680    }
08681    else if(m == 24){ /* 12 meters */
08682       dflmd = REM_MODE_USB;
08683       if((d < 89000) || (d > 99000))rv=-1;
08684    }
08685    else if(m == 28){                      /* 10 meters */
08686       dflmd = REM_MODE_USB;
08687    }
08688    else if(m == 29){ 
08689       if(d >= 51000)
08690          dflmd = REM_MODE_FM;
08691       else
08692          dflmd = REM_MODE_USB;
08693       if(d > 70000)rv=-1;
08694    }
08695    else if(m == 50){                      /* 6 meters */
08696       if(d >= 30000)
08697          dflmd = REM_MODE_FM;
08698       else
08699          dflmd = REM_MODE_USB;
08700    }
08701    else if((m >= 51) && ( m < 54)){
08702       dflmd = REM_MODE_FM;
08703    }
08704    else if(m == 144){ /* 2 meters */
08705       if(d >= 30000)
08706          dflmd = REM_MODE_FM;
08707       else
08708          dflmd = REM_MODE_USB;
08709    }
08710    else if((m >= 145) && (m < 148)){
08711       dflmd = REM_MODE_FM;
08712    }
08713    else if((m >= 430) && (m < 450)){         /* 70 centimeters */
08714       if(m  < 438)
08715          dflmd = REM_MODE_USB;
08716       else
08717          dflmd = REM_MODE_FM;
08718    }
08719 
08720    /* check expanded coverage */
08721    if(mars && rv<0){
08722       if((m >= 450) && (m < 470)){        /* LMR */
08723          dflmd = REM_MODE_FM;
08724          rv=0;
08725       }
08726       else if((m >= 148) && (m < 174)){      /* LMR */
08727          dflmd = REM_MODE_FM;
08728          rv=0;
08729       }
08730       else if((m >= 138) && (m < 144)){      /* VHF-AM AIRCRAFT */
08731          dflmd = REM_MODE_AM;
08732          rv=0;
08733       }
08734       else if((m >= 108) && (m < 138)){      /* VHF-AM AIRCRAFT */
08735          dflmd = REM_MODE_AM;
08736          rv=0;
08737       }
08738       else if( (m==0 && d>=55000) || (m==1 && d<=75000) ){  /* AM BCB*/
08739          dflmd = REM_MODE_AM;
08740          rv=0;
08741       }
08742       else if( (m == 1 && d>75000) || (m>1 && m<30) ){      /* HF SWL*/
08743          dflmd = REM_MODE_AM;
08744          rv=0;
08745       }
08746    }
08747 
08748    if(defmode)
08749       *defmode = dflmd;
08750 
08751    if(debug > 1)
08752       ast_log(LOG_NOTICE,"(%i,%i,%i,%i) returning %i\n",m,d,*defmode,mars,rv);
08753 
08754    return rv;
08755 }

static int check_freq_kenwood ( int  m,
int  d,
int *  defmode 
) [static]

Definition at line 8083 of file app_rpt.c.

References REM_MODE_FM.

Referenced by check_freq().

08084 {
08085    int dflmd = REM_MODE_FM;
08086 
08087    if (m == 144){ /* 2 meters */
08088       if(d < 10100)
08089          return -1;
08090    }
08091    else if((m >= 145) && (m < 148)){
08092       ;
08093    }
08094    else if((m >= 430) && (m < 450)){ /* 70 centimeters */
08095       ;
08096    }
08097    else
08098       return -1;
08099    
08100    if(defmode)
08101       *defmode = dflmd; 
08102 
08103 
08104    return 0;
08105 }

static int check_freq_rbi ( int  m,
int  d,
int *  defmode 
) [static]

Definition at line 8132 of file app_rpt.c.

References REM_MODE_FM.

Referenced by check_freq().

08133 {
08134    int dflmd = REM_MODE_FM;
08135 
08136    if(m == 50){ /* 6 meters */
08137       if(d < 10100)
08138          return -1;
08139    }
08140    else if((m >= 51) && ( m < 54)){
08141                 ;
08142    }
08143    else if(m == 144){ /* 2 meters */
08144       if(d < 10100)
08145          return -1;
08146    }
08147    else if((m >= 145) && (m < 148)){
08148       ;
08149    }
08150    else if((m >= 222) && (m < 225)){ /* 1.25 meters */
08151       ;
08152    }
08153    else if((m >= 430) && (m < 450)){ /* 70 centimeters */
08154       ;
08155    }
08156    else if((m >= 1240) && (m < 1300)){ /* 23 centimeters */
08157       ;
08158    }
08159    else
08160       return -1;
08161    
08162    if(defmode)
08163       *defmode = dflmd; 
08164 
08165 
08166    return 0;
08167 }

static int check_freq_rtx ( int  m,
int  d,
int *  defmode,
struct rpt myrpt 
) [static]

Definition at line 8172 of file app_rpt.c.

References REM_MODE_FM, and rpt::remoterig.

Referenced by check_freq().

08173 {
08174    int dflmd = REM_MODE_FM;
08175 
08176    if (!strcmp(myrpt->remoterig,remote_rig_rtx150))
08177    {
08178 
08179       if(m == 144){ /* 2 meters */
08180          if(d < 10100)
08181             return -1;
08182       }
08183       else if((m >= 145) && (m < 148)){
08184          ;
08185       }
08186       else
08187          return -1;
08188    }
08189    else 
08190    {
08191       if((m >= 430) && (m < 450)){ /* 70 centimeters */
08192          ;
08193       }
08194       else
08195          return -1;
08196    }
08197    if(defmode)
08198       *defmode = dflmd; 
08199 
08200 
08201    return 0;
08202 }

static int check_freq_tm271 ( int  m,
int  d,
int *  defmode 
) [static]

Definition at line 8108 of file app_rpt.c.

References REM_MODE_FM.

Referenced by check_freq().

08109 {
08110    int dflmd = REM_MODE_FM;
08111 
08112    if (m == 144){ /* 2 meters */
08113       if(d < 10100)
08114          return -1;
08115    }
08116    else if((m >= 145) && (m < 148)){
08117       ;
08118    }
08119       return -1;
08120    
08121    if(defmode)
08122       *defmode = dflmd; 
08123 
08124 
08125    return 0;
08126 }

static char check_tx_freq ( struct rpt myrpt  )  [static]

Definition at line 9339 of file app_rpt.c.

References ast_log(), ast_variable_browse(), rpt::cfg, decimals2int(), eatwhite(), finddelim(), rpt::freq, LOG_NOTICE, LOG_WARNING, rpt::loginlevel, rpt::loginuser, MAXREMSTR, ast_variable::name, ast_variable::next, rpt::p, s, split_freq(), rpt::txlimitsstanzaname, and ast_variable::value.

Referenced by rpt_exec().

09340 {
09341    int i,rv=0;
09342    int radio_mhz, radio_decimals, ulimit_mhz, ulimit_decimals, llimit_mhz, llimit_decimals;
09343    char radio_mhz_char[MAXREMSTR];
09344    char radio_decimals_char[MAXREMSTR];
09345    char limit_mhz_char[MAXREMSTR];
09346    char limit_decimals_char[MAXREMSTR];
09347    char limits[256];
09348    char *limit_ranges[40];
09349    struct ast_variable *limitlist;
09350    
09351    if(debug > 3){
09352       ast_log(LOG_NOTICE, "myrpt->freq = %s\n", myrpt->freq);
09353    }
09354 
09355    /* Must have user logged in and tx_limits defined */
09356 
09357    if(!myrpt->p.txlimitsstanzaname || !myrpt->loginuser[0] || !myrpt->loginlevel[0]){
09358       if(debug > 3){
09359          ast_log(LOG_NOTICE, "No tx band table defined, or no user logged in. rv=1\n");
09360       }
09361       rv=1;
09362       return 1; /* Assume it's ok otherwise */
09363    }
09364 
09365    /* Retrieve the band table for the loginlevel */
09366    limitlist = ast_variable_browse(myrpt->cfg, myrpt->p.txlimitsstanzaname);
09367 
09368    if(!limitlist){
09369       ast_log(LOG_WARNING, "No entries in %s band table stanza. rv=0\n", myrpt->p.txlimitsstanzaname);
09370       rv=0;
09371       return 0;
09372    }
09373 
09374    split_freq(radio_mhz_char, radio_decimals_char, myrpt->freq);
09375    radio_mhz = atoi(radio_mhz_char);
09376    radio_decimals = decimals2int(radio_decimals_char);
09377 
09378    if(debug > 3){
09379       ast_log(LOG_NOTICE, "Login User = %s, login level = %s\n", myrpt->loginuser, myrpt->loginlevel);
09380    }
09381 
09382    /* Find our entry */
09383 
09384    for(;limitlist; limitlist=limitlist->next){
09385       if(!strcmp(limitlist->name, myrpt->loginlevel))
09386          break;
09387    }
09388 
09389    if(!limitlist){
09390       ast_log(LOG_WARNING, "Can't find %s entry in band table stanza %s. rv=0\n", myrpt->loginlevel, myrpt->p.txlimitsstanzaname);
09391       rv=0;
09392        return 0;
09393    }
09394    
09395    if(debug > 3){
09396       ast_log(LOG_NOTICE, "Auth: %s = %s\n", limitlist->name, limitlist->value);
09397    }
09398 
09399    /* Parse the limits */
09400 
09401    strncpy(limits, limitlist->value, 256);
09402    limits[255] = 0;
09403    finddelim(limits, limit_ranges, 40);
09404    for(i = 0; i < 40 && limit_ranges[i] ; i++){
09405       char range[40];
09406       char *r,*s;
09407       strncpy(range, limit_ranges[i], 40);
09408       range[39] = 0;
09409         if(debug > 3) 
09410          ast_log(LOG_NOTICE, "Check %s within %s\n", myrpt->freq, range);
09411    
09412       r = strchr(range, '-');
09413       if(!r){
09414          ast_log(LOG_WARNING, "Malformed range in %s tx band table entry. rv=0\n", limitlist->name);
09415          rv=0;
09416          break;
09417       }
09418       *r++ = 0;
09419       s = eatwhite(range);
09420       r = eatwhite(r);
09421       split_freq(limit_mhz_char, limit_decimals_char, s);
09422       llimit_mhz = atoi(limit_mhz_char);
09423       llimit_decimals = decimals2int(limit_decimals_char);
09424       split_freq(limit_mhz_char, limit_decimals_char, r);
09425       ulimit_mhz = atoi(limit_mhz_char);
09426       ulimit_decimals = decimals2int(limit_decimals_char);
09427          
09428       if((radio_mhz >= llimit_mhz) && (radio_mhz <= ulimit_mhz)){
09429          if(radio_mhz == llimit_mhz){ /* CASE 1: TX freq is in llimit mhz portion of band */
09430             if(radio_decimals >= llimit_decimals){ /* Cannot be below llimit decimals */
09431                if(llimit_mhz == ulimit_mhz){ /* If bandwidth < 1Mhz, check ulimit decimals */
09432                   if(radio_decimals <= ulimit_decimals){
09433                      rv=1;
09434                      break;
09435                   }
09436                   else{
09437                      if(debug > 3)
09438                         ast_log(LOG_NOTICE, "Invalid TX frequency, debug msg 1\n");
09439                      rv=0;
09440                      break;
09441                   }
09442                }
09443                else{
09444                   rv=1;
09445                   break;
09446                }
09447             }
09448             else{ /* Is below llimit decimals */
09449                if(debug > 3)
09450                   ast_log(LOG_NOTICE, "Invalid TX frequency, debug msg 2\n");
09451                rv=0;
09452                break;
09453             }
09454          }
09455          else if(radio_mhz == ulimit_mhz){ /* CASE 2: TX freq not in llimit mhz portion of band */
09456             if(radio_decimals <= ulimit_decimals){
09457                if(debug > 3)
09458                   ast_log(LOG_NOTICE, "radio_decimals <= ulimit_decimals\n");
09459                rv=1;
09460                break;
09461             }
09462             else{ /* Is above ulimit decimals */
09463                if(debug > 3)
09464                   ast_log(LOG_NOTICE, "Invalid TX frequency, debug msg 3\n");
09465                rv=0;
09466                break;
09467             }
09468          }
09469          else /* CASE 3: TX freq within a multi-Mhz band and ok */
09470             if(debug > 3)
09471                   ast_log(LOG_NOTICE, "Valid TX freq within a multi-Mhz band and ok.\n");
09472             rv=1;
09473             break;
09474       }
09475    }
09476    if(debug > 3)  
09477       ast_log(LOG_NOTICE, "rv=%i\n",rv);
09478 
09479    return rv;
09480 }

static int civ_cmd ( struct rpt myrpt,
unsigned char *  cmd,
int  cmdlen 
) [static]

Definition at line 7508 of file app_rpt.c.

References serial_remote_io().

Referenced by mem2vfo_ic706(), select_mem_ic706(), set_ctcss_mode_ic706(), set_freq_ic706(), simple_command_ic706(), and vfo_ic706().

07509 {
07510 unsigned char rxbuf[100];
07511 int   i,rv ;
07512 
07513    rv = serial_remote_io(myrpt,cmd,cmdlen,rxbuf,cmdlen + 6,0);
07514    if (rv == -1) return(-1);
07515    if (rv != (cmdlen + 6)) return(1);
07516    for(i = 0; i < 6; i++)
07517       if (rxbuf[i] != cmd[i]) return(1);
07518    if (rxbuf[cmdlen] != 0xfe) return(1);
07519    if (rxbuf[cmdlen + 1] != 0xfe) return(1);
07520    if (rxbuf[cmdlen + 4] != 0xfb) return(1);
07521    if (rxbuf[cmdlen + 5] != 0xfd) return(1);
07522    return(0);
07523 }

static int closerem ( struct rpt myrpt  )  [static]

Definition at line 9304 of file app_rpt.c.

References closerem_ft897(), and rpt::remoterig.

Referenced by rpt_exec().

09305 {
09306    if(!strcmp(myrpt->remoterig, remote_rig_ft897))
09307       return closerem_ft897(myrpt);
09308    else
09309       return 0;
09310 }

static int closerem_ft897 ( struct rpt myrpt  )  [static]

Definition at line 8588 of file app_rpt.c.

References simple_command_ft897().

Referenced by closerem().

08589 {
08590    simple_command_ft897(myrpt, 0x88); /* PTT off */
08591    return 0;
08592 }  

static int collect_function_digits ( struct rpt myrpt,
char *  digits,
int  command_source,
struct rpt_link mylink 
) [static]

Definition at line 6593 of file app_rpt.c.

References rpt::alt_functions, rpt::alt_longestfunc, ast_log(), ast_variable_browse(), rpt::cfg, DC_ERROR, DC_INDETERMINATE, rpt::dphone_functions, rpt::dphone_longestfunc, function_table_tag::function, rpt::functions, rpt::link_functions, rpt::link_longestfunc, LOG_NOTICE, rpt::longestfunc, ast_variable::name, ast_variable::next, rpt::p, rpt::phone_functions, rpt::phone_longestfunc, SOURCE_ALT, SOURCE_DPHONE, SOURCE_LNK, SOURCE_PHONE, strsep(), and ast_variable::value.

Referenced by handle_link_data(), handle_link_phone_dtmf(), handle_remote_dtmf_digit(), and local_dtmf_helper().

06595 {
06596    int i,rv;
06597    char *stringp,*action,*param,*functiondigits;
06598    char function_table_name[30] = "";
06599    char workstring[200];
06600    
06601    struct ast_variable *vp;
06602    
06603    if (debug > 6) ast_log(LOG_NOTICE,"digits=%s  source=%d\n",digits, command_source);
06604 
06605    //if(debug) 
06606    // printf("@@@@ Digits collected: %s, source: %d\n", digits, command_source);
06607    
06608    if (command_source == SOURCE_DPHONE) {
06609       if (!myrpt->p.dphone_functions) return DC_INDETERMINATE;
06610       strncpy(function_table_name, myrpt->p.dphone_functions, sizeof(function_table_name) - 1);
06611       }
06612    else if (command_source == SOURCE_ALT) {
06613       if (!myrpt->p.alt_functions) return DC_INDETERMINATE;
06614       strncpy(function_table_name, myrpt->p.alt_functions, sizeof(function_table_name) - 1);
06615       }
06616    else if (command_source == SOURCE_PHONE) {
06617       if (!myrpt->p.phone_functions) return DC_INDETERMINATE;
06618       strncpy(function_table_name, myrpt->p.phone_functions, sizeof(function_table_name) - 1);
06619       }
06620    else if (command_source == SOURCE_LNK)
06621       strncpy(function_table_name, myrpt->p.link_functions, sizeof(function_table_name) - 1);
06622    else
06623       strncpy(function_table_name, myrpt->p.functions, sizeof(function_table_name) - 1);
06624     /* find context for function table in rpt.conf file */
06625    vp = ast_variable_browse(myrpt->cfg, function_table_name);
06626    while(vp) {
06627       if(!strncasecmp(vp->name, digits, strlen(vp->name)))
06628          break;
06629       vp = vp->next;
06630    }  
06631    /* if function context not found */
06632    if(!vp) {
06633       int n;
06634 
06635       n = myrpt->longestfunc;
06636       if (command_source == SOURCE_LNK) n = myrpt->link_longestfunc;
06637       else 
06638       if (command_source == SOURCE_PHONE) n = myrpt->phone_longestfunc;
06639       else 
06640       if (command_source == SOURCE_ALT) n = myrpt->alt_longestfunc;
06641       else 
06642       if (command_source == SOURCE_DPHONE) n = myrpt->dphone_longestfunc;
06643       
06644       if(strlen(digits) >= n)
06645          return DC_ERROR;
06646       else
06647          return DC_INDETERMINATE;
06648    }  
06649    /* Found a match, retrieve value part and parse */
06650    strncpy(workstring, vp->value, sizeof(workstring) - 1 );
06651    stringp = workstring;
06652    action = strsep(&stringp, ",");
06653    param = stringp;
06654    if(debug)
06655       printf("@@@@ action: %s, param = %s\n",action, (param) ? param : "(null)");
06656    /* Look up the action */
06657    for(i = 0 ; i < (sizeof(function_table)/sizeof(struct function_table_tag)); i++){
06658       if(!strncasecmp(action, function_table[i].action, strlen(action)))
06659          break;
06660    }
06661    if(debug)
06662       printf("@@@@ table index i = %d\n",i);
06663    if(i == (sizeof(function_table)/sizeof(struct function_table_tag))){
06664       /* Error, action not in table */
06665       return DC_ERROR;
06666    }
06667    if(function_table[i].function == NULL){
06668       /* Error, function undefined */
06669       if(debug)
06670          printf("@@@@ NULL for action: %s\n",action);
06671       return DC_ERROR;
06672    }
06673    functiondigits = digits + strlen(vp->name);
06674    rv=(*function_table[i].function)(myrpt, param, functiondigits, command_source, mylink);
06675    if (debug > 6) ast_log(LOG_NOTICE,"rv=%i\n",rv);
06676    return(rv);
06677 }

static int connect_link ( struct rpt myrpt,
char *  node,
int  mode,
int  perma 
) [static]

Definition at line 5682 of file app_rpt.c.

References __kickshort(), __mklinklist(), rpt::archivedir, ast_call(), AST_CDR_FLAG_POST_DISABLED, AST_FORMAT_SLINEAR, ast_free, ast_hangup(), ast_log(), ast_malloc, ast_request(), ast_set_flag, ast_set_read_format(), ast_set_write_format(), ast_softhangup(), AST_SOFTHANGUP_DEV, ast_strdup, ast_true(), rpt_link::chan, rpt::conf, rpt_link::disced, donodelog(), finddelim(), rpt::lastlinknode, rpt::links, rpt::lock, LOG_NOTICE, LOG_WARNING, rpt::longestnode, MAX_RETRIES, rpt_link::max_retries, MAX_RETRIES_PERM, MAXLINKLIST, MAXNODESTR, rpt_link::mode, rpt_link::name, rpt::name, rpt_link::next, node_lookup(), rpt::p, rpt_link::reconnects, rpt_link::retries, rpt_mutex_lock, rpt_mutex_unlock, s, send_newkey(), strsep(), and voxinit_link().

Referenced by function_ilink().

05683 {
05684    char *val, *s, *s1, *s2, *tele;
05685    char lstr[MAXLINKLIST],*strs[MAXLINKLIST];
05686    char tmp[300], deststr[300] = "",modechange = 0;
05687    char sx[320],*sy;
05688    struct rpt_link *l;
05689    int reconnects = 0;
05690    int i,n;
05691    struct dahdi_confinfo ci;  /* conference info */
05692 
05693    val = node_lookup(myrpt,node);
05694    if (!val){
05695       if(strlen(node) >= myrpt->longestnode)
05696          return -1; /* No such node */
05697       return 1; /* No match yet */
05698    }
05699 
05700    if(!strcmp(myrpt->name,node)) /* Do not allow connections to self */
05701       return -2;
05702       
05703    if(debug > 3){
05704       ast_log(LOG_NOTICE,"Connect attempt to node %s\n", node);
05705       ast_log(LOG_NOTICE,"Mode: %s\n",(mode)?"Transceive":"Monitor");
05706       ast_log(LOG_NOTICE,"Connection type: %s\n",(perma)?"Permalink":"Normal");
05707    }
05708 
05709    strncpy(tmp,val,sizeof(tmp) - 1);
05710    s = tmp;
05711    s1 = strsep(&s,",");
05712    if (!strchr(s1,':') && strchr(s1,'/') && strncasecmp(s1, "local/", 6))
05713    {
05714       sy = strchr(s1,'/');    
05715       *sy = 0;
05716       sprintf(sx,"%s:4569/%s",s1,sy + 1);
05717       s1 = sx;
05718    }
05719    s2 = strsep(&s,",");
05720    rpt_mutex_lock(&myrpt->lock);
05721    l = myrpt->links.next;
05722    /* try to find this one in queue */
05723    while(l != &myrpt->links){
05724       if (l->name[0] == '0') 
05725       {
05726          l = l->next;
05727          continue;
05728       }
05729    /* if found matching string */
05730       if (!strcmp(l->name, node))
05731          break;
05732       l = l->next;
05733    }
05734    /* if found */
05735    if (l != &myrpt->links){ 
05736    /* if already in this mode, just ignore */
05737       if ((l->mode) || (!l->chan)) {
05738          rpt_mutex_unlock(&myrpt->lock);
05739          return 2; /* Already linked */
05740       }
05741       reconnects = l->reconnects;
05742       rpt_mutex_unlock(&myrpt->lock);
05743       if (l->chan) ast_softhangup(l->chan, AST_SOFTHANGUP_DEV);
05744       l->retries = l->max_retries + 1;
05745       l->disced = 2;
05746       modechange = 1;
05747    } else
05748    {
05749       __mklinklist(myrpt,NULL,lstr);
05750       rpt_mutex_unlock(&myrpt->lock);
05751       n = finddelim(lstr,strs,MAXLINKLIST);
05752       for(i = 0; i < n; i++)
05753       {
05754          if ((*strs[i] < '0') || 
05755              (*strs[i] > '9')) strs[i]++;
05756          if (!strcmp(strs[i],node))
05757          {
05758             return 2; /* Already linked */
05759          }
05760       }
05761    }
05762    strncpy(myrpt->lastlinknode,node,MAXNODESTR - 1);
05763    /* establish call */
05764    l = ast_malloc(sizeof(struct rpt_link));
05765    if (!l)
05766    {
05767       ast_log(LOG_WARNING, "Unable to malloc\n");
05768       return -1;
05769    }
05770    /* zero the silly thing */
05771    memset((char *)l,0,sizeof(struct rpt_link));
05772    l->mode = mode;
05773    l->outbound = 1;
05774    l->thisconnected = 0;
05775    voxinit_link(l,1);
05776    strncpy(l->name, node, MAXNODESTR - 1);
05777    l->isremote = (s && ast_true(s));
05778    if (modechange) l->connected = 1;
05779    l->hasconnected = l->perma = perma;
05780 #ifdef ALLOW_LOCAL_CHANNELS
05781    if ((strncasecmp(s1,"iax2/", 5) == 0) || (strncasecmp(s1, "local/", 6) == 0))
05782          strncpy(deststr, s1, sizeof(deststr));
05783    else
05784            snprintf(deststr, sizeof(deststr), "IAX2/%s", s1);
05785 #else
05786    snprintf(deststr, sizeof(deststr), "IAX2/%s", s1);
05787 #endif
05788    tele = strchr(deststr, '/');
05789    if (!tele){
05790       ast_log(LOG_WARNING,"link3:Dial number (%s) must be in format tech/number\n",deststr);
05791       ast_free(l);
05792       return -1;
05793    }
05794    *tele++ = 0;
05795    l->chan = ast_request(deststr, AST_FORMAT_SLINEAR, NULL, tele, NULL);
05796    if (l->chan){
05797       ast_set_read_format(l->chan, AST_FORMAT_SLINEAR);
05798       ast_set_write_format(l->chan, AST_FORMAT_SLINEAR);
05799 #ifdef   AST_CDR_FLAG_POST_DISABLED
05800       if (l->chan->cdr)
05801          ast_set_flag(l->chan->cdr,AST_CDR_FLAG_POST_DISABLED);
05802 #endif
05803 #ifndef  NEW_ASTERISK
05804       l->chan->whentohangup = 0;
05805 #endif
05806       l->chan->appl = "Apprpt";
05807       l->chan->data = "(Remote Rx)";
05808       if (debug > 3)
05809          ast_log(LOG_NOTICE, "rpt (remote) initiating call to %s/%s on %s\n",
05810       deststr, tele, l->chan->name);
05811       if(l->chan->cid.cid_num)
05812          ast_free(l->chan->cid.cid_num);
05813       l->chan->cid.cid_num = ast_strdup(myrpt->name);
05814       ast_call(l->chan,tele,999);
05815    }
05816    else {
05817       if(debug > 3) 
05818          ast_log(LOG_NOTICE, "Unable to place call to %s/%s on %s\n",
05819       deststr,tele,l->chan->name);
05820       if (myrpt->p.archivedir)
05821       {
05822          char str[100];
05823          sprintf(str,"LINKFAIL,%s",l->name);
05824          donodelog(myrpt,str);
05825       }
05826       ast_free(l);
05827       return -1;
05828    }
05829    /* allocate a pseudo-channel thru asterisk */
05830    l->pchan = ast_request("DAHDI", AST_FORMAT_SLINEAR, NULL, "pseudo", NULL);
05831    if (!l->pchan){
05832       ast_log(LOG_WARNING,"rpt connect: Sorry unable to obtain pseudo channel\n");
05833       ast_hangup(l->chan);
05834       ast_free(l);
05835       return -1;
05836    }
05837    ast_set_read_format(l->pchan, AST_FORMAT_SLINEAR);
05838    ast_set_write_format(l->pchan, AST_FORMAT_SLINEAR);
05839 #ifdef   AST_CDR_FLAG_POST_DISABLED
05840    if (l->pchan->cdr)
05841       ast_set_flag(l->pchan->cdr,AST_CDR_FLAG_POST_DISABLED);
05842 #endif
05843    /* make a conference for the tx */
05844    ci.chan = 0;
05845    ci.confno = myrpt->conf;
05846    ci.confmode = DAHDI_CONF_CONF | DAHDI_CONF_LISTENER | DAHDI_CONF_TALKER;
05847    /* first put the channel on the conference in proper mode */
05848    if (ioctl(l->pchan->fds[0], DAHDI_SETCONF, &ci) == -1)
05849    {
05850       ast_log(LOG_WARNING, "Unable to set conference mode to Announce\n");
05851       ast_hangup(l->chan);
05852       ast_hangup(l->pchan);
05853       ast_free(l);
05854       return -1;
05855    }
05856    rpt_mutex_lock(&myrpt->lock);
05857    l->reconnects = reconnects;
05858    /* insert at end of queue */
05859    l->max_retries = MAX_RETRIES;
05860    if (perma)
05861       l->max_retries = MAX_RETRIES_PERM;
05862    if (l->isremote) l->retries = l->max_retries + 1;
05863    insque((struct qelem *)l,(struct qelem *)myrpt->links.next);
05864    __kickshort(myrpt);
05865    rpt_mutex_unlock(&myrpt->lock);
05866    if (!l->phonemode) send_newkey(l->chan);
05867    return 0;
05868 }

static int decimals2int ( char *  fraction  )  [static]

Definition at line 8208 of file app_rpt.c.

Referenced by check_tx_freq().

08209 {
08210    int i;
08211    char len = strlen(fraction);
08212    int multiplier = 100000;
08213    int res = 0;
08214 
08215    if(!len)
08216       return 0;
08217    for( i = 0 ; i < len ; i++, multiplier /= 10)
08218       res += (fraction[i] - '0') * multiplier;
08219    return res;
08220 }

static long diskavail ( struct rpt myrpt  )  [static]

Definition at line 1334 of file app_rpt.c.

References rpt::archivedir, ast_log(), LOG_WARNING, rpt::name, and rpt::p.

Referenced by rpt(), and rpt_exec().

01335 {
01336 struct   statfs statfsbuf;
01337 
01338    if (!myrpt->p.archivedir) return(0);
01339    if (statfs(myrpt->p.archivedir,&statfsbuf) == -1)
01340    {
01341       ast_log(LOG_WARNING,"Cannot get filesystem size for %s node %s\n",
01342          myrpt->p.archivedir,myrpt->name);
01343       return(-1);
01344    }
01345    return(statfsbuf.f_bavail);
01346 }

static void do_dtmf_local ( struct rpt myrpt,
char  c 
) [static]

Definition at line 1579 of file app_rpt.c.

References ast_log(), ast_playtones_start(), DTMF_LOCAL_STARTTIME, rpt::dtmf_local_str, DTMF_LOCAL_TIME, rpt::dtmf_local_timer, rpt::lock, LOG_DEBUG, LOG_NOTICE, ast_channel::name, rpt_mutex_lock, rpt_mutex_unlock, and rpt::txchannel.

Referenced by function_ilink(), function_remote(), handle_link_data(), handle_remote_dtmf_digit(), rpt(), and rpt_exec().

01580 {
01581 int   i;
01582 char  digit;
01583 static const char* dtmf_tones[] = {
01584    "!941+1336/200,!0/200", /* 0 */
01585    "!697+1209/200,!0/200", /* 1 */
01586    "!697+1336/200,!0/200", /* 2 */
01587    "!697+1477/200,!0/200", /* 3 */
01588    "!770+1209/200,!0/200", /* 4 */
01589    "!770+1336/200,!0/200", /* 5 */
01590    "!770+1477/200,!0/200", /* 6 */
01591    "!852+1209/200,!0/200", /* 7 */
01592    "!852+1336/200,!0/200", /* 8 */
01593    "!852+1477/200,!0/200", /* 9 */
01594    "!697+1633/200,!0/200", /* A */
01595    "!770+1633/200,!0/200", /* B */
01596    "!852+1633/200,!0/200", /* C */
01597    "!941+1633/200,!0/200", /* D */
01598    "!941+1209/200,!0/200", /* * */
01599    "!941+1477/200,!0/200" };  /* # */
01600 
01601 
01602    if (c)
01603    {
01604       snprintf(myrpt->dtmf_local_str + strlen(myrpt->dtmf_local_str),sizeof(myrpt->dtmf_local_str) - 1,"%c",c);
01605       if (!myrpt->dtmf_local_timer) 
01606           myrpt->dtmf_local_timer = DTMF_LOCAL_STARTTIME;
01607    }
01608    /* if at timeout */
01609    if (myrpt->dtmf_local_timer == 1)
01610    {
01611       if(debug > 6)
01612          ast_log(LOG_NOTICE,"time out dtmf_local_timer=%i\n",myrpt->dtmf_local_timer);
01613 
01614       /* if anything in the string */
01615       if (myrpt->dtmf_local_str[0])
01616       {
01617          digit = myrpt->dtmf_local_str[0];
01618          myrpt->dtmf_local_str[0] = 0;
01619          for(i = 1; myrpt->dtmf_local_str[i]; i++)
01620          {
01621             myrpt->dtmf_local_str[i - 1] =
01622                myrpt->dtmf_local_str[i];
01623          }
01624          myrpt->dtmf_local_str[i - 1] = 0;
01625          myrpt->dtmf_local_timer = DTMF_LOCAL_TIME;
01626          rpt_mutex_unlock(&myrpt->lock);
01627          if (digit >= '0' && digit <='9')
01628             ast_playtones_start(myrpt->txchannel, 0, dtmf_tones[digit-'0'], 0);
01629          else if (digit >= 'A' && digit <= 'D')
01630             ast_playtones_start(myrpt->txchannel, 0, dtmf_tones[digit-'A'+10], 0);
01631          else if (digit == '*')
01632             ast_playtones_start(myrpt->txchannel, 0, dtmf_tones[14], 0);
01633          else if (digit == '#')
01634             ast_playtones_start(myrpt->txchannel, 0, dtmf_tones[15], 0);
01635          else {
01636             /* not handled */
01637             ast_log(LOG_DEBUG, "Unable to generate DTMF tone '%c' for '%s'\n", digit, myrpt->txchannel->name);
01638          }
01639          rpt_mutex_lock(&myrpt->lock);
01640       }
01641       else
01642       {
01643          myrpt->dtmf_local_timer = 0;
01644       }
01645    }
01646 }

static void do_dtmf_phone ( struct rpt myrpt,
struct rpt_link mylink,
char  c 
) [static]

Definition at line 1524 of file app_rpt.c.

References ast_senddigit(), rpt_link::chan, rpt::links, rpt_link::next, and rpt_link::phonemode.

Referenced by handle_link_data(), and local_dtmf_helper().

01525 {
01526 struct        rpt_link *l;
01527 
01528        l = myrpt->links.next;
01529        /* go thru all the links */
01530        while(l != &myrpt->links)
01531        {
01532                if (!l->phonemode)
01533                {
01534                        l = l->next;
01535                        continue;
01536                }
01537                /* dont send to self */
01538                if (mylink && (l == mylink))
01539                {
01540                        l = l->next;
01541                        continue;
01542                }
01543 #ifdef   NEW_ASTERISK
01544                if (l->chan) ast_senddigit(l->chan,c,0);
01545 #else
01546                if (l->chan) ast_senddigit(l->chan,c);
01547 #endif
01548                l = l->next;
01549        }
01550        return;
01551 }

static void do_scheduler ( struct rpt myrpt  )  [static]

Definition at line 10609 of file app_rpt.c.

References ast_log(), ast_variable_browse(), ast_variable_retrieve(), rpt::cfg, rpt::curtv, rpt::dailyexecdcommands, rpt::dailykerchunks, rpt::dailykeyups, rpt::dailytxtime, LOG_NOTICE, LOG_WARNING, rpt::macro, rpt::macrobuf, MACROTIME, rpt::macrotimer, MAXMACRO, ast_variable::name, ast_variable::next, rpt::p, rpt::remote, rpt_localtime(), rpt::s, sysstate::schedulerdisable, rpt::skedstanzaname, rpt::sysstate_cur, ast_variable::value, and value.

Referenced by rpt().

10610 {
10611    int i,res;
10612 
10613 #ifdef   NEW_ASTERISK
10614    struct ast_tm tmnow;
10615 #else
10616    struct tm tmnow;
10617 #endif
10618    struct ast_variable *skedlist;
10619    char *strs[5],*vp,*val,value[100];
10620 
10621    memcpy(&myrpt->lasttv, &myrpt->curtv, sizeof(struct timeval));
10622    
10623    if( (res = gettimeofday(&myrpt->curtv, NULL)) < 0)
10624       ast_log(LOG_NOTICE, "Scheduler gettime of day returned: %s\n", strerror(res));
10625 
10626    /* Try to get close to a 1 second resolution */
10627    
10628    if(myrpt->lasttv.tv_sec == myrpt->curtv.tv_sec)
10629       return;
10630 
10631    rpt_localtime(&myrpt->curtv.tv_sec, &tmnow);
10632 
10633    /* If midnight, then reset all daily statistics */
10634    
10635    if((tmnow.tm_hour == 0)&&(tmnow.tm_min == 0)&&(tmnow.tm_sec == 0)){
10636       myrpt->dailykeyups = 0;
10637       myrpt->dailytxtime = 0;
10638       myrpt->dailykerchunks = 0;
10639       myrpt->dailyexecdcommands = 0;
10640    }
10641 
10642    if(tmnow.tm_sec != 0)
10643       return;
10644 
10645    /* Code below only executes once per minute */
10646 
10647 
10648    /* Don't schedule if remote */
10649 
10650         if (myrpt->remote)
10651                 return;
10652 
10653    /* Don't schedule if disabled */
10654 
10655         if(myrpt->p.s[myrpt->p.sysstate_cur].schedulerdisable){
10656       if(debug > 6)
10657          ast_log(LOG_NOTICE, "Scheduler disabled\n");
10658       return;
10659    }
10660 
10661    if(!myrpt->p.skedstanzaname){ /* No stanza means we do nothing */
10662       if(debug > 6)
10663          ast_log(LOG_NOTICE,"No stanza for scheduler in rpt.conf\n");
10664       return;
10665    }
10666 
10667     /* get pointer to linked list of scheduler entries */
10668     skedlist = ast_variable_browse(myrpt->cfg, myrpt->p.skedstanzaname);
10669 
10670    if(debug > 6){
10671       ast_log(LOG_NOTICE, "Time now: %02d:%02d %02d %02d %02d\n",
10672          tmnow.tm_hour,tmnow.tm_min,tmnow.tm_mday,tmnow.tm_mon + 1, tmnow.tm_wday); 
10673    }
10674    /* walk the list */
10675    for(; skedlist; skedlist = skedlist->next){
10676       if(debug > 6)
10677          ast_log(LOG_NOTICE, "Scheduler entry %s = %s being considered\n",skedlist->name, skedlist->value);
10678       strncpy(value,skedlist->value,99);
10679       value[99] = 0;
10680       /* point to the substrings for minute, hour, dom, month, and dow */
10681       for( i = 0, vp = value ; i < 5; i++){
10682          if(!*vp)
10683             break;
10684          while((*vp == ' ') || (*vp == 0x09)) /* get rid of any leading white space */
10685             vp++;
10686          strs[i] = vp; /* save pointer to beginning of substring */
10687          while((*vp != ' ') && (*vp != 0x09) && (*vp != 0)) /* skip over substring */
10688             vp++;
10689          if(*vp)
10690             *vp++ = 0; /* mark end of substring */
10691       }
10692       if(debug > 6)
10693          ast_log(LOG_NOTICE, "i = %d, min = %s, hour = %s, mday=%s, mon=%s, wday=%s\n",i,
10694             strs[0], strs[1], strs[2], strs[3], strs[4]); 
10695       if(i == 5){
10696          if((*strs[0] != '*')&&(atoi(strs[0]) != tmnow.tm_min))
10697             continue;
10698          if((*strs[1] != '*')&&(atoi(strs[1]) != tmnow.tm_hour))
10699             continue;
10700          if((*strs[2] != '*')&&(atoi(strs[2]) != tmnow.tm_mday))
10701             continue;
10702          if((*strs[3] != '*')&&(atoi(strs[3]) != tmnow.tm_mon + 1))
10703             continue;
10704          if(atoi(strs[4]) == 7)
10705             strs[4] = "0";
10706          if((*strs[4] != '*')&&(atoi(strs[4]) != tmnow.tm_wday))
10707             continue;
10708          if(debug)
10709             ast_log(LOG_NOTICE, "Executing scheduler entry %s = %s\n", skedlist->name, skedlist->value);
10710          if(atoi(skedlist->name) == 0)
10711             return; /* Zero is reserved for the startup macro */
10712          val = (char *) ast_variable_retrieve(myrpt->cfg, myrpt->p.macro, skedlist->name);
10713          if (!val){
10714             ast_log(LOG_WARNING,"Scheduler could not find macro %s\n",skedlist->name);
10715             return; /* Macro not found */
10716          }
10717          if ((MAXMACRO - strlen(myrpt->macrobuf)) < strlen(val)){
10718             ast_log(LOG_WARNING, "Scheduler could not execute macro %s: Macro buffer full\n",
10719                skedlist->name);
10720             return; /* Macro buffer full */
10721          }
10722          myrpt->macrotimer = MACROTIME;
10723          strncat(myrpt->macrobuf,val,MAXMACRO - 1);
10724       }
10725       else{
10726          ast_log(LOG_WARNING,"Malformed scheduler entry in rpt.conf: %s = %s\n",
10727             skedlist->name, skedlist->value);
10728       }
10729    }
10730 
10731 }

static void donodelog ( struct rpt myrpt,
char *  str 
) [static]

Definition at line 1554 of file app_rpt.c.

References nodelog::archivedir, rpt::archivedir, ast_log(), ast_malloc, ast_mutex_lock(), ast_mutex_unlock(), LOG_ERROR, rpt::name, nodeloglock, rpt::p, nodelog::prev, nodelog::str, and nodelog::timestamp.

Referenced by connect_link(), function_remote(), handle_link_data(), handle_link_phone_dtmf(), handle_remote_data(), handle_remote_phone_dtmf(), local_dtmf_helper(), rpt(), rpt_exec(), and setrem().

01555 {
01556 struct nodelog *nodep;
01557 char  datestr[100];
01558 
01559    if (!myrpt->p.archivedir) return;
01560    nodep = (struct nodelog *)ast_malloc(sizeof(struct nodelog));
01561    if (nodep == NULL)
01562    {
01563       ast_log(LOG_ERROR,"Cannot get memory for node log");
01564       return;
01565    }
01566    time(&nodep->timestamp);
01567    strncpy(nodep->archivedir,myrpt->p.archivedir,
01568       sizeof(nodep->archivedir) - 1);
01569    strftime(datestr,sizeof(datestr) - 1,"%Y%m%d%H%M%S",
01570       localtime(&nodep->timestamp));
01571    snprintf(nodep->str,sizeof(nodep->str) - 1,"%s %s,%s\n",
01572       myrpt->name,datestr,str);
01573    ast_mutex_lock(&nodeloglock);
01574    insque((struct qelem *) nodep, (struct qelem *) nodelog.prev);
01575    ast_mutex_unlock(&nodeloglock);
01576 }

static int dovox ( struct vox v,
short *  buf,
int  bs 
) [static]

Definition at line 1118 of file app_rpt.c.

References vox::enacount, vox::lastvox, mymax, mymin, vox::noise_energy, vox::offdebcnt, vox::ondebcnt, vox::speech_energy, VOX_MAX_THRESHOLD, VOX_MIN_THRESHOLD, and vox::voxena.

Referenced by rpt().

01119 {
01120 
01121    int i;
01122    float esquare = 0.0;
01123    float energy = 0.0;
01124    float threshold = 0.0;
01125    
01126    if (v->voxena < 0) return(v->lastvox);
01127    for(i = 0; i < bs; i++)
01128    {
01129       esquare += (float) buf[i] * (float) buf[i];
01130    }
01131    energy = sqrt(esquare);
01132 
01133    if (energy >= v->speech_energy)
01134       v->speech_energy += (energy - v->speech_energy) / 4;
01135    else
01136       v->speech_energy += (energy - v->speech_energy) / 64;
01137 
01138    if (energy >= v->noise_energy)
01139       v->noise_energy += (energy - v->noise_energy) / 64;
01140    else
01141       v->noise_energy += (energy - v->noise_energy) / 4;
01142    
01143    if (v->voxena) threshold = v->speech_energy / 8;
01144    else
01145    {
01146       threshold = mymax(v->speech_energy / 16,v->noise_energy * 2);
01147       threshold = mymin(threshold,VOX_MAX_THRESHOLD);
01148    }
01149    threshold = mymax(threshold,VOX_MIN_THRESHOLD);
01150    if (energy > threshold)
01151    {
01152       if (v->voxena) v->noise_energy *= 0.75;
01153       v->voxena = 1;
01154    } else   v->voxena = 0;
01155    if (v->lastvox != v->voxena)
01156    {
01157       if (v->enacount++ >= ((v->lastvox) ? v->offdebcnt : v->ondebcnt))
01158       {
01159          v->lastvox = v->voxena;
01160          v->enacount = 0;
01161       }
01162    } else v->enacount = 0;
01163    return(v->lastvox);
01164 }

static char* eatwhite ( char *  s  )  [static]

Definition at line 1808 of file app_rpt.c.

Referenced by check_tx_freq().

01809 {
01810    while((*s == ' ') || (*s == 0x09)){ /* get rid of any leading white space */
01811       if(!*s)
01812          break;
01813       s++;
01814    }
01815    return s;
01816 }

static int finddelim ( char *  str,
char *  strp[],
int  limit 
) [static]

Definition at line 1828 of file app_rpt.c.

References DELIMCHR, and QUOTECHR.

Referenced by check_tx_freq(), connect_link(), function_autopatchup(), function_ilink(), load_rpt_vars(), rpt_do_nodes(), rpt_tele_thread(), and statpost().

01829 {
01830 int     i,l,inquo;
01831 
01832         inquo = 0;
01833         i = 0;
01834         strp[i++] = str;
01835         if (!*str)
01836            {
01837                 strp[0] = 0;
01838                 return(0);
01839            }
01840         for(l = 0; *str && (l < limit) ; str++)
01841            {
01842                 if (*str == QUOTECHR)
01843                    {
01844                         if (inquo)
01845                            {
01846                                 *str = 0;
01847                                 inquo = 0;
01848                            }
01849                         else
01850                            {
01851                                 strp[i - 1] = str + 1;
01852                                 inquo = 1;
01853                            }
01854       }
01855                 if ((*str == DELIMCHR) && (!inquo))
01856                 {
01857                         *str = 0;
01858          l++;
01859                         strp[i++] = str + 1;
01860                 }
01861            }
01862         strp[i] = 0;
01863         return(i);
01864 
01865 }

static void flush_telem ( struct rpt myrpt  )  [static]

Definition at line 1348 of file app_rpt.c.

References ast_log(), ast_softhangup(), AST_SOFTHANGUP_DEV, rpt_tele::chan, rpt::lock, LOG_NOTICE, rpt_tele::mode, rpt_tele::next, rpt_mutex_lock, rpt_mutex_unlock, SETREMOTE, and rpt::tele.

Referenced by function_cop().

01349 {
01350    struct rpt_tele *telem;
01351    if(debug > 2)
01352       ast_log(LOG_NOTICE, "flush_telem()!!");
01353    rpt_mutex_lock(&myrpt->lock);
01354    telem = myrpt->tele.next;
01355    while(telem != &myrpt->tele)
01356    {
01357       if (telem->mode != SETREMOTE) ast_softhangup(telem->chan,AST_SOFTHANGUP_DEV);
01358       telem = telem->next;
01359    }
01360    rpt_mutex_unlock(&myrpt->lock);
01361 }

static char func_xlat ( struct rpt myrpt,
char  c,
struct rpt_xlat xlat 
) [static]

Definition at line 1763 of file app_rpt.c.

References rpt::endchar, rpt_xlat::endcharseq, rpt_xlat::endindex, rpt::funcchar, rpt_xlat::funccharseq, rpt_xlat::funcindex, rpt_xlat::lastone, MAXXLATTIME, rpt::p, and rpt_xlat::passchars.

Referenced by handle_link_data(), handle_remote_data(), and rpt().

01764 {
01765 time_t   now;
01766 int   gotone;
01767 
01768    time(&now);
01769    gotone = 0;
01770    /* if too much time, reset the skate machine */
01771    if ((now - xlat->lastone) > MAXXLATTIME)
01772    {
01773       xlat->funcindex = xlat->endindex = 0;
01774    }
01775    if (xlat->funccharseq[0] && (c == xlat->funccharseq[xlat->funcindex++]))
01776    {
01777       time(&xlat->lastone);
01778       gotone = 1;
01779       if (!xlat->funccharseq[xlat->funcindex])
01780       {
01781          xlat->funcindex = xlat->endindex = 0;
01782          return(myrpt->p.funcchar);
01783       }
01784    } else xlat->funcindex = 0;
01785    if (xlat->endcharseq[0] && (c == xlat->endcharseq[xlat->endindex++]))
01786    {
01787       time(&xlat->lastone);
01788       gotone = 1;
01789       if (!xlat->endcharseq[xlat->endindex])
01790       {
01791          xlat->funcindex = xlat->endindex = 0;
01792          return(myrpt->p.endchar);
01793       }
01794    } else xlat->endindex = 0;
01795    /* if in middle of decode seq, send nothing back */
01796    if (gotone) return(0);
01797    /* if no pass chars specified, return em all */
01798    if (!xlat->passchars[0]) return(c);
01799    /* if a "pass char", pass it */
01800    if (strchr(xlat->passchars,c)) return(c);
01801    return(0);
01802 }

static int function_autopatchdn ( struct rpt myrpt,
char *  param,
char *  digitbuf,
int  command_source,
struct rpt_link mylink 
) [static]

Definition at line 6245 of file app_rpt.c.

References sysstate::autopatchdisable, rpt::callmode, channel_revert(), DC_COMPLETE, DC_ERROR, rpt::lock, rpt::macropatch, rpt::p, rpt_mutex_lock, rpt_mutex_unlock, rpt_telemetry(), rpt::s, rpt::sysstate_cur, TERM, and sysstate::txdisable.

06246 {
06247    if (myrpt->p.s[myrpt->p.sysstate_cur].txdisable || myrpt->p.s[myrpt->p.sysstate_cur].autopatchdisable)
06248       return DC_ERROR;
06249    
06250    if(debug)
06251       printf("@@@@ Autopatch down\n");
06252       
06253    rpt_mutex_lock(&myrpt->lock);
06254    
06255    myrpt->macropatch=0;
06256 
06257    if (!myrpt->callmode){
06258       rpt_mutex_unlock(&myrpt->lock);
06259       return DC_COMPLETE;
06260    }
06261    
06262    myrpt->callmode = 0;
06263    channel_revert(myrpt);
06264    rpt_mutex_unlock(&myrpt->lock);
06265    rpt_telemetry(myrpt, TERM, NULL);
06266    return DC_COMPLETE;
06267 }

static int function_autopatchup ( struct rpt myrpt,
char *  param,
char *  digitbuf,
int  command_source,
struct rpt_link mylink 
) [static]

Definition at line 6147 of file app_rpt.c.

References ast_free, ast_log(), ast_pthread_create, ast_strdup, sysstate::autopatchdisable, rpt::callmode, rpt::cidx, DC_COMPLETE, DC_ERROR, rpt::endchar, rpt::exten, finddelim(), rpt::lock, LOG_ERROR, matchkeyword(), MAXPATCHCONTEXT, rpt::mydtmf, rpt::ourcontext, rpt::p, rpt::patchcontext, rpt::patchdialtime, rpt::patchfarenddisconnect, rpt::patchnoct, rpt::patchquiet, rpt_call(), rpt::rpt_call_thread, rpt_mutex_lock, rpt_mutex_unlock, rpt::s, skipchars(), rpt::sysstate_cur, sysstate::txdisable, and value.

06148 {
06149    pthread_attr_t attr;
06150    int i, idx, paramlength;
06151    char *lparam;
06152    char *value = NULL;
06153    char *paramlist[20];
06154 
06155    static char *keywords[] = {
06156    "context",
06157    "dialtime",
06158    "farenddisconnect",
06159    "noct",
06160    "quiet",
06161    NULL
06162    };
06163       
06164    if (myrpt->p.s[myrpt->p.sysstate_cur].txdisable || myrpt->p.s[myrpt->p.sysstate_cur].autopatchdisable)
06165       return DC_ERROR;
06166       
06167    if(debug)
06168       printf("@@@@ Autopatch up\n");
06169 
06170    if(!myrpt->callmode){
06171       /* Set defaults */
06172       myrpt->patchnoct = 0;
06173       myrpt->patchdialtime = 0;
06174       myrpt->patchfarenddisconnect = 0;
06175       myrpt->patchquiet = 0;
06176       strncpy(myrpt->patchcontext, myrpt->p.ourcontext, MAXPATCHCONTEXT);
06177 
06178       if(param){
06179          /* Process parameter list */
06180          lparam = ast_strdup(param);
06181          if(!lparam){
06182             ast_log(LOG_ERROR,"App_rpt out of memory on line %d\n",__LINE__);
06183             return DC_ERROR;  
06184          }
06185          paramlength = finddelim(lparam, paramlist, 20);          
06186          for(i = 0; i < paramlength; i++){
06187             idx = matchkeyword(paramlist[i], &value, keywords);
06188             if(value)
06189                value = skipchars(value, "= ");
06190             switch(idx){
06191 
06192                case 1: /* context */
06193                   strncpy(myrpt->patchcontext, value, MAXPATCHCONTEXT - 1) ;
06194                   break;
06195                   
06196                case 2: /* dialtime */
06197                   myrpt->patchdialtime = atoi(value);
06198                   break;
06199 
06200                case 3: /* farenddisconnect */
06201                   myrpt->patchfarenddisconnect = atoi(value);
06202                   break;
06203 
06204                case 4:  /* noct */
06205                   myrpt->patchnoct = atoi(value);
06206                   break;
06207 
06208                case 5: /* quiet */
06209                   myrpt->patchquiet = atoi(value);
06210                   break;
06211                            
06212                default:
06213                   break;
06214             }
06215          }
06216       ast_free(lparam);
06217       }
06218    }
06219                
06220    rpt_mutex_lock(&myrpt->lock);
06221 
06222    /* if on call, force * into current audio stream */
06223    
06224    if ((myrpt->callmode == 2) || (myrpt->callmode == 3)){
06225       myrpt->mydtmf = myrpt->p.endchar;
06226    }
06227    if (myrpt->callmode){
06228       rpt_mutex_unlock(&myrpt->lock);
06229       return DC_COMPLETE;
06230    }
06231    myrpt->callmode = 1;
06232    myrpt->cidx = 0;
06233    myrpt->exten[myrpt->cidx] = 0;
06234    rpt_mutex_unlock(&myrpt->lock);
06235    pthread_attr_init(&attr);
06236    pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
06237    ast_pthread_create(&myrpt->rpt_call_thread,&attr,rpt_call,(void *) myrpt);
06238    return DC_COMPLETE;
06239 }

static int function_cop ( struct rpt myrpt,
char *  param,
char *  digitbuf,
int  command_source,
struct rpt_link mylink 
) [static]

Definition at line 6373 of file app_rpt.c.

References sysstate::alternatetail, ARB_ALPHA, ast_log(), sysstate::autopatchdisable, birdbath(), channel_steer(), COMPLETE, DC_COMPLETE, DC_DOKEY, DC_ERROR, DC_INDETERMINATE, rpt::disgorgetime, rpt::endchar, flush_telem(), rpt::inpadtest, sysstate::linkfundisable, LOG_NOTICE, MEMNOTFOUND, myatoi(), rpt::p, rpt::parrotmode, retreive_memory(), rpt_telemetry(), rpt::s, sysstate::schedulerdisable, send_link_keyquery(), setrem(), SOURCE_PHONE, rpt::stopgen, rpt::sysstate_cur, TEST_TONE, rpt::topkeylong, sysstate::totdisable, sysstate::txdisable, and sysstate::userfundisable.

06374 {
06375    char string[16];
06376    int res;
06377 
06378    int i, r;
06379 
06380    if(!param)
06381       return DC_ERROR;
06382    
06383    switch(myatoi(param)){
06384       case 1: /* System reset */
06385          res = system("killall -9 asterisk");
06386          return DC_COMPLETE;
06387 
06388       case 2:
06389          myrpt->p.s[myrpt->p.sysstate_cur].txdisable = 0;
06390          rpt_telemetry(myrpt, ARB_ALPHA, (void *) "RPTENA");
06391          return DC_COMPLETE;
06392          
06393       case 3:
06394          myrpt->p.s[myrpt->p.sysstate_cur].txdisable = 1;
06395          return DC_COMPLETE;
06396          
06397       case 4: /* test tone on */
06398          if (myrpt->stopgen < 0) 
06399          {
06400             myrpt->stopgen = 1;
06401          }
06402          else 
06403          {
06404             myrpt->stopgen = 0;
06405             rpt_telemetry(myrpt, TEST_TONE, NULL);
06406          }
06407          return DC_COMPLETE;
06408 
06409       case 5: /* Disgorge variables to log for debug purposes */
06410          myrpt->disgorgetime = time(NULL) + 10; /* Do it 10 seconds later */
06411          return DC_COMPLETE;
06412 
06413       case 6: /* Simulate COR being activated (phone only) */
06414          if (command_source != SOURCE_PHONE) return DC_INDETERMINATE;
06415          return DC_DOKEY;  
06416 
06417 
06418       case 7: /* Time out timer enable */
06419          myrpt->p.s[myrpt->p.sysstate_cur].totdisable = 0;
06420          rpt_telemetry(myrpt, ARB_ALPHA, (void *) "TOTENA");
06421          return DC_COMPLETE;
06422          
06423       case 8: /* Time out timer disable */
06424          myrpt->p.s[myrpt->p.sysstate_cur].totdisable = 1;
06425          rpt_telemetry(myrpt, ARB_ALPHA, (void *) "TOTDIS");
06426          return DC_COMPLETE;
06427 
06428                 case 9: /* Autopatch enable */
06429                         myrpt->p.s[myrpt->p.sysstate_cur].autopatchdisable = 0;
06430                         rpt_telemetry(myrpt, ARB_ALPHA, (void *) "APENA");
06431                         return DC_COMPLETE;
06432 
06433                 case 10: /* Autopatch disable */
06434                         myrpt->p.s[myrpt->p.sysstate_cur].autopatchdisable = 1;
06435                         rpt_telemetry(myrpt, ARB_ALPHA, (void *) "APDIS");
06436                         return DC_COMPLETE;
06437 
06438                 case 11: /* Link Enable */
06439                         myrpt->p.s[myrpt->p.sysstate_cur].linkfundisable = 0;
06440                         rpt_telemetry(myrpt, ARB_ALPHA, (void *) "LNKENA");
06441                         return DC_COMPLETE;
06442 
06443                 case 12: /* Link Disable */
06444                         myrpt->p.s[myrpt->p.sysstate_cur].linkfundisable = 1;
06445                         rpt_telemetry(myrpt, ARB_ALPHA, (void *) "LNKDIS");
06446                         return DC_COMPLETE;
06447 
06448       case 13: /* Query System State */
06449          string[0] = string[1] = 'S';
06450          string[2] = myrpt->p.sysstate_cur + '0';
06451          string[3] = '\0';
06452          rpt_telemetry(myrpt, ARB_ALPHA, (void *) string);
06453          return DC_COMPLETE;
06454 
06455       case 14: /* Change System State */
06456          if(strlen(digitbuf) == 0)
06457             break;
06458          if((digitbuf[0] < '0') || (digitbuf[0] > '9'))
06459             return DC_ERROR;
06460          myrpt->p.sysstate_cur = digitbuf[0] - '0';
06461                         string[0] = string[1] = 'S';
06462                         string[2] = myrpt->p.sysstate_cur + '0';
06463                         string[3] = '\0';
06464                         rpt_telemetry(myrpt, ARB_ALPHA, (void *) string);
06465                         return DC_COMPLETE;
06466 
06467                 case 15: /* Scheduler Enable */
06468                         myrpt->p.s[myrpt->p.sysstate_cur].schedulerdisable = 0;
06469                         rpt_telemetry(myrpt, ARB_ALPHA, (void *) "SKENA");
06470                         return DC_COMPLETE;
06471 
06472                 case 16: /* Scheduler Disable */
06473                         myrpt->p.s[myrpt->p.sysstate_cur].schedulerdisable = 1;
06474                         rpt_telemetry(myrpt, ARB_ALPHA, (void *) "SKDIS");
06475                         return DC_COMPLETE;
06476 
06477                 case 17: /* User functions Enable */
06478                         myrpt->p.s[myrpt->p.sysstate_cur].userfundisable = 0;
06479                         rpt_telemetry(myrpt, ARB_ALPHA, (void *) "UFENA");
06480                         return DC_COMPLETE;
06481 
06482                 case 18: /* User Functions Disable */
06483                         myrpt->p.s[myrpt->p.sysstate_cur].userfundisable = 1;
06484                         rpt_telemetry(myrpt, ARB_ALPHA, (void *) "UFDIS");
06485                         return DC_COMPLETE;
06486 
06487                 case 19: /* Alternate Tail Enable */
06488                         myrpt->p.s[myrpt->p.sysstate_cur].alternatetail = 1;
06489                         rpt_telemetry(myrpt, ARB_ALPHA, (void *) "ATENA");
06490                         return DC_COMPLETE;
06491 
06492                 case 20: /* Alternate Tail Disable */
06493                         myrpt->p.s[myrpt->p.sysstate_cur].alternatetail = 0;
06494                         rpt_telemetry(myrpt, ARB_ALPHA, (void *) "ATDIS");
06495                         return DC_COMPLETE;
06496 
06497                 case 21: /* Parrot Mode Disable */
06498          birdbath(myrpt);
06499          if (myrpt->p.parrotmode < 2)
06500          {
06501             myrpt->p.parrotmode = 0;
06502             rpt_telemetry(myrpt,COMPLETE,NULL);
06503             return DC_COMPLETE;
06504          }
06505          break;
06506 
06507                 case 22: /* Parrot Mode Enable */
06508          birdbath(myrpt);
06509          if (myrpt->p.parrotmode < 2)
06510          {
06511             myrpt->p.parrotmode = 1;
06512             rpt_telemetry(myrpt,COMPLETE,NULL);
06513             return DC_COMPLETE;
06514          }
06515          break;
06516       case 23: /* flush parrot in progress */
06517          birdbath(myrpt);
06518          rpt_telemetry(myrpt,COMPLETE,NULL);
06519          return DC_COMPLETE;
06520       case 24: /* flush all telemetry */
06521          flush_telem(myrpt);
06522          rpt_telemetry(myrpt,COMPLETE,NULL);
06523          return DC_COMPLETE;
06524       case 25: /* request keying info (brief) */
06525          send_link_keyquery(myrpt);
06526          myrpt->topkeylong = 0;
06527          rpt_telemetry(myrpt,COMPLETE,NULL);
06528          return DC_COMPLETE;
06529       case 26: /* request keying info (full) */
06530          send_link_keyquery(myrpt);
06531          myrpt->topkeylong = 1;
06532          rpt_telemetry(myrpt,COMPLETE,NULL);
06533          return DC_COMPLETE;
06534 
06535       case 30: /* recall memory location on programmable radio */
06536 
06537          if(strlen(digitbuf) < 2) /* needs 2 digits */
06538             break;
06539          
06540          for(i = 0 ; i < 2 ; i++){
06541             if((digitbuf[i] < '0') || (digitbuf[i] > '9'))
06542                return DC_ERROR;
06543          }
06544        
06545          r = retreive_memory(myrpt, digitbuf);
06546          if (r < 0){
06547             rpt_telemetry(myrpt,MEMNOTFOUND,NULL);
06548             return DC_COMPLETE;
06549          }
06550          if (r > 0){
06551             return DC_ERROR;
06552          }
06553          if (setrem(myrpt) == -1) return DC_ERROR;
06554          return DC_COMPLETE;  
06555 
06556       case 31: 
06557           /* set channel. note that it's going to change channel 
06558              then confirm on the new channel! */
06559          if(strlen(digitbuf) < 2) /* needs 2 digits */
06560             break;
06561          
06562          for(i = 0 ; i < 2 ; i++){
06563             if((digitbuf[i] < '0') || (digitbuf[i] > '9'))
06564                return DC_ERROR;
06565          }
06566          channel_steer(myrpt,digitbuf);
06567          return DC_COMPLETE;  
06568 
06569       case 32: /* Touch Tone Pad Test */
06570          i = strlen(digitbuf);
06571          if(!i){
06572             if(debug > 3)
06573             ast_log(LOG_NOTICE,"Padtest entered");
06574             myrpt->inpadtest = 1;
06575          }
06576          else{
06577             if(debug > 3)
06578                ast_log(LOG_NOTICE,"Padtest len= %d digits=%s",i,digitbuf);
06579             if(digitbuf[i-1] != myrpt->p.endchar)
06580                break;
06581             rpt_telemetry(myrpt, ARB_ALPHA, digitbuf);
06582             myrpt->inpadtest = 0;
06583             if(debug > 3)
06584                ast_log(LOG_NOTICE,"Padtest exited");
06585             return DC_COMPLETE;
06586          }
06587    }  
06588    return DC_INDETERMINATE;
06589 }

static int function_ilink ( struct rpt myrpt,
char *  param,
char *  digitbuf,
int  command_source,
struct rpt_link mylink 
) [static]

Definition at line 5876 of file app_rpt.c.

References AST_FRAME_TEXT, ast_log(), ast_safe_sleep(), ast_softhangup(), AST_SOFTHANGUP_DEV, ast_write(), rpt_link::chan, rpt::cmdnode, COMPLETE, connect_link(), CONNFAIL, ast_frame::data, ast_frame::datalen, DC_COMPLETE, DC_ERROR, DC_INDETERMINATE, rpt_link::disced, do_dtmf_local(), finddelim(), ast_frame::frametype, FULLSTATUS, rpt::lastlinknode, LASTNODEKEY, sysstate::linkfundisable, rpt::links, rpt::lock, LOG_NOTICE, rpt::longestnode, ast_frame::mallocd, MAX_RETRIES, rpt_link::max_retries, MAXLINKLIST, MAXNODESTR, mdc1200_notify(), rpt_link::mode, myatoi(), rpt::name, rpt_link::name, rpt_link::next, node_lookup(), ast_frame::offset, rpt::p, rpt_link::perma, rpt::propagate_dtmf, rpt::propagate_phonedtmf, ast_frame::ptr, REMALREADY, REMGO, rpt_link::retries, rpt_mutex_lock, rpt_mutex_unlock, rpt_telemetry(), rpt::s, s, ast_frame::samples, rpt::savednodes, SOURCE_ALT, SOURCE_DPHONE, SOURCE_LNK, SOURCE_PHONE, SOURCE_RPT, STATUS, strsep(), ast_frame::subclass, rpt::sysstate_cur, and sysstate::txdisable.

05877 {
05878 
05879    char *val, *s, *s1, *s2;
05880    char tmp[300];
05881    char digitbuf[MAXNODESTR],*strs[MAXLINKLIST];
05882    char mode,perma;
05883    char sx[320],*sy;
05884    struct rpt_link *l;
05885    int i,r;
05886 
05887    if(!param)
05888       return DC_ERROR;
05889       
05890          
05891    if (myrpt->p.s[myrpt->p.sysstate_cur].txdisable || myrpt->p.s[myrpt->p.sysstate_cur].linkfundisable )
05892       return DC_ERROR;
05893 
05894    strncpy(digitbuf,digits,MAXNODESTR - 1);
05895 
05896    if(debug > 6)
05897       printf("@@@@ ilink param = %s, digitbuf = %s\n", (param)? param : "(null)", digitbuf);
05898       
05899    switch(myatoi(param)){
05900       case 11: /* Perm Link off */
05901       case 1: /* Link off */
05902          if ((digitbuf[0] == '0') && (myrpt->lastlinknode[0]))
05903             strcpy(digitbuf,myrpt->lastlinknode);
05904          val = node_lookup(myrpt,digitbuf);
05905          if (!val){
05906             if(strlen(digitbuf) >= myrpt->longestnode)
05907                return DC_ERROR;
05908             break;
05909          }
05910          strncpy(tmp,val,sizeof(tmp) - 1);
05911          s = tmp;
05912          s1 = strsep(&s,",");
05913          if (!strchr(s1,':') && strchr(s1,'/') && strncasecmp(s1, "local/", 6))
05914          {
05915             sy = strchr(s1,'/');    
05916             *sy = 0;
05917             sprintf(sx,"%s:4569/%s",s1,sy + 1);
05918             s1 = sx;
05919          }
05920          s2 = strsep(&s,",");
05921          rpt_mutex_lock(&myrpt->lock);
05922          l = myrpt->links.next;
05923          /* try to find this one in queue */
05924          while(l != &myrpt->links){
05925             if (l->name[0] == '0') 
05926             {
05927                l = l->next;
05928                continue;
05929             }
05930             /* if found matching string */
05931             if (!strcmp(l->name, digitbuf))
05932                break;
05933             l = l->next;
05934          }
05935          if (l != &myrpt->links){ /* if found */
05936             struct   ast_frame wf;
05937 
05938             /* must use perm command on perm link */
05939             if ((myatoi(param) < 10) && 
05940                 (l->max_retries > MAX_RETRIES))
05941             {
05942                rpt_mutex_unlock(&myrpt->lock);
05943                return DC_COMPLETE;
05944             }
05945             strncpy(myrpt->lastlinknode,digitbuf,MAXNODESTR - 1);
05946             l->retries = l->max_retries + 1;
05947             l->disced = 1;
05948             rpt_mutex_unlock(&myrpt->lock);
05949             wf.frametype = AST_FRAME_TEXT;
05950             wf.subclass = 0;
05951             wf.offset = 0;
05952             wf.mallocd = 0;
05953             wf.datalen = strlen(discstr) + 1;
05954             wf.samples = 0;
05955             wf.data.ptr = discstr;
05956             if (l->chan)
05957             {
05958                ast_write(l->chan,&wf);
05959                if (ast_safe_sleep(l->chan,250) == -1) return DC_ERROR;
05960                ast_softhangup(l->chan,AST_SOFTHANGUP_DEV);
05961             }
05962             rpt_telemetry(myrpt, COMPLETE, NULL);
05963             return DC_COMPLETE;
05964          }
05965          rpt_mutex_unlock(&myrpt->lock);  
05966          return DC_COMPLETE;
05967       case 2: /* Link Monitor */
05968       case 3: /* Link transceive */
05969       case 12: /* Link Monitor permanent */
05970       case 13: /* Link transceive permanent */
05971          if ((digitbuf[0] == '0') && (myrpt->lastlinknode[0]))
05972             strcpy(digitbuf,myrpt->lastlinknode);
05973          /* Attempt connection  */
05974          perma = (atoi(param) > 10) ? 1 : 0;
05975          mode = (atoi(param) & 1) ? 1 : 0;
05976          r = connect_link(myrpt, digitbuf, mode, perma);
05977          switch(r){
05978             case -2: /* Attempt to connect to self */
05979                return DC_COMPLETE; /* Silent error */
05980 
05981             case 0:
05982                rpt_telemetry(myrpt, COMPLETE, NULL);
05983                return DC_COMPLETE;
05984 
05985             case 1:
05986                break;
05987             
05988             case 2:
05989                rpt_telemetry(myrpt, REMALREADY, NULL);
05990                return DC_COMPLETE;
05991             
05992             default:
05993                rpt_telemetry(myrpt, CONNFAIL, NULL);
05994                return DC_COMPLETE;
05995          }
05996          break;
05997 
05998       case 4: /* Enter Command Mode */
05999       
06000          /* if doesnt allow link cmd, or no links active, return */
06001          if (((command_source != SOURCE_RPT) && 
06002             (command_source != SOURCE_PHONE) &&
06003             (command_source != SOURCE_ALT) &&
06004             (command_source != SOURCE_DPHONE)) ||
06005              (myrpt->links.next == &myrpt->links))
06006             return DC_COMPLETE;
06007          
06008          /* if already in cmd mode, or selected self, fughetabahtit */
06009          if ((myrpt->cmdnode[0]) || (!strcmp(myrpt->name, digitbuf))){
06010          
06011             rpt_telemetry(myrpt, REMALREADY, NULL);
06012             return DC_COMPLETE;
06013          }
06014          if ((digitbuf[0] == '0') && (myrpt->lastlinknode[0]))
06015             strcpy(digitbuf,myrpt->lastlinknode);
06016          /* node must at least exist in list */
06017          val = node_lookup(myrpt,digitbuf);
06018          if (!val){
06019             if(strlen(digitbuf) >= myrpt->longestnode)
06020                return DC_ERROR;
06021             break;
06022          
06023          }
06024          rpt_mutex_lock(&myrpt->lock);
06025          strcpy(myrpt->lastlinknode,digitbuf);
06026          strncpy(myrpt->cmdnode, digitbuf, sizeof(myrpt->cmdnode) - 1);
06027          rpt_mutex_unlock(&myrpt->lock);
06028          rpt_telemetry(myrpt, REMGO, NULL);  
06029          return DC_COMPLETE;
06030          
06031       case 5: /* Status */
06032          rpt_telemetry(myrpt, STATUS, NULL);
06033          return DC_COMPLETE;
06034 
06035       case 15: /* Full Status */
06036          rpt_telemetry(myrpt, FULLSTATUS, NULL);
06037          return DC_COMPLETE;
06038          
06039          
06040       case 6: /* All Links Off, including permalinks */
06041                        rpt_mutex_lock(&myrpt->lock);
06042          myrpt->savednodes[0] = 0;
06043                         l = myrpt->links.next;
06044                         /* loop through all links */
06045                         while(l != &myrpt->links){
06046             struct   ast_frame wf;
06047                                 if (l->name[0] == '0') /* Skip any IAXRPT monitoring */
06048                                 {
06049                                         l = l->next;
06050                                         continue;
06051                                 }
06052             /* Make a string of disconnected nodes for possible restoration */
06053             sprintf(tmp,"%c%c%s",(l->mode) ? 'X' : 'M',(l->perma) ? 'P':'T',l->name);
06054             if(strlen(tmp) + strlen(myrpt->savednodes) + 1 < MAXNODESTR){ 
06055                if(myrpt->savednodes[0])
06056                   strcat(myrpt->savednodes, ",");
06057                strcat(myrpt->savednodes, tmp);
06058             }
06059                               l->retries = l->max_retries + 1;
06060                                 l->disced = 2; /* Silently disconnect */
06061                                 rpt_mutex_unlock(&myrpt->lock);
06062             /* ast_log(LOG_NOTICE,"dumping link %s\n",l->name); */
06063                                 
06064                                 wf.frametype = AST_FRAME_TEXT;
06065                                 wf.subclass = 0;
06066                                 wf.offset = 0;
06067                                 wf.mallocd = 0;
06068                                 wf.datalen = strlen(discstr) + 1;
06069                                 wf.samples = 0;
06070                                 wf.data.ptr = discstr;
06071                                 if (l->chan)
06072                                 {
06073                                         ast_write(l->chan,&wf);
06074                                         ast_safe_sleep(l->chan,250); /* It's dead already, why check the return value? */
06075                                         ast_softhangup(l->chan,AST_SOFTHANGUP_DEV);
06076                                 }
06077             rpt_mutex_lock(&myrpt->lock);
06078                                 l = l->next;
06079                         }
06080          rpt_mutex_unlock(&myrpt->lock);
06081          if(debug > 3)
06082             ast_log(LOG_NOTICE,"Nodes disconnected: %s\n",myrpt->savednodes);
06083                         rpt_telemetry(myrpt, COMPLETE, NULL);
06084          return DC_COMPLETE;
06085 
06086       case 7: /* Identify last node which keyed us up */
06087          rpt_telemetry(myrpt, LASTNODEKEY, NULL);
06088          break;
06089 
06090 
06091 #ifdef   _MDC_DECODE_H_
06092       case 8:
06093          myrpt->lastunit = 0xd00d; 
06094          mdc1200_notify(myrpt,NULL,myrpt->lastunit);
06095          mdc1200_send(myrpt,myrpt->lastunit);
06096          break;
06097 #endif
06098 
06099       case 16: /* Restore links disconnected with "disconnect all links" command */
06100          strcpy(tmp, myrpt->savednodes); /* Make a copy */
06101          finddelim(tmp, strs, MAXLINKLIST); /* convert into substrings */
06102          for(i = 0; tmp[0] && strs[i] != NULL && i < MAXLINKLIST; i++){
06103             s1 = strs[i];
06104             mode = (s1[0] == 'X') ? 1 : 0;
06105             perma = (s1[1] == 'P') ? 1 : 0;
06106             connect_link(myrpt, s1 + 2, mode, perma); /* Try to reconnect */
06107          }
06108                         rpt_telemetry(myrpt, COMPLETE, NULL);
06109          break;
06110    
06111       case 200:
06112       case 201:
06113       case 202:
06114       case 203:
06115       case 204:
06116       case 205:
06117       case 206:
06118       case 207:
06119       case 208:
06120       case 209:
06121       case 210:
06122       case 211:
06123       case 212:
06124       case 213:
06125       case 214:
06126       case 215:
06127          if (((myrpt->p.propagate_dtmf) && 
06128               (command_source == SOURCE_LNK)) ||
06129              ((myrpt->p.propagate_phonedtmf) &&
06130             ((command_source == SOURCE_PHONE) ||
06131               (command_source == SOURCE_ALT) ||
06132                 (command_source == SOURCE_DPHONE))))
06133                do_dtmf_local(myrpt,
06134                   remdtmfstr[myatoi(param) - 200]);
06135       default:
06136          return DC_ERROR;
06137          
06138    }
06139    
06140    return DC_INDETERMINATE;
06141 }  

static int function_macro ( struct rpt myrpt,
char *  param,
char *  digitbuf,
int  command_source,
struct rpt_link mylink 
) [static]

Definition at line 6309 of file app_rpt.c.

References ast_variable_retrieve(), rpt::cfg, DC_COMPLETE, DC_ERROR, DC_INDETERMINATE, rpt::lock, rpt::macro, MACRO_BUSY, rpt::macro_longest, MACRO_NOTFOUND, rpt::macrobuf, MACROTIME, rpt::macrotimer, MAXMACRO, rpt::p, rpt::remote, rpt_mutex_lock, rpt_mutex_unlock, rpt_telemetry(), and rpt::startupmacro.

06310 {
06311 char  *val;
06312 int   i;
06313    if (myrpt->remote)
06314       return DC_ERROR;
06315 
06316    if(debug) 
06317       printf("@@@@ macro-oni param = %s, digitbuf = %s\n", (param)? param : "(null)", digitbuf);
06318    
06319    if(strlen(digitbuf) < 1) /* needs 1 digit */
06320       return DC_INDETERMINATE;
06321          
06322    for(i = 0 ; i < digitbuf[i] ; i++) {
06323       if((digitbuf[i] < '0') || (digitbuf[i] > '9'))
06324          return DC_ERROR;
06325    }
06326    
06327    if (*digitbuf == '0') val = myrpt->p.startupmacro;
06328    else val = (char *) ast_variable_retrieve(myrpt->cfg, myrpt->p.macro, digitbuf);
06329    /* param was 1 for local buf */
06330    if (!val){
06331                 if (strlen(digitbuf) < myrpt->macro_longest)
06332                         return DC_INDETERMINATE;
06333       rpt_telemetry(myrpt, MACRO_NOTFOUND, NULL);
06334       return DC_COMPLETE;
06335    }        
06336    rpt_mutex_lock(&myrpt->lock);
06337    if ((MAXMACRO - strlen(myrpt->macrobuf)) < strlen(val))
06338    {
06339       rpt_mutex_unlock(&myrpt->lock);
06340       rpt_telemetry(myrpt, MACRO_BUSY, NULL);
06341       return DC_ERROR;
06342    }
06343    myrpt->macrotimer = MACROTIME;
06344    strncat(myrpt->macrobuf,val,MAXMACRO - 1);
06345    rpt_mutex_unlock(&myrpt->lock);
06346    return DC_COMPLETE;  
06347 }

static int function_playback ( struct rpt myrpt,
char *  param,
char *  digitbuf,
int  command_source,
struct rpt_link mylink 
) [static]

Definition at line 6353 of file app_rpt.c.

References ast_fileexists(), DC_COMPLETE, DC_ERROR, ast_channel::language, PLAYBACK, rpt::remote, rpt_telemetry(), and rpt::rxchannel.

06354 {
06355 
06356    if (myrpt->remote)
06357       return DC_ERROR;
06358 
06359    if(debug) 
06360       printf("@@@@ playback param = %s, digitbuf = %s\n", (param)? param : "(null)", digitbuf);
06361    
06362    if (ast_fileexists(param,NULL,myrpt->rxchannel->language) <= 0)
06363       return DC_ERROR;
06364 
06365    rpt_telemetry(myrpt,PLAYBACK,param);
06366    return DC_COMPLETE;
06367 }

static int function_remote ( struct rpt myrpt,
char *  param,
char *  digitbuf,
int  command_source,
struct rpt_link mylink 
) [static]

Definition at line 9641 of file app_rpt.c.

References rpt::archivedir, AST_CONTROL_RADIO_UNKEY, ast_free, ast_indicate(), ast_log(), ast_mutex_lock(), ast_mutex_unlock(), ast_strdup, rpt::authlevel, check_freq(), DC_COMPLETE, DC_COMPLETEQUIET, DC_ERROR, DC_INDETERMINATE, do_dtmf_local(), donodelog(), rpt::freq, get_mem_set(), HF_SCAN_DOWN_FAST, HF_SCAN_DOWN_QUICK, HF_SCAN_DOWN_SLOW, HF_SCAN_UP_FAST, HF_SCAN_UP_QUICK, HF_SCAN_UP_SLOW, rpt::hfscanmode, INVFREQ, ISRIG_RTX, rpt::lock, LOG_NOTICE, LOG_WARNING, rpt::loginlevel, rpt::loginuser, MAXREMSTR, MEMNOTFOUND, multimode_bump_freq(), multimode_capable(), myatoi(), rpt::name, rpt::offset, rpt::p, rpt::powerlevel, REM_HIPWR, REM_LOWPWR, REM_MEDPWR, REM_MINUS, REM_MODE_AM, REM_MODE_FM, REM_MODE_LSB, REM_MODE_USB, REM_PLUS, REM_SCANTIME, REM_SIMPLEX, REMLOGIN, REMLONGSTATUS, REMMODE, rpt::remmode, rpt::remoterig, rpt::remotetx, REMSHORTSTATUS, REMXXX, rpt_telemetry(), rpt::rxpl, rpt::rxplon, s, rpt::scantimer, setrem(), SOURCE_LNK, SOURCE_RPT, split_freq(), strsep(), TUNE, rpt::tunerequest, rpt::txchannel, rpt::txpl, and rpt::txplon.

09642 {
09643    char *s,*s1,*s2;
09644    int i,j,r,ht,k,l,ls2,m,d,offset,offsave, modesave, defmode=0;
09645    intptr_t p;
09646    char multimode = 0;
09647    char oc,*cp,*cp1,*cp2;
09648    char tmp[20], freq[20] = "", savestr[20] = "";
09649    char mhz[MAXREMSTR], decimals[MAXREMSTR];
09650 
09651     if(debug > 6) {
09652       ast_log(LOG_NOTICE,"%s param=%s digitbuf=%s source=%i\n",myrpt->name,param,digitbuf,command_source);
09653    }
09654 
09655    if((!param) || (command_source == SOURCE_RPT) || (command_source == SOURCE_LNK))
09656       return DC_ERROR;
09657       
09658    p = myatoi(param);
09659 
09660    if ((p != 99) && (p != 5) && (p != 140) && myrpt->p.authlevel && 
09661       (!myrpt->loginlevel[0])) return DC_ERROR;
09662    multimode = multimode_capable(myrpt);
09663 
09664    switch(p){
09665 
09666       case 1:  /* retrieve memory */
09667          if(strlen(digitbuf) < 2) /* needs 2 digits */
09668             break;
09669          
09670          for(i = 0 ; i < 2 ; i++){
09671             if((digitbuf[i] < '0') || (digitbuf[i] > '9'))
09672                return DC_ERROR;
09673          }
09674          r=get_mem_set(myrpt, digitbuf);
09675          if (r < 0){
09676             rpt_telemetry(myrpt,MEMNOTFOUND,NULL);
09677             return DC_COMPLETE;
09678          }
09679          else if (r > 0){
09680             return DC_ERROR;
09681          }
09682          return DC_COMPLETE;  
09683          
09684       case 2:  /* set freq and offset */
09685       
09686          
09687             for(i = 0, j = 0, k = 0, l = 0 ; digitbuf[i] ; i++){ /* look for M+*K+*O or M+*H+* depending on mode */
09688             if(digitbuf[i] == '*'){
09689                j++;
09690                continue;
09691             }
09692             if((digitbuf[i] < '0') || (digitbuf[i] > '9'))
09693                goto invalid_freq;
09694             else{
09695                if(j == 0)
09696                   l++; /* # of digits before first * */
09697                if(j == 1)
09698                   k++; /* # of digits after first * */
09699             }
09700          }
09701       
09702          i = strlen(digitbuf) - 1;
09703          if(multimode){
09704             if((j > 2) || (l > 3) || (k > 6))
09705                goto invalid_freq; /* &^@#! */
09706          }
09707          else{
09708             if((j > 2) || (l > 4) || (k > 3))
09709                goto invalid_freq; /* &^@#! */
09710          }
09711 
09712          /* Wait for M+*K+* */
09713 
09714          if(j < 2)
09715             break; /* Not yet */
09716 
09717          /* We have a frequency */
09718 
09719          strncpy(tmp, digitbuf ,sizeof(tmp) - 1);
09720          
09721          s = tmp;
09722          s1 = strsep(&s, "*"); /* Pick off MHz */
09723          s2 = strsep(&s,"*"); /* Pick off KHz and Hz */
09724          ls2 = strlen(s2); 
09725          
09726          switch(ls2){ /* Allow partial entry of khz and hz digits for laziness support */
09727             case 1:
09728                ht = 0;
09729                k = 100 * atoi(s2);
09730                break;
09731             
09732             case 2:
09733                ht = 0;
09734                k = 10 * atoi(s2);
09735                break;
09736                
09737             case 3:
09738                if(!multimode){
09739                   if((s2[2] != '0')&&(s2[2] != '5'))
09740                      goto invalid_freq;
09741                }
09742                ht = 0;
09743                k = atoi(s2);
09744                   break;
09745             case 4:
09746                k = atoi(s2)/10;
09747                ht = 10 * (atoi(s2+(ls2-1)));
09748                break;
09749 
09750             case 5:
09751                k = atoi(s2)/100;
09752                ht = (atoi(s2+(ls2-2)));
09753                break;
09754                
09755             default:
09756                goto invalid_freq;
09757          }
09758 
09759          /* Check frequency for validity and establish a default mode */
09760          
09761          snprintf(freq, sizeof(freq), "%s.%03d%02d",s1, k, ht);
09762 
09763          if(debug)
09764             ast_log(LOG_NOTICE, "New frequency: %s\n", freq);
09765    
09766          split_freq(mhz, decimals, freq);
09767          m = atoi(mhz);
09768          d = atoi(decimals);
09769 
09770          if(check_freq(myrpt, m, d, &defmode)) /* Check to see if frequency entered is legit */
09771                  goto invalid_freq;
09772 
09773 
09774          if((defmode == REM_MODE_FM) && (digitbuf[i] == '*')) /* If FM, user must enter and additional offset digit */
09775             break; /* Not yet */
09776 
09777 
09778          offset = REM_SIMPLEX; /* Assume simplex */
09779 
09780          if(defmode == REM_MODE_FM){
09781             oc = *s; /* Pick off offset */
09782          
09783             if (oc){
09784                switch(oc){
09785                   case '1':
09786                      offset = REM_MINUS;
09787                      break;
09788                   
09789                   case '2':
09790                      offset = REM_SIMPLEX;
09791                   break;
09792                   
09793                   case '3':
09794                      offset = REM_PLUS;
09795                      break;
09796                   
09797                   default:
09798                      goto invalid_freq;
09799                } 
09800             } 
09801          }  
09802          offsave = myrpt->offset;
09803          modesave = myrpt->remmode;
09804          strncpy(savestr, myrpt->freq, sizeof(savestr) - 1);
09805          strncpy(myrpt->freq, freq, sizeof(myrpt->freq) - 1);
09806          myrpt->offset = offset;
09807          myrpt->remmode = defmode;
09808 
09809          if (setrem(myrpt) == -1){
09810             myrpt->offset = offsave;
09811             myrpt->remmode = modesave;
09812             strncpy(myrpt->freq, savestr, sizeof(myrpt->freq) - 1);
09813             goto invalid_freq;
09814          }
09815 
09816          return DC_COMPLETE;
09817 
09818 invalid_freq:
09819          rpt_telemetry(myrpt,INVFREQ,NULL);
09820          return DC_ERROR; 
09821       
09822       case 3: /* set rx PL tone */
09823             for(i = 0, j = 0, k = 0, l = 0 ; digitbuf[i] ; i++){ /* look for N+*N */
09824             if(digitbuf[i] == '*'){
09825                j++;
09826                continue;
09827             }
09828             if((digitbuf[i] < '0') || (digitbuf[i] > '9'))
09829                return DC_ERROR;
09830             else{
09831                if(j)
09832                   l++;
09833                else
09834                   k++;
09835             }
09836          }
09837          if((j > 1) || (k > 3) || (l > 1))
09838             return DC_ERROR; /* &$@^! */
09839          i = strlen(digitbuf) - 1;
09840          if((j != 1) || (k < 2)|| (l != 1))
09841             break; /* Not yet */
09842          if(debug)
09843             printf("PL digits entered %s\n", digitbuf);
09844             
09845          strncpy(tmp, digitbuf, sizeof(tmp) - 1);
09846          /* see if we have at least 1 */
09847          s = strchr(tmp,'*');
09848          if(s)
09849             *s = '.';
09850          strncpy(savestr, myrpt->rxpl, sizeof(savestr) - 1);
09851          strncpy(myrpt->rxpl, tmp, sizeof(myrpt->rxpl) - 1);
09852          if(!strcmp(myrpt->remoterig, remote_rig_rbi))
09853          {
09854             strncpy(myrpt->txpl, tmp, sizeof(myrpt->txpl) - 1);
09855          }
09856          if (setrem(myrpt) == -1){
09857             strncpy(myrpt->rxpl, savestr, sizeof(myrpt->rxpl) - 1);
09858             return DC_ERROR;
09859          }
09860          return DC_COMPLETE;
09861       
09862       case 4: /* set tx PL tone */
09863          /* cant set tx tone on RBI (rx tone does both) */
09864          if(!strcmp(myrpt->remoterig, remote_rig_rbi))
09865             return DC_ERROR;
09866          /*  eventually for the ic706 instead of just throwing the exception
09867             we can check if we are in encode only mode and allow the tx
09868             ctcss code to be changed. but at least the warning message is
09869             issued for now.
09870          */
09871          if(!strcmp(myrpt->remoterig, remote_rig_ic706))
09872          {
09873             if(debug)
09874                ast_log(LOG_WARNING,"Setting IC706 Tx CTCSS Code Not Supported. Set Rx Code for both.\n");
09875             return DC_ERROR;
09876          }
09877          for(i = 0, j = 0, k = 0, l = 0 ; digitbuf[i] ; i++){ /* look for N+*N */
09878             if(digitbuf[i] == '*'){
09879                j++;
09880                continue;
09881             }
09882             if((digitbuf[i] < '0') || (digitbuf[i] > '9'))
09883                return DC_ERROR;
09884             else{
09885                if(j)
09886                   l++;
09887                else
09888                   k++;
09889             }
09890          }
09891          if((j > 1) || (k > 3) || (l > 1))
09892             return DC_ERROR; /* &$@^! */
09893          i = strlen(digitbuf) - 1;
09894          if((j != 1) || (k < 2)|| (l != 1))
09895             break; /* Not yet */
09896          if(debug)
09897             printf("PL digits entered %s\n", digitbuf);
09898             
09899          strncpy(tmp, digitbuf, sizeof(tmp) - 1);
09900          /* see if we have at least 1 */
09901          s = strchr(tmp,'*');
09902          if(s)
09903             *s = '.';
09904          strncpy(savestr, myrpt->txpl, sizeof(savestr) - 1);
09905          strncpy(myrpt->txpl, tmp, sizeof(myrpt->txpl) - 1);
09906          
09907          if (setrem(myrpt) == -1){
09908             strncpy(myrpt->txpl, savestr, sizeof(myrpt->txpl) - 1);
09909             return DC_ERROR;
09910          }
09911          return DC_COMPLETE;
09912       
09913 
09914       case 6: /* MODE (FM,USB,LSB,AM) */
09915          if(strlen(digitbuf) < 1)
09916             break;
09917 
09918          if(!multimode)
09919             return DC_ERROR; /* Multimode radios only */
09920 
09921          switch(*digitbuf){
09922             case '1':
09923                split_freq(mhz, decimals, myrpt->freq); 
09924                m=atoi(mhz);
09925                if(m < 29) /* No FM allowed below 29MHz! */
09926                   return DC_ERROR;
09927                myrpt->remmode = REM_MODE_FM;
09928                
09929                rpt_telemetry(myrpt,REMMODE,NULL);
09930                break;
09931 
09932             case '2':
09933                myrpt->remmode = REM_MODE_USB;
09934                rpt_telemetry(myrpt,REMMODE,NULL);
09935                break;   
09936 
09937             case '3':
09938                myrpt->remmode = REM_MODE_LSB;
09939                rpt_telemetry(myrpt,REMMODE,NULL);
09940                break;
09941             
09942             case '4':
09943                myrpt->remmode = REM_MODE_AM;
09944                rpt_telemetry(myrpt,REMMODE,NULL);
09945                break;
09946       
09947             default:
09948                return DC_ERROR;
09949          }
09950 
09951          if(setrem(myrpt))
09952             return DC_ERROR;
09953          return DC_COMPLETEQUIET;
09954       case 99:
09955          /* cant log in when logged in */
09956          if (myrpt->loginlevel[0]) 
09957             return DC_ERROR;
09958          *myrpt->loginuser = 0;
09959          myrpt->loginlevel[0] = 0;
09960          cp = ast_strdup(param);
09961          cp1 = strchr(cp,',');
09962          ast_mutex_lock(&myrpt->lock);
09963          if (cp1) 
09964          {
09965             *cp1 = 0;
09966             cp2 = strchr(cp1 + 1,',');
09967             if (cp2) 
09968             {
09969                *cp2 = 0;
09970                strncpy(myrpt->loginlevel,cp2 + 1,
09971                   sizeof(myrpt->loginlevel) - 1);
09972             }
09973             strncpy(myrpt->loginuser,cp1 + 1,sizeof(myrpt->loginuser));
09974             ast_mutex_unlock(&myrpt->lock);
09975             if (myrpt->p.archivedir)
09976             {
09977                char str[100];
09978 
09979                sprintf(str,"LOGIN,%s,%s",
09980                    myrpt->loginuser,myrpt->loginlevel);
09981                donodelog(myrpt,str);
09982             }
09983             if (debug) 
09984                printf("loginuser %s level %s\n",myrpt->loginuser,myrpt->loginlevel);
09985             rpt_telemetry(myrpt,REMLOGIN,NULL);
09986          }
09987          ast_free(cp);
09988          return DC_COMPLETEQUIET;
09989       case 100: /* RX PL Off */
09990          myrpt->rxplon = 0;
09991          setrem(myrpt);
09992          rpt_telemetry(myrpt,REMXXX,(void *)p);
09993          return DC_COMPLETEQUIET;
09994       case 101: /* RX PL On */
09995          myrpt->rxplon = 1;
09996          setrem(myrpt);
09997          rpt_telemetry(myrpt,REMXXX,(void *)p);
09998          return DC_COMPLETEQUIET;
09999       case 102: /* TX PL Off */
10000          myrpt->txplon = 0;
10001          setrem(myrpt);
10002          rpt_telemetry(myrpt,REMXXX,(void *)p);
10003          return DC_COMPLETEQUIET;
10004       case 103: /* TX PL On */
10005          myrpt->txplon = 1;
10006          setrem(myrpt);
10007          rpt_telemetry(myrpt,REMXXX,(void *)p);
10008          return DC_COMPLETEQUIET;
10009       case 104: /* Low Power */
10010          if(!strcmp(myrpt->remoterig, remote_rig_ic706))
10011             return DC_ERROR;
10012          myrpt->powerlevel = REM_LOWPWR;
10013          setrem(myrpt);
10014          rpt_telemetry(myrpt,REMXXX,(void *)p);
10015          return DC_COMPLETEQUIET;
10016       case 105: /* Medium Power */
10017          if(!strcmp(myrpt->remoterig, remote_rig_ic706))
10018             return DC_ERROR;
10019          if (ISRIG_RTX(myrpt->remoterig)) return DC_ERROR;
10020          myrpt->powerlevel = REM_MEDPWR;
10021          setrem(myrpt);
10022          rpt_telemetry(myrpt,REMXXX,(void *)p);
10023          return DC_COMPLETEQUIET;
10024       case 106: /* Hi Power */
10025          if(!strcmp(myrpt->remoterig, remote_rig_ic706))
10026             return DC_ERROR;
10027          myrpt->powerlevel = REM_HIPWR;
10028          setrem(myrpt);
10029          rpt_telemetry(myrpt,REMXXX,(void *)p);
10030          return DC_COMPLETEQUIET;
10031       case 107: /* Bump down 20Hz */
10032          multimode_bump_freq(myrpt, -20);
10033          return DC_COMPLETE;
10034       case 108: /* Bump down 100Hz */
10035          multimode_bump_freq(myrpt, -100);
10036          return DC_COMPLETE;
10037       case 109: /* Bump down 500Hz */
10038          multimode_bump_freq(myrpt, -500);
10039          return DC_COMPLETE;
10040       case 110: /* Bump up 20Hz */
10041          multimode_bump_freq(myrpt, 20);
10042          return DC_COMPLETE;
10043       case 111: /* Bump up 100Hz */
10044          multimode_bump_freq(myrpt, 100);
10045          return DC_COMPLETE;
10046       case 112: /* Bump up 500Hz */
10047          multimode_bump_freq(myrpt, 500);
10048          return DC_COMPLETE;
10049       case 113: /* Scan down slow */
10050          myrpt->scantimer = REM_SCANTIME;
10051          myrpt->hfscanmode = HF_SCAN_DOWN_SLOW;
10052          rpt_telemetry(myrpt,REMXXX,(void *)p);
10053          return DC_COMPLETEQUIET;
10054       case 114: /* Scan down quick */
10055          myrpt->scantimer = REM_SCANTIME;
10056          myrpt->hfscanmode = HF_SCAN_DOWN_QUICK;
10057          rpt_telemetry(myrpt,REMXXX,(void *)p);
10058          return DC_COMPLETEQUIET;
10059       case 115: /* Scan down fast */
10060          myrpt->scantimer = REM_SCANTIME;
10061          myrpt->hfscanmode = HF_SCAN_DOWN_FAST;
10062          rpt_telemetry(myrpt,REMXXX,(void *)p);
10063          return DC_COMPLETEQUIET;
10064       case 116: /* Scan up slow */
10065          myrpt->scantimer = REM_SCANTIME;
10066          myrpt->hfscanmode = HF_SCAN_UP_SLOW;
10067          rpt_telemetry(myrpt,REMXXX,(void *)p);
10068          return DC_COMPLETEQUIET;
10069       case 117: /* Scan up quick */
10070          myrpt->scantimer = REM_SCANTIME;
10071          myrpt->hfscanmode = HF_SCAN_UP_QUICK;
10072          rpt_telemetry(myrpt,REMXXX,(void *)p);
10073          return DC_COMPLETEQUIET;
10074       case 118: /* Scan up fast */
10075          myrpt->scantimer = REM_SCANTIME;
10076          myrpt->hfscanmode = HF_SCAN_UP_FAST;
10077          rpt_telemetry(myrpt,REMXXX,(void *)p);
10078          return DC_COMPLETEQUIET;
10079       case 119: /* Tune Request */
10080          if(debug > 3)
10081             ast_log(LOG_NOTICE,"TUNE REQUEST\n");
10082          /* if not currently going, and valid to do */
10083          if((!myrpt->tunerequest) && 
10084              ((!strcmp(myrpt->remoterig, remote_rig_ft897) || 
10085             !strcmp(myrpt->remoterig, remote_rig_ic706)) )) { 
10086             myrpt->remotetx = 0;
10087             ast_indicate(myrpt->txchannel,AST_CONTROL_RADIO_UNKEY);
10088             myrpt->tunerequest = 1;
10089             rpt_telemetry(myrpt,TUNE,NULL);
10090             return DC_COMPLETEQUIET;
10091          }
10092          return DC_ERROR;        
10093       case 5: /* Long Status */
10094          rpt_telemetry(myrpt,REMLONGSTATUS,NULL);
10095          return DC_COMPLETEQUIET;
10096       case 140: /* Short Status */
10097          rpt_telemetry(myrpt,REMSHORTSTATUS,NULL);
10098          return DC_COMPLETEQUIET;
10099       case 200:
10100       case 201:
10101       case 202:
10102       case 203:
10103       case 204:
10104       case 205:
10105       case 206:
10106       case 207:
10107       case 208:
10108       case 209:
10109       case 210:
10110       case 211:
10111       case 212:
10112       case 213:
10113       case 214:
10114       case 215:
10115          do_dtmf_local(myrpt,remdtmfstr[p - 200]);
10116          return DC_COMPLETEQUIET;
10117       default:
10118          break;
10119    }
10120    return DC_INDETERMINATE;
10121 }

static int function_status ( struct rpt myrpt,
char *  param,
char *  digitbuf,
int  command_source,
struct rpt_link mylink 
) [static]

Definition at line 6273 of file app_rpt.c.

References DC_COMPLETE, DC_ERROR, DC_INDETERMINATE, ID, ID1, myatoi(), rpt::p, rpt_telemetry(), rpt::s, STATS_TIME, STATS_TIME_LOCAL, STATS_VERSION, rpt::sysstate_cur, sysstate::txdisable, and sysstate::userfundisable.

06274 {
06275 
06276    if (!param)
06277       return DC_ERROR;
06278 
06279    if ((myrpt->p.s[myrpt->p.sysstate_cur].txdisable) || (myrpt->p.s[myrpt->p.sysstate_cur].userfundisable))
06280       return DC_ERROR;
06281 
06282    if(debug)
06283       printf("@@@@ status param = %s, digitbuf = %s\n", (param)? param : "(null)", digitbuf);
06284    
06285    switch(myatoi(param)){
06286       case 1: /* System ID */
06287          rpt_telemetry(myrpt, ID1, NULL);
06288          return DC_COMPLETE;
06289       case 2: /* System Time */
06290          rpt_telemetry(myrpt, STATS_TIME, NULL);
06291          return DC_COMPLETE;
06292       case 3: /* app_rpt.c version */
06293          rpt_telemetry(myrpt, STATS_VERSION, NULL);
06294          return DC_COMPLETE;
06295       case 11: /* System ID (local only)*/
06296           rpt_telemetry(myrpt, ID , NULL);
06297             return DC_COMPLETE;
06298         case 12: /* System Time (local only)*/
06299             rpt_telemetry(myrpt, STATS_TIME_LOCAL, NULL);
06300             return DC_COMPLETE;
06301       default:
06302          return DC_ERROR;
06303    }
06304    return DC_INDETERMINATE;
06305 }

static int get_mem_set ( struct rpt myrpt,
char *  digitbuf 
) [static]

Definition at line 9579 of file app_rpt.c.

References ast_log(), rpt::freq, LOG_NOTICE, retreive_memory(), and setrem().

Referenced by channel_steer(), and function_remote().

09580 {
09581    int res=0;
09582    if(debug)ast_log(LOG_NOTICE," digitbuf=%s\n", digitbuf);
09583    res = retreive_memory(myrpt, digitbuf);
09584    if(!res)res=setrem(myrpt); 
09585    if(debug)ast_log(LOG_NOTICE," freq=%s  res=%i\n", myrpt->freq, res);
09586    return res;
09587 }

static int get_wait_interval ( struct rpt myrpt,
int  type 
) [static]

Definition at line 3848 of file app_rpt.c.

References ast_free, ast_strdup, ast_variable_retrieve(), rpt::cfg, DLY_CALLTERM, DLY_COMP, DLY_ID, DLY_LINKUNKEY, DLY_PARROT, DLY_TELEM, DLY_UNKEY, rpt::name, and retrieve_astcfgint().

Referenced by rpt_tele_thread(), and wait_interval().

03849 {
03850         int interval;
03851         char *wait_times;
03852         char *wait_times_save;
03853                                                                                                                   
03854         wait_times_save = NULL;
03855         wait_times = (char *) ast_variable_retrieve(myrpt->cfg, myrpt->name, "wait_times");
03856                                                                                                                   
03857         if(wait_times){
03858                 wait_times_save = ast_strdup(wait_times);
03859                 if(!wait_times_save)
03860          return 0;
03861                 
03862         }
03863                                                                                                                   
03864         switch(type){
03865                 case DLY_TELEM:
03866                         if(wait_times)
03867                                 interval = retrieve_astcfgint(myrpt,wait_times_save, "telemwait", 500, 5000, 1000);
03868                         else
03869                                 interval = 1000;
03870                         break;
03871                                                                                                                   
03872                 case DLY_ID:
03873                         if(wait_times)
03874                                 interval = retrieve_astcfgint(myrpt,wait_times_save, "idwait",250,5000,500);
03875                         else
03876                                 interval = 500;
03877                         break;
03878                                                                                                                   
03879                 case DLY_UNKEY:
03880                         if(wait_times)
03881                                 interval = retrieve_astcfgint(myrpt,wait_times_save, "unkeywait",50,5000,1000);
03882                         else
03883                                 interval = 1000;
03884                         break;
03885                                                                                                                   
03886                 case DLY_LINKUNKEY:
03887                         if(wait_times)
03888                                 interval = retrieve_astcfgint(myrpt,wait_times_save, "linkunkeywait",500,5000,1000);
03889                         else
03890                                 interval = 1000;
03891                         break;
03892                                                                                                                   
03893                 case DLY_CALLTERM:
03894                         if(wait_times)
03895                                 interval = retrieve_astcfgint(myrpt,wait_times_save, "calltermwait",500,5000,1500);
03896                         else
03897                                 interval = 1500;
03898                         break;
03899                                                                                                                   
03900                 case DLY_COMP:
03901                         if(wait_times)
03902                                 interval = retrieve_astcfgint(myrpt,wait_times_save, "compwait",500,5000,200);
03903                         else
03904                                 interval = 200;
03905                         break;
03906                                                                                                                   
03907                 case DLY_PARROT:
03908                         if(wait_times)
03909                                 interval = retrieve_astcfgint(myrpt,wait_times_save, "parrotwait",500,5000,200);
03910                         else
03911                                 interval = 200;
03912                         break;
03913                                                                                                                   
03914                 default:
03915          interval = 0;
03916          break;
03917         }
03918    ast_free(wait_times_save);
03919    return interval;
03920 }                                                                                                                  

static char* handle_cli_cmd ( struct ast_cli_entry e,
int  cmd,
struct ast_cli_args a 
) [static]

Definition at line 3439 of file app_rpt.c.

References ast_cli_args::argc, ast_cli_args::argv, CLI_GENERATE, CLI_INIT, ast_cli_entry::command, ast_cli_args::fd, res2cli(), rpt_do_cmd(), and ast_cli_entry::usage.

03441 {
03442         switch (cmd) {
03443         case CLI_INIT:
03444                 e->command = "rpt cmd";
03445                 e->usage = cmd_usage;
03446                 return NULL;
03447         case CLI_GENERATE:
03448                 return NULL;
03449    }
03450    return res2cli(rpt_do_cmd(a->fd,a->argc,a->argv));
03451 }

static char* handle_cli_debug ( struct ast_cli_entry e,
int  cmd,
struct ast_cli_args a 
) [static]

Definition at line 3298 of file app_rpt.c.

References ast_cli_args::argc, ast_cli_args::argv, CLI_GENERATE, CLI_INIT, ast_cli_entry::command, ast_cli_args::fd, res2cli(), rpt_do_debug(), and ast_cli_entry::usage.

03300 {
03301         switch (cmd) {
03302         case CLI_INIT:
03303                 e->command = "rpt debug level";
03304                 e->usage = debug_usage;
03305                 return NULL;
03306         case CLI_GENERATE:
03307                 return NULL;
03308    }
03309    return res2cli(rpt_do_debug(a->fd, a->argc, a->argv));
03310 }

static char* handle_cli_dump ( struct ast_cli_entry e,
int  cmd,
struct ast_cli_args a 
) [static]

Definition at line 3312 of file app_rpt.c.

References ast_cli_args::argc, ast_cli_args::argv, CLI_GENERATE, CLI_INIT, ast_cli_entry::command, ast_cli_args::fd, res2cli(), rpt_do_dump(), and ast_cli_entry::usage.

03314 {
03315         switch (cmd) {
03316         case CLI_INIT:
03317                 e->command = "rpt dump level";
03318                 e->usage = dump_usage;
03319                 return NULL;
03320         case CLI_GENERATE:
03321                 return NULL;
03322    }
03323    return res2cli(rpt_do_dump(a->fd,a->argc,a->argv));
03324 }

static char* handle_cli_fun ( struct ast_cli_entry e,
int  cmd,
struct ast_cli_args a 
) [static]

Definition at line 3411 of file app_rpt.c.

References ast_cli_args::argc, ast_cli_args::argv, CLI_GENERATE, CLI_INIT, ast_cli_entry::command, ast_cli_args::fd, res2cli(), rpt_do_fun(), and ast_cli_entry::usage.

03413 {
03414         switch (cmd) {
03415         case CLI_INIT:
03416                 e->command = "rpt fun";
03417                 e->usage = fun_usage;
03418                 return NULL;
03419         case CLI_GENERATE:
03420                 return NULL;
03421    }
03422    return res2cli(rpt_do_fun(a->fd,a->argc,a->argv));
03423 }

static char* handle_cli_fun1 ( struct ast_cli_entry e,
int  cmd,
struct ast_cli_args a 
) [static]

Definition at line 3425 of file app_rpt.c.

References ast_cli_args::argc, ast_cli_args::argv, CLI_GENERATE, CLI_INIT, ast_cli_entry::command, ast_cli_args::fd, res2cli(), rpt_do_fun1(), and ast_cli_entry::usage.

03427 {
03428         switch (cmd) {
03429         case CLI_INIT:
03430                 e->command = "rpt fun1";
03431                 e->usage = fun_usage;
03432                 return NULL;
03433         case CLI_GENERATE:
03434                 return NULL;
03435    }
03436    return res2cli(rpt_do_fun1(a->fd,a->argc,a->argv));
03437 }

static char* handle_cli_local_nodes ( struct ast_cli_entry e,
int  cmd,
struct ast_cli_args a 
) [static]

Definition at line 3355 of file app_rpt.c.

References ast_cli_args::argc, ast_cli_args::argv, CLI_GENERATE, CLI_INIT, ast_cli_entry::command, ast_cli_args::fd, res2cli(), rpt_do_local_nodes(), and ast_cli_entry::usage.

03357 {
03358         switch (cmd) {
03359         case CLI_INIT:
03360                 e->command = "rpt localnodes";
03361                 e->usage = usage_local_nodes;
03362                 return NULL;
03363         case CLI_GENERATE:
03364                 return NULL;
03365    }
03366    return res2cli(rpt_do_local_nodes(a->fd,a->argc,a->argv));
03367 }

static char* handle_cli_lstats ( struct ast_cli_entry e,
int  cmd,
struct ast_cli_args a 
) [static]

Definition at line 3369 of file app_rpt.c.

References ast_cli_args::argc, ast_cli_args::argv, CLI_GENERATE, CLI_INIT, ast_cli_entry::command, ast_cli_args::fd, res2cli(), rpt_do_lstats(), and ast_cli_entry::usage.

03371 {
03372         switch (cmd) {
03373         case CLI_INIT:
03374                 e->command = "rpt lstats";
03375                 e->usage = dump_lstats;
03376                 return NULL;
03377         case CLI_GENERATE:
03378                 return NULL;
03379    }
03380    return res2cli(rpt_do_lstats(a->fd,a->argc,a->argv));
03381 }

static char* handle_cli_nodes ( struct ast_cli_entry e,
int  cmd,
struct ast_cli_args a 
) [static]

Definition at line 3341 of file app_rpt.c.

References ast_cli_args::argc, ast_cli_args::argv, CLI_GENERATE, CLI_INIT, ast_cli_entry::command, ast_cli_args::fd, res2cli(), rpt_do_nodes(), and ast_cli_entry::usage.

03343 {
03344         switch (cmd) {
03345         case CLI_INIT:
03346                 e->command = "rpt nodes";
03347                 e->usage = dump_nodes;
03348                 return NULL;
03349         case CLI_GENERATE:
03350                 return NULL;
03351    }
03352    return res2cli(rpt_do_nodes(a->fd,a->argc,a->argv));
03353 }

static char* handle_cli_reload ( struct ast_cli_entry e,
int  cmd,
struct ast_cli_args a 
) [static]

Definition at line 3383 of file app_rpt.c.

References ast_cli_args::argc, ast_cli_args::argv, CLI_GENERATE, CLI_INIT, ast_cli_entry::command, ast_cli_args::fd, res2cli(), rpt_do_reload(), and ast_cli_entry::usage.

03385 {
03386         switch (cmd) {
03387         case CLI_INIT:
03388                 e->command = "rpt reload";
03389                 e->usage = reload_usage;
03390                 return NULL;
03391         case CLI_GENERATE:
03392                 return NULL;
03393    }
03394    return res2cli(rpt_do_reload(a->fd,a->argc,a->argv));
03395 }

static char* handle_cli_restart ( struct ast_cli_entry e,
int  cmd,
struct ast_cli_args a 
) [static]

Definition at line 3397 of file app_rpt.c.

References ast_cli_args::argc, ast_cli_args::argv, CLI_GENERATE, CLI_INIT, ast_cli_entry::command, ast_cli_args::fd, res2cli(), rpt_do_restart(), and ast_cli_entry::usage.

03399 {
03400         switch (cmd) {
03401         case CLI_INIT:
03402                 e->command = "rpt restart";
03403                 e->usage = restart_usage;
03404                 return NULL;
03405         case CLI_GENERATE:
03406                 return NULL;
03407    }
03408    return res2cli(rpt_do_restart(a->fd,a->argc,a->argv));
03409 }

static char* handle_cli_stats ( struct ast_cli_entry e,
int  cmd,
struct ast_cli_args a 
) [static]

Definition at line 3327 of file app_rpt.c.

References ast_cli_args::argc, ast_cli_args::argv, CLI_GENERATE, CLI_INIT, ast_cli_entry::command, ast_cli_args::fd, res2cli(), rpt_do_stats(), and ast_cli_entry::usage.

03329 {
03330         switch (cmd) {
03331         case CLI_INIT:
03332                 e->command = "rpt stats";
03333                 e->usage = dump_stats;
03334                 return NULL;
03335         case CLI_GENERATE:
03336                 return NULL;
03337    }
03338    return res2cli(rpt_do_stats(a->fd,a->argc,a->argv));
03339 }

static void handle_link_data ( struct rpt myrpt,
struct rpt_link mylink,
char *  str 
) [static]

Definition at line 6680 of file app_rpt.c.

References rpt::archivedir, ast_canmatch_extension(), ast_exists_extension(), AST_FRAME_TEXT, ast_log(), ast_matchmore_extension(), ast_softhangup(), AST_SOFTHANGUP_DEV, ast_write(), rpt::calldigittimer, rpt::callmode, rpt_link::chan, rpt::cidx, collect_function_digits(), rpt::dailyexecdcommands, ast_frame::data, ast_frame::datalen, DC_COMPLETE, DC_COMPLETEQUIET, DC_ERROR, DC_INDETERMINATE, DC_REQ_FLUSH, rpt_link::disced, do_dtmf_local(), do_dtmf_phone(), donodelog(), dtmfstr, rpt::endchar, rpt::exten, ast_frame::frametype, func_xlat(), rpt::funcchar, rpt::inpadtest, rpt_topkey::keyed, rpt::keyed, rpt::lastdtmfcommand, rpt::lastkeyedtime, rpt_link::linklist, rpt_link::linklistreceived, rpt::links, rpt::lock, LOG_NOTICE, LOG_WARNING, ast_frame::mallocd, rpt_link::max_retries, MAXDTMF, mdc1200_notify(), rpt::mydtmf, rpt_link::name, rpt::name, rpt_link::newkey, rpt_link::next, rpt_topkey::node, ast_frame::offset, rpt::outxlat, rpt::p, rpt::patchcontext, rpt::patchquiet, rpt::pchannel, PROC, rpt::propagate_dtmf, rpt::propagate_phonedtmf, ast_frame::ptr, rpt::rem_dtmf_time, rpt::rem_dtmfbuf, rpt::rem_dtmfidx, rpt_link::retries, rpt_mutex_lock, rpt_mutex_unlock, rpt_telemetry(), ast_frame::samples, seq, SOURCE_LNK, rpt::stopgen, ast_frame::subclass, rpt_topkey::timesince, rpt::topkey, TOPKEYMAXSTR, TOPKEYN, rpt::topkeystate, and rpt::totalexecdcommands.

Referenced by rpt().

06682 {
06683 /* XXX ATTENTION: if you change the size of these arrays you MUST
06684  * change the limits in corresponding sscanf() calls below. */
06685 char  tmp[512],tmp1[512],cmd[300] = "",dest[300],src[300],c;
06686 int   i,seq, res, ts;
06687 struct rpt_link *l;
06688 struct   ast_frame wf;
06689 
06690    wf.frametype = AST_FRAME_TEXT;
06691    wf.subclass = 0;
06692    wf.offset = 0;
06693    wf.mallocd = 0;
06694    wf.datalen = strlen(str) + 1;
06695    wf.samples = 0;
06696    /* put string in our buffer */
06697    strncpy(tmp,str,sizeof(tmp) - 1);
06698 
06699         if (!strcmp(tmp,discstr))
06700         {
06701                 mylink->disced = 1;
06702       mylink->retries = mylink->max_retries + 1;
06703                 ast_softhangup(mylink->chan,AST_SOFTHANGUP_DEV);
06704                 return;
06705         }
06706         if (!strcmp(tmp,newkeystr))
06707         {
06708       mylink->newkey = 1;
06709                 return;
06710         }
06711    if (tmp[0] == 'L')
06712    {
06713       rpt_mutex_lock(&myrpt->lock);
06714       strcpy(mylink->linklist,tmp + 2);
06715       time(&mylink->linklistreceived);
06716       rpt_mutex_unlock(&myrpt->lock);
06717       if (debug > 6) ast_log(LOG_NOTICE,"@@@@ node %s received node list %s from node %s\n",
06718          myrpt->name,tmp,mylink->name);
06719       return;
06720    }
06721    if (tmp[0] == 'K')
06722    {
06723       if (sscanf(tmp, "%299s %299s %299s %30d %30d", cmd, dest, src, &seq, &ts) != 5)
06724       {
06725          ast_log(LOG_WARNING, "Unable to parse keying string %s\n",str);
06726          return;
06727       }
06728       if (dest[0] == '0')
06729       {
06730          strcpy(dest,myrpt->name);
06731       }     
06732       /* if not for me, redistribute to all links */
06733       if (strcmp(dest,myrpt->name))
06734       {
06735          l = myrpt->links.next;
06736          /* see if this is one in list */
06737          while(l != &myrpt->links)
06738          {
06739             if (l->name[0] == '0') 
06740             {
06741                l = l->next;
06742                continue;
06743             }
06744             /* dont send back from where it came */
06745             if ((l == mylink) || (!strcmp(l->name,mylink->name)))
06746             {
06747                l = l->next;
06748                continue;
06749             }
06750             /* if it is, send it and we're done */
06751             if (!strcmp(l->name,dest))
06752             {
06753                /* send, but not to src */
06754                if (strcmp(l->name,src)) {
06755                   wf.data.ptr = str;
06756                   if (l->chan) ast_write(l->chan,&wf);
06757                }
06758                return;
06759             }
06760             l = l->next;
06761          }
06762       }
06763       /* if not for me, or is broadcast, redistribute to all links */
06764       if ((strcmp(dest,myrpt->name)) || (dest[0] == '*'))
06765       {
06766          l = myrpt->links.next;
06767          /* otherwise, send it to all of em */
06768          while(l != &myrpt->links)
06769          {
06770             if (l->name[0] == '0') 
06771             {
06772                l = l->next;
06773                continue;
06774             }
06775             /* dont send back from where it came */
06776             if ((l == mylink) || (!strcmp(l->name,mylink->name)))
06777             {
06778                l = l->next;
06779                continue;
06780             }
06781             /* send, but not to src */
06782             if (strcmp(l->name,src)) {
06783                wf.data.ptr = str;
06784                if (l->chan) ast_write(l->chan,&wf); 
06785             }
06786             l = l->next;
06787          }
06788       }
06789       /* if not for me, end here */
06790       if (strcmp(dest,myrpt->name) && (dest[0] != '*')) return;
06791       if (cmd[1] == '?')
06792       {
06793          time_t now;
06794          int n = 0;
06795 
06796          time(&now);
06797          if (myrpt->lastkeyedtime)
06798          {
06799             n = (int)(now - myrpt->lastkeyedtime);
06800          }
06801          sprintf(tmp1,"K %s %s %d %d",src,myrpt->name,myrpt->keyed,n);
06802          wf.data.ptr = tmp1;
06803          wf.datalen = strlen(tmp1) + 1;
06804          if (mylink->chan) ast_write(mylink->chan,&wf); 
06805          return;
06806       }
06807       if (myrpt->topkeystate != 1) return;
06808       rpt_mutex_lock(&myrpt->lock);
06809       for(i = 0; i < TOPKEYN; i++)
06810       {
06811          if (!strcmp(myrpt->topkey[i].node,src)) break;
06812       }
06813       if (i >= TOPKEYN)
06814       {
06815          for(i = 0; i < TOPKEYN; i++)
06816          {
06817             if (!myrpt->topkey[i].node[0]) break;
06818          }
06819       }
06820       if (i < TOPKEYN)
06821       {
06822          strncpy(myrpt->topkey[i].node,src,TOPKEYMAXSTR - 1);
06823          myrpt->topkey[i].timesince = ts;
06824          myrpt->topkey[i].keyed = seq;
06825       }
06826       rpt_mutex_unlock(&myrpt->lock);
06827       return;
06828    }
06829    if (tmp[0] == 'I')
06830    {
06831       /* XXX WARNING: be very careful with the limits on the folowing
06832        * sscanf() call, make sure they match the values defined above */
06833       if (sscanf(tmp,"%299s %299s %30x",cmd,src,&seq) != 3)
06834       {
06835          ast_log(LOG_WARNING, "Unable to parse ident string %s\n",str);
06836          return;
06837       }
06838       mdc1200_notify(myrpt,src,seq);
06839       strcpy(dest,"*");
06840    }
06841    else
06842    {
06843       /* XXX WARNING: be very careful with the limits on the folowing
06844        * sscanf() call, make sure they match the values defined above */
06845       if (sscanf(tmp,"%299s %299s %299s %30d %1c",cmd,dest,src,&seq,&c) != 5)
06846       {
06847          ast_log(LOG_WARNING, "Unable to parse link string %s\n",str);
06848          return;
06849       }
06850       if (strcmp(cmd,"D"))
06851       {
06852          ast_log(LOG_WARNING, "Unable to parse link string %s\n",str);
06853          return;
06854       }
06855    }
06856    if (dest[0] == '0')
06857    {
06858       strcpy(dest,myrpt->name);
06859    }     
06860 
06861    /* if not for me, redistribute to all links */
06862    if (strcmp(dest,myrpt->name))
06863    {
06864       l = myrpt->links.next;
06865       /* see if this is one in list */
06866       while(l != &myrpt->links)
06867       {
06868          if (l->name[0] == '0') 
06869          {
06870             l = l->next;
06871             continue;
06872          }
06873          /* dont send back from where it came */
06874          if ((l == mylink) || (!strcmp(l->name,mylink->name)))
06875          {
06876             l = l->next;
06877             continue;
06878          }
06879          /* if it is, send it and we're done */
06880          if (!strcmp(l->name,dest))
06881          {
06882             /* send, but not to src */
06883             if (strcmp(l->name,src)) {
06884                wf.data.ptr = str;
06885                if (l->chan) ast_write(l->chan,&wf);
06886             }
06887             return;
06888          }
06889          l = l->next;
06890       }
06891       l = myrpt->links.next;
06892       /* otherwise, send it to all of em */
06893       while(l != &myrpt->links)
06894       {
06895          if (l->name[0] == '0') 
06896          {
06897             l = l->next;
06898             continue;
06899          }
06900          /* dont send back from where it came */
06901          if ((l == mylink) || (!strcmp(l->name,mylink->name)))
06902          {
06903             l = l->next;
06904             continue;
06905          }
06906          /* send, but not to src */
06907          if (strcmp(l->name,src)) {
06908             wf.data.ptr = str;
06909             if (l->chan) ast_write(l->chan,&wf); 
06910          }
06911          l = l->next;
06912       }
06913       return;
06914    }
06915    if (myrpt->p.archivedir)
06916    {
06917       char dtmfstr[100];
06918 
06919       sprintf(dtmfstr,"DTMF,%s,%c",mylink->name,c);
06920       donodelog(myrpt,dtmfstr);
06921    }
06922    c = func_xlat(myrpt,c,&myrpt->p.outxlat);
06923    if (!c) return;
06924    rpt_mutex_lock(&myrpt->lock);
06925    if (c == myrpt->p.endchar) myrpt->stopgen = 1;
06926    if (myrpt->callmode == 1)
06927    {
06928       myrpt->exten[myrpt->cidx++] = c;
06929       myrpt->exten[myrpt->cidx] = 0;
06930       /* if this exists */
06931       if (ast_exists_extension(myrpt->pchannel,myrpt->patchcontext,myrpt->exten,1,NULL))
06932       {
06933          /* if this really it, end now */
06934          if (!ast_matchmore_extension(myrpt->pchannel,myrpt->patchcontext,
06935             myrpt->exten,1,NULL)) 
06936          {
06937             myrpt->callmode = 2;
06938             if(!myrpt->patchquiet)
06939             {
06940                rpt_mutex_unlock(&myrpt->lock);
06941                rpt_telemetry(myrpt,PROC,NULL); 
06942                rpt_mutex_lock(&myrpt->lock);
06943             }
06944          }
06945          else /* othewise, reset timer */
06946          {
06947             myrpt->calldigittimer = 1;
06948          }
06949       }
06950       /* if can continue, do so */
06951       if (!ast_canmatch_extension(myrpt->pchannel,myrpt->patchcontext,myrpt->exten,1,NULL))
06952       {
06953          /* call has failed, inform user */
06954          myrpt->callmode = 4;
06955       }
06956    }
06957    if ((!myrpt->inpadtest) &&(c == myrpt->p.funcchar))
06958    {
06959       myrpt->rem_dtmfidx = 0;
06960       myrpt->rem_dtmfbuf[myrpt->rem_dtmfidx] = 0;
06961       time(&myrpt->rem_dtmf_time);
06962       rpt_mutex_unlock(&myrpt->lock);
06963       return;
06964    } 
06965    else if (myrpt->rem_dtmfidx < 0)
06966    {
06967       if ((myrpt->callmode == 2) || (myrpt->callmode == 3))
06968       {
06969          myrpt->mydtmf = c;
06970       }
06971       if (myrpt->p.propagate_dtmf) do_dtmf_local(myrpt,c);
06972       if (myrpt->p.propagate_phonedtmf) do_dtmf_phone(myrpt,mylink,c);
06973       rpt_mutex_unlock(&myrpt->lock);
06974       return;
06975    }
06976    else if (((myrpt->inpadtest) || (c != myrpt->p.endchar)) && (myrpt->rem_dtmfidx >= 0))
06977    {
06978       time(&myrpt->rem_dtmf_time);
06979       if (myrpt->rem_dtmfidx < MAXDTMF)
06980       {
06981          myrpt->rem_dtmfbuf[myrpt->rem_dtmfidx++] = c;
06982          myrpt->rem_dtmfbuf[myrpt->rem_dtmfidx] = 0;
06983          
06984          rpt_mutex_unlock(&myrpt->lock);
06985          strncpy(cmd, myrpt->rem_dtmfbuf, sizeof(cmd) - 1);
06986          res = collect_function_digits(myrpt, cmd, SOURCE_LNK, mylink);
06987          rpt_mutex_lock(&myrpt->lock);
06988          
06989          switch(res){
06990 
06991             case DC_INDETERMINATE:
06992                break;
06993             
06994             case DC_REQ_FLUSH:
06995                myrpt->rem_dtmfidx = 0;
06996                myrpt->rem_dtmfbuf[0] = 0;
06997                break;
06998             
06999             
07000             case DC_COMPLETE:
07001             case DC_COMPLETEQUIET:
07002                myrpt->totalexecdcommands++;
07003                myrpt->dailyexecdcommands++;
07004                strncpy(myrpt->lastdtmfcommand, cmd, MAXDTMF-1);
07005                myrpt->lastdtmfcommand[MAXDTMF-1] = '\0';
07006                myrpt->rem_dtmfbuf[0] = 0;
07007                myrpt->rem_dtmfidx = -1;
07008                myrpt->rem_dtmf_time = 0;
07009                break;
07010             
07011             case DC_ERROR:
07012             default:
07013                myrpt->rem_dtmfbuf[0] = 0;
07014                myrpt->rem_dtmfidx = -1;
07015                myrpt->rem_dtmf_time = 0;
07016                break;
07017          }
07018       }
07019 
07020    }
07021    rpt_mutex_unlock(&myrpt->lock);
07022    return;
07023 }

static void handle_link_phone_dtmf ( struct rpt myrpt,
struct rpt_link mylink,
char  c 
) [static]

Definition at line 7025 of file app_rpt.c.

References rpt::archivedir, ast_canmatch_extension(), ast_exists_extension(), ast_matchmore_extension(), rpt::calldigittimer, rpt::callmode, rpt::cidx, rpt::cmdnode, collect_function_digits(), COMPLETE, rpt::dailyexecdcommands, DC_COMPLETE, DC_COMPLETEQUIET, DC_DOKEY, DC_ERROR, DC_INDETERMINATE, DC_REQ_FLUSH, donodelog(), rpt::dtmfbuf, rpt::dtmfidx, rpt::endchar, rpt::exten, rpt::funcchar, rpt::inpadtest, rpt::lastdtmfcommand, rpt_link::lastrealrx, rpt_link::lastrx, rpt::lock, MAXDTMF, rpt::mydtmf, rpt_link::name, rpt::p, rpt::patchcontext, rpt::patchquiet, rpt::pchannel, rpt_link::phonemode, PROC, rpt::rem_dtmf_time, rpt::rem_dtmfbuf, rpt::rem_dtmfidx, rpt_mutex_lock, rpt_mutex_unlock, rpt_telemetry(), send_link_dtmf(), SOURCE_ALT, SOURCE_DPHONE, SOURCE_LNK, SOURCE_PHONE, rpt::stopgen, and rpt::totalexecdcommands.

Referenced by rpt().

07027 {
07028 
07029 char  cmd[300];
07030 int   res;
07031 
07032    if (myrpt->p.archivedir)
07033    {
07034       char str[100];
07035 
07036       sprintf(str,"DTMF(P),%s,%c",mylink->name,c);
07037       donodelog(myrpt,str);
07038    }
07039    rpt_mutex_lock(&myrpt->lock);
07040 
07041    if (mylink->phonemode == 3) /*If in simplex dumb phone mode */
07042    {
07043       if(c == myrpt->p.endchar) /* If end char */
07044       {
07045          mylink->lastrealrx = 0; /* Keying state = off */
07046          rpt_mutex_unlock(&myrpt->lock);
07047          return;
07048       }
07049 
07050       if(c == myrpt->p.funcchar) /* If lead-in char */
07051       {
07052          mylink->lastrealrx = !mylink->lastrealrx; /* Toggle keying state */
07053          rpt_mutex_unlock(&myrpt->lock);
07054          return;
07055       }
07056    }
07057    else
07058    {
07059       if (c == myrpt->p.endchar)
07060       {
07061          if (mylink->lastrx)
07062          {
07063             mylink->lastrealrx = 0;
07064             rpt_mutex_unlock(&myrpt->lock);
07065             return;
07066          }
07067          myrpt->stopgen = 1;
07068          if (myrpt->cmdnode[0])
07069          {
07070             myrpt->cmdnode[0] = 0;
07071             myrpt->dtmfidx = -1;
07072             myrpt->dtmfbuf[0] = 0;
07073             rpt_mutex_unlock(&myrpt->lock);
07074             rpt_telemetry(myrpt,COMPLETE,NULL);
07075             return;
07076          }
07077       }
07078    }
07079    if (myrpt->cmdnode[0])
07080    {
07081       rpt_mutex_unlock(&myrpt->lock);
07082       send_link_dtmf(myrpt,c);
07083       return;
07084    }
07085    if (myrpt->callmode == 1)
07086    {
07087       myrpt->exten[myrpt->cidx++] = c;
07088       myrpt->exten[myrpt->cidx] = 0;
07089       /* if this exists */
07090       if (ast_exists_extension(myrpt->pchannel,myrpt->patchcontext,myrpt->exten,1,NULL))
07091       {
07092          /* if this really it, end now */
07093          if (!ast_matchmore_extension(myrpt->pchannel,myrpt->patchcontext,
07094             myrpt->exten,1,NULL)) 
07095          {
07096             myrpt->callmode = 2;
07097             if(!myrpt->patchquiet)
07098             {
07099                rpt_mutex_unlock(&myrpt->lock);
07100                rpt_telemetry(myrpt,PROC,NULL); 
07101                rpt_mutex_lock(&myrpt->lock);
07102             }
07103          }
07104          else /* othewise, reset timer */
07105          {
07106             myrpt->calldigittimer = 1;
07107          }
07108       }
07109       /* if can continue, do so */
07110       if (!ast_canmatch_extension(myrpt->pchannel,myrpt->patchcontext,myrpt->exten,1,NULL))
07111       {
07112          /* call has failed, inform user */
07113          myrpt->callmode = 4;
07114       }
07115    }
07116    if ((myrpt->callmode == 2) || (myrpt->callmode == 3))
07117    {
07118       myrpt->mydtmf = c;
07119    }
07120    if ((!myrpt->inpadtest) && (c == myrpt->p.funcchar))
07121    {
07122       myrpt->rem_dtmfidx = 0;
07123       myrpt->rem_dtmfbuf[myrpt->rem_dtmfidx] = 0;
07124       time(&myrpt->rem_dtmf_time);
07125       rpt_mutex_unlock(&myrpt->lock);
07126       return;
07127    } 
07128    else if (((myrpt->inpadtest) || (c != myrpt->p.endchar)) && (myrpt->rem_dtmfidx >= 0))
07129    {
07130       time(&myrpt->rem_dtmf_time);
07131       if (myrpt->rem_dtmfidx < MAXDTMF)
07132       {
07133          myrpt->rem_dtmfbuf[myrpt->rem_dtmfidx++] = c;
07134          myrpt->rem_dtmfbuf[myrpt->rem_dtmfidx] = 0;
07135          
07136          rpt_mutex_unlock(&myrpt->lock);
07137          strncpy(cmd, myrpt->rem_dtmfbuf, sizeof(cmd) - 1);
07138          switch(mylink->phonemode)
07139          {
07140              case 1:
07141             res = collect_function_digits(myrpt, cmd, 
07142                SOURCE_PHONE, mylink);
07143             break;
07144              case 2:
07145             res = collect_function_digits(myrpt, cmd, 
07146                SOURCE_DPHONE,mylink);
07147             break;
07148              case 4:
07149             res = collect_function_digits(myrpt, cmd, 
07150                SOURCE_ALT,mylink);
07151             break;
07152              default:
07153             res = collect_function_digits(myrpt, cmd, 
07154                SOURCE_LNK, mylink);
07155             break;
07156          }
07157 
07158          rpt_mutex_lock(&myrpt->lock);
07159          
07160          switch(res){
07161 
07162             case DC_INDETERMINATE:
07163                break;
07164             
07165             case DC_DOKEY:
07166                mylink->lastrealrx = 1;
07167                break;
07168             
07169             case DC_REQ_FLUSH:
07170                myrpt->rem_dtmfidx = 0;
07171                myrpt->rem_dtmfbuf[0] = 0;
07172                break;
07173             
07174             
07175             case DC_COMPLETE:
07176             case DC_COMPLETEQUIET:
07177                myrpt->totalexecdcommands++;
07178                myrpt->dailyexecdcommands++;
07179                strncpy(myrpt->lastdtmfcommand, cmd, MAXDTMF-1);
07180                myrpt->lastdtmfcommand[MAXDTMF-1] = '\0';
07181                myrpt->rem_dtmfbuf[0] = 0;
07182                myrpt->rem_dtmfidx = -1;
07183                myrpt->rem_dtmf_time = 0;
07184                break;
07185             
07186             case DC_ERROR:
07187             default:
07188                myrpt->rem_dtmfbuf[0] = 0;
07189                myrpt->rem_dtmfidx = -1;
07190                myrpt->rem_dtmf_time = 0;
07191                break;
07192          }
07193       }
07194 
07195    }
07196    rpt_mutex_unlock(&myrpt->lock);
07197    return;
07198 }

static int handle_remote_data ( struct rpt myrpt,
char *  str 
) [static]

Definition at line 10238 of file app_rpt.c.

References rpt::archivedir, ast_log(), COMPLETE, donodelog(), dtmfstr, func_xlat(), handle_remote_dtmf_digit(), LOG_WARNING, mdc1200_notify(), rpt::name, rpt::newkey, rpt::outxlat, rpt::p, rpt_telemetry(), and seq.

Referenced by rpt_exec().

10239 {
10240 /* XXX ATTENTION: if you change the size of these arrays you MUST
10241  * change the limits in corresponding sscanf() calls below. */
10242 char  tmp[300],cmd[300],dest[300],src[300],c;
10243 int   seq,res;
10244 
10245    /* put string in our buffer */
10246    strncpy(tmp,str,sizeof(tmp) - 1);
10247    if (!strcmp(tmp,discstr)) return 0;
10248         if (!strcmp(tmp,newkeystr))
10249         {
10250       myrpt->newkey = 1;
10251                 return 0;
10252         }
10253 
10254 #ifndef  DO_NOT_NOTIFY_MDC1200_ON_REMOTE_BASES
10255    if (tmp[0] == 'I')
10256    {
10257       /* XXX WARNING: be very careful with the limits on the folowing
10258        * sscanf() call, make sure they match the values defined above */
10259       if (sscanf(tmp,"%299s %299s %30x",cmd,src,&seq) != 3)
10260       {
10261          ast_log(LOG_WARNING, "Unable to parse ident string %s\n",str);
10262          return 0;
10263       }
10264       mdc1200_notify(myrpt,src,seq);
10265       return 0;
10266    }
10267 #endif
10268    /* XXX WARNING: be very careful with the limits on the folowing
10269     * sscanf() call, make sure they match the values defined above */
10270    if (sscanf(tmp,"%299s %299s %299s %30d %1c",cmd,dest,src,&seq,&c) != 5)
10271    {
10272       ast_log(LOG_WARNING, "Unable to parse link string %s\n",str);
10273       return 0;
10274    }
10275    if (strcmp(cmd,"D"))
10276    {
10277       ast_log(LOG_WARNING, "Unable to parse link string %s\n",str);
10278       return 0;
10279    }
10280    /* if not for me, ignore */
10281    if (strcmp(dest,myrpt->name)) return 0;
10282    if (myrpt->p.archivedir)
10283    {
10284       char dtmfstr[100];
10285 
10286       sprintf(dtmfstr,"DTMF,%c",c);
10287       donodelog(myrpt,dtmfstr);
10288    }
10289    c = func_xlat(myrpt,c,&myrpt->p.outxlat);
10290    if (!c) return(0);
10291    res = handle_remote_dtmf_digit(myrpt,c, NULL, 0);
10292    if (res != 1)
10293       return res;
10294    rpt_telemetry(myrpt,COMPLETE,NULL);
10295    return 0;
10296 }

static int handle_remote_dtmf_digit ( struct rpt myrpt,
char  c,
char *  keyed,
int  phonemode 
) [static]

Definition at line 10124 of file app_rpt.c.

References ast_log(), collect_function_digits(), rpt::dailyexecdcommands, DC_COMPLETE, DC_COMPLETEQUIET, DC_DOKEY, DC_ERROR, DC_INDETERMINATE, DC_REQ_FLUSH, do_dtmf_local(), rpt::dtmf_time_rem, DTMF_TIMEOUT, rpt::dtmfbuf, rpt::dtmfidx, rpt::funcchar, rpt::hfscanmode, rpt::last_activity_time, rpt::lastdtmfcommand, rpt::lock, LOG_NOTICE, MAXDTMF, rpt::p, rpt::propagate_dtmf, rpt_mutex_lock, rpt_mutex_unlock, SOURCE_ALT, SOURCE_DPHONE, SOURCE_PHONE, SOURCE_RMT, stop_scan(), and rpt::totalexecdcommands.

Referenced by handle_remote_data(), handle_remote_phone_dtmf(), and rpt_exec().

10125 {
10126 time_t   now;
10127 int   ret,res = 0,src;
10128 
10129    if(debug > 6)
10130       ast_log(LOG_NOTICE,"c=%c  phonemode=%i  dtmfidx=%i\n",c,phonemode,myrpt->dtmfidx);
10131 
10132    time(&myrpt->last_activity_time);
10133    /* Stop scan mode if in scan mode */
10134    if(myrpt->hfscanmode){
10135       stop_scan(myrpt);
10136       return 0;
10137    }
10138 
10139    time(&now);
10140    /* if timed-out */
10141    if ((myrpt->dtmf_time_rem + DTMF_TIMEOUT) < now)
10142    {
10143       myrpt->dtmfidx = -1;
10144       myrpt->dtmfbuf[0] = 0;
10145       myrpt->dtmf_time_rem = 0;
10146    }
10147    /* if decode not active */
10148    if (myrpt->dtmfidx == -1)
10149    {
10150       /* if not lead-in digit, dont worry */
10151       if (c != myrpt->p.funcchar)
10152       {
10153          if (!myrpt->p.propagate_dtmf)
10154          {
10155             rpt_mutex_lock(&myrpt->lock);
10156             do_dtmf_local(myrpt,c);
10157             rpt_mutex_unlock(&myrpt->lock);
10158          }
10159          return 0;
10160       }
10161       myrpt->dtmfidx = 0;
10162       myrpt->dtmfbuf[0] = 0;
10163       myrpt->dtmf_time_rem = now;
10164       return 0;
10165    }
10166    /* if too many in buffer, start over */
10167    if (myrpt->dtmfidx >= MAXDTMF)
10168    {
10169       myrpt->dtmfidx = 0;
10170       myrpt->dtmfbuf[0] = 0;
10171       myrpt->dtmf_time_rem = now;
10172    }
10173    if (c == myrpt->p.funcchar)
10174    {
10175       /* if star at beginning, or 2 together, erase buffer */
10176       if ((myrpt->dtmfidx < 1) || 
10177          (myrpt->dtmfbuf[myrpt->dtmfidx - 1] == myrpt->p.funcchar))
10178       {
10179          myrpt->dtmfidx = 0;
10180          myrpt->dtmfbuf[0] = 0;
10181          myrpt->dtmf_time_rem = now;
10182          return 0;
10183       }
10184    }
10185    myrpt->dtmfbuf[myrpt->dtmfidx++] = c;
10186    myrpt->dtmfbuf[myrpt->dtmfidx] = 0;
10187    myrpt->dtmf_time_rem = now;
10188    
10189    
10190    src = SOURCE_RMT;
10191    if (phonemode == 2) src = SOURCE_DPHONE;
10192    else if (phonemode) src = SOURCE_PHONE;
10193    else if (phonemode == 4) src = SOURCE_ALT;
10194    ret = collect_function_digits(myrpt, myrpt->dtmfbuf, src, NULL);
10195    
10196    switch(ret){
10197    
10198       case DC_INDETERMINATE:
10199          res = 0;
10200          break;
10201             
10202       case DC_DOKEY:
10203          if (keyed) *keyed = 1;
10204          res = 0;
10205          break;
10206             
10207       case DC_REQ_FLUSH:
10208          myrpt->dtmfidx = 0;
10209          myrpt->dtmfbuf[0] = 0;
10210          res = 0;
10211          break;
10212             
10213             
10214       case DC_COMPLETE:
10215          res = 1;
10216       case DC_COMPLETEQUIET:
10217          myrpt->totalexecdcommands++;
10218          myrpt->dailyexecdcommands++;
10219          strncpy(myrpt->lastdtmfcommand, myrpt->dtmfbuf, MAXDTMF-1);
10220          myrpt->lastdtmfcommand[MAXDTMF-1] = '\0';
10221          myrpt->dtmfbuf[0] = 0;
10222          myrpt->dtmfidx = -1;
10223          myrpt->dtmf_time_rem = 0;
10224          break;
10225             
10226       case DC_ERROR:
10227       default:
10228          myrpt->dtmfbuf[0] = 0;
10229          myrpt->dtmfidx = -1;
10230          myrpt->dtmf_time_rem = 0;
10231          res = 0;
10232          break;
10233    }
10234 
10235    return res;
10236 }

static int handle_remote_phone_dtmf ( struct rpt myrpt,
char  c,
char *  keyed,
int  phonemode 
) [static]

Definition at line 10298 of file app_rpt.c.

References rpt::archivedir, COMPLETE, DC_INDETERMINATE, donodelog(), rpt::endchar, rpt::funcchar, handle_remote_dtmf_digit(), rpt::p, and rpt_telemetry().

Referenced by rpt_exec().

10299 {
10300 int   res;
10301 
10302 
10303    if(phonemode == 3) /* simplex phonemode, funcchar key/unkey toggle */
10304    {
10305       if (keyed && *keyed && ((c == myrpt->p.funcchar) || (c == myrpt->p.endchar)))
10306       {
10307          *keyed = 0; /* UNKEY */
10308          return 0;
10309       }
10310       else if (keyed && !*keyed && (c = myrpt->p.funcchar))
10311       {
10312          *keyed = 1; /* KEY */
10313          return 0;
10314       }
10315    }
10316    else /* endchar unkey */
10317    {
10318 
10319       if (keyed && *keyed && (c == myrpt->p.endchar))
10320       {
10321          *keyed = 0;
10322          return DC_INDETERMINATE;
10323       }
10324    }
10325    if (myrpt->p.archivedir)
10326    {
10327       char str[100];
10328 
10329       sprintf(str,"DTMF(P),%c",c);
10330       donodelog(myrpt,str);
10331    }
10332    res = handle_remote_dtmf_digit(myrpt,c,keyed, phonemode);
10333    if (res != 1)
10334       return res;
10335    rpt_telemetry(myrpt,COMPLETE,NULL);
10336    return 0;
10337 }

static int ic706_pltocode ( char *  str  )  [static]

Definition at line 8758 of file app_rpt.c.

References ast_log(), LOG_NOTICE, and s.

Referenced by set_ic706().

08759 {
08760    int i;
08761    char *s;
08762    int rv=-1;
08763 
08764    s = strchr(str,'.');
08765    i = 0;
08766    if (s) i = atoi(s + 1);
08767    i += atoi(str) * 10;
08768    switch(i)
08769    {
08770        case 670:
08771          rv=0;
08772        case 693:
08773          rv=1;
08774        case 719:
08775          rv=2;
08776        case 744:
08777          rv=3;
08778        case 770:
08779          rv=4;
08780        case 797:
08781          rv=5;
08782        case 825:
08783          rv=6;
08784        case 854:
08785          rv=7;
08786        case 885:
08787          rv=8;
08788        case 915:
08789          rv=9;
08790        case 948:
08791          rv=10;
08792        case 974:
08793          rv=11;
08794        case 1000:
08795          rv=12;
08796        case 1035:
08797          rv=13;
08798        case 1072:
08799          rv=14;
08800        case 1109:
08801          rv=15;
08802        case 1148:
08803          rv=16;
08804        case 1188:
08805          rv=17;
08806        case 1230:
08807          rv=18;
08808        case 1273:
08809          rv=19;
08810        case 1318:
08811          rv=20;
08812        case 1365:
08813          rv=21;
08814        case 1413:
08815          rv=22;
08816        case 1462:
08817          rv=23;
08818        case 1514:
08819          rv=24;
08820        case 1567:
08821          rv=25;
08822        case 1598:
08823          rv=26;
08824        case 1622:
08825          rv=27;
08826        case 1655:
08827          rv=28;      
08828        case 1679:
08829          rv=29;
08830        case 1713:
08831          rv=30;
08832        case 1738:
08833          rv=31;
08834        case 1773:
08835          rv=32;
08836        case 1799:
08837          rv=33;
08838         case 1835:
08839          rv=34;
08840        case 1862:
08841          rv=35;
08842        case 1899:
08843          rv=36;
08844        case 1928:
08845          rv=37;
08846        case 1966:
08847          rv=38;
08848        case 1995:
08849          rv=39;
08850        case 2035:
08851          rv=40;
08852        case 2065:
08853          rv=41;
08854        case 2107:
08855          rv=42;
08856        case 2181:
08857          rv=43;
08858        case 2257:
08859          rv=44;
08860        case 2291:
08861          rv=45;
08862        case 2336:
08863          rv=46;
08864        case 2418:
08865          rv=47;
08866        case 2503:
08867          rv=48;
08868        case 2541:
08869          rv=49;
08870    }
08871    if(debug > 1)
08872       ast_log(LOG_NOTICE,"%i  rv=%i\n",i, rv);
08873 
08874    return rv;
08875 }

static int kenwood_pltocode ( char *  str  )  [static]

Definition at line 7542 of file app_rpt.c.

References s.

Referenced by set_tm271(), and setkenwood().

07543 {
07544 int i;
07545 char *s;
07546 
07547    s = strchr(str,'.');
07548    i = 0;
07549    if (s) i = atoi(s + 1);
07550    i += atoi(str) * 10;
07551    switch(i)
07552    {
07553        case 670:
07554       return 1;
07555        case 719:
07556       return 3;
07557        case 744:
07558       return 4;
07559        case 770:
07560       return 5;
07561        case 797:
07562       return 6;
07563        case 825:
07564       return 7;
07565        case 854:
07566       return 8;
07567        case 885:
07568       return 9;
07569        case 915:
07570       return 10;
07571        case 948:
07572       return 11;
07573        case 974:
07574       return 12;
07575        case 1000:
07576       return 13;
07577        case 1035:
07578       return 14;
07579        case 1072:
07580       return 15;
07581        case 1109:
07582       return 16;
07583        case 1148:
07584       return 17;
07585        case 1188:
07586       return 18;
07587        case 1230:
07588       return 19;
07589        case 1273:
07590       return 20;
07591        case 1318:
07592       return 21;
07593        case 1365:
07594       return 22;
07595        case 1413:
07596       return 23;
07597        case 1462:
07598       return 24;
07599        case 1514:
07600       return 25;
07601        case 1567:
07602       return 26;
07603        case 1622:
07604       return 27;
07605        case 1679:
07606       return 28;
07607        case 1738:
07608       return 29;
07609        case 1799:
07610       return 30;
07611        case 1862:
07612       return 31;
07613        case 1928:
07614       return 32;
07615        case 2035:
07616       return 33;
07617        case 2107:
07618       return 34;
07619        case 2181:
07620       return 35;
07621        case 2257:
07622       return 36;
07623        case 2336:
07624       return 37;
07625        case 2418:
07626       return 38;
07627        case 2503:
07628       return 39;
07629    }
07630    return -1;
07631 }

static int linkcount ( struct rpt myrpt  )  [static]

Definition at line 1379 of file app_rpt.c.

References ast_log(), rpt::links, LOG_NOTICE, LOG_WARNING, MAX_STAT_LINKS, and rpt_link::next.

Referenced by rpt_exec().

01380 {
01381    struct   rpt_link *l;
01382    char *reverse_patch_state;
01383    int numoflinks;
01384 
01385    reverse_patch_state = "DOWN";
01386    numoflinks = 0;
01387    l = myrpt->links.next;
01388    while(l && (l != &myrpt->links)){
01389       if(numoflinks >= MAX_STAT_LINKS){
01390          ast_log(LOG_WARNING,
01391          "maximum number of links exceeds %d in rpt_do_stats()!",MAX_STAT_LINKS);
01392          break;
01393       }
01394       //if (l->name[0] == '0'){ /* Skip '0' nodes */
01395       // reverse_patch_state = "UP";
01396       // l = l->next;
01397       // continue;
01398       //}
01399       numoflinks++;
01400     
01401       l = l->next;
01402    }
01403    ast_log(LOG_NOTICE, "numoflinks=%i\n",numoflinks);
01404    return numoflinks;
01405 }

static int load_module ( void   )  [static]

Definition at line 15150 of file app_rpt.c.

References ARRAY_LEN, ast_cli_register(), ast_cli_register_multiple(), ast_manager_register, ast_pthread_create, ast_register_application, manager_rpt_local_nodes(), manager_rpt_status(), rpt_exec(), and rpt_master().

15152 {
15153    int res;
15154    ast_pthread_create(&rpt_master_thread,NULL,rpt_master,NULL);
15155 
15156 #ifdef   NEW_ASTERISK
15157    ast_cli_register_multiple(rpt_cli, ARRAY_LEN(rpt_cli));
15158    res = 0;
15159 #else
15160    /* Register cli extensions */
15161    ast_cli_register(&cli_debug);
15162    ast_cli_register(&cli_dump);
15163    ast_cli_register(&cli_stats);
15164    ast_cli_register(&cli_lstats);
15165    ast_cli_register(&cli_nodes);
15166    ast_cli_register(&cli_local_nodes);
15167    ast_cli_register(&cli_reload);
15168    ast_cli_register(&cli_restart);
15169    ast_cli_register(&cli_fun);
15170    ast_cli_register(&cli_fun1);
15171    res = ast_cli_register(&cli_cmd);
15172 #endif
15173 #ifndef OLD_ASTERISK
15174    res |= ast_manager_register("RptLocalNodes", 0, manager_rpt_local_nodes, "List local node numbers");
15175    res |= ast_manager_register("RptStatus", 0, manager_rpt_status, "Return Rpt Status for CGI");
15176 
15177 #endif
15178    res |= ast_register_application(app, rpt_exec, synopsis, descrip);
15179    return res;
15180 }

static void load_rpt_vars ( int  n,
int  init 
) [static]

Definition at line 2229 of file app_rpt.c.

References rpt::acctcode, rpt::alt_functions, rpt::alt_longestfunc, sysstate::alternatetail, rpt::althangtime, rpt::archivedir, ast_config_destroy(), ast_config_load, ast_log(), ast_mutex_lock(), ast_mutex_unlock(), AST_PTHREADT_NULL, ast_true(), ast_variable_browse(), ast_variable_retrieve(), ast_verbose, rpt::authlevel, sysstate::autopatchdisable, rpt::cfg, rpt::civaddr, CONFIG_STATUS_FILEINVALID, rpt::csstanzaname, DEFAULT_CIV_ADDR, DEFAULT_IOBASE, DEFAULT_MONITOR_MIN_DISK_BLOCKS, DEFAULT_REMOTE_INACT_TIMEOUT, DEFAULT_REMOTE_TIMEOUT, DEFAULT_REMOTE_TIMEOUT_WARNING, DEFAULT_REMOTE_TIMEOUT_WARNING_FREQ, desc, rpt::dphone_functions, rpt::dphone_longestfunc, rpt::duplex, ENDCHAR, rpt::endchar, rpt_xlat::endcharseq, rpt::extnodefile, EXTNODEFILE, rpt::extnodes, EXTNODES, finddelim(), FUNCCHAR, rpt::funcchar, rpt_xlat::funccharseq, rpt::functions, FUNCTIONS, HANGTIME, rpt::hangtime, rpt::ident, IDTIME, rpt::idtime, rpt::inxlat, rpt::iobase, rpt::ioport, rpt::link_functions, rpt::link_longestfunc, sysstate::linkfundisable, rpt::linktolink, lock, LOG_NOTICE, LOG_WARNING, rpt::longestfunc, rpt::longestnode, rpt::macro, MACRO, rpt::macro_longest, MAX_SYSSTATES, MAXXLAT, rpt::memory, MEMORY, rpt::monminblocks, ast_variable::name, rpt::name, name, ast_variable::next, rpt_tele::next, rpt::nobusyout, rpt::nodes, NODES, rpt::notelemtx, option_verbose, rpt::ourcallerid, rpt::ourcontext, rpt::outxlat, rpt::p, rpt::parrotmode, PARROTTIME, rpt::parrottime, rpt_xlat::passchars, rpt::phone_functions, rpt::phone_longestfunc, POLITEID, rpt::politeid, rpt_tele::prev, rpt::propagate_dtmf, rpt::propagate_phonedtmf, rpt::remote_mars, rpt::remoteinacttimeout, rpt::remotetimeout, rpt::remotetimeoutwarning, rpt::remotetimeoutwarningfreq, retrieve_astcfgint(), rpt::rpt_thread, rpt_vars, rpt::rptnode, rpt::s, sysstate::schedulerdisable, rpt::simple, SIMPLEX_PATCH_DELAY, SIMPLEX_PHONE_DELAY, rpt::simplexpatchdelay, rpt::simplexphonedelay, rpt::skedstanzaname, rpt::startupmacro, STATPOST_PROGRAM, rpt::statpost_program, rpt::statpost_url, rpt::tailmessagemax, rpt::tailmessagen, rpt::tailmessages, rpt::tailmessagetime, rpt::tailsquashedtime, rpt::tele, rpt::tonemacro, TONEMACRO, rpt::tonezone, sysstate::totdisable, TOTIME, rpt::totime, sysstate::txdisable, rpt::txlimitsstanzaname, sysstate::userfundisable, ast_variable::value, VERBOSE_PREFIX_3, VOX_RECOVER_MS, VOX_TIMEOUT_MS, rpt::voxrecover_ms, and rpt::voxtimeout_ms.

Referenced by rpt(), rpt_exec(), and rpt_master().

02230 {
02231 char *this,*val;
02232 int   i,j,longestnode;
02233 struct ast_variable *vp;
02234 struct ast_config *cfg;
02235 char *strs[100];
02236 char s1[256];
02237 static char *cs_keywords[] = {"rptena","rptdis","apena","apdis","lnkena","lnkdis","totena","totdis","skena","skdis",
02238             "ufena","ufdis","atena","atdis",NULL};
02239 
02240    if (option_verbose > 2)
02241       ast_verbose(VERBOSE_PREFIX_3 "%s config for repeater %s\n",
02242          (init) ? "Loading initial" : "Re-Loading",rpt_vars[n].name);
02243    ast_mutex_lock(&rpt_vars[n].lock);
02244    if (rpt_vars[n].cfg) ast_config_destroy(rpt_vars[n].cfg);
02245 #ifdef   NEW_ASTERISK
02246    cfg = ast_config_load("rpt.conf",config_flags);
02247 #else
02248    cfg = ast_config_load("rpt.conf");
02249 #endif
02250    if (!cfg || cfg == CONFIG_STATUS_FILEINVALID) {
02251       ast_mutex_unlock(&rpt_vars[n].lock);
02252       ast_log(LOG_NOTICE, "Unable to open radio repeater configuration rpt.conf.  Radio Repeater disabled.\n");
02253       pthread_exit(NULL);
02254    }
02255    rpt_vars[n].cfg = cfg; 
02256    this = rpt_vars[n].name;
02257    memset(&rpt_vars[n].p,0,sizeof(rpt_vars[n].p));
02258    if (init)
02259    {
02260       char *cp;
02261       int savearea = (char *)&rpt_vars[n].p - (char *)&rpt_vars[n];
02262 
02263       cp = (char *) &rpt_vars[n].p;
02264       memset(cp + sizeof(rpt_vars[n].p),0,
02265          sizeof(rpt_vars[n]) - (sizeof(rpt_vars[n].p) + savearea));
02266       rpt_vars[n].tele.next = &rpt_vars[n].tele;
02267       rpt_vars[n].tele.prev = &rpt_vars[n].tele;
02268       rpt_vars[n].rpt_thread = AST_PTHREADT_NULL;
02269       rpt_vars[n].tailmessagen = 0;
02270    }
02271 #ifdef   __RPT_NOTCH
02272    /* zot out filters stuff */
02273    memset(&rpt_vars[n].filters,0,sizeof(rpt_vars[n].filters));
02274 #endif
02275    val = (char *) ast_variable_retrieve(cfg,this,"context");
02276    if (val) rpt_vars[n].p.ourcontext = val;
02277    else rpt_vars[n].p.ourcontext = this;
02278    val = (char *) ast_variable_retrieve(cfg,this,"callerid");
02279    if (val) rpt_vars[n].p.ourcallerid = val;
02280    val = (char *) ast_variable_retrieve(cfg,this,"accountcode");
02281    if (val) rpt_vars[n].p.acctcode = val;
02282    val = (char *) ast_variable_retrieve(cfg,this,"idrecording");
02283    if (val) rpt_vars[n].p.ident = val;
02284    val = (char *) ast_variable_retrieve(cfg,this,"hangtime");
02285    if (val) rpt_vars[n].p.hangtime = atoi(val);
02286       else rpt_vars[n].p.hangtime = HANGTIME;
02287    val = (char *) ast_variable_retrieve(cfg,this,"althangtime");
02288    if (val) rpt_vars[n].p.althangtime = atoi(val);
02289       else rpt_vars[n].p.althangtime = HANGTIME;
02290    val = (char *) ast_variable_retrieve(cfg,this,"totime");
02291    if (val) rpt_vars[n].p.totime = atoi(val);
02292       else rpt_vars[n].p.totime = TOTIME;
02293    val = (char *) ast_variable_retrieve(cfg,this,"voxtimeout");
02294    if (val) rpt_vars[n].p.voxtimeout_ms = atoi(val);
02295       else rpt_vars[n].p.voxtimeout_ms = VOX_TIMEOUT_MS;
02296    val = (char *) ast_variable_retrieve(cfg,this,"voxrecover");
02297    if (val) rpt_vars[n].p.voxrecover_ms = atoi(val);
02298       else rpt_vars[n].p.voxrecover_ms = VOX_RECOVER_MS;
02299    val = (char *) ast_variable_retrieve(cfg,this,"simplexpatchdelay");
02300    if (val) rpt_vars[n].p.simplexpatchdelay = atoi(val);
02301       else rpt_vars[n].p.simplexpatchdelay = SIMPLEX_PATCH_DELAY;
02302    val = (char *) ast_variable_retrieve(cfg,this,"simplexphonedelay");
02303    if (val) rpt_vars[n].p.simplexphonedelay = atoi(val);
02304       else rpt_vars[n].p.simplexphonedelay = SIMPLEX_PHONE_DELAY;
02305    val = (char *) ast_variable_retrieve(cfg,this,"statpost_program");
02306    if (val) rpt_vars[n].p.statpost_program = val;
02307       else rpt_vars[n].p.statpost_program = STATPOST_PROGRAM;
02308    rpt_vars[n].p.statpost_url = 
02309       (char *) ast_variable_retrieve(cfg,this,"statpost_url");
02310    rpt_vars[n].p.tailmessagetime = retrieve_astcfgint(&rpt_vars[n],this, "tailmessagetime", 0, 2400000, 0);    
02311    rpt_vars[n].p.tailsquashedtime = retrieve_astcfgint(&rpt_vars[n],this, "tailsquashedtime", 0, 2400000, 0);     
02312    rpt_vars[n].p.duplex = retrieve_astcfgint(&rpt_vars[n],this,"duplex",0,4,2);
02313    rpt_vars[n].p.idtime = retrieve_astcfgint(&rpt_vars[n],this, "idtime", -60000, 2400000, IDTIME);   /* Enforce a min max including zero */
02314    rpt_vars[n].p.politeid = retrieve_astcfgint(&rpt_vars[n],this, "politeid", 30000, 300000, POLITEID); /* Enforce a min max */
02315    val = (char *) ast_variable_retrieve(cfg,this,"tonezone");
02316    if (val) rpt_vars[n].p.tonezone = val;
02317    rpt_vars[n].p.tailmessages[0] = 0;
02318    rpt_vars[n].p.tailmessagemax = 0;
02319    val = (char *) ast_variable_retrieve(cfg,this,"tailmessagelist");
02320    if (val) rpt_vars[n].p.tailmessagemax = finddelim(val, rpt_vars[n].p.tailmessages, 500);
02321    val = (char *) ast_variable_retrieve(cfg,this,"memory");
02322    if (!val) val = MEMORY;
02323    rpt_vars[n].p.memory = val;
02324    val = (char *) ast_variable_retrieve(cfg,this,"macro");
02325    if (!val) val = MACRO;
02326    rpt_vars[n].p.macro = val;
02327    val = (char *) ast_variable_retrieve(cfg,this,"tonemacro");
02328    if (!val) val = TONEMACRO;
02329    rpt_vars[n].p.tonemacro = val;
02330    val = (char *) ast_variable_retrieve(cfg,this,"startup_macro");
02331    if (val) rpt_vars[n].p.startupmacro = val;
02332    val = (char *) ast_variable_retrieve(cfg,this,"iobase");
02333    /* do not use atoi() here, we need to be able to have
02334       the input specified in hex or decimal so we use
02335       sscanf with a %i */
02336    if ((!val) || (sscanf(val,"%30i",&rpt_vars[n].p.iobase) != 1))
02337       rpt_vars[n].p.iobase = DEFAULT_IOBASE;
02338    val = (char *) ast_variable_retrieve(cfg,this,"ioport");
02339    rpt_vars[n].p.ioport = val;
02340    val = (char *) ast_variable_retrieve(cfg,this,"functions");
02341    if (!val)
02342       {
02343          val = FUNCTIONS;
02344          rpt_vars[n].p.simple = 1;
02345       } 
02346    rpt_vars[n].p.functions = val;
02347    val =  (char *) ast_variable_retrieve(cfg,this,"link_functions");
02348    if (val) rpt_vars[n].p.link_functions = val;
02349    else 
02350       rpt_vars[n].p.link_functions = rpt_vars[n].p.functions;
02351    val = (char *) ast_variable_retrieve(cfg,this,"phone_functions");
02352    if (val) rpt_vars[n].p.phone_functions = val;
02353    val = (char *) ast_variable_retrieve(cfg,this,"dphone_functions");
02354    if (val) rpt_vars[n].p.dphone_functions = val;
02355    val = (char *) ast_variable_retrieve(cfg,this,"alt_functions");
02356    if (val) rpt_vars[n].p.alt_functions = val;
02357    val = (char *) ast_variable_retrieve(cfg,this,"funcchar");
02358    if (!val) rpt_vars[n].p.funcchar = FUNCCHAR; else 
02359       rpt_vars[n].p.funcchar = *val;      
02360    val = (char *) ast_variable_retrieve(cfg,this,"endchar");
02361    if (!val) rpt_vars[n].p.endchar = ENDCHAR; else 
02362       rpt_vars[n].p.endchar = *val;    
02363    val = (char *) ast_variable_retrieve(cfg,this,"nobusyout");
02364    if (val) rpt_vars[n].p.nobusyout = ast_true(val);
02365    val = (char *) ast_variable_retrieve(cfg,this,"notelemtx");
02366    if (val) rpt_vars[n].p.notelemtx = ast_true(val);
02367    val = (char *) ast_variable_retrieve(cfg,this,"propagate_dtmf");
02368    if (val) rpt_vars[n].p.propagate_dtmf = ast_true(val);
02369    val = (char *) ast_variable_retrieve(cfg,this,"propagate_phonedtmf");
02370    if (val) rpt_vars[n].p.propagate_phonedtmf = ast_true(val);
02371    val = (char *) ast_variable_retrieve(cfg,this,"linktolink");
02372    if (val) rpt_vars[n].p.linktolink = ast_true(val);
02373    val = (char *) ast_variable_retrieve(cfg,this,"nodes");
02374    if (!val) val = NODES;
02375    rpt_vars[n].p.nodes = val;
02376    val = (char *) ast_variable_retrieve(cfg,this,"extnodes");
02377    if (!val) val = EXTNODES;
02378    rpt_vars[n].p.extnodes = val;
02379    val = (char *) ast_variable_retrieve(cfg,this,"extnodefile");
02380    if (!val) val = EXTNODEFILE;
02381    rpt_vars[n].p.extnodefile = val;
02382    val = (char *) ast_variable_retrieve(cfg,this,"archivedir");
02383    if (val) rpt_vars[n].p.archivedir = val;
02384    val = (char *) ast_variable_retrieve(cfg,this,"authlevel");
02385    if (val) rpt_vars[n].p.authlevel = atoi(val); 
02386    else rpt_vars[n].p.authlevel = 0;
02387    val = (char *) ast_variable_retrieve(cfg,this,"parrot");
02388    if (val) rpt_vars[n].p.parrotmode = ast_true(val) * 2;
02389    else rpt_vars[n].p.parrotmode = 0;
02390    val = (char *) ast_variable_retrieve(cfg,this,"parrottime");
02391    if (val) rpt_vars[n].p.parrottime = atoi(val); 
02392    else rpt_vars[n].p.parrottime = PARROTTIME;
02393    val = (char *) ast_variable_retrieve(cfg,this,"rptnode");
02394    rpt_vars[n].p.rptnode = val;
02395    val = (char *) ast_variable_retrieve(cfg,this,"mars");
02396    if (val) rpt_vars[n].p.remote_mars = atoi(val); 
02397    else rpt_vars[n].p.remote_mars = 0;
02398    val = (char *) ast_variable_retrieve(cfg,this,"monminblocks");
02399    if (val) rpt_vars[n].p.monminblocks = atol(val); 
02400    else rpt_vars[n].p.monminblocks = DEFAULT_MONITOR_MIN_DISK_BLOCKS;
02401    val = (char *) ast_variable_retrieve(cfg,this,"remote_inact_timeout");
02402    if (val) rpt_vars[n].p.remoteinacttimeout = atoi(val); 
02403    else rpt_vars[n].p.remoteinacttimeout = DEFAULT_REMOTE_INACT_TIMEOUT;
02404    val = (char *) ast_variable_retrieve(cfg,this,"civaddr");
02405    if (val) rpt_vars[n].p.civaddr = atoi(val); 
02406    else rpt_vars[n].p.civaddr = DEFAULT_CIV_ADDR;
02407    val = (char *) ast_variable_retrieve(cfg,this,"remote_timeout");
02408    if (val) rpt_vars[n].p.remotetimeout = atoi(val); 
02409    else rpt_vars[n].p.remotetimeout = DEFAULT_REMOTE_TIMEOUT;
02410    val = (char *) ast_variable_retrieve(cfg,this,"remote_timeout_warning");
02411    if (val) rpt_vars[n].p.remotetimeoutwarning = atoi(val); 
02412    else rpt_vars[n].p.remotetimeoutwarning = DEFAULT_REMOTE_TIMEOUT_WARNING;
02413    val = (char *) ast_variable_retrieve(cfg,this,"remote_timeout_warning_freq");
02414    if (val) rpt_vars[n].p.remotetimeoutwarningfreq = atoi(val); 
02415    else rpt_vars[n].p.remotetimeoutwarningfreq = DEFAULT_REMOTE_TIMEOUT_WARNING_FREQ;
02416 #ifdef   __RPT_NOTCH
02417    val = (char *) ast_variable_retrieve(cfg,this,"rxnotch");
02418    if (val) {
02419       i = finddelim(val,strs,MAXFILTERS * 2);
02420       i &= ~1; /* force an even number, rounded down */
02421       if (i >= 2) for(j = 0; j < i; j += 2)
02422       {
02423          rpt_mknotch(atof(strs[j]),atof(strs[j + 1]),
02424            &rpt_vars[n].filters[j >> 1].gain,
02425              &rpt_vars[n].filters[j >> 1].const0,
02426             &rpt_vars[n].filters[j >> 1].const1,
02427                 &rpt_vars[n].filters[j >> 1].const2);
02428          sprintf(rpt_vars[n].filters[j >> 1].desc,"%s Hz, BW = %s",
02429             strs[j],strs[j + 1]);
02430       }
02431 
02432    }
02433 #endif
02434    val = (char *) ast_variable_retrieve(cfg,this,"inxlat");
02435    if (val) {
02436       memset(&rpt_vars[n].p.inxlat,0,sizeof(struct rpt_xlat));
02437       i = finddelim(val,strs,3);
02438       if (i) strncpy(rpt_vars[n].p.inxlat.funccharseq,strs[0],MAXXLAT - 1);
02439       if (i > 1) strncpy(rpt_vars[n].p.inxlat.endcharseq,strs[1],MAXXLAT - 1);
02440       if (i > 2) strncpy(rpt_vars[n].p.inxlat.passchars,strs[2],MAXXLAT - 1);
02441    }
02442    val = (char *) ast_variable_retrieve(cfg,this,"outxlat");
02443    if (val) {
02444       memset(&rpt_vars[n].p.outxlat,0,sizeof(struct rpt_xlat));
02445       i = finddelim(val,strs,3);
02446       if (i) strncpy(rpt_vars[n].p.outxlat.funccharseq,strs[0],MAXXLAT - 1);
02447       if (i > 1) strncpy(rpt_vars[n].p.outxlat.endcharseq,strs[1],MAXXLAT - 1);
02448       if (i > 2) strncpy(rpt_vars[n].p.outxlat.passchars,strs[2],MAXXLAT - 1);
02449    }
02450    /* retreive the stanza name for the control states if there is one */
02451    val = (char *) ast_variable_retrieve(cfg,this,"controlstates");
02452    rpt_vars[n].p.csstanzaname = val;
02453       
02454    /* retreive the stanza name for the scheduler if there is one */
02455    val = (char *) ast_variable_retrieve(cfg,this,"scheduler");
02456    rpt_vars[n].p.skedstanzaname = val;
02457 
02458    /* retreive the stanza name for the txlimits */
02459    val = (char *) ast_variable_retrieve(cfg,this,"txlimits");
02460    rpt_vars[n].p.txlimitsstanzaname = val;
02461 
02462    longestnode = 0;
02463 
02464    vp = ast_variable_browse(cfg, rpt_vars[n].p.nodes);
02465       
02466    while(vp){
02467       j = strlen(vp->name);
02468       if (j > longestnode)
02469          longestnode = j;
02470       vp = vp->next;
02471    }
02472 
02473    rpt_vars[n].longestnode = longestnode;
02474       
02475    /*
02476    * For this repeater, Determine the length of the longest function 
02477    */
02478    rpt_vars[n].longestfunc = 0;
02479    vp = ast_variable_browse(cfg, rpt_vars[n].p.functions);
02480    while(vp){
02481       j = strlen(vp->name);
02482       if (j > rpt_vars[n].longestfunc)
02483          rpt_vars[n].longestfunc = j;
02484       vp = vp->next;
02485    }
02486    /*
02487    * For this repeater, Determine the length of the longest function 
02488    */
02489    rpt_vars[n].link_longestfunc = 0;
02490    vp = ast_variable_browse(cfg, rpt_vars[n].p.link_functions);
02491    while(vp){
02492       j = strlen(vp->name);
02493       if (j > rpt_vars[n].link_longestfunc)
02494          rpt_vars[n].link_longestfunc = j;
02495       vp = vp->next;
02496    }
02497    rpt_vars[n].phone_longestfunc = 0;
02498    if (rpt_vars[n].p.phone_functions)
02499    {
02500       vp = ast_variable_browse(cfg, rpt_vars[n].p.phone_functions);
02501       while(vp){
02502          j = strlen(vp->name);
02503          if (j > rpt_vars[n].phone_longestfunc)
02504             rpt_vars[n].phone_longestfunc = j;
02505          vp = vp->next;
02506       }
02507    }
02508    rpt_vars[n].dphone_longestfunc = 0;
02509    if (rpt_vars[n].p.dphone_functions)
02510    {
02511       vp = ast_variable_browse(cfg, rpt_vars[n].p.dphone_functions);
02512       while(vp){
02513          j = strlen(vp->name);
02514          if (j > rpt_vars[n].dphone_longestfunc)
02515             rpt_vars[n].dphone_longestfunc = j;
02516          vp = vp->next;
02517       }
02518    }
02519    rpt_vars[n].alt_longestfunc = 0;
02520    if (rpt_vars[n].p.alt_functions)
02521    {
02522       vp = ast_variable_browse(cfg, rpt_vars[n].p.alt_functions);
02523       while(vp){
02524          j = strlen(vp->name);
02525          if (j > rpt_vars[n].alt_longestfunc)
02526             rpt_vars[n].alt_longestfunc = j;
02527          vp = vp->next;
02528       }
02529    }
02530    rpt_vars[n].macro_longest = 1;
02531    vp = ast_variable_browse(cfg, rpt_vars[n].p.macro);
02532    while(vp){
02533       j = strlen(vp->name);
02534       if (j > rpt_vars[n].macro_longest)
02535          rpt_vars[n].macro_longest = j;
02536       vp = vp->next;
02537    }
02538    
02539    /* Browse for control states */
02540    if(rpt_vars[n].p.csstanzaname)
02541       vp = ast_variable_browse(cfg, rpt_vars[n].p.csstanzaname);
02542    else
02543       vp = NULL;
02544    for( i = 0 ; vp && (i < MAX_SYSSTATES) ; i++){ /* Iterate over the number of control state lines in the stanza */
02545       int k,nukw,statenum;
02546       statenum=atoi(vp->name);
02547       strncpy(s1, vp->value, 255);
02548       s1[255] = 0;
02549       nukw  = finddelim(s1,strs,32);
02550       
02551       for (k = 0 ; k < nukw ; k++){ /* for each user specified keyword */  
02552          for(j = 0 ; cs_keywords[j] != NULL ; j++){ /* try to match to one in our internal table */
02553             if(!strcmp(strs[k],cs_keywords[j])){
02554                switch(j){
02555                   case 0: /* rptena */
02556                      rpt_vars[n].p.s[statenum].txdisable = 0;
02557                      break;
02558                   case 1: /* rptdis */
02559                      rpt_vars[n].p.s[statenum].txdisable = 1;
02560                      break;
02561          
02562                   case 2: /* apena */
02563                      rpt_vars[n].p.s[statenum].autopatchdisable = 0;
02564                      break;
02565 
02566                   case 3: /* apdis */
02567                      rpt_vars[n].p.s[statenum].autopatchdisable = 1;
02568                      break;
02569 
02570                   case 4: /* lnkena */
02571                      rpt_vars[n].p.s[statenum].linkfundisable = 0;
02572                      break;
02573    
02574                   case 5: /* lnkdis */
02575                      rpt_vars[n].p.s[statenum].linkfundisable = 1;
02576                      break;
02577 
02578                   case 6: /* totena */
02579                      rpt_vars[n].p.s[statenum].totdisable = 0;
02580                      break;
02581                
02582                   case 7: /* totdis */
02583                      rpt_vars[n].p.s[statenum].totdisable = 1;
02584                      break;
02585 
02586                   case 8: /* skena */
02587                      rpt_vars[n].p.s[statenum].schedulerdisable = 0;
02588                      break;
02589 
02590                   case 9: /* skdis */
02591                      rpt_vars[n].p.s[statenum].schedulerdisable = 1;
02592                      break;
02593 
02594                   case 10: /* ufena */
02595                      rpt_vars[n].p.s[statenum].userfundisable = 0;
02596                      break;
02597 
02598                   case 11: /* ufdis */
02599                      rpt_vars[n].p.s[statenum].userfundisable = 1;
02600                      break;
02601 
02602                   case 12: /* atena */
02603                      rpt_vars[n].p.s[statenum].alternatetail = 1;
02604                      break;
02605 
02606                   case 13: /* atdis */
02607                      rpt_vars[n].p.s[statenum].alternatetail = 0;
02608                      break;
02609          
02610                   default:
02611                      ast_log(LOG_WARNING,
02612                         "Unhandled control state keyword %s", cs_keywords[i]);
02613                      break;
02614                }
02615             }
02616          }
02617       }
02618       vp = vp->next;
02619    }
02620    ast_mutex_unlock(&rpt_vars[n].lock);
02621 }

static void local_dtmf_helper ( struct rpt myrpt,
char  c_in 
) [static]

Definition at line 10414 of file app_rpt.c.

References rpt::archivedir, ast_canmatch_extension(), ast_exists_extension(), ast_log(), ast_matchmore_extension(), ast_pthread_create, rpt::calldigittimer, rpt::callmode, channel_revert(), rpt::cidx, rpt::cmdnode, collect_function_digits(), COMPLETE, rpt::dailyexecdcommands, DC_COMPLETE, DC_COMPLETEQUIET, DC_ERROR, DC_INDETERMINATE, DC_REQ_FLUSH, do_dtmf_phone(), donodelog(), rpt::dtmf_time, rpt::dtmfbuf, rpt::dtmfidx, rpt::endchar, rpt::exten, rpt::funcchar, rpt::inpadtest, rpt::lastdtmfcommand, rpt::lock, LOG_WARNING, rpt::macropatch, MAXDTMF, MAXPATCHCONTEXT, rpt::mydtmf, rpt::ourcontext, rpt::p, rpt::patchcontext, rpt::patchdialtime, rpt::patchfarenddisconnect, rpt::patchnoct, rpt::patchquiet, rpt::pchannel, PROC, rpt::propagate_phonedtmf, rpt_call(), rpt::rpt_call_thread, rpt_mutex_lock, rpt_mutex_unlock, rpt_telemetry(), send_link_dtmf(), rpt::simple, SOURCE_ALT, SOURCE_RPT, rpt::stopgen, TERM, and rpt::totalexecdcommands.

Referenced by rpt().

10415 {
10416 int   res;
10417 pthread_attr_t attr;
10418 char  cmd[MAXDTMF+1] = "",c;
10419 
10420 
10421    c = c_in & 0x7f;
10422    if (myrpt->p.archivedir)
10423    {
10424       char str[100];
10425 
10426       sprintf(str,"DTMF,MAIN,%c",c);
10427       donodelog(myrpt,str);
10428    }
10429    if (c == myrpt->p.endchar)
10430    {
10431    /* if in simple mode, kill autopatch */
10432       if (myrpt->p.simple && myrpt->callmode)
10433       {   
10434          if(debug)
10435             ast_log(LOG_WARNING, "simple mode autopatch kill\n");
10436          rpt_mutex_lock(&myrpt->lock);
10437          myrpt->callmode = 0;
10438          myrpt->macropatch=0;
10439          channel_revert(myrpt);
10440          rpt_mutex_unlock(&myrpt->lock);
10441          rpt_telemetry(myrpt,TERM,NULL);
10442          return;
10443       }
10444       rpt_mutex_lock(&myrpt->lock);
10445       myrpt->stopgen = 1;
10446       if (myrpt->cmdnode[0])
10447       {
10448          myrpt->cmdnode[0] = 0;
10449          myrpt->dtmfidx = -1;
10450          myrpt->dtmfbuf[0] = 0;
10451          rpt_mutex_unlock(&myrpt->lock);
10452          rpt_telemetry(myrpt,COMPLETE,NULL);
10453          return;
10454       } 
10455       else if(!myrpt->inpadtest)
10456                 {
10457                         rpt_mutex_unlock(&myrpt->lock);
10458                         if (myrpt->p.propagate_phonedtmf)
10459                                do_dtmf_phone(myrpt,NULL,c);
10460          return;
10461                 }
10462       else
10463          rpt_mutex_unlock(&myrpt->lock);
10464    }
10465    rpt_mutex_lock(&myrpt->lock);
10466    if (myrpt->cmdnode[0])
10467    {
10468       rpt_mutex_unlock(&myrpt->lock);
10469       send_link_dtmf(myrpt,c);
10470       return;
10471    }
10472    if (!myrpt->p.simple)
10473    {
10474       if ((!myrpt->inpadtest)&&(c == myrpt->p.funcchar))
10475       {
10476          myrpt->dtmfidx = 0;
10477          myrpt->dtmfbuf[myrpt->dtmfidx] = 0;
10478          rpt_mutex_unlock(&myrpt->lock);
10479          time(&myrpt->dtmf_time);
10480          return;
10481       } 
10482       else if (((myrpt->inpadtest)||(c != myrpt->p.endchar)) && (myrpt->dtmfidx >= 0))
10483       {
10484          time(&myrpt->dtmf_time);
10485          
10486          if (myrpt->dtmfidx < MAXDTMF)
10487          {
10488             int src;
10489 
10490             myrpt->dtmfbuf[myrpt->dtmfidx++] = c;
10491             myrpt->dtmfbuf[myrpt->dtmfidx] = 0;
10492             
10493             strncpy(cmd, myrpt->dtmfbuf, sizeof(cmd) - 1);
10494             
10495             rpt_mutex_unlock(&myrpt->lock);
10496             src = SOURCE_RPT;
10497             if (c_in & 0x80) src = SOURCE_ALT;
10498             res = collect_function_digits(myrpt, cmd, src, NULL);
10499             rpt_mutex_lock(&myrpt->lock);
10500             switch(res){
10501                 case DC_INDETERMINATE:
10502                break;
10503                 case DC_REQ_FLUSH:
10504                myrpt->dtmfidx = 0;
10505                myrpt->dtmfbuf[0] = 0;
10506                break;
10507                 case DC_COMPLETE:
10508                 case DC_COMPLETEQUIET:
10509                myrpt->totalexecdcommands++;
10510                myrpt->dailyexecdcommands++;
10511                strncpy(myrpt->lastdtmfcommand, cmd, MAXDTMF-1);
10512                myrpt->lastdtmfcommand[MAXDTMF-1] = '\0';
10513                myrpt->dtmfbuf[0] = 0;
10514                myrpt->dtmfidx = -1;
10515                myrpt->dtmf_time = 0;
10516                break;
10517 
10518                 case DC_ERROR:
10519                 default:
10520                myrpt->dtmfbuf[0] = 0;
10521                myrpt->dtmfidx = -1;
10522                myrpt->dtmf_time = 0;
10523                break;
10524             }
10525             if(res != DC_INDETERMINATE) {
10526                rpt_mutex_unlock(&myrpt->lock);
10527                return;
10528             }
10529          } 
10530       }
10531    }
10532    else /* if simple */
10533    {
10534       if ((!myrpt->callmode) && (c == myrpt->p.funcchar))
10535       {
10536          myrpt->callmode = 1;
10537          myrpt->patchnoct = 0;
10538          myrpt->patchquiet = 0;
10539          myrpt->patchfarenddisconnect = 0;
10540          myrpt->patchdialtime = 0;
10541          strncpy(myrpt->patchcontext, myrpt->p.ourcontext, MAXPATCHCONTEXT);
10542          myrpt->cidx = 0;
10543          myrpt->exten[myrpt->cidx] = 0;
10544          rpt_mutex_unlock(&myrpt->lock);
10545               pthread_attr_init(&attr);
10546               pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
10547          ast_pthread_create(&myrpt->rpt_call_thread,&attr,rpt_call,(void *)myrpt);
10548          return;
10549       }
10550    }
10551    if (myrpt->callmode == 1)
10552    {
10553       myrpt->exten[myrpt->cidx++] = c;
10554       myrpt->exten[myrpt->cidx] = 0;
10555       /* if this exists */
10556       if (ast_exists_extension(myrpt->pchannel,myrpt->patchcontext,myrpt->exten,1,NULL))
10557       {
10558          /* if this really it, end now */
10559          if (!ast_matchmore_extension(myrpt->pchannel,myrpt->patchcontext,
10560             myrpt->exten,1,NULL)) 
10561          {
10562             myrpt->callmode = 2;
10563             rpt_mutex_unlock(&myrpt->lock);
10564             if(!myrpt->patchquiet)
10565                rpt_telemetry(myrpt,PROC,NULL); 
10566             return;
10567          }
10568          else /* othewise, reset timer */
10569          {
10570             myrpt->calldigittimer = 1;
10571          }
10572       }
10573       /* if can continue, do so */
10574       if (!ast_canmatch_extension(myrpt->pchannel,myrpt->patchcontext,myrpt->exten,1,NULL))
10575       {
10576          /* call has failed, inform user */
10577          myrpt->callmode = 4;
10578       }
10579       rpt_mutex_unlock(&myrpt->lock);
10580       return;
10581    }
10582    if ((myrpt->callmode == 2) || (myrpt->callmode == 3))
10583    {
10584       myrpt->mydtmf = c;
10585    }
10586    rpt_mutex_unlock(&myrpt->lock);
10587    if ((myrpt->dtmfidx < 0) && myrpt->p.propagate_phonedtmf)
10588       do_dtmf_phone(myrpt,NULL,c);
10589    return;
10590 }

static int manager_rpt_local_nodes ( struct mansession s,
const struct message m 
) [static]

Definition at line 14625 of file app_rpt.c.

References astman_append(), name, RESULT_SUCCESS, and rpt_vars.

Referenced by load_module().

14626 {
14627     int i;
14628     astman_append(s, "<?xml version=\"1.0\"?>\r\n");
14629     astman_append(s, "<nodes>\r\n");
14630     for (i=0; i< nrpts; i++)
14631     {
14632         astman_append(s, "  <node>%s</node>\r\n", rpt_vars[i].name);        
14633     } /* for i */
14634     astman_append(s, "</nodes>\r\n");
14635     astman_append(s, "\r\n"); /* Properly terminate Manager output */
14636     return RESULT_SUCCESS;
14637 } /* manager_rpt_local_nodes() */

static int manager_rpt_status ( struct mansession s,
const struct message m 
) [static]

Definition at line 15002 of file app_rpt.c.

References ast_free, ast_malloc, ast_strlen_zero(), astman_append(), astman_get_header(), astman_send_error(), name, rpt_manager_do_stats(), rpt_manager_success(), and rpt_vars.

Referenced by load_module().

15003 {
15004    int i,res,len,idx;
15005    int uptime,hours,minutes;
15006    time_t now;
15007    const char *cmd = astman_get_header(m, "Command");
15008    char *str;
15009    enum {MGRCMD_RPTSTAT,MGRCMD_NODESTAT};
15010    struct mgrcmdtbl{
15011       const char *cmd;
15012       int index;
15013    };
15014    static struct mgrcmdtbl mct[] = {
15015       {"RptStat",MGRCMD_RPTSTAT},
15016       {"NodeStat",MGRCMD_NODESTAT},
15017       {NULL,0} /* NULL marks end of command table */
15018    };
15019 
15020    time(&now);
15021 
15022    len = 1024; /* Allocate a working buffer */
15023    if(!(str = ast_malloc(len)))
15024       return -1;
15025 
15026    /* Check for Command */
15027    if(ast_strlen_zero(cmd)){
15028       astman_send_error(s, m, "RptStatus missing command");
15029       ast_free(str);
15030       return 0;
15031    }
15032    /* Try to find the command in the table */
15033    for(i = 0 ; mct[i].cmd ; i++){
15034       if(!strcmp(mct[i].cmd, cmd))
15035          break;
15036    }
15037 
15038    if(!mct[i].cmd){ /* Found or not found ? */
15039       astman_send_error(s, m, "RptStatus unknown command");
15040       ast_free(str);
15041       return 0;
15042    }
15043    else
15044       idx = mct[i].index;
15045 
15046    switch(idx){ /* Use the index to go to the correct command */
15047 
15048       case MGRCMD_RPTSTAT:
15049          /* Return Nodes: and a comma separated list of nodes */
15050          if((res = snprintf(str, len, "Nodes: ")) > -1)
15051             len -= res;
15052          else{
15053             ast_free(str);
15054             return 0;
15055          }
15056          for(i = 0; i < nrpts; i++){
15057             if(i < nrpts - 1){
15058                if((res = snprintf(str+strlen(str), len, "%s,",rpt_vars[i].name)) < 0){
15059                   ast_free(str);
15060                   return 0;
15061                }
15062             }
15063             else{
15064                if((res = snprintf(str+strlen(str), len, "%s",rpt_vars[i].name)) < 0){
15065                   ast_free(str);
15066                   return 0;
15067                }
15068             }
15069             len -= res;
15070          }
15071 
15072          rpt_manager_success(s,m);
15073          
15074          if(!nrpts)
15075             astman_append(s, "<NONE>\r\n");
15076          else
15077             astman_append(s, "%s\r\n", str);
15078 
15079          uptime = (int)(now - starttime);
15080                         hours = uptime/3600;
15081                         uptime %= 3600;
15082                         minutes = uptime/60;
15083                         uptime %= 60;
15084 
15085                         astman_append(s, "RptUptime: %02d:%02d:%02d\r\n",
15086                                 hours, minutes, uptime);
15087 
15088          astman_append(s, "\r\n");
15089          break;      
15090 
15091       case  MGRCMD_NODESTAT:
15092          res = rpt_manager_do_stats(s,m,str);
15093          ast_free(str);
15094          return res;
15095 
15096       default:
15097          astman_send_error(s, m, "RptStatus invalid command");
15098          break;
15099    }
15100    ast_free(str);
15101    return 0;
15102 }

static int matchkeyword ( char *  string,
char **  param,
char *  keywords[] 
) [static]

Definition at line 2060 of file app_rpt.c.

Referenced by function_autopatchup().

02061 {
02062 int   i,ls;
02063    for( i = 0 ; keywords[i] ; i++){
02064       ls = strlen(keywords[i]);
02065       if(!ls){
02066          *param = NULL;
02067          return 0;
02068       }
02069       if(!strncmp(string, keywords[i], ls)){
02070          if(param)
02071             *param = string + ls;
02072          return i + 1; 
02073       }
02074    }
02075    *param = NULL;
02076    return 0;
02077 }

static void mdc1200_notify ( struct rpt myrpt,
char *  fromnode,
unsigned int  unit 
) [static]

Definition at line 1712 of file app_rpt.c.

References ast_verbose, and rpt::name.

Referenced by function_ilink(), handle_link_data(), handle_remote_data(), and rpt().

01713 {
01714    if (!fromnode)
01715    {
01716       ast_verbose("Got MDC-1200 ID %04X from local system (%s)\n",
01717          unit,myrpt->name);
01718    }
01719    else
01720    {
01721       ast_verbose("Got MDC-1200 ID %04X from node %s (%s)\n",
01722          unit,fromnode,myrpt->name);
01723    }
01724 }

static int mem2vfo_ic706 ( struct rpt myrpt  )  [static]

Definition at line 9088 of file app_rpt.c.

References civ_cmd(), rpt::civaddr, and rpt::p.

Referenced by set_ic706().

09089 {
09090    unsigned char cmdstr[10];
09091    
09092    cmdstr[0] = cmdstr[1] = 0xfe;
09093    cmdstr[2] = myrpt->p.civaddr;
09094    cmdstr[3] = 0xe0;
09095    cmdstr[4] = 0x0a;
09096    cmdstr[5] = 0xfd;
09097 
09098    return(civ_cmd(myrpt,cmdstr,6));
09099 }

static int multimode_bump_freq ( struct rpt myrpt,
int  interval 
) [static]

Definition at line 9487 of file app_rpt.c.

References multimode_bump_freq_ft897(), multimode_bump_freq_ic706(), and rpt::remoterig.

Referenced by function_remote(), and service_scan().

09488 {
09489    if(!strcmp(myrpt->remoterig, remote_rig_ft897))
09490       return multimode_bump_freq_ft897(myrpt, interval);
09491    else if(!strcmp(myrpt->remoterig, remote_rig_ic706))
09492       return multimode_bump_freq_ic706(myrpt, interval);
09493    else
09494       return -1;
09495 }

static int multimode_bump_freq_ft897 ( struct rpt myrpt,
int  interval 
) [static]

Definition at line 8600 of file app_rpt.c.

References check_freq_ft897(), rpt::freq, MAXREMSTR, set_freq_ft897(), and split_freq().

Referenced by multimode_bump_freq().

08601 {
08602    int m,d;
08603    char mhz[MAXREMSTR], decimals[MAXREMSTR];
08604 
08605    if(debug)
08606       printf("Before bump: %s\n", myrpt->freq);
08607 
08608    if(split_freq(mhz, decimals, myrpt->freq))
08609       return -1;
08610    
08611    m = atoi(mhz);
08612    d = atoi(decimals);
08613 
08614    d += (interval / 10); /* 10Hz resolution */
08615    if(d < 0){
08616       m--;
08617       d += 100000;
08618    }
08619    else if(d >= 100000){
08620       m++;
08621       d -= 100000;
08622    }
08623 
08624    if(check_freq_ft897(m, d, NULL)){
08625       if(debug)
08626          printf("Bump freq invalid\n");
08627       return -1;
08628    }
08629 
08630    snprintf(myrpt->freq, MAXREMSTR, "%d.%05d", m, d);
08631 
08632    if(debug)
08633       printf("After bump: %s\n", myrpt->freq);
08634 
08635    return set_freq_ft897(myrpt, myrpt->freq);   
08636 }

static int multimode_bump_freq_ic706 ( struct rpt myrpt,
int  interval 
) [static]

Definition at line 9182 of file app_rpt.c.

References check_freq_ic706(), rpt::civaddr, rpt::freq, MAXREMSTR, rpt::p, rpt::remote_mars, serial_remote_io(), and split_freq().

Referenced by multimode_bump_freq().

09183 {
09184    int m,d;
09185    char mhz[MAXREMSTR], decimals[MAXREMSTR];
09186    unsigned char cmdstr[20];
09187 
09188    if(debug)
09189       printf("Before bump: %s\n", myrpt->freq);
09190 
09191    if(split_freq(mhz, decimals, myrpt->freq))
09192       return -1;
09193    
09194    m = atoi(mhz);
09195    d = atoi(decimals);
09196 
09197    d += (interval / 10);