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


C++ IPH_HL函数代码示例

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


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

示例1: __inetPingRecv

/*********************************************************************************************************
** 函数名称: __inetPingRecv
** 功能描述: 接收 ping 包
** 输 入  : iSock         socket
**           usSeqRecv     需要判断的 seq
**           piTTL         接收到的 TTL
** 输 出  : ERROR
** 全局变量: 
** 调用模块: 
*********************************************************************************************************/
static INT  __inetPingRecv (INT  iSock, UINT16  usSeqRecv, INT  *piTTL)
{
             CHAR                   cBuffer[512];
             
             INT                    iCnt = 20;                          /*  默认最多接收的数据包数      */
    REGISTER ssize_t                sstLen;
             INT                    iAddLen = sizeof(struct sockaddr_in);
             struct sockaddr_in     sockaddrinFrom;
             
             struct ip_hdr         *iphdrFrom;
             struct icmp_echo_hdr  *icmphdrFrom;
            
    while ((sstLen = recvfrom(iSock, cBuffer, sizeof(cBuffer), 0, 
                              (struct sockaddr *)&sockaddrinFrom, (socklen_t *)&iAddLen)) > 0) {
        
        if (sstLen >= (sizeof(struct ip_hdr) + sizeof(struct icmp_echo_hdr))) {
            
            iphdrFrom   = (struct ip_hdr *)cBuffer;
            icmphdrFrom = (struct icmp_echo_hdr *)(cBuffer + (IPH_HL(iphdrFrom) * 4));
            
            if ((icmphdrFrom->id == 0xAFAF) && (icmphdrFrom->seqno == htons(usSeqRecv))) {
                *piTTL = 0;
                *piTTL = (u8_t)IPH_TTL(iphdrFrom);
                return  (ERROR_NONE);
            }
        }
        
        iCnt--;                                                         /*  接收到错误的数据包太多      */
        if (iCnt < 0) {
            break;                                                      /*  退出                        */
        }
    }
    
    return  (PX_ERROR);
}
开发者ID:Ga-vin,项目名称:libsylixos,代码行数:45,代码来源:lwip_ping.c

示例2: ping_recv

static void
ping_recv(int s)
{
  char buf[64];
  int fromlen, len;
  struct sockaddr_in from;
  struct ip_hdr *iphdr;
  struct icmp_echo_hdr *iecho;
  fromlen = sizeof(from);
  while((len = lwip_recvfrom(s, buf, sizeof(buf), 0, (struct sockaddr*)&from, (socklen_t*)&fromlen)) > 0) {
    if (len >= (int)(sizeof(struct ip_hdr)+sizeof(struct icmp_echo_hdr))) {
      ip_addr_t fromaddr;
      inet_addr_to_ipaddr(&fromaddr, &from.sin_addr);
      LWIP_DEBUGF( PING_DEBUG, ("ping: recv "));
      ip_addr_debug_print(PING_DEBUG, &fromaddr);
      LWIP_DEBUGF( PING_DEBUG, (" %"U32_F" ms\r\n", (sys_now() - ping_time)));
      iphdr = (struct ip_hdr *)buf;
      iecho = (struct icmp_echo_hdr *)(buf + (IPH_HL(iphdr) * 4));
      if ((iecho->id == PING_ID) && (iecho->seqno == htons(ping_seq_num))) {
        /* do some ping result processing */
        PING_RESULT((ICMPH_TYPE(iecho) == ICMP_ER));
        return;
      } else {
        LWIP_DEBUGF( PING_DEBUG, ("ping: drop\r\n"));
      }
    }
  }

  if (len == 0) {
    LWIP_DEBUGF( PING_DEBUG, ("ping: recv - %"U32_F" ms - timeout\r\n", (sys_now()-ping_time)));
  }

  /* do some ping result processing */
  PING_RESULT(0);
}
开发者ID:jgrivera67,项目名称:McRTOS,代码行数:35,代码来源:ping.c

