Asterisk - The Open Source Telephony Project  18.5.0
Data Structures | Macros | Typedefs | Enumerations | Functions | Variables
res_pjsip_notify.c File Reference
#include "asterisk.h"
#include <pjsip.h>
#include <pjsip_ua.h>
#include "asterisk/cli.h"
#include "asterisk/config.h"
#include "asterisk/manager.h"
#include "asterisk/module.h"
#include "asterisk/pbx.h"
#include "asterisk/res_pjsip.h"
#include "asterisk/res_pjsip_session.h"
#include "asterisk/sorcery.h"
Include dependency graph for res_pjsip_notify.c:

Go to the source code of this file.

Data Structures

struct  notify_cfg
 
struct  notify_channel_data
 
struct  notify_data
 
struct  notify_option
 
struct  notify_option_item
 
struct  notify_uri_data
 

Macros

#define CONTENT_SIZE   512
 
#define CONTENT_TYPE_SIZE   64
 

Typedefs

typedef struct notify_channel_data *(* task_channel_data_create) (struct ast_sip_session *session, void *info)
 
typedef struct notify_data *(* task_data_create) (struct ast_sip_endpoint *, void *info)
 
typedef struct notify_uri_data *(* task_uri_data_create) (const char *uri, void *info)
 

Enumerations

enum  notify_result {
  SUCCESS, INVALID_ENDPOINT, INVALID_CHANNEL, ALLOC_ERROR,
  TASK_PUSH_ERROR
}
 

Functions

static void __reg_module (void)
 
static void __unreg_module (void)
 
 AO2_GLOBAL_OBJ_STATIC (globals)
 
struct ast_moduleAST_MODULE_SELF_SYM (void)
 
static void build_ami_notify (pjsip_tx_data *tdata, void *info)
 
static void build_cli_notify (pjsip_tx_data *tdata, void *info)
 
static void build_notify (pjsip_tx_data *tdata, const char *name, const char *value, struct ast_str **content_type, struct ast_str **content)
 
static void build_notify_body (pjsip_tx_data *tdata, struct ast_str *content_type, struct ast_str *content)
 
static char * cli_complete_endpoint (const char *word)
 
static char * cli_complete_notify (const char *line, const char *word, int pos, int state, int using_uri)
 
static char * cli_notify (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 
 CONFIG_INFO_STANDARD (notify_cfg, globals, notify_cfg_alloc,.files=ACO_FILES(&module_conf))
 
static int load_module (void)
 
static int manager_notify (struct mansession *s, const struct message *m)
 
static void manager_notify_channel (struct mansession *s, const struct message *m, const char *channel)
 
static void manager_notify_endpoint (struct mansession *s, const struct message *m, const char *endpoint_name)
 Completes SIPNotify AMI command in Endpoint mode. More...
 
static void manager_notify_uri (struct mansession *s, const struct message *m, const char *uri)
 
static int multiple_headers_allowed (const char *name)
 
static int not_allowed (const char *name)
 
static struct notify_channel_datanotify_ami_channel_data_create (struct ast_sip_session *session, void *info)
 
static void notify_ami_channel_data_destroy (void *obj)
 
static struct notify_datanotify_ami_data_create (struct ast_sip_endpoint *endpoint, void *info)
 
static void notify_ami_data_destroy (void *obj)
 
static struct notify_uri_datanotify_ami_uri_data_create (const char *uri, void *info)
 
static void notify_ami_uri_data_destroy (void *obj)
 
static void * notify_cfg_alloc (void)
 
static void notify_cfg_destroy (void *obj)
 
static int notify_channel (void *obj)
 
static struct notify_datanotify_cli_data_create (struct ast_sip_endpoint *endpoint, void *info)
 
static void notify_cli_data_destroy (void *obj)
 
static struct notify_uri_datanotify_cli_uri_data_create (const char *uri, void *info)
 
static void notify_cli_uri_data_destroy (void *obj)
 
static int notify_contact (void *obj, void *arg, int flags)
 
static int notify_endpoint (void *obj)
 
static void * notify_option_alloc (const char *category)
 
static int notify_option_cmp (void *obj, void *arg, int flags)
 
static void notify_option_destroy (void *obj)
 
static void * notify_option_find (struct ao2_container *container, const char *category)
 
static int notify_option_handler (const struct aco_option *opt, struct ast_variable *var, void *obj)
 
static int notify_option_hash (const void *obj, int flags)
 
static int notify_uri (void *obj)
 
static enum notify_result push_notify (const char *endpoint_name, void *info, task_data_create data_create)
 
static enum notify_result push_notify_channel (const char *channel_name, void *info, task_channel_data_create data_create)
 
static enum notify_result push_notify_uri (const char *uri, void *info, task_uri_data_create data_create)
 
static int reload_module (void)
 
static int unload_module (void)
 

Variables

static struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "CLI/AMI PJSIP NOTIFY 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, .reload = reload_module, .unload = unload_module, .load_pri = AST_MODPRI_APP_DEPEND, .requires = "res_pjsip", }
 
static const struct ast_module_infoast_module_info = &__mod_info
 
static struct ast_cli_entry cli_options []
 
static struct aco_file module_conf
 
static const char notify_config [] = "pjsip_notify.conf"
 
static struct aco_type notify_option
 
static struct aco_typenotify_options [] = ACO_TYPES(&notify_option)
 

Macro Definition Documentation

◆ CONTENT_SIZE

#define CONTENT_SIZE   512

Definition at line 116 of file res_pjsip_notify.c.

Referenced by build_notify().

◆ CONTENT_TYPE_SIZE

#define CONTENT_TYPE_SIZE   64

Definition at line 115 of file res_pjsip_notify.c.

Referenced by build_notify().

Typedef Documentation

◆ task_channel_data_create

typedef struct notify_channel_data*(* task_channel_data_create) (struct ast_sip_session *session, void *info)

Definition at line 796 of file res_pjsip_notify.c.

◆ task_data_create

typedef struct notify_data*(* task_data_create) (struct ast_sip_endpoint *, void *info)

Definition at line 790 of file res_pjsip_notify.c.

◆ task_uri_data_create

typedef struct notify_uri_data*(* task_uri_data_create) (const char *uri, void *info)

Definition at line 793 of file res_pjsip_notify.c.

Enumeration Type Documentation

◆ notify_result

Enumerator
SUCCESS 
INVALID_ENDPOINT 
INVALID_CHANNEL 
ALLOC_ERROR 
TASK_PUSH_ERROR 

Definition at line 782 of file res_pjsip_notify.c.

Function Documentation

◆ __reg_module()

static void __reg_module ( void  )
static

Definition at line 1264 of file res_pjsip_notify.c.

◆ __unreg_module()

static void __unreg_module ( void  )
static

Definition at line 1264 of file res_pjsip_notify.c.

◆ AO2_GLOBAL_OBJ_STATIC()

AO2_GLOBAL_OBJ_STATIC ( globals  )

◆ AST_MODULE_SELF_SYM()

struct ast_module* AST_MODULE_SELF_SYM ( void  )

Definition at line 1264 of file res_pjsip_notify.c.

◆ build_ami_notify()

static void build_ami_notify ( pjsip_tx_data *  tdata,
void *  info 
)
static

Definition at line 622 of file res_pjsip_notify.c.

References ast_free, ast_log, build_notify(), build_notify_body(), sip_to_pjsip::info(), LOG_NOTICE, ast_variable::name, ast_variable::next, NULL, RAII_VAR, and ast_variable::value.

Referenced by notify_ami_channel_data_create(), notify_ami_channel_data_destroy(), notify_ami_data_create(), and notify_ami_uri_data_create().

623 {
624  struct ast_variable *vars = info;
625  RAII_VAR(struct ast_str *, content_type, NULL, ast_free);
626  RAII_VAR(struct ast_str *, content, NULL, ast_free);
627  struct ast_variable *i;
628 
629  for (i = vars; i; i = i->next) {
630  if (!strcasecmp(i->name, "Content-Length")) {
631  ast_log(LOG_NOTICE, "It is not necessary to specify Content-Length, ignoring.\n");
632  continue;
633  }
634  build_notify(tdata, i->name, i->value,
635  &content_type, &content);
636  }
637 
638  build_notify_body(tdata, content_type, content);
639 }
struct ast_variable * next
static void build_notify_body(pjsip_tx_data *tdata, struct ast_str *content_type, struct ast_str *content)
Structure for variables, used for configurations and for channel variables.
#define NULL
Definition: resample.c:96
static void build_notify(pjsip_tx_data *tdata, const char *name, const char *value, struct ast_str **content_type, struct ast_str **content)
#define ast_log
Definition: astobj2.c:42
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
Definition: utils.h:911
The descriptor of a dynamic string XXX storage will be optimized later if needed We use the ts field ...
Definition: strings.h:584
def info(msg)
#define LOG_NOTICE
Definition: logger.h:263
#define ast_free(a)
Definition: astmm.h:182

◆ build_cli_notify()

static void build_cli_notify ( pjsip_tx_data *  tdata,
void *  info 
)
static

Definition at line 598 of file res_pjsip_notify.c.

References ao2_cleanup, ao2_iterator_destroy(), ao2_iterator_init(), ao2_iterator_next, ast_free, build_notify(), build_notify_body(), sip_to_pjsip::info(), item, notify_option::items, notify_option_item::name, NULL, RAII_VAR, and notify_option_item::value.

Referenced by notify_cli_data_create(), notify_cli_uri_data_create(), and notify_cli_uri_data_destroy().

599 {
600  struct notify_option *option = info;
601  RAII_VAR(struct ast_str *, content_type, NULL, ast_free);
602  RAII_VAR(struct ast_str *, content, NULL, ast_free);
603 
604  struct notify_option_item *item;
605  struct ao2_iterator i = ao2_iterator_init(option->items, 0);
606 
607  while ((item = ao2_iterator_next(&i))) {
608  build_notify(tdata, item->name, item->value,
609  &content_type, &content);
610  ao2_cleanup(item);
611  }
613 
614  build_notify_body(tdata, content_type, content);
615 }
static void build_notify_body(pjsip_tx_data *tdata, struct ast_str *content_type, struct ast_str *content)
struct ao2_container * items
static struct aco_type item
Definition: test_config.c:1463
void ao2_iterator_destroy(struct ao2_iterator *iter)
Destroy a container iterator.
#define NULL
Definition: resample.c:96
static void build_notify(pjsip_tx_data *tdata, const char *name, const char *value, struct ast_str **content_type, struct ast_str **content)
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
Definition: utils.h:911
The descriptor of a dynamic string XXX storage will be optimized later if needed We use the ts field ...
Definition: strings.h:584
def info(msg)
#define ao2_iterator_next(iter)
Definition: astobj2.h:1933
#define ast_free(a)
Definition: astmm.h:182
When we need to walk through a container, we use an ao2_iterator to keep track of the current positio...
Definition: astobj2.h:1841
#define ao2_cleanup(obj)
Definition: astobj2.h:1958
struct ao2_iterator ao2_iterator_init(struct ao2_container *c, int flags) attribute_warn_unused_result
Create an iterator for a container.

◆ build_notify()

static void build_notify ( pjsip_tx_data *  tdata,
const char *  name,
const char *  value,
struct ast_str **  content_type,
struct ast_str **  content 
)
static

Definition at line 553 of file res_pjsip_notify.c.

References ast_log, ast_sip_add_header(), ast_str_append(), ast_str_create, ast_str_set(), ast_str_strlen(), CONTENT_SIZE, CONTENT_TYPE_SIZE, LOG_ERROR, LOG_WARNING, multiple_headers_allowed(), not_allowed(), and NULL.

Referenced by build_ami_notify(), and build_cli_notify().

555 {
556  if (not_allowed(name)) {
557  ast_log(LOG_WARNING, "Cannot specify %s header, "
558  "ignoring\n", name);
559  return;
560  }
561 
562  if (!strcasecmp(name, "Content-type")) {
563  if (!(*content_type)) {
564  *content_type = ast_str_create(CONTENT_TYPE_SIZE);
565  }
566  ast_str_set(content_type, 0,"%s", value);
567  } else if (!strcasecmp(name, "Content")) {
568  if (!(*content)) {
569  *content = ast_str_create(CONTENT_SIZE);
570  }
571 
572  if (ast_str_strlen(*content)) {
573  ast_str_append(content, 0, "\r\n");
574  }
575  ast_str_append(content, 0, "%s", value);
576  } else {
577  /* See if there is an existing one */
579  pj_str_t hdr_name;
580  pj_cstr(&hdr_name, name);
581 
582  if (pjsip_msg_find_hdr_by_name(tdata->msg, &hdr_name, NULL)) {
583  ast_log(LOG_ERROR, "Only one '%s' header can be added to a NOTIFY, "
584  "ignoring \"%s: %s\"\n", name, name, value);
585  return;
586  }
587  }
588 
589  ast_sip_add_header(tdata, name, value);
590  }
591 }
static int not_allowed(const char *name)
static int multiple_headers_allowed(const char *name)
#define LOG_WARNING
Definition: logger.h:274
#define CONTENT_TYPE_SIZE
int ast_str_append(struct ast_str **buf, ssize_t max_len, const char *fmt,...)
Append to a thread local dynamic string.
Definition: strings.h:1091
#define NULL
Definition: resample.c:96
int value
Definition: syslog.c:37
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:5063
int ast_str_set(struct ast_str **buf, ssize_t max_len, const char *fmt,...)
Set a dynamic string using variable arguments.
Definition: strings.h:1065
#define ast_log
Definition: astobj2.c:42
#define LOG_ERROR
Definition: logger.h:285
#define CONTENT_SIZE
static const char name[]
Definition: cdr_mysql.c:74
size_t ast_str_strlen(const struct ast_str *buf)
Returns the current length of the string stored within buf.
Definition: strings.h:688
#define ast_str_create(init_len)
Create a malloc&#39;ed dynamic length string.
Definition: strings.h:620

