ReactOS  0.4.15-dev-1638-gc0caa5c
ipv4.cpp
Go to the documentation of this file.
1 /*
2  * COPYRIGHT: See COPYING in the top level directory
3  * PROJECT: ReactOS BDA Proxy
4  * FILE: dll/directx/msdvbnp/ipv4.cpp
5  * PURPOSE: IBDA_IPV4Filter interface
6  *
7  * PROGRAMMERS: Johannes Anderwald (johannes.anderwald@reactos.org)
8  */
9 #include "precomp.h"
10 
12 {
13 public:
17 
18  //IBDA_IPV4Filter
20  HRESULT STDMETHODCALLTYPE PutMulticastList(ULONG ulcbAddresses, BYTE * pAddressList);
21  HRESULT STDMETHODCALLTYPE GetMulticastList(ULONG *pulcbAddresses, BYTE *pAddressList);
24 
25 
26  CIPV4Filter(IBDA_NetworkProvider * pNetworkProvider);
27  virtual ~CIPV4Filter();
28 
29 protected:
34 };
35 
37  IBDA_NetworkProvider * pNetworkProvider) : m_pNetworkProvider(pNetworkProvider),
38  m_ulcbAddresses(0),
39  m_pAddressList(0),
40  m_ulModeMask(0)
41 {
42 }
43 
45 {
46  if (m_pAddressList)
48 }
49 
50 
51 HRESULT
54  REFIID InterfaceId,
56 {
58  return m_pNetworkProvider->QueryInterface(InterfaceId, Interface);
59 }
60 
61 ULONG
64 {
66  return m_pNetworkProvider->AddRef();
67 }
68 
69 ULONG
72 {
74  return m_pNetworkProvider->Release();
75 }
76 
77 //-------------------------------------------------------------------
78 //IBDA_IPV4Filter
79 //
80 
81 
82 HRESULT
85  ULONG *pulcbAddresses)
86 {
87  if (!pulcbAddresses)
88  return E_POINTER;
89 
90  *pulcbAddresses = 0;
91  return NOERROR;
92 }
93 
94 HRESULT
97  ULONG ulcbAddresses,
98  BYTE * pAddressList)
99 {
100  if (!ulcbAddresses || !pAddressList)
101  return E_POINTER;
102 
103  if (m_pAddressList)
105 
106  m_pAddressList = (BYTE*)CoTaskMemAlloc(ulcbAddresses);
107  if (!m_pAddressList)
108  return E_OUTOFMEMORY;
109 
110  CopyMemory(m_pAddressList, pAddressList, ulcbAddresses);
111  m_ulcbAddresses = ulcbAddresses;
112  return NOERROR;
113 }
114 
115 HRESULT
118  ULONG *pulcbAddresses,
119  BYTE *pAddressList)
120 {
121  if (!pulcbAddresses || !pAddressList)
122  return E_POINTER;
123 
124  if (*pulcbAddresses < m_ulcbAddresses)
125  return E_OUTOFMEMORY;
126 
127  CopyMemory(pAddressList, m_pAddressList, m_ulcbAddresses);
128  *pulcbAddresses = m_ulcbAddresses;
129  return NOERROR;
130 }
131 
132 HRESULT
135  ULONG ulModeMask)
136 {
137  m_ulModeMask = ulModeMask;
138  return NOERROR;
139 }
140 
141 HRESULT
144  ULONG *pulModeMask)
145 {
146  *pulModeMask = m_ulModeMask;
147  return NOERROR;
148 }
149 
150 HRESULT
151 WINAPI
153  IBDA_NetworkProvider * pNetworkProvider,
154  REFIID riid,
155  LPVOID * ppv)
156 {
157  CIPV4Filter * filter = new CIPV4Filter(pNetworkProvider);
158 
159  if (!filter)
160  return E_OUTOFMEMORY;
161 
162  if (FAILED(filter->QueryInterface(riid, ppv)))
163  {
164  /* not supported */
165  delete filter;
166  return E_NOINTERFACE;
167  }
168 
169  return NOERROR;
170 }
STDMETHODIMP QueryInterface(REFIID InterfaceId, PVOID *Interface)
Definition: ipv4.cpp:53
#define REFIID
Definition: guiddef.h:118
#define E_NOINTERFACE
Definition: winerror.h:2364
VOID WINAPI CoTaskMemFree(LPVOID ptr)
Definition: ifs.c:442
#define NOERROR
Definition: winerror.h:2354
REFIID riid
Definition: precomp.h:44
HRESULT WINAPI CIPV4Filter_fnConstructor(IBDA_NetworkProvider *pNetworkProvider, REFIID riid, LPVOID *ppv)
Definition: ipv4.cpp:152
REFIID LPVOID * ppv
Definition: atlbase.h:39
#define assert(x)
Definition: debug.h:53
HRESULT STDMETHODCALLTYPE GetMulticastList(ULONG *pulcbAddresses, BYTE *pAddressList)
Definition: ipv4.cpp:117
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
IBDA_NetworkProvider * m_pNetworkProvider
Definition: ipv4.cpp:30
#define STDMETHODIMP
Definition: basetyps.h:43
ULONG Release()
ULONG m_ulcbAddresses
Definition: ipv4.cpp:31
HRESULT STDMETHODCALLTYPE GetMulticastMode(ULONG *pulModeMask)
Definition: ipv4.cpp:143
LONG HRESULT
Definition: typedefs.h:79
ULONG m_ulModeMask
Definition: ipv4.cpp:33
#define WINAPI
Definition: msvc.h:6
#define CopyMemory
Definition: winbase.h:1646
#define STDMETHODCALLTYPE
Definition: bdasup.h:9
ULONG AddRef()
HRESULT STDMETHODCALLTYPE GetMulticastListSize(ULONG *pulcbAddresses)
Definition: ipv4.cpp:84
BYTE * m_pAddressList
Definition: ipv4.cpp:32
unsigned char BYTE
Definition: xxhash.c:193
virtual ~CIPV4Filter()
Definition: ipv4.cpp:44
CIPV4Filter(IBDA_NetworkProvider *pNetworkProvider)
Definition: ipv4.cpp:36
IN PVOID IN PVOID IN USHORT IN USHORT IN PINTERFACE Interface
Definition: pci.h:361
HRESULT STDMETHODCALLTYPE PutMulticastMode(ULONG ulModeMask)
Definition: ipv4.cpp:134
HRESULT QueryInterface([in] REFIID riid, [out, iid_is(riid)] void **ppvObject)
unsigned int ULONG
Definition: retypes.h:1
STDMETHODIMP_(ULONG) AddRef()
#define E_POINTER
Definition: winerror.h:2365
LPVOID WINAPI CoTaskMemAlloc(SIZE_T size)
Definition: ifs.c:426
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
Definition: glext.h:7005
HRESULT STDMETHODCALLTYPE PutMulticastList(ULONG ulcbAddresses, BYTE *pAddressList)
Definition: ipv4.cpp:96