Asterisk - The Open Source Telephony Project  18.5.0
Data Structures | Macros | Enumerations | Functions
res_fax.h File Reference
#include "asterisk.h"
#include "asterisk/lock.h"
#include "asterisk/linkedlists.h"
#include "asterisk/module.h"
#include "asterisk/utils.h"
#include "asterisk/options.h"
#include "asterisk/frame.h"
#include "asterisk/cli.h"
#include "asterisk/stringfields.h"
#include "asterisk/manager.h"
Include dependency graph for res_fax.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  ast_fax_document
 
struct  ast_fax_documents
 
struct  ast_fax_session
 The data required to handle a fax session. More...
 
struct  ast_fax_session_details
 The data communicated between the high level applications and the generic fax function. More...
 
struct  ast_fax_t38_parameters
 
struct  ast_fax_tech
 used to register a FAX technology module with res_fax More...
 

Macros

#define AST_FAX_FRFLAG_GATEWAY   (1 << 13)
 

Enumerations

enum  ast_fax_capabilities {
  AST_FAX_TECH_SEND = (1 << 0), AST_FAX_TECH_RECEIVE = (1 << 1), AST_FAX_TECH_AUDIO = (1 << 2), AST_FAX_TECH_T38 = (1 << 3),
  AST_FAX_TECH_MULTI_DOC = (1 << 4), AST_FAX_TECH_GATEWAY = (1 << 5), AST_FAX_TECH_V21_DETECT = (1 << 6)
}
 capabilities for res_fax to locate a fax technology module More...
 
enum  ast_fax_modems { AST_FAX_MODEM_V17 = (1 << 0), AST_FAX_MODEM_V27TER = (1 << 1), AST_FAX_MODEM_V29 = (1 << 2), AST_FAX_MODEM_V34 = (1 << 3) }
 fax modem capabilities More...
 
enum  ast_fax_optflag { AST_FAX_OPTFLAG_FALSE = 0, AST_FAX_OPTFLAG_TRUE, AST_FAX_OPTFLAG_DEFAULT }
 fax session options More...
 
enum  ast_fax_state {
  AST_FAX_STATE_UNINITIALIZED = 0, AST_FAX_STATE_INITIALIZED, AST_FAX_STATE_OPEN, AST_FAX_STATE_ACTIVE,
  AST_FAX_STATE_COMPLETE, AST_FAX_STATE_RESERVED, AST_FAX_STATE_INACTIVE
}
 current state of a fax session More...
 

Functions

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. More...
 
unsigned int ast_fax_maxrate (void)
 get the maxiumum supported fax rate More...
 
unsigned int ast_fax_minrate (void)
 get the minimum supported fax rate More...
 
const char * ast_fax_session_operation_str (struct ast_fax_session *s)
 get string representation of a FAX session's operation More...
 
const char * ast_fax_state_to_str (enum ast_fax_state state)
 convert an ast_fax_state to a string More...
 
int ast_fax_tech_register (struct ast_fax_tech *tech)
 register a fax technology More...
 
void ast_fax_tech_unregister (struct ast_fax_tech *tech)
 unregister a fax technology More...
 

Macro Definition Documentation

◆ AST_FAX_FRFLAG_GATEWAY

#define AST_FAX_FRFLAG_GATEWAY   (1 << 13)

Definition at line 232 of file res_fax.h.

Referenced by fax_gateway_framehook(), spandsp_fax_gw_t30_gen(), and t38_tx_packet_handler().

Enumeration Type Documentation

◆ ast_fax_capabilities

capabilities for res_fax to locate a fax technology module

Enumerator
AST_FAX_TECH_SEND 

SendFax is supported

AST_FAX_TECH_RECEIVE 

ReceiveFax is supported

AST_FAX_TECH_AUDIO 

Audio FAX session supported

AST_FAX_TECH_T38 

T.38 FAX session supported

AST_FAX_TECH_MULTI_DOC 

sending mulitple documents supported

AST_FAX_TECH_GATEWAY 

T.38 - T.30 Gateway

AST_FAX_TECH_V21_DETECT 

V21 detection is supported

Definition at line 35 of file res_fax.h.

35  {
36  /*! SendFax is supported */
37  AST_FAX_TECH_SEND = (1 << 0),
38  /*! ReceiveFax is supported */
39  AST_FAX_TECH_RECEIVE = (1 << 1),
40  /*! Audio FAX session supported */
41  AST_FAX_TECH_AUDIO = (1 << 2),
42  /*! T.38 FAX session supported */
43  AST_FAX_TECH_T38 = (1 << 3),
44  /*! sending mulitple documents supported */
45  AST_FAX_TECH_MULTI_DOC = (1 << 4),
46  /*! T.38 - T.30 Gateway */
47  AST_FAX_TECH_GATEWAY = (1 << 5),
48  /*! V21 detection is supported */
49  AST_FAX_TECH_V21_DETECT = (1 << 6),
50 };

