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


C++ PJSIP_URI_SCHEME_IS_SIP函数代码示例

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


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

示例1: public_id_from_uri

/// Returns a canonical IMS public user identity from a URI as per TS 23.003
/// 13.4.
std::string PJUtils::public_id_from_uri(const pjsip_uri* uri)
{
  if (PJSIP_URI_SCHEME_IS_SIP(uri))
  {
    pjsip_sip_uri public_id;
    memcpy((char*)&public_id, (char*)uri, sizeof(pjsip_sip_uri));
    public_id.passwd.slen = 0;
    public_id.port = 0;
    public_id.user_param.slen = 0;
    public_id.method_param.slen = 0;
    public_id.transport_param.slen = 0;
    public_id.ttl_param = -1;
    public_id.lr_param = 0;
    public_id.maddr_param.slen = 0;
    public_id.other_param.next = NULL;
    public_id.header_param.next = NULL;
    return uri_to_string(PJSIP_URI_IN_FROMTO_HDR, (pjsip_uri*)&public_id);
  }
  else if (PJSIP_URI_SCHEME_IS_TEL(uri))
  {
    pjsip_tel_uri public_id;
    memcpy((char*)&public_id, (char*)uri, sizeof(pjsip_tel_uri));
    public_id.context.slen = 0;
    public_id.ext_param.slen = 0;
    public_id.isub_param.slen = 0;
    public_id.other_param.next = NULL;
    return uri_to_string(PJSIP_URI_IN_FROMTO_HDR, (pjsip_uri*)&public_id);
  }
  else
  {
    return std::string();
  }
}
开发者ID:telecore-ivan,项目名称:sprout,代码行数:35,代码来源:pjutils.cpp

示例2: pjsua_pool_create

bool SipAccount::getNumber(pj_str_t* uri, std::string* pDisplay, std::string* pNumber) {
  pj_pool_t* pool = pjsua_pool_create("", 128, 10);
  pjsip_name_addr* n = (pjsip_name_addr*)pjsip_parse_uri(pool, uri->ptr, uri->slen, PJSIP_PARSE_URI_AS_NAMEADDR);
  if (n == NULL) {
    Logger::warn("pjsip_parse_uri() failed for %s", pj_strbuf(uri));
    pj_pool_release(pool);
    return false;
  }
  if (!PJSIP_URI_SCHEME_IS_SIP(n)) {
    Logger::warn("pjsip_parse_uri() returned unknown schema for %s", pj_strbuf(uri));
    pj_pool_release(pool);
    return false;
  }

  *pDisplay = std::string(n->display.ptr, n->display.slen);

  pjsip_sip_uri *sip = (pjsip_sip_uri*)pjsip_uri_get_uri(n);
  std::string number = std::string(sip->user.ptr, sip->user.slen);
  
  // make number international
  *pNumber = Helper::makeNumberInternational(&m_settings.base, number);

  pj_pool_release(pool);
  return true;
}
开发者ID:Buffi79,项目名称:callblocker,代码行数:25,代码来源:SipAccount.cpp

示例3: mod_stateless_on_rx_request

static pj_bool_t mod_stateless_on_rx_request(pjsip_rx_data *rdata)
{
    const pj_str_t stateless_user = { "0", 1 };
    pjsip_uri *uri;
    pjsip_sip_uri *sip_uri;

    uri = pjsip_uri_get_uri(rdata->msg_info.msg->line.req.uri);

    /* Only want to receive SIP/SIPS scheme */
    if (!PJSIP_URI_SCHEME_IS_SIP(uri) && !PJSIP_URI_SCHEME_IS_SIPS(uri))
	return PJ_FALSE;

    sip_uri = (pjsip_sip_uri*) uri;

    /* Check for matching user part */
    if (pj_strcmp(&sip_uri->user, &stateless_user)!=0)
	return PJ_FALSE;

    /*
     * Yes, this is for us.
     */

    /* Ignore ACK request */
    if (rdata->msg_info.msg->line.req.method.id == PJSIP_ACK_METHOD)
	return PJ_TRUE;

    /*
     * Respond statelessly with 200/OK.
     */
    pjsip_endpt_respond_stateless(app.sip_endpt, rdata, 200, NULL,
				  NULL, NULL);
    app.server.cur_state.stateless_cnt++;
    return PJ_TRUE;
}
开发者ID:ClearwaterCore,项目名称:pjsip-upstream,代码行数:34,代码来源:pjsip-perf.c

示例4: is_uri_local

// Utility to determine if URI is local to this host.
pj_bool_t PJUtils::is_uri_local(const pjsip_uri* uri)
{
  if (PJSIP_URI_SCHEME_IS_SIP(uri))
  {
    int port = (((pjsip_sip_uri*)uri)->port != 0) ? ((pjsip_sip_uri*)uri)->port : 5060;
    pj_str_t host = ((pjsip_sip_uri*)uri)->host;

    if ((port == stack_data.trusted_port) ||
        (port == stack_data.untrusted_port))
    {
      // Port matches, check the list of host names.
      unsigned i;
      for (i=0; i<stack_data.name_cnt; ++i)
      {
        if (pj_stricmp(&host, &stack_data.name[i])==0)
        {
          /* Match */
          return PJ_TRUE;
        }
      }
    }
  }

  /* Doesn't match */
  return PJ_FALSE;
}
开发者ID:triendeau,项目名称:sprout,代码行数:27,代码来源:pjutils.cpp