示例3: ping_recv

static void
ping_recv(int s)
{
  char*     buf            = NULL;
  int       fromlen, len;
  struct    sockaddr_in from;
  struct    ip_hdr *iphdr;
  struct    icmp_echo_hdr *iecho;
  int       ms;
  BOOL      bResult        = FALSE;

  //Allocate a buffer to contain the received data.
  buf = (char*)KMemAlloc(1500,KMEM_SIZE_TYPE_ANY);
  if(NULL == buf)
  {
	  return;
  }
  while((len = lwip_recvfrom(s, buf, 1500, 0, (struct sockaddr*)&from, (socklen_t*)&fromlen)) > 0)
  {
		if(len >= (int)(sizeof(struct ip_hdr)+sizeof(struct icmp_echo_hdr)))
		{
			ip_addr_t fromaddr;
      inet_addr_to_ipaddr(&fromaddr, &from.sin_addr);
			//Get times between sent and receive.
			ms = sys_now() - ping_time;
			ms *= SYSTEM_TIME_SLICE;

      iphdr = (struct ip_hdr *)buf;
      iecho = (struct icmp_echo_hdr *)(buf + (IPH_HL(iphdr) * 4));
      if (((iecho->id == PING_ID) && (iecho->seqno == htons(ping_seq_num)) && iecho->type == ICMP_ER))
			{
				len = len - sizeof(struct ip_hdr) - sizeof(struct icmp_echo_hdr);  //Adjust received data's length,since it
		                                                                       //includes IP and ICMP headers.
				_hx_printf("  [%d] Reply from %s,size = %d,time = %d(ms)\r\n",ping_pkt_seq,inet_ntoa(fromaddr),len,ms);
				ping_succ ++;
				bResult = TRUE;
      }
	    else
	    {
		    //printf("  ping : Received invalid replay,drop it.\r\n");
      }
    }
  }

  if (!bResult)
  {
		_hx_printf("  [%d] Request time out.\r\n",ping_pkt_seq);
  }

  if(buf)  //Release it.
  {
	  KMemFree(buf,KMEM_SIZE_TYPE_ANY,0);
  }
}
开发者ID:AlexShiLucky,项目名称:HelloX_STM32,代码行数:54,代码来源:network2.c

示例4: udp_lookup

uint8_t
udp_lookup(struct ip_hdr *iphdr, struct netif *inp)
{
  struct udp_pcb *pcb;
  struct udp_hdr *udphdr;
  uint16_t src, dest;
  
  udphdr = (struct udp_hdr *)(uint8_t *)iphdr + IPH_HL(iphdr) * 4/sizeof(uint8_t);

  src = NTOHS(udphdr->src);
  dest = NTOHS(udphdr->dest);
  
  pcb = pcb_cache;
  if(pcb != NULL &&
     pcb->remote_port == src &&
     pcb->local_port == dest &&
     (ip_addr_isany(&pcb->remote_ip) ||
      ip_addr_cmp(&(pcb->remote_ip), &(iphdr->src))) &&
     (ip_addr_isany(&pcb->local_ip) ||
      ip_addr_cmp(&(pcb->local_ip), &(iphdr->dest)))) {
    return 1;
  } else {  
    for(pcb = udp_pcbs; pcb != NULL; pcb = pcb->next) {
      if(pcb->remote_port == src &&
	 pcb->local_port == dest &&
	 (ip_addr_isany(&pcb->remote_ip) ||
	  ip_addr_cmp(&(pcb->remote_ip), &(iphdr->src))) &&
	 (ip_addr_isany(&pcb->local_ip) ||
	  ip_addr_cmp(&(pcb->local_ip), &(iphdr->dest)))) {
	pcb_cache = pcb;
	break;
      }
    }

    if(pcb == NULL) {
      for(pcb = udp_pcbs; pcb != NULL; pcb = pcb->next) {
	if(pcb->local_port == dest &&
	   (ip_addr_isany(&pcb->remote_ip) ||
	    ip_addr_cmp(&(pcb->remote_ip), &(iphdr->src))) &&
	   (ip_addr_isany(&pcb->local_ip) ||
	    ip_addr_cmp(&(pcb->local_ip), &(iphdr->dest)))) {
	  break;
	}
      }
    }
  }

  if(pcb != NULL) {
    return 1;
  } else {  
    return 1;
  }
}
开发者ID:eastzone,项目名称:cs344-sw-cpp,代码行数:53,代码来源:udp.c

