Changeset 22500 in vbox
- Timestamp:
- Aug 27, 2009 9:44:23 AM (15 years ago)
- Location:
- trunk/src/VBox/Devices/Network/slirp
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Network/slirp/bootp.c
r22494 r22500 47 47 return NULL; 48 48 } 49 BOOTPClient *bc_alloc_client(PNATState pData)49 static BOOTPClient *bc_alloc_client(PNATState pData) 50 50 { 51 51 int i; … … 428 428 memcpy(bc->macaddr, bp->bp_hwaddr, bp->bp_hlen); 429 429 bc->addr.s_addr = bp->bp_ciaddr.s_addr; 430 slirp_update_arp_cache(pData, bp->bp_ciaddr.s_addr, bp->bp_hwaddr); 430 431 } 431 432 } … … 450 451 memcpy(bc->macaddr, bp->bp_hwaddr, bp->bp_hlen); 451 452 bc->addr.s_addr = ui32; 453 slirp_update_arp_cache(pData, bp->bp_ciaddr.s_addr, bp->bp_hwaddr); 452 454 break; 453 455 case NONE: -
trunk/src/VBox/Devices/Network/slirp/bootp.h
r22494 r22500 133 133 134 134 void bootp_input(PNATState, struct mbuf *m); 135 BOOTPClient *bc_alloc_client(PNATState pData); -
trunk/src/VBox/Devices/Network/slirp/ip_output.c
r22478 r22500 49 49 { 50 50 int i; 51 struct arp_cache_entry *ac = NULL; 51 52 /* @todo (vasily) to quick ramp up on routing rails 52 53 * we use information from DHCP server leasings, this … … 54 55 * and should be borrowed from other places 55 56 */ 57 LIST_FOREACH(ac, &pData->arp_cache, list) 58 { 59 if (ac->ip == dst) 60 return &ac->ether[0]; 61 } 56 62 for (i = 0; i < NB_ADDR; i++) 57 63 { -
trunk/src/VBox/Devices/Network/slirp/slirp.c
r22495 r22500 637 637 ftp_alias_unload(pData); 638 638 nbt_alias_unload(pData); 639 while(!LIST_EMPTY(&instancehead)) { 639 while(!LIST_EMPTY(&instancehead)) 640 { 640 641 struct libalias *la = LIST_FIRST(&instancehead); 641 642 /* libalias do all clean up */ 642 643 LibAliasUninit(la); 644 } 645 while(!LIST_EMPTY(&pData->arp_cache)) 646 { 647 struct arp_cache_entry *ac = LIST_FIRST(&pData->arp_cache); 648 LIST_REMOVE(ac, list); 649 RTMemFree(ac); 643 650 } 644 651 #ifdef RT_OS_WINDOWS … … 1371 1378 break; 1372 1379 case ARPOP_REPLY: 1373 /* @todo check if we already have requested address */ 1374 /* if no*/ 1375 { 1376 BOOTPClient *bc = bc_alloc_client(pData); 1377 bc->addr.s_addr = *(uint32_t *)ah->ar_sip; 1378 memcpy(bc->macaddr, ah->ar_sha, ETH_ALEN); 1379 m_free(pData, m); 1380 { 1381 struct arp_cache_entry *ac = NULL; 1382 if (slirp_update_arp_cache(pData, ah->ar_sip, ah->ar_sha) == 0) 1383 break; 1384 ac = RTMemAllocZ(sizeof(struct arp_cache_entry)); 1385 if (ac == NULL) 1386 { 1387 LogRel(("NAT: Can´t allocate arp cache entry\n")); 1388 m_free(pData, m); 1389 return; 1390 } 1391 ac->ip = *(uint32_t *)ah->ar_sip; 1392 memcpy(ac->ether, ah->ar_sha, ETH_ALEN); 1393 LIST_INSERT_HEAD(&pData->arp_cache, ac, list); 1380 1394 } 1381 1395 break; … … 1825 1839 LogRel(("NAT: ARP request sent\n")); 1826 1840 } 1841 /* updates the arp cache 1842 * @returns 0 - if has found and updated 1843 * 1 - if hasn´t found. 1844 */ 1845 int slirp_update_arp_cache(PNATState pData, uint32_t dst, const uint8_t *mac) 1846 { 1847 struct arp_cache_entry *ac; 1848 LIST_FOREACH(ac, &pData->arp_cache, list) 1849 { 1850 if (memcmp(ac->ether, mac, ETH_ALEN) == 0) 1851 { 1852 ac->ip = dst; 1853 return 0; 1854 } 1855 } 1856 return 1; 1857 } -
trunk/src/VBox/Devices/Network/slirp/slirp.h
r22494 r22500 310 310 /*slirp.c*/ 311 311 void slirp_arp_who_has(PNATState pData, uint32_t dst); 312 int slirp_update_arp_cache(PNATState pData, uint32_t dst, const uint8_t *mac); 312 313 #define MIN_MRU 128 313 314 #define MAX_MRU 16384 -
trunk/src/VBox/Devices/Network/slirp/slirp_state.h
r22494 r22500 38 38 /** DHCP Lease time. */ 39 39 #define LEASE_TIME (24 * 3600) 40 41 /* 42 * ARP cache this is naive implementaion of ARP 43 * cache of mapping 4 byte IPv4 address to 6 byte 44 * ethernet one. 45 */ 46 struct arp_cache_entry 47 { 48 uint32_t ip; 49 uint8_t ether[6]; 50 LIST_ENTRY(arp_cache_entry) list; 51 }; 52 LIST_HEAD(arp_cache_head, arp_cache_entry); 40 53 41 54 /** TFTP session entry. */ … … 241 254 struct port_forward_rule_list port_forward_rule_head; 242 255 int port_forwarding_activated; 256 struct arp_cache_head arp_cache; 243 257 /*libalis modules' handlers*/ 244 258 struct proto_handler *ftp_module;
Note:
See TracChangeset
for help on using the changeset viewer.