vbox的更動 57416 路徑 trunk/src/VBox/NetworkServices
- 時間撮記:
- 2015-8-18 上午11:19:28 (9 年 以前)
- 檔案:
-
- 修改 1 筆資料
圖例:
- 未更動
- 新增
- 刪除
-
trunk/src/VBox/NetworkServices/NAT/VBoxNetLwipNAT.cpp
r56318 r57416 18 18 /* Must be included before winutils.h (lwip/def.h), otherwise Windows build breaks. */ 19 19 #define LOG_GROUP LOG_GROUP_NAT_SERVICE 20 21 #include <iprt/cpp/mem.h>22 20 23 21 #include "winutils.h" … … 183 181 */ 184 182 bool fDontLoadRulesOnStartup; 185 static voidonLwipTcpIpInit(void *arg);186 static voidonLwipTcpIpFini(void *arg);183 static DECLCALLBACK(void) onLwipTcpIpInit(void *arg); 184 static DECLCALLBACK(void) onLwipTcpIpFini(void *arg); 187 185 static err_t netifInit(netif *pNetif); 188 186 static err_t netifLinkoutput(netif *pNetif, pbuf *pBuf); 189 static int intNetThreadRecv(RTTHREAD, void *);187 /* static int intNetThreadRecv(RTTHREAD, void *); - unused */ 190 188 191 189 VECNATSERVICEPF m_vecPortForwardRule4; … … 294 292 295 293 default: 296 LogRel(("Event: %s %s port-forwarding rule \"%s\":" 297 " invalid protocol %d\n", 294 LogRel(("Event: %s %s port-forwarding rule \"%s\": invalid protocol %d\n", 298 295 fCreateFW ? "Add" : "Remove", 299 296 fIPv6FW ? "IPv6" : "IPv4", … … 303 300 } 304 301 305 LogRel(("Event: %s %s port-forwarding rule \"%s\":" 306 " %s %s%s%s:%d -> %s%s%s:%d\n", 302 LogRel(("Event: %s %s port-forwarding rule \"%s\": %s %s%s%s:%d -> %s%s%s:%d\n", 307 303 fCreateFW ? "Add" : "Remove", 308 304 fIPv6FW ? "IPv6" : "IPv4", … … 353 349 { 354 350 /* compare */ 355 NATSEVICEPORTFORWARDRULE &natFw = *it;351 NATSEVICEPORTFORWARDRULE &natFw = *it; 356 352 if ( natFw.Pfr.iPfrProto == r.Pfr.iPfrProto 357 353 && natFw.Pfr.u16PfrHostPort == r.Pfr.u16PfrHostPort 358 && (strncmp(natFw.Pfr.szPfrHostAddr, r.Pfr.szPfrHostAddr, INET6_ADDRSTRLEN) == 0)354 && strncmp(natFw.Pfr.szPfrHostAddr, r.Pfr.szPfrHostAddr, INET6_ADDRSTRLEN) == 0 359 355 && natFw.Pfr.u16PfrGuestPort == r.Pfr.u16PfrGuestPort 360 && (strncmp(natFw.Pfr.szPfrGuestAddr, r.Pfr.szPfrGuestAddr, INET6_ADDRSTRLEN) == 0))356 && strncmp(natFw.Pfr.szPfrGuestAddr, r.Pfr.szPfrGuestAddr, INET6_ADDRSTRLEN) == 0) 361 357 { 362 RTCMemAutoPtr<fwspec> pFwCopy; 363 if (RT_UNLIKELY(!pFwCopy.alloc())) 364 break; 365 366 memcpy(pFwCopy.get(), &natFw.FWSpec, sizeof(natFw.FWSpec)); 367 368 int status = portfwd_rule_del(pFwCopy.get()); 369 if (status != 0) 370 break; 371 372 pFwCopy.release(); /* owned by lwip thread now */ 373 rules.erase(it); 358 fwspec *pFwCopy = (fwspec *)RTMemDup(&natFw.FWSpec, sizeof(natFw.FWSpec)); 359 if (pFwCopy) 360 { 361 int status = portfwd_rule_del(pFwCopy); 362 if (status == 0) 363 rules.erase(it); /* (pFwCopy is owned by lwip thread now.) */ 364 else 365 RTMemFree(pFwCopy); 366 } 374 367 break; 375 368 } … … 427 420 428 421 429 void VBoxNetLwipNAT::onLwipTcpIpInit(void*arg)422 /*static*/ DECLCALLBACK(void) VBoxNetLwipNAT::onLwipTcpIpInit(void *arg) 430 423 { 431 424 AssertPtrReturnVoid(arg); … … 520 513 521 514 522 voidVBoxNetLwipNAT::onLwipTcpIpFini(void* arg)515 /*static*/ DECLCALLBACK(void) VBoxNetLwipNAT::onLwipTcpIpFini(void* arg) 523 516 { 524 517 AssertPtrReturnVoid(arg); … … 535 528 * Callback for netif_add() to initialize the interface. 536 529 */ 537 err_t VBoxNetLwipNAT::netifInit(netif *pNetif)530 /*static*/ err_t VBoxNetLwipNAT::netifInit(netif *pNetif) 538 531 { 539 532 err_t rcLwip = ERR_OK; … … 597 590 598 591 599 err_t VBoxNetLwipNAT::netifLinkoutput(netif *pNetif, pbuf *pPBuf)592 /*static*/ err_t VBoxNetLwipNAT::netifLinkoutput(netif *pNetif, pbuf *pPBuf) 600 593 { 601 594 AssertPtrReturn(pNetif, ERR_ARG); … … 702 695 703 696 704 int VBoxNetLwipNAT::natServicePfRegister(NATSEVICEPORTFORWARDRULE& natPf)697 /*static*/ int VBoxNetLwipNAT::natServicePfRegister(NATSEVICEPORTFORWARDRULE& natPf) 705 698 { 706 699 int lrc; … … 739 732 return VERR_IGNORED; 740 733 741 RTCMemAutoPtr<fwspec> pFwCopy; 742 if (RT_UNLIKELY(!pFwCopy.alloc())) 743 { 734 fwspec *pFwCopy = (fwspec *)RTMemDup(&natPf.FWSpec, sizeof(natPf.FWSpec)); 735 if (pFwCopy) 736 { 737 lrc = portfwd_rule_add(pFwCopy); 738 if (lrc == 0) 739 return VINF_SUCCESS; /* (pFwCopy is owned by lwip thread now.) */ 740 RTMemFree(pFwCopy); 741 } 742 else 744 743 LogRel(("Unable to allocate memory for %s rule \"%s\"\n", 745 744 natPf.Pfr.fPfrIPv6 ? "IPv6" : "IPv4", 746 745 natPf.Pfr.szPfrName)); 747 return VERR_IGNORED; 748 } 749 750 memcpy(pFwCopy.get(), &natPf.FWSpec, sizeof(natPf.FWSpec)); 751 752 lrc = portfwd_rule_add(pFwCopy.get()); 753 if (lrc != 0) 754 return VERR_IGNORED; 755 756 pFwCopy.release(); /* owned by lwip thread now */ 757 return VINF_SUCCESS; 758 } 759 760 761 int VBoxNetLwipNAT::natServiceProcessRegisteredPf(VECNATSERVICEPF& vecRules) 746 return VERR_IGNORED; 747 } 748 749 750 /*static*/ int VBoxNetLwipNAT::natServiceProcessRegisteredPf(VECNATSERVICEPF& vecRules) 762 751 { 763 752 ITERATORNATSERVICEPF it;
注意:
瀏覽 TracChangeset
來幫助您使用更動檢視器