示例5: PJSIP_URI_SCHEME_IS_SIPS

// Determine the default private ID for a public ID contained in a URI.  This
// is calculated as specified by the 3GPP specs by effectively stripping the
// scheme.
std::string PJUtils::default_private_id_from_uri(const pjsip_uri* uri)
{
  std::string id;
  if (PJSIP_URI_SCHEME_IS_SIP(uri) ||
      PJSIP_URI_SCHEME_IS_SIPS(uri))
  {
    pjsip_sip_uri* sip_uri = (pjsip_sip_uri*)uri;
    if (sip_uri->user.slen > 0)
    {
      id = PJUtils::pj_str_to_string(&sip_uri->user) + "@" + PJUtils::pj_str_to_string(&sip_uri->host);
    }
    else
    {
      id = PJUtils::pj_str_to_string(&sip_uri->host);
    }
  }
  else if (PJSIP_URI_SCHEME_IS_TEL(uri))
  {
    id = PJUtils::pj_str_to_string(&((pjsip_tel_uri*)uri)->number) +
               "@" + PJUtils::pj_str_to_string(&stack_data.default_home_domain);
  }
  else
  {
    const pj_str_t* scheme = pjsip_uri_get_scheme(uri);
    LOG_WARNING("Unsupported scheme \"%.*s\" in To header when determining private ID - ignoring",
                scheme->slen, scheme->ptr);
  }

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

示例6: mangle_uri

/// Apply the mangalgorithm to the specified URI. The user part of the URI is
/// always mangled. The domain is mangled separately, and is only mangled if
/// mangelwurzel's change_domain flag is set, or if the function's
/// force_mangle_domain flag is set (we use this flag to make sure we always
/// mangle the domains for Routes and Record-Routes). We don't mangle
/// anything else (e.g. port number, SIP parameters).
void MangelwurzelTsx::mangle_uri(pjsip_uri* uri,
                                 pj_pool_t* pool,
                                 bool force_mangle_domain)
{
  if (PJSIP_URI_SCHEME_IS_SIP(uri))
  {
    pjsip_sip_uri* sip_uri = (pjsip_sip_uri*)uri;
    std::string user = PJUtils::pj_str_to_string(&sip_uri->user);
    mangle_string(user);
    sip_uri->user = pj_strdup3(pool, user.c_str());

    if ((force_mangle_domain) || (_config.change_domain))
    {
      std::string host = PJUtils::pj_str_to_string(&sip_uri->host);
      mangle_string(host);
      sip_uri->host = pj_strdup3(pool, host.c_str());
    }
  }
  else if (PJSIP_URI_SCHEME_IS_TEL(uri))
  {
    pjsip_tel_uri* tel_uri = (pjsip_tel_uri*)uri;
    std::string number = PJUtils::pj_str_to_string(&tel_uri->number);
    mangle_string(number);
    tel_uri->number = pj_strdup3(pool, number.c_str());
  }
}
开发者ID:ClearwaterCore,项目名称:sprout,代码行数:32,代码来源:mangelwurzel.cpp

示例7: pjsua_find_buddy

/*
 * Find buddy.
 */
static pjsua_buddy_id pjsua_find_buddy(const pjsip_uri *uri)
{
    const pjsip_sip_uri *sip_uri;
    unsigned i;

    uri = (const pjsip_uri*) pjsip_uri_get_uri((pjsip_uri*)uri);

    if (!PJSIP_URI_SCHEME_IS_SIP(uri) && !PJSIP_URI_SCHEME_IS_SIPS(uri))
	return PJSUA_INVALID_ID;

    sip_uri = (const pjsip_sip_uri*) uri;

    for (i=0; i<PJ_ARRAY_SIZE(pjsua_var.buddy); ++i) {
	const pjsua_buddy *b = &pjsua_var.buddy[i];

	if (!pjsua_buddy_is_valid(i))
	    continue;

	if (pj_stricmp(&sip_uri->user, &b->name)==0 &&
	    pj_stricmp(&sip_uri->host, &b->host)==0 &&
	    (sip_uri->port==(int)b->port || (sip_uri->port==0 && b->port==5060)))
	{
	    /* Match */
	    return i;
	}
    }

    return PJSUA_INVALID_ID;
}
开发者ID:svn2github,项目名称:pjproject,代码行数:32,代码来源:pjsua_pres.c

示例8: websocket_on_rx_msg

/*!
 * \brief Store the transport a message came in on, so it can be used for outbound messages to that contact.
 */
static pj_bool_t websocket_on_rx_msg(pjsip_rx_data *rdata)
{
	static const pj_str_t STR_WS = { "ws", 2 };
	static const pj_str_t STR_WSS = { "wss", 3 };
	pjsip_contact_hdr *contact;

	long type = rdata->tp_info.transport->key.type;

	if (type != (long)transport_type_ws && type != (long)transport_type_wss) {
		return PJ_FALSE;
	}

	if ((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);

		pj_cstr(&uri->host, rdata->pkt_info.src_name);
		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);
		pj_strdup(rdata->tp_info.pool, &uri->transport_param, (type == (long)transport_type_ws) ? &STR_WS : &STR_WSS);
	}

	rdata->msg_info.via->rport_param = 0;

	return PJ_FALSE;
}
开发者ID:GGGO,项目名称:asterisk,代码行数:30,代码来源:res_pjsip_transport_websocket.c

