Changeset 48289 in vbox for trunk/src/VBox
- Timestamp:
- Sep 5, 2013 3:23:26 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/NetworkServices/NAT/VBoxNetLwipNAT.cpp
r48288 r48289 363 363 AssertPtrReturnVoid(pNetif); 364 364 365 /* IPv6 link-local address in slot 0 */366 netif_create_ip6_linklocal_address(pNetif, /* :from_mac_48bit */ 1);367 368 /*369 * RFC 4193 Locally Assigned Global ID (ULA) in slot 1370 * [fd17:625c:f037:XXXX::1] where XXXX, 16 bit Subnet ID, are two371 * bytes from the middle of the IPv4 address, e.g. :dead: for372 * 10.222.173.1373 */374 {375 uint8_t nethi = g_pLwipNat->m_Ipv4Address.au8[1];376 uint8_t netlo = g_pLwipNat->m_Ipv4Address.au8[2];377 378 ip6_addr_t *paddr = netif_ip6_addr(pNetif, 1);379 IP6_ADDR(paddr, 0, 0xFD, 0x17, 0x62, 0x5C);380 IP6_ADDR(paddr, 1, 0xF0, 0x37, nethi, netlo);381 IP6_ADDR(paddr, 2, 0x00, 0x00, 0x00, 0x00);382 IP6_ADDR(paddr, 3, 0x00, 0x00, 0x00, 0x01);383 netif_ip6_addr_set_state(pNetif, 1, IP6_ADDR_PREFERRED);384 }385 386 #if LWIP_IPV6_SEND_ROUTER_SOLICIT387 pNetif->rs_count = 0;388 #endif389 390 365 netif_set_up(pNetif); 391 366 netif_set_link_up(pNetif); … … 443 418 444 419 /* 445 * This function finalize the interface initialization 446 * (tcpip thread?) 420 * Callback for netif_add() to initialize the interface. 447 421 */ 448 422 err_t VBoxNetLwipNAT::netifInit(netif *pNetif) 449 423 { 424 err_t rcLwip = ERR_OK; 425 450 426 AssertPtrReturn(pNetif, ERR_ARG); 451 427 428 VBoxNetLwipNAT *pNat = static_cast<VBoxNetLwipNAT *>(pNetif->state); 429 AssertPtrReturn(pNat, ERR_ARG); 430 452 431 LogFlowFunc(("ENTER: pNetif[%c%c%d]\n", pNetif->name[0], pNetif->name[1], pNetif->num)); 453 432 /* validity */ 454 433 AssertReturn( pNetif->name[0] == 'N' 455 434 && pNetif->name[1] == 'T', ERR_ARG); 456 435 457 436 458 437 pNetif->hwaddr_len = sizeof(RTMAC); 459 memcpy(pNetif->hwaddr, &g_pLwipNat->m_MacAddress, sizeof(RTMAC)); 460 g_pLwipNat->m_u16Mtu = 1500; // XXX: FIXME 461 pNetif->mtu = g_pLwipNat->m_u16Mtu; 438 memcpy(pNetif->hwaddr, &pNat->m_MacAddress, sizeof(RTMAC)); 439 440 pNat->m_u16Mtu = 1500; // XXX: FIXME 441 pNetif->mtu = pNat->m_u16Mtu; 442 462 443 pNetif->flags = NETIF_FLAG_BROADCAST 463 444 | NETIF_FLAG_ETHARP /* Don't bother driver with ARP and let Lwip resolve ARP handling */ 464 445 | NETIF_FLAG_ETHERNET; /* Lwip works with ethernet too */ 465 446 447 pNetif->linkoutput = netifLinkoutput; /* ether-level-pipe */ 448 pNetif->output = lwip_etharp_output; /* ip-pipe */ 449 pNetif->output_ip6 = ethip6_output; 450 451 /* IPv6 link-local address in slot 0 */ 466 452 netif_create_ip6_linklocal_address(pNetif, /* :from_mac_48bit */ 1); 467 netif_ip6_addr_set_state(pNetif, 0, IP6_ADDR_VALID); 468 pNetif->output_ip6 = ethip6_output; 469 LogFunc(("netif[%c%c%d] ipv6 addr:%RTnaipv6\n", 470 pNetif->name[0], 471 pNetif->name[1], 472 pNetif->num, 473 &pNetif->ip6_addr[0].addr[0])); 474 475 pNetif->output = lwip_etharp_output; /* ip-pipe */ 476 pNetif->linkoutput = netifLinkoutput; /* ether-level-pipe */ 477 478 err_t rcLwip = ERR_OK; 479 453 netif_ip6_addr_set_state(pNetif, 0, IP6_ADDR_PREFERRED); // skip DAD 454 455 /* 456 * RFC 4193 Locally Assigned Global ID (ULA) in slot 1 457 * [fd17:625c:f037:XXXX::1] where XXXX, 16 bit Subnet ID, are two 458 * bytes from the middle of the IPv4 address, e.g. :dead: for 459 * 10.222.173.1 460 */ 461 u8_t nethi = ip4_addr2(&pNetif->ip_addr); 462 u8_t netlo = ip4_addr3(&pNetif->ip_addr); 463 464 ip6_addr_t *paddr = netif_ip6_addr(pNetif, 1); 465 IP6_ADDR(paddr, 0, 0xFD, 0x17, 0x62, 0x5C); 466 IP6_ADDR(paddr, 1, 0xF0, 0x37, nethi, netlo); 467 IP6_ADDR(paddr, 2, 0x00, 0x00, 0x00, 0x00); 468 IP6_ADDR(paddr, 3, 0x00, 0x00, 0x00, 0x01); 469 netif_ip6_addr_set_state(pNetif, 1, IP6_ADDR_PREFERRED); 470 471 #if LWIP_IPV6_SEND_ROUTER_SOLICIT 472 pNetif->rs_count = 0; 473 #endif 480 474 481 475 LogFlowFunc(("LEAVE: %d\n", rcLwip));
Note:
See TracChangeset
for help on using the changeset viewer.