示例5: ping_recv

static u8_t ping_recv(void *arg, struct raw_pcb *pcb, 
			struct pbuf *p, ip_addr_t *addr)
{
	struct ip_hdr *iphdr;
	struct icmp_echo_hdr *iecho;
	LWIP_UNUSED_ARG(arg);
	LWIP_UNUSED_ARG(pcb);
	LWIP_UNUSED_ARG(addr);

	LWIP_ASSERT("p != NULL", p != NULL);

	if ((p->tot_len >= (PBUF_IP_HLEN + sizeof(struct icmp_echo_hdr)))) {
		iphdr = (struct ip_hdr *)p->payload;
		iecho = (struct icmp_echo_hdr *)(p->payload + (IPH_HL(iphdr) * 4));
		if ((lns.ping_reply != NULL) &&
		    (iecho->id == PING_ID) && 
		    (iecho->seqno == htons(lns.ping_seq_num))) {
			lns.ping_recv_tstamp = vmm_timer_timestamp();

			lns.ping_reply->ripaddr[0] = ip4_addr1(&lns.ping_addr);
			lns.ping_reply->ripaddr[1] = ip4_addr2(&lns.ping_addr);
			lns.ping_reply->ripaddr[2] = ip4_addr3(&lns.ping_addr);
			lns.ping_reply->ripaddr[3] = ip4_addr4(&lns.ping_addr);
			lns.ping_reply->ttl = IPH_TTL(iphdr);
			lns.ping_reply->len = p->tot_len - (IPH_HL(iphdr) * 4);
			lns.ping_reply->seqno = lns.ping_seq_num;

			vmm_completion_complete(&lns.ping_done);

			/* Free the pbuf */
			pbuf_free(p);

			/* Eat the packet. lwIP should not process it. */
			return 1;
		}
	}

	/* Don't eat the packet. Let lwIP process it. */
	return 0;
}
开发者ID:32bitmicro,项目名称:xvisor,代码行数:40,代码来源:netstack.c

示例6: _udp_check_sum

/* Update UDP datagram's check sum accordingly. */
static void _udp_check_sum(struct ip_hdr* p, struct pbuf* pb)
{
	struct udp_hdr* pUdpHdr = NULL;
	int iph_len = IPH_HL(p);

	LWIP_UNUSED_ARG(pb);

	iph_len *= 4;
	pUdpHdr = (struct udp_hdr*)((char*)p + iph_len);
	__NATDEBUG("%s: reset UDP chksum from [%x] to 0.\r\n",
		__func__, pUdpHdr->chksum);
	pUdpHdr->chksum = 0; /* Reset check sum. */
}
开发者ID:hellox-project,项目名称:HelloX_OS,代码行数:14,代码来源:easynat.c

示例7: validateTCPChksum

/* 
 * Validate a TCP segment's checksum,return TRUE if pass the validation,
 * FALSE will be returned otherwise.
 */