◆ build_notify_body()

static void build_notify_body ( pjsip_tx_data *  tdata,
struct ast_str content_type,
struct ast_str content 
)
static

Definition at line 529 of file res_pjsip_notify.c.

References ast_sip_add_body(), ast_str_buffer(), ast_sip_body::body_text, ast_sip_body::subtype, and ast_sip_body::type.

Referenced by build_ami_notify(), and build_cli_notify().

531 {
532  if (content_type) {
533  char *p;
534  struct ast_sip_body body;
535 
536  if (content) {
537  body.body_text = ast_str_buffer(content);
538  }
539 
540  body.type = ast_str_buffer(content_type);
541  if ((p = strchr(body.type, '/'))) {
542  *p++ = '\0';
543  body.subtype = p;
544  }
545  ast_sip_add_body(tdata, &body);
546  }
547 }
const char * body_text
Definition: res_pjsip.h:2033
char * ast_str_buffer(const struct ast_str *buf)
Returns the string buffer within the ast_str buf.
Definition: strings.h:714
int ast_sip_add_body(pjsip_tx_data *tdata, const struct ast_sip_body *body)
Add a body to an outbound SIP message.
Definition: res_pjsip.c:5091
SIP body description.
Definition: res_pjsip.h:2027

◆ cli_complete_endpoint()

static char* cli_complete_endpoint ( const char *  word)
static

Definition at line 913 of file res_pjsip_notify.c.

References ao2_cleanup, ao2_iterator_destroy(), ao2_iterator_init(), ao2_iterator_next, ao2_ref, ast_cli_completion_add(), ast_sip_get_sorcery(), ast_sorcery_object_get_id(), ast_sorcery_retrieve_by_prefix(), ast_strdup, endpoints, and NULL.

Referenced by cli_complete_notify().

914 {
915  int wordlen = strlen(word);
916  struct ao2_container * endpoints;
917  struct ast_sip_endpoint *endpoint;
918  struct ao2_iterator i;
919 
921  "endpoint", word, wordlen);
922  if (endpoints == NULL) {
923  return NULL;
924  }
925 
926  i = ao2_iterator_init(endpoints, 0);
927  while ((endpoint = ao2_iterator_next(&i))) {
930  ao2_cleanup(endpoint);
931  }
933 
934  ao2_ref(endpoints, -1);
935 
936  return NULL;
937 }
void ao2_iterator_destroy(struct ao2_iterator *iter)
Destroy a container iterator.
#define ast_strdup(str)
A wrapper for strdup()
Definition: astmm.h:243
struct ao2_container * ast_sorcery_retrieve_by_prefix(const struct ast_sorcery *sorcery, const char *type, const char *prefix, const size_t prefix_len)
Retrieve multiple objects whose id begins with the specified prefix.
Definition: sorcery.c:1984
#define NULL
Definition: resample.c:96
static struct ao2_container * endpoints
#define ao2_ref(o, delta)
Definition: astobj2.h:464
const char * ast_sorcery_object_get_id(const void *object)
Get the unique identifier of a sorcery object.
Definition: sorcery.c:2312
An entity with which Asterisk communicates.
Definition: res_pjsip.h:812
#define ao2_iterator_next(iter)
Definition: astobj2.h:1933
struct ast_sorcery * ast_sip_get_sorcery(void)
Get a pointer to the SIP sorcery structure.
When we need to walk through a container, we use an ao2_iterator to keep track of the current positio...
Definition: astobj2.h:1841
#define ao2_cleanup(obj)
Definition: astobj2.h:1958
Generic container type.
int ast_cli_completion_add(char *value)
Add a result to a request for completion options.
Definition: main/cli.c:2726
struct ao2_iterator ao2_iterator_init(struct ao2_container *c, int flags) attribute_warn_unused_result
Create an iterator for a container.
short word

◆ cli_complete_notify()

static char* cli_complete_notify ( const char *  line,
const char *  word,
int  pos,
int  state,
int  using_uri 
)
static

Definition at line 943 of file res_pjsip_notify.c.

References ao2_cleanup, ao2_global_obj_ref, ao2_iterator_destroy(), ao2_iterator_init(), ao2_iterator_next, ast_strdup, ast_strlen_zero, c, cli_complete_endpoint(), globals, notify_option::name, NULL, and RAII_VAR.

Referenced by cli_notify().

