312 .
type =
"header_datastore",
316 .
type =
"response_header_datastore",
339 pjsip_hdr *hdr = msg->hdr.next;
342 while (
hdr &&
hdr != &msg->hdr) {
344 le->
hdr = pjsip_hdr_clone(pool,
hdr);
362 pj_pool_t *pool =
session->inv_session->dlg->pool;
370 !(datastore->data = pj_pool_alloc(pool,
sizeof(
struct hdr_list))) ||
392 pj_pool_t *pool =
session->inv_session->dlg->pool;
395 pjsip_status_line
status = rdata->msg_info.msg->line.status;
398 if (
session->inv_session->state != PJSIP_INV_STATE_CONNECTING ||
status.code!=200) {
406 !(datastore->data = pj_pool_alloc(pool,
sizeof(
struct hdr_list))) ||
434 if (pj_stricmp2(&le->
hdr->name, header_name) == 0 && i++ == header_number) {
457 pjsip_hdr *hdr =
NULL;
459 int pj_hdr_string_len;
462 size_t plen, wlen = 0;
470 if (!datastore || !datastore->data) {
471 ast_debug(1,
"There was no datastore from which to read headers.\n");
475 list = datastore->data;
482 pj_hdr_string_len = pjsip_hdr_print_on(hdr, pj_hdr_string, data->
len - 1);
483 if (pj_hdr_string_len == -1) {
485 "Not enough buffer space in pjsip_hdr_print_on\n");
488 pj_hdr_string[pj_hdr_string_len] =
'\0';
489 p = strchr(pj_hdr_string,
':');
492 "A malformed header was returned from pjsip_hdr_print_on\n");
496 pj_hdr_string[p - pj_hdr_string] =
'\0';
499 if (wlen + plen + 1 > data->
len) {
501 "Buffer isn't big enough to hold header value. %zu > %zu\n", plen + 1,
505 pos = strstr(data->
buf, p);
506 if (pos && pos[1] ==
',') {
507 if (pos == data->
buf) {
509 }
else if (pos[-1] ==
',') {
529 data->
buf[wlen-1] =
'\0';
548 pjsip_hdr *hdr =
NULL;
550 int pj_hdr_string_len;
560 if (!datastore || !datastore->data) {
561 ast_debug(1,
"There was no datastore from which to read headers.\n");
565 list = datastore->data;
586 pj_hdr_string_len = pjsip_hdr_print_on(hdr, pj_hdr_string, data->
len - 1);
587 if (pj_hdr_string_len == -1) {
589 "Not enough buffer space in pjsip_hdr_print_on\n");
593 pj_hdr_string[pj_hdr_string_len] =
'\0';
595 p = strchr(pj_hdr_string,
':');
598 "A malformed header was returned from pjsip_hdr_print_on.\n");
605 if (plen + 1 > data->
len) {
607 "Buffer isn't big enough to hold header value. %zu > %zu\n", plen + 1,
631 pj_pool_t *pool =
session->inv_session->dlg->pool;
632 pj_str_t pj_header_name;
633 pj_str_t pj_header_value;
643 || !(datastore->data = pj_pool_alloc(pool,
sizeof(
struct hdr_list)))
657 le->
hdr = (pjsip_hdr *) pjsip_generic_string_hdr_create(pool, &pj_header_name,
659 list = datastore->data;
680 pjsip_hdr *hdr =
NULL;
685 if (!datastore || !datastore->data) {
698 pj_strdup2(pool, &((pjsip_generic_string_hdr *) hdr)->hvalue, data->
header_value);
717 int removed_count = 0;
722 if (!datastore || !datastore->data) {
727 list = datastore->data;
743 if (data->
buf && data->
len) {
744 snprintf(data->
buf, data->
len,
"%d", removed_count);
839 if (!
args.header_number) {
856 if (!strcasecmp(
args.action,
"read")) {
858 }
else if (!strcasecmp(
args.action,
"remove")) {
863 "Unknown action '%s' is not valid, must be 'read' or 'remove'.\n",
897 if (!
args.header_number) {
914 if (!strcasecmp(
args.action,
"read")) {
918 "Unknown action '%s' is not valid, must be 'read'.\n",
953 if (!
args.header_number) {
970 if (!strcasecmp(
args.action,
"add")) {
973 }
else if (!strcasecmp(
args.action,
"update")) {
976 }
else if (!strcasecmp(
args.action,
"remove")) {
981 "Unknown action '%s' is not valid, must be 'add', 'update', or 'remove'.\n",
988 .
name =
"PJSIP_HEADER",
994 .
name =
"PJSIP_HEADERS",
999 .
name =
"PJSIP_RESPONSE_HEADER",
1004 .
name =
"PJSIP_RESPONSE_HEADERS",
1027 if (!datastore || !datastore->data ||
1028 (
session->inv_session->state >= PJSIP_INV_STATE_CONFIRMED)) {
1032 list = datastore->data;
1034 pjsip_msg_add_hdr(tdata->msg, (pjsip_hdr *) pjsip_hdr_clone(tdata->pool, le->
hdr));
1067 pj_str_t param_name;
1069 pjsip_fromto_hdr *dlg_info;
1070 pjsip_name_addr *dlg_info_name_addr;
1071 pjsip_sip_uri *dlg_info_uri;
1075 dlg_info =
session->inv_session->dlg->remote.info;
1076 dlg_info_name_addr = (pjsip_name_addr *) dlg_info->uri;
1077 dlg_info_uri = pjsip_uri_get_uri(dlg_info_name_addr);
1082 param = pjsip_param_find(&dlg_info_uri->other_param, ¶m_name);
1084 param = pjsip_param_find(&dlg_info->other_param, ¶m_name);
1088 ast_debug(1,
"No %s parameter found named %s\n",
1093 param_len = pj_strlen(¶m->value);
1094 if (param_len >= data->
len) {
1095 ast_log(
LOG_ERROR,
"Buffer is too small for parameter value (%zu > %zu)\n", param_len, data->
len);
1099 ast_debug(2,
"Successfully read %s parameter %s (length %zu)\n",
1104 data->
buf[param_len] =
'\0';
1119 pj_pool_t *pool =
session->inv_session->dlg->pool;
1121 pjsip_fromto_hdr *dlg_info;
1122 pjsip_name_addr *dlg_info_name_addr;
1123 pjsip_sip_uri *dlg_info_uri;
1125 dlg_info =
session->inv_session->dlg->local.info;
1126 dlg_info_name_addr = (pjsip_name_addr *) dlg_info->uri;
1127 dlg_info_uri = pjsip_uri_get_uri(dlg_info_name_addr);
1128 if (!PJSIP_URI_SCHEME_IS_SIP(dlg_info_uri) && !PJSIP_URI_SCHEME_IS_SIPS(dlg_info_uri)) {
1133 ast_debug(1,
"Adding custom %s param %s = %s\n",
1146#define param_add(pool, list, pname, pvalue) { \
1147 pjsip_param *param; \
1148 param = PJ_POOL_ALLOC_T(pool, pjsip_param); \
1149 pj_strdup2(pool, ¶m->name, pname); \
1150 pj_strdup2(pool, ¶m->value, pvalue); \
1151 pj_list_insert_before(list, param); \
1198 if (!strcasecmp(
args.param_type,
"header")) {
1200 }
else if (!strcasecmp(
args.param_type,
"uri")) {
1247 if (!strcasecmp(
args.param_type,
"header")) {
1249 }
else if (!strcasecmp(
args.param_type,
"uri")) {
1261 .
name =
"PJSIP_HEADER_PARAM",
1294 .
requires =
"res_pjsip,res_pjsip_session",
Asterisk main include file. File version handling, generic pbx functions.
static struct ast_mansession session
#define ast_alloca(size)
call __builtin_alloca to ensure we get gcc builtin semantics
General Asterisk PBX channel definitions.
const char * ast_channel_name(const struct ast_channel *chan)
void * ast_channel_tech_pvt(const struct ast_channel *chan)
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
int ast_sip_push_task_wait_serializer(struct ast_taskprocessor *serializer, int(*sip_task)(void *), void *task_data)
Push a task to the serializer and wait for it to complete.
Application convenience functions, designed to give consistent look and feel to Asterisk apps.
#define AST_APP_ARG(name)
Define an application argument.
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application's arguments.
#define AST_STANDARD_APP_ARGS(args, parse)
Performs the 'standard' argument separation process for an application.
#define ast_debug(level,...)
Log a DEBUG message.
#define AST_LIST_HEAD_INIT_NOLOCK(head)
Initializes a list head structure.
#define AST_LIST_HEAD_NOLOCK(name, type)
Defines a structure to be used to hold a list of specified type (with no lock).
#define AST_LIST_TRAVERSE(head, var, field)
Loops over (traverses) the entries in a list.
#define AST_LIST_INSERT_TAIL(head, elm, field)
Appends a list entry to the tail of a list.
#define AST_LIST_ENTRY(type)
Declare a forward link structure inside a list entry.
#define AST_LIST_TRAVERSE_SAFE_END
Closes a safe loop traversal block.
#define AST_LIST_TRAVERSE_SAFE_BEGIN(head, var, field)
Loops safely over (traverses) the entries in a list.
#define AST_LIST_REMOVE_CURRENT(field)
Removes the current entry from a list during a traversal.
Asterisk module definitions.
#define AST_MODULE_INFO(keystr, flags_to_set, desc, fields...)
@ AST_MODULE_SUPPORT_CORE
#define ASTERISK_GPL_KEY
The text the key() function should return.
@ AST_MODULE_LOAD_SUCCESS
Core PBX routines and definitions.
#define ast_custom_function_register(acf)
Register a custom function.
int ast_custom_function_unregister(struct ast_custom_function *acf)
Unregister a custom function.
@ AST_SIP_SUPPLEMENT_PRIORITY_CHANNEL
struct ast_datastore * ast_sip_session_get_datastore(struct ast_sip_session *session, const char *name)
Retrieve a session datastore.
int ast_sip_session_add_datastore(struct ast_sip_session *session, struct ast_datastore *datastore)
Add a datastore to a SIP session.
void ast_sip_session_remove_datastore(struct ast_sip_session *session, const char *name)
Remove a session datastore from the session.
#define ast_sip_session_register_supplement(supplement)
struct ast_datastore * ast_sip_session_alloc_datastore(const struct ast_datastore_info *info, const char *uid)
Alternative for ast_datastore_alloc()
void ast_sip_session_unregister_supplement(struct ast_sip_session_supplement *supplement)
Unregister a an supplement to SIP session processing.
#define S_OR(a, b)
returns the equivalent of logic or for strings: first one if not empty, otherwise second one.
static force_inline int attribute_pure ast_strlen_zero(const char *s)
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
char * ast_strip(char *s)
Strip leading/trailing whitespace from a string.
Main Channel structure associated with a channel.
Data structure associated with a custom dialplan function.
Structure for a data store type.
Structure for a data store object.
A structure which contains a channel implementation and session.
struct ast_sip_session * session
Pointer to session.
A supplement to SIP message processing.
A structure describing a SIP session.
struct pjsip_inv_session * inv_session
struct ast_taskprocessor * serializer
Linked list for accumulating headers.
struct hdr_list_entry::@457 nextptr
enum param_type paramtype
struct ast_sip_channel_pvt * channel
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.