locked
How to delete IPsec tunnel created by FwpmIPsecTunnelAdd0? RRS feed

  • Question

  • I'm using code derived from http://msdn.microsoft.com/en-us/library/windows/desktop/bb540651(v=vs.85).aspx to create an IPsec tunnel. The code successfully creates a tunnel. Now I want to delete the tunnel. I use FwpmIPsecTunnelDeleteByKey0 because it's the only function I've found to delete a tunnel. When my code calls it, it fails with 80320008 (FWP_E_NOT_FOUND).  I'm calling FwpmIPsecTunnelDeleteByKey0 with engine handle (returned by FwpmEngineOpen0 and passed to FwpmIPsecTunnelAdd0) and GUID* (GUID in FWPM_PROVIDER structure passed to FwpmProviderAdd0 and GUID* in providerKey  field of main mode and quick mode FWPM_PROVIDER_CONTEXT0 structures passed to FwpmIPsecTunnelAdd0).

    After the FwpmIPsecTunnelDeletelByKey0, my code calls FwpmProviderContextDeleteByKey0 and it fails with 80320006 (FWP_E_PROVIDER_CONTEXT_NOT_FOUND).  I call FwpmProviderContextDeleteByKey0 with the same arguments I use to call FwpmIPsecTunnelDeleteByKey0.

    Why is the call to FwpmIPsecTunnelDeletebyKey0 failing?

    Why is the call to FwpmProviderContextDeleteByKey0 failing?

    Is there another function I can use to delete the tunnel?


    cas

    Wednesday, February 29, 2012 8:20 PM

Answers

  • For FwpmIPsecTunnelDeleteByKey0, you need to pass in an engineHandle, and the GUID of the tunnel you wish to delete (the GUID is the providerContext key from the tunnelPolicy you used when calling FwpmIPsecTunnelAdd)

    For the FwpmProviderContextDeleteByKey failure, did you add the ProviderContext?  did you use the same key as the add? 

    This is the only function to delete Tunnels.

    Hope this helps,


    Dusty Harper [MSFT]
    Microsoft Corporation
    ------------------------------------------------------------
    This posting is provided "AS IS", with NO warranties and confers NO rights
    ------------------------------------------------------------

    Wednesday, February 29, 2012 11:27 PM
    Moderator

All replies

  • For FwpmIPsecTunnelDeleteByKey0, you need to pass in an engineHandle, and the GUID of the tunnel you wish to delete (the GUID is the providerContext key from the tunnelPolicy you used when calling FwpmIPsecTunnelAdd)

    For the FwpmProviderContextDeleteByKey failure, did you add the ProviderContext?  did you use the same key as the add? 

    This is the only function to delete Tunnels.

    Hope this helps,


    Dusty Harper [MSFT]
    Microsoft Corporation
    ------------------------------------------------------------
    This posting is provided "AS IS", with NO warranties and confers NO rights
    ------------------------------------------------------------

    Wednesday, February 29, 2012 11:27 PM
    Moderator
  • The problem wasconfusing providerKey and providerContextKey. I understand the problem with my program. Thanks for your help!


    cas

    Thursday, March 1, 2012 9:46 PM