945 {
946  char *c = NULL;
947 
948  if (pos == 3) {
949  int which = 0;
950  int wordlen = strlen(word);
951 
952  RAII_VAR(struct notify_cfg *, cfg,
954  struct notify_option *option;
955 
956  /* do completion for notify type */
957  struct ao2_iterator i = ao2_iterator_init(cfg->notify_options, 0);
958  while ((option = ao2_iterator_next(&i))) {
959  if (!strncasecmp(word, option->name, wordlen) && ++which > state) {
960  c = ast_strdup(option->name);
961  }
962 
963  ao2_cleanup(option);
964  if (c) {
965  break;
966  }
967  }
969  return c;
970  }
971 
972  if (pos == 4) {
973  int wordlen = strlen(word);
974 
975  if (ast_strlen_zero(word)) {
976  if (state == 0) {
977  c = ast_strdup("endpoint");
978  } else if (state == 1) {
979  c = ast_strdup("uri");
980  }
981  } else if (state == 0) {
982  if (!strncasecmp(word, "endpoint", wordlen)) {
983  c = ast_strdup("endpoint");
984  } else if (!strncasecmp(word, "uri", wordlen)) {
985  c = ast_strdup("uri");
986  }
987  }
988 
989  return c;
990  }
991 
992  return pos > 4 && !using_uri ? cli_complete_endpoint(word) : NULL;
993 }
#define ao2_global_obj_ref(holder)
Definition: astobj2.h:925
void ao2_iterator_destroy(struct ao2_iterator *iter)
Destroy a container iterator.
static struct test_val c
#define ast_strdup(str)
A wrapper for strdup()
Definition: astmm.h:243
#define NULL
Definition: resample.c:96
#define ast_strlen_zero(foo)
Definition: strings.h:52
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
Definition: utils.h:911
static struct console_pvt globals
#define ao2_iterator_next(iter)
Definition: astobj2.h:1933
When we need to walk through a container, we use an ao2_iterator to keep track of the current positio...
Definition: astobj2.h:1841
#define ao2_cleanup(obj)
Definition: astobj2.h:1958
static char * cli_complete_endpoint(const char *word)
struct ao2_iterator ao2_iterator_init(struct ao2_container *c, int flags) attribute_warn_unused_result
Create an iterator for a container.
short word

◆ cli_notify()

static char* cli_notify ( struct ast_cli_entry e,
int  cmd,
struct ast_cli_args a 
)
static

Definition at line 1003 of file res_pjsip_notify.c.

References ALLOC_ERROR, ao2_cleanup, ao2_global_obj_ref, ast_cli_args::argc, ast_cli_args::argv, ast_cli(), cli_complete_notify(), CLI_FAILURE, CLI_GENERATE, CLI_INIT, CLI_SHOWUSAGE, CLI_SUCCESS, ast_cli_entry::command, ast_cli_args::fd, globals, INVALID_ENDPOINT, ast_cli_args::line, ast_cli_args::n, notify_cli_data_create(), notify_cli_uri_data_create(), notify_option_find(), NULL, ast_cli_args::pos, push_notify(), push_notify_uri(), RAII_VAR, TASK_PUSH_ERROR, ast_cli_entry::usage, and ast_cli_args::word.

1004 {
1005  RAII_VAR(struct notify_cfg *, cfg, NULL, ao2_cleanup);
1006  RAII_VAR(struct notify_option *, option, NULL, ao2_cleanup);
1007 
1008  int i;
1009  int using_uri = 0;
1010 
1011  switch (cmd) {
1012  case CLI_INIT:
1013  e->command = "pjsip send notify";
1014  e->usage =
1015  "Usage: pjsip send notify <type> {endpoint|uri} <peer> [<peer>...]\n"
1016  " Send a NOTIFY request to an endpoint\n"
1017  " Message types are defined in pjsip_notify.conf\n";
1018  return NULL;
1019  case CLI_GENERATE:
1020  if (a->argc > 4 && (!strcasecmp(a->argv[4], "uri"))) {
1021  using_uri = 1;
1022  }
1023 
1024  return cli_complete_notify(a->line, a->word, a->pos, a->n, using_uri);
1025  }
1026 
1027  if (a->argc < 6) {
1028  return CLI_SHOWUSAGE;
1029  }
1030 
1031  if (!strcasecmp(a->argv[4], "uri")) {
1032  using_uri = 1;
1033  } else if (strcasecmp(a->argv[4], "endpoint")) {
1034  return CLI_SHOWUSAGE;
1035  }
1036 
1037  cfg = ao2_global_obj_ref(globals);
1038 
1039  if (!(option = notify_option_find(cfg->notify_options, a->argv[3])))
1040  {
1041  ast_cli(a->fd, "Unable to find notify type '%s'\n",
1042  a->argv[3]);
1043  return CLI_FAILURE;
1044  }
1045 
1046  for (i = 5; i < a->argc; ++i) {
1047  ast_cli(a->fd, "Sending NOTIFY of type '%s' to '%s'\n",
1048  a->argv[3], a->argv[i]);
1049 
1050  switch (using_uri ? push_notify_uri(a->argv[i], option, notify_cli_uri_data_create) :
1051  push_notify(a->argv[i], option, notify_cli_data_create)) {
1052  case INVALID_ENDPOINT:
1053  ast_cli(a->fd, "Unable to retrieve endpoint %s\n",
1054  a->argv[i]);
1055  break;
1056  case ALLOC_ERROR:
1057  ast_cli(a->fd, "Unable to allocate NOTIFY task data\n");
1058  return CLI_FAILURE;
1059  case TASK_PUSH_ERROR:
1060  ast_cli(a->fd, "Unable to push NOTIFY task\n");
1061  return CLI_FAILURE;
1062  default:
1063  break;
1064  }
1065  }
1066 
1067  return CLI_SUCCESS;
1068 }
static char * cli_complete_notify(const char *line, const char *word, int pos, int state, int using_uri)
const int argc
Definition: cli.h:160
Definition: cli.h:152
#define ao2_global_obj_ref(holder)
Definition: astobj2.h:925
#define NULL
Definition: resample.c:96
void ast_cli(int fd, const char *fmt,...)
Definition: clicompat.c:6
static struct notify_data * notify_cli_data_create(struct ast_sip_endpoint *endpoint, void *info)
const char * line
Definition: cli.h:162
static struct notify_uri_data * notify_cli_uri_data_create(const char *uri, void *info)
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
Definition: utils.h:911
const int fd
Definition: cli.h:159
const int n
Definition: cli.h:165
static struct console_pvt globals
const char *const * argv
Definition: cli.h:161
static enum notify_result push_notify(const char *endpoint_name, void *info, task_data_create data_create)
#define CLI_SHOWUSAGE
Definition: cli.h:45
static enum notify_result push_notify_uri(const char *uri, void *info, task_uri_data_create data_create)
static void * notify_option_find(struct ao2_container *container, const char *category)
#define CLI_FAILURE
Definition: cli.h:46
char * command
Definition: cli.h:186
const char * word
Definition: cli.h:163
const char * usage
Definition: cli.h:177
#define CLI_SUCCESS
Definition: cli.h:44
#define ao2_cleanup(obj)
Definition: astobj2.h:1958
const int pos
Definition: cli.h:164

◆ CONFIG_INFO_STANDARD()

CONFIG_INFO_STANDARD ( notify_cfg  ,
globals  ,
notify_cfg_alloc  ,
files = ACO_FILES(&module_conf) 
)

◆ load_module()

static int load_module ( void  )
static

Definition at line 1218 of file res_pjsip_notify.c.

References aco_info_destroy(), aco_info_init(), aco_option_register_custom, ACO_PREFIX, aco_process_config(), ARRAY_LEN, ast_cli_register_multiple, ast_manager_register_xml, AST_MODULE_LOAD_DECLINE, AST_MODULE_LOAD_SUCCESS, EVENT_FLAG_SYSTEM, manager_notify(), and notify_option_handler().

Referenced by unload_module().

1219 {
1220  if (aco_info_init(&notify_cfg)) {
1221  return AST_MODULE_LOAD_DECLINE;
1222  }
1223 
1225  "", notify_option_handler, 0);
1226 
1227  if (aco_process_config(&notify_cfg, 0)) {
1229  return AST_MODULE_LOAD_DECLINE;
1230  }
1231 
1234 
1235  return AST_MODULE_LOAD_SUCCESS;
1236 }
#define ARRAY_LEN(a)
Definition: isdn_lib.c:42
#define aco_option_register_custom(info, name, matchtype, types, default_val, handler, flags)
Register a config option.
#define ast_cli_register_multiple(e, len)
Register multiple commands.
Definition: cli.h:265
enum aco_process_status aco_process_config(struct aco_info *info, int reload)
Process a config info via the options registered with an aco_info.
static struct ast_cli_entry cli_options[]
#define EVENT_FLAG_SYSTEM
Definition: manager.h:71
static struct aco_type * notify_options[]
int aco_info_init(struct aco_info *info)
Initialize an aco_info structure.
void aco_info_destroy(struct aco_info *info)
Destroy an initialized aco_info struct.
Module has failed to load, may be in an inconsistent state.
Definition: module.h:78
static int manager_notify(struct mansession *s, const struct message *m)
static int notify_option_handler(const struct aco_option *opt, struct ast_variable *var, void *obj)
#define ast_manager_register_xml(action, authority, func)
Register a manager callback using XML documentation to describe the manager.
Definition: manager.h:186

◆ manager_notify()

static int manager_notify ( struct mansession s,
const struct message m 
)
static

Definition at line 1183 of file res_pjsip_notify.c.

References ast_strlen_zero, astman_get_header(), astman_send_error(), manager_notify_channel(), manager_notify_endpoint(), and manager_notify_uri().

Referenced by load_module().

