42 #include "asterisk/io.h"
216 #define FAX_MAXBUCKETS 10
218 #define RES_FAX_TIMEOUT 10000
247 #define RES_FAX_MINRATE 4800
248 #define RES_FAX_MAXRATE 14400
249 #define RES_FAX_STATUSEVENTS 0
250 #define RES_FAX_MODEM (AST_FAX_MODEM_V17 | AST_FAX_MODEM_V27 | AST_FAX_MODEM_V29)
254 uint32_t statusevents:1;
275 static const char *
config =
"res_fax.conf";
307 unsigned int last_consec_frames, last_consec_ms;
308 unsigned char wassil;
317 history->
silence = (dspsilence != 0) ? 1 : 0;
318 if (history->
silence != wassil) {
324 if ((last_consec_frames != 0)) {
325 ast_verb(6,
"Channel '%s' fax session '%u', [ %.3ld.%.6ld ], %s sent %u frames (%u ms) of %s.\n",
326 s->
channame, s->
id, (
long) diff.tv_sec, (
long int) diff.tv_usec,
327 (c2s) ?
"channel" :
"stack", last_consec_frames, last_consec_ms,
328 (wassil) ?
"silence" :
"energy");
359 if (!(details = datastore->
data)) {
436 datastore->
data = details;
462 char *m[5], *tok, *v = (
char *)value;
465 if (!strchr(v,
',')) {
469 tok = strtok(v,
", ");
472 tok = strtok(NULL,
", ");
478 for (j = 0; j < i; j++) {
479 if (!strcasecmp(m[j],
"v17")) {
481 }
else if (!strcasecmp(m[j],
"v27")) {
483 }
else if (!strcasecmp(m[j],
"v29")) {
485 }
else if (!strcasecmp(m[j],
"v34")) {
488 ast_log(
LOG_WARNING,
"ignoring invalid modem setting: '%s', valid options {v17 | v27 | v29 | v34}\n", m[j]);
497 size_t size = bufsize;
618 struct fax_module *fax;
637 struct fax_module *fax;
639 ast_verb(3,
"Unregistering FAX module type '%s'\n", tech->
type);
643 if (fax->
tech != tech) {
649 ast_verb(4,
"Unregistered FAX module type '%s'\n", tech->
type);
661 return "Uninitialized";
663 return "Initialized";
680 void ast_fax_log(
int level,
const char *file,
const int line,
const char *
function,
const char *msg)
682 if (fax_logger_level != -1) {
685 ast_log(level, file, line,
function,
"%s", msg);
694 if (sscanf(ratestr,
"%d", &rate) != 1) {
709 ast_log(
LOG_WARNING,
"ignoring invalid rate '%s'. Valid options are {2400 | 4800 | 7200 | 9600 | 12000 | 14400 | 28800 | 33600}\n", ratestr);
763 struct fax_module *faxmod;
813 struct fax_module *faxmod;
941 size += strlen(separator) + strlen(prefix) + strlen(doc->
filename);
983 "LocalStationID: %s\r\n"
1015 #define GENERIC_FAX_EXEC_SET_VARS(fax, chan, errorstr, reason) \
1017 if (ast_strlen_zero(fax->details->result)) \
1018 ast_string_field_set(fax->details, result, "FAILED"); \
1019 if (ast_strlen_zero(fax->details->resultstr)) \
1020 ast_string_field_set(fax->details, resultstr, reason); \
1021 if (ast_strlen_zero(fax->details->error)) \
1022 ast_string_field_set(fax->details, error, errorstr); \
1023 set_channel_variables(chan, fax->details); \
1026 #define GENERIC_FAX_EXEC_ERROR_QUIET(fax, chan, errorstr, reason) \
1028 GENERIC_FAX_EXEC_SET_VARS(fax, chan, errorstr, reason); \
1031 #define GENERIC_FAX_EXEC_ERROR(fax, chan, errorstr, reason) \
1033 ast_log(LOG_ERROR, "channel '%s' FAX session '%u' failure, reason: '%s' (%s)\n", chan->name, fax->id, reason, errorstr); \
1034 GENERIC_FAX_EXEC_ERROR_QUIET(fax, chan, errorstr, reason); \
1078 ast_log(
LOG_ERROR,
"channel '%s' is in an unsupported T.38 negotiation state, cannot continue.\n", chan->
name);
1085 ast_log(
LOG_ERROR,
"channel '%s' is in an unsupported T.38 negotiation state, cannot continue.\n", chan->
name);
1097 struct timeval start;
1102 ast_debug(1,
"error while disabling T.38 on channel '%s'\n", chan->
name);
1116 ast_debug(1,
"error while disabling T.38 on channel '%s'\n", chan->
name);
1125 (frame->
datalen ==
sizeof(t38_parameters))) {
1148 ast_debug(1,
"channel '%s' timed-out during T.38 shutdown\n", chan->
name);
1167 unsigned int expected_frametype = -1;
1171 const char *tempvar;
1175 unsigned int orig_write_format = 0, orig_read_format = 0;
1177 struct timeval start;
1206 ast_log(
LOG_ERROR,
"channel '%s' failed to set write format to signed linear'.\n", chan->
name);
1253 ast_debug(5,
"channel %s will wait on FAX fd %d\n", chan->
name, fax->
fd);
1256 remaining_time = timeout;
1258 while (remaining_time > 0) {
1271 ast_debug(1,
"Channel '%s' did not return a frame; probably hung up.\n", chan->
name);
1285 (frame->
datalen ==
sizeof(t38_parameters))) {
1286 unsigned int was_t38 = t38negotiated;
1305 if (t38negotiated && !was_t38) {
1317 ast_verb(3,
"Channel '%s' switched to T.38 FAX session '%u'.\n", chan->
name, fax->
id);
1319 }
else if ((frame->
frametype == expected_frametype) &&
1320 (!memcmp(&frame->
subclass, &expected_framesubclass,
sizeof(frame->
subclass)))) {
1347 }
else if (ofd == fax->
fd) {
1350 if (!(frame = fax->
tech->
read(fax))) {
1363 if (ms && (ofd < 0)) {
1366 if (remaining_time <= 0)
1377 if (remaining_time <= 0) {
1384 ast_debug(3,
"channel '%s' - event loop stopped { timeout: %d, remaining_time: %d }\n", chan->
name, timeout, remaining_time);
1388 if (!strcasecmp(details->
result,
"FAILED")) {
1405 if (orig_read_format) {
1408 if (orig_write_format) {
1422 struct timeval start;
1458 (frame->
datalen ==
sizeof(t38_parameters))) {
1472 ast_debug(1,
"Negotiated T.38 for receive on %s\n", chan->
name);
1493 ast_debug(1,
"Negotiating T.38 for receive on %s\n", chan->
name);
1527 (frame->
datalen ==
sizeof(t38_parameters))) {
1537 ast_debug(1,
"Negotiated T.38 for receive on %s\n", chan->
name);
1568 ast_log(
LOG_WARNING,
"Audio FAX not allowed on channel '%s' and T.38 negotiation failed; aborting.\n", chan->
name);
1581 char *
parse, modems[128] =
"";
1585 struct ast_fax_tech_token *token = NULL;
1611 ast_log(
LOG_ERROR,
"System cannot provide memory for session requirements.\n");
1633 ast_log(
LOG_ERROR,
"'modems' setting '%s' is incompatible with 'minrate' setting %u\n", modems, details->
minrate);
1644 ast_log(
LOG_ERROR,
"'modems' setting '%s' is incompatible with 'maxrate' setting %u\n", modems, details->
maxrate);
1657 ast_log(
LOG_WARNING,
"%s requires an argument (filename[,options])\n", app_receivefax);
1678 ast_log(
LOG_WARNING,
"%s requires an argument (filename[,options])\n", app_receivefax);
1697 if (!(doc =
ast_calloc(1,
sizeof(*doc) + strlen(
args.filename) + 1))) {
1702 ast_log(
LOG_ERROR,
"System cannot provide memory for session requirements.\n");
1710 ast_verb(3,
"Channel '%s' receiving FAX '%s'\n", chan->
name,
args.filename);
1784 ast_debug(1,
"error disabling T.38 mode on %s\n", chan->
name);
1798 "RemoteStationID: %s\r\n"
1799 "LocalStationID: %s\r\n"
1800 "PagesTransferred: %s\r\n"
1801 "Resolution: %s\r\n"
1802 "TransferRate: %s\r\n"
1820 return (!channel_alive) ? -1 : 0;
1828 struct timeval start;
1843 if (
ast_playtones_start(chan, 1024,
"!1100/500,!0/3000,!1100/500,!0/3000,!1100/500,!0/3000", 1)) {
1872 (frame->
datalen ==
sizeof(t38_parameters))) {
1886 ast_debug(1,
"Negotiated T.38 for send on %s\n", chan->
name);
1910 ast_debug(1,
"Negotiating T.38 for send on %s\n", chan->
name);
1944 (frame->
datalen ==
sizeof(t38_parameters))) {
1954 ast_debug(1,
"Negotiated T.38 for receive on %s\n", chan->
name);
2007 ast_log(
LOG_ERROR,
"error reading frame while generating second CNG tone on %s\n", chan->
name);
2014 (frame->
datalen ==
sizeof(t38_parameters))) {
2028 ast_debug(1,
"Negotiated T.38 for send on %s\n", chan->
name);
2055 ast_log(
LOG_WARNING,
"Audio FAX not allowed on channel '%s' and T.38 negotiation failed; aborting.\n", chan->
name);
2069 char *
parse, *filenames, *c, modems[128] =
"";
2070 int channel_alive, file_count;
2073 struct ast_fax_tech_token *token = NULL;
2099 ast_log(
LOG_ERROR,
"System cannot provide memory for session requirements.\n");
2121 ast_log(
LOG_ERROR,
"'modems' setting '%s' is incompatible with 'minrate' setting %u\n", modems, details->
minrate);
2132 ast_log(
LOG_ERROR,
"'modems' setting '%s' is incompatible with 'maxrate' setting %u\n", modems, details->
maxrate);
2145 ast_log(
LOG_WARNING,
"%s requires an argument (filename[&filename[&filename]][,options])\n", app_sendfax);
2167 ast_log(
LOG_WARNING,
"%s requires an argument (filename[&filename[&filename]],options])\n", app_sendfax);
2184 filenames =
args.filenames;
2185 while ((c =
strsep(&filenames,
"&"))) {
2186 if (access(c, (F_OK | R_OK)) < 0) {
2191 ast_log(
LOG_ERROR,
"access failure. Verify '%s' exists and check permissions.\n",
args.filenames);
2196 if (!(doc =
ast_calloc(1,
sizeof(*doc) + strlen(c) + 1))) {
2201 ast_log(
LOG_ERROR,
"System cannot provide memory for session requirements.\n");
2211 if (file_count > 1) {
2215 ast_verb(3,
"Channel '%s' sending FAX:\n", chan->
name);
2297 ast_debug(1,
"error disabling T.38 mode on %s\n", chan->
name);
2305 return (!channel_alive) ? -1 : 0;
2317 "RemoteStationID: %s\r\n"
2318 "LocalStationID: %s\r\n"
2319 "PagesTransferred: %s\r\n"
2320 "Resolution: %s\r\n"
2321 "TransferRate: %s\r\n"
2341 return (!channel_alive) ? -1 : 0;
2374 tklen = strlen(a->
word);
2377 snprintf(tbuf,
sizeof(tbuf),
"%u", s->
id);
2378 if (!strncasecmp(a->
word, tbuf, tklen) && ++wordnum > a->
n) {
2391 struct fax_module *fax;
2395 e->
command =
"fax show version";
2397 "Usage: fax show version\n"
2398 " Show versions of FAX For Asterisk components.\n";
2408 ast_cli(a->
fd,
"FAX For Asterisk Components:\n");
2428 e->
command =
"fax set debug {on|off}";
2430 "Usage: fax set debug { on | off }\n"
2431 " Enable/Disable FAX debugging on new FAX sessions. The basic FAX debugging will result in\n"
2432 " additional events sent to manager sessions with 'call' class permissions. When\n"
2433 " verbosity is greater than '5' events will be displayed to the console and audio versus\n"
2434 " energy analysis will be performed and displayed to the console.\n";
2441 if (!strcasecmp(what,
"on")) {
2443 }
else if (!strcasecmp(what,
"off")) {
2450 ast_cli(a->
fd,
"\n\nFAX Debug %s\n\n", (flag) ?
"Enabled" :
"Disabled");
2458 struct fax_module *fax;
2459 unsigned int num_modules = 0;
2463 e->
command =
"fax show capabilities";
2465 "Usage: fax show capabilities\n"
2466 " Shows the capabilities of the registered FAX technology modules\n";
2472 ast_cli(a->
fd,
"\n\nRegistered FAX Technology Modules:\n\n");
2480 ast_cli(a->
fd,
"%u registered modules\n\n", num_modules);
2488 struct fax_module *fax;
2489 char modems[128] =
"";
2494 e->
command =
"fax show settings";
2496 "Usage: fax show settings\n"
2497 " Show the global settings and defaults of both the FAX core and technology modules\n";
2505 ast_cli(a->
fd,
"FAX For Asterisk Settings:\n");
2506 ast_cli(a->
fd,
"\tECM: %s\n", options.
ecm ?
"Enabled" :
"Disabled");
2511 ast_cli(a->
fd,
"\tModem Modulations Allowed: %s\n", modems);
2512 ast_cli(a->
fd,
"\n\nFAX Technology Modules:\n\n");
2530 e->
command =
"fax show session";
2532 "Usage: fax show session <session number>\n"
2533 " Shows status of the named FAX session\n";
2543 if (sscanf(a->
argv[3],
"%u", &tmp.
id) != 1) {
2548 ast_cli(a->
fd,
"\nFAX Session Details:\n--------------------\n\n");
2562 struct fax_module *fax;
2566 e->
command =
"fax show stats";
2568 "Usage: fax show stats\n"
2569 " Shows a statistical summary of FAX transmissions\n";
2575 ast_cli(a->
fd,
"\nFAX Statistics:\n---------------\n\n");
2602 e->
command =
"fax show sessions";
2604 "Usage: fax show sessions\n"
2605 " Shows the current FAX sessions\n";
2611 ast_cli(a->
fd,
"\nCurrent FAX Sessions:\n\n");
2612 ast_cli(a->
fd,
"%-20.20s %-10.10s %-10.10s %-5.5s %-10.10s %-15.15s %-30.30s\n",
2613 "Channel",
"Tech",
"FAXID",
"Type",
"Operation",
"State",
"File(s)");
2619 ast_log(
LOG_ERROR,
"Error printing filenames for 'fax show sessions' command\n");
2626 ast_cli(a->
fd,
"%-20.20s %-10.10s %-10u %-5.5s %-10.10s %-15.15s %-30s\n",
2638 ast_cli(a->
fd,
"\n%d FAX sessions\n\n", session_count);
2673 char modems[128] =
"";
2691 config, reload ?
"not changing" :
"using default");
2697 config, reload ?
"not changing" :
"using default");
2713 if (!strcasecmp(v->
name,
"minrate")) {
2714 ast_debug(3,
"reading minrate '%s' from configuration file\n", v->
value);
2720 }
else if (!strcasecmp(v->
name,
"maxrate")) {
2721 ast_debug(3,
"reading maxrate '%s' from configuration file\n", v->
value);
2727 }
else if (!strcasecmp(v->
name,
"statusevents")) {
2728 ast_debug(3,
"reading statusevents '%s' from configuration file\n", v->
value);
2730 }
else if (!strcasecmp(v->
name,
"ecm")) {
2731 ast_debug(3,
"reading ecm '%s' from configuration file\n", v->
value);
2733 }
else if ((!strcasecmp(v->
name,
"modem")) || (!strcasecmp(v->
name,
"modems"))) {
2747 ast_log(
LOG_WARNING,
"'modems' setting '%s' is no longer accepted with 'minrate' setting %u\n", modems, options.
minrate);
2748 ast_log(
LOG_WARNING,
"'minrate' has been reset to 4800, please update res_fax.conf.\n");
2754 ast_log(
LOG_ERROR,
"'modems' setting '%s' is incompatible with 'minrate' setting %u\n", modems, options.
minrate);
2761 ast_log(
LOG_ERROR,
"'modems' setting '%s' is incompatible with 'maxrate' setting %u\n", modems, options.
maxrate);
2781 ast_log(
LOG_ERROR,
"channel '%s' can't read FAXOPT(%s) because it has never been written.\n", chan->
name, data);
2784 if (!strcasecmp(data,
"ecm")) {
2786 }
else if (!strcasecmp(data,
"error")) {
2788 }
else if (!strcasecmp(data,
"filename")) {
2790 ast_log(
LOG_ERROR,
"channel '%s' can't read FAXOPT(%s) because it has never been written.\n", chan->
name, data);
2795 }
else if (!strcasecmp(data,
"filenames")) {
2797 ast_log(
LOG_ERROR,
"channel '%s' can't read FAXOPT(%s) because it has never been written.\n", chan->
name, data);
2803 ast_log(
LOG_ERROR,
"channel '%s' can't read FAXOPT(%s), there was an error generating the filenames list.\n", chan->
name, data);
2806 }
else if (!strcasecmp(data,
"headerinfo")) {
2808 }
else if (!strcasecmp(data,
"localstationid")) {
2810 }
else if (!strcasecmp(data,
"maxrate")) {
2811 snprintf(buf, len,
"%u", details->
maxrate);
2812 }
else if (!strcasecmp(data,
"minrate")) {
2813 snprintf(buf, len,
"%u", details->
minrate);
2814 }
else if (!strcasecmp(data,
"pages")) {
2816 }
else if (!strcasecmp(data,
"rate")) {
2818 }
else if (!strcasecmp(data,
"remotestationid")) {
2820 }
else if (!strcasecmp(data,
"resolution")) {
2822 }
else if (!strcasecmp(data,
"sessionid")) {
2823 snprintf(buf, len,
"%u", details->
id);
2824 }
else if (!strcasecmp(data,
"status")) {
2826 }
else if (!strcasecmp(data,
"statusstr")) {
2828 }
else if ((!strcasecmp(data,
"modem")) || (!strcasecmp(data,
"modems"))) {
2846 ast_log(
LOG_WARNING,
"channel '%s' can't set FAXOPT(%s) to '%s' because it failed to create a datastore.\n", chan->
name, data, value);
2849 ast_debug(3,
"channel '%s' setting FAXOPT(%s) to '%s'\n", chan->
name, data, value);
2851 if (!strcasecmp(data,
"ecm")) {
2860 }
else if (!strcasecmp(data,
"headerinfo")) {
2862 }
else if (!strcasecmp(data,
"localstationid")) {
2864 }
else if (!strcasecmp(data,
"maxrate")) {
2869 }
else if (!strcasecmp(data,
"minrate")) {
2874 }
else if ((!strcasecmp(data,
"modem")) || (!strcasecmp(data,
"modems"))) {
2910 if (fax_logger_level != -1) {
static int receivefax_exec(struct ast_channel *chan, const char *data)
initiate a receive FAX session
void pbx_substitute_variables_helper(struct ast_channel *c, const char *cp1, char *cp2, int count)
static enum ast_t38_state ast_channel_get_t38_state(struct ast_channel *chan)
Retrieves the current T38 state of a channel.
const ast_string_field result
struct ast_fax_tech * tech
union ast_frame_subclass subclass
#define GENERIC_FAX_EXEC_ERROR(fax, chan, errorstr, reason)
#define ast_rwlock_rdlock(a)
struct ast_smoother * ast_smoother_new(int bytes)
#define ast_channel_lock(chan)
static char exten[AST_MAX_EXTENSION]
Main Channel structure associated with a channel.
static int receivefax_t38_init(struct ast_channel *chan, struct ast_fax_session_details *details)
#define AST_CLI_DEFINE(fn, txt,...)
static struct ast_control_t38_parameters our_t38_parameters
void ast_smoother_free(struct ast_smoother *s)
Asterisk locking-related definitions:
Asterisk main include file. File version handling, generic pbx functions.
#define ao2_link(arg1, arg2)
#define AST_LIST_FIRST(head)
Returns the first entry contained in a list.
int ao2_container_count(struct ao2_container *c)
Returns the number of elements in a container.
void ast_fax_tech_unregister(struct ast_fax_tech *tech)
unregister a fax technology
#define AST_RWLOCK_DEFINE_STATIC(rwlock)
static void destroy_session_details(void *details)
destroy a FAX session details structure
#define AST_APP_OPTIONS(holder, options...)
Declares an array of options for an application.
void ast_module_unref(struct ast_module *)
char * strsep(char **str, const char *delims)
int(*const start_session)(struct ast_fax_session *)
int(*const switch_to_t38)(struct ast_fax_session *)
unsigned int consec_frames
#define AST_RWLIST_HEAD_STATIC(name, type)
Defines a structure to be used to hold a read/write list of specified type, statically initialized...
const ast_string_field uniqueid
String manipulation functions.
unsigned long frames_sent
const ast_string_field headerinfo
unsigned long frames_received
static unsigned int fax_rate_str_to_int(const char *ratestr)
convert a rate string to a rate
Asterisk version information.
int ast_cli_unregister_multiple(struct ast_cli_entry *e, int len)
Unregister multiple commands.
static struct fax_options default_options
struct ast_frame * ast_smoother_read(struct ast_smoother *s)
#define ast_test_flag(p, flag)
void(*const release_token)(struct ast_fax_tech_token *)
static void get_manager_event_info(struct ast_channel *chan, struct manager_event_info *info)
static const char app_sendfax[]
static int generic_fax_exec(struct ast_channel *chan, struct ast_fax_session_details *details, struct ast_fax_session *reserved, struct ast_fax_tech_token *token)
this is the generic FAX session handling function
void ast_dsp_free(struct ast_dsp *dsp)
const char * ast_get_version(void)
Retrieve the Asterisk version string.
Convenient Signal Processing routines.
#define AST_RWLIST_WRLOCK(head)
Write locks a list.
int(*const cancel_session)(struct ast_fax_session *)
#define ao2_iterator_next(arg1)
enum ast_fax_modems modems
descriptor for a cli entry.
struct ast_variable * ast_variable_browse(const struct ast_config *config, const char *category)
Goes through variables.
static ast_rwlock_t options_lock
static char * ast_fax_caps_to_str(enum ast_fax_capabilities caps, char *buf, size_t bufsize)
int ast_app_parse_options(const struct ast_app_option *options, struct ast_flags *flags, char **args, char *optstr)
Parses a string containing application options and sets flags/arguments.
struct ast_dsp * ast_dsp_new(void)
#define AST_RWLIST_UNLOCK(head)
Attempts to unlock a read/write based list.
static void destroy_session(void *session)
destroy a FAX session structure
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application's arguments.
Structure for variables, used for configurations and for channel variables.
const ast_string_field transfer_rate
static void t38_parameters_ast_to_fax(struct ast_fax_t38_parameters *dst, const struct ast_control_t38_parameters *src)
static void t38_parameters_fax_to_ast(struct ast_control_t38_parameters *dst, const struct ast_fax_t38_parameters *src)
struct ast_frame * ast_read(struct ast_channel *chan)
Reads a frame.
struct ast_smoother * smoother
enum ast_control_t38 request_response
static int session_hash_cb(const void *obj, const int flags)
hash callback for ao2
Structure for a data store type.
Configuration File Parser.
int ast_indicate_data(struct ast_channel *chan, int condition, const void *data, size_t datalen)
Indicates condition of channel, with payload.
#define ast_log_dynamic_level(level,...)
Send a log message to a dynamically registered log level.
enum ast_control_t38_rate rate
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
#define AST_LIST_EMPTY(head)
Checks whether the specified list contains any entries.
static int session_cmp_cb(void *obj, void *arg, int flags)
compare callback for ao2
struct ao2_iterator ao2_iterator_init(struct ao2_container *c, int flags)
Create an iterator for a container.
#define AST_MODULE_INFO(keystr, flags_to_set, desc, fields...)
Structure for a data store object.
struct ast_datastore * ast_channel_datastore_find(struct ast_channel *chan, const struct ast_datastore_info *info, const char *uid)
Find a datastore on a channel.
Generic File Format Support. Should be included by clients of the file handling routines. File service providers should instead include mod_format.h.
const char *const description
void ast_playtones_stop(struct ast_channel *chan)
Stop playing tones on a channel.
static struct ast_fax_session_details * session_details_new(void)
create a FAX session details structure
char context[AST_MAX_CONTEXT]
struct ast_channel * chan
void ast_cli(int fd, const char *fmt,...)
#define ast_rwlock_unlock(a)
void *(*const new_session)(struct ast_fax_session *, struct ast_fax_tech_token *)
struct ao2_container * container
The asterisk data main content structure.
int ast_unregister_application(const char *app)
Unregister an application.
struct ast_config * ast_config_load2(const char *filename, const char *who_asked, struct ast_flags flags)
Load a config file.
struct ast_channel * ast_waitfor_nandfds(struct ast_channel **chan, int n, int *fds, int nfds, int *exception, int *outfd, int *ms)
Waits for activity on a group of channels.
#define ast_verb(level,...)
void ast_config_destroy(struct ast_config *config)
Destroys a config.
int ast_atomic_fetchadd_int(volatile int *p, int v)
Atomically add v to *p and return * the previous value of *p. This can be used to handle reference co...
int ast_custom_function_unregister(struct ast_custom_function *acf)
Unregister a custom function.
const char * pbx_builtin_getvar_helper(struct ast_channel *chan, const char *name)
Return a pointer to the value of the corresponding channel variable.
int args
This gets set in ast_cli_register()
static int load_module(void)
load res_fax
static struct @331 faxregistry
The faxregistry is used to manage information and statistics for all FAX sessions.
static char * cli_fax_show_sessions(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
display fax sessions
void ast_logger_unregister_level(const char *name)
Unregister a previously registered logger level.
int ast_set_write_format(struct ast_channel *chan, format_t format)
Sets write format on channel chan Set write format for channel to whichever component of "format" is ...
#define AST_RWLIST_RDLOCK(head)
Read locks a list.
struct ast_fax_debug_info * debug_info
char exten[AST_MAX_EXTENSION]
struct ast_fax_tech_token *(*const reserve_session)(struct ast_fax_session *)
static int update_modem_bits(enum ast_fax_modems *bits, const char *value)
int ast_set_read_format(struct ast_channel *chan, format_t format)
Sets read format on channel chan Set read format for channel to whichever component of "format" is be...
#define ast_debug(level,...)
Log a DEBUG message.
static int acf_faxopt_write(struct ast_channel *chan, const char *cmd, char *data, const char *value)
FAXOPT write function modifies the contents of a FAX option.
#define GENERIC_FAX_EXEC_SET_VARS(fax, chan, errorstr, reason)
unsigned int transcoding_mmr
struct ast_fax_t38_parameters our_t38_parameters
int ast_build_string(char **buffer, size_t *space, const char *fmt,...)
Build a string in a buffer, designed to be called repeatedly.
static char * cli_fax_show_version(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
General Asterisk PBX channel definitions.
static char * cli_fax_show_session(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
display details of a specified fax session
enum ast_fax_capabilities caps
char *(*const cli_show_session)(struct ast_fax_session *, int)
static int disable_t38(struct ast_channel *chan)
#define ast_string_field_init(x, size)
Initialize a field pool and fields.
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Data structure associated with a custom dialplan function.
static int check_modem_rate(enum ast_fax_modems modems, unsigned int rate)
#define AST_MAX_EXTENSION
#define AST_RWLIST_TRAVERSE
static const char app_receivefax[]
#define ao2_ref(o, delta)
struct ast_fax_session_details * details
enum ast_control_t38_rate rate
#define AST_RWLIST_REMOVE_CURRENT
static struct ast_fax_session * fax_session_new(struct ast_fax_session_details *details, struct ast_channel *chan, struct ast_fax_session *reserved, struct ast_fax_tech_token *token)
create a FAX session
The data communicated between the high level applications and the generic fax function.
static int sendfax_exec(struct ast_channel *chan, const char *data)
initiate a send FAX session
#define AST_LIST_REMOVE_HEAD(head, field)
Removes and returns the head entry from a list.
struct ast_module * module
const ast_string_field remotestationid
int ast_logger_register_level(const char *name)
Register a new logger level.
Core PBX routines and definitions.
unsigned int ast_fax_minrate(void)
get the minimum supported fax rate
#define AST_RWLIST_TRAVERSE_SAFE_BEGIN
void ast_dsp_set_threshold(struct ast_dsp *dsp, int threshold)
Set threshold value for silence.
void ast_dsp_reset(struct ast_dsp *dsp)
Reset total silence count.
The AMI - Asterisk Manager Interface - is a TCP protocol created to manage Asterisk with third-party ...
unsigned int transcoding_mmr
#define ast_strdupa(s)
duplicate a string in memory from the stack
unsigned int transcoding_jbig
static int set_fax_t38_caps(struct ast_channel *chan, struct ast_fax_session_details *details)
ast_fax_modems
fax modem capabilities
char *(*const cli_show_settings)(int)
#define AST_LIST_INSERT_TAIL(head, elm, field)
Appends a list entry to the tail of a list.
void(*const destroy_session)(struct ast_fax_session *)
int attribute_pure ast_true(const char *val)
Make sure something is true. Determine if a string containing a boolean value is "true". This function checks to see whether a string passed to it is an indication of an "true" value. It checks to see if the string is "yes", "true", "y", "t", "on" or "1".
union ast_fax_session_details::@203 option
unsigned int pages_transferred
static void fax_session_release(struct ast_fax_session *s, struct ast_fax_tech_token *token)
unsigned int ast_fax_maxrate(void)
get the maxiumum supported fax rate
int ast_remaining_ms(struct timeval start, int max_ms)
Calculate remaining milliseconds given a starting timestamp and upper bound.
unsigned int fill_bit_removal
static struct ast_datastore_info fax_datastore
static void set_channel_variables(struct ast_channel *chan, struct ast_fax_session_details *details)
Set fax related channel variables.
struct ast_fax_documents documents
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
enum ast_channel_state _state
const ast_string_field name
used to register a FAX technology module with res_fax
char * ast_skip_blanks(const char *str)
Gets a pointer to the first non-whitespace character in a string.
struct sla_ringing_trunk * first
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
#define ao2_alloc(data_size, destructor_fn)
struct ast_datastore * ast_datastore_alloc(const struct ast_datastore_info *info, const char *uid)
#define FAX_MAXBUCKETS
maximum buckets for res_fax ao2 containers
struct ast_fax_tech * tech
#define AST_LIST_TRAVERSE(head, var, field)
Loops over (traverses) the entries in a list.
#define ao2_find(arg1, arg2, arg3)
#define ast_channel_unlock(chan)
static void parse(struct mgcp_request *req)
const char *const version
char *(*const cli_show_capabilities)(int)
#define RES_FAX_STATUSEVENTS
static int acf_faxopt_read(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
FAXOPT read function returns the contents of a FAX option.
static int reload_module(void)
static char * cli_fax_set_debug(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
enable FAX debugging
ast_fax_capabilities
capabilities for res_fax to locate a fax technology module
ast_fax_state
current state of a fax session
enum ast_fax_modems modems
int ast_write(struct ast_channel *chan, struct ast_frame *frame)
Write a frame to a channel This function writes the given frame to the indicated channel.
void ast_fax_log(int level, const char *file, const int line, const char *function, const char *msg)
Log message at FAX or recommended level.
static int fax_logger_level
static int unload_module(void)
unload res_fax
static int global_fax_debug
void ao2_iterator_destroy(struct ao2_iterator *i)
Destroy a container iterator.
int(*const write)(struct ast_fax_session *, const struct ast_frame *)
Structure used to handle boolean flags.
static const char * config
Support for logging to various files, console and syslog Configuration in file logger.conf.
static void destroy_callback(void *data)
unsigned int transcoding_jbig
int pbx_builtin_setvar_helper(struct ast_channel *chan, const char *name, const char *value)
Add a variable to the channel variable stack, removing the most recently set value for the same name...
char *(*const cli_show_stats)(int)
#define ast_rwlock_wrlock(a)
static struct ast_app_option fax_exec_options[128]
static struct ast_fax_session * fax_session_reserve(struct ast_fax_session_details *details, struct ast_fax_tech_token **token)
registered FAX technology modules are put into this list
int ast_dsp_silence(struct ast_dsp *dsp, struct ast_frame *f, int *totalsilence)
Return non-zero if this is silence. Updates "totalsilence" with the total number of seconds of silenc...
#define AST_RWLIST_INSERT_TAIL
#define AST_LIST_HEAD_INIT_NOLOCK(head)
Initializes a list head structure.
#define AST_FORMAT_SLINEAR
static int set_config(int reload)
configure res_fax
int ast_waitfor(struct ast_channel *chan, int ms)
Wait for input on a channel.
When we need to walk through a container, we use an ao2_iterator to keep track of the current positio...
Standard Command Line Interface.
struct ast_fax_document * next
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
#define ao2_container_alloc(arg1, arg2, arg3)
static struct ast_fax_session_details * find_details(struct ast_channel *chan)
returns a reference counted pointer to a fax datastore, if it exists
#define S_OR(a, b)
returns the equivalent of logic or for strings: first one if not empty, otherwise second one...
int attribute_pure ast_false(const char *val)
Make sure something is false. Determine if a string containing a boolean value is "false"...
static void set_general_options(const struct fax_options *options)
int ast_cli_register_multiple(struct ast_cli_entry *e, int len)
Register multiple commands.
static struct fax_options general_options
static int report_fax_status(struct ast_channel *chan, struct ast_fax_session_details *details, const char *status)
send a FAX status manager event
int ast_answer(struct ast_channel *chan)
Answer a channel.
enum ast_control_t38_rate_management rate_management
The data required to handle a fax session.
Application convenience functions, designed to give consistent look and feel to Asterisk apps...
static char * fax_session_tab_complete(struct ast_cli_args *a)
fax session tab completion
static void debug_check_frame_for_silence(struct ast_fax_session *s, unsigned int c2s, struct ast_frame *frame)
const char * ast_fax_state_to_str(enum ast_fax_state state)
convert an ast_fax_state to a string
Data structure associated with a single frame of data.
enum ast_control_t38_rate_management rate_management
static char * cli_fax_show_settings(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
display global defaults and settings
enum ast_fax_capabilities caps
int ast_playtones_start(struct ast_channel *chan, int vol, const char *tonelist, int interruptible)
Start playing a list of tones on a channel.
Options provided by main asterisk program.
struct timeval ast_tvsub(struct timeval a, struct timeval b)
Returns the difference of two timevals a - b.
static int ast_fax_modem_to_str(enum ast_fax_modems bits, char *tbuf, size_t bufsize)
const ast_string_field resultstr
#define AST_APP_ARG(name)
Define an application argument.
enum ast_frame_type frametype
struct ast_variable * next
struct ast_frame *(*const read)(struct ast_fax_session *)
const ast_string_field localstationid
static char * cli_fax_show_stats(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
display fax stats
#define AST_STANDARD_APP_ARGS(args, parse)
Performs the 'standard' argument separation process for an application.
#define CONFIG_STATUS_FILEINVALID
static char context[AST_MAX_CONTEXT]
const ast_string_field error
#define ASTERISK_GPL_KEY
The text the key() function should return.
#define manager_event(category, event, contents,...)
External routines may send asterisk manager events this way.
static struct ast_cli_entry fax_cli[]
Asterisk module definitions.
struct debug_info_history c2s s2c
unsigned int fill_bit_removal
static char * cli_fax_show_capabilities(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
display registered FAX capabilities
struct ast_fax_t38_parameters their_t38_parameters
union ast_frame::@172 data
static struct ast_fax_session_details * find_or_create_details(struct ast_channel *chan)
returns a reference counted details structure from the channel's fax datastore. If the datastore does...
static int sendfax_t38_init(struct ast_channel *chan, struct ast_fax_session_details *details)
int ast_channel_datastore_add(struct ast_channel *chan, struct ast_datastore *datastore)
Add a datastore to a channel.
#define ast_string_field_free_memory(x)
free all memory - to be called before destroying the object
#define ao2_unlink(arg1, arg2)
const ast_string_field resolution
#define ast_custom_function_register(acf)
Register a custom function.
#define AST_RWLIST_TRAVERSE_SAFE_END
int(*const generate_silence)(struct ast_fax_session *)
#define ast_register_application_xml(app, execute)
Register an application using XML documentation.
struct ast_custom_function acf_faxopt
FAXOPT dialplan function.
#define ASTERISK_FILE_VERSION(file, version)
Register/unregister a source code file with the core.
#define AST_APP_OPTION(option, flagno)
Declares an application option that does not accept an argument.
#define CONFIG_STATUS_FILEUNCHANGED
int ast_fax_tech_register(struct ast_fax_tech *tech)
register a fax technology
static char * generate_filenames_string(struct ast_fax_session_details *details, char *prefix, char *separator)
#define ast_smoother_feed(s, f)
static char prefix[MAX_PREFIX]
#define ast_string_field_set(x, field, data)
Set a field to a simple string value.
struct ast_module * ast_module_ref(struct ast_module *)
static void get_general_options(struct fax_options *options)