43#define RETURN_REASON_DATASTORE_NAME "pjsip_session_return_reason"
50 struct pjsip_tx_data *tdata)
53 pjsip_generic_string_hdr *reason_hdr;
58 struct pjsip_status_line
status = tdata->msg->line.status;
67 if (!((PJSIP_IS_STATUS_IN_CLASS(
status.code, 100) &&
status.code != 100) ||
status.code == 200)) {
73 SCOPE_EXIT_RTN(
"%s: No datastore on session. Nothing to do\n", tag);
77 rc =
ast_asprintf(&reason_str,
"%s; cause=%d; text=\"%s\"",
83 reason_val = pj_str(reason_str);
92 ast_trace(3,
"%s: Reason already sent\n", tag);
98 if (pj_strcmp(&reason_hdr->hvalue, &reason_val) == 0) {
99 ast_trace(3,
"%s: MATCH. Cleaning up old reason\n", tag);
100 pj_list_erase(reason_hdr);
103 reason_hdr = pjsip_msg_find_hdr_by_name(tdata->msg, &
reason_hdr_str, reason_hdr->next);
109 reason_hdr = pjsip_generic_string_hdr_create(tdata->pool, &
reason_hdr_str, &reason_val);
111 pjsip_msg_add_hdr(tdata->msg, (pjsip_hdr *)reason_hdr);
113 ast_trace(1,
"%s: Created reason header: Reason: %s\n",
116 ast_trace(1,
"%s: Failed to create reason header: Reason: %s\n",
124 const char *protocol,
int code,
const char *
text)
129 SCOPE_ENTER(4,
"%s: Adding Reason header %s %d %s\n",
131 code,
S_OR(
text,
"<missing text>"));
145 datastore->data = rr;
148 "%s: Failed to add datastore to session\n", tag);
Asterisk main include file. File version handling, generic pbx functions.
static struct ast_mansession session
#define ast_strdup(str)
A wrapper for strdup()
#define ast_asprintf(ret, fmt,...)
A wrapper for asprintf()
#define ast_calloc(num, len)
A wrapper for calloc()
#define SCOPE_EXIT_RTN(...)
#define SCOPE_EXIT_RTN_VALUE(__return_value,...)
#define SCOPE_ENTER(level,...)
#define ast_trace(level,...)
@ AST_SIP_SUPPLEMENT_PRIORITY_CHANNEL
#define PJSTR_PRINTF_VAR(_v)
#define PJSTR_PRINTF_SPEC
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.
const char * ast_sip_session_get_name(const struct ast_sip_session *session)
Get the channel or endpoint name associated with the session.
#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)
Structure for a data store type.
Structure for a data store object.
A supplement to SIP message processing.
A structure describing a SIP session.
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.