Changeset 22541 in vbox
- Timestamp:
- Aug 28, 2009 5:54:12 AM (15 years ago)
- Location:
- trunk/src/VBox/Devices/Network/slirp
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Network/slirp/bootp.c
r22500 r22541 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 slirp_arp_cache_update(pData, bp->bp_ciaddr.s_addr, bp->bp_hwaddr); 431 431 } 432 432 } … … 451 451 memcpy(bc->macaddr, bp->bp_hwaddr, bp->bp_hlen); 452 452 bc->addr.s_addr = ui32; 453 slirp_ update_arp_cache(pData, bp->bp_ciaddr.s_addr, bp->bp_hwaddr);453 slirp_arp_cache_update(pData, bp->bp_ciaddr.s_addr, bp->bp_hwaddr); 454 454 break; 455 455 case NONE: -
trunk/src/VBox/Devices/Network/slirp/slirp.c
r22505 r22541 1320 1320 tip = *(uint32_t*)ah->ar_tip; 1321 1321 1322 mr = m_get(pData);1323 1324 reh = mtod(mr, struct ethhdr *);1325 memcpy(reh->h_source, eh->h_source, ETH_ALEN); /* XXX: if_encap will swap src and dst*/1326 Log4(("NAT: arp:%R[ether]->%R[ether]\n",1327 reh->h_source, reh->h_dest));1328 Log4(("NAT: arp: %R[IP4]\n", &tip));1329 1330 mr->m_data += if_maxlinkhdr;1331 mr->m_len = sizeof(struct arphdr);1332 rah = mtod(mr, struct arphdr *);1333 1322 1334 1323 ar_op = ntohs(ah->ar_op); … … 1336 1325 { 1337 1326 case ARPOP_REQUEST: 1327 mr = m_get(pData); 1328 1329 reh = mtod(mr, struct ethhdr *); 1330 memcpy(reh->h_source, eh->h_source, ETH_ALEN); /* XXX: if_encap will swap src and dst*/ 1331 Log4(("NAT: arp:%R[ether]->%R[ether]\n", 1332 reh->h_source, reh->h_dest)); 1333 Log4(("NAT: arp: %R[IP4]\n", &tip)); 1334 1335 mr->m_data += if_maxlinkhdr; 1336 mr->m_len = sizeof(struct arphdr); 1337 rah = mtod(mr, struct arphdr *); 1338 1338 #ifdef VBOX_WITH_NAT_SERVICE 1339 1339 if (tip == special_addr.s_addr) goto arp_ok; … … 1376 1376 m_free(pData, m); 1377 1377 } 1378 /*Gratuitous ARP*/ 1379 if ( *(uint32_t *)ah->ar_sip == *(uint32_t *)ah->ar_tip 1380 && memcmp(ah->ar_tha, broadcast_ethaddr, ETH_ALEN) == 0 1381 && memcmp(eh->h_dest, broadcast_ethaddr, ETH_ALEN) == 0) 1382 { 1383 /* we've received anounce about address asignment 1384 * Let's do ARP cache update 1385 */ 1386 if (slirp_arp_cache_update(pData, *(uint32_t *)ah->ar_tip, &eh->h_dest[0]) == 0) 1387 { 1388 m_free(pData, mr); 1389 m_free(pData, m); 1390 break; 1391 } 1392 slirp_arp_cache_add(pData, *(uint32_t *)ah->ar_tip, &eh->h_dest[0]); 1393 } 1378 1394 break; 1379 1395 case ARPOP_REPLY: 1380 1396 { 1381 struct arp_cache_entry *ac = NULL; 1382 if (slirp_update_arp_cache(pData, ah->ar_sip, ah->ar_sha) == 0) 1397 if (slirp_arp_cache_update(pData, *(uint32_t *)ah->ar_sip, &ah->ar_sha[0]) == 0) 1383 1398 { 1384 1399 m_free(pData, m); 1385 1400 break; 1386 1401 } 1387 ac = RTMemAllocZ(sizeof(struct arp_cache_entry)); 1388 if (ac == NULL) 1389 { 1390 LogRel(("NAT: Can't allocate arp cache entry\n")); 1391 m_free(pData, m); 1392 return; 1393 } 1394 ac->ip = *(uint32_t *)ah->ar_sip; 1395 memcpy(ac->ether, ah->ar_sha, ETH_ALEN); 1396 LIST_INSERT_HEAD(&pData->arp_cache, ac, list); 1402 slirp_arp_cache_add(pData, *(uint32_t *)ah->ar_sip, ah->ar_sha); 1403 m_free(pData, m); 1397 1404 } 1398 1405 break; … … 1846 1853 * 1 - if hasn't found. 1847 1854 */ 1848 int slirp_ update_arp_cache(PNATState pData, uint32_t dst, const uint8_t *mac)1855 int slirp_arp_cache_update(PNATState pData, uint32_t dst, const uint8_t *mac) 1849 1856 { 1850 1857 struct arp_cache_entry *ac; … … 1859 1866 return 1; 1860 1867 } 1868 void slirp_arp_cache_add(PNATState pData, uint32_t ip, const uint8_t *ether) 1869 { 1870 struct arp_cache_entry *ac = NULL; 1871 ac = RTMemAllocZ(sizeof(struct arp_cache_entry)); 1872 if (ac == NULL) 1873 { 1874 LogRel(("NAT: Can't allocate arp cache entry\n")); 1875 return; 1876 } 1877 ac->ip = ip; 1878 memcpy(ac->ether, ether, ETH_ALEN); 1879 LIST_INSERT_HEAD(&pData->arp_cache, ac, list); 1880 } -
trunk/src/VBox/Devices/Network/slirp/slirp.h
r22500 r22541 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 int slirp_arp_cache_update(PNATState pData, uint32_t dst, const uint8_t *mac); 313 void slirp_arp_cache_add(PNATState pData, uint32_t ip, const uint8_t *ether); 313 314 #define MIN_MRU 128 314 315 #define MAX_MRU 16384
Note:
See TracChangeset
for help on using the changeset viewer.