当前位置: 首页>>代码示例>>C++>>正文


C++ pjsip_msg_find_hdr_by_name函数代码示例

本文整理汇总了C++中pjsip_msg_find_hdr_by_name函数的典型用法代码示例。如果您正苦于以下问题:C++ pjsip_msg_find_hdr_by_name函数的具体用法?C++ pjsip_msg_find_hdr_by_name怎么用?C++ pjsip_msg_find_hdr_by_name使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了pjsip_msg_find_hdr_by_name函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: timer_supported

void SessionExpiresHelper::process_request(pjsip_msg* req,
                                           pj_pool_t* pool,
                                           SAS::TrailId trail)
{
  // Session expires is only allowed on INVITE and UPDATE methods.
  pjsip_method* method = &req->line.req.method;

  if ((pjsip_method_cmp(method, pjsip_get_invite_method()) != 0) &&
      (pjsip_method_cmp(method, &METHOD_UPDATE) != 0))
  {
    return;
  }

  // Store if this is the initial transaction on a dialog, and if the UAC
  // supports session timers. We need both of these when processing the
  // response.
  _initial_request = (PJSIP_MSG_TO_HDR(req)->tag.slen == 0);
  _uac_supports_timer = timer_supported(req);

  // Find the session-expires header (if present) and the minimum
  // session-expires. Note that the latter has a default value.
  pjsip_session_expires_hdr* se_hdr = (pjsip_session_expires_hdr*)
    pjsip_msg_find_hdr_by_name(req, &STR_SESSION_EXPIRES, NULL);

  pjsip_min_se_hdr* min_se_hdr = (pjsip_min_se_hdr*)
    pjsip_msg_find_hdr_by_name(req, &STR_MIN_SE, NULL);

  SessionInterval min_se = (min_se_hdr != NULL) ?
                            min_se_hdr->expires :
                            DEFAULT_MIN_SE;

  if ((se_hdr != NULL) && (se_hdr->expires < _target_se))
  {
    // The request already has a session expires that is below our target. We
    // don't need to change the value.
    TRC_DEBUG("Session expires already set to %d", se_hdr->expires);
  }
  else
  {
    // No pre-existing session expires, or the current value is greater than
    // our target. Set it to as close to our target as possible, but don't set
    // it below the min-SE.
    if (se_hdr == NULL)
    {
      se_hdr = pjsip_session_expires_hdr_create(pool);
      pjsip_msg_add_hdr(req, (pjsip_hdr*)se_hdr);
    }

    se_hdr->expires = std::max(_target_se, min_se);

    TRC_DEBUG("Set session expires to %d", se_hdr->expires);
  }

  // Make a note of the session expires (we may need it when processing the
  // response)
  _se_on_req = se_hdr->expires;
}
开发者ID:gfraysse,项目名称:sprout,代码行数:57,代码来源:session_expires_helper.cpp

示例2: get_q850_reason_code

/**
 * Get Q.850 reason code from pjsip_event
 */
int get_q850_reason_code(pjsip_event *e) {
	int cause = 0;
	const pj_str_t HDR = { "Reason", 6 };
	pj_bool_t is_q850 = PJ_FALSE;

	if (e->body.tsx_state.type == PJSIP_EVENT_RX_MSG) {

		pjsip_generic_string_hdr *hdr =
				(pjsip_generic_string_hdr*) pjsip_msg_find_hdr_by_name(
						e->body.tsx_state.src.rdata->msg_info.msg, &HDR, NULL);

		if (hdr) {
			char *token = strtok(hdr->hvalue.ptr, ";");
			while (token != NULL) {
				if (!is_q850 && pj_ansi_stricmp(token, "Q.850") == 0) {
					is_q850 = PJ_TRUE;
				} else if (cause == 0) {
					cause = lookup_q850_cause(token);
				}
				token = strtok(NULL, ";");
			}
		}
	}

	return (is_q850) ? cause : 0;
}
开发者ID:mmajid,项目名称:abc-voip,代码行数:29,代码来源:pjsua_jni_addons.c

