ReactOS  0.4.15-dev-321-g2d9b385
ethernetfilter.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/ethernetfilter.cpp
5  * PURPOSE: IBDA_EthernetFilter interface
6  *
7  * PROGRAMMERS: Johannes Anderwald (johannes.anderwald@reactos.org)
8  */
9 #include "precomp.h"
10 
12 {
13 public:
15 
18 
19  //IBDA_EthernetFilter
21  HRESULT STDMETHODCALLTYPE PutMulticastList(ULONG ulcbAddresses, BYTE * pAddressList);
22  HRESULT STDMETHODCALLTYPE GetMulticastList(ULONG *pulcbAddresses, BYTE *pAddressList);
25 
26 
27  CEthernetFilter(IBDA_NetworkProvider * pNetworkProvider);
28  virtual ~CEthernetFilter();
29 
30 protected:
35 };
36 
38  IBDA_NetworkProvider * pNetworkProvider) : m_pNetworkProvider(pNetworkProvider),
39  m_ulcbAddresses(0),
40  m_pAddressList(0),
41  m_ulModeMask(0)
42 {
43 }
44 
46 {
47  if (m_pAddressList)
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_EthernetFilter
79 //
80 
81 HRESULT
84  ULONG ulcbAddresses,
85  BYTE * pAddressList)
86 {
87  if (!ulcbAddresses || !pAddressList)
88  return E_POINTER;
89 
90  if (m_pAddressList)
92 
93  m_pAddressList = (BYTE*)CoTaskMemAlloc(ulcbAddresses);
94  if (!m_pAddressList)
95  return E_OUTOFMEMORY;
96 
97  CopyMemory(m_pAddressList, pAddressList, ulcbAddresses);
98  m_ulcbAddresses = ulcbAddresses;
99  return NOERROR;
100 }
101 
102 HRESULT
105  ULONG *pulcbAddresses,
106  BYTE *pAddressList)
107 {
108  if (!pulcbAddresses || !pAddressList)
109  return E_POINTER;
110 
111  if (*pulcbAddresses < m_ulcbAddresses)
112  return E_OUTOFMEMORY;
113 
114  CopyMemory(pAddressList, m_pAddressList, m_ulcbAddresses);
115  *pulcbAddresses = m_ulcbAddresses;
116  return NOERROR;
117 }
118 
119 HRESULT
122  ULONG *pulcbAddresses)
123 {
124  if (!pulcbAddresses)
125  return E_POINTER;
126 
127  *pulcbAddresses = m_ulcbAddresses;
128  return NOERROR;
129 }
130 
131 HRESULT
134  ULONG ulModeMask)
135 {
136  m_ulModeMask = ulModeMask;
137  return NOERROR;
138 }
139 
140 HRESULT
143  ULONG *pulModeMask)
144 {
145  *pulModeMask = m_ulModeMask;
146  return NOERROR;
147 }
148 
149 HRESULT
150 WINAPI
152  IBDA_NetworkProvider * pNetworkProvider,
153  REFIID riid,
154  LPVOID * ppv)
155 {
156  CEthernetFilter * filter = new CEthernetFilter(pNetworkProvider);
157 
158  if (!filter)
159  return E_OUTOFMEMORY;
160 
161  if (FAILED(filter->QueryInterface(riid, ppv)))
162  {
163  /* not supported */
164  delete filter;
165  return E_NOINTERFACE;
166  }
167 
168  return NOERROR;
169 }
HRESULT STDMETHODCALLTYPE GetMulticastMode(ULONG *pulModeMask)
#define REFIID
Definition: guiddef.h:118
#define E_NOINTERFACE
Definition: winerror.h:2364
VOID WINAPI CoTaskMemFree(LPVOID ptr)
Definition: ifs.c:442
HRESULT STDMETHODCALLTYPE GetMulticastList(ULONG *pulcbAddresses, BYTE *pAddressList)
#define NOERROR
Definition: winerror.h:2354
REFIID riid
Definition: precomp.h:44
IBDA_NetworkProvider * m_pNetworkProvider
REFIID LPVOID * ppv
Definition: atlbase.h:39
HRESULT STDMETHODCALLTYPE PutMulticastList(ULONG ulcbAddresses, BYTE *pAddressList)
#define assert(x)
Definition: debug.h:53
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define STDMETHODIMP
Definition: basetyps.h:43
ULONG Release()
virtual ~CEthernetFilter()
IN PVOID IN PVOID IN USHORT IN USHORT IN PINTERFACE Interface
Definition: pci.h:361
LONG HRESULT
Definition: typedefs.h:78
#define WINAPI
Definition: msvc.h:6
#define CopyMemory
Definition: winbase.h:1646
#define STDMETHODCALLTYPE
Definition: bdasup.h:9
ULONG AddRef()
STDMETHODIMP QueryInterface(REFIID InterfaceId, PVOID *Interface)
HRESULT STDMETHODCALLTYPE PutMulticastMode(ULONG ulModeMask)
unsigned char BYTE
Definition: xxhash.c:193
HRESULT STDMETHODCALLTYPE GetMulticastListSize(ULONG *pulcbAddresses)
STDMETHODIMP_(ULONG) AddRef()
HRESULT QueryInterface([in] REFIID riid, [out, iid_is(riid)] void **ppvObject)
unsigned int ULONG
Definition: retypes.h:1
HRESULT WINAPI CEthernetFilter_fnConstructor(IBDA_NetworkProvider *pNetworkProvider, REFIID riid, LPVOID *ppv)
#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
CEthernetFilter(IBDA_NetworkProvider *pNetworkProvider)