static BOOL validateTCPChksum(struct ip_hdr* p, struct pbuf* pb)
{
	struct tcp_hdr* pTcpHdr = NULL;
	int iph_len = IPH_HL(p);
	int ip_len = ntohs(IPH_LEN(p)); /* Total IP packet length. */
	int chksum_old = 0, chksum_new = 0;
	ip_addr_t src, dest;

	iph_len *= 4;
	/* Locate TCP header. */
	pTcpHdr = (struct tcp_hdr*)((char*)p + iph_len);

	/* Validate pbuf object. */
	if (pb->tot_len < (iph_len + sizeof(struct tcp_hdr)))
	{
		return FALSE;
	}

	/* Validate the length of this packet. */
	if (ip_len < (iph_len + sizeof(struct tcp_hdr)))
	{
		return FALSE;
	}

	/*
	* Preserve TCP segment's check sum value before re-calculate
	* the value.
	*/
	chksum_old = pTcpHdr->chksum;
	ip_addr_copy(src, p->src);
	ip_addr_copy(dest, p->dest);
	pbuf_header(pb, -iph_len); /* move to TCP header. */
	pTcpHdr->chksum = 0; /* Reset the original check sum. */
	/* Recalculate the segment's checksum value. */
	chksum_new = inet_chksum_pseudo(pb, &src, &dest, IP_PROTO_TCP,
		/* IP payload length,e.i,TCP header plus data. */
		ip_len - iph_len);
		//pb->tot_len);
	pbuf_header(pb, iph_len); /* move back. */
	if (chksum_new != chksum_old)
	{
		__LOG("TCP checksum fail:ip_len = %d,pbuf_tot_len = %d,src_addr:%s\r\n",
			ip_len,
			pb->tot_len,
			inet_ntoa(p->src.addr));
		IP_STATS_INC(tcp.chkerr);
		IP_STATS_INC(tcp.drop);
		return FALSE;
	}
	return TRUE;
}
开发者ID:hellox-project,项目名称:HelloX_OS,代码行数:55,代码来源:easynat.c

示例8: _OutPacketMatch

/* Check if there is an entry that for a given output IP packet. */
static BOOL _OutPacketMatch(struct ip_hdr* pHdr, __EASY_NAT_ENTRY* pNatEntry)
{
	struct tcp_hdr* pTcpHdr = NULL;
	struct udp_hdr* pUdpHdr = NULL;
	int iph_len = 0;

	BUG_ON(NULL == pHdr);
	BUG_ON(NULL == pNatEntry);

	/* Increment total match times counter. */
	NatManager.stat.match_times++;

	/* Check according protocol type. */
	iph_len = IPH_HL(pHdr);
	iph_len *= 4;
	switch (pHdr->_proto)
	{
	case IP_PROTO_TCP:
		pTcpHdr = (struct tcp_hdr*)((char*)pHdr + iph_len);
		if ((pHdr->src.addr == pNatEntry->srcAddr_bef.addr) &&
			(pHdr->dest.addr == pNatEntry->dstAddr_bef.addr) &&
			(pTcpHdr->src == htons(pNatEntry->srcPort_bef)) &&
			(pTcpHdr->dest == htons(pNatEntry->dstPort_bef)))
		{
			return TRUE;
		}
		return FALSE;
		break;
	case IP_PROTO_UDP:
		pUdpHdr = (struct udp_hdr*)((char*)pHdr + iph_len);
		if ((pHdr->src.addr == pNatEntry->srcAddr_bef.addr) &&
			(pHdr->dest.addr == pNatEntry->dstAddr_bef.addr) &&
			(pUdpHdr->src == htons(pNatEntry->srcPort_bef)) &&
			(pUdpHdr->dest == htons(pNatEntry->dstPort_bef)))
		{
			return TRUE;
		}
		return FALSE;
		break;
	case IP_PROTO_ICMP:
		return OutPacketMatch_ICMP(pNatEntry, pHdr);
		break;
	default:
		return FALSE;
		break;
	}
	return FALSE;
}
开发者ID:hellox-project,项目名称:HelloX_OS,代码行数:49,代码来源:easynat.c

示例9: OutTranslation

