65 && !strchr(
"-.!%*_+`'~", *
str)) {
122 pjsip_supported_hdr *hdr;
125 hdr = pjsip_msg_find_hdr(tdata->msg, PJSIP_H_SUPPORTED,
NULL);
128 hdr = pjsip_supported_hdr_create(tdata->pool);
133 pjsip_msg_add_hdr(tdata->msg, (pjsip_hdr *)hdr);
139 for (i = 0; i < hdr->count; ++i) {
145 if (hdr->count >= PJSIP_GENERIC_ARRAY_MAX_COUNT) {
192 static const pj_str_t from_name = {
"From", 4 };
194 pjsip_generic_string_hdr *hdr;
198 if (!(hdr = pjsip_msg_find_hdr_by_name(rdata->msg_info.msg, &
diversion_name,
NULL))) {
202 pj_strdup_with_null(rdata->tp_info.pool, &
value, &hdr->hvalue);
205 return pjsip_parse_hdr(rdata->tp_info.pool, &from_name,
value.ptr,
206 pj_strlen(&
value), &size);
217 static const pj_str_t from_name = {
"From", 4 };
218 pjsip_fromto_hdr * result_hdr =
NULL;
220 pjsip_generic_string_hdr *hdr =
NULL;
229 static const pj_str_t index_name = {
"index", 5 };
232 pjsip_fromto_hdr * fromto_hdr =
NULL;
233 pjsip_param * index =
NULL;
235 pj_strdup_with_null(rdata->tp_info.pool, &
value, &hdr->hvalue);
238 fromto_hdr = pjsip_parse_hdr(rdata->tp_info.pool, &from_name,
value.ptr,
239 pj_strlen(&
value), &size);
241 if (fromto_hdr ==
NULL) {
245 index = pjsip_param_find(&fromto_hdr->other_param, &index_name);
248 if (!pj_strcmp2(&index->value,
"1")) {
257 result_hdr = fromto_hdr;
259 }
while ((hdr = pjsip_msg_find_hdr_by_name(rdata->msg_info.msg, &
history_info_name, hdr->next)));
276 pjsip_sip_uri *uri = pjsip_uri_get_uri(name_addr->uri);
280 uri_user = uri->user;
283 semi = pj_strchr(&uri_user,
';');
296 pj_strset(&uri_user, (
char *) pj_strbuf(&uri_user), semi - pj_strbuf(&uri_user));
299 if (pj_strlen(&uri_user)) {
305 if (pj_strlen(&name_addr->display)) {
329 static const pj_str_t cause_name = {
"cause", 5 };
330 pjsip_uri *uri = name_addr->uri;
331 pjsip_param *cause =
NULL;
332 unsigned long cause_value = 0;
344 cause_value = pj_strtoul(&cause->value);
354 static const pj_str_t reason_name = {
"reason", 6 };
355 pjsip_param *reason = pjsip_param_find(&from_info->other_param, &reason_name);
373 if (*reason_str ==
'"') {
378 if (data->
code < 0) {
387 pjsip_fromto_hdr *from_info,
388 pjsip_name_addr *to_info)
421 if (
session->inv_session->role == PJSIP_ROLE_UAC) {
433 PJSIP_MSG_TO_HDR(rdata->msg_info.msg)->uri);
435 pjsip_fromto_hdr *history_info_to;
436 pjsip_fromto_hdr *history_info_from;
439 if (history_info_to) {
452 static const pj_str_t contact_name = {
"Contact", 7 };
453 static const pj_str_t contact_name_s = {
"m", 1 };
455 pjsip_status_line
status = rdata->msg_info.msg->line.status;
456 pjsip_fromto_hdr *div_hdr;
457 pjsip_fromto_hdr *history_info_to;
458 pjsip_fromto_hdr *history_info_from;
459 pjsip_contact_hdr *contact_hdr;
471 if (history_info_to) {
478 if (!div_hdr && !
session->id.number.valid) {
479 div_hdr = PJSIP_MSG_TO_HDR(rdata->msg_info.msg);
486 contact_hdr = pjsip_msg_find_hdr_by_names(rdata->msg_info.msg, &contact_name, &contact_name_s,
NULL);
489 (pjsip_name_addr*)PJSIP_MSG_FROM_HDR(rdata->msg_info.msg)->uri);
493 div_hdr ? (pjsip_name_addr*)div_hdr->uri :
NULL);
506 static const pj_str_t reason_name = {
"reason", 6 };
508 pjsip_fromto_hdr *hdr;
509 pjsip_name_addr *name_addr;
511 pjsip_fromto_hdr *old_hdr;
512 const char *reason_str;
513 const char *quote_str;
518 if (tdata->msg->type == PJSIP_REQUEST_MSG) {
525 base = PJSIP_MSG_FROM_HDR(tdata->msg)->uri;
531 hdr = pjsip_from_hdr_create(tdata->pool);
532 hdr->type = PJSIP_H_OTHER;
535 name_addr = pjsip_uri_clone(tdata->pool, base);
537 pj_strdup2(tdata->pool, &name_addr->display,
id->name.str);
540 param = PJ_POOL_ALLOC_T(tdata->pool, pjsip_param);
541 param->name = reason_name;
546 quote_str = *reason_str ==
'\"' ||
sip_is_token(reason_str) ?
"" :
"\"";
548 reason_buf = pj_pool_alloc(tdata->pool, strlen(reason_str) + 3);
549 sprintf(reason_buf,
"%s%s%s", quote_str, reason_str, quote_str);
551 param->value = pj_str(reason_buf);
553 pj_list_insert_before(&hdr->other_param, param);
555 hdr->uri = (pjsip_uri *) name_addr;
558 pj_list_erase(old_hdr);
560 pjsip_msg_add_hdr(tdata->msg, (pjsip_hdr *)hdr);
572 static const pj_str_t index_name = {
"index", 5 };
573 static const pj_str_t cause_name = {
"cause", 5 };
574 static const pj_str_t first_index = {
"1", 1 };
575 static const pj_str_t last_index = {
"1.1", 3 };
577 pjsip_fromto_hdr *hdr;
578 pjsip_name_addr *name_addr;
581 pjsip_fromto_hdr *old_hdr;
588 pjsip_uri *base = PJSIP_MSG_TO_HDR(tdata->msg)->uri;
591 hdr = pjsip_from_hdr_create(tdata->pool);
592 hdr->type = PJSIP_H_OTHER;
595 name_addr = pjsip_uri_clone(tdata->pool, base);
596 uri = pjsip_uri_get_uri(name_addr->uri);
600 pj_strdup2(tdata->pool, &name_addr->display, from->
name.
str);
601 pj_strdup2(tdata->pool, &uri->user, from->
number.
str);
604 param = PJ_POOL_ALLOC_T(tdata->pool, pjsip_param);
605 param->name = index_name;
606 param->value = first_index;
609 pj_list_insert_before(&hdr->other_param, param);
610 hdr->uri = (pjsip_uri *) name_addr;
613 pj_list_erase(old_hdr);
616 pjsip_msg_add_hdr(tdata->msg, (pjsip_hdr *)hdr);
622 hdr = pjsip_from_hdr_create(tdata->pool);
623 hdr->type = PJSIP_H_OTHER;
626 name_addr = pjsip_uri_clone(tdata->pool, base);
627 uri = pjsip_uri_get_uri(name_addr->uri);
629 pj_strdup2(tdata->pool, &name_addr->display, to->
name.
str);
630 pj_strdup2(tdata->pool, &uri->user, to->
number.
str);
632 param = PJ_POOL_ALLOC_T(tdata->pool, pjsip_param);
633 param->name = index_name;
634 param->value = last_index;
635 pj_list_insert_before(&hdr->other_param, param);
637 param = PJ_POOL_ALLOC_T(tdata->pool, pjsip_param);
638 param->name = cause_name;
640 cause_buf = pj_pool_alloc(tdata->pool, 4);
641 snprintf(cause_buf, 4,
"%ud", cause);
642 param->value = pj_str(cause_buf);
643 pj_list_insert_before(&uri->other_param, param);
644 hdr->uri = (pjsip_uri *) name_addr;
646 pjsip_msg_add_hdr(tdata->msg, (pjsip_hdr *)hdr);
659 if (
session->channel &&
session->endpoint->id.send_history_info) {
687 struct pjsip_status_line
status = tdata->msg->line.status;
690 if (PJSIP_IS_STATUS_IN_CLASS(
status.code, 300) || (
status.code == 181)) {
727 .
requires =
"res_pjsip,res_pjsip_session",
struct sla_ringing_trunk * first
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_strdupa(s)
duplicate a string in memory from the stack
#define ast_malloc(len)
A wrapper for malloc()
CallerID (and other GR30) management and generation Includes code and algorithms from the Zapata libr...
AST_REDIRECTING_REASON
redirecting reason codes.
@ AST_REDIRECTING_REASON_AWAY
@ AST_REDIRECTING_REASON_UNKNOWN
@ AST_REDIRECTING_REASON_SEND_TO_VM
@ AST_REDIRECTING_REASON_NO_ANSWER
@ AST_REDIRECTING_REASON_DO_NOT_DISTURB
@ AST_REDIRECTING_REASON_FOLLOW_ME
@ AST_REDIRECTING_REASON_DEFLECTION
@ AST_REDIRECTING_REASON_UNAVAILABLE
@ AST_REDIRECTING_REASON_UNCONDITIONAL
@ AST_REDIRECTING_REASON_CALL_FWD_DTE
@ AST_REDIRECTING_REASON_OUT_OF_ORDER
@ AST_REDIRECTING_REASON_TIME_OF_DAY
@ AST_REDIRECTING_REASON_USER_BUSY
int ast_redirecting_reason_parse(const char *data)
Convert redirecting reason text code to value (used in config file parsing)
General Asterisk PBX channel definitions.
void ast_party_redirecting_init(struct ast_party_redirecting *init)
Initialize the given redirecting structure.
void ast_channel_set_redirecting(struct ast_channel *chan, const struct ast_party_redirecting *redirecting, const struct ast_set_party_redirecting *update)
Set the redirecting id information in the Asterisk channel.
struct ast_party_redirecting * ast_channel_redirecting(struct ast_channel *chan)
void ast_channel_queue_redirecting_update(struct ast_channel *chan, const struct ast_party_redirecting *redirecting, const struct ast_set_party_redirecting *update)
Queue a redirecting update frame on a channel.
void ast_set_party_id_all(struct ast_set_party_id *update_id)
Set the update marker to update all information of a corresponding party id.
void ast_party_id_copy(struct ast_party_id *dest, const struct ast_party_id *src)
Copy the source party id information to the destination party id.
void ast_party_redirecting_free(struct ast_party_redirecting *doomed)
Destroy the redirecting information contents.
static void update(int code_size, int y, int wi, int fi, int dq, int sr, int dqsez, struct g726_state *state_ptr)
Asterisk module definitions.
#define ast_module_shutdown_ref(mod)
Prevent unload of the module before shutdown.
#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
struct pjsip_param * ast_sip_pjsip_uri_get_other_param(pjsip_uri *uri, const pj_str_t *param_str)
Find an 'other' SIP/SIPS URI parameter by name.
const pj_str_t * ast_sip_pjsip_uri_get_username(pjsip_uri *uri)
Get the user portion of the pjsip_uri.
int ast_sip_is_allowed_uri(pjsip_uri *uri)
Check whether a pjsip_uri is allowed or not.
@ AST_SIP_SUPPLEMENT_PRIORITY_CHANNEL
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.
static void set_redirecting_reason(pjsip_fromto_hdr *from_info, pjsip_name_addr *to_info, struct ast_party_redirecting_reason *data)
static const struct reasons reason_table[]
static pjsip_fromto_hdr * get_history_info_header(pjsip_rx_data *rdata, const unsigned int first)
static const unsigned int reason_code_to_cause(const struct ast_party_redirecting_reason *reason)
static void add_history_info_header(pjsip_tx_data *tdata, struct ast_party_redirecting *data)
static void set_redirecting_reason_by_cause(pjsip_name_addr *name_addr, struct ast_party_redirecting_reason *data)
static const pj_str_t history_info_name
static int add_supported(pjsip_tx_data *tdata)
static pj_str_t HISTINFO_SUPPORTED_NAME
static pjsip_fromto_hdr * get_diversion_header(pjsip_rx_data *rdata)
static int diversion_incoming_request(struct ast_sip_session *session, pjsip_rx_data *rdata)
static void diversion_outgoing_request(struct ast_sip_session *session, pjsip_tx_data *tdata)
static const pj_str_t diversion_name
static void diversion_outgoing_response(struct ast_sip_session *session, pjsip_tx_data *tdata)
static void set_redirecting(struct ast_sip_session *session, pjsip_fromto_hdr *from_info, pjsip_name_addr *to_info)
static void get_redirecting_add_diversion(struct ast_sip_session *session, pjsip_tx_data *tdata)
static void set_redirecting_value(char **dst, const pj_str_t *src)
static void set_redirecting_id(pjsip_name_addr *name_addr, struct ast_party_id *data, struct ast_set_party_id *update)
static int load_module(void)
static const char * reason_code_to_str(const struct ast_party_redirecting_reason *reason)
static int unload_module(void)
static void diversion_incoming_response(struct ast_sip_session *session, pjsip_rx_data *rdata)
static int sip_is_token(const char *str)
static enum AST_REDIRECTING_REASON cause_to_reason(const unsigned long cause)
static void add_diversion_header(pjsip_tx_data *tdata, struct ast_party_redirecting *data)
static void copy_redirecting_id(struct ast_party_id *dst, const struct ast_party_id *src, struct ast_set_party_id *update)
static struct ast_sip_session_supplement diversion_supplement
@ AST_SIP_SESSION_BEFORE_MEDIA
#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.
String manipulation functions.
static force_inline int attribute_pure ast_strlen_zero(const char *s)
char * ast_strip_quoted(char *s, const char *beg_quotes, const char *end_quotes)
Strip leading/trailing whitespace and quotes from a string.
Information needed to identify an endpoint in a call.
struct ast_party_name name
Subscriber name.
struct ast_party_number number
Subscriber phone number.
unsigned char valid
TRUE if the name information is valid/present.
char * str
Subscriber name (Malloced)
unsigned char valid
TRUE if the number information is valid/present.
char * str
Subscriber phone number (Malloced)
Redirecting reason information.
int code
enum AST_REDIRECTING_REASON value for redirection
char * str
a string value for the redirecting reason
Redirecting Line information. RDNIS (Redirecting Directory Number Information Service) Where a call d...
struct ast_party_redirecting_reason reason
Reason for the redirection.
struct ast_party_id from
Who is redirecting the call (Sent to the party the call is redirected toward)
int count
Number of times the call was redirected.
struct ast_party_id to
Call is redirecting to a new party (Sent to the caller)
Indicate what information in ast_party_id should be set.
Indicate what information in ast_party_redirecting should be set.
A supplement to SIP message processing.
A structure describing a SIP session.
Diversion header reasons.
enum AST_REDIRECTING_REASON code