Asterisk - The Open Source Telephony Project
18.5.0
|
#include "asterisk.h"
#include <pjsip.h>
#include <pjsip_ua.h>
#include "asterisk/res_pjsip.h"
#include "asterisk/res_pjsip_session.h"
#include "asterisk/module.h"
#include "asterisk/acl.h"
Go to the source code of this file.
Data Structures | |
struct | nat_hook_details |
Structure which contains hook details. More... | |
struct | request_transport_details |
Structure which contains information about a transport. More... | |
Macros | |
#define | AST_SIP_X_AST_ORIG_HOST "x-ast-orig-host" |
#define | AST_SIP_X_AST_ORIG_HOST_LEN 15 |
#define | COLON_LEN 1 |
#define | is_sip_uri(uri) (PJSIP_URI_SCHEME_IS_SIP(uri) || PJSIP_URI_SCHEME_IS_SIPS(uri)) |
#define | MAX_PORT_LEN 5 |
Functions | |
static void | __reg_module (void) |
static void | __unreg_module (void) |
struct ast_module * | AST_MODULE_SELF_SYM (void) |
static int | find_transport_state_in_use (void *obj, void *arg, int flags) |
Callback function for finding the transport the request is going out on. More... | |
static pj_bool_t | handle_rx_message (struct ast_sip_endpoint *endpoint, pjsip_rx_data *rdata) |
static int | load_module (void) |
static pjsip_sip_uri * | nat_get_contact_sip_uri (pjsip_tx_data *tdata) |
Helper function which returns the SIP URI of a Contact header. More... | |
static int | nat_incoming_invite_request (struct ast_sip_session *session, struct pjsip_rx_data *rdata) |
Function called when an INVITE goes out. More... | |
static void | nat_incoming_invite_response (struct ast_sip_session *session, struct pjsip_rx_data *rdata) |
Function called when an INVITE response comes in. More... | |
static int | nat_invoke_hook (void *obj, void *arg, int flags) |
Callback function for invoking hooks. More... | |
static pj_bool_t | nat_on_rx_message (pjsip_rx_data *rdata) |
static pj_status_t | nat_on_tx_message (pjsip_tx_data *tdata) |
static void | nat_outgoing_invite_request (struct ast_sip_session *session, struct pjsip_tx_data *tdata) |
Function called when an INVITE comes in. More... | |
static pj_status_t | process_nat (pjsip_tx_data *tdata) |
static void | restore_orig_contact_host (pjsip_tx_data *tdata) |
static int | rewrite_contact (pjsip_rx_data *rdata, pjsip_dialog *dlg) |
static int | rewrite_route_set (pjsip_rx_data *rdata, pjsip_dialog *dlg) |
static void | rewrite_uri (pjsip_rx_data *rdata, pjsip_sip_uri *uri, pj_pool_t *pool) |
static void | save_orig_contact_host (pjsip_rx_data *rdata, pjsip_sip_uri *uri) |
static int | unload_module (void) |
Variables | |
static struct ast_module_info | __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "PJSIP NAT Support" , .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 = "30ef0c93b36035ec78c9cfd712d36d9b" , .support_level = AST_MODULE_SUPPORT_CORE, .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_APP_DEPEND, .requires = "res_pjsip,res_pjsip_session", } |
static const struct ast_module_info * | ast_module_info = &__mod_info |
static pjsip_module | nat_module |
static struct ast_sip_session_supplement | nat_supplement |
Supplement for adding NAT functionality to dialog. More... | |
#define AST_SIP_X_AST_ORIG_HOST "x-ast-orig-host" |
URI parameter for original host/port
Definition at line 37 of file res_pjsip_nat.c.
Referenced by restore_orig_contact_host(), and save_orig_contact_host().
#define AST_SIP_X_AST_ORIG_HOST_LEN 15 |
Definition at line 38 of file res_pjsip_nat.c.
Referenced by restore_orig_contact_host().
#define COLON_LEN 1 |
Referenced by save_orig_contact_host().
#define is_sip_uri | ( | uri | ) | (PJSIP_URI_SCHEME_IS_SIP(uri) || PJSIP_URI_SCHEME_IS_SIPS(uri)) |
Definition at line 40 of file res_pjsip_nat.c.
Referenced by restore_orig_contact_host().
#define MAX_PORT_LEN 5 |
Referenced by save_orig_contact_host().
|
static |
Definition at line 556 of file res_pjsip_nat.c.
|
static |
Definition at line 556 of file res_pjsip_nat.c.
struct ast_module* AST_MODULE_SELF_SYM | ( | void | ) |
Definition at line 556 of file res_pjsip_nat.c.
|
static |
Callback function for finding the transport the request is going out on.
Definition at line 254 of file res_pjsip_nat.c.
References CMP_MATCH, ast_sip_transport_state::factory, request_transport_details::factory, request_transport_details::local_address, request_transport_details::local_port, ast_sip_transport_state::transport, request_transport_details::transport, ast_sip_transport_state::type, and request_transport_details::type.
Referenced by process_nat().
|
static |
Definition at line 200 of file res_pjsip_nat.c.
References ast_sip_endpoint_nat_configuration::force_rport, ast_sip_endpoint::nat, rewrite_contact(), ast_sip_endpoint_nat_configuration::rewrite_contact, and rewrite_route_set().
Referenced by nat_incoming_invite_response(), and nat_on_rx_message().
|
static |
Definition at line 538 of file res_pjsip_nat.c.
References ast_log, AST_MODFLAG_LOAD_ORDER, AST_MODPRI_APP_DEPEND, AST_MODULE_INFO(), AST_MODULE_LOAD_DECLINE, AST_MODULE_LOAD_SUCCESS, AST_MODULE_SUPPORT_CORE, ast_sip_register_service(), ast_sip_session_register_supplement, ASTERISK_GPL_KEY, LOG_ERROR, nat_module, and unload_module().
|
static |
Helper function which returns the SIP URI of a Contact header.
Definition at line 274 of file res_pjsip_nat.c.
References NULL.
Referenced by process_nat().
|
static |
Function called when an INVITE goes out.
Definition at line 498 of file res_pjsip_nat.c.
References ast_sip_session::inv_session, nat_module, and NULL.
|
static |
Function called when an INVITE response comes in.
Definition at line 508 of file res_pjsip_nat.c.
References ast_sip_session::endpoint, and handle_rx_message().
|
static |
Callback function for invoking hooks.
Definition at line 294 of file res_pjsip_nat.c.
References ast_sip_nat_hook::outgoing_external_message, nat_hook_details::tdata, and nat_hook_details::transport.
Referenced by process_nat().
|
static |
Definition at line 228 of file res_pjsip_nat.c.
References ao2_cleanup, ast_pjsip_rdata_get_endpoint(), and handle_rx_message().
|
static |
Definition at line 477 of file res_pjsip_nat.c.
References process_nat(), and restore_orig_contact_host().
|
static |
Function called when an INVITE comes in.
Definition at line 514 of file res_pjsip_nat.c.
References ast_sip_session::inv_session, nat_module, and NULL.
|
static |
Definition at line 365 of file res_pjsip_nat.c.
References ao2_callback, ao2_cleanup, ast_debug, AST_RETRIEVE_FLAG_ALL, AST_RETRIEVE_FLAG_MULTIPLE, ast_sip_get_sorcery(), ast_sip_get_transport_states(), ast_sip_transport_is_local, ast_sockaddr_isnull(), ast_sockaddr_parse(), ast_sockaddr_set_port, ast_sockaddr_stringify_host(), ast_sorcery_retrieve_by_fields(), ast_sorcery_retrieve_by_id(), AST_TRANSPORT_TCP, AST_TRANSPORT_TLS, AST_TRANSPORT_UDP, request_transport_details::factory, find_transport_state_in_use(), request_transport_details::local_address, request_transport_details::local_port, nat_get_contact_sip_uri(), nat_invoke_hook(), NULL, PARSE_PORT_FORBID, RAII_VAR, nat_hook_details::tdata, request_transport_details::transport, transport_states, and request_transport_details::type.
Referenced by nat_on_tx_message().
|
static |
Definition at line 306 of file res_pjsip_nat.c.
References ast_debug, AST_SIP_X_AST_ORIG_HOST, AST_SIP_X_AST_ORIG_HOST_LEN, is_sip_uri, and NULL.
Referenced by nat_on_tx_message().
|
static |
Definition at line 179 of file res_pjsip_nat.c.
References NULL, and rewrite_uri().
Referenced by handle_rx_message().
|
static |
Record-Route header has no meaning in REGISTER requests and should be ignored
There is currently no good way to get the dlg object for a pubsub dialog so we will just look at the rr & contact of the current message and hope for the best
Even if this message doesn't have any route headers the dialog may, so wait until a later invocation that has a dialog reference to make sure there isn't a previously saved routset in the dialog before deciding the contact needs to be modified
Definition at line 116 of file res_pjsip_nat.c.
References NULL, and rewrite_uri().
Referenced by handle_rx_message().
|
static |
Definition at line 69 of file res_pjsip_nat.c.
References save_orig_contact_host().
Referenced by rewrite_contact(), and rewrite_route_set().
|
static |
Definition at line 43 of file res_pjsip_nat.c.
References ast_debug, AST_SIP_X_AST_ORIG_HOST, COLON_LEN, and MAX_PORT_LEN.
Referenced by rewrite_uri().
|
static |
Definition at line 531 of file res_pjsip_nat.c.
References ast_sip_session_unregister_supplement(), ast_sip_unregister_service(), and nat_module.
Referenced by load_module().
|
static |
Definition at line 556 of file res_pjsip_nat.c.
|
static |
Definition at line 556 of file res_pjsip_nat.c.
|
static |
Definition at line 487 of file res_pjsip_nat.c.
Referenced by load_module(), nat_incoming_invite_request(), nat_outgoing_invite_request(), and unload_module().
|
static |
Supplement for adding NAT functionality to dialog.
Definition at line 522 of file res_pjsip_nat.c.