/* Output direction translation. */
static void OutTranslation(__EASY_NAT_ENTRY* pEntry, struct ip_hdr* pHdr,struct pbuf* pb)
{
	struct tcp_hdr* pTcpHdr = NULL;
	struct udp_hdr* pUdpHdr = NULL;
	int iph_len = 0;

	BUG_ON(NULL == pEntry);
	BUG_ON(NULL == pHdr);
	BUG_ON(NULL == pb);

	/*
	* Update NAT entry state info.
	* It must be done before actual translation,since it maybe
	* altered in specific protocol's translation process,such
	* as TCP,it may set the entry's timeout value to MAX to
	* purge the entry as soon as possible,in case of the TCP
	* connection released.
	*/
	pEntry->ms = 0;
	pEntry->match_times++;

	/* Translate address first. */
	pHdr->src.addr = pEntry->srcAddr_aft.addr;
	/* Farther translation according protocol. */
	iph_len = IPH_HL(pHdr);
	iph_len *= 4;
	switch (pHdr->_proto)
	{
	case IP_PROTO_TCP:
		pTcpHdr = (struct tcp_hdr*)((char*)pHdr + iph_len);
		//pTcpHdr->src = htons(pEntry->srcPort_aft); 
		TcpTranslation(pEntry, pTcpHdr, out);
		break;
	case IP_PROTO_UDP:
		pUdpHdr = (struct udp_hdr*)((char*)pHdr + iph_len);
		pUdpHdr->src = htons(pEntry->srcPort_aft);
		break;
	case IP_PROTO_ICMP:
		OutTranslation_ICMP(pEntry, pHdr, pb);
		break;
	default:
		break;
	}
	/* Update the packet's checksum. */
	_iphdr_check_sum(pHdr, pb);
}
开发者ID:hellox-project,项目名称:HelloX_OS,代码行数:47,代码来源:easynat.c

示例10: ip_lookup

u8_t
ip_lookup(void *header, struct netif *inp)
{
    struct ip_hdr *iphdr;

    iphdr = header;

    /* Refuse anything that isn't IPv4. */
    if(IPH_V(iphdr) != 4) {
        return 0;
    }

    /* Immediately accept/decline packets that are fragments or has
       options. */
#if IP_REASSEMBLY == 0
    /*  if((IPH_OFFSET(iphdr) & htons(IP_OFFMASK | IP_MF)) != 0) {
      return 0;
      }*/
#endif /* IP_REASSEMBLY == 0 */

#if IP_OPTIONS == 0
    if(IPH_HL(iphdr) != 5) {
        return 0;
    }
#endif /* IP_OPTIONS == 0 */

    switch(IPH_PROTO(iphdr)) {
#if LWIP_UDP > 0
    case IP_PROTO_UDP:
        return udp_lookup(iphdr, inp);
        break;
#endif /* LWIP_UDP */
#if LWIP_TCP > 0
    case IP_PROTO_TCP:
        return 1;
#endif /* LWIP_TCP */
    case IP_PROTO_ICMP:
        return 1;
        break;
    default:
        return 0;
    }
}
开发者ID:Joel397,项目名称:Ongoing_work_files,代码行数:43,代码来源:ip.c

示例11: ip_debug_print

