bool CFirewallOpener::AddRule(const CICSRuleInfo& riPortRule, const INetSharingConfigurationPtr pNSC, const INetConnectionPropsPtr pNCP) { INetSharingPortMappingPtr pNSPM; HRESULT hr = pNSC->AddPortMapping(riPortRule.m_strRuleName.AllocSysString(), riPortRule.m_byProtocol, riPortRule.m_nPortNumber, riPortRule.m_nPortNumber, 0, CComBSTR(L"127.0.0.1"), ICSTT_IPADDRESS, &pNSPM); CComBSTR bstrName; pNCP->get_Name(&bstrName); if ( SUCCEEDED(hr) && SUCCEEDED(pNSPM->Enable())) { // ==> Improved ICS-Firewall support [MoNKi] - Max if(riPortRule.m_bRemoveOnExit || m_bClearMappings) { CICSRuleInfo ruleToAdd(riPortRule); AddToICFdat(ruleToAdd); } // <== Improved ICS-Firewall support [MoNKi] - Max theApp.QueueDebugLogLine(false, _T("Succeeded to add Rule '%s' for Port '%u' on Connection '%s'"),riPortRule.m_strRuleName, riPortRule.m_nPortNumber, CString(bstrName)); return true; } else { theApp.QueueDebugLogLine(false, _T("Failed to add Rule '%s' for Port '%u' on Connection '%s'"),riPortRule.m_strRuleName, riPortRule.m_nPortNumber, CString(bstrName)); return false; } }
bool CFirewallOpener::AddRule(const CICSRuleInfo& riPortRule, const INetSharingConfigurationPtr pNSC, const INetConnectionPropsPtr pNCP){ INetSharingPortMappingPtr pNSPM; HRESULT hr = pNSC->AddPortMapping(riPortRule.m_strRuleName.AllocSysString(), riPortRule.m_byProtocol, riPortRule.m_nPortNumber, riPortRule.m_nPortNumber, 0, L"127.0.0.1", ICSTT_IPADDRESS, &pNSPM); CComBSTR bstrName; pNCP->get_Name(&bstrName); if ( SUCCEEDED(hr) && SUCCEEDED(pNSPM->Enable())){ theApp.QueueDebugLogLine(false, _T("Succeeded to add Rule '%s' for Port '%u' on Connection '%s'"),riPortRule.m_strRuleName, riPortRule.m_nPortNumber, CString(bstrName)); return true; } else{ theApp.QueueDebugLogLine(false, _T("Failed to add Rule '%s' for Port '%u' on Connection '%s'"),riPortRule.m_strRuleName, riPortRule.m_nPortNumber, CString(bstrName)); return false; } }