Asterisk - The Open Source Telephony Project GIT-master-f36a736
|
Various sorts of access control. More...
#include "asterisk.h"
#include "asterisk/network.h"
#include <ifaddrs.h>
#include "asterisk/acl.h"
#include "asterisk/channel.h"
#include "asterisk/utils.h"
#include "asterisk/lock.h"
#include "asterisk/srv.h"
#include "asterisk/cli.h"
Go to the source code of this file.
Data Structures | |
struct | dscp_codepoint |
Functions | |
static int | acl_new (struct ast_acl **pointer, const char *name) |
static struct ast_ha * | append_ha_core (const char *sense, const char *stuff, struct ast_ha *path, int *error, int port_flags) |
int | ast_acl_list_is_empty (struct ast_acl_list *acl_list) |
Determines if an ACL is empty or if it contains entries. More... | |
void | ast_acl_output (int fd, struct ast_acl_list *acl_list, const char *prefix) |
output an ACL to the provided fd More... | |
void | ast_append_acl (const char *sense, const char *stuff, struct ast_acl_list **path, int *error, int *named_acl_flag) |
Add a rule to an ACL struct. More... | |
struct ast_ha * | ast_append_ha (const char *sense, const char *stuff, struct ast_ha *path, int *error) |
Add a new rule to a list of HAs. More... | |
struct ast_ha * | ast_append_ha_with_port (const char *sense, const char *stuff, struct ast_ha *path, int *error) |
Add a new rule with optional port to a list of HAs. More... | |
enum ast_acl_sense | ast_apply_acl (struct ast_acl_list *acl_list, const struct ast_sockaddr *addr, const char *purpose) |
Apply a set of rules to a given IP address. More... | |
static enum ast_acl_sense | ast_apply_acl_internal (struct ast_acl_list *acl_list, const struct ast_sockaddr *addr, const char *log_prefix) |
enum ast_acl_sense | ast_apply_acl_nolog (struct ast_acl_list *acl_list, const struct ast_sockaddr *addr) |
Apply a set of rules to a given IP address, don't log failure. More... | |
enum ast_acl_sense | ast_apply_ha (const struct ast_ha *ha, const struct ast_sockaddr *addr) |
Apply a set of rules to a given IP address. More... | |
void | ast_copy_ha (const struct ast_ha *from, struct ast_ha *to) |
Copy the contents of one HA to another. More... | |
struct ast_acl_list * | ast_duplicate_acl_list (struct ast_acl_list *original) |
Duplicates the contests of a list of lists of host access rules. More... | |
static struct ast_ha * | ast_duplicate_ha (struct ast_ha *original) |
struct ast_ha * | ast_duplicate_ha_list (struct ast_ha *original) |
Duplicate the contents of a list of host access rules. More... | |
int | ast_find_ourip (struct ast_sockaddr *ourip, const struct ast_sockaddr *bindaddr, int family) |
Find our IP address. More... | |
struct ast_acl_list * | ast_free_acl_list (struct ast_acl_list *acl_list) |
Free a list of ACLs. More... | |
void | ast_free_ha (struct ast_ha *ha) |
Free a list of HAs. More... | |
int | ast_get_ip (struct ast_sockaddr *addr, const char *hostname) |
Get the IP address given a hostname. More... | |
int | ast_get_ip_or_srv (struct ast_sockaddr *addr, const char *hostname, const char *service) |
Get the IP address given a hostname and optional service. More... | |
int | ast_get_ip_or_srv_with_preference (struct ast_sockaddr *addr, const char *hostname, const char *service, struct ast_sockaddr *preference) |
Get the IP address given a hostname and optional service with a preferred result. More... | |
void | ast_ha_join (const struct ast_ha *ha, struct ast_str **buf) |
Convert HAs to a comma separated string value. More... | |
void | ast_ha_join_cidr (const struct ast_ha *ha, struct ast_str **buf) |
Convert HAs to a comma separated string value using CIDR notation. More... | |
void | ast_ha_output (int fd, const struct ast_ha *ha, const char *prefix) |
output an HA to the provided fd More... | |
int | ast_ouraddrfor (const struct ast_sockaddr *them, struct ast_sockaddr *us) |
Get our local IP address when contacting a remote host. More... | |
int | ast_str2cos (const char *value, unsigned int *cos) |
Convert a string to the appropriate COS value. More... | |
int | ast_str2tos (const char *value, unsigned int *tos) |
Convert a string to the appropriate TOS value. More... | |
const char * | ast_tos2str (unsigned int tos) |
Convert a TOS value into its string representation. More... | |
static void | debug_ha_sense_appended (struct ast_ha *ha) |
static int | get_local_address (struct ast_sockaddr *ourip) |
static int | parse_cidr_mask (struct ast_sockaddr *addr, int is_v4, const char *mask_str) |
Parse a netmask in CIDR notation. More... | |
static int | resolve_match_or_first (struct ast_sockaddr *addr, const char *name, int flag, int family, struct ast_sockaddr *preference) |
static void | score_address (const struct sockaddr_in *sin, struct in_addr *best_addr, int *best_score) |
Variables | |
static const struct dscp_codepoint | dscp_pool1 [] |
Various sorts of access control.
Definition in file acl.c.
|
static |
Definition at line 304 of file acl.c.
References ast_acl::acl, ACL_NAME_LENGTH, ast_calloc, ast_copy_string(), and name.
Referenced by ast_append_acl(), and ast_duplicate_acl_list().
|
static |
Definition at line 575 of file acl.c.
References ast_ha::addr, ast_calloc, ast_free_ha(), ast_log, AST_SENSE_ALLOW, AST_SENSE_DENY, ast_sockaddr_apply_netmask(), ast_sockaddr_ipv4_mapped(), ast_sockaddr_is_ipv4(), ast_sockaddr_parse(), ast_sockaddr_port, ast_sockaddr_set_port, ast_sockaddr_stringify(), ast_strdupa, DEBUG_ATLEAST, debug_ha_sense_appended(), error(), LOG_NOTICE, LOG_WARNING, ast_ha::netmask, ast_ha::next, NULL, parse_cidr_mask(), PARSE_PORT_FORBID, PARSE_PORT_MASK, ast_ha::sense, strsep(), and tmp().
Referenced by ast_append_ha(), and ast_append_ha_with_port().
int ast_acl_list_is_empty | ( | struct ast_acl_list * | acl_list | ) |
Determines if an ACL is empty or if it contains entries.
acl_list | The ACL list being checked |
0 | the list is not empty |
1 | the list is empty |
Definition at line 540 of file acl.c.
References AST_LIST_FIRST, AST_LIST_LOCK, and AST_LIST_UNLOCK.
Referenced by acl_to_str(), apply_acl(), apply_contact_acl(), apply_endpoint_acl(), apply_endpoint_contact_acl(), contact_acl_to_str(), curl_open_socket_cb(), handle_cli_iax2_show_peer(), handle_cli_iax2_show_users(), and handle_showmanager().
void ast_acl_output | ( | int | fd, |
struct ast_acl_list * | acl, | ||
const char * | prefix | ||
) |
output an ACL to the provided fd
This function can be used centrally to output HAs as used in ACLs from other modules. It follows the format as originally used for named ACLs in named_acl.c.
fd | The file-descriptor to which to output the ACL. |
acl | The ACL to output. |
prefix | If you need a specific prefix output on each line, give it here, may be NULL. |
Definition at line 1115 of file acl.c.
References ast_acl::acl, ast_cli(), ast_ha_output(), AST_LIST_LOCK, AST_LIST_TRAVERSE, AST_LIST_UNLOCK, ast_strlen_zero(), ast_acl::list, and prefix.
Referenced by handle_showmanager().
void ast_append_acl | ( | const char * | sense, |
const char * | stuff, | ||
struct ast_acl_list ** | path, | ||
int * | error, | ||
int * | named_acl_flag | ||
) |
Add a rule to an ACL struct.
This adds a named ACL or an ACL rule to an ast_acl container. It works in a similar way to ast_append_ha.
sense | Can be any among "permit", "deny", or "acl" this controls whether the rule being added will simply modify the unnamed ACL at the head of the list or if a new named ACL will be added to that ast_acl. | |
stuff | If sense is 'permit'/'deny', this is the ip address and subnet mask separated with a '/' like in ast_append ha. If it sense is 'acl', then this will be the name of the ACL being appended to the container. | |
path | Address of the ACL list being appended | |
[out] | error | The int that error points to will be set to 1 if an error occurs. |
[out] | named_acl_flag | This will raise a flag under certain conditions to indicate that a named ACL has been added by this operation. This may be used to indicate that an event subscription should be made against the named ACL subsystem. Note: This flag may be raised by this function, but it will never be lowered by it. |
Definition at line 429 of file acl.c.
References acl_new(), ast_append_ha(), ast_calloc, AST_LIST_FIRST, AST_LIST_HEAD_INIT, AST_LIST_INSERT_HEAD, AST_LIST_INSERT_TAIL, AST_LIST_LOCK, AST_LIST_TRAVERSE, AST_LIST_UNLOCK, ast_log, ast_named_acl_find(), ast_skip_blanks(), ast_strdupa, ast_strlen_zero(), current, error(), LOG_ERROR, NULL, strsep(), and tmp().
Referenced by __init_manager(), acl_handler(), build_peer(), build_user(), endpoint_acl_handler(), rtp_reload(), and verification_apply().
struct ast_ha * ast_append_ha | ( | const char * | sense, |
const char * | stuff, | ||
struct ast_ha * | path, | ||
int * | error | ||
) |
Add a new rule to a list of HAs.
This adds the new host access rule to the end of the list whose head is specified by the path parameter. Rules are evaluated in a way such that if multiple rules apply to a single IP address/subnet mask, then the rule latest in the list will be used.
sense | Either "permit" or "deny" (Actually any 'p' word will result in permission, and any other word will result in denial) | |
stuff | The IP address and subnet mask, separated with a '/'. The subnet mask can either be in dotted-decimal format or in CIDR notation (i.e. 0-32). | |
path | The head of the HA list to which we wish to append our new rule. If NULL is passed, then the new rule will become the head of the list | |
[out] | error | The integer error points to will be set non-zero if an error occurs |
Definition at line 712 of file acl.c.
References append_ha_core(), error(), PARSE_PORT_FORBID, and ast_ha::sense.
Referenced by acl_handler_fn(), add_calltoken_ignore(), ast_append_acl(), AST_TEST_DEFINE(), build_callno_limits(), build_device(), build_ha(), named_acl_find_realtime(), and transport_localnet_handler().
struct ast_ha * ast_append_ha_with_port | ( | const char * | sense, |
const char * | stuff, | ||
struct ast_ha * | path, | ||
int * | error | ||
) |
Add a new rule with optional port to a list of HAs.
This adds the new host access rule to the end of the list whose head is specified by the path parameter. Rules are evaluated in a way such that if multiple rules apply to a single IP address/subnet mask, then the rule latest in the list will be used.
sense | Either "permit" or "deny" (Actually any 'p' word will result in permission, and any other word will result in denial) | |
stuff | The IP address and subnet mask, separated with a '/'. The subnet mask can either be in dotted-decimal format or in CIDR notation (i.e. 0-32). A port can be provided by placing it after the IP address, separated with a ':'. | |
path | The head of the HA list to which we wish to append our new rule. If NULL is passed, then the new rule will become the head of the list | |
[out] | error | The integer error points to will be set non-zero if an error occurs |
Definition at line 717 of file acl.c.
References append_ha_core(), error(), and ast_ha::sense.
Referenced by ip_identify_match_handler(), ip_identify_match_host_lookup(), and pjsip_enable_logger_host().
enum ast_acl_sense ast_apply_acl | ( | struct ast_acl_list * | acl_list, |
const struct ast_sockaddr * | addr, | ||
const char * | purpose | ||
) |
Apply a set of rules to a given IP address.
Similar to the above, only uses an acl container, which is a whole slew of ast_ha lists. It runs ast_apply_ha on each of the ast_ha structs contained in the acl container. It will deny if any of the ast_ha lists fail, and it will pass only if all of the rules pass.
acl_list | The head of the list of ACLs to evaluate |
addr | An ast_sockaddr whose address is considered when matching rules |
purpose | Context for which the ACL is being applied - Establishes purpose of a notice when rejected |
AST_SENSE_ALLOW | The IP address passes our ACLs |
AST_SENSE_DENY | The IP address fails our ACLs |
Definition at line 799 of file acl.c.
References ast_apply_acl_internal().
Referenced by apply_acl(), apply_contact_acl(), apply_endpoint_acl(), apply_endpoint_contact_acl(), auth_http_callback(), authenticate(), check_access(), curl_open_socket_cb(), and register_verify().
|
static |
Definition at line 757 of file acl.c.
References ast_acl::acl, ast_apply_ha(), AST_LIST_LOCK, AST_LIST_TRAVERSE, AST_LIST_UNLOCK, ast_log, AST_SENSE_ALLOW, AST_SENSE_DENY, ast_sockaddr_stringify_addr(), ast_strlen_zero(), ast_acl::list, LOG_NOTICE, and LOG_WARNING.
Referenced by ast_apply_acl(), and ast_apply_acl_nolog().
enum ast_acl_sense ast_apply_acl_nolog | ( | struct ast_acl_list * | acl_list, |
const struct ast_sockaddr * | addr | ||
) |
Apply a set of rules to a given IP address, don't log failure.
Exactly like ast_apply_acl, except that it will never log anything.
acl_list | The head of the list of ACLs to evaluate |
addr | An ast_sockaddr whose address is considered when matching rules |
AST_SENSE_ALLOW | The IP address passes our ACLs |
AST_SENSE_DENY | The IP address fails our ACLs |
Definition at line 803 of file acl.c.
References ast_apply_acl_internal(), and NULL.
enum ast_acl_sense ast_apply_ha | ( | const struct ast_ha * | ha, |
const struct ast_sockaddr * | addr | ||
) |
Apply a set of rules to a given IP address.
The list of host access rules is traversed, beginning with the input rule. If the IP address given matches a rule, the "sense" of that rule is used as the return value. Note that if an IP address matches multiple rules that the last one matched will be the one whose sense will be returned.
ha | The head of the list of host access rules to follow |
addr | An ast_sockaddr whose address is considered when matching rules |
AST_SENSE_ALLOW | The IP address passes our ACL |
AST_SENSE_DENY | The IP address fails our ACL |
Definition at line 807 of file acl.c.
References ast_ha::addr, ast_copy_string(), ast_debug, ast_log, AST_SENSE_ALLOW, ast_sockaddr_apply_netmask(), ast_sockaddr_cmp_addr(), ast_sockaddr_ipv4_mapped(), ast_sockaddr_is_ipv4(), ast_sockaddr_is_ipv4_mapped(), ast_sockaddr_is_ipv6(), ast_sockaddr_port, ast_sockaddr_set_port, ast_sockaddr_stringify(), LOG_ERROR, ast_ha::netmask, ast_ha::next, result, and ast_ha::sense.
Referenced by ast_apply_acl_internal(), AST_TEST_DEFINE(), ip_identify_match_check(), ip_identify_match_host_lookup(), and pjsip_log_test_filter().
Copy the contents of one HA to another.
This copies the internals of the 'from' HA to the 'to' HA. It is important that the 'to' HA has been allocated prior to calling this function
from | Source HA to copy |
to | Destination HA to copy to |
Definition at line 255 of file acl.c.
References ast_ha::addr, ast_sockaddr_copy(), ast_ha::netmask, and ast_ha::sense.
Referenced by add_calltoken_ignore(), ast_duplicate_ha(), and build_callno_limits().
struct ast_acl_list * ast_duplicate_acl_list | ( | struct ast_acl_list * | original | ) |
Duplicates the contests of a list of lists of host access rules.
A deep copy of an ast_acl list is made (which in turn means a deep copy of each of the ast_ha structs contained within). The returned value is allocated on the heap and must be freed independently of the input paramater when finished.
original | The ast_acl_list to copy |
Definition at line 315 of file acl.c.
References ast_acl::acl, acl_new(), ast_calloc, ast_duplicate_ha_list(), ast_free_acl_list(), AST_LIST_HEAD_INIT, AST_LIST_INSERT_TAIL, AST_LIST_LOCK, AST_LIST_TRAVERSE, AST_LIST_UNLOCK, ast_log, ast_acl::is_invalid, ast_acl::is_realtime, ast_acl::list, LOG_ERROR, ast_acl::name, and NULL.
Referenced by vs_copy_cfg_common().
Definition at line 263 of file acl.c.
References ast_calloc, and ast_copy_ha().
Referenced by ast_duplicate_ha_list().
Duplicate the contents of a list of host access rules.
A deep copy of all ast_has in the list is made. The returned value is allocated on the heap and must be freed independently of the input parameter when finished.
original | The ast_ha to copy |
Definition at line 276 of file acl.c.
References ast_duplicate_ha(), ast_free_ha(), current, ast_ha::next, and NULL.
Referenced by ast_duplicate_acl_list(), and ast_named_acl_find().
int ast_find_ourip | ( | struct ast_sockaddr * | ourip, |
const struct ast_sockaddr * | bindaddr, | ||
int | family | ||
) |
Find our IP address.
This function goes through many iterations in an attempt to find our IP address. If any step along the way should fail, we move to the next item in the list. Here are the steps taken:
[out] | ourip | Our IP address is written here when it is found |
bindaddr | A hint used for finding our IP. See the steps above for more details | |
family | Only addresses of the given family will be returned. Use 0 or AST_SOCKADDR_UNSPEC to get addresses of all families. |
0 | Success |
-1 | Failure |
Definition at line 1068 of file acl.c.
References ast_debug, ast_log, ast_ouraddrfor(), ast_sockaddr_copy(), ast_sockaddr_is_any(), ast_sockaddr_port, ast_sockaddr_set_port, bindaddr, get_local_address(), LOG_WARNING, MAXHOSTNAMELEN, NULL, PARSE_PORT_FORBID, and resolve_match_or_first().
Referenced by ast_rtp_prop_set().
struct ast_acl_list * ast_free_acl_list | ( | struct ast_acl_list * | acl | ) |
Free a list of ACLs.
Given the head of a list of ast_acl structs, it and all appended acl structs will be freed. This includes the ast_ha structs within the individual nodes.
acl | The list of ACLs to free |
NULL |
Definition at line 233 of file acl.c.
References ast_free, ast_free_ha(), AST_LIST_HEAD_DESTROY, AST_LIST_LOCK, AST_LIST_REMOVE_HEAD, AST_LIST_UNLOCK, current, ast_acl::list, and NULL.
Referenced by __init_manager(), acl_destroy(), ast_duplicate_acl_list(), build_peer(), build_user(), endpoint_destructor(), manager_free_user(), peer_destructor(), rtp_reload(), user_destructor(), vcfg_cleanup(), verification_apply(), and vs_copy_cfg_common().
void ast_free_ha | ( | struct ast_ha * | ha | ) |
Free a list of HAs.
Given the head of a list of HAs, it and all appended HAs are freed
ha | The head of the list of HAs to free |
Definition at line 222 of file acl.c.
References ast_free, and ast_ha::next.
Referenced by add_calltoken_ignore(), append_ha_core(), ast_duplicate_ha_list(), ast_free_acl_list(), AST_TEST_DEFINE(), build_callno_limits(), destroy_named_acl(), destroy_sip_transport_state(), ip_identify_destroy(), named_acl_find_realtime(), pjsip_disable_logger(), pjsip_enable_logger_host(), pjsip_logger_session_destroy(), test_item_destructor(), and transport_localnet_handler().
int ast_get_ip | ( | struct ast_sockaddr * | addr, |
const char * | hostname | ||
) |
Get the IP address given a hostname.
Similar in nature to ast_gethostbyname, except that instead of getting an entire hostent structure, you instead are given only the IP address inserted into a ast_sockaddr structure.
addr | The IP address found. The address family is used as an input parameter to filter the returned addresses. If it is AST_AF_UNSPEC, both IPv4 and IPv6 addresses can be returned. |
hostname | The hostname to look up |
0 | Success |
-1 | Failure |
Definition at line 1016 of file acl.c.
References ast_get_ip_or_srv(), hostname, and NULL.
Referenced by build_peer(), peer_set_srcaddr(), setup_stunaddr(), and stun_monitor_request().
int ast_get_ip_or_srv | ( | struct ast_sockaddr * | addr, |
const char * | hostname, | ||
const char * | service | ||
) |
Get the IP address given a hostname and optional service.
If the service parameter is non-NULL, then an SRV lookup will be made by prepending the service to the hostname parameter, separated by a '.' For example, if hostname is "example.com" and service is "_sip._udp" then an SRV lookup will be done for "_sip._udp.example.com". If service is NULL, then this function acts exactly like a call to ast_get_ip.
addr | The IP address found. The address family is used as an input parameter to filter the returned addresses. If it is 0, both IPv4 and IPv6 addresses can be returned. |
hostname | The hostname to look up |
service | A specific service provided by the host. A NULL service results in an A-record lookup instead of an SRV lookup |
0 | Success |
-1 | Failure |
Definition at line 933 of file acl.c.
References ast_get_ip_or_srv_with_preference(), hostname, NULL, and service.
Referenced by ast_get_ip(), create_addr(), and internal_dnsmgr_lookup().
int ast_get_ip_or_srv_with_preference | ( | struct ast_sockaddr * | addr, |
const char * | hostname, | ||
const char * | service, | ||
struct ast_sockaddr * | preference | ||
) |
Get the IP address given a hostname and optional service with a preferred result.
If the service parameter is non-NULL, then an SRV lookup will be made by prepending the service to the hostname parameter, separated by a '.' For example, if hostname is "example.com" and service is "_sip._udp" then an SRV lookup will be done for "_sip._udp.example.com". If service is NULL, then this function acts exactly like a call to ast_get_ip.
addr | The IP address found. The address family is used as an input parameter to filter the returned addresses. If it is 0, both IPv4 and IPv6 addresses can be returned. |
hostname | The hostname to look up |
service | A specific service provided by the host. A NULL service results in an A-record lookup instead of an SRV lookup |
preference | The preferred IP address to return. If multiple results are available and this IP address is in the list then it will be returned. If NULL, or if the none of the returned IP addresses match, then the first IP address will be returned. |
0 | Success |
-1 | Failure |
Definition at line 907 of file acl.c.
References ast_get_srv(), ast_sockaddr_set_port, hostname, NULL, PARSE_PORT_FORBID, resolve_match_or_first(), service, and ast_sockaddr::ss.
Referenced by ast_get_ip_or_srv(), and dnsmgr_refresh().
Convert HAs to a comma separated string value.
ha | the starting ha head |
buf | string buffer to convert data to |
Definition at line 722 of file acl.c.
References ast_ha::addr, AST_SENSE_ALLOW, ast_sockaddr_port, ast_sockaddr_stringify(), ast_sockaddr_stringify_addr(), ast_str_append(), buf, ast_ha::netmask, ast_ha::next, and ast_ha::sense.
Referenced by localnet_to_str(), and match_to_str().
Convert HAs to a comma separated string value using CIDR notation.
ha | the starting ha head |
buf | string buffer to convert data to |
Definition at line 744 of file acl.c.
References ast_ha::addr, AST_SENSE_ALLOW, ast_sockaddr_cidr_bits(), ast_sockaddr_stringify_addr(), ast_str_append(), buf, ast_ha::netmask, ast_ha::next, and ast_ha::sense.
void ast_ha_output | ( | int | fd, |
const struct ast_ha * | ha, | ||
const char * | prefix | ||
) |
output an HA to the provided fd
This function can be used centrally to output HAs as used in ACLs from other modules. It follows the format as originally used for named ACLs in named_acl.c.
fd | The file-descriptor to which to output the HA. |
ha | The HA to output. |
prefix | If you need a specific prefix output on each line, give it here, may be NULL. |
Definition at line 1103 of file acl.c.
References ast_ha::addr, ast_cli(), AST_SENSE_ALLOW, AST_SOCKADDR_BUFLEN, ast_sockaddr_stringify_addr(), ast_ha::netmask, ast_ha::next, prefix, and ast_ha::sense.
Referenced by ast_acl_output(), cli_display_named_acl(), and print_acl().
int ast_ouraddrfor | ( | const struct ast_sockaddr * | them, |
struct ast_sockaddr * | us | ||
) |
Get our local IP address when contacting a remote host.
This function will attempt to connect(2) to them over UDP using a source port of 5060. If the connect(2) call is successful, then we inspect the sockaddr_in output parameter of connect(2) to determine the IP address used to connect to them. This IP address is then copied into us.
them | The IP address to which we wish to attempt to connect | |
[out] | us | The source IP address used to connect to them |
-1 | Failure |
0 | Success |
Definition at line 1021 of file acl.c.
References ast_connect(), ast_debug, ast_getsockname(), ast_log, ast_sockaddr_is_ipv6(), ast_sockaddr_port, ast_sockaddr_set_port, ast_sockaddr_stringify_addr(), ast_strdupa, errno, LOG_ERROR, and LOG_WARNING.
Referenced by ast_find_ourip(), ast_rtp_remote_address_set(), and unicast_rtp_request().
int ast_str2cos | ( | const char * | value, |
unsigned int * | cos | ||
) |
Convert a string to the appropriate COS value.
value | The COS string to convert | |
[out] | cos | The integer representation of that COS value |
-1 | Failure |
0 | Success |
Definition at line 969 of file acl.c.
Referenced by reload_config(), and set_config().
int ast_str2tos | ( | const char * | value, |
unsigned int * | tos | ||
) |
Convert a string to the appropriate TOS value.
value | The TOS string to convert | |
[out] | tos | The integer representation of that TOS value |
-1 | Failure |
0 | Success |
Definition at line 983 of file acl.c.
References ARRAY_LEN, dscp_pool1, name, dscp_codepoint::space, tos, and value.
Referenced by iax_template_parse(), reload_config(), set_config(), tos_handler(), and transport_tos_handler().
const char * ast_tos2str | ( | unsigned int | tos | ) |
Convert a TOS value into its string representation.
tos | The TOS value to look up |
Definition at line 1003 of file acl.c.
References ARRAY_LEN, dscp_pool1, dscp_codepoint::name, dscp_codepoint::space, and tos.
|
static |
Definition at line 565 of file acl.c.
References ast_ha::addr, ast_log, ast_sockaddr_stringify(), ast_strdupa, LOG_DEBUG, ast_ha::netmask, and ast_ha::sense.
Referenced by append_ha_core().
|
static |
Definition at line 118 of file acl.c.
References ast_free, ast_malloc, ast_sockaddr_setnull(), buf, NULL, score_address(), and ast_sockaddr::ss.
Referenced by ast_find_ourip().
|
static |
Parse a netmask in CIDR notation.
For a mask of an IPv4 address, this should be a number between 0 and 32. For a mask of an IPv6 address, this should be a number between 0 and 128. This function creates an IPv6 ast_sockaddr from the given netmask. For masks of IPv4 addresses, this is accomplished by adding 96 to the original netmask.
[out] | addr | The ast_sockaddr produced from the CIDR netmask |
is_v4 | Tells if the address we are masking is IPv4. | |
mask_str | The CIDR mask to convert |
-1 | Failure |
0 | Success |
Definition at line 381 of file acl.c.
References ast_sockaddr_from_sin, ast_sockaddr::len, ast_sockaddr::ss, and V6_WORD.
Referenced by append_ha_core().
|
static |
Definition at line 875 of file acl.c.
References ast_debug, ast_free, ast_log, ast_sockaddr_cmp_addr(), ast_sockaddr_copy(), ast_sockaddr_resolve(), LOG_WARNING, and name.
Referenced by ast_find_ourip(), and ast_get_ip_or_srv_with_preference().
|
static |
Definition at line 59 of file acl.c.
References ast_inet_ntoa().
Referenced by get_local_address().
|
static |
Definition at line 945 of file acl.c.
Referenced by ast_str2tos(), and ast_tos2str().