void
ip_debug_print(struct pbuf *p)
{
    struct ip_hdr *iphdr = p->payload;
    u8_t *payload;

    payload = (u8_t *)iphdr + IP_HLEN/sizeof(u8_t);

    DEBUGF(IP_DEBUG, ("IP header:\n"));
    DEBUGF(IP_DEBUG, ("+-------------------------------+\n"));
    DEBUGF(IP_DEBUG, ("|%2d |%2d |   %2d  |      %4d     | (v, hl, tos, len)\n",
                      IPH_V(iphdr),
                      IPH_HL(iphdr),
                      IPH_TOS(iphdr),
                      ntohs(IPH_LEN(iphdr))));
    DEBUGF(IP_DEBUG, ("+-------------------------------+\n"));
    DEBUGF(IP_DEBUG, ("|    %5d      |%d%d%d|    %4d   | (id, flags, offset)\n",
                      ntohs(IPH_ID(iphdr)),
                      ntohs(IPH_OFFSET(iphdr)) >> 15 & 1,
                      ntohs(IPH_OFFSET(iphdr)) >> 14 & 1,
                      ntohs(IPH_OFFSET(iphdr)) >> 13 & 1,
                      ntohs(IPH_OFFSET(iphdr)) & IP_OFFMASK));
    DEBUGF(IP_DEBUG, ("+-------------------------------+\n"));
    DEBUGF(IP_DEBUG, ("|   %2d  |   %2d  |    0x%04x     | (ttl, proto, chksum)\n",
                      IPH_TTL(iphdr),
                      IPH_PROTO(iphdr),
                      ntohs(IPH_CHKSUM(iphdr))));
    DEBUGF(IP_DEBUG, ("+-------------------------------+\n"));
    DEBUGF(IP_DEBUG, ("|  %3ld  |  %3ld  |  %3ld  |  %3ld  | (src)\n",
                      ntohl(iphdr->src.addr) >> 24 & 0xff,
                      ntohl(iphdr->src.addr) >> 16 & 0xff,
                      ntohl(iphdr->src.addr) >> 8 & 0xff,
                      ntohl(iphdr->src.addr) & 0xff));
    DEBUGF(IP_DEBUG, ("+-------------------------------+\n"));
    DEBUGF(IP_DEBUG, ("|  %3ld  |  %3ld  |  %3ld  |  %3ld  | (dest)\n",
                      ntohl(iphdr->dest.addr) >> 24 & 0xff,
                      ntohl(iphdr->dest.addr) >> 16 & 0xff,
                      ntohl(iphdr->dest.addr) >> 8 & 0xff,
                      ntohl(iphdr->dest.addr) & 0xff));
    DEBUGF(IP_DEBUG, ("+-------------------------------+\n"));
}
开发者ID:Joel397,项目名称:Ongoing_work_files,代码行数:41,代码来源:ip.c

示例12: _tcp_check_sum

/* Update TCP segment's check sum. */
static void _tcp_check_sum(struct ip_hdr* p, struct pbuf* pb)
{
	struct tcp_hdr* pTcpHdr = NULL;
	int iph_len = IPH_HL(p);
	int ip_len = ntohs(IPH_LEN(p)); /* Total IP packet's length. */
	int chksum = 0;
	ip_addr_t src, dest;

	iph_len *= 4;
	/* Locate TCP header. */
	pTcpHdr = (struct tcp_hdr*)((char*)p + iph_len);

	/* Validate pbuf object. */
	if (pb->tot_len < (iph_len + sizeof(struct tcp_hdr)))
	{
		return;
	}

	/* Validate IP packet's total length. */
	if (ip_len < (iph_len + sizeof(struct tcp_hdr)))
	{
		return;
	}

	/*
	* Reset TCP header's check sum since it's source address
	* or source port is changed after NATing.
	*/
	chksum = pTcpHdr->chksum;
	ip_addr_copy(src, p->src);
	ip_addr_copy(dest, p->dest);
	pbuf_header(pb, -iph_len); /* move to TCP header. */
	pTcpHdr->chksum = 0; /* Reset the original check sum. */
	pTcpHdr->chksum = inet_chksum_pseudo(pb, &src, &dest, IP_PROTO_TCP,
		ip_len - iph_len);
	pbuf_header(pb, iph_len); /* move back. */
	__NATDEBUG("%s: TCP check sum updated[%X] -> [%X]\r\n",
		__func__,
		chksum,
		pTcpHdr->chksum);
}
开发者ID:hellox-project,项目名称:HelloX_OS,代码行数:42,代码来源:easynat.c

示例13: InitNatEntry

