Asterisk - The Open Source Telephony Project GIT-master-f36a736
Functions | Variables
res_pjsip_sips_contact.c File Reference
#include "asterisk.h"
#include <pjsip.h>
#include "asterisk/res_pjsip.h"
#include "asterisk/module.h"
Include dependency graph for res_pjsip_sips_contact.c:

Go to the source code of this file.

Functions

static void __reg_module (void)
 
static void __unreg_module (void)
 
struct ast_moduleAST_MODULE_SELF_SYM (void)
 
static int load_module (void)
 
static pj_status_t sips_contact_on_tx_request (pjsip_tx_data *tdata)
 Upgrade Contact URIs on outgoing SIP requests to SIPS if required. More...
 
static int unload_module (void)
 

Variables

static struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "UAC SIPS Contact 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 = AST_BUILDOPT_SUM, .support_level = AST_MODULE_SUPPORT_CORE, .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_APP_DEPEND, .requires = "res_pjsip", }
 
static const struct ast_module_infoast_module_info = &__mod_info
 
static pjsip_module sips_contact_module
 

Function Documentation

◆ __reg_module()

static void __reg_module ( void  )
static

Definition at line 106 of file res_pjsip_sips_contact.c.

◆ __unreg_module()

static void __unreg_module ( void  )
static

Definition at line 106 of file res_pjsip_sips_contact.c.

◆ AST_MODULE_SELF_SYM()

struct ast_module * AST_MODULE_SELF_SYM ( void  )

Definition at line 106 of file res_pjsip_sips_contact.c.

◆ load_module()

static int load_module ( void  )
static

Definition at line 91 of file res_pjsip_sips_contact.c.

92{
95 }
96
98}
@ AST_MODULE_LOAD_SUCCESS
Definition: module.h:70
@ AST_MODULE_LOAD_DECLINE
Module has failed to load, may be in an inconsistent state.
Definition: module.h:78
int ast_sip_register_service(pjsip_module *module)
Register a SIP service in Asterisk.
Definition: res_pjsip.c:117
static pjsip_module sips_contact_module

References AST_MODULE_LOAD_DECLINE, AST_MODULE_LOAD_SUCCESS, ast_sip_register_service(), and sips_contact_module.

◆ sips_contact_on_tx_request()

static pj_status_t sips_contact_on_tx_request ( pjsip_tx_data *  tdata)
static

Upgrade Contact URIs on outgoing SIP requests to SIPS if required.

The rules being used here are according to RFC 3261 section 8.1.1.8. In brief, if the request URI is SIPS or the topmost Route header is SIPS, then the Contact header we send must also be SIPS.

Definition at line 39 of file res_pjsip_sips_contact.c.

40{
41 pjsip_contact_hdr *contact;
42 pjsip_route_hdr *route;
43 pjsip_sip_uri *contact_uri;
44
45 contact = pjsip_msg_find_hdr(tdata->msg, PJSIP_H_CONTACT, NULL);
46 if (!contact) {
47 return PJ_SUCCESS;
48 }
49
50 contact_uri = pjsip_uri_get_uri(contact->uri);
51 if (PJSIP_URI_SCHEME_IS_SIPS(contact_uri)) {
52 /* If the Contact header is already SIPS, then we don't need to do anything */
53 return PJ_SUCCESS;
54 }
55
56 if (PJSIP_URI_SCHEME_IS_SIPS(tdata->msg->line.req.uri)) {
57 ast_debug(1, "Upgrading contact URI on outgoing SIP request to SIPS due to SIPS Request URI\n");
58 pjsip_sip_uri_set_secure(contact_uri, PJ_TRUE);
59 return PJ_SUCCESS;
60 }
61
62 route = pjsip_msg_find_hdr(tdata->msg, PJSIP_H_ROUTE, NULL);
63 if (!route) {
64 return PJ_SUCCESS;
65 }
66
67 if (!PJSIP_URI_SCHEME_IS_SIPS(&route->name_addr)) {
68 return PJ_SUCCESS;
69 }
70
71 /* Our Contact header is not a SIPS URI, but our topmost Route header is. */
72 ast_debug(1, "Upgrading contact URI on outgoing SIP request to SIPS due to SIPS Route header\n");
73 pjsip_sip_uri_set_secure(contact_uri, PJ_TRUE);
74
75 return PJ_SUCCESS;
76}
#define ast_debug(level,...)
Log a DEBUG message.
#define NULL
Definition: resample.c:96

References ast_debug, and NULL.

◆ unload_module()

static int unload_module ( void  )
static

Definition at line 85 of file res_pjsip_sips_contact.c.

86{
88 return 0;
89}
void ast_sip_unregister_service(pjsip_module *module)
Definition: res_pjsip.c:133

References ast_sip_unregister_service(), and sips_contact_module.

Variable Documentation

◆ __mod_info

struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "UAC SIPS Contact 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 = AST_BUILDOPT_SUM, .support_level = AST_MODULE_SUPPORT_CORE, .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_APP_DEPEND, .requires = "res_pjsip", }
static

Definition at line 106 of file res_pjsip_sips_contact.c.

◆ ast_module_info

const struct ast_module_info* ast_module_info = &__mod_info
static

Definition at line 106 of file res_pjsip_sips_contact.c.

◆ sips_contact_module

pjsip_module sips_contact_module
static

Definition at line 78 of file res_pjsip_sips_contact.c.

Referenced by load_module(), and unload_module().