• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ pjsip_msg_find_hdr函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: while

/// Gets the maximum expires value from all contacts in a REGISTER message
/// (request or response).
int PJUtils::max_expires(pjsip_msg* msg)
{
  int max_expires = 0;

  // Check for an expires header (this will specify the default expiry for
  // any contacts that don't specify their own expiry).
  pjsip_expires_hdr* expires_hdr = (pjsip_expires_hdr*)pjsip_msg_find_hdr(msg, PJSIP_H_EXPIRES, NULL);
  int default_expires = (expires_hdr != NULL) ? expires_hdr->ivalue : 300;

  pjsip_contact_hdr* contact = (pjsip_contact_hdr*)pjsip_msg_find_hdr(msg, PJSIP_H_CONTACT, NULL);

  while (contact != NULL)
  {
    int expires = (contact->expires != -1) ? contact->expires : default_expires;
    if (expires > max_expires)
    {
      max_expires = expires;
    }
    contact = (pjsip_contact_hdr*)pjsip_msg_find_hdr(msg, PJSIP_H_CONTACT, contact->next);
  }

  return max_expires;
}
开发者ID:telecore-ivan,项目名称:sprout,代码行数:25,代码来源:pjutils.cpp


示例2: cid_marker

/// Add SAS markers for the specified call ID and branch IDs on the message (either may be omitted).
void PJUtils::mark_sas_call_branch_ids(const SAS::TrailId trail, pjsip_cid_hdr* cid_hdr, pjsip_msg* msg)
{
  // If we have a call ID, log it.
  if (cid_hdr != NULL)
  {
    SAS::Marker cid_marker(trail, MARKER_ID_SIP_CALL_ID, 1u);
    cid_marker.add_var_param(cid_hdr->id.slen, cid_hdr->id.ptr);
    SAS::report_marker(cid_marker, SAS::Marker::Scope::Trace);
  }

  // If we have a message, look for branch IDs too.
  if (msg != NULL)
  {
    // First find the top Via header.  This was added by us.
    pjsip_via_hdr* top_via = (pjsip_via_hdr*)pjsip_msg_find_hdr(msg, PJSIP_H_VIA, NULL);

    // If we found the top header (and we really should have done), log its branch ID.
    if (top_via != NULL)
    {
      {
        SAS::Marker via_marker(trail, MARKER_ID_VIA_BRANCH_PARAM, 1u);
        via_marker.add_var_param(top_via->branch_param.slen, top_via->branch_param.ptr);
        SAS::report_marker(via_marker, SAS::Marker::Scope::Trace);
      }

      // Now see if we can find the next Via header and log it if so.  This will have been added by
      // the previous server.  This means we'll be able to correlate with its trail.
      pjsip_via_hdr* second_via = (pjsip_via_hdr*)pjsip_msg_find_hdr(msg, PJSIP_H_VIA, top_via);
      if (second_via != NULL)
      {
        SAS::Marker via_marker(trail, MARKER_ID_VIA_BRANCH_PARAM, 2u);
        via_marker.add_var_param(second_via->branch_param.slen, second_via->branch_param.ptr);
        SAS::report_marker(via_marker, SAS::Marker::Scope::Trace);
      }
    }
  }
}
开发者ID:oldurecu,项目名称:sprout,代码行数:38,代码来源:pjutils.cpp


示例3: send_request

