/*++ Copyright (c) 2000 Microsoft Corporation. All rights reserved. --*/ // socksfilter.h : Declaration of the Csocksfilter #ifndef __SOCKSFILTER_H_ #define __SOCKSFILTER_H_ #include "stdafx.h" #include "resource.h" // main symbols #include "FilterDataStructures.h" const USHORT SOCKS_PORT=1080; const DWORD MAX_CMD_LENGTH=512; const MAX_USR_LEN=100; const MAX_PWD_LEN=100; const CONN_CMD = 1; const BIND_CMD = 2; const CONN_SUCC = 0; const CONN_FAIL = 1; const NO_ACCEPT_METHOD = 0xFF; ///////////////////////////////////////////////////////////////////////////// // Csocksfilter class ATL_NO_VTABLE Csocksfilter : public CComObjectRootEx, public CComCoClass, public IFWXFilter, public IFWXAcceptCompletion, public IFWXPolicyChangeNotification { private: CComPtr m_spIFWXFirewall; /*Pointer to the WspProxy interface of the server */ FwxFilterHookEvents m_SocksHookEvents ; CComPtr m_spListenSocket; public: Csocksfilter(); DECLARE_REGISTRY_RESOURCEID(IDR_SOCKSFILTER) DECLARE_NOT_AGGREGATABLE(Csocksfilter) DECLARE_PROTECT_FINAL_CONSTRUCT() BEGIN_COM_MAP(Csocksfilter) COM_INTERFACE_ENTRY(IFWXFilter) COM_INTERFACE_ENTRY(IFWXPolicyChangeNotification) END_COM_MAP() // IFWXFilter public: IT findInMap(u_long ulIp,LPSTR user); HRESULT findSocket(u_long ulIP,LPSTR user,DWORD ip,USHORT port,IFWXNetworkSocket **); HRESULT DeleteFromList(SOCKLIST *,SOCKLIST::iterator); HRESULT DeleteFromMap(IT it); HRESULT InsertSocket(u_long,LPSTR ,CComPtr&); HRESULT InsertSession(u_long ulIp,LPSTR ,SessionItem&); HRESULT SubCount(SessionItem *session); HRESULT FindOrCreateSession( u_long ulIp, LPSTR user, LPSTR domain, SOCKADDR ClientAddr, SOCKADDR ProxyAddr, IFWXSession **spSession, HANDLE ); HRESULT FindSession(u_long ulIp,LPSTR,IFWXSession **spSession); HRESULT STDMETHODCALLTYPE FilterInit( /* [in] */ IFWXFirewall __RPC_FAR *pIFWXFirewall, /* [out] */ FwxFilterHookEvents __RPC_FAR *pFilterHookEvents); HRESULT STDMETHODCALLTYPE FilterShutdown( void) ; HRESULT STDMETHODCALLTYPE AttachToSession( /* [in] */ IFWXSession __RPC_FAR *piSession, /* [out] */ IFWXSessionFilter __RPC_FAR *__RPC_FAR *piSessionFilter, /* [out] */ FwxFilterHookEvents __RPC_FAR *pFilterHookEvents) ; // IFWXPolicyChangeNotification HRESULT STDMETHODCALLTYPE ReloadConfiguration( void) ; // IAcceptCompition HRESULT STDMETHODCALLTYPE CompleteAsyncAccept( BOOL fSuccess, DWORD Win32ErrorCode, IFWXNetworkSocket *pListeningSocket, IFWXNetworkSocket *pAcceptSocket, PSOCKADDR RemoteAddress, DWORD RemoteAddressLength, PSOCKADDR LocalAddress, DWORD LocalAddressLength, UserContextType UserData ); private: void IssueNextAccept() { Lock(); CComPtr spSocket(m_spListenSocket); Unlock(); if (spSocket) spSocket->Accept(this, NULL); } // This map holds IP and a SessionItem (Item includs a session,number of // connections to this Session and list of sockets) std::map m_UserIPSessionItemMap; }; #endif //__SOCKSFILTER_H_