示例3: rfc3326_use_reason_header

static void rfc3326_use_reason_header(struct ast_sip_session *session, struct pjsip_rx_data *rdata)
{
	const pj_str_t str_reason = { "Reason", 6 };
	pjsip_generic_string_hdr *header = pjsip_msg_find_hdr_by_name(rdata->msg_info.msg, &str_reason, NULL);
	char buf[20], *cause, *text;
	int code;

	if (!header) {
		return;
	}

	ast_copy_pj_str(buf, &header->hvalue, sizeof(buf));
	cause = ast_skip_blanks(buf);

	if (strncasecmp(cause, "Q.850", 5) || !(cause = strstr(cause, "cause="))) {
		return;
	}

	/* If text is present get rid of it */
	if ((text = strstr(cause, ";"))) {
		*text = '\0';
	}

	if (sscanf(cause, "cause=%30d", &code) != 1) {
		return;
	}

	ast_channel_hangupcause_set(session->channel, code & 0x7f);
}
开发者ID:GGGO,项目名称:asterisk,代码行数:29,代码来源:res_pjsip_rfc3326.c

示例4: add_rpid_header

/*!
 * \internal
 * \brief Add a Remote-Party-ID header to an outbound message
 * \param tdata The message to add the header to
 * \param id The identification information used to populate the header
 */
static void add_rpid_header(pjsip_tx_data *tdata, const struct ast_party_id *id)
{
	static const pj_str_t pj_rpid_name = { "Remote-Party-ID", 15 };
	pjsip_fromto_hdr *rpid_hdr;
	pjsip_fromto_hdr *old_rpid;

	if (!id->number.valid) {
		return;
	}

	/* Since inv_session reuses responses, we have to make sure there's not already
	 * a P-Asserted-Identity present. If there is, we just modify the old one.
	 */
	old_rpid = pjsip_msg_find_hdr_by_name(tdata->msg, &pj_rpid_name, NULL);
	if (old_rpid) {
		modify_id_header(tdata->pool, old_rpid, id);
		add_privacy_params(tdata, old_rpid, id);
		return;
	}

	rpid_hdr = create_new_id_hdr(&pj_rpid_name, tdata, id);
	if (!rpid_hdr) {
		return;
	}
	add_privacy_params(tdata, rpid_hdr, id);
	pjsip_msg_add_hdr(tdata->msg, (pjsip_hdr *)rpid_hdr);
}
开发者ID:aderbas,项目名称:asterisk,代码行数:33,代码来源:res_pjsip_caller_id.c

示例5: set_id_from_pai

/*!
 * \internal
 * \brief Set an ast_party_id structure based on data in a P-Asserted-Identity header
 *
 * This makes use of \ref set_id_from_hdr for setting name and number. It uses
 * the contents of a Privacy header in order to set presentation information.
 *
 * \param rdata The incoming message
 * \param[out] id The ID to set
 * \retval 0 Successfully set the party ID
 * \retval non-zero Could not set the party ID
 */
static int set_id_from_pai(pjsip_rx_data *rdata, struct ast_party_id *id)
{
	static const pj_str_t pai_str = { "P-Asserted-Identity", 19 };
	static const pj_str_t privacy_str = { "Privacy", 7 };
	pjsip_fromto_hdr *pai_hdr = get_id_header(rdata, &pai_str);
	pjsip_generic_string_hdr *privacy;

	if (!pai_hdr) {
		return -1;
	}

	set_id_from_hdr(pai_hdr, id);

	if (!id->number.valid) {
		return -1;
	}

	privacy = pjsip_msg_find_hdr_by_name(rdata->msg_info.msg, &privacy_str, NULL);
	if (privacy && !pj_stricmp2(&privacy->hvalue, "id")) {
		id->number.presentation = AST_PRES_PROHIB_USER_NUMBER_NOT_SCREENED;
		id->name.presentation = AST_PRES_PROHIB_USER_NUMBER_NOT_SCREENED;
	} else {
		id->number.presentation = AST_PRES_ALLOWED_USER_NUMBER_NOT_SCREENED;
		id->name.presentation = AST_PRES_ALLOWED_USER_NUMBER_NOT_SCREENED;
	}

	return 0;
}
开发者ID:brandonshults01,项目名称:asterisk,代码行数:40,代码来源:res_pjsip_caller_id.c