/* Send request */
static void send_request(const pjsip_method *method,
			 int cseq,
			 const pj_str_t *branch,
			 pj_bool_t with_offer)
{
    pjsip_tx_data *tdata;
    pj_str_t dummy_sdp_str = 
    {
	"v=0\r\n"
	"o=- 3360842071 3360842071 IN IP4 192.168.0.68\r\n"
	"s=pjmedia\r\n"
	"c=IN IP4 192.168.0.68\r\n"
	"t=0 0\r\n"
	"m=audio 4000 RTP/AVP 0 101\r\n"
	"a=rtcp:4001 IN IP4 192.168.0.68\r\n"
	"a=rtpmap:0 PCMU/8000\r\n"
	"a=sendrecv\r\n"
	"a=rtpmap:101 telephone-event/8000\r\n"
	"a=fmtp:101 0-15\r\n",
	0
    };
    pj_status_t status;

    status = pjsip_dlg_create_request(dlg, method, cseq, &tdata);
    pj_assert(status == PJ_SUCCESS);

    if (branch) {
	pjsip_via_hdr *via;

	via = (pjsip_via_hdr*) pjsip_msg_find_hdr(tdata->msg, PJSIP_H_VIA, NULL);
	pj_strdup(tdata->pool, &via->branch_param, branch);
    }

    if (with_offer) {
	pjsip_msg_body *body;
	pj_str_t mime_application = { "application", 11};
	pj_str_t mime_sdp = {"sdp", 3};


	dummy_sdp_str.slen = pj_ansi_strlen(dummy_sdp_str.ptr);
	body = pjsip_msg_body_create(tdata->pool, 
				     &mime_application, &mime_sdp, 
				     &dummy_sdp_str);
	tdata->msg->body = body;
    }

    status = pjsip_dlg_send_request(dlg, tdata, -1, NULL);
    pj_assert(status == PJ_SUCCESS);
}
开发者ID:deveck,项目名称:Deveck.TAM,代码行数:50,代码来源:invtester.c


示例4: simple_registrar

/*
 * A simple registrar, invoked by default_mod_on_rx_request()
 */
static void simple_registrar(pjsip_rx_data *rdata)
{
    pjsip_tx_data *tdata;
    const pjsip_expires_hdr *exp;
    const pjsip_hdr *h;
    unsigned cnt = 0;
    pjsip_generic_string_hdr *srv;
    pj_status_t status;

    status = pjsip_endpt_create_response(pjsua_get_pjsip_endpt(),
				 rdata, 200, NULL, &tdata);
    if (status != PJ_SUCCESS)
	return;

    exp = (pjsip_expires_hdr*)
	  pjsip_msg_find_hdr(rdata->msg_info.msg, PJSIP_H_EXPIRES, NULL);

    h = rdata->msg_info.msg->hdr.next;
    while (h != &rdata->msg_info.msg->hdr) {
	if (h->type == PJSIP_H_CONTACT) {
	    const pjsip_contact_hdr *c = (const pjsip_contact_hdr*)h;
	    int e = c->expires;

	    if (e < 0) {
		if (exp)
		    e = exp->ivalue;
		else
		    e = 3600;
	    }

	    if (e > 0) {
		pjsip_contact_hdr *nc = (pjsip_contact_hdr*)
					pjsip_hdr_clone(tdata->pool, h);
		nc->expires = e;
		pjsip_msg_add_hdr(tdata->msg, (pjsip_hdr*)nc);
		++cnt;
	    }
	}
	h = h->next;
    }

    srv = pjsip_generic_string_hdr_create(tdata->pool, NULL, NULL);
    srv->name = pj_str((char*)"Server");
    srv->hvalue = pj_str((char*)"pjsua simple registrar");
    pjsip_msg_add_hdr(tdata->msg, (pjsip_hdr*)srv);

    pjsip_endpt_send_response2(pjsua_get_pjsip_endpt(),
                               rdata, tdata, NULL, NULL);
}
开发者ID:avble,项目名称:natClientEx,代码行数:52,代码来源:vidgui.cpp


示例5: digest_create_request_with_auth_from_old

static int digest_create_request_with_auth_from_old(const struct ast_sip_auth_vector *auths, pjsip_rx_data *challenge,
		pjsip_tx_data *old_request, pjsip_tx_data **new_request)
{
	pjsip_auth_clt_sess auth_sess;
	pjsip_cseq_hdr *cseq;

	if (pjsip_auth_clt_init(&auth_sess, ast_sip_get_pjsip_endpoint(),
				old_request->pool, 0) != PJ_SUCCESS) {
		ast_log(LOG_WARNING, "Failed to initialize client authentication session\n");
		return -1;
	}

	if (set_outbound_authentication_credentials(&auth_sess, auths, challenge)) {
		ast_log(LOG_WARNING, "Failed to set authentication credentials\n");
		return -1;
	}

	switch (pjsip_auth_clt_reinit_req(&auth_sess, challenge,
				old_request, new_request)) {
	case PJ_SUCCESS:
		/* PJSIP creates a new transaction for new_request (meaning it creates a new
		 * branch). However, it recycles the Call-ID, from-tag, and CSeq from the
		 * original request. Some SIP implementations will not process the new request
		 * since the CSeq is the same as the original request. Incrementing it here
		 * fixes the interop issue
		 */
		cseq = pjsip_msg_find_hdr((*new_request)->msg, PJSIP_H_CSEQ, NULL);
		ast_assert(cseq != NULL);
		++cseq->cseq;
		return 0;
	case PJSIP_ENOCREDENTIAL:
		ast_log(LOG_WARNING, "Unable to create request with auth."
				"No auth credentials for any realms in challenge.\n");
		break;
	case PJSIP_EAUTHSTALECOUNT:
		ast_log(LOG_WARNING, "Unable to create request with auth."
				"Number of stale retries exceeded\n");
		break;
	case PJSIP_EFAILEDCREDENTIAL:
		ast_log(LOG_WARNING, "Authentication credentials not accepted by server\n");
		break;
	default:
		ast_log(LOG_WARNING, "Unable to create request with auth. Unknown failure\n");
		break;
	}

	return -1;
}
开发者ID:MattheusNiels,项目名称:BackupCerberus,代码行数:48,代码来源:res_pjsip_outbound_authenticator_digest.c