◆ ast_fax_modems

fax modem capabilities

Enumerator
AST_FAX_MODEM_V17 

V.17

AST_FAX_MODEM_V27TER 

V.27ter

AST_FAX_MODEM_V29 

V.29

AST_FAX_MODEM_V34 

V.34

Definition at line 53 of file res_fax.h.

53  {
54  /*! V.17 */
55  AST_FAX_MODEM_V17 = (1 << 0),
56  /*! V.27ter */
57  AST_FAX_MODEM_V27TER = (1 << 1),
58  /*! V.29 */
59  AST_FAX_MODEM_V29 = (1 << 2),
60  /*! V.34 */
61  AST_FAX_MODEM_V34 = (1 << 3),
62 };

◆ ast_fax_optflag

fax session options

Enumerator
AST_FAX_OPTFLAG_FALSE 

false/disable configuration override

AST_FAX_OPTFLAG_TRUE 

true/enable configuration override

AST_FAX_OPTFLAG_DEFAULT 

use the configured default

Definition at line 83 of file res_fax.h.

83  {
84  /*! false/disable configuration override */
86  /*! true/enable configuration override */
88  /*! use the configured default */
90 };

◆ ast_fax_state

current state of a fax session

Enumerator
AST_FAX_STATE_UNINITIALIZED 

uninitialized state

AST_FAX_STATE_INITIALIZED 

initialized state

AST_FAX_STATE_OPEN 

fax resources open state

AST_FAX_STATE_ACTIVE 

fax session in progress

AST_FAX_STATE_COMPLETE 

fax session complete

AST_FAX_STATE_RESERVED 

reserved state

AST_FAX_STATE_INACTIVE 

inactive state

Definition at line 65 of file res_fax.h.

65  {
66  /*! uninitialized state */
68  /*! initialized state */
70  /*! fax resources open state */
72  /*! fax session in progress */
74  /*! fax session complete */
76  /*! reserved state */
78  /*! inactive state */
80 };

Function Documentation

◆ ast_fax_log()

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.

The first four parameters can be represented with Asterisk's LOG_* levels. In other words, this function may be called like

ast_fax_log(LOG_DEBUG, msg);

Definition at line 1036 of file res_fax.c.

References ast_log, ast_log_dynamic_level, and fax_logger_level.

Referenced by spandsp_log().

1037 {
1038  if (fax_logger_level != -1) {
1040  } else {
1041  ast_log(level, file, line, function, "%s", msg);
1042  }
1043 }
#define ast_log_dynamic_level(level,...)
Send a log message to a dynamically registered log level.
Definition: logger.h:439
#define ast_log
Definition: astobj2.c:42
static int fax_logger_level
Definition: res_fax.c:487

◆ ast_fax_maxrate()

unsigned int ast_fax_maxrate ( void  )

get the maxiumum supported fax rate

Definition at line 796 of file res_fax.c.

References get_general_options(), and fax_options::maxrate.

Referenced by acf_faxopt_write().

797 {
798  struct fax_options options;
800 
801  return options.maxrate;
802 }
static struct test_options options
static void get_general_options(struct fax_options *options)
Definition: res_fax.c:4397

◆ ast_fax_minrate()

unsigned int ast_fax_minrate ( void  )

get the minimum supported fax rate

Definition at line 804 of file res_fax.c.

References get_general_options(), and fax_options::minrate.

Referenced by acf_faxopt_write().

805 {
806  struct fax_options options;
808 
809  return options.minrate;
810 }
static struct test_options options
static void get_general_options(struct fax_options *options)
Definition: res_fax.c:4397

◆ ast_fax_session_operation_str()

const char* ast_fax_session_operation_str ( struct ast_fax_session s)

get string representation of a FAX session's operation

Definition at line 4254 of file res_fax.c.

References AST_FAX_TECH_GATEWAY, AST_FAX_TECH_RECEIVE, AST_FAX_TECH_SEND, AST_FAX_TECH_V21_DETECT, ast_fax_session_details::caps, and ast_fax_session::details.

Referenced by cli_fax_show_sessions(), manager_fax_sessions_entry(), and spandsp_manager_fax_session().

4255 {
4256  if (s->details->caps & AST_FAX_TECH_GATEWAY) {
4257  return "gateway";
4258  }
4259  if (s->details->caps & AST_FAX_TECH_SEND) {
4260  return "send";
4261  }
4262  if (s->details->caps & AST_FAX_TECH_RECEIVE) {
4263  return "receive";
4264  }
4265  if (s->details->caps & AST_FAX_TECH_V21_DETECT) {
4266  return "V.21";
4267  }
4268 
4269  return "none";
4270 }
struct ast_fax_session_details * details
Definition: res_fax.h:208
enum ast_fax_capabilities caps
Definition: res_fax.h:113