示例6: get_vox_error_info

/**
 * VoX Mobile :: negative SIP response handler
 */
int get_vox_error_info(pjsip_event *e)
{
    int cause = 0;
    const pj_str_t HDR = { "Error-Info", 10 };
    const pj_str_t BLOCKED_PSTN = { "PSTN not allowed", 16 };
    const pj_str_t BLOCKED_DESTINATION = { "Blocked destination", 19 };

    if (e->body.tsx_state.type == PJSIP_EVENT_RX_MSG) {

        pjsip_generic_string_hdr *hdr = (pjsip_generic_string_hdr*)pjsip_msg_find_hdr_by_name(
                                         e->body.tsx_state.src.rdata->msg_info.msg,
                                         &HDR,
                                         NULL);

        if (hdr) {
            if (pj_strcmp(&hdr->hvalue, &BLOCKED_PSTN) == 0)
                cause = 403;
            else if (pj_strcmp(&hdr->hvalue, &BLOCKED_DESTINATION) == 0)
                cause = 580;
            else {
                cause = (int)pj_strtoul(&hdr->hvalue);
            }
        }
    }

    return cause;
}
开发者ID:RockHardJim,项目名称:voxmobile,代码行数:30,代码来源:reason_parser.c

示例7: get_reason_code

/**
 * Get TAG reason code from pjsip_event
 */
int get_reason_code(pjsip_event *e, char* tag, int (*code_parser)(const char*)) {
	int code = 0;
	const pj_str_t HDR = { "Reason", 6 };
	pj_bool_t has_tag = PJ_FALSE;

	if (e->body.tsx_state.type == PJSIP_EVENT_RX_MSG) {

		pjsip_generic_string_hdr *hdr =
				(pjsip_generic_string_hdr*) pjsip_msg_find_hdr_by_name(
						e->body.tsx_state.src.rdata->msg_info.msg, &HDR, NULL);

		// TODO : check if the header should not be parsed here? -- I don't see how it could work without parsing.
		if (hdr) {
	        char *reason_header = strdup(hdr->hvalue.ptr);
			char *token = strtok(reason_header, ";");
			while (token != NULL) {
				if (!has_tag && pj_ansi_stricmp(token, tag) == 0) {
				    has_tag = PJ_TRUE;
				} else if (code == 0) {
				    code = code_parser(token);
				}
				token = strtok(NULL, ";");
			}
			free(reason_header);
		}
	}

	return (has_tag) ? code : 0;
}
开发者ID:RockHardJim,项目名称:voxmobile,代码行数:32,代码来源:reason_parser.c

示例8: PJ_DECL

PJ_DECL(pj_str_t) get_rx_data_header(const pj_str_t name, pjsip_rx_data* data){
	pjsip_generic_string_hdr *hdr =
			(pjsip_generic_string_hdr*) pjsip_msg_find_hdr_by_name(data->msg_info.msg, &name, NULL);
	if (hdr && hdr->hvalue.ptr) {
		return hdr->hvalue;
	}
	return pj_str("");
}
开发者ID:ChrisKwon,项目名称:spore,代码行数:8,代码来源:pjsua_jni_addons.c

示例9: while

/// Remove all existing copies of a header.  The header to delete must
/// not be one that has an abbreviation.
void PJUtils::remove_hdr(pjsip_msg* msg,
                         const pj_str_t* name)
{
  while (pjsip_hdr* hdr = (pjsip_hdr*)pjsip_msg_find_hdr_by_name(msg, name, NULL))
  {
    pj_list_erase(hdr);
  }
}
开发者ID:oldurecu,项目名称:sprout,代码行数:10,代码来源:pjutils.cpp

