ReactOS  0.4.14-dev-583-g2a1ba2c
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 ) {
16  return TDI_ADDRESS_LENGTH_IP;
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 
217 NTSTATUS
222 
223  _SEH2_TRY {
224  RtlCopyMemory( ConnectionInfo->RemoteAddress,
225  Address,
226  ConnectionInfo->RemoteAddressLength );
229  } _SEH2_END;
230 
231  return Status;
232 }
233 
234 
235 NTSTATUS
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 }
UINT TaLengthOfTransportAddress(PTRANSPORT_ADDRESS Addr)
Definition: tdiconn.c:46
UINT TaLengthOfTransportAddressByType(UINT AddressType)
Definition: tdiconn.c:60
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
PTRANSPORT_ADDRESS TaBuildNullTransportAddress(UINT AddressType)
Definition: tdiconn.c:113
#define MID_TRACE
Definition: debug.h:15
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
NTSTATUS TdiBuildNullConnectionInfoInPlace(PTDI_CONNECTION_INFORMATION ConnInfo, ULONG Type)
Definition: tdiconn.c:137
Type
Definition: Type.h:6
#define DbgPrint
Definition: loader.c:25
#define TAG_AFD_TDI_CONNECTION_INFORMATION
Definition: afd.h:53
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define TDI_ADDRESS_TYPE_IPX
Definition: tdi.h:350
LONG NTSTATUS
Definition: precomp.h:26
#define TAG_AFD_TRANSPORT_ADDRESS
Definition: afd.h:39
NTSTATUS TdiBuildNullTransportAddressInPlace(PTRANSPORT_ADDRESS A, UINT AddressType)
Definition: tdiconn.c:98
#define TDI_ADDRESS_LENGTH_IPX
Definition: tdi.h:421
_SEH2_TRY
Definition: create.c:4250
#define A(row, col)
#define TDI_ADDRESS_TYPE_NETBIOS
Definition: tdi.h:361
#define AFD_DbgPrint(_t_, _x_)
Definition: debug.h:60
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
smooth NULL
Definition: ftsmooth.c:416
#define TDI_ADDRESS_LENGTH_VNS
Definition: tdi.h:486
static WCHAR Address[46]
Definition: ping.c:68
UINT TdiAddressSizeFromType(UINT AddressType)
Definition: tdiconn.c:13
#define TDI_ADDRESS_TYPE_APPLETALK
Definition: tdi.h:360
struct _TRANSPORT_ADDRESS * PTRANSPORT_ADDRESS
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
UINT TaLengthOfAddress(PTA_ADDRESS Addr)
Definition: tdiconn.c:32
#define TDI_ADDRESS_LENGTH_NETBIOS
Definition: tdi.h:434
#define TDI_ADDRESS_LENGTH_APPLETALK
Definition: tdi.h:405
struct _TDI_CONNECTION_INFORMATION * PTDI_CONNECTION_INFORMATION
_Must_inspect_result_ typedef _In_ ULONG _In_ BOOLEAN Target
Definition: iotypes.h:1068
NTSTATUS TdiBuildConnectionInfo(PTDI_CONNECTION_INFORMATION *ConnectionInfo, PTRANSPORT_ADDRESS Address)
Definition: tdiconn.c:237
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
NTSTATUS TdiBuildConnectionInfoInPlace(PTDI_CONNECTION_INFORMATION ConnectionInfo, PTRANSPORT_ADDRESS Address)
Definition: tdiconn.c:219
Definition: ttei1.cpp:12
#define TDI_ADDRESS_TYPE_IP
Definition: tdi.h:345
Status
Definition: gdiplustypes.h:24
TA_ADDRESS Address[1]
Definition: tdi.h:377
_SEH2_END
Definition: create.c:4424
VOID TaCopyTransportAddressInPlace(PTRANSPORT_ADDRESS Target, PTRANSPORT_ADDRESS Source)
Definition: tdiconn.c:74
unsigned short USHORT
Definition: pedump.c:61
unsigned int UINT
Definition: ndis.h:50
#define TDI_ADDRESS_TYPE_VNS
Definition: tdi.h:365
USHORT AddressLength
Definition: tdi.h:338
unsigned int ULONG
Definition: retypes.h:1
PTRANSPORT_ADDRESS TaCopyTransportAddress(PTRANSPORT_ADDRESS OtherAddress)
Definition: tdiconn.c:80
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
#define MIN_TRACE
Definition: debug.h:14
_In_ UINT _In_ UINT _In_ PNDIS_PACKET Source
Definition: ndis.h:3167
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:12
#define TDI_ADDRESS_LENGTH_IP
Definition: tdi.h:413
return STATUS_SUCCESS
Definition: btrfs.c:2938
NTSTATUS TdiBuildNullConnectionInfo(PTDI_CONNECTION_INFORMATION *ConnectionInfo, ULONG Type)
Definition: tdiconn.c:171