◆ ast_fax_state_to_str()

const char* ast_fax_state_to_str ( enum ast_fax_state  state)

convert an ast_fax_state to a string

convert an ast_fax_state to a string

Definition at line 1013 of file res_fax.c.

References AST_FAX_STATE_ACTIVE, AST_FAX_STATE_COMPLETE, AST_FAX_STATE_INACTIVE, AST_FAX_STATE_INITIALIZED, AST_FAX_STATE_OPEN, AST_FAX_STATE_RESERVED, AST_FAX_STATE_UNINITIALIZED, ast_log, and LOG_WARNING.

Referenced by cli_fax_show_sessions(), manager_fax_sessions_entry(), spandsp_fax_cli_show_session(), spandsp_fax_write(), and spandsp_manager_fax_session().

1014 {
1015  switch (state) {
1017  return "Uninitialized";
1019  return "Initialized";
1020  case AST_FAX_STATE_OPEN:
1021  return "Open";
1022  case AST_FAX_STATE_ACTIVE:
1023  return "Active";
1025  return "Complete";
1027  return "Reserved";
1029  return "Inactive";
1030  default:
1031  ast_log(LOG_WARNING, "unhandled FAX state: %u\n", state);
1032  return "Unknown";
1033  }
1034 }
#define LOG_WARNING
Definition: logger.h:274
#define ast_log
Definition: astobj2.c:42

◆ ast_fax_tech_register()

int ast_fax_tech_register ( struct ast_fax_tech tech)

register a fax technology

register a fax technology

Definition at line 974 of file res_fax.c.

References ast_calloc, AST_RWLIST_INSERT_TAIL, AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, ast_verb, ast_fax_tech::description, fax_module::tech, and ast_fax_tech::type.

Referenced by load_module().

975 {
976  struct fax_module *fax;
977 
978  if (!(fax = ast_calloc(1, sizeof(*fax)))) {
979  return -1;
980  }
981  fax->tech = tech;
983  AST_RWLIST_INSERT_TAIL(&faxmodules, fax, list);
985 
986  ast_verb(3, "Registered handler for '%s' (%s)\n", fax->tech->type, fax->tech->description);
987 
988  return 0;
989 }
#define AST_RWLIST_WRLOCK(head)
Write locks a list.
Definition: linkedlists.h:51
const char *const type
Definition: res_fax.h:237
#define AST_RWLIST_UNLOCK(head)
Attempts to unlock a read/write based list.
Definition: linkedlists.h:150
const struct ast_fax_tech * tech
Definition: res_fax.c:517
const char *const description
Definition: res_fax.h:239
#define ast_verb(level,...)
Definition: logger.h:463
#define ast_calloc(num, len)
A wrapper for calloc()
Definition: astmm.h:204
registered FAX technology modules are put into this list
Definition: res_fax.c:516
#define AST_RWLIST_INSERT_TAIL
Definition: linkedlists.h:740

◆ ast_fax_tech_unregister()

void ast_fax_tech_unregister ( struct ast_fax_tech tech)

unregister a fax technology

unregister a fax technology

Definition at line 992 of file res_fax.c.

References ast_free, AST_RWLIST_REMOVE_CURRENT, AST_RWLIST_TRAVERSE_SAFE_BEGIN, AST_RWLIST_TRAVERSE_SAFE_END, AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, ast_verb, fax_module::tech, and ast_fax_tech::type.

Referenced by unload_module().

993 {
994  struct fax_module *fax;
995 
996  ast_verb(3, "Unregistering FAX module type '%s'\n", tech->type);
997 
1000  if (fax->tech != tech) {
1001  continue;
1002  }
1004  ast_free(fax);
1005  ast_verb(4, "Unregistered FAX module type '%s'\n", tech->type);
1006  break;
1007  }
1010 }
#define AST_RWLIST_WRLOCK(head)
Write locks a list.
Definition: linkedlists.h:51
const char *const type
Definition: res_fax.h:237
#define AST_RWLIST_UNLOCK(head)
Attempts to unlock a read/write based list.
Definition: linkedlists.h:150
const struct ast_fax_tech * tech
Definition: res_fax.c:517
#define ast_verb(level,...)
Definition: logger.h:463
#define AST_RWLIST_REMOVE_CURRENT
Definition: linkedlists.h:569
#define AST_RWLIST_TRAVERSE_SAFE_BEGIN
Definition: linkedlists.h:544
#define ast_free(a)
Definition: astmm.h:182
registered FAX technology modules are put into this list
Definition: res_fax.c:516
#define AST_RWLIST_TRAVERSE_SAFE_END
Definition: linkedlists.h:616