示例10: has_call_feature

static int has_call_feature(pjsip_rx_data *rdata)
{
	static const pj_str_t call_feature_str = { "X-Digium-Call-Feature", 21 };

	pjsip_generic_string_hdr *hdr = pjsip_msg_find_hdr_by_name(
		rdata->msg_info.msg, &call_feature_str, NULL);

	return hdr && !pj_stricmp2(&hdr->hvalue, SEND_TO_VM_HEADER_VALUE);
}
开发者ID:auntieNeo,项目名称:asterisk,代码行数:9,代码来源:res_pjsip_send_to_voicemail.c

示例11: pjsip_msg_find_hdr_by_name

/// Determine the served user for originating requests.
pjsip_uri* PJUtils::orig_served_user(pjsip_msg* msg)
{
  // The served user for originating requests is determined from the
  // P-Served-User or P-Asserted-Identity headers.  For extra compatibility,
  // we will also look at the From header if neither of the IMS headers is
  // present.
  pjsip_uri* uri = NULL;
  pjsip_routing_hdr* served_user = (pjsip_routing_hdr*)
                     pjsip_msg_find_hdr_by_name(msg, &STR_P_SERVED_USER, NULL);

  if (served_user != NULL)
  {
    uri = (pjsip_uri*)pjsip_uri_get_uri(&served_user->name_addr);
    LOG_DEBUG("Served user from P-Served-User header");
  }

  if (uri == NULL)
  {
    // No P-Served-User header present, so check for P-Asserted-Identity
    // header.
    pjsip_routing_hdr* asserted_id = (pjsip_routing_hdr*)
               pjsip_msg_find_hdr_by_name(msg, &STR_P_ASSERTED_IDENTITY, NULL);

    if (asserted_id != NULL)
    {
      uri = (pjsip_uri*)pjsip_uri_get_uri(&asserted_id->name_addr);
      LOG_DEBUG("Served user from P-Asserted-Identity header");
    }
  }

  if (uri == NULL)
  {
    // Neither IMS header is present, so use the From header.  This isn't
    // strictly speaking IMS compliant.
    LOG_DEBUG("From header %p", PJSIP_MSG_FROM_HDR(msg));
    uri = (pjsip_uri*)pjsip_uri_get_uri(PJSIP_MSG_FROM_HDR(msg)->uri);
    LOG_DEBUG("Served user from From header (%p)", uri);
  }

  return uri;
}
开发者ID:oldurecu,项目名称:sprout,代码行数:42,代码来源:pjutils.cpp

示例12: build_path_data

static int build_path_data(pjsip_rx_data *rdata, struct ast_str **path_str)
{
	pjsip_generic_string_hdr *path_hdr = pjsip_msg_find_hdr_by_name(rdata->msg_info.msg, &path_hdr_name, NULL);

	if (!path_hdr) {
		return 0;
	}

	*path_str = ast_str_create(64);
	if (!path_str) {
		return -1;
	}

	ast_str_set(path_str, 0, "%.*s", (int)path_hdr->hvalue.slen, path_hdr->hvalue.ptr);

	while ((path_hdr = (pjsip_generic_string_hdr *) pjsip_msg_find_hdr_by_name(rdata->msg_info.msg, &path_hdr_name, path_hdr->next))) {
		ast_str_append(path_str, 0, ",%.*s", (int)path_hdr->hvalue.slen, path_hdr->hvalue.ptr);
	}

	return 0;
}
开发者ID:edvinanet,项目名称:asterisk,代码行数:21,代码来源:res_pjsip_registrar.c

示例13: while

