Asterisk - The Open Source Telephony Project GIT-master-b023714
|
#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... | |
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 pj_bool_t | handle_rx_message (struct ast_sip_endpoint *endpoint, pjsip_rx_data *rdata) |
static int | load_module (void) |
static int | nat_incoming_invite_request (struct ast_sip_session *session, struct pjsip_rx_data *rdata) |
Function called when an INVITE goes out. | |
static void | nat_incoming_invite_response (struct ast_sip_session *session, struct pjsip_rx_data *rdata) |
Function called when an INVITE response comes in. | |
static int | nat_invoke_hook (void *obj, void *arg, int flags) |
Callback function for invoking hooks. | |
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. | |
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 = ASTERISK_GPL_KEY , .buildopt_sum = AST_BUILDOPT_SUM, .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. | |
#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.
#define AST_SIP_X_AST_ORIG_HOST_LEN 15 |
Definition at line 38 of file res_pjsip_nat.c.
#define COLON_LEN 1 |
#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.
#define MAX_PORT_LEN 5 |
|
static |
Definition at line 479 of file res_pjsip_nat.c.
|
static |
Definition at line 479 of file res_pjsip_nat.c.
struct ast_module * AST_MODULE_SELF_SYM | ( | void | ) |
Definition at line 479 of file res_pjsip_nat.c.
|
static |
Definition at line 199 of file res_pjsip_nat.c.
References ast_sip_endpoint_nat_configuration::force_rport, ast_sip_endpoint::nat, ast_sip_endpoint_nat_configuration::rewrite_contact, rewrite_contact(), and rewrite_route_set().
Referenced by nat_incoming_invite_response(), and nat_on_rx_message().
|
static |
Definition at line 461 of file res_pjsip_nat.c.
References ast_log, AST_MODULE_LOAD_DECLINE, AST_MODULE_LOAD_SUCCESS, ast_sip_register_service(), ast_sip_session_register_supplement, LOG_ERROR, nat_module, and nat_supplement.
|
static |
Function called when an INVITE goes out.
Definition at line 421 of file res_pjsip_nat.c.
References nat_module, NULL, and session.
|
static |
Function called when an INVITE response comes in.
Definition at line 431 of file res_pjsip_nat.c.
References handle_rx_message(), and session.
|
static |
Callback function for invoking hooks.
Definition at line 247 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 227 of file res_pjsip_nat.c.
References ao2_cleanup, ast_pjsip_rdata_get_endpoint(), and handle_rx_message().
|
static |
Definition at line 400 of file res_pjsip_nat.c.
References process_nat(), restore_orig_contact_host(), and nat_hook_details::tdata.
|
static |
Function called when an INVITE comes in.
Definition at line 437 of file res_pjsip_nat.c.
References nat_module, NULL, and session.
|
static |
Definition at line 318 of file res_pjsip_nat.c.
References ao2_callback, ao2_cleanup, ast_debug, AST_RETRIEVE_FLAG_ALL, AST_RETRIEVE_FLAG_MULTIPLE, ast_sip_find_transport_state_in_use(), ast_sip_get_contact_sip_uri(), ast_sip_get_sorcery(), ast_sip_set_request_transport_details(), 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(), nat_invoke_hook(), NULL, PARSE_PORT_FORBID, RAII_VAR, nat_hook_details::tdata, and nat_hook_details::transport.
Referenced by nat_on_tx_message().
|
static |
Definition at line 259 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, NULL, and nat_hook_details::tdata.
Referenced by nat_on_tx_message().
|
static |
Definition at line 178 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 115 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 454 of file res_pjsip_nat.c.
References ast_sip_session_unregister_supplement(), ast_sip_unregister_service(), nat_module, and nat_supplement.
|
static |
Definition at line 479 of file res_pjsip_nat.c.
|
static |
Definition at line 479 of file res_pjsip_nat.c.
|
static |
Definition at line 410 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 445 of file res_pjsip_nat.c.
Referenced by load_module(), and unload_module().