Asterisk - The Open Source Telephony Project GIT-master-f36a736
|
UDPTL support for T.38 faxing. More...
#include "asterisk.h"
#include <sys/time.h>
#include <signal.h>
#include <fcntl.h>
#include "asterisk/module.h"
#include "asterisk/udptl.h"
#include "asterisk/frame.h"
#include "asterisk/channel.h"
#include "asterisk/acl.h"
#include "asterisk/config_options.h"
#include "asterisk/lock.h"
#include "asterisk/utils.h"
#include "asterisk/netsock2.h"
#include "asterisk/cli.h"
#include "asterisk/unaligned.h"
Go to the source code of this file.
Data Structures | |
struct | ast_udptl |
Structure for an UDPTL session. More... | |
struct | udptl_config |
struct | udptl_fec_rx_buffer_t |
struct | udptl_fec_tx_buffer_t |
struct | udptl_global_options |
Macros | |
#define | DEFAULT_FAX_MAX_DATAGRAM 400 |
#define | DEFAULT_UDPTLEND 4999 |
#define | DEFAULT_UDPTLSTART 4000 |
#define | FALSE 0 |
#define | FAX_MAX_DATAGRAM_LIMIT 1400 |
#define | LOCAL_FAX_MAX_DATAGRAM 1400 |
#define | LOG_TAG(u) S_OR(u->tag, "no tag") |
#define | MAX_FEC_ENTRIES 5 |
#define | MAX_FEC_SPAN 5 |
#define | TRUE (!FALSE) |
#define | UDPTL_BUF_MASK 15 |
#define | UDPTL_MTU 1200 |
Functions | |
static void | __ast_udptl_reload (int reload) |
static void | __reg_module (void) |
static void | __unreg_module (void) |
static | AO2_GLOBAL_OBJ_STATIC (globals) |
struct ast_module * | AST_MODULE_SELF_SYM (void) |
void | ast_udptl_destroy (struct ast_udptl *udptl) |
int | ast_udptl_fd (const struct ast_udptl *udptl) |
enum ast_t38_ec_modes | ast_udptl_get_error_correction_scheme (const struct ast_udptl *udptl) |
unsigned int | ast_udptl_get_far_max_datagram (const struct ast_udptl *udptl) |
unsigned int | ast_udptl_get_far_max_ifp (struct ast_udptl *udptl) |
retrieves far max ifp More... | |
unsigned int | ast_udptl_get_local_max_datagram (struct ast_udptl *udptl) |
retrieves local_max_datagram. More... | |
void | ast_udptl_get_peer (const struct ast_udptl *udptl, struct ast_sockaddr *them) |
void | ast_udptl_get_us (const struct ast_udptl *udptl, struct ast_sockaddr *us) |
struct ast_udptl * | ast_udptl_new_with_bindaddr (struct ast_sched_context *sched, struct io_context *io, int callbackmode, struct ast_sockaddr *addr) |
struct ast_frame * | ast_udptl_read (struct ast_udptl *udptl) |
void | ast_udptl_set_callback (struct ast_udptl *udptl, ast_udptl_callback callback) |
void | ast_udptl_set_data (struct ast_udptl *udptl, void *data) |
void | ast_udptl_set_error_correction_scheme (struct ast_udptl *udptl, enum ast_t38_ec_modes ec) |
void | ast_udptl_set_far_max_datagram (struct ast_udptl *udptl, unsigned int max_datagram) |
sets far max datagram size. If max_datagram is = 0, the far max datagram size is set to a default value. More... | |
void | ast_udptl_set_local_max_ifp (struct ast_udptl *udptl, unsigned int max_ifp) |
void | ast_udptl_set_peer (struct ast_udptl *udptl, const struct ast_sockaddr *them) |
void | ast_udptl_set_tag (struct ast_udptl *udptl, const char *format,...) |
Associates a character string 'tag' with a UDPTL session. More... | |
void | ast_udptl_setnat (struct ast_udptl *udptl, int nat) |
int | ast_udptl_setqos (struct ast_udptl *udptl, unsigned int tos, unsigned int cos) |
void | ast_udptl_stop (struct ast_udptl *udptl) |
int | ast_udptl_write (struct ast_udptl *s, struct ast_frame *f) |
static void | calculate_far_max_ifp (struct ast_udptl *udptl) |
static void | calculate_local_max_datagram (struct ast_udptl *udptl) |
CONFIG_INFO_CORE ("udptl", cfg_info, globals, udptl_snapshot_alloc,.files=ACO_FILES(&udptl_conf),.pre_apply_config=udptl_pre_apply_config,) | |
static int | decode_length (uint8_t *buf, unsigned int limit, unsigned int *len, unsigned int *pvalue) |
static int | decode_open_type (uint8_t *buf, unsigned int limit, unsigned int *len, const uint8_t **p_object, unsigned int *p_num_octets) |
static unsigned int | encode_length (uint8_t *buf, unsigned int *len, unsigned int value) |
static int | encode_open_type (const struct ast_udptl *udptl, uint8_t *buf, unsigned int buflen, unsigned int *len, const uint8_t *data, unsigned int num_octets) |
static char * | handle_cli_show_config (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
static char * | handle_cli_udptl_set_debug (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
static int | load_module (void) |
static int | reload_module (void) |
static int | removed_options_handler (const struct aco_option *opt, struct ast_variable *var, void *obj) |
static int | udptl_build_packet (struct ast_udptl *s, uint8_t *buf, unsigned int buflen, uint8_t *ifp, unsigned int ifp_len) |
static void | udptl_config_destructor (void *obj) |
static int | udptl_debug_test_addr (const struct ast_sockaddr *addr) |
static int | udptl_pre_apply_config (void) |
static int | udptl_rx_packet (struct ast_udptl *s, uint8_t *buf, unsigned int len) |
static void * | udptl_snapshot_alloc (void) |
static int | udptlread (int *id, int fd, short events, void *cbdata) |
static int | unload_module (void) |
Variables | |
static struct ast_module_info | __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_GLOBAL_SYMBOLS | AST_MODFLAG_LOAD_ORDER , .description = "UDPTL" , .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, .support_level = AST_MODULE_SUPPORT_CORE, .load = load_module, .unload = unload_module, .reload = reload_module, .load_pri = AST_MODPRI_CORE, .requires = "extconfig", } |
static const struct ast_module_info * | ast_module_info = &__mod_info |
static struct ast_cli_entry | cli_udptl [] |
static struct aco_type | general_option |
static struct aco_type * | general_options [] = ACO_TYPES(&general_option) |
static struct aco_file | udptl_conf |
static int | udptldebug |
static struct ast_sockaddr | udptldebugaddr |
UDPTL support for T.38 faxing.
Definition in file udptl.c.
|
static |
Definition at line 1325 of file udptl.c.
References aco_process_config(), ACO_PROCESS_ERROR, aco_set_defaults(), ao2_cleanup, ao2_global_obj_replace_unref, ast_log, general_option, globals, LOG_ERROR, LOG_NOTICE, RAII_VAR, reload(), and udptl_snapshot_alloc().
Referenced by load_module(), and reload_module().
|
static |
struct ast_module * AST_MODULE_SELF_SYM | ( | void | ) |
void ast_udptl_destroy | ( | struct ast_udptl * | udptl | ) |
Definition at line 1148 of file udptl.c.
References ast_free, ast_io_remove(), ast_udptl::fd, ast_udptl::io, ast_udptl::ioid, and ast_udptl::tag.
Referenced by ooh323_destroy(), and stream_destroy().
int ast_udptl_fd | ( | const struct ast_udptl * | udptl | ) |
Definition at line 728 of file udptl.c.
References ast_udptl::fd.
Referenced by apply_negotiated_sdp_stream(), and configure_local_rtp().
enum ast_t38_ec_modes ast_udptl_get_error_correction_scheme | ( | const struct ast_udptl * | udptl | ) |
Definition at line 938 of file udptl.c.
References ast_udptl::error_correction_scheme.
Referenced by create_outgoing_sdp_stream().
unsigned int ast_udptl_get_far_max_datagram | ( | const struct ast_udptl * | udptl | ) |
Definition at line 1006 of file udptl.c.
References ast_udptl::far_max_datagram.
unsigned int ast_udptl_get_far_max_ifp | ( | struct ast_udptl * | udptl | ) |
retrieves far max ifp
0 | if no value is present |
Definition at line 1014 of file udptl.c.
References calculate_far_max_ifp(), and ast_udptl::far_max_ifp.
Referenced by onModeChanged(), ooh323_indicate(), setup_udptl_connection(), t38_change_state(), and t38_interpret_parameters().
unsigned int ast_udptl_get_local_max_datagram | ( | struct ast_udptl * | udptl | ) |
retrieves local_max_datagram.
0 | if no value is present |
Definition at line 982 of file udptl.c.
References calculate_local_max_datagram(), and ast_udptl::local_max_datagram.
Referenced by create_outgoing_sdp_stream().
void ast_udptl_get_peer | ( | const struct ast_udptl * | udptl, |
struct ast_sockaddr * | them | ||
) |
Definition at line 1133 of file udptl.c.
References ast_sockaddr_copy(), and ast_udptl::them.
void ast_udptl_get_us | ( | const struct ast_udptl * | udptl, |
struct ast_sockaddr * | us | ||
) |
Definition at line 1138 of file udptl.c.
References ast_sockaddr_copy(), and ast_udptl::us.
Referenced by configure_local_rtp(), and create_outgoing_sdp_stream().
struct ast_udptl * ast_udptl_new_with_bindaddr | ( | struct ast_sched_context * | sched, |
struct io_context * | io, | ||
int | callbackmode, | ||
struct ast_sockaddr * | addr | ||
) |
Definition at line 1026 of file udptl.c.
References ao2_cleanup, ao2_global_obj_ref, ast_bind(), ast_calloc, ast_free, ast_io_add(), AST_IO_IN, ast_log, ast_random(), ast_sockaddr_copy(), ast_sockaddr_is_ipv6(), ast_sockaddr_set_port, ast_socket_nonblock, udptl_fec_tx_buffer_t::buf_len, udptl_fec_rx_buffer_t::buf_len, errno, ast_udptl::error_correction_entries, ast_udptl::error_correction_span, ast_udptl::far_max_datagram, ast_udptl::far_max_ifp, ast_udptl::fd, globals, io, ast_udptl::io, ast_udptl::ioid, ast_udptl::local_max_datagram, ast_udptl::local_max_ifp, LOG_ERROR, LOG_WARNING, NULL, RAII_VAR, ast_udptl::rx, sched, ast_udptl::sched, ast_udptl::tx, UDPTL_BUF_MASK, udptlread(), and ast_udptl::us.
Referenced by configure_local_rtp(), and t38_initialize_session().
Definition at line 760 of file udptl.c.
References ast_assert, ast_debug, AST_FRIENDLY_OFFSET, ast_log, ast_null_frame, ast_recvfrom(), ast_sockaddr_cmp(), ast_sockaddr_copy(), ast_sockaddr_isnull(), ast_sockaddr_stringify(), ast_verb, buf, errno, ast_udptl::f, ast_udptl::fd, LOG_TAG, LOG_WARNING, ast_udptl::nat, NULL, ast_udptl::rawdata, ast_udptl::tag, ast_udptl::them, udptl_debug_test_addr(), and udptl_rx_packet().
Referenced by media_session_udptl_read_callback(), ooh323_rtp_read(), and udptlread().
void ast_udptl_set_callback | ( | struct ast_udptl * | udptl, |
ast_udptl_callback | callback | ||
) |
Definition at line 738 of file udptl.c.
References ast_udptl::callback.
void ast_udptl_set_data | ( | struct ast_udptl * | udptl, |
void * | data | ||
) |
Definition at line 733 of file udptl.c.
References ast_udptl::data.
void ast_udptl_set_error_correction_scheme | ( | struct ast_udptl * | udptl, |
enum ast_t38_ec_modes | ec | ||
) |
Definition at line 943 of file udptl.c.
References ast_udptl::error_correction_entries, ast_udptl::error_correction_scheme, ast_udptl::error_correction_span, ast_udptl::far_max_ifp, ast_udptl::local_max_datagram, UDPTL_ERROR_CORRECTION_FEC, and UDPTL_ERROR_CORRECTION_REDUNDANCY.
Referenced by t38_initialize_session(), and t38_interpret_sdp().
void ast_udptl_set_far_max_datagram | ( | struct ast_udptl * | udptl, |
unsigned int | max_datagram | ||
) |
sets far max datagram size. If max_datagram is = 0, the far max datagram size is set to a default value.
Definition at line 995 of file udptl.c.
References DEFAULT_FAX_MAX_DATAGRAM, ast_udptl::far_max_datagram, ast_udptl::far_max_ifp, and FAX_MAX_DATAGRAM_LIMIT.
Referenced by configure_local_rtp(), onModeChanged(), t38_initialize_session(), and t38_interpret_sdp().
void ast_udptl_set_local_max_ifp | ( | struct ast_udptl * | udptl, |
unsigned int | max_ifp | ||
) |
Definition at line 971 of file udptl.c.
References ast_udptl::local_max_datagram, and ast_udptl::local_max_ifp.
Referenced by t38_interpret_parameters().
void ast_udptl_set_peer | ( | struct ast_udptl * | udptl, |
const struct ast_sockaddr * | them | ||
) |
Definition at line 1128 of file udptl.c.
References ast_sockaddr_copy(), and ast_udptl::them.
Referenced by apply_negotiated_sdp_stream(), and setup_udptl_connection().
void ast_udptl_set_tag | ( | struct ast_udptl * | udptl, |
const char * | format, | ||
... | |||
) |
Associates a character string 'tag' with a UDPTL session.
udptl | The UDPTL session. |
format | printf-style format string used to construct the tag |
This function formats a tag for the specified UDPTL session, so that any log messages generated by the UDPTL stack related to that session will include the tag and the reader of the messages will be able to identify which endpoint caused them to be generated.
Definition at line 1110 of file udptl.c.
References ast_free, ast_vasprintf, NULL, and ast_udptl::tag.
Referenced by setup_udptl_connection(), and t38_change_state().
void ast_udptl_setnat | ( | struct ast_udptl * | udptl, |
int | nat | ||
) |
Definition at line 743 of file udptl.c.
References ast_udptl::nat.
Referenced by t38_initialize_session().
int ast_udptl_setqos | ( | struct ast_udptl * | udptl, |
unsigned int | tos, | ||
unsigned int | cos | ||
) |
Definition at line 1123 of file udptl.c.
References ast_set_qos(), cos, ast_udptl::fd, and tos.
void ast_udptl_stop | ( | struct ast_udptl * | udptl | ) |
Definition at line 1143 of file udptl.c.
References ast_sockaddr_setnull(), and ast_udptl::them.
Definition at line 1159 of file udptl.c.
References AST_FRAME_MODEM, ast_log, AST_MODEM_T38, ast_sendto(), ast_sockaddr_isnull(), ast_sockaddr_stringify(), ast_verb, buf, ast_frame::data, ast_frame::datalen, DEFAULT_FAX_MAX_DATAGRAM, errno, ast_udptl::f, ast_udptl::far_max_datagram, ast_udptl::far_max_ifp, ast_udptl::fd, ast_frame::frametype, ast_frame_subclass::integer, len(), LOG_NOTICE, LOG_TAG, LOG_WARNING, ast_frame::ptr, seq, ast_frame::subclass, ast_udptl::them, ast_udptl::tx_seq_no, udptl_build_packet(), and udptl_debug_test_addr().
Referenced by media_session_udptl_write_callback(), and ooh323_write().
|
static |
Definition at line 870 of file udptl.c.
References ast_log, ast_udptl::error_correction_entries, ast_udptl::error_correction_scheme, ast_udptl::far_max_datagram, ast_udptl::far_max_ifp, LOG_TAG, LOG_WARNING, UDPTL_ERROR_CORRECTION_FEC, UDPTL_ERROR_CORRECTION_NONE, and UDPTL_ERROR_CORRECTION_REDUNDANCY.
Referenced by ast_udptl_get_far_max_ifp().
|
static |
Definition at line 829 of file udptl.c.
References ast_log, ast_udptl::error_correction_scheme, LOCAL_FAX_MAX_DATAGRAM, ast_udptl::local_max_datagram, ast_udptl::local_max_ifp, LOG_TAG, LOG_WARNING, MIN, UDPTL_ERROR_CORRECTION_FEC, UDPTL_ERROR_CORRECTION_NONE, and UDPTL_ERROR_CORRECTION_REDUNDANCY.
Referenced by ast_udptl_get_local_max_datagram().
CONFIG_INFO_CORE | ( | "udptl" | , |
cfg_info | , | ||
globals | , | ||
udptl_snapshot_alloc | , | ||
. | files = ACO_FILES(&udptl_conf) , |
||
. | pre_apply_config = udptl_pre_apply_config |
||
) |
|
static |
Definition at line 272 of file udptl.c.
References ast_debug, buf, and len().
Referenced by decode_open_type(), and udptl_rx_packet().
|
static |
Definition at line 298 of file udptl.c.
References buf, decode_length(), and len().
Referenced by udptl_rx_packet().
|
static |
Definition at line 318 of file udptl.c.
References buf, len(), and value.
Referenced by encode_open_type(), and udptl_build_packet().
|
static |
Definition at line 346 of file udptl.c.
References ast_log, buf, encode_length(), len(), LOG_ERROR, and LOG_TAG.
Referenced by udptl_build_packet().
|
static |
Definition at line 1258 of file udptl.c.
References a, ao2_cleanup, ao2_global_obj_ref, ast_cli(), AST_CLI_YESNO, CLI_FAILURE, CLI_GENERATE, CLI_INIT, CLI_SUCCESS, ast_cli_entry::command, globals, NULL, RAII_VAR, and ast_cli_entry::usage.
|
static |
Definition at line 1213 of file udptl.c.
References a, ast_cli(), ast_free, ast_sockaddr_copy(), ast_sockaddr_resolve(), ast_sockaddr_stringify(), CLI_GENERATE, CLI_INIT, CLI_SHOWUSAGE, CLI_SUCCESS, ast_cli_entry::command, NULL, udptldebug, udptldebugaddr, and ast_cli_entry::usage.
|
static |
Definition at line 1394 of file udptl.c.
References __ast_udptl_reload(), __stringify, ACO_EXACT, aco_info_init(), aco_option_register, aco_option_register_custom, ARRAY_LEN, ast_cli_register_multiple, AST_MODULE_LOAD_FAILURE, AST_MODULE_LOAD_SUCCESS, cli_udptl, DEFAULT_UDPTLEND, DEFAULT_UDPTLSTART, end, FLDSET, general_options, MAX_FEC_ENTRIES, MAX_FEC_SPAN, NULL, OPT_BOOL_T, OPT_UINT_T, PARSE_DEFAULT, PARSE_IN_RANGE, PARSE_RANGE_DEFAULTS, and removed_options_handler().
|
static |
Definition at line 1374 of file udptl.c.
References __ast_udptl_reload().
|
static |
Definition at line 1315 of file udptl.c.
References ast_log, LOG_WARNING, and var.
Referenced by load_module().
|
static |
Definition at line 619 of file udptl.c.
References ast_debug, buf, udptl_fec_tx_buffer_t::buf, udptl_fec_tx_buffer_t::buf_len, encode_length(), encode_open_type(), ast_udptl::error_correction_entries, ast_udptl::error_correction_scheme, ast_udptl::error_correction_span, len(), LOCAL_FAX_MAX_DATAGRAM, LOG_TAG, seq, ast_udptl::tx, ast_udptl::tx_seq_no, UDPTL_BUF_MASK, UDPTL_ERROR_CORRECTION_FEC, UDPTL_ERROR_CORRECTION_NONE, and UDPTL_ERROR_CORRECTION_REDUNDANCY.
Referenced by ast_udptl_write().
|
static |
Definition at line 1294 of file udptl.c.
References ao2_cleanup, and udptl_config::general.
Referenced by udptl_snapshot_alloc().
|
inlinestatic |
Definition at line 256 of file udptl.c.
References ast_sockaddr_cmp(), ast_sockaddr_cmp_addr(), ast_sockaddr_isnull(), ast_sockaddr_port, udptldebug, and udptldebugaddr.
Referenced by ast_udptl_read(), and ast_udptl_write().
|
static |
Definition at line 1342 of file udptl.c.
References __stringify, aco_pending_config(), ast_log, DEFAULT_UDPTLEND, DEFAULT_UDPTLSTART, udptl_global_options::end, udptl_config::general, LOG_NOTICE, LOG_WARNING, udptl_global_options::nochecksums, udptl_global_options::start, and udptl_global_options::use_even_ports.
|
static |
Definition at line 379 of file udptl.c.
References ARRAY_LEN, ast_debug, AST_FRAME_MODEM, AST_LIST_NEXT, AST_MODEM_T38, buf, udptl_fec_rx_buffer_t::buf, udptl_fec_rx_buffer_t::buf_len, ast_frame::data, ast_frame::datalen, decode_length(), decode_open_type(), ast_udptl::f, udptl_fec_rx_buffer_t::fec, udptl_fec_rx_buffer_t::fec_entries, udptl_fec_rx_buffer_t::fec_len, udptl_fec_rx_buffer_t::fec_span, ast_frame::frametype, ast_frame_subclass::integer, len(), LOCAL_FAX_MAX_DATAGRAM, ast_frame::mallocd, MAX_FEC_ENTRIES, NULL, ast_frame::offset, ast_frame::ptr, ast_udptl::rx, ast_udptl::rx_seq_no, ast_frame::seqno, ast_frame::src, ast_frame::subclass, TRUE, and UDPTL_BUF_MASK.
Referenced by ast_udptl_read().
|
static |
Definition at line 1300 of file udptl.c.
References ao2_alloc, ao2_ref, udptl_config::general, NULL, and udptl_config_destructor().
Referenced by __ast_udptl_reload().
|
static |
Definition at line 748 of file udptl.c.
References ast_udptl_read(), ast_udptl::callback, and ast_udptl::data.
Referenced by ast_udptl_new_with_bindaddr().
|
static |
Definition at line 1385 of file udptl.c.
References aco_info_destroy(), ao2_t_global_obj_release, ARRAY_LEN, ast_cli_unregister_multiple(), cli_udptl, and globals.
|
static |
|
static |
|
static |
Definition at line 1289 of file udptl.c.
Referenced by load_module(), and unload_module().
|
static |
Definition at line 236 of file udptl.c.
Referenced by __ast_udptl_reload().
|
static |
Definition at line 244 of file udptl.c.
Referenced by load_module().
|
static |
|
static |
Are we debugging?
Definition at line 128 of file udptl.c.
Referenced by handle_cli_udptl_set_debug(), and udptl_debug_test_addr().
|
static |
Debug packets to/from this host
Definition at line 129 of file udptl.c.
Referenced by handle_cli_udptl_set_debug(), and udptl_debug_test_addr().