Asterisk - The Open Source Telephony Project  18.5.0
res_pjsip_empty_info.c
Go to the documentation of this file.
1 /*
2  * Asterisk -- An open source telephony toolkit.
3  *
4  * Copyright (C) 2016, Digium, Inc.
5  *
6  * Bradley Latus <[email protected]>
7  *
8  * See http://www.asterisk.org for more information about
9  * the Asterisk project. Please do not directly contact
10  * any of the maintainers of this project for assistance;
11  * the project provides a web site, mailing lists and IRC
12  * channels for your use.
13  *
14  * This program is free software, distributed under the terms of
15  * the GNU General Public License Version 2. See the LICENSE file
16  * at the top of the source tree.
17  */
18 
19 /*** MODULEINFO
20  <depend>pjproject</depend>
21  <depend>res_pjsip</depend>
22  <depend>res_pjsip_session</depend>
23  <support_level>core</support_level>
24  ***/
25 
26 #include "asterisk.h"
27 
28 #include <pjsip.h>
29 #include <pjsip_ua.h>
30 
31 #include "asterisk/res_pjsip.h"
33 #include "asterisk/module.h"
34 
36  struct pjsip_rx_data *rdata, int code)
37 {
38  pjsip_tx_data *tdata;
39  pjsip_dialog *dlg = session->inv_session->dlg;
40 
41  if (pjsip_dlg_create_response(dlg, rdata, code, NULL, &tdata) == PJ_SUCCESS) {
42  struct pjsip_transaction *tsx = pjsip_rdata_get_tsx(rdata);
43  pjsip_dlg_send_response(dlg, tsx, tdata);
44  }
45 }
46 
48  struct pjsip_rx_data *rdata)
49 {
50  if (!rdata->msg_info.ctype) {
51  /* Need to return 200 OK on empty body */
52  /* Some SBCs use empty INFO as a KEEPALIVE */
53  send_response(session, rdata, 200);
54  return 1;
55  }
56 
57  /* Let another module respond */
58  return 0;
59 
60 }
61 
63  .method = "INFO",
65  .incoming_request = empty_info_incoming_request,
66 };
67 
68 static int load_module(void)
69 {
70  ast_sip_session_register_supplement(&empty_info_supplement);
72 }
73 
74 static int unload_module(void)
75 {
76  ast_sip_session_unregister_supplement(&empty_info_supplement);
77  return 0;
78 }
79 
80 AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "PJSIP Empty INFO Support",
81  .support_level = AST_MODULE_SUPPORT_CORE,
82  .load = load_module,
83  .unload = unload_module,
84  .load_pri = AST_MODPRI_APP_DEPEND,
85  .requires = "res_pjsip,res_pjsip_session",
86 );
Asterisk main include file. File version handling, generic pbx functions.
static int unload_module(void)
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
#define NULL
Definition: resample.c:96
struct pjsip_inv_session * inv_session
A structure describing a SIP session.
static struct ast_mansession session
static void send_response(struct ast_sip_session *session, struct pjsip_rx_data *rdata, int code)
static int load_module(void)
static struct ast_sip_session_supplement empty_info_supplement
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",)
A supplement to SIP message processing.
static int empty_info_incoming_request(struct ast_sip_session *session, struct pjsip_rx_data *rdata)
#define ASTERISK_GPL_KEY
The text the key() function should return.
Definition: module.h:46
Asterisk module definitions.
#define ast_sip_session_register_supplement(supplement)