void PJUtils::clone_header(const pj_str_t* hdr_name, pjsip_msg* old_msg, pjsip_msg* new_msg, pj_pool_t* pool)
{
  pjsip_hdr* original_hdr = NULL;
  pjsip_hdr* last_hdr = NULL;
  while ((original_hdr = (pjsip_hdr*)pjsip_msg_find_hdr_by_name(old_msg, hdr_name, original_hdr)) && (last_hdr != original_hdr))
  {
    LOG_INFO("Cloning header! %ld", (long int)original_hdr);
    pjsip_hdr* new_hdr = (pjsip_hdr*)pjsip_hdr_clone(pool, original_hdr);
    pjsip_msg_add_hdr(new_msg, new_hdr);
    last_hdr = original_hdr;
  }
}
开发者ID:telecore-ivan,项目名称:sprout,代码行数:12,代码来源:pjutils.cpp

示例14: add_diversion_header

/*!
 * \internal
 * \brief Adds diversion header information to an outbound SIP message
 *
 * \param tdata The outbound message
 * \param data The redirecting data used to fill parts of the diversion header
 */
static void add_diversion_header(pjsip_tx_data *tdata, struct ast_party_redirecting *data)
{
	pjsip_fromto_hdr *hdr;
	pjsip_name_addr *name_addr;
	pjsip_sip_uri *uri;
	pjsip_param *param;
	pjsip_fromto_hdr *old_hdr;
	const char *reason_str;
	const char *quote_str;
	char *reason_buf;

	struct ast_party_id *id = &data->from;
	pjsip_uri *base = PJSIP_MSG_FROM_HDR(tdata->msg)->uri;

	if (!id->number.valid || ast_strlen_zero(id->number.str)) {
		return;
	}

	hdr = pjsip_from_hdr_create(tdata->pool);
	hdr->type = PJSIP_H_OTHER;
	pj_strdup(tdata->pool, &hdr->name, &diversion_name);
	hdr->sname = hdr->name;

	name_addr = pjsip_uri_clone(tdata->pool, base);
	uri = pjsip_uri_get_uri(name_addr->uri);

	pj_strdup2(tdata->pool, &name_addr->display, id->name.str);
	pj_strdup2(tdata->pool, &uri->user, id->number.str);

	param = PJ_POOL_ALLOC_T(tdata->pool, pjsip_param);
	param->name = pj_str("reason");

	reason_str = reason_code_to_str(&data->reason);

	/* Reason is either already quoted or it is a token to not need quotes added. */
	quote_str = *reason_str == '\"' || sip_is_token(reason_str) ? "" : "\"";

	reason_buf = pj_pool_alloc(tdata->pool, strlen(reason_str) + 3);
	sprintf(reason_buf, "%s%s%s", quote_str, reason_str, quote_str);/* Safe */

	param->value = pj_str(reason_buf);

	pj_list_insert_before(&hdr->other_param, param);

	hdr->uri = (pjsip_uri *) name_addr;
	old_hdr = pjsip_msg_find_hdr_by_name(tdata->msg, &diversion_name, NULL);
	if (old_hdr) {
		pj_list_erase(old_hdr);
	}
	pjsip_msg_add_hdr(tdata->msg, (pjsip_hdr *)hdr);
}
开发者ID:litnimax,项目名称:asterisk,代码行数:58,代码来源:res_pjsip_diversion.c

示例15: pjsip_parse_hdr

static pjsip_fromto_hdr *get_diversion_header(pjsip_rx_data *rdata)
{
	static const pj_str_t from_name = { "From", 4 };

	pjsip_generic_string_hdr *hdr;
	pj_str_t value;
	int size;

	if (!(hdr = pjsip_msg_find_hdr_by_name(rdata->msg_info.msg, &diversion_name, NULL))) {
		return NULL;
	}

	pj_strdup_with_null(rdata->tp_info.pool, &value, &hdr->hvalue);

	/* parse as a fromto header */
	return pjsip_parse_hdr(rdata->tp_info.pool, &from_name, value.ptr,
			       pj_strlen(&value), &size);
}
开发者ID:litnimax,项目名称:asterisk,代码行数:18,代码来源:res_pjsip_diversion.c


注:本文中的pjsip_msg_find_hdr_by_name函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。