示例6: find_challenge

static int find_challenge(const pjsip_rx_data *rdata, const struct ast_sip_auth *auth)
{
	struct pjsip_authorization_hdr *auth_hdr = (pjsip_authorization_hdr *) &rdata->msg_info.msg->hdr;
	int challenge_found = 0;
	char nonce[64];

	while ((auth_hdr = (pjsip_authorization_hdr *) pjsip_msg_find_hdr(rdata->msg_info.msg, PJSIP_H_AUTHORIZATION, auth_hdr->next))) {
		ast_copy_pj_str(nonce, &auth_hdr->credential.digest.nonce, sizeof(nonce));
		if (check_nonce(nonce, rdata, auth) && !pj_strcmp2(&auth_hdr->credential.digest.realm, auth->realm)) {
			challenge_found = 1;
			break;
		}
	}

	return challenge_found;
}
开发者ID:aderbas,项目名称:asterisk,代码行数:16,代码来源:res_pjsip_authenticator_digest.c


示例7: msg_supports_extension

/// Checks whether the supplied message contains the extension in the
/// Supported header.
pj_bool_t PJUtils::msg_supports_extension(pjsip_msg* msg, const char* extension)
{
  pjsip_supported_hdr* supported_hdr = (pjsip_supported_hdr*)pjsip_msg_find_hdr(msg, PJSIP_H_SUPPORTED, NULL);
  if (!supported_hdr)
  {
    return PJ_FALSE;
  }
  for (unsigned ii = 0; ii < supported_hdr->count; ++ii)
  {
    if (pj_strcmp2(&supported_hdr->values[ii], extension) == 0)
    {
      return PJ_TRUE;
    }
  }
  return PJ_FALSE;
}
开发者ID:telecore-ivan,项目名称:sprout,代码行数:18,代码来源:pjutils.cpp


示例8: pjsip_msg_find_hdr

static pjsip_authorization_hdr *get_auth_header(pjsip_rx_data *rdata, char *username,
	size_t username_size, char *realm, size_t realm_size, pjsip_authorization_hdr *start)
{
	pjsip_authorization_hdr *header;

	header = pjsip_msg_find_hdr(rdata->msg_info.msg, PJSIP_H_AUTHORIZATION, start);

	if (!header || pj_stricmp2(&header->scheme, "digest")) {
		return NULL;
	}

	ast_copy_pj_str(username, &header->credential.digest.username, username_size);
	ast_copy_pj_str(realm, &header->credential.digest.realm, realm_size);

	return header;
}
开发者ID:rebbud,项目名称:asterisk,代码行数:16,代码来源:res_pjsip_endpoint_identifier_user.c


示例9: pjsip_msg_find_hdr

bool SessionExpiresHelper::timer_supported(pjsip_msg* msg)
{
  pjsip_supported_hdr* supported_hdr = (pjsip_supported_hdr*)
    pjsip_msg_find_hdr(msg, PJSIP_H_SUPPORTED, NULL);

  if (supported_hdr != NULL)
  {
    for (unsigned ii = 0; ii < supported_hdr->count; ++ii)
    {
      if (pj_strcmp(&supported_hdr->values[ii], &STR_TIMER) == 0)
      {
        return true;
      }
    }
  }

  return false;
}
开发者ID:gfraysse,项目名称:sprout,代码行数:18,代码来源:session_expires_helper.cpp