示例9:

/// Utility to determine if URI contains a valid E.164 number
pj_bool_t PJUtils::is_e164(const pjsip_uri* uri)
{
  if (PJSIP_URI_SCHEME_IS_SIP(uri))
  {
    return PJUtils::is_e164(&((pjsip_sip_uri*)uri)->user);
  }
  return PJ_FALSE;
}
开发者ID:telecore-ivan,项目名称:sprout,代码行数:9,代码来源:pjutils.cpp

示例10: return

bool PJUtils::is_emergency_registration(pjsip_contact_hdr* contact_hdr)
{
  // Contact header must be a SIP URI
  pjsip_sip_uri* uri = (contact_hdr->uri != NULL) ?
                     (pjsip_sip_uri*)pjsip_uri_get_uri(contact_hdr->uri) : NULL;
  return ((uri != NULL) && (PJSIP_URI_SCHEME_IS_SIP(uri)) &&
          (pjsip_param_find(&uri->other_param, &STR_SOS) != NULL));
}
开发者ID:oldurecu,项目名称:sprout,代码行数:8,代码来源:pjutils.cpp

示例11: is_home_domain

/// Utility to determine if this URI belongs to the home domain.
pj_bool_t PJUtils::is_home_domain(const pjsip_uri* uri)
{
  if ((PJSIP_URI_SCHEME_IS_SIP(uri)) &&
      (pj_stricmp(&((pjsip_sip_uri*)uri)->host, &stack_data.home_domain)==0))
  {
    return PJ_TRUE;
  }
  return PJ_FALSE;
}
开发者ID:telecore-ivan,项目名称:sprout,代码行数:10,代码来源:pjutils.cpp

示例12: is_home_domain

/// Utility to determine if this URI belongs to the home domain.
pj_bool_t PJUtils::is_home_domain(const pjsip_uri* uri)
{
  if (PJSIP_URI_SCHEME_IS_SIP(uri))
  {
    std::string host = pj_str_to_string(&((pjsip_sip_uri*)uri)->host);
    return is_home_domain(host);
  }

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

示例13: pjsip_msg_find_hdr

/*! \brief Helper function which returns the SIP URI of a Contact header */
static pjsip_sip_uri *nat_get_contact_sip_uri(pjsip_tx_data *tdata)
{
	pjsip_contact_hdr *contact = pjsip_msg_find_hdr(tdata->msg, PJSIP_H_CONTACT, NULL);

	if (!contact || (!PJSIP_URI_SCHEME_IS_SIP(contact->uri) && !PJSIP_URI_SCHEME_IS_SIPS(contact->uri))) {
		return NULL;
	}

	return pjsip_uri_get_uri(contact->uri);
}
开发者ID:MattheusNiels,项目名称:BackupCerberus,代码行数:11,代码来源:res_pjsip_nat.c

示例14: get_endpoint_details

static int get_endpoint_details(pjsip_rx_data *rdata, char *domain, size_t domain_size)
{
	pjsip_uri *from = rdata->msg_info.from->uri;
	pjsip_sip_uri *sip_from;
	if (!PJSIP_URI_SCHEME_IS_SIP(from) && !PJSIP_URI_SCHEME_IS_SIPS(from)) {
		return -1;
	}
	sip_from = (pjsip_sip_uri *) pjsip_uri_get_uri(from);
	ast_copy_pj_str(domain, &sip_from->host, domain_size);
	return 0;
}
开发者ID:pruiz,项目名称:asterisk,代码行数:11,代码来源:res_pjsip_endpoint_identifier_anonymous.c

示例15: get_from_header

static int get_from_header(pjsip_rx_data *rdata, char *username, size_t username_size, char *domain, size_t domain_size)
{
	pjsip_uri *from = rdata->msg_info.from->uri;
	pjsip_sip_uri *sip_from;
	if (!PJSIP_URI_SCHEME_IS_SIP(from) && !PJSIP_URI_SCHEME_IS_SIPS(from)) {
		return -1;
	}
	sip_from = (pjsip_sip_uri *) pjsip_uri_get_uri(from);
	ast_copy_pj_str(username, &sip_from->user, username_size);
	ast_copy_pj_str(domain, &sip_from->host, domain_size);
	return 0;
}
开发者ID:rebbud,项目名称:asterisk,代码行数:12,代码来源:res_pjsip_endpoint_identifier_user.c


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