1184 {
1185  const char *endpoint_name = astman_get_header(m, "Endpoint");
1186  const char *uri = astman_get_header(m, "URI");
1187  const char *channel = astman_get_header(m, "Channel");
1188  int count = 0;
1189 
1190  if (!ast_strlen_zero(endpoint_name)) {
1191  ++count;
1192  }
1193  if (!ast_strlen_zero(uri)) {
1194  ++count;
1195  }
1196  if (!ast_strlen_zero(channel)) {
1197  ++count;
1198  }
1199 
1200  if (1 < count) {
1201  astman_send_error(s, m,
1202  "PJSIPNotify requires either an endpoint name, a SIP URI, or a channel. "
1203  "You must use only one of them.");
1204  } else if (!ast_strlen_zero(endpoint_name)) {
1205  manager_notify_endpoint(s, m, endpoint_name);
1206  } else if (!ast_strlen_zero(uri)) {
1207  manager_notify_uri(s, m, uri);
1208  } else if (!ast_strlen_zero(channel)) {
1209  manager_notify_channel(s, m, channel);
1210  } else {
1211  astman_send_error(s, m,
1212  "PJSIPNotify requires either an endpoint name, a SIP URI, or a channel.");
1213  }
1214 
1215  return 0;
1216 }
static void manager_notify_endpoint(struct mansession *s, const struct message *m, const char *endpoint_name)
Completes SIPNotify AMI command in Endpoint mode.
Definition: muted.c:95
const char * astman_get_header(const struct message *m, char *var)
Get header from mananger transaction.
Definition: manager.c:2820
#define ast_strlen_zero(foo)
Definition: strings.h:52
static void manager_notify_channel(struct mansession *s, const struct message *m, const char *channel)
static void manager_notify_uri(struct mansession *s, const struct message *m, const char *uri)
void astman_send_error(struct mansession *s, const struct message *m, char *error)
Send error in manager transaction.
Definition: manager.c:3159

◆ manager_notify_channel()

static void manager_notify_channel ( struct mansession s,
const struct message m,
const char *  channel 
)
static

Definition at line 1151 of file res_pjsip_notify.c.

References ALLOC_ERROR, ast_assert, ast_variables_destroy(), astman_get_variables_order(), astman_send_ack(), astman_send_error(), INVALID_CHANNEL, INVALID_ENDPOINT, notify_ami_channel_data_create(), ORDER_NATURAL, push_notify_channel(), SUCCESS, and TASK_PUSH_ERROR.

Referenced by manager_notify().

1153 {
1155 
1157  case INVALID_CHANNEL:
1158  ast_variables_destroy(vars);
1159  astman_send_error(s, m, "Channel not found");
1160  break;
1161  case INVALID_ENDPOINT:
1162  /* Shouldn't be possible. */
1163  ast_assert(0);
1164  break;
1165  case ALLOC_ERROR:
1166  ast_variables_destroy(vars);
1167  astman_send_error(s, m, "Unable to allocate NOTIFY task data");
1168  break;
1169  case TASK_PUSH_ERROR:
1170  /* Don't need to destroy vars since it is handled by cleanup in push_notify_channel */
1171  astman_send_error(s, m, "Unable to push Notify task");
1172  break;
1173  case SUCCESS:
1174  astman_send_ack(s, m, "NOTIFY sent");
1175  break;
1176  }
1177 }
void ast_variables_destroy(struct ast_variable *var)
Free variable list.
Definition: extconf.c:1263
Structure for variables, used for configurations and for channel variables.
#define ast_assert(a)
Definition: utils.h:695
void astman_send_ack(struct mansession *s, const struct message *m, char *msg)
Send ack in manager transaction.
Definition: manager.c:3191
Definition: muted.c:95
struct ast_variable * astman_get_variables_order(const struct message *m, enum variable_orders order)
Get a linked list of the Variable: headers with order specified.
Definition: manager.c:2911
static enum notify_result push_notify_channel(const char *channel_name, void *info, task_channel_data_create data_create)
static struct notify_channel_data * notify_ami_channel_data_create(struct ast_sip_session *session, void *info)
void astman_send_error(struct mansession *s, const struct message *m, char *error)
Send error in manager transaction.
Definition: manager.c:3159

◆ manager_notify_endpoint()

static void manager_notify_endpoint ( struct mansession s,
const struct message m,
const char *  endpoint_name 
)
static

Completes SIPNotify AMI command in Endpoint mode.

Definition at line 1078 of file res_pjsip_notify.c.

References ALLOC_ERROR, ast_assert, ast_variables_destroy(), astman_get_variables_order(), astman_send_ack(), astman_send_error(), astman_send_error_va(), INVALID_CHANNEL, INVALID_ENDPOINT, notify_ami_data_create(), ORDER_NATURAL, push_notify(), SUCCESS, and TASK_PUSH_ERROR.

Referenced by manager_notify().

1080 {
1082 
1083  if (!strncasecmp(endpoint_name, "sip/", 4)) {
1084  endpoint_name += 4;
1085  }
1086 
1087  if (!strncasecmp(endpoint_name, "pjsip/", 6)) {
1088  endpoint_name += 6;
1089  }
1090 
1091  switch (push_notify(endpoint_name, vars, notify_ami_data_create)) {
1092  case INVALID_CHANNEL:
1093  /* Shouldn't be possible. */
1094  ast_assert(0);
1095  break;
1096  case INVALID_ENDPOINT:
1097  ast_variables_destroy(vars);
1098  astman_send_error_va(s, m, "Unable to retrieve endpoint %s",
1099  endpoint_name);
1100  break;
1101  case ALLOC_ERROR:
1102  ast_variables_destroy(vars);
1103  astman_send_error(s, m, "Unable to allocate NOTIFY task data");
1104  break;
1105  case TASK_PUSH_ERROR:
1106  /* Don't need to destroy vars since it is handled by cleanup in push_notify */
1107  astman_send_error(s, m, "Unable to push NOTIFY task");
1108  break;
1109  case SUCCESS:
1110  astman_send_ack(s, m, "NOTIFY sent");
1111  break;
1112  }
1113 }
void ast_variables_destroy(struct ast_variable *var)
Free variable list.
Definition: extconf.c:1263
Structure for variables, used for configurations and for channel variables.
#define ast_assert(a)
Definition: utils.h:695
void astman_send_ack(struct mansession *s, const struct message *m, char *msg)
Send ack in manager transaction.
Definition: manager.c:3191
void astman_send_error_va(struct mansession *s, const struct message *m, const char *fmt,...)
Send error in manager transaction (with va_args support)
Definition: manager.c:3164
static enum notify_result push_notify(const char *endpoint_name, void *info, task_data_create data_create)
struct ast_variable * astman_get_variables_order(const struct message *m, enum variable_orders order)
Get a linked list of the Variable: headers with order specified.
Definition: manager.c:2911
static struct notify_data * notify_ami_data_create(struct ast_sip_endpoint *endpoint, void *info)
void astman_send_error(struct mansession *s, const struct message *m, char *error)
Send error in manager transaction.
Definition: manager.c:3159

◆ manager_notify_uri()

static void manager_notify_uri ( struct mansession s,
const struct message m,
const char *  uri 
)
static

Definition at line 1119 of file res_pjsip_notify.c.

References ALLOC_ERROR, ast_assert, ast_variables_destroy(), astman_get_variables_order(), astman_send_ack(), astman_send_error(), INVALID_CHANNEL, INVALID_ENDPOINT, notify_ami_uri_data_create(), ORDER_NATURAL, push_notify_uri(), SUCCESS, and TASK_PUSH_ERROR.

Referenced by manager_notify().

1121 {
1123 
1124  switch (push_notify_uri(uri, vars, notify_ami_uri_data_create)) {
1125  case INVALID_CHANNEL:
1126  /* Shouldn't be possible. */
1127  ast_assert(0);
1128  break;
1129  case INVALID_ENDPOINT:
1130  /* Shouldn't be possible. */
1131  ast_assert(0);
1132  break;
1133  case ALLOC_ERROR:
1134  ast_variables_destroy(vars);
1135  astman_send_error(s, m, "Unable to allocate NOTIFY task data");
1136  break;
1137  case TASK_PUSH_ERROR:
1138  /* Don't need to destroy vars since it is handled by cleanup in push_notify_uri */
1139  astman_send_error(s, m, "Unable to push Notify task");
1140  break;
1141  case SUCCESS:
1142  astman_send_ack(s, m, "NOTIFY sent");
1143  break;
1144  }
1145 }
void ast_variables_destroy(struct ast_variable *var)
Free variable list.
Definition: extconf.c:1263
Structure for variables, used for configurations and for channel variables.
#define ast_assert(a)
Definition: utils.h:695
void astman_send_ack(struct mansession *s, const struct message *m, char *msg)
Send ack in manager transaction.
Definition: manager.c:3191
static enum notify_result push_notify_uri(const char *uri, void *info, task_uri_data_create data_create)
struct ast_variable * astman_get_variables_order(const struct message *m, enum variable_orders order)
Get a linked list of the Variable: headers with order specified.
Definition: manager.c:2911
void astman_send_error(struct mansession *s, const struct message *m, char *error)
Send error in manager transaction.
Definition: manager.c:3159
static struct notify_uri_data * notify_ami_uri_data_create(const char *uri, void *info)

◆ multiple_headers_allowed()

static int multiple_headers_allowed ( const char *  name)
static

Definition at line 518 of file res_pjsip_notify.c.

Referenced by build_notify().

519 {
520  /* This can be extended to include additional headers */
521  return strcasecmp("Event", name);
522 }
static const char name[]
Definition: cdr_mysql.c:74

