[Common-dev] Re: [Client-dev] CR-Client: new Firewall Control Manager - deal with WinXP SP2 firewall

[Common-dev] Re: [Client-dev] CR-Client: new Firewall Control Manager - deal with WinXP SP2 firewall

Henry Ping ping at real.com
Thu Aug 26 18:01:11 PDT 2004


Attached is the new diff made to client/netwksvc, the changes in 
protocol/rtsp/rtspclnt.cpp in my previous diff is no longer needed.

This diff only applies to neptune116 and neptune121, I will send out 
different diff for HEAD since our new network service with IPv6 support has 
been changed quite a bit on HEAD. We need to check in this first to neptune 
branch for upcoming player update release.

-->Henry

At 05:09 PM 8/26/2004 -0700, Henry Ping wrote:
>I put firewall interaction in RTSP, the same layer where the proxy 
>interaction also occurs. Now I am thinking about it, I like your idea, so 
>I will move the open/close UDP port logic down to the socket layer(i.e. 
>HXUDPSocket).
>
>Thanks
>-->Henry
>
>At 04:49 PM 8/26/2004 -0700, Aaron Colwell wrote:
>>Henry,
>>
>>I haven't finished looking through the diff yet, but I was wondering why the
>>interaction with the firewall is happening in the RTSP code instead of in
>>the socket code. If you put it in the socket code then all code that uses
>>the socket API won't have to worry about these sort of firewall problems.
>>
>>Aaron
>>
>>On Thu, Aug 26, 2004 at 04:12:34PM -0700, Henry Ping wrote:
>> >    Overview:
>> >    Windows Firewall is now turned on by default by WinXP SP2. This 
>> causes a
>> >    firewall warning dialogbox popping up each time when our player 
>> tries to
>> >    playback content via new UDP port.
>> >
>> >    In order to achieve better user experience, we decided to suppress the
>> >    dialogbox and programmatically open&close the UDP port when Windows'
>> >    Firewall is ON.
>> >
>> >    The warning dialogbox is shown at the time when we bind a socket to a
>> >    particular UDP port, in order to minimize the chance of leaving UDP 
>> port
>> >    open to the rest of system, we will open the UDP port right before the
>> >    Bind() and close the same UDP port right after the Bind().
>> >
>> >    In addition, to ensure we don't leave any UDP port opened by us behind,
>> >    we'll scan through the opening ports and close them if they are 
>> opened by
>> >    us both at the initialization of the engine and at the closure of the
>> >    engine.
>> >
>> >    Since Firewall manipulation can be an x-platform service provided 
>> by the
>> >    engine in the future, I created a designated interface
>> >    IHXFirewallControlManager along with several basic methods.
>> >
>> >    Files Modified:
>> >    common/include/hxpiids.h: define IHXFirewallControlManager
>> >    client/core/hxcleng.cpp: keeps IHXFirewallControlManager instance
>> >    protocol/rtsp/rtspclnt.cpp: use IHXFirewallControlManager to open/close
>> >    the UDP port when Windows' Firewall is ON.
>> >
>> >    Files Added:
>> >    common/include/hxfwctlmgr.h: declare IHXFirewallControlManager methods
>> >    common/netio/pub/fwctlmgr.h
>> >    common/netio/pub/fwctlmgr.cpp: base class to load platform specific 
>> child
>> >    class
>> >    common/netio/pub/platform/win/win_fwctlmgr.h
>> >    common/netio/platform/win/win_fwctlmgr.cpp: Windows Firewall specific
>> >    implementation
>> >
>> >    IHXFirewallControlManager is associated with 
>> HELIX_FEATURE_FW_CTLMGR which
>> >    is added to helix-client-core-advanced.pfi
>> >
>> >    This feature can also be disabled at run time by setting player 
>> preference
>> >    "FWIntegration=0", it's enabled by default.
>> >
>> >    The implementation for Windows Firewall requires the latest Microsoft
>> >    Platform SDK titled "Windows XP Service Pack 2 Platform SDK RC2"
>> >
>> >    Image Size and Heap Use impact:
>> >    Negligible
>> >
>> >    Platforms and Profiles Affected:
>> >    Windows, helix-client-all-defines
>> >
>> >    Distribution Libraries affected:
>> >    None
>> >
>> >    Distribution library impact and planned action:
>> >    None
>> >
>> >    Branch:
>> >    HEAD
>> >    neptune_1_1_6
>> >    neptune_1_2_1
>> >
>> >    QA Instructions:
>> >    - play content via UDP on WinXP SP2 with Firewall is ON, no warning
>> >    dialogbox should be shown and the playback is still successful via UDP
>> >    - verify no ports is left open by us("HelixDNAClient") from Windows
>> >    Firewall Control applet at any time(before, during and after the 
>> playback)
>> >
>> >    -->Henry
>> > cannot read /etc/hooks.lua: No such file or directory
>> > cannot read /home/aaron/.elinks//hooks.lua: No such file or directory
>>
>> > ? Makefile
>> > ? Umakefil.upp
>> > ? a
>> > ? common_netio.dsp
>> > ? common_netio.dsw
>> > ? dbg32
>> > ? fwctlmgr.cpp
>> > ? vc60.idb
>> > ? platform/win/win_fwctlmgr.cpp
>> > ? pub/fwctlmgr.h
>> > ? pub/platform/win/win_fwctlmgr.h
>> > Index: Umakefil
>> > ===================================================================
>> > RCS file: /cvsroot/common/netio/Umakefil,v
>> > retrieving revision 1.3
>> > diff -u -w -4 -r1.3 Umakefil
>> > --- Umakefil  5 Mar 2003 00:06:32 -0000       1.3
>> > +++ Umakefil  26 Aug 2004 22:43:47 -0000
>> > @@ -44,13 +44,15 @@
>> >                            'common/system/pub',
>> >                         'common/runtime/pub',
>> >                         'common/runtime/hlxclib/sys')
>> >
>> > -
>> >  project.AddSources('conn.cpp',
>> >                     'sockio.cpp',
>> >                  'thrdconn.cpp',
>> >                  'threngin.cpp')
>> > +
>> > +if "HELIX_FEATURE_FW_CTLMGR" in project.defines:
>> > +     project.AddSources('fwctlmgr.cpp')
>> >
>> >  if "HELIX_FEATURE_MIN_HEAP" in project.defines:
>> >       project.AddDefines('HELIX_CONFIG_LOW_HEAP_STREAMING')
>> >
>> > Index: win.pcf
>> > ===================================================================
>> > RCS file: /cvsroot/common/netio/win.pcf,v
>> > retrieving revision 1.3
>> > diff -u -w -4 -r1.3 win.pcf
>> > --- win.pcf   15 Nov 2002 20:10:29 -0000      1.3
>> > +++ win.pcf   26 Aug 2004 22:43:47 -0000
>> > @@ -34,11 +34,17 @@
>> >  #
>> >  # ***** END LICENSE BLOCK *****
>> >  #
>> >
>> > +if project.IsDefined("HELIX_CONFIG_MS_PSDK"):
>> > +     project.AddIncludes(os.path.join(GetSDKPath("ms_psdk"), "include"))
>> > +
>> >  project.AddDefines('WIN32_LEAN_AND_MEAN')
>> >  project.AddModuleIncludes('common/netio/pub/platform/win')
>> >  project.AddSources('platform/win/hxsock.cpp',
>> >                  'platform/win/win_net.cpp',
>> >                  'platform/win/win_conn.cpp',
>> >                  'platform/win/casynnet.cpp',
>> >                  'platform/win/casynthr.cpp')
>> > +
>> > +if "HELIX_FEATURE_FW_CTLMGR" in project.defines:
>> > +     project.AddSources('platform/win/win_fwctlmgr.cpp')
>>
>> > ? Makefile
>> > ? Umakefil.upp
>> > ? a
>> > ? client_core.dsp
>> > ? client_core.dsw
>> > ? client_core_clntcoredll.dsp
>> > ? client_core_clntcoredll.dsw
>> > ? client_core_clntcorelib.dsp
>> > ? client_core_clntcorelib.dsw
>> > ? clntcore.def
>> > ? clntcoredll.mak
>> > ? clntcoredll.upp
>> > ? clntcorelib.mak
>> > ? clntcorelib.upp
>> > ? dbg32
>> > ? dlliids.new
>> > ? hxbsrc.tmp
>> > ? hxsrc.tmp
>> > ? pylinktmp-clntcore
>> > ? vc60.idb
>> > Index: clntcoredll_win32.pcf
>> > ===================================================================
>> > RCS file: /cvsroot/client/core/clntcoredll_win32.pcf,v
>> > retrieving revision 1.2.22.2
>> > diff -u -w -4 -r1.2.22.2 clntcoredll_win32.pcf
>> > --- clntcoredll_win32.pcf     28 Jan 2004 00:58:35 -0000      1.2.22.2
>> > +++ clntcoredll_win32.pcf     26 Aug 2004 22:44:39 -0000
>> > @@ -55,6 +55,7 @@
>> >      'advapi32.lib',
>> >      'winmm.lib',
>> >      'gdi32.lib',
>> >      'ole32.lib',
>> > +    'oleaut32.lib',
>> >      'uuid.lib'
>> >      ]
>> > Index: hxcleng.cpp
>> > ===================================================================
>> > RCS file: /cvsroot/client/core/hxcleng.cpp,v
>> > retrieving revision 1.42
>> > diff -u -w -4 -r1.42 hxcleng.cpp
>> > --- hxcleng.cpp       17 Sep 2003 20:22:53 -0000      1.42
>> > +++ hxcleng.cpp       26 Aug 2004 22:44:39 -0000
>> > @@ -55,8 +55,9 @@
>> >  #include "ihxpckts.h"
>> >  #include "hxfiles.h"
>> >  #include "hxcore.h"
>> >  #include "hxprefs.h"
>> > +#include "fwctlmgr.h"
>> >  #include "auderrs.h"
>> >  #include "hxausvc.h"
>> >  #include "hxhyper.h"
>> >  #include "hxmon.h"
>> > @@ -335,8 +336,9 @@
>> >      ,m_lROBActive(0)
>> >      ,m_pProxyAutoConfig(NULL)
>> >      ,m_pNetInterfaces(NULL)
>> >      ,m_AUName(NULL)
>> > +    ,m_pFWCtlMgr(NULL)
>> >  #if defined(_MACINTOSH) && defined(_CARBON) && defined(THREADS_SUPPORTED)
>> >      ,m_bUseMacBlitMutex(FALSE)
>> >      ,m_pMacBlitMutex(NULL)
>> >  #endif
>> > @@ -397,8 +399,11 @@
>> >  #endif /* HELIX_FEATURE_SMARTERNETWORK */
>> >  #if defined(HELIX_FEATURE_OVERLAYMGR)
>> >      m_pOverlayManager       = new 
>> HXOverlayManager((IUnknown*)(IHXClientEngine*)this);
>> >  #endif /* HELIX_FEATURE_OVERLAYMGR */
>> > +#if defined(HELIX_FEATURE_FW_CTLMGR)
>> > +    m_pFWCtlMgr = HXFirewallControlManager::Create();
>> > +#endif /* HELIX_FEATURE_FW_CTLMGR */
>> >
>> >  #ifdef _MEDIUM_BLOCK
>> >      m_pAllocator->SetScheduler((IUnknown*)m_pScheduler);
>> >  #endif
>> > @@ -498,8 +503,11 @@
>> >  #endif /* HELIX_FEATURE_PROXYMGR */
>> >  #if defined(HELIX_FEATURE_SMARTERNETWORK)
>> >      HX_ADDREF(m_pPreferredTransportManager);
>> >  #endif /* HELIX_FEATURE_SMARTERNETWORK */
>> > +#if defined(HELIX_FEATURE_FW_CTLMGR)
>> > +    HX_ADDREF(m_pFWCtlMgr);
>> > +#endif /* HELIX_FEATURE_FW_CTLMGR */
>> >  #if defined(HELIX_FEATURE_OVERLAYMGR)
>> >      HX_ADDREF(m_pOverlayManager);
>> >  #endif /* HELIX_FEATURE_OVERLAYMGR */
>> >
>> > @@ -1168,8 +1176,15 @@
>> >           m_pScheduler->QueryInterface(riid, ppvObj) == HXR_OK)
>> >      {
>> >      return HXR_OK;
>> >      }
>> > +#if defined(HELIX_FEATURE_FW_CTLMGR)
>> > +    else if (m_pFWCtlMgr &&
>> > +             m_pFWCtlMgr->QueryInterface(riid, ppvObj) == HXR_OK)
>> > +    {
>> > +        return HXR_OK;
>> > +    }
>> > +#endif /* HELIX_FEATURE_FW_CTLMGR */
>> >  #ifdef HELIX_FEATURE_OPTIMIZED_SCHEDULER
>> >      else if (m_pOptimizedScheduler &&
>> >           m_pOptimizedScheduler->QueryInterface(riid, ppvObj) == HXR_OK)
>> >      {
>> > @@ -2244,8 +2259,16 @@
>> >      m_pRegistry->Close();
>> >      HX_RELEASE(m_pRegistry);
>> >      }
>> >  #endif /* HELIX_FEATURE_REGISTRY */
>> > +
>> > +#if defined(HELIX_FEATURE_FW_CTLMGR)
>> > +    if (m_pFWCtlMgr)
>> > +    {
>> > +        m_pFWCtlMgr->Close();
>> > +        HX_RELEASE(m_pFWCtlMgr);
>> > +    }
>> > +#endif /* HELIX_FEATURE_FW_CTLMGR */
>> >
>> >  #if defined(HELIX_FEATURE_PAC)
>> >      if (m_pProxyAutoConfig)
>> >      {
>> > Index: pub/hxcleng.h
>> > ===================================================================
>> > RCS file: /cvsroot/client/core/pub/hxcleng.h,v
>> > retrieving revision 1.12
>> > diff -u -w -4 -r1.12 hxcleng.h
>> > --- pub/hxcleng.h     12 Sep 2003 02:36:22 -0000      1.12
>> > +++ pub/hxcleng.h     26 Aug 2004 22:44:39 -0000
>> > @@ -83,8 +83,9 @@
>> >  class   HXOverlayManager;
>> >  class        HXNetInterface;
>> >  class        HXPlayer;
>> >  class        HXCookies;
>> > +class   HXFirewallControlManager;
>> >
>> >  struct       IHXClientAdviseSink;
>> >  struct       IHXErrorMessages;
>> >  struct       IHXCommonClassFactory;
>> > @@ -211,8 +212,9 @@
>> >  #if defined(_UNIX) || defined(__TCS__)
>> >      IHXSiteEventHandler*   m_pSiteEventHandler;
>> >  #endif
>> >
>> > +    HXFirewallControlManager*       m_pFWCtlMgr;
>> >      HXProxyManager*      m_pProxyManager;
>> >
>> >      HXPreferredTransportManager*   m_pPreferredTransportManager;
>> >      HXOverlayManager*              m_pOverlayManager;
>>
>> > ? a
>> > ? hxfwctlmgr.h
>> > Index: hxpac.h
>> > ===================================================================
>> > RCS file: /cvsroot/common/include/hxpac.h,v
>> > retrieving revision 1.1.1.1
>> > diff -u -w -4 -r1.1.1.1 hxpac.h
>> > Index: hxpiids.h
>> > ===================================================================
>> > RCS file: /cvsroot/common/include/hxpiids.h,v
>> > retrieving revision 1.22
>> > diff -u -w -4 -r1.22 hxpiids.h
>> > --- hxpiids.h 24 Sep 2003 18:39:47 -0000      1.22
>> > +++ hxpiids.h 26 Aug 2004 21:41:36 -0000
>> > @@ -720,8 +720,16 @@
>> >
>> >  /*
>> >   *
>> >   *  File:
>> > + *      hxfwmgr.h
>> > + *
>> > + */
>> > +DEFINE_GUID_ENUM(IID_IHXFirewallControlManager,         0x00004900, 
>> 0x901, 0x11d1, 0x8b, 0x6, 0x0, 0xa0, 0x24, 0x40, 0x6d, 0x59)
>> > +
>> > +/*
>> > + *
>> > + *  File:
>> >   *      mmsrsend.h
>> >   *
>> >   */
>> >  #ifndef MMSRSEND_H
>> > Index: platform.h
>> > ===================================================================
>> > RCS file: /cvsroot/common/include/platform.h,v
>> > retrieving revision 1.13.4.3
>> > diff -u -w -4 -r1.13.4.3 platform.h
>>
>> > /* ***** BEGIN LICENSE BLOCK *****
>> >  * Source last modified: $Id: hxcleng.cpp,v 1.60 2004/08/09 22:09:26 
>> liam_murray Exp $
>> >  *
>> >  * Portions Copyright (c) 1995-2004 RealNetworks, Inc. All Rights 
>> Reserved.
>> >  *
>> >  * The contents of this file, and the files included with this file,
>> >  * are subject to the current version of the RealNetworks Public
>> >  * Source License (the "RPSL") available at
>> >  * http://www.helixcommunity.org/content/rpsl unless you have licensed
>> >  * the file under the current version of the RealNetworks Community
>> >  * Source License (the "RCSL") available at
>> >  * http://www.helixcommunity.org/content/rcsl, in which case the RCSL
>> >  * will apply. You may also obtain the license terms directly from
>> >  * RealNetworks.  You may not use this file except in compliance with
>> >  * the RPSL or, if you have a valid RCSL with RealNetworks applicable
>> >  * to this file, the RCSL.  Please see the applicable RPSL or RCSL for
>> >  * the rights, obligations and limitations governing use of the
>> >  * contents of the file.
>> >  *
>> >  * Alternatively, the contents of this file may be used under the
>> >  * terms of the GNU General Public License Version 2 or later (the
>> >  * "GPL") in which case the provisions of the GPL are applicable
>> >  * instead of those above. If you wish to allow use of your version of
>> >  * this file only under the terms of the GPL, and not to allow others
>> >  * to use your version of this file under the terms of either the RPSL
>> >  * or RCSL, indicate your decision by deleting the provisions above
>> >  * and replace them with the notice and other provisions required by
>> >  * the GPL. If you do not delete the provisions above, a recipient may
>> >  * use your version of this file under the terms of any one of the
>> >  * RPSL, the RCSL or the GPL.
>> >  *
>> >  * This file is part of the Helix DNA Technology. RealNetworks is the
>> >  * developer of the Original Code and owns the copyrights in the
>> >  * portions it created.
>> >  *
>> >  * This file, and the files included with this file, is distributed
>> >  * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY
>> >  * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS
>> >  * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES
>> >  * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET
>> >  * ENJOYMENT OR NON-INFRINGEMENT.
>> >  *
>> >  * Technology Compatibility Kit Test Suite(s) Location:
>> >  *    http://www.helixcommunity.org/content/tck
>> >  *
>> >  * Contributor(s):
>> >  *
>> >  * ***** END LICENSE BLOCK ***** */
>> >
>> > #ifndef _HXWINFWCTLMGR_H_
>> > #define _HXWINFWCTLMGR_H_
>> >
>> > #include <windows.h>
>> > #include <crtdbg.h>
>> > #include <netfw.h>
>> > #include <objbase.h>
>> > #include <oleauto.h>
>> > #include <stdio.h>
>> >
>> > #include "fwctlmgr.h"
>> >
>> > class HXWinFirewallControlManager;
>> >
>> > class HXWinFirewallControlManager : public HXFirewallControlManager
>> > {
>> > private:
>> >     INetFwProfile*  m_fwProfile;
>> >     BSTR            m_fwBstrName;
>> >
>> >     HX_RESULT       Init();
>> >     HX_RESULT       Reset();
>> >
>> >     ~HXWinFirewallControlManager();
>> >
>> >     PRIVATE_DESTRUCTORS_ARE_NOT_A_CRIME
>> >
>> > public:
>> >     HXWinFirewallControlManager();
>> >     void Close(void);
>> >
>> >     /*
>> >      * IHXFirewallControlManager methods
>> >      */
>> >
>> >     STDMETHOD_(BOOL,IsFirewallOn)   (THIS);
>> >     STDMETHOD(TurnOnFirewall)       (THIS);
>> >     STDMETHOD(TurnOffFirewall)      (THIS);
>> >     STDMETHOD(OpenPort)             (UINT32 ulPort,
>> >                                      HX_NET_FW_IP_PROTOCOL protocol);
>> >     STDMETHOD(ClosePort)            (UINT32 ulPort,
>> >                                      HX_NET_FW_IP_PROTOCOL protocol);
>> > };
>> >
>> > #endif /* _HXWINFWMGR_H_ */
>>
>> > /* ***** BEGIN LICENSE BLOCK *****
>> >  * Source last modified: $Id: hxcleng.cpp,v 1.60 2004/08/09 22:09:26 
>> liam_murray Exp $
>> >  *
>> >  * Portions Copyright (c) 1995-2004 RealNetworks, Inc. All Rights 
>> Reserved.
>> >  *
>> >  * The contents of this file, and the files included with this file,
>> >  * are subject to the current version of the RealNetworks Public
>> >  * Source License (the "RPSL") available at
>> >  * http://www.helixcommunity.org/content/rpsl unless you have licensed
>> >  * the file under the current version of the RealNetworks Community
>> >  * Source License (the "RCSL") available at
>> >  * http://www.helixcommunity.org/content/rcsl, in which case the RCSL
>> >  * will apply. You may also obtain the license terms directly from
>> >  * RealNetworks.  You may not use this file except in compliance with
>> >  * the RPSL or, if you have a valid RCSL with RealNetworks applicable
>> >  * to this file, the RCSL.  Please see the applicable RPSL or RCSL for
>> >  * the rights, obligations and limitations governing use of the
>> >  * contents of the file.
>> >  *
>> >  * Alternatively, the contents of this file may be used under the
>> >  * terms of the GNU General Public License Version 2 or later (the
>> >  * "GPL") in which case the provisions of the GPL are applicable
>> >  * instead of those above. If you wish to allow use of your version of
>> >  * this file only under the terms of the GPL, and not to allow others
>> >  * to use your version of this file under the terms of either the RPSL
>> >  * or RCSL, indicate your decision by deleting the provisions above
>> >  * and replace them with the notice and other provisions required by
>> >  * the GPL. If you do not delete the provisions above, a recipient may
>> >  * use your version of this file under the terms of any one of the
>> >  * RPSL, the RCSL or the GPL.
>> >  *
>> >  * This file is part of the Helix DNA Technology. RealNetworks is the
>> >  * developer of the Original Code and owns the copyrights in the
>> >  * portions it created.
>> >  *
>> >  * This file, and the files included with this file, is distributed
>> >  * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY
>> >  * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS
>> >  * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES
>> >  * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET
>> >  * ENJOYMENT OR NON-INFRINGEMENT.
>> >  *
>> >  * Technology Compatibility Kit Test Suite(s) Location:
>> >  *    http://www.helixcommunity.org/content/tck
>> >  *
>> >  * Contributor(s):
>> >  *
>> >  * ***** END LICENSE BLOCK ***** */
>> >
>> > #include "hxtypes.h"
>> > #include "hxresult.h"
>> > #include "hxcom.h"
>> > #include "hxassert.h"
>> > #include "fwctlmgr.h"
>> >
>> > #if defined(_WIN32)
>> > #include "platform/win/win_fwctlmgr.h"
>> > #endif /* _WIN32 */
>> >
>> > HXFirewallControlManager::HXFirewallControlManager()
>> >                        :m_lRefCount(0)
>> >                          ,m_bInitialized(FALSE)
>> > {
>> > }
>> >
>> > HXFirewallControlManager::~HXFirewallControlManager()
>> > {
>> > }
>> >
>> > STDMETHODIMP
>> > HXFirewallControlManager::QueryInterface(REFIID riid, void**ppvObj)
>> > {
>> >     QInterfaceList qiList[] =
>> >         {
>> >             { GET_IIDHANDLE(IID_IHXFirewallControlManager), 
>> (IHXFirewallControlManager*)this },
>> >             { GET_IIDHANDLE(IID_IUnknown), 
>> (IUnknown*)(IHXFirewallControlManager*)this },
>> >         };
>> >
>> >     return ::QIFind(qiList, QILISTSIZE(qiList), riid, ppvObj);
>> > }
>> >
>> > /////////////////////////////////////////////////////////////////////////
>> > //  Method:
>> > //    IUnknown::AddRef
>> > //  Purpose:
>> > //    Everyone usually implements this the same... feel free to use
>> > //    this implementation.
>> > //
>> > STDMETHODIMP_(ULONG32)
>> > HXFirewallControlManager::AddRef()
>> > {
>> >     return InterlockedIncrement(&m_lRefCount);
>> > }
>> >
>> > /////////////////////////////////////////////////////////////////////////
>> > //  Method:
>> > //    IUnknown::Release
>> > //  Purpose:
>> > //    Everyone usually implements this the same... feel free to use
>> > //    this implementation.
>> > //
>> > STDMETHODIMP_(ULONG32)
>> > HXFirewallControlManager::Release()
>> > {
>> >     if (InterlockedDecrement(&m_lRefCount) > 0)
>> >     {
>> >         return m_lRefCount;
>> >     }
>> >
>> >     delete this;
>> >     return 0;
>> > }
>> >
>> > HXFirewallControlManager* HXFirewallControlManager::Create()
>> > {
>> >     HXFirewallControlManager* pFWCtlMgr = NULL;
>> >
>> > #if defined(_WIN32)
>> >     pFWCtlMgr = new HXWinFirewallControlManager();
>> > #endif /* _WIN32 */
>> >
>> >     return pFWCtlMgr;
>> > }
>> >
>> > void
>> > HXFirewallControlManager::Close()
>> > {
>> >     return;
>> > }
>> >
>> > STDMETHODIMP_(BOOL)
>> > HXFirewallControlManager::IsFirewallOn()
>> > {
>> >     return FALSE;
>> > }
>> >
>> > STDMETHODIMP
>> > HXFirewallControlManager::TurnOnFirewall()
>> > {
>> >     return HXR_NOTIMPL;
>> > }
>> >
>> > STDMETHODIMP
>> > HXFirewallControlManager::TurnOffFirewall()
>> > {
>> >     return HXR_NOTIMPL;
>> > }
>> >
>> > STDMETHODIMP
>> > HXFirewallControlManager::OpenPort(UINT32 ulPort, 
>> HX_NET_FW_IP_PROTOCOL protocol)
>> > {
>> >     return HXR_NOTIMPL;
>> > }
>> >
>> > STDMETHODIMP
>> > HXFirewallControlManager::ClosePort(UINT32 ulPort, 
>> HX_NET_FW_IP_PROTOCOL protocol)
>> > {
>> >     return HXR_NOTIMPL;
>> > }
>> >
>>
>> > /* ***** BEGIN LICENSE BLOCK *****
>> >  * Source last modified: $Id: hxcleng.cpp,v 1.60 2004/08/09 22:09:26 
>> liam_murray Exp $
>> >  *
>> >  * Portions Copyright (c) 1995-2004 RealNetworks, Inc. All Rights 
>> Reserved.
>> >  *
>> >  * The contents of this file, and the files included with this file,
>> >  * are subject to the current version of the RealNetworks Public
>> >  * Source License (the "RPSL") available at
>> >  * http://www.helixcommunity.org/content/rpsl unless you have licensed
>> >  * the file under the current version of the RealNetworks Community
>> >  * Source License (the "RCSL") available at
>> >  * http://www.helixcommunity.org/content/rcsl, in which case the RCSL
>> >  * will apply. You may also obtain the license terms directly from
>> >  * RealNetworks.  You may not use this file except in compliance with
>> >  * the RPSL or, if you have a valid RCSL with RealNetworks applicable
>> >  * to this file, the RCSL.  Please see the applicable RPSL or RCSL for
>> >  * the rights, obligations and limitations governing use of the
>> >  * contents of the file.
>> >  *
>> >  * Alternatively, the contents of this file may be used under the
>> >  * terms of the GNU General Public License Version 2 or later (the
>> >  * "GPL") in which case the provisions of the GPL are applicable
>> >  * instead of those above. If you wish to allow use of your version of
>> >  * this file only under the terms of the GPL, and not to allow others
>> >  * to use your version of this file under the terms of either the RPSL
>> >  * or RCSL, indicate your decision by deleting the provisions above
>> >  * and replace them with the notice and other provisions required by
>> >  * the GPL. If you do not delete the provisions above, a recipient may
>> >  * use your version of this file under the terms of any one of the
>> >  * RPSL, the RCSL or the GPL.
>> >  *
>> >  * This file is part of the Helix DNA Technology. RealNetworks is the
>> >  * developer of the Original Code and owns the copyrights in the
>> >  * portions it created.
>> >  *
>> >  * This file, and the files included with this file, is distributed
>> >  * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY
>> >  * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS
>> >  * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES
>> >  * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET
>> >  * ENJOYMENT OR NON-INFRINGEMENT.
>> >  *
>> >  * Technology Compatibility Kit Test Suite(s) Location:
>> >  *    http://www.helixcommunity.org/content/tck
>> >  *
>> >  * Contributor(s):
>> >  *
>> >  * ***** END LICENSE BLOCK ***** */
>> >
>> > #ifndef _FWCTLMGR_H_
>> > #define _FWCTLMGR_H_
>> >
>> > #include "hxfwctlmgr.h"
>> >
>> > class HXFirewallControlManager;
>> >
>> > class HXFirewallControlManager : public IHXFirewallControlManager
>> > {
>> > protected:
>> >     LONG32        m_lRefCount;
>> >     BOOL            m_bInitialized;
>> >
>> >     ~HXFirewallControlManager();
>> >
>> >     PRIVATE_DESTRUCTORS_ARE_NOT_A_CRIME
>> >
>> > public:
>> >     HXFirewallControlManager();
>> >
>> >     static  HXFirewallControlManager*   Create(void);
>> >     virtual void    Close(void);
>> >
>> >     /*
>> >      *        IUnknown methods
>> >      */
>> >     STDMETHOD(QueryInterface) (THIS_
>> >                               REFIID riid,
>> >                               void** ppvObj);
>> >
>> >     STDMETHOD_(ULONG32,AddRef)        (THIS);
>> >
>> >     STDMETHOD_(ULONG32,Release)       (THIS);
>> >
>> >     /*
>> >      * IHXFirewallControlManager methods
>> >      */
>> >
>> >     STDMETHOD_(BOOL,IsFirewallOn)   (THIS);
>> >     STDMETHOD(TurnOnFirewall)       (THIS);
>> >     STDMETHOD(TurnOffFirewall)      (THIS);
>> >     STDMETHOD(OpenPort)             (UINT32 ulPort,
>> >                                      HX_NET_FW_IP_PROTOCOL protocol);
>> >     STDMETHOD(ClosePort)            (UINT32 ulPort,
>> >                                      HX_NET_FW_IP_PROTOCOL protocol);
>> > };
>> >
>> > #endif /* _FWCTLMGR_H_ */
>>
>> > /* ***** BEGIN LICENSE BLOCK *****
>> >  * Source last modified: $Id: hxcleng.cpp,v 1.60 2004/08/09 22:09:26 
>> liam_murray Exp $
>> >  *
>> >  * Portions Copyright (c) 1995-2004 RealNetworks, Inc. All Rights 
>> Reserved.
>> >  *
>> >  * The contents of this file, and the files included with this file,
>> >  * are subject to the current version of the RealNetworks Public
>> >  * Source License (the "RPSL") available at
>> >  * http://www.helixcommunity.org/content/rpsl unless you have licensed
>> >  * the file under the current version of the RealNetworks Community
>> >  * Source License (the "RCSL") available at
>> >  * http://www.helixcommunity.org/content/rcsl, in which case the RCSL
>> >  * will apply. You may also obtain the license terms directly from
>> >  * RealNetworks.  You may not use this file except in compliance with
>> >  * the RPSL or, if you have a valid RCSL with RealNetworks applicable
>> >  * to this file, the RCSL.  Please see the applicable RPSL or RCSL for
>> >  * the rights, obligations and limitations governing use of the
>> >  * contents of the file.
>> >  *
>> >  * Alternatively, the contents of this file may be used under the
>> >  * terms of the GNU General Public License Version 2 or later (the
>> >  * "GPL") in which case the provisions of the GPL are applicable
>> >  * instead of those above. If you wish to allow use of your version of
>> >  * this file only under the terms of the GPL, and not to allow others
>> >  * to use your version of this file under the terms of either the RPSL
>> >  * or RCSL, indicate your decision by deleting the provisions above
>> >  * and replace them with the notice and other provisions required by
>> >  * the GPL. If you do not delete the provisions above, a recipient may
>> >  * use your version of this file under the terms of any one of the
>> >  * RPSL, the RCSL or the GPL.
>> >  *
>> >  * This file is part of the Helix DNA Technology. RealNetworks is the
>> >  * developer of the Original Code and owns the copyrights in the
>> >  * portions it created.
>> >  *
>> >  * This file, and the files included with this file, is distributed
>> >  * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY
>> >  * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS
>> >  * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES
>> >  * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET
>> >  * ENJOYMENT OR NON-INFRINGEMENT.
>> >  *
>> >  * Technology Compatibility Kit Test Suite(s) Location:
>> >  *    http://www.helixcommunity.org/content/tck
>> >  *
>> >  * Contributor(s):
>> >  *
>> >  * ***** END LICENSE BLOCK ***** */
>> >
>> > #ifndef _HXFWCTLMGR_H_
>> > #define _HXFWCTLMGR_H_
>> >
>> > typedef enum HX_NET_FW_IP_PROTOCOL_
>> > {
>> >     HX_NET_FW_IP_PROTOCOL_TCP,
>> >     HX_NET_FW_IP_PROTOCOL_UDP
>> > } HX_NET_FW_IP_PROTOCOL;
>> >
>> > typedef 
>> _INTERFACE    IHXFirewallControlManager       IHXFirewallControlManager;
>> >
>> > 
>> /****************************************************************************
>> >  *
>> >  *  Interface:
>> >  *
>> >  *    IHXFirewallControlManager
>> >  *
>> >  *  Purpose:
>> >  *
>> >  *    Interface to filewall management
>> >  *
>> >  *  IHXFirewallControlManager:
>> >  *
>> >  *    {00004900-0901-11d1-8B06-00A024406D59}
>> >  *
>> >  */
>> > DEFINE_GUID(IID_IHXFirewallControlManager, 0x00004900, 0x901, 0x11d1, 
>> 0x8b, 0x6,
>> >                                            0x0, 0xa0, 0x24, 0x40, 
>> 0x6d, 0x59);
>> >
>> > DECLARE_INTERFACE_(IHXFirewallControlManager, IUnknown)
>> > {
>> >     /*
>> >      * IUnknown methods
>> >      */
>> >     STDMETHOD(QueryInterface) (THIS_
>> >                               REFIID riid,
>> >                               void** ppvObj) PURE;
>> >
>> >     STDMETHOD_(ULONG32,AddRef)        (THIS) PURE;
>> >
>> >     STDMETHOD_(ULONG32,Release)       (THIS) PURE;
>> >
>> >     /*
>> >      * IHXFirewallControlManager methods
>> >      */
>> >
>> >     STDMETHOD_(BOOL,IsFirewallOn)   (THIS) PURE;
>> >     STDMETHOD(TurnOnFirewall)       (THIS) PURE;
>> >     STDMETHOD(TurnOffFirewall)      (THIS) PURE;
>> >     STDMETHOD(OpenPort)             (UINT32 ulPort,
>> >                                      HX_NET_FW_IP_PROTOCOL protocol) PURE;
>> >     STDMETHOD(ClosePort)            (UINT32 ulPort,
>> >                                      HX_NET_FW_IP_PROTOCOL protocol) PURE;
>> > };
>> >
>> > #endif /* _HXFWCTLMGR_H_ */
>>
>> > ? Makefile
>> > ? Umakefil.upp
>> > ? a
>> > ? dbg32
>> > ? protocol_rtsp.dsp
>> > ? protocol_rtsp.dsw
>> > ? vc60.idb
>> > Index: rtspclnt.cpp
>> > ===================================================================
>> > RCS file: /cvsroot/protocol/rtsp/rtspclnt.cpp,v
>> > retrieving revision 1.41.2.24
>> > diff -u -w -4 -r1.41.2.24 rtspclnt.cpp
>> > --- rtspclnt.cpp      15 Jun 2004 17:09:32 -0000      1.41.2.24
>> > +++ rtspclnt.cpp      26 Aug 2004 21:50:00 -0000
>> > @@ -417,9 +417,11 @@
>> >      m_pSDPFileHeader(NULL),
>> >      m_pSDPStreamHeaders(NULL),
>> >      m_bSessionSucceeded(FALSE),
>> >      m_bHasSyncMasterStream(FALSE),
>> > +    m_bFWIntegration(TRUE),
>> >      m_pNetworkServices(NULL),
>> > +    m_pFWCtlMgr(NULL),
>> >      m_pPreferences(NULL),
>> >      m_pSessionTimeout(NULL),
>> >      m_pTimeoutCallback(NULL),
>> >      m_bUseLegacyTimeOutMsg(TRUE),
>> > @@ -463,8 +465,9 @@
>> >      HX_RELEASE(m_pUAProfDiff);
>> >      HX_RELEASE(m_pUAProfURI);
>> >      HX_RELEASE(m_pPreferences);
>> >      HX_RELEASE(m_pNetworkServices);
>> > +    HX_RELEASE(m_pFWCtlMgr);
>> >      HX_RELEASE(m_pRegistry);
>> >      HX_RELEASE(m_pFileHeader);
>> >      HX_RELEASE(m_pSessionHeaders);
>> >      HX_RELEASE(m_pResponseHeaders);
>> > @@ -562,8 +565,14 @@
>> >       hresult = HXR_FAILED;
>> >          goto cleanup;
>> >      }
>> >
>> > +    ReadPrefBOOL(m_pPreferences, "FWIntegration", m_bFWIntegration);
>> > +    if (m_bFWIntegration)
>> > +    {
>> > +        pContext->QueryInterface(IID_IHXFirewallControlManager, 
>> (void**)&m_pFWCtlMgr);
>> > +    }
>> > +
>> >      if (NULL == pHostName &&
>> >          NULL != pInfo &&
>> >          HXR_OK == pInfo->GetPropertyCString("helix-sdp", pSrcBuffer))
>> >      {
>> > @@ -4630,9 +4639,19 @@
>> >               pSockOpt->SetOption(HX_SOCKOPT_REUSE_PORT, TRUE);
>> >               HX_RELEASE(pSockOpt);
>> >           }
>> >
>> > +            if (m_pFWCtlMgr && m_pFWCtlMgr->IsFirewallOn())
>> > +            {
>> > +                m_pFWCtlMgr->OpenPort(nToPort, 
>> HX_NET_FW_IP_PROTOCOL_UDP);
>> > +                pUDPSocket->Bind(HXR_INADDR_ANY, nToPort);
>> > +                m_pFWCtlMgr->ClosePort(nToPort, 
>> HX_NET_FW_IP_PROTOCOL_UDP);
>> > +            }
>> > +            else
>> > +            {
>> >           pUDPSocket->Bind(HXR_INADDR_ANY, nToPort);
>> > +            }
>> > +
>> >           pUDPSocket->Read(HX_SAFEUINT(MAX_UDP_PACKET));
>> >
>> >           ((RTSPTransport*)((*m_pTransportMPortMap)[nToPort]))->
>> >               JoinMulticast(DwToHost(HXinet_addr(pPIP)), nToPort, 
>> pUDPSocket);
>> > @@ -7519,8 +7538,14 @@
>> >          HX_RELEASE(pSockOpt);
>> >      }
>> >  #endif /* HELIX_FEATURE_TRANSPORT_MULTICAST */
>> >
>> > +    if (m_pFWCtlMgr && m_pFWCtlMgr->IsFirewallOn())
>> > +    {
>> > +        m_pFWCtlMgr->OpenPort(ulPort, HX_NET_FW_IP_PROTOCOL_UDP);
>> > +        m_pFWCtlMgr->OpenPort(ulPort+1, HX_NET_FW_IP_PROTOCOL_UDP);
>> > +    }
>> > +
>> >      if (HXR_OK != pUDPSocket1->Bind(HXR_INADDR_ANY, ulPort) ||
>> >       HXR_OK != pUDPSocket2->Bind(HXR_INADDR_ANY, ulPort+1))
>> >      {
>> >          rc = HXR_FAILED;
>> > @@ -7528,8 +7553,14 @@
>> >      }
>> >
>> >  cleanup:
>> >
>> > +    if (m_pFWCtlMgr && m_pFWCtlMgr->IsFirewallOn())
>> > +    {
>> > +        m_pFWCtlMgr->ClosePort(ulPort, HX_NET_FW_IP_PROTOCOL_UDP);
>> > +        m_pFWCtlMgr->ClosePort(ulPort+1, HX_NET_FW_IP_PROTOCOL_UDP);
>> > +    }
>> > +
>> >      if (HXR_OK == rc)
>> >      {
>> >          (*m_pUDPSocketStreamMap)[ulStream] = pUDPSocket1;
>> >          (*m_pRTCPSocketStreamMap)[ulStream] = pUDPSocket2;
>> > Index: pub/rtspclnt.h
>> > ===================================================================
>> > RCS file: /cvsroot/protocol/rtsp/pub/rtspclnt.h,v
>> > retrieving revision 1.11.2.10
>> > diff -u -w -4 -r1.11.2.10 rtspclnt.h
>> > --- pub/rtspclnt.h    8 Mar 2004 20:01:40 -0000       1.11.2.10
>> > +++ pub/rtspclnt.h    26 Aug 2004 21:50:00 -0000
>> > @@ -42,8 +42,9 @@
>> >  #include "rtptran.h"
>> >  #include "rtspmdsc.h"
>> >  #include "sdptypes.h"        // SdpFileType
>> >  #include "hxpreftr.h"
>> > +#include "hxfwctlmgr.h"
>> >  #include "hxbufctl.h" // IHXTransportBufferLimit
>> >
>> >  class RTSPClientState;
>> >  class RTSPOptionsMessage;
>> > @@ -986,10 +987,12 @@
>> >      BOOL                             m_bSplitterConsumer;
>> >      RawPacketFilter*                         m_pPacketFilter;
>> >
>> >      BOOL                             m_bHasSyncMasterStream;
>> > +    BOOL                                m_bFWIntegration;
>> >
>> >      IHXNetworkServices*                      m_pNetworkServices;
>> > +    IHXFirewallControlManager*          m_pFWCtlMgr;
>> >      IHXPreferences*                  m_pPreferences;
>> >      IHXBuffer*                               m_pUAProfURI;
>> >      IHXBuffer*                               m_pUAProfDiff;
>> >
>>
>> > ? a
>> > Index: helix-client-core-advanced.pfi
>> > ===================================================================
>> > RCS file: /cvsroot/ribosome/build/umakepf/helix-client-core-advanced.pfi,v
>> > retrieving revision 1.17
>> > diff -u -w -4 -r1.17 helix-client-core-advanced.pfi
>> > --- helix-client-core-advanced.pfi    8 Jul 2004 00:37:47 -0000       1.17
>> > +++ helix-client-core-advanced.pfi    26 Aug 2004 22:43:09 -0000
>> > @@ -82,8 +82,9 @@
>> >  project.AddDefines('HELIX_FEATURE_ALT_URL')
>> >  project.AddDefines('HELIX_FEATURE_SMIL_REPEAT')
>> >  project.AddDefines('HELIX_FEATURE_SMIL_SOUNDLEVEL')
>> >  project.AddDefines('HELIX_FEATURE_DRM')
>> > +project.AddDefines('HELIX_FEATURE_FW_CTLMGR')
>> >
>> >  # Allows building dtdriver module for audio transcode
>> >  exec_profile_file("helix-dtdr-local-audio-transcode.pfi")
>> >
>> > Index: helix-client-core-audio-advanced.pfi
>> > ===================================================================
>> > RCS file: 
>> /cvsroot/ribosome/build/umakepf/helix-client-core-audio-advanced.pfi,v
>> > retrieving revision 1.10
>> > diff -u -w -4 -r1.10 helix-client-core-audio-advanced.pfi
>>
>> > /* ***** BEGIN LICENSE BLOCK *****
>> >  * Source last modified: $Id: hxcleng.cpp,v 1.60 2004/08/09 22:09:26 
>> liam_murray Exp $
>> >  *
>> >  * Portions Copyright (c) 1995-2004 RealNetworks, Inc. All Rights 
>> Reserved.
>> >  *
>> >  * The contents of this file, and the files included with this file,
>> >  * are subject to the current version of the RealNetworks Public
>> >  * Source License (the "RPSL") available at
>> >  * http://www.helixcommunity.org/content/rpsl unless you have licensed
>> >  * the file under the current version of the RealNetworks Community
>> >  * Source License (the "RCSL") available at
>> >  * http://www.helixcommunity.org/content/rcsl, in which case the RCSL
>> >  * will apply. You may also obtain the license terms directly from
>> >  * RealNetworks.  You may not use this file except in compliance with
>> >  * the RPSL or, if you have a valid RCSL with RealNetworks applicable
>> >  * to this file, the RCSL.  Please see the applicable RPSL or RCSL for
>> >  * the rights, obligations and limitations governing use of the
>> >  * contents of the file.
>> >  *
>> >  * Alternatively, the contents of this file may be used under the
>> >  * terms of the GNU General Public License Version 2 or later (the
>> >  * "GPL") in which case the provisions of the GPL are applicable
>> >  * instead of those above. If you wish to allow use of your version of
>> >  * this file only under the terms of the GPL, and not to allow others
>> >  * to use your version of this file under the terms of either the RPSL
>> >  * or RCSL, indicate your decision by deleting the provisions above
>> >  * and replace them with the notice and other provisions required by
>> >  * the GPL. If you do not delete the provisions above, a recipient may
>> >  * use your version of this file under the terms of any one of the
>> >  * RPSL, the RCSL or the GPL.
>> >  *
>> >  * This file is part of the Helix DNA Technology. RealNetworks is the
>> >  * developer of the Original Code and owns the copyrights in the
>> >  * portions it created.
>> >  *
>> >  * This file, and the files included with this file, is distributed
>> >  * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY
>> >  * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS
>> >  * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES
>> >  * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET
>> >  * ENJOYMENT OR NON-INFRINGEMENT.
>> >  *
>> >  * Technology Compatibility Kit Test Suite(s) Location:
>> >  *    http://www.helixcommunity.org/content/tck
>> >  *
>> >  * Contributor(s):
>> >  *
>> >  * ***** END LICENSE BLOCK ***** */
>> >
>> > #define _WIN32_DCOM
>> >
>> > #include "hxtypes.h"
>> > #include "hxresult.h"
>> > #include "hxcom.h"
>> > #include "hxassert.h"
>> > #include "hxslist.h"
>> > #include "win_fwctlmgr.h"
>> >
>> > typedef struct
>> > {
>> >     LONG                lPort;
>> >     NET_FW_IP_PROTOCOL  protocol;
>> > } HXFWPorts;
>> >
>> > // copied from netfw_i.c in MS Platform SDK
>> > const IID IID_INetFwOpenPort = 
>> {0xE0483BA0,0x47FF,0x4D9C,{0xA6,0xD6,0x77,0x41,0xD0,0xB1,0x95,0xF7}};
>> >
>> > #define HX_FWPORT_IDENTIFIER    L"HelixDNAClient"
>> >
>> > HXWinFirewallControlManager::HXWinFirewallControlManager()
>> >                           :HXFirewallControlManager()
>> >                             ,m_fwProfile(NULL)
>> >                             ,m_fwBstrName(NULL)
>> > {
>> >     HRESULT hr = S_OK;
>> >
>> >     // Initialize COM.
>> >     hr = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | 
>> COINIT_DISABLE_OLE1DDE);
>> >     if (SUCCEEDED(hr) || RPC_E_CHANGED_MODE == hr)
>> >     {
>> >         if (HXR_OK == Init())
>> >         {
>> >             // create the identifier for the ports we modify
>> >             m_fwBstrName = SysAllocString((const unsigned 
>> short*)HX_FWPORT_IDENTIFIER);
>> >             if (SysStringLen(m_fwBstrName) != 0)
>> >             {
>> >                 m_bInitialized = TRUE;
>> >                 // remove any left open ports by us from previous session
>> >                 Reset();
>> >             }
>> >         }
>> >     }
>> > }
>> >
>> > HXWinFirewallControlManager::~HXWinFirewallControlManager()
>> > {
>> >     Close();
>> > }
>> >
>> > void
>> > HXWinFirewallControlManager::Close()
>> > {
>> >     HRESULT hr = S_OK;
>> >
>> >     // remove any left open ports by us from this session
>> >     hr = Reset();
>> >
>> >     HX_RELEASE(m_fwProfile);
>> >     if (m_bInitialized)
>> >     {
>> >         m_bInitialized = FALSE;
>> >         CoUninitialize();
>> >     }
>> >
>> >     return;
>> > }
>> >
>> > STDMETHODIMP_(BOOL)
>> > HXWinFirewallControlManager::IsFirewallOn()
>> > {
>> >     BOOL    fwOn = FALSE;
>> >     HRESULT hr = S_OK;
>> >     VARIANT_BOOL fwEnabled;
>> >
>> >     if (!m_bInitialized)
>> >     {
>> >         goto exit;
>> >     }
>> >
>> >     // Get the current state of the firewall.
>> >     hr = m_fwProfile->get_FirewallEnabled(&fwEnabled);
>> >     if (FAILED(hr))
>> >     {
>> >         goto exit;
>> >     }
>> >
>> >     // Check to see if the firewall is on.
>> >     if (fwEnabled == VARIANT_TRUE)
>> >     {
>> >         fwOn = TRUE;
>> >     }
>> >
>> > exit:
>> >
>> >     return fwOn;
>> > }
>> >
>> > STDMETHODIMP
>> > HXWinFirewallControlManager::TurnOnFirewall()
>> > {
>> >     HRESULT hr = S_OK;
>> >
>> >     // no-op if firewall is on
>> >     if (IsFirewallOn())
>> >     {
>> >         return HXR_OK;
>> >     }
>> >
>> >     if (!m_bInitialized)
>> >     {
>> >         return HXR_FAILED;
>> >     }
>> >
>> >     // Check to see if the firewall is off.
>> >     if (!IsFirewallOn())
>> >     {
>> >         // Turn the firewall on.
>> >         hr = m_fwProfile->put_FirewallEnabled(VARIANT_TRUE);
>> >     }
>> >
>> >     if (SUCCEEDED(hr))
>> >     {
>> >         return HXR_OK;
>> >     }
>> >     else
>> >     {
>> >         return HXR_FAILED;
>> >     }
>> > }
>> >
>> > STDMETHODIMP
>> > HXWinFirewallControlManager::TurnOffFirewall()
>> > {
>> >     HRESULT hr = S_OK;
>> >
>> >     // no-op if firewall is off
>> >     if (!IsFirewallOn())
>> >     {
>> >         return HXR_OK;
>> >     }
>> >
>> >     HX_ASSERT(m_fwProfile);
>> >
>> >     // Turn the firewall off.
>> >     hr = m_fwProfile->put_FirewallEnabled(VARIANT_FALSE);
>> >     if (SUCCEEDED(hr))
>> >     {
>> >         return HXR_OK;
>> >     }
>> >     else
>> >     {
>> >         return HXR_FAILED;
>> >     }
>> > }
>> >
>> > STDMETHODIMP
>> > HXWinFirewallControlManager::OpenPort(UINT32 ulPort, 
>> HX_NET_FW_IP_PROTOCOL protocol)
>> > {
>> >     HRESULT hr = S_OK;
>> >     VARIANT_BOOL fwEnabled;
>> >     BSTR fwBstrName = NULL;
>> >     NET_FW_IP_PROTOCOL winprotocol;
>> >     INetFwOpenPort* fwOpenPort = NULL;
>> >     INetFwOpenPorts* fwOpenPorts = NULL;
>> >
>> >     // no-op if firewall is off
>> >     if (!IsFirewallOn())
>> >     {
>> >         goto exit;
>> >     }
>> >
>> >     HX_ASSERT(m_fwProfile);
>> >
>> >     // Retrieve the globally open ports collection.
>> >     hr = m_fwProfile->get_GloballyOpenPorts(&fwOpenPorts);
>> >     if (FAILED(hr))
>> >     {
>> >         goto exit;
>> >     }
>> >
>> >     // Attempt to retrieve the globally open port.
>> >     if (HX_NET_FW_IP_PROTOCOL_UDP == protocol)
>> >     {
>> >         winprotocol = NET_FW_IP_PROTOCOL_UDP;
>> >     }
>> >     else if (HX_NET_FW_IP_PROTOCOL_TCP == protocol)
>> >     {
>> >         winprotocol = NET_FW_IP_PROTOCOL_TCP;
>> >     }
>> >     else
>> >     {
>> >         HX_ASSERT(FALSE);
>> >         goto exit;
>> >     }
>> >
>> >     hr = fwOpenPorts->Item(ulPort, winprotocol, &fwOpenPort);
>> >     if (SUCCEEDED(hr))
>> >     {
>> >         // Find out if the globally open port is enabled.
>> >         hr = fwOpenPort->get_Enabled(&fwEnabled);
>> >         if (FAILED(hr))
>> >         {
>> >             goto exit;
>> >         }
>> >
>> >         if (fwEnabled == VARIANT_TRUE)
>> >         {
>> >             goto exit;
>> >         }
>> >     }
>> >
>> >     HX_RELEASE(fwOpenPort);
>> >
>> >     // Create an instance of an open port.
>> >     hr = CoCreateInstance(
>> >             __uuidof(NetFwOpenPort),
>> >             NULL,
>> >             CLSCTX_INPROC_SERVER,
>> >             __uuidof(INetFwOpenPort),
>> > reinterpret_cast<void**>(static_cast<INetFwOpenPort**>(&fwOpenPort))
>> >             );
>> >
>> >     if (FAILED(hr))
>> >     {
>> >         goto exit;
>> >     }
>> >
>> >     // Set the port number.
>> >     hr = fwOpenPort->put_Port(ulPort);
>> >     if (FAILED(hr))
>> >     {
>> >         goto exit;
>> >     }
>> >
>> >     // Set the IP protocol.
>> >     hr = fwOpenPort->put_Protocol(winprotocol);
>> >     if (FAILED(hr))
>> >     {
>> >         goto exit;
>> >     }
>> >
>> >     // Set the friendly name of the port.
>> >     hr = fwOpenPort->put_Name(m_fwBstrName);
>> >     if (FAILED(hr))
>> >     {
>> >         goto exit;
>> >     }
>> >
>> >     // Opens the port and adds it to the collection.
>> >     hr = fwOpenPorts->Add(fwOpenPort);
>> >     if (FAILED(hr))
>> >     {
>> >         goto exit;
>> >     }
>> >
>> > exit:
>> >
>> >     // Release the globally open port.
>> >     // Release the globally open ports collection.
>> >     HX_RELEASE(fwOpenPort);
>> >     HX_RELEASE(fwOpenPorts);
>> >
>> >     if (FAILED(hr))
>> >     {
>> >         return HXR_FAILED;
>> >     }
>> >
>> >     return HXR_OK;
>> > }
>> >
>> > STDMETHODIMP
>> > HXWinFirewallControlManager::ClosePort(UINT32 ulPort, 
>> HX_NET_FW_IP_PROTOCOL protocol)
>> > {
>> >     HRESULT hr = S_OK;
>> >     VARIANT_BOOL fwEnabled;
>> >     NET_FW_IP_PROTOCOL winprotocol;
>> >     INetFwOpenPort* fwOpenPort = NULL;
>> >     INetFwOpenPorts* fwOpenPorts = NULL;
>> >
>> >     // no-op if firewall is off
>> >     if (!IsFirewallOn())
>> >     {
>> >         goto exit;
>> >     }
>> >
>> >     HX_ASSERT(m_fwProfile);
>> >
>> >     // Retrieve the globally open ports collection.
>> >     hr = m_fwProfile->get_GloballyOpenPorts(&fwOpenPorts);
>> >     if (FAILED(hr))
>> >     {
>> >         goto exit;
>> >     }
>> >
>> >     // Attempt to retrieve the globally open port.
>> >     if (HX_NET_FW_IP_PROTOCOL_UDP == protocol)
>> >     {
>> >         winprotocol = NET_FW_IP_PROTOCOL_UDP;
>> >     }
>> >     else if (HX_NET_FW_IP_PROTOCOL_TCP == protocol)
>> >     {
>> >         winprotocol = NET_FW_IP_PROTOCOL_TCP;
>> >     }
>> >     else
>> >     {
>> >         HX_ASSERT(FALSE);
>> >         goto exit;
>> >     }
>> >
>> >     hr = fwOpenPorts->Item(ulPort, winprotocol, &fwOpenPort);
>> >     if (SUCCEEDED(hr))
>> >     {
>> >         // Find out if the globally open port is enabled.
>> >         hr = fwOpenPort->get_Enabled(&fwEnabled);
>> >         if (FAILED(hr))
>> >         {
>> >             goto exit;
>> >         }
>> >
>> >         if (fwEnabled == VARIANT_TRUE)
>> >         {
>> >             // Opens the port and adds it to the collection.
>> >             hr = fwOpenPorts->Remove(ulPort, winprotocol);
>> >             if (FAILED(hr))
>> >             {
>> >                 goto exit;
>> >             }
>> >         }
>> >     }
>> >
>> > exit:
>> >     // Release the globally open port.
>> >     // Release the globally open ports collection.
>> >     HX_RELEASE(fwOpenPort);
>> >     HX_RELEASE(fwOpenPorts);
>> >
>> >     if (FAILED(hr))
>> >     {
>> >         return HXR_FAILED;
>> >     }
>> >
>> >     return HXR_OK;
>> > }
>> >
>> > HX_RESULT
>> > HXWinFirewallControlManager::Init()
>> > {
>> >     HX_RESULT       rc = HXR_OK;
>> >     HRESULT         hr = S_OK;
>> >     INetFwMgr*      fwMgr = NULL;
>> >     INetFwPolicy*   fwPolicy = NULL;
>> >
>> >     // Create an instance of the firewall settings manager.
>> >     hr = CoCreateInstance(
>> >             __uuidof(NetFwMgr),
>> >             NULL,
>> >             CLSCTX_INPROC_SERVER,
>> >             __uuidof(INetFwMgr),
>> >             reinterpret_cast<void**>(static_cast<INetFwMgr**>(&fwMgr))
>> >             );
>> >     if (FAILED(hr))
>> >     {
>> >         rc = HXR_FAILED;
>> >         goto exit;
>> >     }
>> >
>> >     // Retrieve the local firewall policy.
>> >     hr = fwMgr->get_LocalPolicy(&fwPolicy);
>> >     if (FAILED(hr))
>> >     {
>> >         rc = HXR_FAILED;
>> >         goto exit;
>> >     }
>> >
>> >     // Retrieve the firewall profile currently in effect.
>> >     hr = fwPolicy->get_CurrentProfile(&m_fwProfile);
>> >     if (FAILED(hr))
>> >     {
>> >         rc = HXR_FAILED;
>> >         goto exit;
>> >     }
>> >
>> > exit:
>> >
>> >     // Release the local firewall policy.
>> >     // Release the firewall settings manager.
>> >     HX_RELEASE(fwPolicy);
>> >     HX_RELEASE(fwMgr);
>> >
>> >     return rc;
>> > }
>> >
>> > HX_RESULT
>> > HXWinFirewallControlManager::Reset()
>> > {
>> >     HRESULT             hr = S_OK;
>> >     LCID                lLan = 1024;    // Use the default language 
>> for comparing strings
>> >     CHXSimpleList*      pPortsRemoveList = NULL;
>> >     CHXSimpleList::Iterator i;
>> >     IUnknown*           pUnk = NULL;
>> >     INetFwOpenPorts*    fwOpenPorts = NULL;
>> >     IEnumVARIANT*       pEnumVar = NULL;
>> >
>> >     if (!m_bInitialized)
>> >     {
>> >         goto exit;
>> >     }
>> >
>> >     // Retrieve the globally open ports collection.
>> >     hr = m_fwProfile->get_GloballyOpenPorts(&fwOpenPorts);
>> >     if (FAILED(hr))
>> >     {
>> >         goto exit;
>> >     }
>> >
>> >     hr = fwOpenPorts->get__NewEnum(&pUnk);
>> >     if (SUCCEEDED(hr))
>> >     {
>> >         hr = pUnk->QueryInterface(IID_IEnumVARIANT, (void **)&pEnumVar);
>> >         if (SUCCEEDED(hr))
>> >         {
>> >             VARIANT varCurPorts;
>> >             VariantInit(&varCurPorts);
>> >             hr = pEnumVar->Reset();
>> >
>> >             // Loop through each port in the collection
>> >             while (S_OK == pEnumVar->Next(1, &varCurPorts, NULL))
>> >             {
>> >                 INetFwOpenPort* fwOpenPort = NULL;
>> >                 IDispatch*      pdispPorts = V_DISPATCH(&varCurPorts);
>> >
>> >                 if 
>> (SUCCEEDED(pdispPorts->QueryInterface(IID_INetFwOpenPort, (void 
>> **)&fwOpenPort)))
>> >                 {
>> >                     // Get the name associated with the port
>> >                     BSTR bstrName = NULL;
>> >                     if (SUCCEEDED(fwOpenPort->get_Name(&bstrName)))
>> >                     {
>> >                         // Retrieve the port created by us(m_fwBstrName)
>> >                         if (VARCMP_EQ == VarBstrCmp(bstrName, 
>> m_fwBstrName, lLan, NULL))
>> >                         {
>> >                             if (!pPortsRemoveList)
>> >                             {
>> >                                 pPortsRemoveList = new CHXSimpleList();
>> >                             }
>> >
>> >                             if (pPortsRemoveList)
>> >                             {
>> >                                 HXFWPorts* pPort = new HXFWPorts;
>> >                                 fwOpenPort->get_Port(&(pPort->lPort));
>> > fwOpenPort->get_Protocol(&(pPort->protocol));
>> >
>> >                                 pPortsRemoveList->AddTail(pPort);
>> >                             }
>> >                         }
>> >                         SysFreeString(bstrName);
>> >                     }
>> >                     HX_RELEASE(fwOpenPort);
>> >                 }
>> >                 VariantClear(&varCurPorts);
>> >             }
>> >             HX_RELEASE(pEnumVar);
>> >         }
>> >         HX_RELEASE(pUnk);
>> >     }
>> >
>> >     // Close the ports opened by us
>> >     if (pPortsRemoveList)
>> >     {
>> >         for (i = pPortsRemoveList->Begin(); i != 
>> pPortsRemoveList->End(); ++i)
>> >         {
>> >           HXFWPorts* pPort = (HXFWPorts*)(*i);
>> >             fwOpenPorts->Remove(pPort->lPort, pPort->protocol);
>> >             HX_DELETE(pPort);
>> >         }
>> >         HX_DELETE(pPortsRemoveList);
>> >     }
>> >
>> > exit:
>> >
>> >     SysFreeString(m_fwBstrName);
>> >     HX_RELEASE(fwOpenPorts);
>> >
>> >     return HXR_OK;
>> > }
>>
>> > _______________________________________________
>> > Client-dev mailing list
>> > Client-dev at lists.helixcommunity.org
>> > http://lists.helixcommunity.org/mailman/listinfo/client-dev
>
>
>_______________________________________________
>Common-dev mailing list
>Common-dev at lists.helixcommunity.org
>http://lists.helixcommunity.org/mailman/listinfo/common-dev
-------------- next part --------------
? Makefile
? Umakefil.upp
? a
? client_netwksvc.dsp
? client_netwksvc.dsw
? dbg32
? vc60.idb
Index: hxnetapi.cpp
===================================================================
RCS file: /cvsroot/client/netwksvc/hxnetapi.cpp,v
retrieving revision 1.27.4.1
diff -u -w -4 -r1.27.4.1 hxnetapi.cpp
--- hxnetapi.cpp	30 Oct 2003 21:37:08 -0000	1.27.4.1
+++ hxnetapi.cpp	27 Aug 2004 00:54:06 -0000
@@ -80,9 +80,9 @@
 #include "macsockets.h" 
 #endif
 
 #include "threngin.h"