/* Initialize a new NAT entry giving the IP header. */
static void InitNatEntry(__EASY_NAT_ENTRY* pEntry, struct ip_hdr* pHdr, struct netif* pOutIf)
{
	struct udp_hdr* pUdpHdr = NULL;
	struct tcp_hdr* pTcpHdr = NULL;
	int iph_len = 0;

	/* Set NAT entry according IP header. */
	pEntry->srcAddr_bef.addr = pHdr->src.addr;
	pEntry->dstAddr_bef.addr = pHdr->dest.addr;
	pEntry->srcAddr_aft.addr = pOutIf->ip_addr.addr; /* Changed. */
	pEntry->dstAddr_aft.addr = pHdr->dest.addr;
	pEntry->protocol = pHdr->_proto;
	pEntry->netif = pOutIf; 
	pEntry->ms = 0;
	pEntry->match_times++;

	iph_len = IPH_HL(pHdr);
	iph_len *= 4;
	switch (pHdr->_proto)
	{
	case IP_PROTO_TCP:
		pTcpHdr = (struct tcp_hdr*)((char*)pHdr + iph_len);
		pEntry->srcPort_bef = ntohs(pTcpHdr->src);
		pEntry->srcPort_aft = ntohs(GetTCPSrcPort());      /* Changed. */
		pEntry->dstPort_bef = ntohs(pTcpHdr->dest);
		pEntry->dstPort_aft = ntohs(pTcpHdr->dest);
		break;
	case IP_PROTO_UDP:
		pUdpHdr = (struct udp_hdr*)((char*)pHdr + iph_len);
		pEntry->srcPort_bef = ntohs(pUdpHdr->src);
		pEntry->srcPort_aft = ntohs(GetUDPSrcPort());      /* Changed. */
		pEntry->dstPort_bef = ntohs(pUdpHdr->dest);
		pEntry->dstPort_aft = ntohs(pUdpHdr->dest);
		break;
	case IP_PROTO_ICMP:
		InitNatEntry_ICMP(pEntry, pHdr);
		break;
	default:
		break;
	}
}
开发者ID:hellox-project,项目名称:HelloX_OS,代码行数:42,代码来源:easynat.c

示例14: ip_debug_print

void
ip_debug_print(struct pbuf *p)
{
  struct ip_hdr *iphdr = p->payload;
  u8_t *payload;

  payload = (u8_t *)iphdr + IP_HLEN;

  LWIP_DEBUGF(IP_DEBUG, ("IP header:\n"));
  LWIP_DEBUGF(IP_DEBUG, ("+-------------------------------+\n"));
  LWIP_DEBUGF(IP_DEBUG, ("|%2"S16_F" |%2"S16_F" |  0x%02"X16_F" |     %5"U16_F"     | (v, hl, tos, len)\n",
                    IPH_V(iphdr),
                    IPH_HL(iphdr),
                    IPH_TOS(iphdr),
                    ntohs(IPH_LEN(iphdr))));
  LWIP_DEBUGF(IP_DEBUG, ("+-------------------------------+\n"));
  LWIP_DEBUGF(IP_DEBUG, ("|    %5"U16_F"      |%"U16_F"%"U16_F"%"U16_F"|    %4"U16_F"   | (id, flags, offset)\n",
                    ntohs(IPH_ID(iphdr)),
                    ntohs(IPH_OFFSET(iphdr)) >> 15 & 1,
                    ntohs(IPH_OFFSET(iphdr)) >> 14 & 1,
                    ntohs(IPH_OFFSET(iphdr)) >> 13 & 1,
                    ntohs(IPH_OFFSET(iphdr)) & IP_OFFMASK));
  LWIP_DEBUGF(IP_DEBUG, ("+-------------------------------+\n"));
  LWIP_DEBUGF(IP_DEBUG, ("|  %3"U16_F"  |  %3"U16_F"  |    0x%04"X16_F"     | (ttl, proto, chksum)\n",
                    IPH_TTL(iphdr),
                    IPH_PROTO(iphdr),
                    ntohs(IPH_CHKSUM(iphdr))));
  LWIP_DEBUGF(IP_DEBUG, ("+-------------------------------+\n"));
  LWIP_DEBUGF(IP_DEBUG, ("|  %3"U16_F"  |  %3"U16_F"  |  %3"U16_F"  |  %3"U16_F"  | (src)\n",
                    ip4_addr1(&iphdr->src),
                    ip4_addr2(&iphdr->src),
                    ip4_addr3(&iphdr->src),
                    ip4_addr4(&iphdr->src)));
  LWIP_DEBUGF(IP_DEBUG, ("+-------------------------------+\n"));
  LWIP_DEBUGF(IP_DEBUG, ("|  %3"U16_F"  |  %3"U16_F"  |  %3"U16_F"  |  %3"U16_F"  | (dest)\n",
                    ip4_addr1(&iphdr->dest),
                    ip4_addr2(&iphdr->dest),
                    ip4_addr3(&iphdr->dest),
                    ip4_addr4(&iphdr->dest)));
  LWIP_DEBUGF(IP_DEBUG, ("+-------------------------------+\n"));
}
开发者ID:AldenHiggins,项目名称:ELEC424-Lab06-Scheduling-with-FreeRTOS,代码行数:41,代码来源:ip.c

