Asterisk - The Open Source Telephony Project
18.5.0
|
sip config parsing functions and unit tests More...
#include "asterisk.h"
#include "include/sip.h"
#include "include/config_parser.h"
#include "include/sip_utils.h"
Go to the source code of this file.
Macros | |
#define | TEST_AUTO_COMEDIA 1 << 3 |
#define | TEST_AUTO_FORCE_RPORT 1 << 2 |
#define | TEST_COMEDIA 1 << 1 |
#define | TEST_FORCE_RPORT 1 << 0 |
Functions | |
AST_TEST_DEFINE (sip_parse_register_line_test) | |
AST_TEST_DEFINE (sip_parse_host_line_test) | |
AST_TEST_DEFINE (sip_parse_nat_test) | |
static int | match_nat_options (int val, struct ast_flags *flags) |
void | sip_config_parser_register_tests (void) |
SIP test registration. More... | |
void | sip_config_parser_unregister_tests (void) |
SIP test registration. More... | |
int | sip_parse_host (char *line, int lineno, char **hostname, int *portnum, enum ast_transport *transport) |
parses a config line for a host with a transport More... | |
void | sip_parse_nat_option (const char *value, struct ast_flags *mask, struct ast_flags *flags) |
Parse the comma-separated nat= option values. More... | |
int | sip_parse_register_line (struct sip_registry *reg, int default_expiry, const char *value, int lineno) |
Parse register=> line in sip.conf. More... | |
sip config parsing functions and unit tests
Definition in file config_parser.c.
#define TEST_AUTO_COMEDIA 1 << 3 |
Definition at line 843 of file config_parser.c.
Referenced by AST_TEST_DEFINE(), and match_nat_options().
#define TEST_AUTO_FORCE_RPORT 1 << 2 |
Definition at line 842 of file config_parser.c.
Referenced by AST_TEST_DEFINE(), and match_nat_options().
#define TEST_COMEDIA 1 << 1 |
Definition at line 841 of file config_parser.c.
Referenced by AST_TEST_DEFINE(), and match_nat_options().
#define TEST_FORCE_RPORT 1 << 0 |
Definition at line 840 of file config_parser.c.
Referenced by AST_TEST_DEFINE(), and match_nat_options().
AST_TEST_DEFINE | ( | sip_parse_register_line_test | ) |
Definition at line 276 of file config_parser.c.
References ast_calloc_with_stringfields, ast_free, ast_string_field_free_memory, AST_TEST_FAIL, AST_TEST_NOT_RUN, AST_TEST_PASS, ast_test_status_update, AST_TRANSPORT_TCP, AST_TRANSPORT_TLS, AST_TRANSPORT_UDP, sip_registry::authuser, sip_registry::callback, sip_registry::callid_valid, sip_registry::configured_expiry, default_expiry, sip_registry::expire, sip_registry::expiry, FALSE, sip_registry::hostname, sip_to_pjsip::info(), INITIAL_CSEQ, NULL, sip_registry::ocseq, sip_registry::peername, sip_registry::portno, sip_registry::refresh, sip_registry::regdomain, sip_registry::regdomainport, sip_registry::secret, sip_parse_register_line(), STANDARD_SIP_PORT, STANDARD_TLS_PORT, TEST_EXECUTE, TEST_INIT, sip_registry::timeout, sip_registry::transport, and sip_registry::username.
AST_TEST_DEFINE | ( | sip_parse_host_line_test | ) |
Definition at line 712 of file config_parser.c.
References ast_strlen_zero, AST_TEST_FAIL, AST_TEST_NOT_RUN, AST_TEST_PASS, ast_test_status_update, AST_TRANSPORT_TCP, AST_TRANSPORT_TLS, AST_TRANSPORT_UDP, host, sip_to_pjsip::info(), NULL, sip_parse_host(), STANDARD_SIP_PORT, STANDARD_TLS_PORT, TEST_EXECUTE, TEST_INIT, and sip_registry::transport.
AST_TEST_DEFINE | ( | sip_parse_nat_test | ) |
Definition at line 861 of file config_parser.c.
References ARRAY_LEN, AST_TEST_FAIL, AST_TEST_NOT_RUN, AST_TEST_PASS, ast_test_status_update, ast_flags::flags, sip_to_pjsip::info(), match_nat_options(), options, sip_parse_nat_option(), str, TEST_AUTO_COMEDIA, TEST_AUTO_FORCE_RPORT, TEST_COMEDIA, TEST_EXECUTE, TEST_FORCE_RPORT, and TEST_INIT.
|
static |
Definition at line 844 of file config_parser.c.
References ast_test_flag, SIP_NAT_FORCE_RPORT, SIP_PAGE2_SYMMETRICRTP, SIP_PAGE3_NAT_AUTO_COMEDIA, SIP_PAGE3_NAT_AUTO_RPORT, TEST_AUTO_COMEDIA, TEST_AUTO_FORCE_RPORT, TEST_COMEDIA, and TEST_FORCE_RPORT.
Referenced by AST_TEST_DEFINE().
void sip_config_parser_register_tests | ( | void | ) |
SIP test registration.
register config parsing tests
Definition at line 913 of file config_parser.c.
References AST_TEST_REGISTER.
Referenced by sip_register_tests().
void sip_config_parser_unregister_tests | ( | void | ) |
SIP test registration.
unregister config parsing tests
Definition at line 921 of file config_parser.c.
References AST_TEST_UNREGISTER.
Referenced by sip_unregister_tests().
int sip_parse_host | ( | char * | line, |
int | lineno, | ||
char ** | hostname, | ||
int * | portnum, | ||
enum ast_transport * | transport | ||
) |
parses a config line for a host with a transport
An example input would be: tls://www.google.com:8056
0 | on success |
-1 | on failure |
Definition at line 647 of file config_parser.c.
References ast_log, ast_sockaddr_split_hostport(), ast_strlen_zero, AST_TRANSPORT_TCP, AST_TRANSPORT_TLS, AST_TRANSPORT_UDP, hostname, LOG_NOTICE, LOG_WARNING, NULL, STANDARD_SIP_PORT, and STANDARD_TLS_PORT.
Referenced by AST_TEST_DEFINE(), and proxy_from_config().
Parse the comma-separated nat= option values.
value | The comma-separated value |
mask | An array of ast_flags that will be set by this function and used as a mask for copying the flags later |
flags | An array of ast_flags that will be set by this function |
Definition at line 794 of file config_parser.c.
References ast_clear_flag, ast_false(), ast_log, ast_set_flag, ast_strdupa, ast_test_flag, LOG_WARNING, parse(), SIP_NAT_FORCE_RPORT, SIP_PAGE2_SYMMETRICRTP, SIP_PAGE3_NAT_AUTO_COMEDIA, SIP_PAGE3_NAT_AUTO_RPORT, and strsep().
Referenced by AST_TEST_DEFINE(), and handle_common_options().
int sip_parse_register_line | ( | struct sip_registry * | reg, |
int | default_expiry, | ||
const char * | value, | ||
int | lineno | ||
) |
Parse register=> line in sip.conf.
0 | on success |
-1 | on failure |
register => [peer?][transport://]user[][:secret[:authuser]][:port][/extension][~expiry] becomes userpart => [peer?][transport://]user[][:secret[:authuser]] hostpart => host[:port][/extension][~expiry]
pre1.peer => peer pre1.userpart => [transport://]user[][:secret[:authuser]] hostpart => host[:port][/extension][~expiry]
pre1.peer => peer pre2.transport = transport pre2.userpart => user[][:secret[:authuser]] hostpart => host[:port][/extension][~expiry]
pre1.peer => peer pre2.transport = transport user1.userpart => user[] user1.secret => secret user1.authuser => authuser hostpart => host[:port][/extension][~expiry]
pre1.peer => peer pre2.transport = transport user1.userpart => user[] user1.secret => secret user1.authuser => authuser host1.hostpart => host[:port][/extension] host1.expiry => [expiry]
pre1.peer => peer pre2.transport = transport user1.userpart => user[] user1.secret => secret user1.authuser => authuser host2.hostpart => host[:port] host2.extension => [extension] host1.expiry => [expiry]
pre1.peer => peer pre2.transport = transport user1.userpart => user[] user1.secret => secret user1.authuser => authuser host3.host => host host3.port => port host2.extension => extension host1.expiry => expiry
pre1.peer => peer pre2.transport = transport user2.user => user user2.domain => domain user1.secret => secret user1.authuser => authuser host3.host => host host3.port => port host2.extension => extension host1.expiry => expiry
pre1.peer => peer pre2.transport = transport user2.user => user user2.domain => domain user1.secret => secret user3.authuser => authuser user3.domainport => domainport host3.host => host host3.port => port host2.extension => extension host1.expiry => expiry
Definition at line 37 of file config_parser.c.
References AST_APP_ARG, ast_copy_string(), AST_DECLARE_APP_ARGS, ast_log, AST_NONSTANDARD_RAW_ARGS, ast_string_field_set, ast_strip_quoted(), ast_strlen_zero, AST_TRANSPORT_TCP, AST_TRANSPORT_TLS, AST_TRANSPORT_UDP, buf, sip_registry::callid_valid, sip_registry::configured_expiry, default_expiry, sip_registry::expire, sip_registry::expiry, FALSE, host, hostname, INITIAL_CSEQ, LOG_NOTICE, LOG_WARNING, NULL, sip_registry::ocseq, port_str2int(), sip_registry::portno, sip_registry::refresh, sip_registry::regdomainport, S_OR, STANDARD_SIP_PORT, STANDARD_TLS_PORT, sip_registry::timeout, and sip_registry::transport.
Referenced by AST_TEST_DEFINE(), and sip_register().