-
+#include "hxprefutil.h"
 #include "netbyte.h"
 #include "hxnetapi.h"
 #include "hxnetutil.h"
 
@@ -1930,16 +1930,19 @@
     m_pSchedulerReadCallback(NULL),
     m_pSchedulerWriteCallback(NULL),
     m_pNonInterruptReadCallback(NULL),
     m_pScheduler(0),
+    m_pPreferences(NULL),
+    m_pFWCtlMgr(NULL),
     m_nDestPort(0),
     m_bInitComplete(FALSE),
     m_pInterruptState(NULL),
     m_pResponseInterruptSafe(NULL),
     m_pMutex(NULL),
     m_bReuseAddr(FALSE),
     m_bReusePort(FALSE),    
     m_bInDestructor(FALSE),
+    m_bFWIntegration(TRUE),
     m_pContext(pContext)
 {
 #ifdef _MACINTOSH
 	m_pInterruptSafeMacWriteQueue = new InterruptSafeMacQueue();
@@ -1952,8 +1955,15 @@
     if (pContext)
     {
 	pContext->QueryInterface(IID_IHXScheduler, (void**) &m_pScheduler);
 	pContext->QueryInterface(IID_IHXInterruptState, (void**) &m_pInterruptState);
+        pContext->QueryInterface(IID_IHXPreferences, (void**) &m_pPreferences);
+    }
+
+    ReadPrefBOOL(m_pPreferences, "FWIntegration", m_bFWIntegration);
+    if (m_bFWIntegration)
+    {
+        pContext->QueryInterface(IID_IHXFirewallControlManager, (void**)&m_pFWCtlMgr);
     }
 
     if (m_pScheduler)
     {
@@ -2039,8 +2049,11 @@
 	m_pScheduler->Release();
 	m_pScheduler = 0;
     }
 
+    HX_RELEASE(m_pFWCtlMgr);
+    HX_RELEASE(m_pPreferences);
+
     while (!m_ReadBuffers.IsEmpty())
     {
 	UDP_PACKET* pPacket = (UDP_PACKET*)m_ReadBuffers.RemoveHead();
 
@@ -2220,12 +2233,21 @@
 #ifdef _UNIX    
     m_pData->SetAsyncDNSPref( ReadAsyncDNSPref((IUnknown*)m_pContext) );
 #endif    
 
+    if (m_pFWCtlMgr)
+    {
+        m_pFWCtlMgr->OpenPort(nPort, HX_NET_FW_IP_PROTOCOL_UDP);
+    }
   
     // XXXST -- local addr binding stuff, removed dependency to m_nLocalPort
     // 0 for local port will make the system choose a free port
     theErr = m_pData->init(ulLocalAddr, nPort);
+
+    if (m_pFWCtlMgr)
+    {
+        m_pFWCtlMgr->ClosePort(nPort, HX_NET_FW_IP_PROTOCOL_UDP);
+    }
     
     if (theErr)
     {
 	theErr = ConvertNetworkError(theErr);
Index: pub/hxnetapi.h
===================================================================
RCS file: /cvsroot/client/netwksvc/pub/hxnetapi.h,v
retrieving revision 1.12
diff -u -w -4 -r1.12 hxnetapi.h
--- pub/hxnetapi.h	20 Jun 2003 20:36:13 -0000	1.12
+++ pub/hxnetapi.h	27 Aug 2004 00:54:06 -0000
@@ -53,8 +53,9 @@
 #include "hxathsp.h"
 #include "hxcomsp.h"
 #include "hxplnsp.h"
 
+#include "hxfwctlmgr.h"
 #include "hxcloakedtcp.h"
 #include "hxsockcallback.h"
 #include "hxnetutil.h"
 
@@ -301,8 +302,10 @@
     UINT32			m_nRequired;
     CHXSimpleList		m_ReadBuffers;
     CHXSimpleList		m_WriteBuffers;
     IHXScheduler*		m_pScheduler;
+    IHXPreferences*             m_pPreferences;
+    IHXFirewallControlManager*  m_pFWCtlMgr;
     UDPSocketCallback*		m_pCallback;
     ScheduledSocketCallback*	m_pSchedulerReadCallback;
     ScheduledSocketCallback*	m_pSchedulerWriteCallback;
     ScheduledSocketCallback*	m_pNonInterruptReadCallback;
@@ -318,8 +321,9 @@
 #endif
 
     BOOL			m_bReuseAddr;
     BOOL			m_bReusePort;    
+    BOOL                        m_bFWIntegration;
 };
 
 class HXTCPSocket : public IHXTCPSocket,
 		     public IHXSetSocketOption,


More information about the Common-dev mailing list
 

Site Map   |   Terms of Use   |   Privacy Policy   |   Contact Us

Copyright © 1995-2007 RealNetworks, Inc. All rights reserved. RealNetworks and Helix are trademarks of RealNetworks.
All other trademarks or registered trademarks are the property of their respective holders.