ReactOS 0.4.15-dev-7674-gc0b4db1
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/afd/afd/tdiconn.c
5 * PURPOSE: Ancillary functions driver
6 * PROGRAMMER: Art Yerkes (ayerkes@speakeasy.net)
7 * UPDATE HISTORY:
8 * 20040708 Created
9 */
10
11#include <afd.h>
12
14 switch( AddressType ) {
21 /* case TDI_ADDRESS_TYPE_NS: */
26 default:
27 DbgPrint("TdiAddressSizeFromType - invalid type: %x\n", AddressType);
28 return 0;
29 }
30}
31
33{
34 UINT AddrLen = Addr->AddressLength;
35
36 if (!AddrLen)
37 return 0;
38
39 AddrLen += 2 * sizeof( USHORT );
40
41 AFD_DbgPrint(MID_TRACE,("AddrLen %x\n", AddrLen));
42
43 return AddrLen;
44}
45
47{
48 UINT AddrLen = TaLengthOfAddress(&Addr->Address[0]);
49
50 if (!AddrLen)
51 return 0;
52
53 AddrLen += sizeof(ULONG);
54
55 AFD_DbgPrint(MID_TRACE,("AddrLen %x\n", AddrLen));
56
57 return AddrLen;
58}
59
61{
62 UINT AddrLen = TdiAddressSizeFromType(AddressType);
63
64 if (!AddrLen)
65 return 0;
66
67 AddrLen += sizeof(ULONG) + 2 * sizeof(USHORT);
68
69 AFD_DbgPrint(MID_TRACE,("AddrLen %x\n", AddrLen));
70
71 return AddrLen;
72}
73
77 RtlCopyMemory( Target, Source, AddrLen );
78}
79
81 UINT AddrLen;
83
84 AddrLen = TaLengthOfTransportAddress( OtherAddress );
85 if (!AddrLen)
86 return NULL;
87
89 AddrLen,
91
92 if( A )
93 TaCopyTransportAddressInPlace( A, OtherAddress );
94
95 return A;
96}
97
99{
100 A->TAAddressCount = 1;
101
102 A->Address[0].AddressLength = TdiAddressSizeFromType(AddressType);
103 if (!A->Address[0].AddressLength)
105
106 A->Address[0].AddressType = AddressType;
107
108 RtlZeroMemory(A->Address[0].Address, A->Address[0].AddressLength);
109
110 return STATUS_SUCCESS;
111}
112
114{
115 UINT AddrLen;
117
118 AddrLen = TaLengthOfTransportAddressByType(AddressType);
119 if (!AddrLen)
120 return NULL;
121
123
124 if (A)
125 {
127 {
129 return NULL;
130 }
131 }
132
133 return A;
134}
135
138 ULONG Type )
139/*
140 * FUNCTION: Builds a NULL TDI connection information structure
141 * ARGUMENTS:
142 * ConnectionInfo = Address of buffer to place connection information
143 * Type = TDI style address type (TDI_ADDRESS_TYPE_XXX).
144 * RETURNS:
145 * Status of operation
146 */
147{
148 ULONG TdiAddressSize;
149 PTRANSPORT_ADDRESS TransportAddress;
150
151 TdiAddressSize = TaLengthOfTransportAddressByType(Type);
152 if (!TdiAddressSize)
153 {
154 AFD_DbgPrint(MIN_TRACE,("Invalid parameter\n"));
156 }
157
158 RtlZeroMemory(ConnInfo,
160 TdiAddressSize);
161
162 ConnInfo->OptionsLength = sizeof(ULONG);
163 ConnInfo->RemoteAddressLength = TdiAddressSize;
164 ConnInfo->RemoteAddress = TransportAddress =
165 (PTRANSPORT_ADDRESS)&ConnInfo[1];
166
167 return TdiBuildNullTransportAddressInPlace(TransportAddress, Type);
168}
169
171( PTDI_CONNECTION_INFORMATION *ConnectionInfo,
172 ULONG Type )
173/*
174 * FUNCTION: Builds a NULL TDI connection information structure
175 * ARGUMENTS:
176 * ConnectionInfo = Address of buffer pointer to allocate connection
177 * information in
178 * Type = TDI style address type (TDI_ADDRESS_TYPE_XXX).
179 * RETURNS:
180 * Status of operation
181 */
182{
184 ULONG TdiAddressSize;
186
187 TdiAddressSize = TaLengthOfTransportAddressByType(Type);
188 if (!TdiAddressSize) {
189 AFD_DbgPrint(MIN_TRACE,("Invalid parameter\n"));
190 *ConnectionInfo = NULL;
192 }
193
194 ConnInfo = (PTDI_CONNECTION_INFORMATION)
196 sizeof(TDI_CONNECTION_INFORMATION) + TdiAddressSize,
198 if (!ConnInfo) {
199 *ConnectionInfo = NULL;
201 }
202
204
205 if (!NT_SUCCESS(Status))
206 {
208 ConnInfo = NULL;
209 }
210
211 *ConnectionInfo = ConnInfo;
212
213 return Status;
214}
215
216
219( PTDI_CONNECTION_INFORMATION ConnectionInfo,
222
223 _SEH2_TRY {
224 RtlCopyMemory( ConnectionInfo->RemoteAddress,
225 Address,
226 ConnectionInfo->RemoteAddressLength );
229 } _SEH2_END;
230
231 return Status;
232}
233
234
237( PTDI_CONNECTION_INFORMATION *ConnectionInfo,
240 ( ConnectionInfo, Address->Address[0].AddressType );
241
242 if( NT_SUCCESS(Status) )
243 TdiBuildConnectionInfoInPlace( *ConnectionInfo, Address );
244
245 return Status;
246}
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
#define MIN_TRACE
Definition: debug.h:14
#define MID_TRACE
Definition: debug.h:15
Definition: ehthrow.cxx:93
#define NULL
Definition: types.h:112
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define A(row, col)
#define AFD_DbgPrint(_t_, _x_)
Definition: debug.h:60
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define NonPagedPool
Definition: env_spec_w32.h:307
#define _SEH2_END
Definition: filesup.c:22
#define _SEH2_TRY
Definition: filesup.c:19
Status
Definition: gdiplustypes.h:25
#define DbgPrint
Definition: hal.h:12
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
#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:159
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:34
#define STATUS_SUCCESS
Definition: shellext.h:65
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)
Definition: tdiconn.c:171
UINT TdiAddressSizeFromType(UINT AddressType)
Definition: tdiconn.c:13
NTSTATUS TdiBuildConnectionInfoInPlace(PTDI_CONNECTION_INFORMATION ConnectionInfo, PTRANSPORT_ADDRESS Address)
Definition: tdiconn.c:219
UINT TaLengthOfTransportAddress(PTRANSPORT_ADDRESS Addr)
Definition: tdiconn.c:46
UINT TaLengthOfTransportAddressByType(UINT AddressType)
Definition: tdiconn.c:60
VOID TaCopyTransportAddressInPlace(PTRANSPORT_ADDRESS Target, PTRANSPORT_ADDRESS Source)
Definition: tdiconn.c:74
NTSTATUS TdiBuildNullConnectionInfoInPlace(PTDI_CONNECTION_INFORMATION ConnInfo, ULONG Type)
Definition: tdiconn.c:137
NTSTATUS TdiBuildConnectionInfo(PTDI_CONNECTION_INFORMATION *ConnectionInfo, PTRANSPORT_ADDRESS Address)
Definition: tdiconn.c:237
NTSTATUS TdiBuildNullTransportAddressInPlace(PTRANSPORT_ADDRESS A, UINT AddressType)
Definition: tdiconn.c:98
PTRANSPORT_ADDRESS TaBuildNullTransportAddress(UINT AddressType)
Definition: tdiconn.c:113
UINT TaLengthOfAddress(PTA_ADDRESS Addr)
Definition: tdiconn.c:32
PTRANSPORT_ADDRESS TaCopyTransportAddress(PTRANSPORT_ADDRESS OtherAddress)
Definition: tdiconn.c:80
#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