示例15: show_ip_pkt

static void show_ip_pkt(struct pbuf *p)
{
	struct ip_hdr *iphdr = (struct ip_hdr *)p->payload;
	u8_t *payload;

	payload = (u8_t *)iphdr + IP_HLEN;

	_hx_printf("[%s]IP header:\r\n",__func__);
	_hx_printf("+-------------------------------+\r\n");
	_hx_printf("|%2"S16_F" |%2"S16_F" |  0x%02"X16_F" |     %5"U16_F"     | (v, hl, tos, len)\r\n",
		IPH_V(iphdr),
		IPH_HL(iphdr),
		IPH_TOS(iphdr),
		ntohs(IPH_LEN(iphdr)));
	_hx_printf("+-------------------------------+\r\n");
	_hx_printf("|    %5"U16_F"      |%"U16_F"%"U16_F"%"U16_F"|    %4"U16_F"   | (id, flags, offset)\r\n",
		ntohs(IPH_ID(iphdr)),
		ntohs(IPH_OFFSET(iphdr)) >> 15 & 1,
		ntohs(IPH_OFFSET(iphdr)) >> 14 & 1,
		ntohs(IPH_OFFSET(iphdr)) >> 13 & 1,
		ntohs(IPH_OFFSET(iphdr)) & IP_OFFMASK);
	_hx_printf("+-------------------------------+\r\n");
	_hx_printf("|  %3"U16_F"  |  %3"U16_F"  |    0x%04"X16_F"     | (ttl, proto, chksum)\r\n",
		IPH_TTL(iphdr),
		IPH_PROTO(iphdr),
		ntohs(IPH_CHKSUM(iphdr)));
	_hx_printf("+-------------------------------+\r\n");
	_hx_printf("|  %3"U16_F"  |  %3"U16_F"  |  %3"U16_F"  |  %3"U16_F"  | (src)\r\n",
		ip4_addr1_16(&iphdr->src),
		ip4_addr2_16(&iphdr->src),
		ip4_addr3_16(&iphdr->src),
		ip4_addr4_16(&iphdr->src));
	_hx_printf("+-------------------------------+\r\n");
	_hx_printf("|  %3"U16_F"  |  %3"U16_F"  |  %3"U16_F"  |  %3"U16_F"  | (dest)\r\n",
		ip4_addr1_16(&iphdr->dest),
		ip4_addr2_16(&iphdr->dest),
		ip4_addr3_16(&iphdr->dest),
		ip4_addr4_16(&iphdr->dest));
	_hx_printf("+-------------------------------+\r\n");
}
开发者ID:hellox-project,项目名称:HelloX_OS,代码行数:40,代码来源:easynat.c


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