◆ not_allowed()

static int not_allowed ( const char *  name)
static

Definition at line 491 of file res_pjsip_notify.c.

References ARRAY_LEN.

Referenced by build_notify().

492 {
493  int i;
494  static const char *names[] = {
495  "Call-ID",
496  "Contact",
497  "CSeq",
498  "To",
499  "From",
500  "Record-Route",
501  "Route",
502  "Request-URI",
503  "Via",
504  };
505 
506  for (i = 0; i < ARRAY_LEN(names); ++i) {
507  if (!strcasecmp(name, names[i])) {
508  return 1;
509  }
510  }
511  return 0;
512 }
#define ARRAY_LEN(a)
Definition: isdn_lib.c:42
static const char name[]
Definition: cdr_mysql.c:74

◆ notify_ami_channel_data_create()

static struct notify_channel_data* notify_ami_channel_data_create ( struct ast_sip_session session,
void *  info 
)
static

Definition at line 465 of file res_pjsip_notify.c.

References AO2_ALLOC_OPT_LOCK_NOLOCK, ao2_alloc_options, build_ami_notify(), notify_channel_data::build_notify, notify_channel_data::info, sip_to_pjsip::info(), notify_ami_channel_data_destroy(), NULL, session, and notify_channel_data::session.

Referenced by manager_notify_channel().

467 {
468  struct notify_channel_data *data;
469 
472  if (!data) {
473  return NULL;
474  }
475 
476  data->session = session;
477  data->info = info;
479 
480  return data;
481 }
struct ast_sip_session * session
static void build_ami_notify(pjsip_tx_data *tdata, void *info)
#define ao2_alloc_options(data_size, destructor_fn, options)
Definition: astobj2.h:406
#define NULL
Definition: resample.c:96
static void notify_ami_channel_data_destroy(void *obj)
static struct ast_mansession session
void(* build_notify)(pjsip_tx_data *, void *)
def info(msg)

◆ notify_ami_channel_data_destroy()

static void notify_ami_channel_data_destroy ( void *  obj)
static

Definition at line 403 of file res_pjsip_notify.c.

References ao2_cleanup, ast_variables_destroy(), build_ami_notify(), notify_channel_data::info, sip_to_pjsip::info(), and notify_channel_data::session.

Referenced by notify_ami_channel_data_create().

404 {
405  struct notify_channel_data *data = obj;
406  struct ast_variable *info = data->info;
407 
408  ao2_cleanup(data->session);
409  ast_variables_destroy(info);
410 }
void ast_variables_destroy(struct ast_variable *var)
Free variable list.
Definition: extconf.c:1263
struct ast_sip_session * session
Structure for variables, used for configurations and for channel variables.
def info(msg)
#define ao2_cleanup(obj)
Definition: astobj2.h:1958

◆ notify_ami_data_create()

static struct notify_data* notify_ami_data_create ( struct ast_sip_endpoint endpoint,
void *  info 
)
static

Definition at line 418 of file res_pjsip_notify.c.

References ao2_alloc, ao2_ref, build_ami_notify(), notify_data::build_notify, notify_data::endpoint, notify_data::info, sip_to_pjsip::info(), notify_ami_data_destroy(), and NULL.

Referenced by manager_notify_endpoint().

