Asterisk - The Open Source Telephony Project GIT-master-f36a736
|
Implementation of Inter-Asterisk eXchange Protocol, v 2. More...
#include "asterisk.h"
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include "asterisk/frame.h"
#include "asterisk/utils.h"
#include "asterisk/unaligned.h"
#include "asterisk/config.h"
#include "asterisk/lock.h"
#include "asterisk/threadstorage.h"
#include "asterisk/netsock2.h"
#include "asterisk/format_cache.h"
#include "asterisk/format_compatibility.h"
#include "include/iax2.h"
#include "include/parser.h"
#include "include/provision.h"
#include "include/codec_pref.h"
Go to the source code of this file.
Data Structures | |
struct | iax2_ie |
struct | iax_frame_list |
This is just so iax_frames, a list head struct for holding a list of iax_frame structures, is defined. More... | |
struct | iax_frames |
Macros | |
#define | FRAME_CACHE_MAX_SIZE 20 |
Functions | |
static void | __init_frame_cache (void) |
A per-thread cache of iax_frame structures. More... | |
static void | dump_addr (char *output, int maxlen, void *value, int len) |
static void | dump_byte (char *output, int maxlen, void *value, int len) |
static void | dump_datetime (char *output, int maxlen, void *value, int len) |
static void | dump_ies (unsigned char *iedata, int len) |
static void | dump_int (char *output, int maxlen, void *value, int len) |
static void | dump_ipaddr (char *output, int maxlen, void *value, int len) |
static void | dump_prefs (char *output, int maxlen, void *value, int len) |
static void | dump_prov (char *output, int maxlen, void *value, int len) |
static void | dump_prov_flags (char *output, int maxlen, void *value, int len) |
static void | dump_prov_ies (char *output, int maxlen, unsigned char *iedata, int len) |
static void | dump_samprate (char *output, int maxlen, void *value, int len) |
static void | dump_short (char *output, int maxlen, void *value, int len) |
static void | dump_string (char *output, int maxlen, void *value, int len) |
static void | dump_string_hex (char *output, int maxlen, void *value, int len) |
static void | dump_versioned_codec (char *output, int maxlen, void *value, int len) |
static void | frame_cache_cleanup (void *data) |
void | iax_frame_free (struct iax_frame *fr) |
struct iax_frame * | iax_frame_new (int direction, int datalen, unsigned int cacheable) |
void | iax_frame_subclass2str (enum iax_frame_subclass subclass, char *str, size_t len) |
void | iax_frame_wrap (struct iax_frame *fr, struct ast_frame *f) |
int | iax_get_frames (void) |
int | iax_get_iframes (void) |
int | iax_get_oframes (void) |
const char * | iax_ie2str (int ie) |
int | iax_ie_append (struct iax_ie_data *ied, unsigned char ie) |
int | iax_ie_append_addr (struct iax_ie_data *ied, unsigned char ie, const struct ast_sockaddr *addr) |
int | iax_ie_append_byte (struct iax_ie_data *ied, unsigned char ie, unsigned char dat) |
int | iax_ie_append_int (struct iax_ie_data *ied, unsigned char ie, unsigned int value) |
int | iax_ie_append_raw (struct iax_ie_data *ied, unsigned char ie, const void *data, int datalen) |
int | iax_ie_append_short (struct iax_ie_data *ied, unsigned char ie, unsigned short value) |
int | iax_ie_append_str (struct iax_ie_data *ied, unsigned char ie, const char *str) |
int | iax_ie_append_versioned_uint64 (struct iax_ie_data *ied, unsigned char ie, unsigned char version, uint64_t value) |
int | iax_parse_ies (struct iax_ies *ies, unsigned char *data, int datalen) |
void | iax_set_error (void(*func)(const char *)) |
void | iax_set_output (void(*func)(const char *)) |
void | iax_showframe (struct iax_frame *f, struct ast_iax2_full_hdr *fhi, int rx, struct ast_sockaddr *addr, int datalen) |
static void | internalerror (const char *str) |
static void | internaloutput (const char *str) |
Variables | |
static void(* | errorf )(const char *str) = internalerror |
static struct ast_threadstorage | frame_cache = { .once = PTHREAD_ONCE_INIT , .key_init = __init_frame_cache , .custom_init = NULL , } |
static int | frames = 0 |
static int | iframes = 0 |
static struct iax2_ie | infoelts [] |
static int | oframes = 0 |
static void(* | outputf )(const char *str) = internaloutput |
static const struct iax2_ie | prov_ies [] |
Implementation of Inter-Asterisk eXchange Protocol, v 2.
Definition in file parser.c.
|
static |
|
static |
Definition at line 90 of file parser.c.
References ast_copy_string(), ast_sockaddr_is_ipv4(), ast_sockaddr_is_ipv4_mapped(), ast_sockaddr_stringify(), len(), ast_sockaddr::len, ast_sockaddr::ss, and value.
|
static |
Definition at line 165 of file parser.c.
References ast_copy_string(), len(), and value.
|
static |
Definition at line 173 of file parser.c.
References ast_copy_string(), ast_strftime(), get_unaligned_uint32(), len(), ast_tm::tm_hour, ast_tm::tm_mday, ast_tm::tm_min, ast_tm::tm_mon, ast_tm::tm_sec, ast_tm::tm_year, and value.
|
static |
Definition at line 416 of file parser.c.
References ARRAY_LEN, iax2_ie::dump, iax2_ie::ie, infoelts, len(), name, outputf, and tmp().
Referenced by iax_showframe().
|
static |
Definition at line 149 of file parser.c.
References ast_copy_string(), get_unaligned_uint32(), len(), and value.
|
static |
Definition at line 189 of file parser.c.
References ast_copy_string(), ast_sockaddr_stringify(), len(), ast_sockaddr::len, ast_sockaddr::ss, and value.
|
static |
Definition at line 130 of file parser.c.
References iax2_codec_pref_convert(), iax2_codec_pref_string(), len(), and value.
|
static |
Definition at line 264 of file parser.c.
References dump_prov_ies(), len(), and value.
|
static |
Definition at line 211 of file parser.c.
References ast_copy_string(), buf, get_unaligned_uint32(), iax_provflags2str(), len(), and value.
|
static |
Definition at line 364 of file parser.c.
References ast_copy_string(), iax2_ie::dump, iax2_ie::ie, len(), name, prov_ies, and tmp().
Referenced by dump_prov().
|
static |
Definition at line 221 of file parser.c.
References ast_copy_string(), IAX_RATE_11KHZ, IAX_RATE_16KHZ, IAX_RATE_22KHZ, IAX_RATE_44KHZ, IAX_RATE_48KHZ, IAX_RATE_8KHZ, len(), tmp(), and value.
|
static |
Definition at line 157 of file parser.c.
References ast_copy_string(), get_unaligned_uint16(), len(), and value.
|
static |
|
static |
|
static |
Definition at line 248 of file parser.c.
References ast_copy_string(), get_unaligned_uint64(), iax2_getformatname(), len(), ntohll(), value, and version.
|
static |
Definition at line 1337 of file parser.c.
References ast_free, AST_LIST_REMOVE_HEAD, current, iax_frame::list, and iax_frames::list.
void iax_frame_free | ( | struct iax_frame * | fr | ) |
Definition at line 1295 of file parser.c.
References iax_frame::afdatalen, ast_atomic_fetchadd_int(), ast_free, AST_LIST_FIRST, AST_LIST_INSERT_HEAD, AST_LIST_INSERT_TAIL, ast_opt_cache_media_frames, ast_threadstorage_get(), iax_frame::cacheable, iax_frame::direction, DIRECTION_INGRESS, DIRECTION_OUTGRESS, errorf, frame_cache, FRAME_CACHE_MAX_SIZE, frames, iframes, iax_frames::list, NULL, oframes, and iax_frames::size.
Referenced by iax2_frame_free(), and transmit_frame().
struct iax_frame * iax_frame_new | ( | int | direction, |
int | datalen, | ||
unsigned int | cacheable | ||
) |
Definition at line 1228 of file parser.c.
References iax_frame::afdatalen, ast_atomic_fetchadd_int(), ast_calloc, ast_free, AST_LIST_FIRST, AST_LIST_REMOVE, AST_LIST_REMOVE_CURRENT, AST_LIST_TRAVERSE_SAFE_BEGIN, AST_LIST_TRAVERSE_SAFE_END, ast_threadstorage_get(), iax_frame::cacheable, iax_frame::datalen, iax_frame::direction, DIRECTION_INGRESS, frame_cache, FRAME_CACHE_MAX_SIZE, frames, iframes, iax_frame::list, iax_frames::list, NULL, oframes, iax_frame::retrans, and iax_frames::size.
Referenced by iax2_send(), and iaxfrdup2().
void iax_frame_subclass2str | ( | enum iax_frame_subclass | subclass, |
char * | str, | ||
size_t | len | ||
) |
Definition at line 463 of file parser.c.
References ast_copy_string(), IAX_COMMAND_ACCEPT, IAX_COMMAND_ACK, IAX_COMMAND_AUTHREP, IAX_COMMAND_AUTHREQ, IAX_COMMAND_CALLTOKEN, IAX_COMMAND_DIAL, IAX_COMMAND_DPREP, IAX_COMMAND_DPREQ, IAX_COMMAND_FWDATA, IAX_COMMAND_FWDOWNL, IAX_COMMAND_HANGUP, IAX_COMMAND_INVAL, IAX_COMMAND_LAGRP, IAX_COMMAND_LAGRQ, IAX_COMMAND_MWI, IAX_COMMAND_NEW, IAX_COMMAND_PAGE, IAX_COMMAND_PING, IAX_COMMAND_POKE, IAX_COMMAND_PONG, IAX_COMMAND_PROVISION, IAX_COMMAND_QUELCH, IAX_COMMAND_REGACK, IAX_COMMAND_REGAUTH, IAX_COMMAND_REGREJ, IAX_COMMAND_REGREL, IAX_COMMAND_REGREQ, IAX_COMMAND_REJECT, IAX_COMMAND_RTKEY, IAX_COMMAND_TRANSFER, IAX_COMMAND_TXACC, IAX_COMMAND_TXCNT, IAX_COMMAND_TXMEDIA, IAX_COMMAND_TXREADY, IAX_COMMAND_TXREJ, IAX_COMMAND_TXREL, IAX_COMMAND_TXREQ, IAX_COMMAND_UNQUELCH, IAX_COMMAND_UNSUPPORT, IAX_COMMAND_VNAK, len(), and str.
Referenced by ast_cli_netstats(), handle_cli_iax2_show_channels(), iax_showframe(), and socket_process_helper().
Definition at line 1195 of file parser.c.
References iax_frame::af, iax_frame::afdata, iax_frame::afdatalen, ast_format_cmp(), AST_FORMAT_CMP_EQUAL, ast_format_slin, AST_FRAME_VOICE, AST_FRIENDLY_OFFSET, ast_log, ast_swapcopy_samples(), ast_frame::data, ast_frame::datalen, ast_frame::delivery, ast_frame_subclass::format, ast_frame::frametype, ast_frame_subclass::integer, ast_frame::len, LOG_ERROR, ast_frame::mallocd, ast_frame::offset, ast_frame::ptr, ast_frame::samples, ast_frame::src, and ast_frame::subclass.
Referenced by iax2_send(), iaxfrdup2(), socket_process_helper(), and socket_process_meta().
int iax_get_frames | ( | void | ) |
Definition at line 1349 of file parser.c.
References frames.
Referenced by handle_cli_iax2_show_stats().
int iax_get_iframes | ( | void | ) |
Definition at line 1350 of file parser.c.
References iframes.
Referenced by handle_cli_iax2_show_stats().
int iax_get_oframes | ( | void | ) |
Definition at line 1351 of file parser.c.
References oframes.
Referenced by handle_cli_iax2_show_stats().
const char * iax_ie2str | ( | int | ie | ) |
Definition at line 353 of file parser.c.
References ARRAY_LEN, iax2_ie::ie, infoelts, and iax2_ie::name.
Referenced by iax_ie_append_raw(), and iax_parse_ies().
int iax_ie_append | ( | struct iax_ie_data * | ied, |
unsigned char | ie | ||
) |
Definition at line 780 of file parser.c.
References iax_ie_append_raw(), and NULL.
Referenced by iax2_call(), and iax_firmware_append().
int iax_ie_append_addr | ( | struct iax_ie_data * | ied, |
unsigned char | ie, | ||
const struct ast_sockaddr * | addr | ||
) |
Definition at line 741 of file parser.c.
References iax_ie_append_raw(), and ast_sockaddr::len.
Referenced by update_registry().
int iax_ie_append_byte | ( | struct iax_ie_data * | ied, |
unsigned char | ie, | ||
unsigned char | dat | ||
) |
Definition at line 775 of file parser.c.
References iax_ie_append_raw().
Referenced by __auth_reject(), __auto_hangup(), authenticate_request(), iax2_call(), iax2_hangup(), iax_provision_build(), and socket_process_helper().
int iax_ie_append_int | ( | struct iax_ie_data * | ied, |
unsigned char | ie, | ||
unsigned int | value | ||
) |
Definition at line 756 of file parser.c.
References iax_ie_append_raw(), and value.
Referenced by cache_get_callno_locked(), construct_rr(), iax2_call(), iax_firmware_append(), iax_provision_build(), socket_process_helper(), try_transfer(), and update_registry().
int iax_ie_append_raw | ( | struct iax_ie_data * | ied, |
unsigned char | ie, | ||
const void * | data, | ||
int | datalen | ||
) |
Definition at line 726 of file parser.c.
References iax_ie_data::buf, errorf, iax_ie2str(), iax_ie_data::pos, and tmp().
Referenced by iax2_call(), iax2_key_rotate(), iax2_provision(), iax_firmware_append(), iax_ie_append(), iax_ie_append_addr(), iax_ie_append_byte(), iax_ie_append_int(), iax_ie_append_short(), iax_ie_append_str(), and iax_ie_append_versioned_uint64().
int iax_ie_append_short | ( | struct iax_ie_data * | ied, |
unsigned char | ie, | ||
unsigned short | value | ||
) |
Definition at line 763 of file parser.c.
References iax_ie_append_raw(), and value.
Referenced by authenticate_request(), cache_get_callno_locked(), construct_rr(), dp_lookup(), iax2_call(), iax2_do_register(), iax_provision_build(), registry_authrequest(), registry_rerequest(), socket_process_helper(), and update_registry().
int iax_ie_append_str | ( | struct iax_ie_data * | ied, |
unsigned char | ie, | ||
const char * | str | ||
) |
Definition at line 770 of file parser.c.
References iax_ie_append_raw(), and str.
Referenced by __auth_reject(), __auto_hangup(), authenticate(), authenticate_request(), cache_get_callno_locked(), dp_lookup(), handle_call_token(), iax2_call(), iax2_do_register(), iax2_dprequest(), iax2_transfer(), iax_provision_build(), registry_authrequest(), registry_rerequest(), resend_with_token(), socket_process_helper(), and update_registry().
int iax_ie_append_versioned_uint64 | ( | struct iax_ie_data * | ied, |
unsigned char | ie, | ||
unsigned char | version, | ||
uint64_t | value | ||
) |
Definition at line 746 of file parser.c.
References htonll(), iax_ie_append_raw(), put_unaligned_uint64(), value, and version.
Referenced by iax2_call(), and socket_process_helper().
int iax_parse_ies | ( | struct iax_ies * | ies, |
unsigned char * | data, | ||
int | datalen | ||
) |
Definition at line 795 of file parser.c.
References iax_ies::adsicpe, iax_ies::apparent_addr, ast_copy_string(), ast_free, ast_str_buffer(), ast_str_create, ast_str_set(), ast_variable_new, iax_ies::authmethods, iax_ies::autoanswer, iax_ies::called_context, iax_ies::called_number, iax_ies::calling_ani, iax_ies::calling_ani2, iax_ies::calling_name, iax_ies::calling_number, iax_ies::calling_pres, iax_ies::calling_tns, iax_ies::calling_ton, iax_ies::callno, iax_ies::calltoken, iax_ies::calltokendata, iax_ies::capability, iax_ies::cause, iax_ies::causecode, iax_ies::challenge, iax_ies::codec_prefs, iax_ies::datetime, iax_ies::devicetype, iax_ies::dnid, iax_ies::dpstatus, iax_ies::enckey, iax_ies::enckeylen, iax_ies::encmethods, errorf, ast_variable::file, iax_ies::firmwarever, iax_ies::format, iax_ies::fwdata, iax_ies::fwdatalen, iax_ies::fwdesc, get_unaligned_uint16(), get_unaligned_uint32(), get_unaligned_uint64(), iax_ie2str(), IAX_IE_ADSICPE, IAX_IE_APPARENT_ADDR, IAX_IE_AUTHMETHODS, IAX_IE_AUTOANSWER, IAX_IE_CALLED_CONTEXT, IAX_IE_CALLED_NUMBER, IAX_IE_CALLING_ANI, IAX_IE_CALLING_NAME, IAX_IE_CALLING_NUMBER, IAX_IE_CALLINGANI2, IAX_IE_CALLINGPRES, IAX_IE_CALLINGTNS, IAX_IE_CALLINGTON, IAX_IE_CALLNO, IAX_IE_CALLTOKEN, IAX_IE_CAPABILITY, IAX_IE_CAPABILITY2, IAX_IE_CAUSE, IAX_IE_CAUSECODE, IAX_IE_CHALLENGE, IAX_IE_CODEC_PREFS, IAX_IE_DATETIME, IAX_IE_DEVICETYPE, IAX_IE_DNID, IAX_IE_DPSTATUS, IAX_IE_ENCKEY, IAX_IE_ENCRYPTION, IAX_IE_FIRMWAREVER, IAX_IE_FORMAT, IAX_IE_FORMAT2, IAX_IE_FWBLOCKDATA, IAX_IE_FWBLOCKDESC, IAX_IE_IAX_UNKNOWN, IAX_IE_LANGUAGE, IAX_IE_MD5_RESULT, IAX_IE_MSGCOUNT, IAX_IE_MUSICONHOLD, IAX_IE_OSPTOKEN, IAX_IE_PASSWORD, IAX_IE_PROVVER, IAX_IE_RDNIS, IAX_IE_REFRESH, IAX_IE_RR_DELAY, IAX_IE_RR_DROPPED, IAX_IE_RR_JITTER, IAX_IE_RR_LOSS, IAX_IE_RR_OOO, IAX_IE_RR_PKTS, IAX_IE_RSA_RESULT, IAX_IE_SAMPLINGRATE, IAX_IE_SERVICEIDENT, IAX_IE_TRANSFERID, IAX_IE_USERNAME, IAX_IE_VARIABLE, IAX_IE_VERSION, IAX_MAX_OSPBLOCK_NUM, IAX_RATE_8KHZ, iax_ies::iax_unknown, iax_ies::language, len(), ast_sockaddr::len, iax_ies::md5_result, iax_ies::msgcount, iax_ies::musiconhold, ast_variable::name, ast_variable::next, ntohll(), NULL, iax_ies::ospblocklength, iax_ies::osptokenblock, outputf, iax_ies::password, iax_ies::provver, iax_ies::provverpres, iax_ies::rdnis, iax_ies::refresh, iax_ies::rr_delay, iax_ies::rr_dropped, iax_ies::rr_jitter, iax_ies::rr_loss, iax_ies::rr_ooo, iax_ies::rr_pkts, iax_ies::rsa_result, iax_ies::samprate, iax_ies::serviceident, str, tmp(), iax_ies::transferid, iax_ies::username, ast_variable::value, var, iax_ies::vars, version, and iax_ies::version.
Referenced by socket_process_helper().
void iax_set_error | ( | void(*)(const char *) | func | ) |
void iax_set_output | ( | void(*)(const char *) | func | ) |
void iax_showframe | ( | struct iax_frame * | f, |
struct ast_iax2_full_hdr * | fhi, | ||
int | rx, | ||
struct ast_sockaddr * | addr, | ||
int | datalen | ||
) |
Definition at line 595 of file parser.c.
References ARRAY_LEN, AST_FRAME_CONTROL, AST_FRAME_DTMF_BEGIN, AST_FRAME_DTMF_END, AST_FRAME_IAX, ast_sockaddr_stringify(), ast_iax2_full_hdr::csub, iax_frame::data, ast_iax2_full_hdr::dcallno, dump_ies(), IAX_FLAG_FULL, IAX_FLAG_RETRANS, iax_frame_subclass2str(), ast_iax2_full_hdr::iedata, ast_iax2_full_hdr::iseqno, ast_iax2_full_hdr::oseqno, outputf, iax_frame::retries, ast_iax2_full_hdr::scallno, tmp(), ast_iax2_full_hdr::ts, type, and ast_iax2_full_hdr::type.
Referenced by iax_outputframe().
|
static |
|
static |
|
static |
Definition at line 88 of file parser.c.
Referenced by iax_frame_free(), iax_ie_append_raw(), iax_parse_ies(), and iax_set_error().
|
static |
Definition at line 63 of file parser.c.
Referenced by iax_frame_free(), and iax_frame_new().
|
static |
Definition at line 51 of file parser.c.
Referenced by __ast_answer(), __ast_frdup(), __ast_queue_frame(), __frame_free(), ast_frame_header_new(), ast_rtp_interpret(), ast_rtp_read(), fixed_jb_get(), frame_cache_cleanup(), iax_frame_free(), iax_frame_new(), iax_get_frames(), load_stream_readqueue(), process_dtmf_rfc2833(), queue_put(), and read_test().
|
static |
Definition at line 52 of file parser.c.
Referenced by iax_frame_free(), iax_frame_new(), and iax_get_iframes().
|
static |
Definition at line 274 of file parser.c.
Referenced by dump_ies(), and iax_ie2str().
|
static |
Definition at line 53 of file parser.c.
Referenced by iax_frame_free(), iax_frame_new(), and iax_get_oframes().
|
static |
Definition at line 87 of file parser.c.
Referenced by dump_ies(), iax_parse_ies(), iax_set_output(), and iax_showframe().
|
static |
Definition at line 333 of file parser.c.
Referenced by dump_prov_ies().