示例10: set_id_from_from

/*!
 * \internal
 * \brief Set an ast_party_id structure based on data in a From
 *
 * This makes use of \ref set_id_from_hdr for setting name and number. It uses
 * no information from the message in order to set privacy. It relies on endpoint
 * configuration for privacy information.
 *
 * \param rdata The incoming message
 * \param[out] id The ID to set
 * \retval 0 Succesfully set the party ID
 * \retval non-zero Could not set the party ID
 */
static int set_id_from_from(struct pjsip_rx_data *rdata, struct ast_party_id *id)
{
	pjsip_fromto_hdr *from = pjsip_msg_find_hdr(rdata->msg_info.msg,
			PJSIP_H_FROM, rdata->msg_info.msg->hdr.next);

	if (!from) {
		/* This had better not happen */
		return -1;
	}

	set_id_from_hdr(from, id);

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

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


示例11: pjsua_im_accept_pager

/**
 * Private: check if we can accept the message.
 */
pj_bool_t pjsua_im_accept_pager(pjsip_rx_data *rdata,
				pjsip_accept_hdr **p_accept_hdr)
{
    /* Some UA sends text/html, so this check will break */
#if 0
    pjsip_ctype_hdr *ctype;
    pjsip_msg *msg;

    msg = rdata->msg_info.msg;

    /* Request MUST have message body, with Content-Type equal to
     * "text/plain".
     */
    ctype = (pjsip_ctype_hdr*)
	    pjsip_msg_find_hdr(msg, PJSIP_H_CONTENT_TYPE, NULL);
    if (msg->body == NULL || ctype == NULL || 
	!acceptable_message(&ctype->media)) 
    {
	/* Create Accept header. */
	if (p_accept_hdr)
	    *p_accept_hdr = pjsua_im_create_accept(rdata->tp_info.pool);

	return PJ_FALSE;
    }
#elif 0
    pjsip_msg *msg;

    msg = rdata->msg_info.msg;
    if (msg->body == NULL) {
	/* Create Accept header. */
	if (p_accept_hdr)
	    *p_accept_hdr = pjsua_im_create_accept(rdata->tp_info.pool);

	return PJ_FALSE;
    }
#else
    /* Ticket #693: allow incoming MESSAGE without message body */
    PJ_UNUSED_ARG(rdata);
    PJ_UNUSED_ARG(p_accept_hdr);
#endif

    return PJ_TRUE;
}
开发者ID:CloudStyleStudio,项目名称:csip,代码行数:46,代码来源:pjsua_im.c


示例12: LOG_INFO

/// Adds a header indicating the message is integrity protected because it
/// was received on a transport that has already been authenticated.
void PJUtils::add_integrity_protected_indication(pjsip_tx_data* tdata)
{
  LOG_INFO("Adding integrity-protected indicator to message");
  pjsip_authorization_hdr* auth_hdr = (pjsip_authorization_hdr*)
                   pjsip_msg_find_hdr(tdata->msg, PJSIP_H_AUTHORIZATION, NULL);

  if (auth_hdr == NULL)
  {
    auth_hdr = pjsip_authorization_hdr_create(tdata->pool);
    auth_hdr->scheme = pj_str("Digest");
    auth_hdr->credential.digest.realm = pj_str("");
    auth_hdr->credential.digest.username = PJUtils::uri_to_pj_str(PJSIP_URI_IN_FROMTO_HDR, tdata->msg->line.req.uri, tdata->pool);
    pjsip_msg_add_hdr(tdata->msg, (pjsip_hdr*)auth_hdr);
  }
  pjsip_param* new_param = (pjsip_param*) pj_pool_alloc(tdata->pool, sizeof(pjsip_param));
  new_param->name = STR_INTEGRITY_PROTECTED;
  new_param->value = pj_str("\"yes\"");
  pj_list_insert_before(&auth_hdr->credential.common.other_param, new_param);
}
开发者ID:triendeau,项目名称:sprout,代码行数:21,代码来源:pjutils.cpp


示例13: PJSIP_MSG_FROM_HDR

/// Apply the mangalgorithm to the From tag, To tag (if present) and call ID of
/// req.
void MangelwurzelTsx::mangle_dialog_identifiers(pjsip_msg* req, pj_pool_t* pool)
{
  pjsip_from_hdr* from_hdr = PJSIP_MSG_FROM_HDR(req);

  if (from_hdr != NULL)
  {
    std::string from_tag = PJUtils::pj_str_to_string(&from_hdr->tag);
    mangle_string(from_tag);
    TRC_DEBUG("From tag mangled to %s", from_tag.c_str());
    from_hdr->tag = pj_strdup3(pool, from_tag.c_str());
  }

  pjsip_to_hdr* to_hdr = PJSIP_MSG_TO_HDR(req);

  if (to_hdr != NULL)
  {
    std::string to_tag = PJUtils::pj_str_to_string(&to_hdr->tag);
    mangle_string(to_tag);
    TRC_DEBUG("To tag mangled to %s", to_tag.c_str());
    to_hdr->tag = pj_strdup3(pool, to_tag.c_str());
  }

  pjsip_cid_hdr* cid_hdr = (pjsip_cid_hdr*)pjsip_msg_find_hdr(req,
                                                              PJSIP_H_CALL_ID,
                                                              NULL);
  if (cid_hdr != NULL)
  {
    std::string call_id = PJUtils::pj_str_to_string(&cid_hdr->id);
    mangle_string(call_id);
    TRC_DEBUG("Call ID manged to %s", call_id.c_str());
    cid_hdr->id = pj_strdup3(pool, call_id.c_str());

    // Report a SAS marker for the new call ID so that the two dialogs can be
    // correlated in SAS.
    TRC_DEBUG("Logging SAS Call-ID marker, Call-ID %.*s",
              cid_hdr->id.slen,
              cid_hdr->id.ptr);
    SAS::Marker cid_marker(trail(), MARKER_ID_SIP_CALL_ID, 1u);
    cid_marker.add_var_param(cid_hdr->id.slen, cid_hdr->id.ptr);
    SAS::report_marker(cid_marker, SAS::Marker::Scope::Trace);
  }
}
开发者ID:ClearwaterCore,项目名称:sprout,代码行数:44,代码来源:mangelwurzel.cpp


示例14: add_supported

static int add_supported(pjsip_tx_data *tdata)
{
	pjsip_supported_hdr *hdr;

	hdr = pjsip_msg_find_hdr(tdata->msg, PJSIP_H_SUPPORTED, NULL);
	if (!hdr) {
		/* insert a new Supported header */
		hdr = pjsip_supported_hdr_create(tdata->pool);
		if (!hdr) {
			return -1;
		}

		pjsip_msg_add_hdr(tdata->msg, (pjsip_hdr *)hdr);
	}

	/* add on to the existing Supported header */
	pj_strassign(&hdr->values[hdr->count++], &PATH_SUPPORTED_NAME);

	return 0;
}
开发者ID:auntieNeo,项目名称:asterisk,代码行数:20,代码来源:res_pjsip_path.c


示例15: rewrite_contact

static int rewrite_contact(pjsip_rx_data *rdata, pjsip_dialog *dlg)
{
	pjsip_contact_hdr *contact;

	contact = pjsip_msg_find_hdr(rdata->msg_info.msg, PJSIP_H_CONTACT, NULL);
	if (contact && !contact->star && (PJSIP_URI_SCHEME_IS_SIP(contact->uri) || PJSIP_URI_SCHEME_IS_SIPS(contact->uri))) {
		pjsip_sip_uri *uri = pjsip_uri_get_uri(contact->uri);

		rewrite_uri(rdata, uri);

		if (dlg && pj_list_empty(&dlg->route_set) && (!dlg->remote.contact
			|| pjsip_uri_cmp(PJSIP_URI_IN_REQ_URI, dlg->remote.contact->uri, contact->uri))) {
			dlg->remote.contact = (pjsip_contact_hdr*)pjsip_hdr_clone(dlg->pool, contact);
			dlg->target = dlg->remote.contact->uri;
		}
		return 0;
	}

	return -1;
}
开发者ID:MattheusNiels,项目名称:BackupCerberus,代码行数:20,代码来源:res_pjsip_nat.c


示例16: pjsip_msg_find_hdr

/// Substitutes the branch identifier in the top Via header with a new unique
/// identifier.  This is used when forking requests and when retrying requests
/// to alternate servers.  This code is taken from pjsip_generate_branch_id
/// for the case when the branch ID is calculated from a GUID.
void PJUtils::generate_new_branch_id(pjsip_tx_data* tdata)
{
  pjsip_via_hdr* via = (pjsip_via_hdr*)
                             pjsip_msg_find_hdr(tdata->msg, PJSIP_H_VIA, NULL);
  via->branch_param.ptr = (char*)
                              pj_pool_alloc(tdata->pool, PJSIP_MAX_BRANCH_LEN);
  via->branch_param.slen = PJSIP_RFC3261_BRANCH_LEN;
  pj_memcpy(via->branch_param.ptr,
            PJSIP_RFC3261_BRANCH_ID,
            PJSIP_RFC3261_BRANCH_LEN);

  pj_str_t tmp;
  tmp.ptr = via->branch_param.ptr + PJSIP_RFC3261_BRANCH_LEN + 2;
  // Add "Pj" between the RFC3261 prefix and the random string to be consistent
  // with branch IDs generated by PJSIP.
  *(tmp.ptr-2) = 'P';
  *(tmp.ptr-1) = 'j';
  pj_generate_unique_string(&tmp);

  via->branch_param.slen = PJSIP_MAX_BRANCH_LEN;
}
开发者ID:oldurecu,项目名称:sprout,代码行数:25,代码来源:pjutils.cpp


示例17: PJ_DEF

PJ_DEF(pj_status_t) pjsip_publishc_send(pjsip_publishc *pubc, 
					pjsip_tx_data *tdata)
{
    pj_status_t status;
    pjsip_cseq_hdr *cseq_hdr;
    pj_uint32_t cseq;

    /* Make sure we don't have pending transaction. */
    if (pubc->pending_tsx) {
	PJ_LOG(4,(THIS_FILE, "Unable to send request, pubc has another "
			     "transaction pending"));
	pjsip_tx_data_dec_ref( tdata );
	return PJSIP_EBUSY;
    }

    /* Invalidate message buffer. */
    pjsip_tx_data_invalidate_msg(tdata);

    /* Increment CSeq */
    cseq = ++pubc->cseq_hdr->cseq;
    cseq_hdr = (pjsip_cseq_hdr*)
    	       pjsip_msg_find_hdr(tdata->msg, PJSIP_H_CSEQ, NULL);
    cseq_hdr->cseq = cseq;

    /* Increment pending transaction first, since transaction callback
     * may be called even before send_request() returns!
     */
    ++pubc->pending_tsx;
    status = pjsip_endpt_send_request(pubc->endpt, tdata, -1, pubc, 
				      &tsx_callback);
    if (status!=PJ_SUCCESS) {
	// no need to decrement, callback has been called and it should
	// already decremented pending_tsx. Decrementing this here may 
	// cause accessing freed memory location.
	//--pubc->pending_tsx;
	PJ_LOG(4,(THIS_FILE, "Error sending request, status=%d", status));
    }

    return status;
}
开发者ID:svn2github,项目名称:pjproject,代码行数:40,代码来源:publishc.c


示例18: is_next_route_local

/// Checks whether the next Route header in the message refers to this node,
/// and optionally returns the header.  If there are no Route headers it
/// returns false.
pj_bool_t PJUtils::is_next_route_local(const pjsip_msg* msg, pjsip_route_hdr* start, pjsip_route_hdr** hdr)
{
  bool rc = false;
  pjsip_route_hdr* route_hdr = (pjsip_route_hdr*)pjsip_msg_find_hdr(msg, PJSIP_H_ROUTE, (start != NULL) ? start->next : NULL);

  if (route_hdr != NULL)
  {
    // Found the next Route header, so check whether the URI corresponds to
    // this node or one of its aliases.
    pjsip_uri* uri = route_hdr->name_addr.uri;
    LOG_DEBUG("Found Route header, URI = %s", uri_to_string(PJSIP_URI_IN_ROUTING_HDR, uri).c_str());
    if ((is_home_domain(uri)) || (is_uri_local(uri)))
    {
      rc = true;
      if (hdr != NULL)
      {
        *hdr = route_hdr;
      }
    }
  }
  return rc;
}
开发者ID:telecore-ivan,项目名称:sprout,代码行数:25,代码来源:pjutils.cpp


示例19: caller_id_outgoing_request

/*!
 * \internal
 * \brief Session supplement callback for outgoing INVITE requests
 *
 * For an initial INVITE request, we may change the From header to appropriately
 * reflect the identity information. On all INVITEs (initial and reinvite) we may
 * add other identity headers such as P-Asserted-Identity and Remote-Party-ID based
 * on configuration and privacy settings
 *
 * \param session The session on which the INVITE will be sent
 * \param tdata The outbound INVITE request
 */
static void caller_id_outgoing_request(struct ast_sip_session *session, pjsip_tx_data *tdata)
{
	struct ast_party_id effective_id;
	struct ast_party_id connected_id;

	if (!session->channel) {
		return;
	}

	/* Must do a deep copy unless we hold the channel lock the entire time. */
	ast_party_id_init(&connected_id);
	ast_channel_lock(session->channel);
	effective_id = ast_channel_connected_effective_id(session->channel);
	ast_party_id_copy(&connected_id, &effective_id);
	ast_channel_unlock(session->channel);

	if (session->inv_session->state < PJSIP_INV_STATE_CONFIRMED) {
		/* Only change the From header on the initial outbound INVITE. Switching it
		 * mid-call might confuse some UAs.
		 */
		pjsip_fromto_hdr *from;
		pjsip_dialog *dlg;

		from = pjsip_msg_find_hdr(tdata->msg, PJSIP_H_FROM, tdata->msg->hdr.next);
		dlg = session->inv_session->dlg;

		if (ast_strlen_zero(session->endpoint->fromuser)
			&& (session->endpoint->id.trust_outbound
				|| (ast_party_id_presentation(&connected_id) & AST_PRES_RESTRICTION) == AST_PRES_ALLOWED)) {
			modify_id_header(tdata->pool, from, &connected_id);
			modify_id_header(dlg->pool, dlg->local.info, &connected_id);
		}

		ast_sip_add_usereqphone(session->endpoint, tdata->pool, from->uri);
		ast_sip_add_usereqphone(session->endpoint, dlg->pool, dlg->local.info->uri);
	}
	add_id_headers(session, tdata, &connected_id);
	ast_party_id_free(&connected_id);
}
开发者ID:brandonshults01,项目名称:asterisk,代码行数:51,代码来源:res_pjsip_caller_id.c


示例20: handle_rx_message

static pj_bool_t handle_rx_message(struct ast_sip_endpoint *endpoint, pjsip_rx_data *rdata)
{
	pjsip_contact_hdr *contact;

	if (!endpoint) {
		return PJ_FALSE;
	}

	if (endpoint->nat.rewrite_contact && (contact = pjsip_msg_find_hdr(rdata->msg_info.msg, PJSIP_H_CONTACT, NULL)) &&
		!contact->star && (PJSIP_URI_SCHEME_IS_SIP(contact->uri) || PJSIP_URI_SCHEME_IS_SIPS(contact->uri))) {
		pjsip_sip_uri *uri = pjsip_uri_get_uri(contact->uri);
		pjsip_dialog *dlg = pjsip_rdata_get_dlg(rdata);

		pj_cstr(&uri->host, rdata->pkt_info.src_name);
		if (strcasecmp("udp", rdata->tp_info.transport->type_name)) {
			uri->transport_param = pj_str(rdata->tp_info.transport->type_name);
		} else {
			uri->transport_param.slen = 0;
		}
		uri->port = rdata->pkt_info.src_port;
		ast_debug(4, "Re-wrote Contact URI host/port to %.*s:%d\n",
			(int)pj_strlen(&uri->host), pj_strbuf(&uri->host), uri->port);

		/* rewrite the session target since it may have already been pulled from the contact header */
		if (dlg && (!dlg->remote.contact
			|| pjsip_uri_cmp(PJSIP_URI_IN_REQ_URI, dlg->remote.contact->uri, contact->uri))) {
			dlg->remote.contact = (pjsip_contact_hdr*)pjsip_hdr_clone(dlg->pool, contact);
			dlg->target = dlg->remote.contact->uri;
		}
	}

	if (endpoint->nat.force_rport) {
		rdata->msg_info.via->rport_param = rdata->pkt_info.src_port;
	}

	return PJ_FALSE;
}
开发者ID:adaptiman,项目名称:asterisk,代码行数:37,代码来源:res_pjsip_nat.c



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ pjsip_msg_find_hdr_by_name函数代码示例发布时间:2022-05-30
下一篇:
C++ pjsip_hdr_clone函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap