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

C++ pj_htonl函数代码示例

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

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



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

示例1: PJ_DEF

PJ_DEF(pj_status_t) pjmedia_rtp_session_init2( 
				    pjmedia_rtp_session *ses,
				    pjmedia_rtp_session_setting settings)
{
    pj_status_t status;
    int		 pt = 0;
    pj_uint32_t	 sender_ssrc = 0;

    if (settings.flags & 1)
	pt = settings.default_pt;
    if (settings.flags & 2)
	sender_ssrc = settings.sender_ssrc;

    status = pjmedia_rtp_session_init(ses, pt, sender_ssrc);
    if (status != PJ_SUCCESS)
	return status;

    if (settings.flags & 4) {
	ses->out_extseq = settings.seq;
	ses->out_hdr.seq = pj_htons((pj_uint16_t)ses->out_extseq);
    }
    if (settings.flags & 8)
	ses->out_hdr.ts = pj_htonl(settings.ts);

    return PJ_SUCCESS;
}
开发者ID:Antares84,项目名称:asuswrt-merlin,代码行数:26,代码来源:rtp.c


示例2: pj_inet_addr

void $UPROTO$_server_leave($UPROTO$_server_t *userver, char *multicast_ip) {
    pj_ip_mreq mreq;
    pj_str_t s;
    pj_status_t ret;
    mreq.imr_multiaddr = pj_inet_addr(pj_cstr(&s, multicast_ip));
    mreq.imr_interface.s_addr = pj_htonl(PJ_INADDR_ANY);

    pj_mutex_lock(userver->mutex);
    ret = pj_sock_setsockopt(userver->fd, PJ_SOL_IP, PJ_IP_DROP_MEMBERSHIP, &mreq,sizeof(mreq));
    PERROR_IF_TRUE(ret != 0, "Error in leaving mcast group");
    pj_mutex_unlock(userver->mutex);
}
开发者ID:mocidis,项目名称:userver,代码行数:12,代码来源:userver.c


示例3: PJ_DEF

/*
 * Convert text to IPv4/IPv6 address.
 */
PJ_DEF(pj_status_t) pj_inet_pton(int af, const pj_str_t *src, void *dst)
{
    char tempaddr[PJ_INET6_ADDRSTRLEN];

    PJ_ASSERT_RETURN(af==PJ_AF_INET || af==PJ_AF_INET6, PJ_EINVAL);
    PJ_ASSERT_RETURN(src && src->slen && dst, PJ_EINVAL);

    /* Initialize output with PJ_IN_ADDR_NONE for IPv4 (to be 
     * compatible with pj_inet_aton()
     */
    if (af==PJ_AF_INET) {
	((pj_in_addr*)dst)->s_addr = PJ_INADDR_NONE;
    }

    /* Caution:
     *	this function might be called with cp->slen >= 46
     *  (i.e. when called with hostname to check if it's an IP addr).
     */
    if (src->slen >= PJ_INET6_ADDRSTRLEN) {
	return PJ_ENAMETOOLONG;
    }

    pj_memcpy(tempaddr, src->ptr, src->slen);
    tempaddr[src->slen] = '\0';


    wchar_t tempaddr16[PJ_INET6_ADDRSTRLEN];
    pj_ansi_to_unicode(tempaddr, pj_ansi_strlen(tempaddr),
		       tempaddr16, sizeof(tempaddr16));

    TBuf<PJ_INET6_ADDRSTRLEN> ip_addr((const TText*)tempaddr16);

    TInetAddr addr;
    addr.Init(KAfInet6);
    if (addr.Input(ip_addr) == KErrNone) {
	if (af==PJ_AF_INET) {
	    /* Success (Symbian IP address is in host byte order) */
	    pj_uint32_t ip = pj_htonl(addr.Address());
	    pj_memcpy(dst, &ip, 4);
	} else if (af==PJ_AF_INET6) {
	    const TIp6Addr & ip6 = addr.Ip6Address();
	    pj_memcpy(dst, ip6.u.iAddr8, 16);
	} else {
	    pj_assert(!"Unexpected!");
	    return PJ_EBUG;
	}
	return PJ_SUCCESS;
    } else {
	/* Error */
	return PJ_EINVAL;
    }
}
开发者ID:avble,项目名称:natClientEx,代码行数:55,代码来源:sock_symbian.cpp


示例4: PJ_DEF

PJ_DEF(pj_status_t) pjstun_create_bind_req( pj_pool_t *pool,
        void **msg, pj_size_t *len,
        pj_uint32_t id_hi,
        pj_uint32_t id_lo)
{
    pjstun_msg_hdr *hdr;

    PJ_CHECK_STACK();


    hdr = PJ_POOL_ZALLOC_T(pool, pjstun_msg_hdr);
    if (!hdr)
        return PJ_ENOMEM;

    hdr->type = pj_htons(PJSTUN_BINDING_REQUEST);
    hdr->tsx[2] = pj_htonl(id_hi);
    hdr->tsx[3] = pj_htonl(id_lo);
    *msg = hdr;
    *len = sizeof(pjstun_msg_hdr);

    return PJ_SUCCESS;
}
开发者ID:knox-carl,项目名称:pjsip,代码行数:22,代码来源:stun_simple.c


示例5: PJ_DEF

PJ_DEF(void) pjmedia_rtcp_init(pjmedia_rtcp_session *sess, 
			       char *name,
			       unsigned clock_rate,
			       unsigned samples_per_frame,
			       pj_uint32_t ssrc)
{
    pjmedia_rtcp_sr_pkt *sr_pkt = &sess->rtcp_sr_pkt;
    pj_time_val now;
    
    /* Memset everything */
    pj_bzero(sess, sizeof(pjmedia_rtcp_session));

    /* Last RX timestamp in RTP packet */
    sess->rtp_last_ts = (unsigned)-1;

    /* Name */
    sess->name = name ? name : (char*)THIS_FILE,

    /* Set clock rate */
    sess->clock_rate = clock_rate;
    sess->pkt_size = samples_per_frame;

    /* Init common RTCP SR header */
    sr_pkt->common.version = 2;
    sr_pkt->common.count = 1;
    sr_pkt->common.pt = RTCP_SR;
    sr_pkt->common.length = pj_htons(12);
    sr_pkt->common.ssrc = pj_htonl(ssrc);
    
    /* Copy to RTCP RR header */
    pj_memcpy(&sess->rtcp_rr_pkt.common, &sr_pkt->common, 
	      sizeof(pjmedia_rtcp_common));
    sess->rtcp_rr_pkt.common.pt = RTCP_RR;
    sess->rtcp_rr_pkt.common.length = pj_htons(7);

    /* Get time and timestamp base and frequency */
    pj_gettimeofday(&now);
    sess->tv_base = now;
    sess->stat.start = now;
    pj_get_timestamp(&sess->ts_base);
    pj_get_timestamp_freq(&sess->ts_freq);

    /* Initialize statistics states */
    pj_math_stat_init(&sess->stat.rtt);
    pj_math_stat_init(&sess->stat.rx.loss_period);
    pj_math_stat_init(&sess->stat.rx.jitter);
    pj_math_stat_init(&sess->stat.tx.loss_period);
    pj_math_stat_init(&sess->stat.tx.jitter);

    /* RR will be initialized on receipt of the first RTP packet. */
}
开发者ID:max3903,项目名称:SFLphone,代码行数:51,代码来源:rtcp.c


示例6: PJ_DEF

/*
 * Bind socket.
 */
PJ_DEF(pj_status_t) pj_sock_bind_in( pj_sock_t sockfd, 
				     pj_uint32_t addr32,
				     pj_uint16_t port)
{
    pj_sockaddr_in addr;

    PJ_CHECK_STACK();

    addr.sin_family = PJ_AF_INET;
    addr.sin_addr.s_addr = pj_htonl(addr32);
    addr.sin_port = pj_htons(port);

    return pj_sock_bind(sockfd, &addr, sizeof(pj_sockaddr_in));
}
开发者ID:Jopie64,项目名称:pjsip,代码行数:17,代码来源:sock_linux_kernel.c


示例7: PJ_DEF

PJ_DEF(pj_status_t) pj_stun_create_bind_req( pj_pool_t *pool, 
					     void **msg, pj_size_t *len,
					     pj_uint32_t id_hi, 
					     pj_uint32_t id_lo)
{
    pj_stun_msg_hdr *hdr;
    
    PJ_LOG(5,(THIS_FILE, "pj_stun_create_bind_req"));

    hdr = pj_pool_calloc(pool, 1, sizeof(pj_stun_msg_hdr));
    if (!hdr) {
	PJ_LOG(5,(THIS_FILE, "Error allocating memory!"));
	return -1;
    }

    hdr->type = pj_htons(PJ_STUN_BINDING_REQUEST);
    hdr->tsx[2] = pj_htonl(id_hi);
    hdr->tsx[3] = pj_htonl(id_lo);
    *msg = hdr;
    *len = sizeof(pj_stun_msg_hdr);

    return 0;
}
开发者ID:svn2github,项目名称:pjproject,代码行数:23,代码来源:stun.c


示例8: zrtp_sendDataZRTP

/*
 * Here start with callback functions that support the ZRTP core
 */
static int32_t zrtp_sendDataZRTP(ZrtpContext* ctx, const uint8_t* data, int32_t length)
{
    struct tp_zrtp *zrtp = (struct tp_zrtp*)ctx->userData;
    pj_uint16_t totalLen = length + 12;     /* Fixed number of bytes of ZRTP header */
    pj_uint32_t crc;
    pj_uint8_t* buffer = zrtp->zrtpBuffer;
    pj_uint16_t* pus;
    pj_uint32_t* pui;

    if ((totalLen) > MAX_ZRTP_SIZE)
        return 0;

    /* Get some handy pointers */
    pus = (pj_uint16_t*)buffer;
    pui = (pj_uint32_t*)buffer;

    /* set up fixed ZRTP header */
    *buffer = 0x10;     /* invalid RTP version - refer to ZRTP spec chap 5 */
    *(buffer + 1) = 0;
    pus[1] = pj_htons(zrtp->zrtpSeq++);
    pui[1] = pj_htonl(ZRTP_MAGIC);
    pui[2] = pj_htonl(zrtp->localSSRC);   /* stored in host order */

    /* Copy ZRTP message data behind the header data */
    pj_memcpy(buffer+12, data, length);

    /* Setup and compute ZRTP CRC */
    crc = zrtp_GenerateCksum(buffer, totalLen-CRC_SIZE);

    /* convert and store CRC in ZRTP packet.*/
    crc = zrtp_EndCksum(crc);
    *(uint32_t*)(buffer+totalLen-CRC_SIZE) = pj_htonl(crc);

    /* Send the ZRTP packet using the slave transport */
    return (pjmedia_transport_send_rtp(zrtp->slave_tp, buffer, totalLen) == PJ_SUCCESS) ? 1 : 0;
}
开发者ID:jresende,项目名称:ZRTP4PJ,代码行数:39,代码来源:transport_zrtp.c


示例9: PJ_DEF

/*
 * Bind socket.
 */
PJ_DEF(pj_status_t) pj_sock_bind_in( pj_sock_t sock, 
				     pj_uint32_t addr32,
				     pj_uint16_t port)
{
    pj_sockaddr_in addr;

    PJ_CHECK_STACK();

    PJ_SOCKADDR_SET_LEN(&addr, sizeof(pj_sockaddr_in));
    addr.sin_family = PJ_AF_INET;
    pj_bzero(addr.sin_zero, sizeof(addr.sin_zero));
    addr.sin_addr.s_addr = pj_htonl(addr32);
    addr.sin_port = pj_htons(port);

    return pj_sock_bind(sock, &addr, sizeof(pj_sockaddr_in));
}
开发者ID:chiefdome,项目名称:asterisk,代码行数:19,代码来源:sock_bsd.c


示例10: PJ_DEF


//.........这里部分代码省略.........
    wait_resp = sock_cnt * srv_cnt;

    TRACE_((THIS_FILE, "  Done initialization."));

#if defined(PJ_SELECT_NEEDS_NFDS) && PJ_SELECT_NEEDS_NFDS!=0
    nfds = -1;
    for (i=0; i<sock_cnt; ++i) {
	if (sock[i] > nfds) {
	    nfds = sock[i];
	}
    }
#else
    nfds = FD_SETSIZE-1;
#endif

    /* Main retransmission loop. */
    for (send_cnt=0; send_cnt<MAX_REQUEST; ++send_cnt) {
	pj_time_val next_tx, now;
	pj_fd_set_t r;
	int select_rc;

	PJ_FD_ZERO(&r);

	/* Send messages to servers that has not given us response. */
	for (i=0; i<sock_cnt && status==PJ_SUCCESS; ++i) {
	    for (j=0; j<srv_cnt && status==PJ_SUCCESS; ++j) {
		pjstun_msg_hdr *msg_hdr = (pjstun_msg_hdr*) out_msg;
                pj_ssize_t sent_len;

		if (rec[i].srv[j].mapped_port != 0)
		    continue;

		/* Modify message so that we can distinguish response. */
		msg_hdr->tsx[2] = pj_htonl(i);
		msg_hdr->tsx[3] = pj_htonl(j);

		/* Send! */
                sent_len = out_msg_len;
		status = pj_sock_sendto(sock[i], out_msg, &sent_len, 0,
					(pj_sockaddr_t*)&srv_addr[j],
					sizeof(pj_sockaddr_in));
	    }
	}

	/* All requests sent.
	 * The loop below will wait for responses until all responses have
	 * been received (i.e. wait_resp==0) or timeout occurs, which then
	 * we'll go to the next retransmission iteration.
	 */
	TRACE_((THIS_FILE, "  Request(s) sent, counter=%d", send_cnt));

	/* Calculate time of next retransmission. */
	pj_gettimeofday(&next_tx);
	next_tx.sec += (stun_timer[send_cnt]/1000);
	next_tx.msec += (stun_timer[send_cnt]%1000);
	pj_time_val_normalize(&next_tx);
	
	for (pj_gettimeofday(&now), select_rc=1; 
	     status==PJ_SUCCESS && select_rc>=1 && wait_resp>0 
	       && PJ_TIME_VAL_LT(now, next_tx); 
	     pj_gettimeofday(&now)) 
	{
	    pj_time_val timeout;

	    timeout = next_tx;
	    PJ_TIME_VAL_SUB(timeout, now);
开发者ID:Antares84,项目名称:asuswrt-merlin,代码行数:67,代码来源:stun_simple_client.c


示例11: PJ_DEF

/*
 * Set IPv4 address
 */
PJ_DEF(void) pj_sockaddr_in_set_addr(pj_sockaddr_in *addr,
				     pj_uint32_t hostaddr)
{
    addr->sin_addr.s_addr = pj_htonl(hostaddr);
}
开发者ID:Antares84,项目名称:asuswrt-merlin,代码行数:8,代码来源:sock_common.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ pj_init函数代码示例发布时间:2022-05-30
下一篇:
C++ pj_grp_lock_acquire函数代码示例发布时间: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