39 static const pj_str_t str_reason = {
"Reason", 6 };
40 pjsip_generic_string_hdr *
header;
43 int code_q850 = 0, code_sip = 0;
45 header = pjsip_msg_find_hdr_by_name(rdata->msg_info.msg, &str_reason,
NULL);
47 header = pjsip_msg_find_hdr_by_name(rdata->msg_info.msg, &str_reason,
header->
next)) {
48 int cause_q850, cause_sip;
50 int data_size =
sizeof(*cause_code);
54 cause_q850 = !strncasecmp(cause,
"Q.850", 5);
55 cause_sip = !strncasecmp(cause,
"SIP", 3);
56 if ((cause_q850 || cause_sip) && (cause = strstr(cause,
"cause="))) {
57 int *
code = cause_q850 ? &code_q850 : &code_sip;
58 if (sscanf(cause,
"cause=%30d",
code) != 1) {
65 data_size += 4 + strlen(cause) + 1;
67 memset(cause_code, 0, data_size);
69 snprintf(cause_code->
code, data_size,
"SIP %s", cause);
74 }
else if (code_sip) {
84 }
else if (code_sip) {
91 if ((pjsip_method_cmp(&rdata->msg_info.msg->line.req.method, &pjsip_bye_method) &&
92 pjsip_method_cmp(&rdata->msg_info.msg->line.req.method, &pjsip_cancel_method)) ||
104 struct pjsip_status_line
status = rdata->msg_info.msg->line.status;
118 ast_sip_add_header(tdata,
"Reason",
"SIP;cause=200;text=\"Call completed elsewhere\"");
121 if (
session->endpoint &&
session->endpoint->suppress_q850_reason_headers) {
122 ast_debug(1,
"A Q.850 '%s'(%i) Reason header was suppressed for endpoint '%s'\n",
134 if ((pjsip_method_cmp(&tdata->msg->line.req.method, &pjsip_bye_method)
135 && pjsip_method_cmp(&tdata->msg->line.req.method, &pjsip_cancel_method))
151 struct pjsip_status_line
status = tdata->msg->line.status;
186 .
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
Internal Asterisk hangup causes.
#define AST_CAUSE_ANSWERED_ELSEWHERE
const char * ast_channel_name(const struct ast_channel *chan)
int ast_queue_control_data(struct ast_channel *chan, enum ast_control_frame_type control, const void *data, size_t datalen)
Queue a control frame with payload.
int ast_channel_hangupcause(const struct ast_channel *chan)
void ast_channel_hangupcause_hash_set(struct ast_channel *chan, const struct ast_control_pvt_cause_code *cause_code, int datalen)
Sets the HANGUPCAUSE hash and optionally the SIP_CAUSE hash on the given channel.
const char * ast_cause2str(int cause) attribute_pure
Gives the string form of a given cause code.
void ast_channel_hangupcause_set(struct ast_channel *chan, int value)
@ AST_CONTROL_PVT_CAUSE_CODE
#define ast_debug(level,...)
Log a DEBUG message.
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
const int ast_sip_hangup_sip2cause(int cause)
Convert SIP hangup causes to Asterisk hangup causes.
void ast_copy_pj_str(char *dest, const pj_str_t *src, size_t size)
Copy a pj_str_t into a standard character buffer.
int ast_sip_add_header(pjsip_tx_data *tdata, const char *name, const char *value)
Add a header to an outbound SIP message.
static struct ast_sip_session_supplement rfc3326_supplement
static void rfc3326_add_reason_header(struct ast_sip_session *session, struct pjsip_tx_data *tdata)
static void rfc3326_use_reason_header(struct ast_sip_session *session, struct pjsip_rx_data *rdata)
static int load_module(void)
static int unload_module(void)
static void rfc3326_outgoing_response(struct ast_sip_session *session, struct pjsip_tx_data *tdata)
static void rfc3326_outgoing_request(struct ast_sip_session *session, struct pjsip_tx_data *tdata)
static void rfc3326_incoming_response(struct ast_sip_session *session, struct pjsip_rx_data *rdata)
static int rfc3326_incoming_request(struct ast_sip_session *session, struct pjsip_rx_data *rdata)
#define ast_sip_session_register_supplement(supplement)
void ast_sip_session_unregister_supplement(struct ast_sip_session_supplement *supplement)
Unregister a an supplement to SIP session processing.
const char * ast_sorcery_object_get_id(const void *object)
Get the unique identifier of a sorcery object.
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
char *attribute_pure ast_skip_blanks(const char *str)
Gets a pointer to the first non-whitespace character in a string.
unsigned int cause_extended
char chan_name[AST_CHANNEL_NAME]
A supplement to SIP message processing.
int(* incoming_request)(struct ast_sip_session *session, struct pjsip_rx_data *rdata)
Called on incoming SIP request This method can indicate a failure in processing in its return....
A structure describing a SIP session.
struct ast_taskprocessor * ast_threadpool_serializer_get_current(void)
Get the threadpool serializer currently associated with this thread.