Changeset 25822 in vbox for trunk/src/VBox/Devices/Network
- Timestamp:
- Jan 14, 2010 9:09:04 AM (15 years ago)
- Location:
- trunk/src/VBox/Devices/Network/slirp
- Files:
-
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Network/slirp/bootp.c
r25362 r25822 88 88 return NULL; 89 89 90 paddr->s_addr = htonl(ntohl(pData->special_addr.s_addr) | (bc->number + START_ADDR));90 paddr->s_addr = RT_H2N_U32(RT_N2H_U32(pData->special_addr.s_addr) | (bc->number + START_ADDR)); 91 91 bc->addr.s_addr = paddr->s_addr; 92 92 return bc; … … 167 167 bc = &bootp_clients[i]; 168 168 bc->allocated = 1; 169 paddr->s_addr = htonl(ntohl(pData->special_addr.s_addr) | (i + START_ADDR));169 paddr->s_addr = RT_H2N_U32(RT_N2H_U32(pData->special_addr.s_addr) | (i + START_ADDR)); 170 170 return bc; 171 171 } … … 192 192 rbp->bp_giaddr.s_addr = bp->bp_giaddr.s_addr; 193 193 #if 0 /*check flags*/ 194 saddr.sin_port = htons(BOOTP_SERVER);195 daddr.sin_port = htons(BOOTP_CLIENT);194 saddr.sin_port = RT_H2N_U16_C(BOOTP_SERVER); 195 daddr.sin_port = RT_H2N_U16_C(BOOTP_CLIENT); 196 196 #endif 197 197 rbp->bp_htype = 1; … … 220 220 int added = 0; 221 221 uint8_t *q_dns_header = NULL; 222 uint32_t lease_time = htonl(LEASE_TIME);223 uint32_t netmask = htonl(pData->netmask);222 uint32_t lease_time = RT_H2N_U32_C(LEASE_TIME); 223 uint32_t netmask = RT_H2N_U32(pData->netmask); 224 224 225 225 rbp = mtod(m, struct bootp_t *); … … 244 244 } 245 245 #ifndef VBOX_WITH_NAT_SERVICE 246 saddr.s_addr = htonl(ntohl(pData->special_addr.s_addr) | CTL_ALIAS);246 saddr.s_addr = RT_H2N_U32(RT_N2H_U32(pData->special_addr.s_addr) | CTL_ALIAS); 247 247 #else 248 248 saddr.s_addr = pData->special_addr.s_addr; … … 274 274 if (pData->use_dns_proxy || pData->use_host_resolver) 275 275 { 276 uint32_t addr = htonl(ntohl(pData->special_addr.s_addr) | CTL_DNS);276 uint32_t addr = RT_H2N_U32(RT_N2H_U32(pData->special_addr.s_addr) | CTL_DNS); 277 277 FILL_BOOTP_EXT(q, RFC1533_DNS, 4, &addr); 278 278 goto skip_dns_servers; … … 441 441 else 442 442 { 443 if ((bp->bp_ciaddr.s_addr & htonl(pData->netmask)) != pData->special_addr.s_addr)443 if ((bp->bp_ciaddr.s_addr & RT_H2N_U32(pData->netmask)) != pData->special_addr.s_addr) 444 444 { 445 445 LogRel(("NAT: Client %R[IP4] requested IP -- sending NAK\n", &bp->bp_ciaddr)); … … 465 465 Assert(req_ip != NULL); 466 466 ui32 = *(uint32_t *)(req_ip + 2); 467 if ((ui32 & htonl(pData->netmask)) != pData->special_addr.s_addr)467 if ((ui32 & RT_H2N_U32(pData->netmask)) != pData->special_addr.s_addr) 468 468 { 469 469 LogRel(("NAT: address %R[IP4] has been requested -- sending NAK\n", &ui32)); … … 712 712 713 713 #ifndef VBOX_WITH_NAT_SERVICE 714 saddr.sin_addr.s_addr = htonl(ntohl(pData->special_addr.s_addr) | CTL_ALIAS);714 saddr.sin_addr.s_addr = RT_H2N_U32(RT_N2H_U32(pData->special_addr.s_addr) | CTL_ALIAS); 715 715 #else 716 716 saddr.sin_addr.s_addr = pData->special_addr.s_addr; … … 733 733 else 734 734 daddr.sin_addr.s_addr = rbp->bp_yiaddr.s_addr; /*unicast requested by client*/ 735 saddr.sin_port = htons(BOOTP_SERVER);736 daddr.sin_port = htons(BOOTP_CLIENT);735 saddr.sin_port = RT_H2N_U16_C(BOOTP_SERVER); 736 daddr.sin_port = RT_H2N_U16_C(BOOTP_CLIENT); 737 737 udp_output2(pData, NULL, m, &saddr, &daddr, IPTOS_LOWDELAY); 738 738 } -
trunk/src/VBox/Devices/Network/slirp/debug.c
r23466 r25822 207 207 buff[17] = 0; 208 208 lprint("%s %3d %15s %5d ", 209 buff, so->s, inet_ntoa(so->so_laddr), ntohs(so->so_lport));209 buff, so->s, inet_ntoa(so->so_laddr), RT_N2H_U16(so->so_lport)); 210 210 lprint("%15s %5d %5d %5d\n", 211 inet_ntoa(so->so_faddr), ntohs(so->so_fport),211 inet_ntoa(so->so_faddr), RT_N2H_U16(so->so_fport), 212 212 so->so_rcv.sb_cc, so->so_snd.sb_cc); 213 213 LOOP_LABEL(tcp, so, so_next); … … 221 221 buff[17] = 0; 222 222 lprint("%s %3d %15s %5d ", 223 buff, so->s, inet_ntoa(so->so_laddr), ntohs(so->so_lport));223 buff, so->s, inet_ntoa(so->so_laddr), RT_N2H_U16(so->so_lport)); 224 224 lprint("%15s %5d %5d %5d\n", 225 inet_ntoa(so->so_faddr), ntohs(so->so_fport),225 inet_ntoa(so->so_faddr), RT_N2H_U16(so->so_fport), 226 226 so->so_rcv.sb_cc, so->so_snd.sb_cc); 227 227 LOOP_LABEL(udp, so, so_next); … … 240 240 AssertReturn(strcmp(pszType, "IP4") == 0, 0); 241 241 242 ip = ntohl(*(uint32_t*)pvValue);242 ip = RT_N2H_U32(*(uint32_t*)pvValue); 243 243 return RTStrFormat(pfnOutput, pvArgOutput, NULL, 0, IP4_ADDR_PRINTF_FORMAT, 244 244 IP4_ADDR_PRINTF_DECOMP(ip)); … … 292 292 293 293 in_addr = (struct sockaddr_in *)&addr; 294 ip = ntohl(so->so_faddr.s_addr);294 ip = RT_N2H_U32(so->so_faddr.s_addr); 295 295 return RTStrFormat(pfnOutput, pvArgOutput, NULL, 0, "socket %4d:(proto:%u) " 296 296 "state=%04x ip=" IP4_ADDR_PRINTF_FORMAT ":%d " 297 297 "name=" IP4_ADDR_PRINTF_FORMAT ":%d", 298 298 so->s, so->so_type, so->so_state, IP4_ADDR_PRINTF_DECOMP(ip), 299 ntohs(so->so_fport),300 IP4_ADDR_PRINTF_DECOMP( ntohl(in_addr->sin_addr.s_addr)),301 ntohs(in_addr->sin_port));299 RT_N2H_U16(so->so_fport), 300 IP4_ADDR_PRINTF_DECOMP(RT_N2H_U32(in_addr->sin_addr.s_addr)), 301 RT_N2H_U16(in_addr->sin_port)); 302 302 } 303 303 -
trunk/src/VBox/Devices/Network/slirp/ip.h
r17191 r25822 55 55 #else 56 56 # ifndef NTOHL 57 # define NTOHL(d) ((d) = ntohl((d)))57 # define NTOHL(d) ((d) = RT_N2H_U32((d))) 58 58 # endif 59 59 # ifndef NTOHS 60 # define NTOHS(d) ((d) = ntohs((u_int16_t)(d)))60 # define NTOHS(d) ((d) = RT_N2H_U16((u_int16_t)(d))) 61 61 # endif 62 62 # ifndef HTONL 63 # define HTONL(d) ((d) = htonl((d)))63 # define HTONL(d) ((d) = RT_H2N_U32((d))) 64 64 # endif 65 65 # ifndef HTONS 66 # define HTONS(d) ((d) = htons((u_int16_t)(d)))66 # define HTONS(d) ((d) = RT_H2N_U16((u_int16_t)(d))) 67 67 # endif 68 68 #endif -
trunk/src/VBox/Devices/Network/slirp/ip_icmp.c
r25265 r25822 372 372 #endif 373 373 addr.sin_family = AF_INET; 374 if ((ip->ip_dst.s_addr & htonl(pData->netmask)) == pData->special_addr.s_addr)374 if ((ip->ip_dst.s_addr & RT_H2N_U32(pData->netmask)) == pData->special_addr.s_addr) 375 375 { 376 376 /* It's an alias */ 377 switch ( ntohl(ip->ip_dst.s_addr) & ~pData->netmask)377 switch (RT_N2H_U32(ip->ip_dst.s_addr) & ~pData->netmask) 378 378 { 379 379 case CTL_DNS: -
trunk/src/VBox/Devices/Network/slirp/ip_input.c
r25799 r25822 102 102 DEBUG_ARG("m = %lx", (long)m); 103 103 ip = mtod(m, struct ip *); 104 Log2(("ip_dst=%R[IP4](len:%d) m_len = %d", &ip->ip_dst, ntohs(ip->ip_len), m->m_len));105 Log2(("ip_dst=%R[IP4](len:%d) m_len = %d\n", &ip->ip_dst, ntohs(ip->ip_len), m->m_len));104 Log2(("ip_dst=%R[IP4](len:%d) m_len = %d", &ip->ip_dst, RT_N2H_U16(ip->ip_len), m->m_len)); 105 Log2(("ip_dst=%R[IP4](len:%d) m_len = %d\n", &ip->ip_dst, RT_N2H_U16(ip->ip_len), m->m_len)); 106 106 107 107 ipstat.ips_total++; … … 112 112 STAM_PROFILE_STOP(&pData->StatALIAS_input, b); 113 113 Log2(("NAT: LibAlias return %d\n", rc)); 114 if (m->m_len != ntohs(ip->ip_len)) 115 { 116 m->m_len = ntohs(ip->ip_len); 117 } 114 if (m->m_len != RT_N2H_U16(ip->ip_len)) 115 m->m_len = RT_N2H_U16(ip->ip_len); 118 116 } 119 117 … … 291 289 * before proceeding further 292 290 */ 293 struct ipq_t * q= TAILQ_LAST(head, ipqhead);294 if ( q== NULL)291 struct ipq_t *pHead = TAILQ_LAST(head, ipqhead); 292 if (pHead == NULL) 295 293 { 296 294 /* gak */ 297 295 for (i = 0; i < IPREASS_NHASH; i++) 298 296 { 299 struct ipq_t * r= TAILQ_LAST(&ipq[i], ipqhead);300 if ( r)297 struct ipq_t *pTail = TAILQ_LAST(&ipq[i], ipqhead); 298 if (pTail) 301 299 { 302 ipstat.ips_fragtimeout += r->ipq_nfrags;303 ip_freef(pData, &ipq[i], r);300 ipstat.ips_fragtimeout += pTail->ipq_nfrags; 301 ip_freef(pData, &ipq[i], pTail); 304 302 break; 305 303 } … … 308 306 else 309 307 { 310 ipstat.ips_fragtimeout += q->ipq_nfrags;311 ip_freef(pData, head, q);308 ipstat.ips_fragtimeout += pHead->ipq_nfrags; 309 ip_freef(pData, head, pHead); 312 310 } 313 311 } -
trunk/src/VBox/Devices/Network/slirp/ip_output.c
r25265 r25822 128 128 ip->ip_v = IPVERSION; 129 129 ip->ip_off &= IP_DF; 130 ip->ip_id = htons(ip_currid++);130 ip->ip_id = RT_H2N_U16(ip_currid++); 131 131 ip->ip_hl = hlen >> 2; 132 132 ipstat.ips_localout++; … … 175 175 if ((u_int16_t)ip->ip_len <= if_mtu) 176 176 { 177 ip->ip_len = htons((u_int16_t)ip->ip_len);178 ip->ip_off = htons((u_int16_t)ip->ip_off);177 ip->ip_len = RT_H2N_U16((u_int16_t)ip->ip_len); 178 ip->ip_off = RT_H2N_U16((u_int16_t)ip->ip_off); 179 179 ip->ip_sum = 0; 180 180 ip->ip_sum = cksum(m, hlen); … … 182 182 { 183 183 #ifndef VBOX_WITH_SLIRP_BSD_MBUF 184 STAM_PROFILE_START(&pData->StatALIAS_output, a);184 STAM_PROFILE_START(&pData->StatALIAS_output, b); 185 185 rc = LibAliasOut((m->m_la ? m->m_la : pData->proxy_alias), 186 186 mtod(m, char *), m->m_len); … … 188 188 #else 189 189 struct m_tag *t; 190 STAM_PROFILE_START(&pData->StatALIAS_output, a);190 STAM_PROFILE_START(&pData->StatALIAS_output, b); 191 191 if (t = m_tag_find(m, PACKET_TAG_ALIAS, NULL) != 0) 192 192 rc = LibAliasOut((struct libalias *)&t[1], mtod(m, char *), … … 202 202 } 203 203 #endif 204 STAM_PROFILE_STOP(&pData->StatALIAS_output, a);204 STAM_PROFILE_STOP(&pData->StatALIAS_output, b); 205 205 } 206 206 … … 245 245 int tmplen = 0; 246 246 #endif 247 int rc ;247 int rcLa; 248 248 HTONS(ip->ip_len); 249 249 HTONS(ip->ip_off); … … 251 251 ip->ip_sum = cksum(m, hlen); 252 252 #ifndef VBOX_WITH_SLIRP_BSD_MBUF 253 rc = LibAliasOut((m->m_la ? m->m_la : pData->proxy_alias),254 mtod(m, char *), m->m_len);253 rcLa = LibAliasOut((m->m_la ? m->m_la : pData->proxy_alias), 254 mtod(m, char *), m->m_len); 255 255 #else 256 256 if (m->m_next != NULL) … … 270 270 271 271 if (t = m_tag_find(m, PACKET_TAG_ALIAS, NULL) != 0) 272 rc = LibAliasOut((struct libalias *)&t[1], tmpbuf, tmplen);272 rcLa = LibAliasOut((struct libalias *)&t[1], tmpbuf, tmplen); 273 273 else 274 rc = LibAliasOut(pData->proxy_alias, tmpbuf, tmplen);274 rcLa = LibAliasOut(pData->proxy_alias, tmpbuf, tmplen); 275 275 276 276 if (m->m_next != NULL) 277 277 { 278 if (rc != PKT_ALIAS_IGNORED)278 if (rcLa != PKT_ALIAS_IGNORED) 279 279 { 280 280 struct ip *tmpip = (struct ip *)tmpbuf; 281 m_copyback(pData, m, 0, ntohs(tmpip->ip_len) + (tmpip->ip_hl << 2), tmpbuf);281 m_copyback(pData, m, 0, RT_N2H_U16(tmpip->ip_len) + (tmpip->ip_hl << 2), tmpbuf); 282 282 } 283 283 if (tmpbuf != NULL) 284 284 RTMemFree(tmpbuf); 285 285 } 286 if (rc == PKT_ALIAS_IGNORED)286 if (rcLa == PKT_ALIAS_IGNORED) 287 287 { 288 288 Log(("NAT: packet was droppped\n")); … … 292 292 NTOHS(ip->ip_len); 293 293 NTOHS(ip->ip_off); 294 Log2(("NAT: LibAlias return %d\n", rc ));294 Log2(("NAT: LibAlias return %d\n", rcLa)); 295 295 } 296 296 … … 337 337 else 338 338 mhip->ip_off |= IP_MF; 339 mhip->ip_len = htons((u_int16_t)(len + mhlen));339 mhip->ip_len = RT_H2N_U16((u_int16_t)(len + mhlen)); 340 340 341 341 #ifndef VBOX_WITH_SLIRP_BSD_MBUF … … 353 353 m->m_len += mhlen; 354 354 RTMemFree(buf); 355 m->m_len += ntohs(mhip->ip_len);356 #endif 357 358 mhip->ip_off = htons((u_int16_t)mhip->ip_off);355 m->m_len += RT_N2H_U16(mhip->ip_len); 356 #endif 357 358 mhip->ip_off = RT_H2N_U16((u_int16_t)mhip->ip_off); 359 359 mhip->ip_sum = 0; 360 360 mhip->ip_sum = cksum(m, mhlen); … … 369 369 m = m0; 370 370 m_adj(m, hlen + firstlen - (u_int16_t)ip->ip_len); 371 ip->ip_len = htons((u_int16_t)m->m_len);372 ip->ip_off = htons((u_int16_t)(ip->ip_off | IP_MF));371 ip->ip_len = RT_H2N_U16((u_int16_t)m->m_len); 372 ip->ip_off = RT_H2N_U16((u_int16_t)(ip->ip_off | IP_MF)); 373 373 ip->ip_sum = 0; 374 374 ip->ip_sum = cksum(m, hlen); -
trunk/src/VBox/Devices/Network/slirp/mbuf.c
r25375 r25822 133 133 { 134 134 #if 1 135 intrc = mbuf_zone_init(pData);135 rc = mbuf_zone_init(pData); 136 136 if (rc == 0) 137 137 goto recheck_zone; -
trunk/src/VBox/Devices/Network/slirp/slirp.c
r25799 r25822 282 282 283 283 LogRel(("NAT: adding %R[IP4] to DNS server list\n", &InAddr)); 284 if ((InAddr.s_addr & htonl(IN_CLASSA_NET)) == ntohl(INADDR_LOOPBACK & IN_CLASSA_NET))285 pDns->de_addr.s_addr = htonl(ntohl(pData->special_addr.s_addr) | CTL_ALIAS);284 if ((InAddr.s_addr & RT_H2N_U32_C(IN_CLASSA_NET)) == RT_N2H_U32_C(INADDR_LOOPBACK & IN_CLASSA_NET)) 285 pDns->de_addr.s_addr = RT_H2N_U32(RT_N2H_U32(pData->special_addr.s_addr) | CTL_ALIAS); 286 286 else 287 287 pDns->de_addr.s_addr = InAddr.s_addr; … … 433 433 /* check */ 434 434 pDns->de_addr.s_addr = tmp_addr.s_addr; 435 if ((pDns->de_addr.s_addr & htonl(IN_CLASSA_NET)) == ntohl(INADDR_LOOPBACK & IN_CLASSA_NET))436 { 437 pDns->de_addr.s_addr = htonl(ntohl(pData->special_addr.s_addr) | CTL_ALIAS);435 if ((pDns->de_addr.s_addr & RT_H2N_U32_C(IN_CLASSA_NET)) == RT_N2H_U32_C(INADDR_LOOPBACK & IN_CLASSA_NET)) 436 { 437 pDns->de_addr.s_addr = RT_H2N_U32(RT_N2H_U32(pData->special_addr.s_addr) | CTL_ALIAS); 438 438 } 439 439 TAILQ_INSERT_HEAD(&pData->pDnsList, pDns, de_list); … … 580 580 #endif 581 581 pData->slirp_ethaddr = &special_ethaddr[0]; 582 alias_addr.s_addr = pData->special_addr.s_addr | htonl(CTL_ALIAS);582 alias_addr.s_addr = pData->special_addr.s_addr | RT_H2N_U32_C(CTL_ALIAS); 583 583 /* @todo: add ability to configure this staff */ 584 584 … … 609 609 flags |= PKT_ALIAS_LOG; /* set logging */ 610 610 flags = LibAliasSetMode(pData->proxy_alias, flags, ~0); 611 proxy_addr.s_addr = htonl(ntohl(pData->special_addr.s_addr) | CTL_ALIAS);611 proxy_addr.s_addr = RT_H2N_U32(RT_N2H_U32(pData->special_addr.s_addr) | CTL_ALIAS); 612 612 LibAliasSetAddress(pData->proxy_alias, proxy_addr); 613 613 ftp_alias_load(pData); … … 1447 1447 eh = mtod(m, struct ethhdr *); 1448 1448 ah = (struct arphdr *)&eh[1]; 1449 htip = ntohl(*(uint32_t*)ah->ar_tip);1449 htip = RT_N2H_U32(*(uint32_t*)ah->ar_tip); 1450 1450 tip = *(uint32_t*)ah->ar_tip; 1451 1451 1452 ar_op = ntohs(ah->ar_op); 1452 ar_op = RT_N2H_U16(ah->ar_op); 1453 1453 1454 switch (ar_op) 1454 1455 { … … 1479 1480 goto arp_ok; 1480 1481 #endif 1481 if ((htip & pData->netmask) == ntohl(pData->special_addr.s_addr))1482 if ((htip & pData->netmask) == RT_N2H_U32(pData->special_addr.s_addr)) 1482 1483 { 1483 1484 if ( CTL_CHECK(htip, CTL_DNS) … … 1497 1498 1498 1499 arp_ok: 1499 rah->ar_hrd = htons(1);1500 rah->ar_pro = htons(ETH_P_IP);1500 rah->ar_hrd = RT_H2N_U16_C(1); 1501 rah->ar_pro = RT_H2N_U16_C(ETH_P_IP); 1501 1502 rah->ar_hln = ETH_ALEN; 1502 1503 rah->ar_pln = 4; 1503 rah->ar_op = htons(ARPOP_REPLY);1504 rah->ar_op = RT_H2N_U16_C(ARPOP_REPLY); 1504 1505 memcpy(rah->ar_sha, special_ethaddr, ETH_ALEN); 1505 1506 … … 1578 1579 } 1579 1580 eh = mtod(m, struct ethhdr *); 1580 proto = ntohs(eh->h_proto);1581 proto = RT_N2H_U16(eh->h_proto); 1581 1582 #else 1582 1583 Log2(("NAT: slirp_input %d\n", pkt_len)); … … 1617 1618 m->m_len = pkt_len ; 1618 1619 memcpy(m->m_data, pkt, pkt_len); 1619 proto = ntohs(*(uint16_t *)(pkt + 12));1620 proto = RT_N2H_U16(*(uint16_t *)(pkt + 12)); 1620 1621 #endif 1621 1622 /* Note: we add to align the IP header */ … … 1721 1722 } 1722 1723 #endif 1723 eh->h_proto = htons(eth_proto);1724 eh->h_proto = RT_H2N_U16(eth_proto); 1724 1725 #ifdef VBOX_WITH_SLIRP_BSD_MBUF 1725 1726 m_copydata(m, 0, mlen, (char *)buf); … … 1816 1817 1817 1818 if (rule->proto == IPPROTO_UDP) 1818 so = udp_listen(pData, rule->bind_ip.s_addr, htons(rule->host_port), guest_addr,1819 htons(rule->guest_port), 0);1819 so = udp_listen(pData, rule->bind_ip.s_addr, RT_H2N_U16(rule->host_port), guest_addr, 1820 RT_H2N_U16(rule->guest_port), 0); 1820 1821 else 1821 so = solisten(pData, rule->bind_ip.s_addr, htons(rule->host_port), guest_addr,1822 htons(rule->guest_port), 0);1822 so = solisten(pData, rule->bind_ip.s_addr, RT_H2N_U16(rule->host_port), guest_addr, 1823 RT_H2N_U16(rule->guest_port), 0); 1823 1824 1824 1825 if (so == NULL) … … 1843 1844 flags = LibAliasSetMode(lib, flags, ~0); 1844 1845 1845 alias.s_addr = htonl(ntohl(guest_addr) | CTL_ALIAS);1846 alias_link = LibAliasRedirectPort(lib, psin->sin_addr, htons(rule->host_port),1847 alias, htons(rule->guest_port),1846 alias.s_addr = RT_H2N_U32(RT_N2H_U32(guest_addr) | CTL_ALIAS); 1847 alias_link = LibAliasRedirectPort(lib, psin->sin_addr, RT_H2N_U16(rule->host_port), 1848 alias, RT_H2N_U16(rule->guest_port), 1848 1849 pData->special_addr, -1, /* not very clear for now */ 1849 1850 rule->proto); … … 1905 1906 { 1906 1907 return add_exec(&exec_list, do_pty, (char *)args, 1907 addr_low_byte, htons(guest_port));1908 addr_low_byte, RT_H2N_U16(guest_port)); 1908 1909 } 1909 1910 … … 1987 1988 Log2(("next_server:%s\n", next_server)); 1988 1989 if (next_server == NULL) 1989 pData->tftp_server.s_addr = htonl(ntohl(pData->special_addr.s_addr) | CTL_TFTP);1990 pData->tftp_server.s_addr = RT_H2N_U32(RT_N2H_U32(pData->special_addr.s_addr) | CTL_TFTP); 1990 1991 else 1991 1992 inet_aton(next_server, &pData->tftp_server); … … 2117 2118 memset(ehdr->h_source, 0xff, ETH_ALEN); 2118 2119 ahdr = (struct arphdr *)&ehdr[1]; 2119 ahdr->ar_hrd = htons(1);2120 ahdr->ar_pro = htons(ETH_P_IP);2120 ahdr->ar_hrd = RT_H2N_U16_C(1); 2121 ahdr->ar_pro = RT_H2N_U16_C(ETH_P_IP); 2121 2122 ahdr->ar_hln = ETH_ALEN; 2122 2123 ahdr->ar_pln = 4; 2123 ahdr->ar_op = htons(ARPOP_REQUEST);2124 ahdr->ar_op = RT_H2N_U16_C(ARPOP_REQUEST); 2124 2125 memcpy(ahdr->ar_sha, special_ethaddr, ETH_ALEN); 2125 *(uint32_t *)ahdr->ar_sip = htonl(ntohl(pData->special_addr.s_addr) | CTL_ALIAS);2126 *(uint32_t *)ahdr->ar_sip = RT_H2N_U32(RT_N2H_U32(pData->special_addr.s_addr) | CTL_ALIAS); 2126 2127 memset(ahdr->ar_tha, 0xff, ETH_ALEN); /*broadcast*/ 2127 2128 *(uint32_t *)ahdr->ar_tip = dst; -
trunk/src/VBox/Devices/Network/slirp/slirp.h
r25362 r25822 33 33 # include <io.h> 34 34 #endif 35 #include <iprt/asm.h> 35 36 #include <iprt/assert.h> 36 37 #include <iprt/string.h> -
trunk/src/VBox/Devices/Network/slirp/socket.c
r25265 r25822 596 596 */ 597 597 len = M_FREEROOM(m); 598 /* if (so->so_fport != htons(53)) */598 /* if (so->so_fport != RT_H2N_U16_C(53)) */ 599 599 rc = ioctlsocket(so->s, FIONREAD, &n); 600 600 if ( rc == -1 … … 708 708 if (so->so_expire) 709 709 { 710 if (so->so_fport != htons(53))710 if (so->so_fport != RT_H2N_U16_C(53)) 711 711 so->so_expire = curtime + SO_EXPIRE; 712 712 } … … 716 716 */ 717 717 #ifndef VBOX_WITH_SLIRP_BSD_MBUF 718 if (so->so_fport == htons(53))718 if (so->so_fport == RT_H2N_U16_C(53)) 719 719 dnsproxy_answer(pData, so, m); 720 720 #endif … … 765 765 paddr = (struct sockaddr_in *)&addr; 766 766 paddr->sin_family = AF_INET; 767 if ((so->so_faddr.s_addr & htonl(pData->netmask)) == pData->special_addr.s_addr)767 if ((so->so_faddr.s_addr & RT_H2N_U32(pData->netmask)) == pData->special_addr.s_addr) 768 768 { 769 769 /* It's an alias */ 770 uint32_t last_byte = ntohl(so->so_faddr.s_addr) & ~pData->netmask;770 uint32_t last_byte = RT_N2H_U32(so->so_faddr.s_addr) & ~pData->netmask; 771 771 switch(last_byte) 772 772 { … … 802 802 803 803 DEBUG_MISC((dfd, " sendto()ing, addr.sin_port=%d, addr.sin_addr.s_addr=%.16s\n", 804 ntohs(paddr->sin_port), inet_ntoa(paddr->sin_addr)));804 RT_N2H_U16(paddr->sin_port), inet_ntoa(paddr->sin_addr))); 805 805 806 806 /* Don't care what port we get */ -
trunk/src/VBox/Devices/Network/slirp/tcp_input.c
r22584 r25822 352 352 tlen = ((struct ip *)ti)->ip_len; 353 353 memset(ti->ti_x1, 0, 9); 354 ti->ti_len = htons((u_int16_t)tlen);354 ti->ti_len = RT_H2N_U16((u_int16_t)tlen); 355 355 len = sizeof(struct ip ) + tlen; 356 356 /* keep checksum for ICMP reply … … 392 392 || ( optlen > TCPOLEN_TSTAMP_APPA 393 393 && optp[TCPOLEN_TSTAMP_APPA] == TCPOPT_EOL)) && 394 *(u_int32_t *)optp == htonl(TCPOPT_TSTAMP_HDR) &&394 *(u_int32_t *)optp == RT_H2N_U32_C(TCPOPT_TSTAMP_HDR) && 395 395 (ti->ti_flags & TH_SYN) == 0) 396 396 { 397 397 ts_present = 1; 398 ts_val = ntohl(*(u_int32_t *)(optp + 4));399 ts_ecr = ntohl(*(u_int32_t *)(optp + 8));398 ts_val = RT_N2H_U32(*(u_int32_t *)(optp + 4)); 399 ts_ecr = RT_N2H_U32(*(u_int32_t *)(optp + 8)); 400 400 optp = NULL; / * we have parsed the options * / 401 401 } -
trunk/src/VBox/Devices/Network/slirp/tcp_output.c
r23462 r25822 301 301 opt[0] = TCPOPT_MAXSEG; 302 302 opt[1] = 4; 303 mss = htons((u_int16_t) tcp_mss(pData, tp, 0));303 mss = RT_H2N_U16((u_int16_t) tcp_mss(pData, tp, 0)); 304 304 memcpy((caddr_t)(opt + 2), (caddr_t)&mss, sizeof(mss)); 305 305 optlen = 4; … … 310 310 || (tp->t_flags & TF_RCVD_SCALE))) 311 311 { 312 *((u_int32_t *) (opt + optlen)) = htonl( TCPOPT_NOP << 24313 | TCPOPT_WINDOW << 16314 | TCPOLEN_WINDOW << 8315 | tp->request_r_scale);312 *((u_int32_t *) (opt + optlen)) = RT_H2N_U32( TCPOPT_NOP << 24 313 | TCPOPT_WINDOW << 16 314 | TCPOLEN_WINDOW << 8 315 | tp->request_r_scale); 316 316 optlen += 4; 317 317 } … … 334 334 335 335 /* Form timestamp option as shown in appendix A of RFC 1323. */ 336 *lp++ = htonl(TCPOPT_TSTAMP_HDR);337 *lp++ = htonl(tcp_now);338 *lp = htonl(tp->ts_recent);336 *lp++ = RT_H2N_U32_C(TCPOPT_TSTAMP_HDR); 337 *lp++ = RT_H2N_U32(tcp_now); 338 *lp = RT_H2N_U32(tp->ts_recent); 339 339 optlen += TCPOLEN_TSTAMP_APPA; 340 340 } … … 519 519 */ 520 520 if (len || (flags & (TH_SYN|TH_FIN)) || tp->t_timer[TCPT_PERSIST]) 521 ti->ti_seq = htonl(tp->snd_nxt);521 ti->ti_seq = RT_H2N_U32(tp->snd_nxt); 522 522 else 523 ti->ti_seq = htonl(tp->snd_max);524 ti->ti_ack = htonl(tp->rcv_nxt);523 ti->ti_seq = RT_H2N_U32(tp->snd_max); 524 ti->ti_ack = RT_H2N_U32(tp->rcv_nxt); 525 525 if (optlen) 526 526 { … … 539 539 if (win < (long)(tp->rcv_adv - tp->rcv_nxt)) 540 540 win = (long)(tp->rcv_adv - tp->rcv_nxt); 541 ti->ti_win = htons((u_int16_t) (win>>tp->rcv_scale));541 ti->ti_win = RT_H2N_U16((u_int16_t) (win>>tp->rcv_scale)); 542 542 543 543 #if 0 544 544 if (SEQ_GT(tp->snd_up, tp->snd_nxt)) 545 545 { 546 ti->ti_urp = htons((u_int16_t)(tp->snd_up - tp->snd_nxt));546 ti->ti_urp = RT_H2N_U16((u_int16_t)(tp->snd_up - tp->snd_nxt)); 547 547 #else 548 548 if (SEQ_GT(tp->snd_up, tp->snd_una)) 549 549 { 550 ti->ti_urp = htons((u_int16_t)(tp->snd_up - ntohl(ti->ti_seq)));550 ti->ti_urp = RT_H2N_U16((u_int16_t)(tp->snd_up - RT_N2H_U32(ti->ti_seq))); 551 551 #endif 552 552 ti->ti_flags |= TH_URG; … … 566 566 */ 567 567 if (len + optlen) 568 ti->ti_len = htons((u_int16_t)(sizeof (struct tcphdr)569 + optlen + len));568 ti->ti_len = RT_H2N_U16((u_int16_t)(sizeof (struct tcphdr) 569 + optlen + len)); 570 570 ti->ti_sum = cksum(m, (int)(hdrlen + len)); 571 571 -
trunk/src/VBox/Devices/Network/slirp/tcp_subr.c
r25754 r25822 75 75 memset(n->ti_x1, 0, 9); 76 76 n->ti_pr = IPPROTO_TCP; 77 n->ti_len = htons(sizeof (struct tcpiphdr) - sizeof (struct ip));77 n->ti_len = RT_H2N_U16(sizeof (struct tcpiphdr) - sizeof (struct ip)); 78 78 n->ti_src = so->so_faddr; 79 79 n->ti_dst = so->so_laddr; … … 156 156 #undef xchg 157 157 } 158 ti->ti_len = htons((u_short)(sizeof (struct tcphdr) + tlen));158 ti->ti_len = RT_H2N_U16((u_short)(sizeof (struct tcphdr) + tlen)); 159 159 tlen += sizeof (struct tcpiphdr); 160 160 m->m_len = tlen; 161 161 162 162 memset(ti->ti_x1, 0, 9); 163 ti->ti_seq = htonl(seq);164 ti->ti_ack = htonl(ack);163 ti->ti_seq = RT_H2N_U32(seq); 164 ti->ti_ack = RT_H2N_U32(ack); 165 165 ti->ti_x2 = 0; 166 166 ti->ti_off = sizeof (struct tcphdr) >> 2; 167 167 ti->ti_flags = flags; 168 168 if (tp) 169 ti->ti_win = htons((u_int16_t) (win >> tp->rcv_scale));169 ti->ti_win = RT_H2N_U16((u_int16_t) (win >> tp->rcv_scale)); 170 170 else 171 ti->ti_win = htons((u_int16_t)win);171 ti->ti_win = RT_H2N_U16((u_int16_t)win); 172 172 ti->ti_urp = 0; 173 173 ti->ti_sum = 0; … … 407 407 408 408 addr.sin_family = AF_INET; 409 if ((so->so_faddr.s_addr & htonl(pData->netmask)) == pData->special_addr.s_addr)409 if ((so->so_faddr.s_addr & RT_H2N_U32(pData->netmask)) == pData->special_addr.s_addr) 410 410 { 411 411 /* It's an alias */ 412 switch( ntohl(so->so_faddr.s_addr) & ~pData->netmask)412 switch(RT_N2H_U32(so->so_faddr.s_addr) & ~pData->netmask) 413 413 { 414 414 case CTL_DNS: … … 425 425 DEBUG_MISC((dfd, " connect()ing, addr.sin_port=%d, " 426 426 "addr.sin_addr.s_addr=%.16s\n", 427 ntohs(addr.sin_port), inet_ntoa(addr.sin_addr)));427 RT_N2H_U16(addr.sin_port), inet_ntoa(addr.sin_addr))); 428 428 /* We don't care what port we get */ 429 429 ret = connect(s,(struct sockaddr *)&addr,sizeof (addr)); -
trunk/src/VBox/Devices/Network/slirp/tftp.c
r23369 r25822 136 136 m->m_data += sizeof(struct udpiphdr); 137 137 138 tp->tp_op = htons(TFTP_OACK);138 tp->tp_op = RT_H2N_U16_C(TFTP_OACK); 139 139 n += RTStrPrintf((char *)tp->x.tp_buf + n, M_FREEROOM(m), "%s", key) + 1; 140 140 n += RTStrPrintf((char *)tp->x.tp_buf + n, M_FREEROOM(m), "%u", value) + 1; … … 175 175 m->m_data += sizeof(struct udpiphdr); 176 176 177 tp->tp_op = htons(TFTP_ERROR);178 tp->x.tp_error.tp_error_code = htons(errorcode);177 tp->tp_op = RT_H2N_U16_C(TFTP_ERROR); 178 tp->x.tp_error.tp_error_code = RT_H2N_U16(errorcode); 179 179 strcpy((char *)tp->x.tp_error.tp_msg, msg); 180 180 … … 224 224 m->m_data += sizeof(struct udpiphdr); 225 225 226 tp->tp_op = htons(TFTP_DATA);227 tp->x.tp_data.tp_block_nr = htons(block_nr);226 tp->tp_op = RT_H2N_U16_C(TFTP_DATA); 227 tp->x.tp_data.tp_block_nr = RT_H2N_U16(block_nr); 228 228 229 229 saddr.sin_addr = recv_tp->ip.ip_dst; … … 385 385 386 386 if (tftp_send_data(pData, &tftp_sessions[s], 387 ntohs(tp->x.tp_data.tp_block_nr) + 1, tp) < 0)387 RT_N2H_U16(tp->x.tp_data.tp_block_nr) + 1, tp) < 0) 388 388 { 389 389 /* XXX */ … … 395 395 struct tftp_t *tp = (struct tftp_t *)m->m_data; 396 396 397 switch( ntohs(tp->tp_op))397 switch(RT_N2H_U16(tp->tp_op)) 398 398 { 399 399 case TFTP_RRQ: -
trunk/src/VBox/Devices/Network/slirp/udp.c
r25747 r25822 106 106 * If not enough data to reflect UDP length, drop. 107 107 */ 108 len = ntohs((u_int16_t)uh->uh_ulen);108 len = RT_N2H_U16((u_int16_t)uh->uh_ulen); 109 109 Assert((ip->ip_len == len)); 110 110 Assert((ip->ip_len + iphlen == m->m_len)); … … 156 156 * handle DHCP/BOOTP 157 157 */ 158 if ( ntohs(uh->uh_dport) == BOOTP_SERVER)158 if (uh->uh_dport == RT_H2N_U16_C(BOOTP_SERVER)) 159 159 { 160 160 bootp_input(pData, m); … … 163 163 164 164 if ( pData->use_host_resolver 165 && ntohs(uh->uh_dport) == 53166 && CTL_CHECK( ntohl(ip->ip_dst.s_addr), CTL_DNS))165 && uh->uh_dport == RT_H2N_U16_C(53) 166 && CTL_CHECK(RT_N2H_U32(ip->ip_dst.s_addr), CTL_DNS)) 167 167 { 168 168 struct sockaddr_in dst, src; … … 182 182 */ 183 183 #ifndef VBOX_WITH_SLIRP_BSD_MBUF 184 if ( ntohs(uh->uh_dport) == TFTP_SERVER185 && CTL_CHECK( ntohl(ip->ip_dst.s_addr), CTL_TFTP))184 if ( uh->uh_dport == RT_H2N_U16_C(TFTP_SERVER) 185 && CTL_CHECK(RT_N2H_U32(ip->ip_dst.s_addr), CTL_TFTP)) 186 186 { 187 187 tftp_input(pData, m); … … 259 259 */ 260 260 if ( pData->use_dns_proxy 261 && (ip->ip_dst.s_addr == htonl(ntohl(pData->special_addr.s_addr) | CTL_DNS))262 && ( ntohs(uh->uh_dport) == 53))261 && (ip->ip_dst.s_addr == RT_H2N_U32(RT_N2H_U32(pData->special_addr.s_addr) | CTL_DNS)) 262 && (uh->uh_dport == RT_H2N_U16_C(53))) 263 263 { 264 264 dnsproxy_query(pData, so, m, iphlen); … … 343 343 memset(ui->ui_x1, 0, 9); 344 344 ui->ui_pr = IPPROTO_UDP; 345 ui->ui_len = htons(m->m_len - sizeof(struct ip));345 ui->ui_len = RT_H2N_U16(m->m_len - sizeof(struct ip)); 346 346 /* XXXXX Check for from-one-location sockets, or from-any-location sockets */ 347 347 ui->ui_src = saddr->sin_addr; … … 377 377 378 378 saddr = *addr; 379 if ((so->so_faddr.s_addr & htonl(pData->netmask)) == pData->special_addr.s_addr)379 if ((so->so_faddr.s_addr & RT_H2N_U32(pData->netmask)) == pData->special_addr.s_addr) 380 380 { 381 381 saddr.sin_addr.s_addr = so->so_faddr.s_addr; 382 if ((so->so_faddr.s_addr & htonl(~pData->netmask)) == htonl(~pData->netmask))382 if ((so->so_faddr.s_addr & RT_H2N_U32(~pData->netmask)) == RT_H2N_U32(~pData->netmask)) 383 383 saddr.sin_addr.s_addr = alias_addr.s_addr; 384 384 } … … 386 386 /* Any UDP packet to the loopback address must be translated to be from 387 387 * the forwarding address, i.e. 10.0.2.2. */ 388 if ( (saddr.sin_addr.s_addr & htonl(IN_CLASSA_NET))389 == htonl(INADDR_LOOPBACK & IN_CLASSA_NET))388 if ( (saddr.sin_addr.s_addr & RT_H2N_U32_C(IN_CLASSA_NET)) 389 == RT_H2N_U32_C(INADDR_LOOPBACK & IN_CLASSA_NET)) 390 390 saddr.sin_addr.s_addr = alias_addr.s_addr; 391 391 … … 482 482 while(udptos[i].tos) 483 483 { 484 if ( (udptos[i].fport && ntohs(so->so_fport) == udptos[i].fport)485 || (udptos[i].lport && ntohs(so->so_lport) == udptos[i].lport))484 if ( (udptos[i].fport && RT_N2H_U16(so->so_fport) == udptos[i].fport) 485 || (udptos[i].lport && RT_N2H_U16(so->so_lport) == udptos[i].lport)) 486 486 { 487 487 so->so_emu = udptos[i].emu;
Note:
See TracChangeset
for help on using the changeset viewer.