38{
39 static const pj_str_t str_reason = { "Reason", 6 };
40 pjsip_generic_string_hdr *
header;
42 char *cause;
43 int code_q850 = 0, code_sip = 0;
44
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);
51
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) {
60 }
61
62
63
64
65 data_size += 4 + strlen(cause) + 1;
67 memset(cause_code, 0, data_size);
69 snprintf(cause_code->
code, data_size,
"SIP %s", cause);
70
72 if (code_q850) {
74 } else if (code_sip) {
76 }
79 }
80 }
81
82 if (code_q850) {
84 } else if (code_sip) {
86 }
87}
#define ast_alloca(size)
call __builtin_alloca to ensure we get gcc builtin semantics
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.
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.
void ast_channel_hangupcause_set(struct ast_channel *chan, int value)
@ AST_CONTROL_PVT_CAUSE_CODE
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.
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]