ReactOS 0.4.16-dev-1946-g52006dd
tdiconn.c
Go to the documentation of this file.
1/*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS kernel
4 * FILE: drivers/net/tdihelpers/tdiconn.c
5 * PURPOSE: Ancillary functions driver
6 * PROGRAMMER: Art Yerkes (ayerkes@speakeasy.net)
7 * UPDATE HISTORY:
8 * 20040708 Created
9 * 20251021 Moved to tdihelpers since it is used by 2 drivers (AFD, NETIO) now
10 */
11
12#include <afd.h>
13
14#ifdef UNIMPLEMENTED
15#undef UNIMPLEMENTED
16#endif
17
18/* If you want to see the DPRINT() output in your debugger,
19 * remove the following line (or comment it out) */
20#define NDEBUG
21#include <reactos/debug.h>
22
24 switch( AddressType ) {
31 /* case TDI_ADDRESS_TYPE_NS: */
36 default:
37 DbgPrint("TdiAddressSizeFromType - invalid type: %x\n", AddressType);
38 return 0;
39 }
40}
41
43{
44 UINT AddrLen = Addr->AddressLength;
45
46 if (!AddrLen)
47 return 0;
48
49 AddrLen += 2 * sizeof( USHORT );
50
51 DPRINT("AddrLen %x\n", AddrLen);
52
53 return AddrLen;
54}
55
57{
58 UINT AddrLen = TaLengthOfAddress(&Addr->Address[0]);
59
60 if (!AddrLen)
61 return 0;
62
63 AddrLen += sizeof(ULONG);
64
65 DPRINT("AddrLen %x\n", AddrLen);
66
67 return AddrLen;
68}
69
71{
72 UINT AddrLen = TdiAddressSizeFromType(AddressType);
73
74 if (!AddrLen)
75 return 0;
76
77 AddrLen += sizeof(ULONG) + 2 * sizeof(USHORT);
78
79 DPRINT("AddrLen %x\n", AddrLen);
80
81 return AddrLen;
82}
83
87 RtlCopyMemory( Target, Source, AddrLen );
88}
89
91 UINT AddrLen;
93
94 AddrLen = TaLengthOfTransportAddress( OtherAddress );
95 if (!AddrLen)
96 return NULL;
97
99 AddrLen,
101
102 if( A )
103 TaCopyTransportAddressInPlace( A, OtherAddress );
104
105 return A;
106}
107
109{
110 A->TAAddressCount = 1;
111
112 A->Address[0].AddressLength = TdiAddressSizeFromType(AddressType);
113 if (!A->Address[0].AddressLength)
115
116 A->Address[0].AddressType = AddressType;
117
118 RtlZeroMemory(A->Address[0].Address, A->Address[0].AddressLength);
119
120 return STATUS_SUCCESS;
121}
122
124{
125 UINT AddrLen;
127
128 AddrLen = TaLengthOfTransportAddressByType(AddressType);
129 if (!AddrLen)
130 return NULL;
131
133
134 if (A)
135 {
137 {
139 return NULL;
140 }
141 }
142
143 return A;
144}
145
148 ULONG Type )
157{
158 ULONG TdiAddressSize;
159 PTRANSPORT_ADDRESS TransportAddress;
160
161 TdiAddressSize = TaLengthOfTransportAddressByType(Type);
162 if (!TdiAddressSize)
163 {
164 DPRINT("Invalid parameter\n");
166 }
167
168 RtlZeroMemory(ConnInfo,
170 TdiAddressSize);
171
172 ConnInfo->OptionsLength = sizeof(ULONG);
173 ConnInfo->RemoteAddressLength = TdiAddressSize;
174 ConnInfo->RemoteAddress = TransportAddress =
175 (PTRANSPORT_ADDRESS)&ConnInfo[1];
176
177 return TdiBuildNullTransportAddressInPlace(TransportAddress, Type);
178}
179
181( PTDI_CONNECTION_INFORMATION *ConnectionInfo,
182 ULONG Type )
192{
194 ULONG TdiAddressSize;
196
197 TdiAddressSize = TaLengthOfTransportAddressByType(Type);
198 if (!TdiAddressSize) {
199 DPRINT("Invalid parameter\n");
200 *ConnectionInfo = NULL;
202 }
203
204 ConnInfo = (PTDI_CONNECTION_INFORMATION)
206 sizeof(TDI_CONNECTION_INFORMATION) + TdiAddressSize,
208 if (!ConnInfo) {
209 *ConnectionInfo = NULL;
211 }
212
214
215 if (!NT_SUCCESS(Status))
216 {
218 ConnInfo = NULL;
219 }
220
221 *ConnectionInfo = ConnInfo;
222
223 return Status;
224}
225
226
229( PTDI_CONNECTION_INFORMATION ConnectionInfo,
232
233 _SEH2_TRY {
234 RtlCopyMemory( ConnectionInfo->RemoteAddress,
235 Address,
236 ConnectionInfo->RemoteAddressLength );
239 } _SEH2_END;
240
241 return Status;
242}
243
244
247( PTDI_CONNECTION_INFORMATION *ConnectionInfo,
250 ( ConnectionInfo, Address->Address[0].AddressType );
251
252 if( NT_SUCCESS(Status) )
253 TdiBuildConnectionInfoInPlace( *ConnectionInfo, Address );
254
255 return Status;
256}
Type
Definition: Type.h:7
#define TAG_AFD_TDI_CONNECTION_INFORMATION
Definition: afd.h:53
#define TAG_AFD_TRANSPORT_ADDRESS
Definition: afd.h:39
LONG NTSTATUS
Definition: precomp.h:26
Definition: ehthrow.cxx:93
#define NULL
Definition: types.h:112
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
#define A(row, col)
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define NonPagedPool
Definition: env_spec_w32.h:307
Status
Definition: gdiplustypes.h:25
#define DbgPrint
Definition: hal.h:12
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:90
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1109
unsigned int UINT
Definition: ndis.h:50
_In_ UINT _In_ UINT _In_ PNDIS_PACKET Source
Definition: ndis.h:3169
unsigned short USHORT
Definition: pedump.c:61
static WCHAR Address[46]
Definition: ping.c:68
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:181
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:82
#define _SEH2_END
Definition: pseh2_64.h:171
#define _SEH2_TRY
Definition: pseh2_64.h:71
#define STATUS_SUCCESS
Definition: shellext.h:65
#define DPRINT
Definition: sndvol32.h:73
USHORT AddressLength
Definition: tdi.h:338
TA_ADDRESS Address[1]
Definition: tdi.h:377
struct _TDI_CONNECTION_INFORMATION * PTDI_CONNECTION_INFORMATION
#define TDI_ADDRESS_LENGTH_VNS
Definition: tdi.h:486
#define TDI_ADDRESS_TYPE_VNS
Definition: tdi.h:365
struct _TRANSPORT_ADDRESS * PTRANSPORT_ADDRESS
#define TDI_ADDRESS_LENGTH_APPLETALK
Definition: tdi.h:405
#define TDI_ADDRESS_LENGTH_IPX
Definition: tdi.h:421
#define TDI_ADDRESS_TYPE_NETBIOS
Definition: tdi.h:361
#define TDI_ADDRESS_LENGTH_IP
Definition: tdi.h:413
#define TDI_ADDRESS_TYPE_IPX
Definition: tdi.h:350
#define TDI_ADDRESS_TYPE_IP
Definition: tdi.h:345
#define TDI_ADDRESS_TYPE_APPLETALK
Definition: tdi.h:360
#define TDI_ADDRESS_LENGTH_NETBIOS
Definition: tdi.h:434
NTSTATUS TdiBuildNullConnectionInfo(PTDI_CONNECTION_INFORMATION *ConnectionInfo, ULONG Type)
Builds a NULL TDI connection information structure.
Definition: tdiconn.c:181
UINT TdiAddressSizeFromType(UINT AddressType)
Definition: tdiconn.c:23
NTSTATUS TdiBuildConnectionInfoInPlace(PTDI_CONNECTION_INFORMATION ConnectionInfo, PTRANSPORT_ADDRESS Address)
Definition: tdiconn.c:229
UINT TaLengthOfTransportAddress(PTRANSPORT_ADDRESS Addr)
Definition: tdiconn.c:56
UINT TaLengthOfTransportAddressByType(UINT AddressType)
Definition: tdiconn.c:70
VOID TaCopyTransportAddressInPlace(PTRANSPORT_ADDRESS Target, PTRANSPORT_ADDRESS Source)
Definition: tdiconn.c:84
NTSTATUS TdiBuildNullConnectionInfoInPlace(PTDI_CONNECTION_INFORMATION ConnInfo, ULONG Type)
Builds a NULL TDI connection information structure.
Definition: tdiconn.c:147
NTSTATUS TdiBuildConnectionInfo(PTDI_CONNECTION_INFORMATION *ConnectionInfo, PTRANSPORT_ADDRESS Address)
Definition: tdiconn.c:247
NTSTATUS TdiBuildNullTransportAddressInPlace(PTRANSPORT_ADDRESS A, UINT AddressType)
Definition: tdiconn.c:108
PTRANSPORT_ADDRESS TaBuildNullTransportAddress(UINT AddressType)
Definition: tdiconn.c:123
UINT TaLengthOfAddress(PTA_ADDRESS Addr)
Definition: tdiconn.c:42
PTRANSPORT_ADDRESS TaCopyTransportAddress(PTRANSPORT_ADDRESS OtherAddress)
Definition: tdiconn.c:90
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
uint32_t ULONG
Definition: typedefs.h:59
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_In_ WDFIOTARGET Target
Definition: wdfrequest.h:306