- Timestamp:
- Jun 8, 2014 12:22:18 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/NetworkServices/NAT/pxping.c
r51574 r51575 6 6 #include "proxy_pollmgr.h" 7 7 #include "pxremap.h" 8 9 #include <iprt/string.h> 8 10 9 11 #ifndef RT_OS_WINDOWS … … 14 16 #endif 15 17 #include <netinet/in.h> 16 #include <arpa/inet.h> /* XXX: inet_ntop */17 18 #include <poll.h> 18 19 #include <stdint.h> … … 193 194 ipX_addr_t *dst, u16_t host_id); 194 195 196 static FNRTSTRFORMATTYPE pxping_pcb_rtstrfmt; 195 197 static struct ping_pcb *pxping_pcb_allocate(struct pxping *pxping); 196 198 static void pxping_pcb_register(struct pxping *pxping, struct ping_pcb *pcb); … … 199 201 static void pxping_timeout_add(struct pxping *pxping, struct ping_pcb *pcb); 200 202 static void pxping_timeout_del(struct pxping *pxping, struct ping_pcb *pcb); 201 static void pxping_pcb_debug_print(struct ping_pcb *pcb);202 203 203 204 static int pxping_pmgr_pump(struct pollmgr_handler *handler, SOCKET fd, int revents); … … 329 330 } 330 331 332 status = RTStrFormatTypeRegister("ping_pcb", pxping_pcb_rtstrfmt, NULL); 333 AssertRC(status); 334 331 335 return ERR_OK; 332 336 } … … 455 459 } 456 460 457 pxping_pcb_debug_print(pcb); /* XXX */458 DPRINTF((" seq %d len %u ttl %d\n",461 DPRINTF(("ping %p: %R[ping_pcb] seq %d len %u ttl %d\n", 462 pcb, pcb, 459 463 ntohs(icmph->seqno), (unsigned int)p->tot_len, 460 464 IPH_TTL(iph))); … … 673 677 } 674 678 675 pxping_pcb_debug_print(pcb); /* XXX */676 DPRINTF((" seq %d len %u hopl %d\n",679 DPRINTF(("ping %p: %R[ping_pcb] seq %d len %u hopl %d\n", 680 pcb, pcb, 677 681 ntohs(seq), (unsigned int)p->tot_len, 678 682 IP6H_HOPLIM(iph))); … … 747 751 748 752 749 static void 750 pxping_pcb_debug_print(struct ping_pcb *pcb) 751 { 752 char addrbuf[sizeof "ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255"]; 753 const char *addrstr; 754 int sdom = pcb->is_ipv6 ? AF_INET6 : AF_INET; 755 756 DPRINTF(("ping %p:", (void *)pcb)); 757 758 addrstr = inet_ntop(sdom, (void *)&pcb->src, addrbuf, sizeof(addrbuf)); 759 DPRINTF((" %s", addrstr)); 760 761 DPRINTF((" ->")); 762 763 addrstr = inet_ntop(sdom, (void *)&pcb->dst, addrbuf, sizeof(addrbuf)); 764 DPRINTF((" %s", addrstr)); 765 766 DPRINTF((" id %04x->%04x", ntohs(pcb->guest_id), ntohs(pcb->host_id))); 753 /** 754 * Formatter for %R[ping_pcb]. 755 */ 756 static DECLCALLBACK(size_t) 757 pxping_pcb_rtstrfmt(PFNRTSTROUTPUT pfnOutput, void *pvArgOutput, 758 const char *pszType, const void *pvValue, 759 int cchWidth, int cchPrecision, unsigned int fFlags, 760 void *pvUser) 761 { 762 const struct ping_pcb *pcb = (const struct ping_pcb *)pvValue; 763 size_t cb = 0; 764 765 NOREF(cchWidth); 766 NOREF(cchPrecision); 767 NOREF(fFlags); 768 NOREF(pvUser); 769 770 AssertReturn(strcmp(pszType, "ping_pcb") == 0, 0); 771 772 if (pcb == NULL) { 773 return RTStrFormat(pfnOutput, pvArgOutput, NULL, NULL, "(null)"); 774 } 775 776 /* XXX: %RTnaipv4 takes the value, but %RTnaipv6 takes the pointer */ 777 if (pcb->is_ipv6) { 778 cb += RTStrFormat(pfnOutput, pvArgOutput, NULL, NULL, 779 "%RTnaipv6 -> %RTnaipv6", &pcb->src, &pcb->dst); 780 } 781 else { 782 cb += RTStrFormat(pfnOutput, pvArgOutput, NULL, NULL, 783 "%RTnaipv4 -> %RTnaipv4", 784 ip4_addr_get_u32(ipX_2_ip(&pcb->src)), 785 ip4_addr_get_u32(ipX_2_ip(&pcb->dst))); 786 } 787 788 cb += RTStrFormat(pfnOutput, pvArgOutput, NULL, NULL, 789 " id %04x->%04x", ntohs(pcb->guest_id), ntohs(pcb->host_id)); 790 791 return cb; 767 792 } 768 793 … … 932 957 sys_mutex_unlock(&pxping->lock); 933 958 934 pxping_pcb_debug_print(pcb); /* XXX */ 935 DPRINTF((" - created\n")); 959 DPRINTF(("ping %p: %R[ping_pcb] - created\n", pcb, pcb)); 936 960 937 961 pxping_timer_needed(pxping); … … 939 963 else { 940 964 /* just bump up expiration timeout lazily */ 941 pxping_pcb_debug_print(pcb); /* XXX */942 DPRINTF((" - slot %d -> %d\n",965 DPRINTF(("ping %p: %R[ping_pcb] - slot %d -> %d\n", 966 pcb, pcb, 943 967 (unsigned int)pcb->timeout_slot, 944 968 (unsigned int)pxping->timeout_slot)); … … 1195 1219 seq = icmph->seqno; 1196 1220 1197 { 1198 char addrbuf[sizeof "255.255.255.255"]; 1199 const char *addrstr; 1200 1201 addrstr = inet_ntop(AF_INET, &peer->sin_addr, addrbuf, sizeof(addrbuf)); 1202 DPRINTF(("<--- PING %s id 0x%x seq %d\n", 1203 addrstr, ntohs(id), ntohs(seq))); 1204 } 1205 1221 DPRINTF(("<--- PING %RTnaipv4 id 0x%x seq %d\n", 1222 peer->sin_addr.s_addr, ntohs(id), ntohs(seq))); 1206 1223 1207 1224 /* … … 1339 1356 seq = oicmph->seqno; 1340 1357 1341 { 1342 char addrbuf[sizeof "255.255.255.255"]; 1343 const char *addrstr; 1344 1345 addrstr = inet_ntop(AF_INET, &oiph->dest, addrbuf, sizeof(addrbuf)); 1346 DPRINTF2(("%s: ping %s id 0x%x seq %d", 1347 __func__, addrstr, ntohs(id), ntohs(seq))); 1348 if (ICMPH_TYPE(icmph) == ICMP_DUR) { 1349 DPRINTF2((" unreachable (code %d)\n", ICMPH_CODE(icmph))); 1350 } 1351 else { 1352 DPRINTF2((" time exceeded\n")); 1353 } 1358 DPRINTF2(("%s: ping %RTnaipv4 id 0x%x seq %d", 1359 __func__, ip4_addr_get_u32(&oiph->dest), ntohs(id), ntohs(seq))); 1360 if (ICMPH_TYPE(icmph) == ICMP_DUR) { 1361 DPRINTF2((" unreachable (code %d)\n", ICMPH_CODE(icmph))); 1362 } 1363 else { 1364 DPRINTF2((" time exceeded\n")); 1354 1365 } 1355 1366 … … 1454 1465 int status; 1455 1466 1456 char addrbuf[sizeof "ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255"];1457 const char *addrstr;1458 1459 1467 /* 1460 1468 * Reads from raw IPv6 sockets deliver only the payload. Full … … 1497 1505 icmph = (struct icmp6_echo_hdr *)pollmgr_udpbuf; 1498 1506 1499 addrstr = inet_ntop(AF_INET6, (void *)&sin6.sin6_addr, 1500 addrbuf, sizeof(addrbuf)); 1501 DPRINTF2(("%s: %s ICMPv6: ", __func__, addrstr)); 1507 DPRINTF2(("%s: %RTnaipv6 ICMPv6: ", __func__, &sin6.sin6_addr)); 1502 1508 1503 1509 if (icmph->type == ICMP6_TYPE_EREP) {
Note:
See TracChangeset
for help on using the changeset viewer.