129 memset(&addr, 0,
sizeof(addr));
142 pjsip_sip_uri *sip_uri;
145 if (!contact || contact->star) {
149 if (!PJSIP_URI_SCHEME_IS_SIP(contact->uri) && !PJSIP_URI_SCHEME_IS_SIPS(contact->uri)) {
153 sip_uri = pjsip_uri_get_uri(contact->uri);
160 int num_contact_addrs;
164 pjsip_contact_hdr *
contact = (pjsip_contact_hdr *)&rdata->msg_info.msg->hdr;
170 while ((contact = pjsip_msg_find_hdr(rdata->msg_info.msg, PJSIP_H_CONTACT, contact->next))) {
172 if (num_contact_addrs <= 0) {
175 for (i = 0; i < num_contact_addrs; ++i) {
192 #define SIP_SORCERY_ACL_TYPE "acl" 206 pjsip_rx_data *rdata = arg;
228 if (rdata->msg_info.msg->line.req.method.id != PJSIP_ACK_METHOD) {
243 if (!strncmp(var->
name,
"contact_", 8)) {
258 ast_log(
LOG_ERROR,
"There is an error in ACL configuration. Blocking ALL SIP traffic.\n");
266 .name = {
"ACL Module", 14 },
301 "config",
"pjsip.conf,criteria=type=acl");
342 .requires =
"res_pjsip",
static void acl_destroy(void *obj)
Asterisk main include file. File version handling, generic pbx functions.
Security Event Reporting API.
int ast_sockaddr_parse(struct ast_sockaddr *addr, const char *str, int flags)
Parse an IPv4 or IPv6 address string.
void ast_sorcery_force_reload_object(const struct ast_sorcery *sorcery, const char *type)
Inform any wizards of a specific object type to reload persistent objects even if no changes determin...
struct stasis_topic * ast_security_topic(void)
A stasis_topic which publishes messages for security related issues.
Stasis Message Bus API. See Stasis Message Bus API for detailed documentation.
static int apply_acl(pjsip_rx_data *rdata, struct ast_acl_list *acl)
#define ao2_callback(c, flags, cb_fn, arg)
Structure for variables, used for configurations and for channel variables.
static int apply_contact_acl(pjsip_rx_data *rdata, struct ast_acl_list *contact_acl)
Perform no matching, return all objects.
struct stasis_message_type * stasis_message_type(const struct stasis_message *msg)
Get the message type for a stasis_message.
Type for a default handler that should do nothing.
int stasis_subscription_set_filter(struct stasis_subscription *subscription, enum stasis_subscription_message_filter filter)
Set the message type filtering level on a subscription.
struct stasis_message_type * ast_named_acl_change_type(void)
a stasis_message_type for changes against a named ACL or the set of all named ACLs ...
#define ast_sorcery_apply_config(sorcery, name)
Return all matching objects.
Wrapper for an ast_acl linked list.
void ast_copy_pj_str(char *dest, const pj_str_t *src, size_t size)
Copy a pj_str_t into a standard character buffer.
void ast_sorcery_load_object(const struct ast_sorcery *sorcery, const char *type)
Inform any wizards of a specific object type to load persistent objects.
Socket address structure.
static pjsip_module acl_module
#define ast_sorcery_object_field_register_custom(sorcery, type, name, default_val, config_handler, sorcery_handler, multiple_handler, flags,...)
Register a field within an object with custom handlers.
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
Access Control of various sorts.
static int extract_contact_addr(pjsip_contact_hdr *contact, struct ast_sockaddr **addrs)
static struct stasis_subscription * acl_change_sub
#define ast_sorcery_object_register(sorcery, type, alloc, transform, apply)
Register an object type.
int ast_sip_register_service(pjsip_module *module)
Register a SIP service in Asterisk.
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.
int ast_acl_list_is_empty(struct ast_acl_list *acl_list)
Determines if an ACL is empty or if it contains entries.
#define stasis_subscribe(topic, callback, data)
static int check_acls(void *obj, void *arg, int flags)
static int load_module(void)
#define ast_sockaddr_set_port(addr, port)
Sets the port number of a socket address.
struct ast_acl_list * ast_free_acl_list(struct ast_acl_list *acl)
Free a list of ACLs.
#define ast_sorcery_apply_default(sorcery, type, name, data)
static char * ast_sockaddr_stringify(const struct ast_sockaddr *addr)
Wrapper around ast_sockaddr_stringify_fmt() with default format.
def ignore(key=None, val=None, section=None, pjsip=None, nmapped=None, type='endpoint')
#define SIP_SORCERY_ACL_TYPE
static void acl_change_stasis_cb(void *data, struct stasis_subscription *sub, struct stasis_message *message)
static void * acl_alloc(const char *name)
struct stasis_subscription * stasis_unsubscribe_and_join(struct stasis_subscription *subscription)
Cancel a subscription, blocking until the last message is processed.
Module has failed to load, may be in an inconsistent state.
static pj_bool_t acl_on_rx_msg(pjsip_rx_data *rdata)
Support for logging to various files, console and syslog Configuration in file logger.conf.
AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS|AST_MODFLAG_LOAD_ORDER, "HTTP Phone Provisioning",.support_level=AST_MODULE_SUPPORT_EXTENDED,.load=load_module,.unload=unload_module,.reload=reload,.load_pri=AST_MODPRI_CHANNEL_DEPEND,.requires="http",)
void * ast_sorcery_retrieve_by_fields(const struct ast_sorcery *sorcery, const char *type, unsigned int flags, struct ast_variable *fields)
Retrieve an object or multiple objects using specific fields.
#define ast_sorcery_object_field_register(sorcery, type, name, default_val, opt_type, flags,...)
Register a field within an object.
pjsip_endpoint * ast_sip_get_pjsip_endpoint(void)
Get a pointer to the PJSIP endpoint.
struct ast_sorcery * ast_sip_get_sorcery(void)
Get a pointer to the SIP sorcery structure.
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.
void ast_sip_unregister_service(pjsip_module *module)
static int unload_module(void)
int stasis_subscription_accept_message_type(struct stasis_subscription *subscription, const struct stasis_message_type *type)
Indicate to a subscription that we are interested in a message type.
struct stasis_forward * sub
struct ast_acl_list * contact_acl
static int acl_handler(const struct aco_option *opt, struct ast_variable *var, void *obj)
struct ast_acl_list * acl
int error(const char *format,...)
void * ast_sorcery_generic_alloc(size_t size, ao2_destructor_fn destructor)
Allocate a generic sorcery capable object.
#define ASTERISK_GPL_KEY
The text the key() function should return.
Asterisk module definitions.
SIP ACL details and configuration.
Sorcery Data Access Layer API.
int ast_sockaddr_resolve(struct ast_sockaddr **addrs, const char *str, int flags, int family)
Parses a string with an IPv4 or IPv6 address and place results into an array.