420 {
421  struct notify_data *data = ao2_alloc(sizeof(*data),
423  if (!data) {
424  return NULL;
425  }
426 
427  data->endpoint = endpoint;
428  ao2_ref(data->endpoint, +1);
429 
430  data->info = info;
432 
433  return data;
434 }
static void build_ami_notify(pjsip_tx_data *tdata, void *info)
void(* build_notify)(pjsip_tx_data *, void *)
#define NULL
Definition: resample.c:96
struct ast_sip_endpoint * endpoint
static void notify_ami_data_destroy(void *obj)
#define ao2_ref(o, delta)
Definition: astobj2.h:464
def info(msg)
#define ao2_alloc(data_size, destructor_fn)
Definition: astobj2.h:411

◆ notify_ami_data_destroy()

static void notify_ami_data_destroy ( void *  obj)
static

Definition at line 377 of file res_pjsip_notify.c.

References ao2_cleanup, ast_variables_destroy(), notify_data::endpoint, notify_data::info, and sip_to_pjsip::info().

Referenced by notify_ami_data_create().

378 {
379  struct notify_data *data = obj;
380  struct ast_variable *info = data->info;
381 
382  ao2_cleanup(data->endpoint);
383  ast_variables_destroy(info);
384 }
void ast_variables_destroy(struct ast_variable *var)
Free variable list.
Definition: extconf.c:1263
Structure for variables, used for configurations and for channel variables.
struct ast_sip_endpoint * endpoint
def info(msg)
#define ao2_cleanup(obj)
Definition: astobj2.h:1958

◆ notify_ami_uri_data_create()

static struct notify_uri_data* notify_ami_uri_data_create ( const char *  uri,
void *  info 
)
static

Definition at line 440 of file res_pjsip_notify.c.

References ao2_alloc, ao2_ref, ast_strdup, build_ami_notify(), notify_uri_data::build_notify, notify_uri_data::info, sip_to_pjsip::info(), notify_ami_uri_data_destroy(), NULL, and notify_uri_data::uri.

Referenced by manager_notify_uri().

442 {
443  struct notify_uri_data *data = ao2_alloc(sizeof(*data),
445  if (!data) {
446  return NULL;
447  }
448 
449  data->uri = ast_strdup(uri);
450  if (!data->uri) {
451  ao2_ref(data, -1);
452  return NULL;
453  }
454 
455  data->info = info;
457 
458  return data;
459 }
static void build_ami_notify(pjsip_tx_data *tdata, void *info)
#define ast_strdup(str)
A wrapper for strdup()
Definition: astmm.h:243
#define NULL
Definition: resample.c:96
#define ao2_ref(o, delta)
Definition: astobj2.h:464
static void notify_ami_uri_data_destroy(void *obj)
def info(msg)
#define ao2_alloc(data_size, destructor_fn)
Definition: astobj2.h:411
void(* build_notify)(pjsip_tx_data *, void *)

◆ notify_ami_uri_data_destroy()

static void notify_ami_uri_data_destroy ( void *  obj)
static

Definition at line 390 of file res_pjsip_notify.c.

References ast_free, ast_variables_destroy(), notify_uri_data::info, sip_to_pjsip::info(), and notify_uri_data::uri.

Referenced by notify_ami_uri_data_create().

391 {
392  struct notify_uri_data *data = obj;
393  struct ast_variable *info = data->info;
394 
395  ast_free(data->uri);
396  ast_variables_destroy(info);
397 }
void ast_variables_destroy(struct ast_variable *var)
Free variable list.
Definition: extconf.c:1263
Structure for variables, used for configurations and for channel variables.
def info(msg)
#define ast_free(a)
Definition: astmm.h:182

◆ notify_cfg_alloc()

static void* notify_cfg_alloc ( void  )
static

Definition at line 221 of file res_pjsip_notify.c.

References ao2_alloc, AO2_ALLOC_OPT_LOCK_NOLOCK, ao2_cleanup, ao2_container_alloc_hash, notify_cfg_destroy(), notify_option_cmp(), notify_option_hash(), notify_cfg::notify_options, and NULL.

222 {
223  struct notify_cfg *cfg;
224 
225  if (!(cfg = ao2_alloc(sizeof(*cfg), notify_cfg_destroy))) {
226  return NULL;
227  }
228 
231  if (!cfg->notify_options) {
232  ao2_cleanup(cfg);
233  return NULL;
234  }
235 
236  return cfg;
237 }
struct ao2_container * notify_options
static int notify_option_hash(const void *obj, int flags)
#define NULL
Definition: resample.c:96
static void notify_cfg_destroy(void *obj)
#define ao2_container_alloc_hash(ao2_options, container_options, n_buckets, hash_fn, sort_fn, cmp_fn)
Definition: astobj2.h:1310
#define ao2_alloc(data_size, destructor_fn)
Definition: astobj2.h:411
static int notify_option_cmp(void *obj, void *arg, int flags)
#define ao2_cleanup(obj)
Definition: astobj2.h:1958

◆ notify_cfg_destroy()

static void notify_cfg_destroy ( void *  obj)
static

Definition at line 215 of file res_pjsip_notify.c.

References ao2_cleanup, and notify_cfg::notify_options.

Referenced by notify_cfg_alloc().

216 {
217  struct notify_cfg *cfg = obj;
219 }
struct ao2_container * notify_options
#define ao2_cleanup(obj)
Definition: astobj2.h:1958

◆ notify_channel()

static int notify_channel ( void *  obj)
static

Definition at line 751 of file res_pjsip_notify.c.

References ao2_cleanup, ast_channel_name(), ast_debug, ast_sip_add_header(), ast_sip_create_request(), ast_sip_send_request(), NULL, and RAII_VAR.

Referenced by build_calendar(), and push_notify_channel().

752 {
753  RAII_VAR(struct notify_channel_data *, data, obj, ao2_cleanup);
754  pjsip_tx_data *tdata;
755  struct pjsip_dialog *dlg;
756 
757  if (!data->session->channel
758  || !data->session->inv_session
759  || data->session->inv_session->state < PJSIP_INV_STATE_EARLY
760  || data->session->inv_session->state == PJSIP_INV_STATE_DISCONNECTED) {
761  return -1;
762  }
763 
764  ast_debug(1, "Sending notify on channel %s\n", ast_channel_name(data->session->channel));
765 
766  dlg = data->session->inv_session->dlg;
767 
768  if (ast_sip_create_request("NOTIFY", dlg, NULL, NULL, NULL, &tdata)) {
769  return -1;
770  }
771 
772  ast_sip_add_header(tdata, "Subscription-State", "terminated");
773  data->build_notify(tdata, data->info);
774 
775  if (ast_sip_send_request(tdata, dlg, NULL, NULL, NULL)) {
776  return -1;
777  }
778 
779  return 0;
780 }
#define NULL
Definition: resample.c:96
int ast_sip_send_request(pjsip_tx_data *tdata, struct pjsip_dialog *dlg, struct ast_sip_endpoint *endpoint, void *token, void(*callback)(void *token, pjsip_event *e))
General purpose method for sending a SIP request.
Definition: res_pjsip.c:5034
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:5063
#define ast_debug(level,...)
Log a DEBUG message.
Definition: logger.h:452
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
Definition: utils.h:911
#define ao2_cleanup(obj)
Definition: astobj2.h:1958
const char * ast_channel_name(const struct ast_channel *chan)
int ast_sip_create_request(const char *method, struct pjsip_dialog *dlg, struct ast_sip_endpoint *endpoint, const char *uri, struct ast_sip_contact *contact, pjsip_tx_data **tdata)
General purpose method for creating a SIP request.
Definition: res_pjsip.c:4490

◆ notify_cli_data_create()

static struct notify_data* notify_cli_data_create ( struct ast_sip_endpoint endpoint,
void *  info 
)
static

Definition at line 325 of file res_pjsip_notify.c.

References ao2_alloc, ao2_ref, build_cli_notify(), notify_data::build_notify, notify_data::endpoint, notify_data::info, sip_to_pjsip::info(), notify_cli_data_destroy(), and NULL.

Referenced by cli_notify().

327 {
328  struct notify_data *data = ao2_alloc(sizeof(*data),
330  if (!data) {
331  return NULL;
332  }
333 
334  data->endpoint = endpoint;
335  ao2_ref(data->endpoint, +1);
336 
337  data->info = info;
338  ao2_ref(data->info, +1);
339 
341 
342  return data;
343 }
void(* build_notify)(pjsip_tx_data *, void *)
#define NULL
Definition: resample.c:96
struct ast_sip_endpoint * endpoint
#define ao2_ref(o, delta)
Definition: astobj2.h:464
static void notify_cli_data_destroy(void *obj)
def info(msg)
#define ao2_alloc(data_size, destructor_fn)
Definition: astobj2.h:411
static void build_cli_notify(pjsip_tx_data *tdata, void *info)

◆ notify_cli_data_destroy()

static void notify_cli_data_destroy ( void *  obj)
static

Definition at line 279 of file res_pjsip_notify.c.

References ao2_cleanup, notify_data::endpoint, and notify_data::info.

Referenced by notify_cli_data_create().

280 {
281  struct notify_data *data = obj;
282 
283  ao2_cleanup(data->endpoint);
284  ao2_cleanup(data->info);
285 }
struct ast_sip_endpoint * endpoint
#define ao2_cleanup(obj)
Definition: astobj2.h:1958

◆ notify_cli_uri_data_create()

static struct notify_uri_data* notify_cli_uri_data_create ( const char *  uri,
void *  info 
)
static

Definition at line 349 of file res_pjsip_notify.c.

References ao2_alloc, ao2_ref, ast_strdup, build_cli_notify(), notify_uri_data::build_notify, notify_uri_data::info, sip_to_pjsip::info(), notify_cli_uri_data_destroy(), NULL, and notify_uri_data::uri.

Referenced by cli_notify().

351 {
352  struct notify_uri_data *data = ao2_alloc(sizeof(*data),
354 
355  if (!data) {
356  return NULL;
357  }
358 
359  data->uri = ast_strdup(uri);
360  if (!data->uri) {
361  ao2_ref(data, -1);
362  return NULL;
363  }
364 
365  data->info = info;
366  ao2_ref(data->info, +1);
367 
369 
370  return data;
371 }
#define ast_strdup(str)
A wrapper for strdup()
Definition: astmm.h:243
#define NULL
Definition: resample.c:96
#define ao2_ref(o, delta)
Definition: astobj2.h:464
def info(msg)
#define ao2_alloc(data_size, destructor_fn)
Definition: astobj2.h:411
void(* build_notify)(pjsip_tx_data *, void *)
static void notify_cli_uri_data_destroy(void *obj)
static void build_cli_notify(pjsip_tx_data *tdata, void *info)

◆ notify_cli_uri_data_destroy()

static void notify_cli_uri_data_destroy ( void *  obj)
static

Definition at line 307 of file res_pjsip_notify.c.

References ao2_cleanup, ast_free, build_cli_notify(), notify_uri_data::info, sip_to_pjsip::info(), and notify_uri_data::uri.

Referenced by notify_cli_uri_data_create().

308 {
309  struct notify_uri_data *data = obj;
310 
311  ast_free(data->uri);
312  ao2_cleanup(data->info);
313 }
#define ast_free(a)
Definition: astmm.h:182
#define ao2_cleanup(obj)
Definition: astobj2.h:1958

◆ notify_contact()

static int notify_contact ( void *  obj,
void *  arg,
int  flags 
)
static

Definition at line 645 of file res_pjsip_notify.c.

References ast_log, ast_sip_add_header(), ast_sip_create_request(), ast_sip_send_request(), notify_data::build_notify, notify_data::endpoint, notify_data::info, LOG_ERROR, LOG_WARNING, NULL, and ast_sip_contact::uri.

Referenced by notify_endpoint().

646 {
647  struct ast_sip_contact *contact = obj;
648  struct notify_data *data = arg;
649  pjsip_tx_data *tdata;
650 
651  if (ast_sip_create_request("NOTIFY", NULL, data->endpoint,
652  NULL, contact, &tdata)) {
653  ast_log(LOG_WARNING, "SIP NOTIFY - Unable to create request for "
654  "contact %s\n", contact->uri);
655  return -1;
656  }
657 
658  ast_sip_add_header(tdata, "Subscription-State", "terminated");
659  data->build_notify(tdata, data->info);
660 
661  if (ast_sip_send_request(tdata, NULL, data->endpoint, NULL, NULL)) {
662  ast_log(LOG_ERROR, "SIP NOTIFY - Unable to send request for "
663  "contact %s\n", contact->uri);
664  return -1;
665  }
666 
667  return 0;
668 }
#define LOG_WARNING
Definition: logger.h:274
void(* build_notify)(pjsip_tx_data *, void *)
#define NULL
Definition: resample.c:96
int ast_sip_send_request(pjsip_tx_data *tdata, struct pjsip_dialog *dlg, struct ast_sip_endpoint *endpoint, void *token, void(*callback)(void *token, pjsip_event *e))
General purpose method for sending a SIP request.
Definition: res_pjsip.c:5034
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:5063
struct ast_sip_endpoint * endpoint
#define ast_log
Definition: astobj2.c:42
#define LOG_ERROR
Definition: logger.h:285
Contact associated with an address of record.
Definition: res_pjsip.h:281
const ast_string_field uri
Definition: res_pjsip.h:303
int ast_sip_create_request(const char *method, struct pjsip_dialog *dlg, struct ast_sip_endpoint *endpoint, const char *uri, struct ast_sip_contact *contact, pjsip_tx_data **tdata)
General purpose method for creating a SIP request.
Definition: res_pjsip.c:4490

◆ notify_endpoint()

static int notify_endpoint ( void *  obj)
static

Definition at line 677 of file res_pjsip_notify.c.

References ao2_callback, ao2_cleanup, ast_log, ast_sip_location_retrieve_aor(), ast_sip_location_retrieve_aor_contacts(), ast_strdupa, ast_strip(), ast_strlen_zero, LOG_WARNING, notify_contact(), NULL, OBJ_NODATA, RAII_VAR, and strsep().

Referenced by push_notify().

678 {
679  RAII_VAR(struct notify_data *, data, obj, ao2_cleanup);
680  char *aor_name, *aors;
681 
682  if (ast_strlen_zero(data->endpoint->aors)) {
683  ast_log(LOG_WARNING, "Unable to NOTIFY - "
684  "endpoint has no configured AORs\n");
685  return -1;
686  }
687 
688  aors = ast_strdupa(data->endpoint->aors);
689 
690  while ((aor_name = ast_strip(strsep(&aors, ",")))) {
691  RAII_VAR(struct ast_sip_aor *, aor,
693  RAII_VAR(struct ao2_container *, contacts, NULL, ao2_cleanup);
694 
695  if (!aor || !(contacts = ast_sip_location_retrieve_aor_contacts(aor))) {
696  continue;
697  }
698 
699  ao2_callback(contacts, OBJ_NODATA, notify_contact, data);
700  }
701 
702  return 0;
703 }
A SIP address of record.
Definition: res_pjsip.h:361
#define LOG_WARNING
Definition: logger.h:274
#define ao2_callback(c, flags, cb_fn, arg)
Definition: astobj2.h:1716
struct ao2_container * ast_sip_location_retrieve_aor_contacts(const struct ast_sip_aor *aor)
Retrieve all contacts currently available for an AOR.
Definition: location.c:247
#define NULL
Definition: resample.c:96
#define ast_strlen_zero(foo)
Definition: strings.h:52
#define ast_log
Definition: astobj2.c:42
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
Definition: utils.h:911
char * ast_strip(char *s)
Strip leading/trailing whitespace from a string.
Definition: strings.h:219
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: astmm.h:300
static int notify_contact(void *obj, void *arg, int flags)
struct ast_sip_aor * ast_sip_location_retrieve_aor(const char *aor_name)
Retrieve a named AOR.
Definition: location.c:147
char * strsep(char **str, const char *delims)
#define ao2_cleanup(obj)
Definition: astobj2.h:1958
Generic container type.

◆ notify_option_alloc()

static void* notify_option_alloc ( const char *  category)
static

Definition at line 158 of file res_pjsip_notify.c.

References ao2_alloc, AO2_ALLOC_OPT_LOCK_NOLOCK, ao2_cleanup, ao2_container_alloc_list, AO2_CONTAINER_ALLOC_OPT_DUPS_ALLOW, ast_copy_string(), notify_option::items, notify_option::name, notify_option_destroy(), and NULL.

159 {
160  int category_size = strlen(category) + 1;
161 
162  struct notify_option *option = ao2_alloc(
163  sizeof(*option) + category_size, notify_option_destroy);
164 
165  if (!option) {
166  return NULL;
167  }
168 
169  ast_copy_string(option->name, category, category_size);
170 
171  if (!(option->items = ao2_container_alloc_list(
174  ao2_cleanup(option);
175  return NULL;
176  }
177 
178  return option;
179 }
struct ao2_container * items
Allow objects with duplicate keys in container.
Definition: astobj2.h:1185
#define ao2_container_alloc_list(ao2_options, container_options, sort_fn, cmp_fn)
Definition: astobj2.h:1335
#define NULL
Definition: resample.c:96
#define ao2_alloc(data_size, destructor_fn)
Definition: astobj2.h:411
static void notify_option_destroy(void *obj)
#define ao2_cleanup(obj)
Definition: astobj2.h:1958
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:401

◆ notify_option_cmp()

static int notify_option_cmp ( void *  obj,
void *  arg,
int  flags 
)
static

Definition at line 143 of file res_pjsip_notify.c.

References CMP_MATCH, notify_option::name, and OBJ_KEY.

Referenced by notify_cfg_alloc().

144 {
145  struct notify_option *option1 = obj;
146  struct notify_option *option2 = arg;
147  const char *key = flags & OBJ_KEY ? arg : option2->name;
148 
149  return strcasecmp(option1->name, key) ? 0 : CMP_MATCH;
150 }
#define OBJ_KEY
Definition: astobj2.h:1155

◆ notify_option_destroy()

static void notify_option_destroy ( void *  obj)
static

Definition at line 152 of file res_pjsip_notify.c.

References ao2_cleanup, and notify_option::items.

Referenced by notify_option_alloc().

153 {
154  struct notify_option *option = obj;
155  ao2_cleanup(option->items);
156 }
struct ao2_container * items
#define ao2_cleanup(obj)
Definition: astobj2.h:1958

◆ notify_option_find()

static void* notify_option_find ( struct ao2_container container,
const char *  category 
)
static

Definition at line 181 of file res_pjsip_notify.c.

References ao2_find, and OBJ_KEY.

Referenced by cli_notify().

182 {
183  return ao2_find(container, category, OBJ_KEY);
184 }
#define OBJ_KEY
Definition: astobj2.h:1155
#define ao2_find(container, arg, flags)
Definition: astobj2.h:1756

◆ notify_option_handler()

static int notify_option_handler ( const struct aco_option opt,
struct ast_variable var,
void *  obj 
)
static

Definition at line 186 of file res_pjsip_notify.c.

References ao2_alloc, ao2_cleanup, ao2_link, ast_copy_string(), item, notify_option::items, ast_variable::name, aco_type::name, NULL, RAII_VAR, and ast_variable::value.

Referenced by load_module().

188 {
189  struct notify_option *option = obj;
190 
191  int name_size = strlen(var->name) + 1;
192  int value_size = strlen(var->value) + 1;
193 
194  RAII_VAR(struct notify_option_item *, item,
195  ao2_alloc(sizeof(*item) + name_size + value_size,
196  NULL), ao2_cleanup);
197 
198  item->name = item->buf;
199  item->value = item->buf + name_size;
200 
201  ast_copy_string(item->buf, var->name, name_size);
202  ast_copy_string(item->buf + name_size, var->value, value_size);
203 
204  if (!ao2_link(option->items, item)) {
205  return -1;
206  }
207 
208  return 0;
209 }
struct ao2_container * items
static struct aco_type item
Definition: test_config.c:1463
#define NULL
Definition: resample.c:96
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
Definition: utils.h:911
#define ao2_alloc(data_size, destructor_fn)
Definition: astobj2.h:411
const char * name
#define ao2_cleanup(obj)
Definition: astobj2.h:1958
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:401
#define ao2_link(container, obj)
Definition: astobj2.h:1549

◆ notify_option_hash()

static int notify_option_hash ( const void *  obj,
int  flags 
)
static

Definition at line 137 of file res_pjsip_notify.c.

References ast_str_case_hash(), notify_option::name, and OBJ_KEY.

Referenced by notify_cfg_alloc().

138 {
139  const struct notify_option *option = obj;
140  return ast_str_case_hash(flags & OBJ_KEY ? obj : option->name);
141 }
#define OBJ_KEY
Definition: astobj2.h:1155
static force_inline int attribute_pure ast_str_case_hash(const char *str)
Compute a hash value on a case-insensitive string.
Definition: strings.h:1250

◆ notify_uri()

static int notify_uri ( void *  obj)
static

Definition at line 709 of file res_pjsip_notify.c.

References ao2_cleanup, ast_log, ast_sip_add_header(), ast_sip_create_request(), ast_sip_default_outbound_endpoint(), ast_sip_send_request(), ast_strlen_zero, notify_data::endpoint, LOG_ERROR, LOG_WARNING, NULL, and RAII_VAR.

Referenced by handle_cc_notify(), and push_notify_uri().

710 {
711  RAII_VAR(struct notify_uri_data *, data, obj, ao2_cleanup);
712  RAII_VAR(struct ast_sip_endpoint *, endpoint,
714  pjsip_tx_data *tdata;
715 
716  if (!endpoint) {
717  ast_log(LOG_WARNING, "No default outbound endpoint set, can not send "
718  "NOTIFY requests to arbitrary URIs.\n");
719  return -1;
720  }
721 
722  if (ast_strlen_zero(data->uri)) {
723  ast_log(LOG_WARNING, "Unable to NOTIFY - URI is blank.\n");
724  return -1;
725  }
726 
727  if (ast_sip_create_request("NOTIFY", NULL, endpoint,
728  data->uri, NULL, &tdata)) {
729  ast_log(LOG_WARNING, "SIP NOTIFY - Unable to create request for "
730  "uri %s\n", data->uri);
731  return -1;
732  }
733 
734  ast_sip_add_header(tdata, "Subscription-State", "terminated");
735 
736  data->build_notify(tdata, data->info);
737 
738  if (ast_sip_send_request(tdata, NULL, endpoint, NULL, NULL)) {
739  ast_log(LOG_ERROR, "SIP NOTIFY - Unable to send request for "
740  "uri %s\n", data->uri);
741  return -1;
742  }
743 
744  return 0;
745 }
#define LOG_WARNING
Definition: logger.h:274
struct ast_sip_endpoint * ast_sip_default_outbound_endpoint(void)
Retrieve the default outbound endpoint.
#define NULL
Definition: resample.c:96
int ast_sip_send_request(pjsip_tx_data *tdata, struct pjsip_dialog *dlg, struct ast_sip_endpoint *endpoint, void *token, void(*callback)(void *token, pjsip_event *e))
General purpose method for sending a SIP request.
Definition: res_pjsip.c:5034
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:5063
#define ast_strlen_zero(foo)
Definition: strings.h:52
#define ast_log
Definition: astobj2.c:42
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
Definition: utils.h:911
An entity with which Asterisk communicates.
Definition: res_pjsip.h:812
#define LOG_ERROR
Definition: logger.h:285
#define ao2_cleanup(obj)
Definition: astobj2.h:1958
int ast_sip_create_request(const char *method, struct pjsip_dialog *dlg, struct ast_sip_endpoint *endpoint, const char *uri, struct ast_sip_contact *contact, pjsip_tx_data **tdata)
General purpose method for creating a SIP request.
Definition: res_pjsip.c:4490

◆ push_notify()

static enum notify_result push_notify ( const char *  endpoint_name,
void *  info,
task_data_create  data_create 
)
static

Definition at line 803 of file res_pjsip_notify.c.

References ALLOC_ERROR, ao2_cleanup, ast_sip_get_sorcery(), ast_sip_push_task(), ast_sorcery_retrieve_by_id(), ast_sip_session::endpoint, notify_data::endpoint, INVALID_ENDPOINT, notify_endpoint(), NULL, RAII_VAR, SUCCESS, and TASK_PUSH_ERROR.

Referenced by cli_notify(), and manager_notify_endpoint().

805 {
806  RAII_VAR(struct ast_sip_endpoint *, endpoint, NULL, ao2_cleanup);
807  struct notify_data *data;
808 
810  ast_sip_get_sorcery(), "endpoint", endpoint_name))) {
811  return INVALID_ENDPOINT;
812  }
813 
814  if (!(data = data_create(endpoint, info))) {
815  return ALLOC_ERROR;
816  }
817 
818  if (ast_sip_push_task(NULL, notify_endpoint, data)) {
819  ao2_cleanup(data);
820  return TASK_PUSH_ERROR;
821  }
822 
823  return SUCCESS;
824 }
#define NULL
Definition: resample.c:96
void * ast_sorcery_retrieve_by_id(const struct ast_sorcery *sorcery, const char *type, const char *id)
Retrieve an object using its unique identifier.
Definition: sorcery.c:1853
struct ast_sip_endpoint * endpoint
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
Definition: utils.h:911
static int notify_endpoint(void *obj)
An entity with which Asterisk communicates.
Definition: res_pjsip.h:812
int ast_sip_push_task(struct ast_taskprocessor *serializer, int(*sip_task)(void *), void *task_data)
Pushes a task to SIP servants.
Definition: res_pjsip.c:5138
def info(msg)
struct ast_sorcery * ast_sip_get_sorcery(void)
Get a pointer to the SIP sorcery structure.
#define ao2_cleanup(obj)
Definition: astobj2.h:1958

◆ push_notify_channel()

static enum notify_result push_notify_channel ( const char *  channel_name,
void *  info,
task_channel_data_create  data_create 
)
static

Definition at line 851 of file res_pjsip_notify.c.

References ALLOC_ERROR, ao2_ref, ast_channel_get_by_name(), ast_channel_lock, ast_channel_tech(), ast_channel_tech_pvt(), ast_channel_unlock, ast_channel_unref, ast_debug, ast_log, ast_sip_push_task(), ast_sip_session::inv_session, INVALID_CHANNEL, LOG_WARNING, notify_channel(), ast_sip_session::serializer, session, ast_sip_channel_pvt::session, SUCCESS, TASK_PUSH_ERROR, and type.

Referenced by manager_notify_channel().

853 {
854  struct notify_channel_data *data;
855  struct ast_channel *ch;
856  struct ast_sip_session *session;
857  struct ast_sip_channel_pvt *ch_pvt;
858 
859  /* note: this increases the refcount of the channel */
860  ch = ast_channel_get_by_name(channel_name);
861  if (!ch) {
862  ast_debug(1, "No channel found with name %s", channel_name);
863  return INVALID_CHANNEL;
864  }
865 
866  if (strcmp(ast_channel_tech(ch)->type, "PJSIP")) {
867  ast_log(LOG_WARNING, "Channel was a non-PJSIP channel: %s\n", channel_name);
868  ast_channel_unref(ch);
869  return INVALID_CHANNEL;
870  }
871 
872  ast_channel_lock(ch);
873  ch_pvt = ast_channel_tech_pvt(ch);
874  session = ch_pvt->session;
875 
876  if (!session || !session->inv_session
877  || session->inv_session->state < PJSIP_INV_STATE_EARLY
878  || session->inv_session->state == PJSIP_INV_STATE_DISCONNECTED) {
879  ast_debug(1, "No active session for channel %s\n", channel_name);
880  ast_channel_unlock(ch);
881  ast_channel_unref(ch);
882  return INVALID_CHANNEL;
883  }
884 
885  ao2_ref(session, +1);
886  ast_channel_unlock(ch);
887 
888  /* don't keep a reference to the channel, we've got a reference to the session */
889  ast_channel_unref(ch);
890 
891  /*
892  * data_create will take ownership of the session,
893  * and take care of releasing the ref.
894  */
895  data = data_create(session, info);
896  if (!data) {
897  ao2_ref(session, -1);
898  return ALLOC_ERROR;
899  }
900 
901  if (ast_sip_push_task(session->serializer, notify_channel, data)) {
902  ao2_ref(data, -1);
903  return TASK_PUSH_ERROR;
904  }
905 
906  return SUCCESS;
907 }
static const char type[]
Definition: chan_ooh323.c:109
#define ast_channel_lock(chan)
Definition: channel.h:2945
Main Channel structure associated with a channel.
void * ast_channel_tech_pvt(const struct ast_channel *chan)
#define ast_channel_unref(c)
Decrease channel reference count.
Definition: channel.h:2981
#define LOG_WARNING
Definition: logger.h:274
A structure which contains a channel implementation and session.
struct ast_sip_session * session
Pointer to session.
struct pjsip_inv_session * inv_session
A structure describing a SIP session.
#define ast_debug(level,...)
Log a DEBUG message.
Definition: logger.h:452
#define ast_log
Definition: astobj2.c:42
static struct ast_mansession session
#define ao2_ref(o, delta)
Definition: astobj2.h:464
struct ast_taskprocessor * serializer
int ast_sip_push_task(struct ast_taskprocessor *serializer, int(*sip_task)(void *), void *task_data)
Pushes a task to SIP servants.
Definition: res_pjsip.c:5138
def info(msg)
#define ast_channel_unlock(chan)
Definition: channel.h:2946
static int notify_channel(void *obj)
struct ast_channel * ast_channel_get_by_name(const char *name)
Find a channel by name.
Definition: channel.c:1454
const struct ast_channel_tech * ast_channel_tech(const struct ast_channel *chan)

◆ push_notify_uri()

static enum notify_result push_notify_uri ( const char *  uri,
void *  info,
task_uri_data_create  data_create 
)
static

Definition at line 830 of file res_pjsip_notify.c.

References ALLOC_ERROR, ao2_cleanup, ast_sip_push_task(), notify_uri(), NULL, SUCCESS, and TASK_PUSH_ERROR.

Referenced by cli_notify(), and manager_notify_uri().

832 {
833  struct notify_uri_data *data;
834 
835  if (!(data = data_create(uri, info))) {
836  return ALLOC_ERROR;
837  }
838 
839  if (ast_sip_push_task(NULL, notify_uri, data)) {
840  ao2_cleanup(data);
841  return TASK_PUSH_ERROR;
842  }
843 
844  return SUCCESS;
845 }
#define NULL
Definition: resample.c:96
static int notify_uri(void *obj)
int ast_sip_push_task(struct ast_taskprocessor *serializer, int(*sip_task)(void *), void *task_data)
Pushes a task to SIP servants.
Definition: res_pjsip.c:5138
def info(msg)
#define ao2_cleanup(obj)
Definition: astobj2.h:1958

◆ reload_module()

static int reload_module ( void  )
static

Definition at line 1238 of file res_pjsip_notify.c.

References aco_process_config(), ACO_PROCESS_ERROR, and AST_MODULE_LOAD_DECLINE.

Referenced by unload_module().

1239 {
1241  return AST_MODULE_LOAD_DECLINE;
1242  }
1243 
1244  return 0;
1245 }
enum aco_process_status aco_process_config(struct aco_info *info, int reload)
Process a config info via the options registered with an aco_info.
Their was an error and no changes were applied.
Module has failed to load, may be in an inconsistent state.
Definition: module.h:78

◆ unload_module()

static int unload_module ( void  )
static

Definition at line 1247 of file res_pjsip_notify.c.

References aco_info_destroy(), ao2_global_obj_release, ARRAY_LEN, ast_cli_unregister_multiple(), ast_manager_unregister(), AST_MODFLAG_LOAD_ORDER, AST_MODPRI_APP_DEPEND, AST_MODULE_INFO(), AST_MODULE_SUPPORT_CORE, ASTERISK_GPL_KEY, globals, load_module(), reload(), and reload_module().

1248 {
1249  ast_manager_unregister("PJSIPNotify");
1253 
1254  return 0;
1255 }
#define ARRAY_LEN(a)
Definition: isdn_lib.c:42
int ast_cli_unregister_multiple(struct ast_cli_entry *e, int len)
Unregister multiple commands.
Definition: clicompat.c:30
static struct ast_cli_entry cli_options[]
static struct console_pvt globals
int ast_manager_unregister(const char *action)
Unregister a registered manager command.
Definition: manager.c:7258
void aco_info_destroy(struct aco_info *info)
Destroy an initialized aco_info struct.
#define ao2_global_obj_release(holder)
Definition: astobj2.h:865

Variable Documentation

◆ __mod_info

struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "CLI/AMI PJSIP NOTIFY 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, .reload = reload_module, .unload = unload_module, .load_pri = AST_MODPRI_APP_DEPEND, .requires = "res_pjsip", }
static

Definition at line 1264 of file res_pjsip_notify.c.

◆ ast_module_info

const struct ast_module_info* ast_module_info = &__mod_info
static

Definition at line 1264 of file res_pjsip_notify.c.

◆ cli_options

struct ast_cli_entry cli_options[]
static
Initial value:
= {
{ .handler = cli_notify , .summary = "Send a NOTIFY request to a SIP endpoint" ,}
}
static char * cli_notify(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)

Definition at line 1070 of file res_pjsip_notify.c.

◆ module_conf

struct aco_file module_conf
static
Initial value:
= {
.filename = notify_config,
}
#define ACO_TYPES(...)
A helper macro to ensure that aco_info types always have a sentinel.
static const char notify_config[]

Definition at line 251 of file res_pjsip_notify.c.

◆ notify_config

const char notify_config[] = "pjsip_notify.conf"
static

Definition at line 122 of file res_pjsip_notify.c.

◆ notify_option

struct aco_type notify_option
static

Definition at line 239 of file res_pjsip_notify.c.

◆ notify_options

struct aco_type* notify_options[] = ACO_TYPES(&notify_option)
static

Definition at line 249 of file res_pjsip_notify.c.