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

Go to the source code of this file.

Macros

#define DEFAULT_ENCODING   "identity"
 
#define DEFAULT_LANGUAGE   "en"
 

Functions

static void __reg_module (void)
 
static void __unreg_module (void)
 
struct ast_moduleAST_MODULE_SELF_SYM (void)
 
static int load_module (void)
 
static int options_incoming_request (struct ast_sip_session *session, pjsip_rx_data *rdata)
 
static int unload_module (void)
 

Variables

static struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "SIP OPTIONS in dialog handler" , .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,res_pjsip_session", }
 
static const struct ast_module_infoast_module_info = &__mod_info
 
static struct ast_sip_session_supplement dlg_options_supplement
 

Macro Definition Documentation

◆ DEFAULT_ENCODING

#define DEFAULT_ENCODING   "identity"

Definition at line 37 of file res_pjsip_dlg_options.c.

◆ DEFAULT_LANGUAGE

#define DEFAULT_LANGUAGE   "en"

Definition at line 36 of file res_pjsip_dlg_options.c.

Function Documentation

◆ __reg_module()

static void __reg_module ( void  )
static

Definition at line 103 of file res_pjsip_dlg_options.c.

◆ __unreg_module()

static void __unreg_module ( void  )
static

Definition at line 103 of file res_pjsip_dlg_options.c.

◆ AST_MODULE_SELF_SYM()

struct ast_module * AST_MODULE_SELF_SYM ( void  )

Definition at line 103 of file res_pjsip_dlg_options.c.

◆ load_module()

static int load_module ( void  )
static

Definition at line 84 of file res_pjsip_dlg_options.c.

85{
87
89}
@ AST_MODULE_LOAD_SUCCESS
Definition: module.h:70
static struct ast_sip_session_supplement dlg_options_supplement
#define ast_sip_session_register_supplement(supplement)

References AST_MODULE_LOAD_SUCCESS, ast_sip_session_register_supplement, and dlg_options_supplement.

◆ options_incoming_request()

static int options_incoming_request ( struct ast_sip_session session,
pjsip_rx_data *  rdata 
)
static

Definition at line 39 of file res_pjsip_dlg_options.c.

40{
41 pjsip_tx_data *tdata;
42 pj_status_t status;
43 const pjsip_hdr *hdr;
44 pjsip_endpoint *endpt = ast_sip_get_pjsip_endpoint();
45
46 status = pjsip_dlg_create_response(session->inv_session->dlg, rdata, 200, NULL,&tdata);
47 if (status != PJ_SUCCESS) {
48 ast_log(LOG_ERROR, "Unable to create response (%d)\n", status);
49 return status;
50 }
51
52 /* Add appropriate headers */
53 if ((hdr = pjsip_endpt_get_capability(endpt, PJSIP_H_ACCEPT, NULL))) {
54 pjsip_msg_add_hdr(tdata->msg, (pjsip_hdr*)pjsip_hdr_clone(tdata->pool, hdr));
55 }
56 if ((hdr = pjsip_endpt_get_capability(endpt, PJSIP_H_ALLOW, NULL))) {
57 pjsip_msg_add_hdr(tdata->msg, (pjsip_hdr*)pjsip_hdr_clone(tdata->pool, hdr));
58 }
59 if ((hdr = pjsip_endpt_get_capability(endpt, PJSIP_H_SUPPORTED, NULL))) {
60 pjsip_msg_add_hdr(tdata->msg, (pjsip_hdr*)pjsip_hdr_clone(tdata->pool, hdr));
61 }
62
63 /*
64 * XXX TODO: pjsip doesn't care a lot about either of these headers -
65 * while it provides specific methods to create them, they are defined
66 * to be the standard string header creation. Hard coded here.
67 */
68 ast_sip_add_header(tdata, "Accept-Encoding", DEFAULT_ENCODING);
69 ast_sip_add_header(tdata, "Accept-Language", DEFAULT_LANGUAGE);
70
71 status = pjsip_dlg_send_response(session->inv_session->dlg, pjsip_rdata_get_tsx(rdata), tdata);
72 if (status != PJ_SUCCESS) {
73 ast_log(LOG_ERROR, "Unable to send response (%d)\n", status);
74 }
75
76 return status;
77}
jack_status_t status
Definition: app_jack.c:146
static struct ast_mansession session
#define ast_log
Definition: astobj2.c:42
#define LOG_ERROR
pjsip_endpoint * ast_sip_get_pjsip_endpoint(void)
Get a pointer to the PJSIP endpoint.
Definition: res_pjsip.c:520
int ast_sip_add_header(pjsip_tx_data *tdata, const char *name, const char *value)
Add a header to an outbound SIP message.
Definition: res_pjsip.c:2008
#define DEFAULT_ENCODING
#define DEFAULT_LANGUAGE
#define NULL
Definition: resample.c:96

References ast_log, ast_sip_add_header(), ast_sip_get_pjsip_endpoint(), DEFAULT_ENCODING, DEFAULT_LANGUAGE, LOG_ERROR, NULL, session, and status.

◆ unload_module()

static int unload_module ( void  )
static

Definition at line 91 of file res_pjsip_dlg_options.c.

92{
94 return 0;
95}
void ast_sip_session_unregister_supplement(struct ast_sip_session_supplement *supplement)
Unregister a an supplement to SIP session processing.
Definition: pjsip_session.c:63

References ast_sip_session_unregister_supplement(), and dlg_options_supplement.

Variable Documentation

◆ __mod_info

struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "SIP OPTIONS in dialog handler" , .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,res_pjsip_session", }
static

Definition at line 103 of file res_pjsip_dlg_options.c.

◆ ast_module_info

const struct ast_module_info* ast_module_info = &__mod_info
static

Definition at line 103 of file res_pjsip_dlg_options.c.

◆ dlg_options_supplement

struct ast_sip_session_supplement dlg_options_supplement
static
Initial value:
= {
.method = "OPTIONS",
.incoming_request = options_incoming_request,
}
static int options_incoming_request(struct ast_sip_session *session, pjsip_rx_data *rdata)

Definition at line 79 of file res_pjsip_dlg_options.c.

Referenced by load_module(), and unload_module().