Changeset 53309 in vbox for trunk/src/VBox/Devices/Network/slirp/ip_icmp.c
- Timestamp:
- Nov 12, 2014 3:47:13 AM (10 years ago)
- svn:sync-xref-src-repo-rev:
- 96888
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Network/slirp/ip_icmp.c
r53303 r53309 346 346 icmp_input(PNATState pData, struct mbuf *m, int hlen) 347 347 { 348 register struct icmp *icp;349 void *icp_buf = NULL;350 348 register struct ip *ip = mtod(m, struct ip *); 351 349 int icmplen = ip->ip_len; 350 uint8_t icmp_type; 351 void *icp_buf = NULL; 352 352 int status; 353 353 uint32_t dst; … … 382 382 } 383 383 384 if (m->m_next) 385 { 386 icp_buf = RTMemAlloc(icmplen); 387 if (!icp_buf) 388 { 389 Log(("NAT: not enought memory to allocate the buffer\n")); 390 goto end_error_free_m; 391 } 392 m_copydata(m, 0, icmplen, icp_buf); 393 icp = (struct icmp *)icp_buf; 394 } 395 else 396 icp = mtod(m, struct icmp *); 384 /* are we guaranteed to have ICMP header in first mbuf? be safe. */ 385 m_copydata(m, 0, sizeof(icmp_type), (caddr_t)&icmp_type); 397 386 398 387 m->m_len += hlen; … … 402 391 /* code = icp->icmp_code; */ 403 392 404 LogFlow(("icmp_type = %d\n", ic p->icmp_type));405 switch (ic p->icmp_type)393 LogFlow(("icmp_type = %d\n", icmp_type)); 394 switch (icmp_type) 406 395 { 407 396 case ICMP_ECHO: … … 422 411 else 423 412 { 413 struct icmp *icp; 424 414 struct sockaddr_in addr; 425 415 #ifdef RT_OS_WINDOWS … … 442 432 else 443 433 addr.sin_addr.s_addr = ip->ip_dst.s_addr; 434 435 if (m->m_next) 436 { 437 icp_buf = RTMemAlloc(icmplen); 438 if (!icp_buf) 439 { 440 Log(("NAT: not enought memory to allocate the buffer\n")); 441 goto end_error_free_m; 442 } 443 m_copydata(m, hlen, icmplen, icp_buf); 444 icp = (struct icmp *)icp_buf; 445 } 446 else 447 icp = (struct icmp *)(mtod(m, char *) + hlen); 448 444 449 #ifndef RT_OS_WINDOWS 445 450 if (pData->icmp_socket.s != -1)
Note:
See TracChangeset
for help on using the changeset viewer.