Asterisk - The Open Source Telephony Project  GIT-master-a24979a
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.

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_TECH_T38
Definition: res_fax.h:43
@ AST_FAX_TECH_AUDIO
Definition: res_fax.h:41
@ AST_FAX_TECH_RECEIVE
Definition: res_fax.h:39
@ AST_FAX_TECH_V21_DETECT
Definition: res_fax.h:49
@ AST_FAX_TECH_MULTI_DOC
Definition: res_fax.h:45
@ AST_FAX_TECH_SEND
Definition: res_fax.h:37
@ AST_FAX_TECH_GATEWAY
Definition: res_fax.h:47

◆ 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_MODEM_V17
Definition: res_fax.h:55
@ AST_FAX_MODEM_V29
Definition: res_fax.h:59
@ AST_FAX_MODEM_V27TER
Definition: res_fax.h:57
@ AST_FAX_MODEM_V34
Definition: res_fax.h:61

◆ 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_OPTFLAG_DEFAULT
Definition: res_fax.h:89
@ AST_FAX_OPTFLAG_FALSE
Definition: res_fax.h:85
@ AST_FAX_OPTFLAG_TRUE
Definition: res_fax.h:87

◆ 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 };
@ AST_FAX_STATE_INITIALIZED
Definition: res_fax.h:69
@ AST_FAX_STATE_INACTIVE
Definition: res_fax.h:79
@ AST_FAX_STATE_ACTIVE
Definition: res_fax.h:73
@ AST_FAX_STATE_COMPLETE
Definition: res_fax.h:75
@ AST_FAX_STATE_OPEN
Definition: res_fax.h:71
@ AST_FAX_STATE_UNINITIALIZED
Definition: res_fax.h:67
@ AST_FAX_STATE_RESERVED
Definition: res_fax.h:77

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 1035 of file res_fax.c.

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

References ast_log, ast_log_dynamic_level, fax_logger_level, and make_ari_stubs::file.

Referenced by spandsp_log().

◆ ast_fax_maxrate()

unsigned int ast_fax_maxrate ( void  )

get the maxiumum supported fax rate

Definition at line 795 of file res_fax.c.

796 {
797  struct fax_options options;
799 
800  return options.maxrate;
801 }
static void get_general_options(struct fax_options *options)
Definition: res_fax.c:4396
static struct test_options options

References get_general_options(), and options.

◆ ast_fax_minrate()

unsigned int ast_fax_minrate ( void  )

get the minimum supported fax rate

Definition at line 803 of file res_fax.c.

804 {
805  struct fax_options options;
807 
808  return options.minrate;
809 }

References get_general_options(), and options.

◆ 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 4253 of file res_fax.c.

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

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().

◆ 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 1012 of file res_fax.c.

1013 {
1014  switch (state) {
1016  return "Uninitialized";
1018  return "Initialized";
1019  case AST_FAX_STATE_OPEN:
1020  return "Open";
1021  case AST_FAX_STATE_ACTIVE:
1022  return "Active";
1024  return "Complete";
1026  return "Reserved";
1028  return "Inactive";
1029  default:
1030  ast_log(LOG_WARNING, "unhandled FAX state: %u\n", state);
1031  return "Unknown";
1032  }
1033 }
#define LOG_WARNING

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().

◆ 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 973 of file res_fax.c.

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

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.

◆ 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 991 of file res_fax.c.

992 {
993  struct fax_module *fax;
994 
995  ast_verb(3, "Unregistering FAX module type '%s'\n", tech->type);
996 
999  if (fax->tech != tech) {
1000  continue;
1001  }
1003  ast_free(fax);
1004  ast_verb(4, "Unregistered FAX module type '%s'\n", tech->type);
1005  break;
1006  }
1009 }
#define ast_free(a)
Definition: astmm.h:180
#define AST_RWLIST_REMOVE_CURRENT
Definition: linkedlists.h:570
#define AST_RWLIST_TRAVERSE_SAFE_BEGIN
Definition: linkedlists.h:545
#define AST_RWLIST_TRAVERSE_SAFE_END
Definition: linkedlists.h:617

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().