mirror of
https://github.com/reactos/reactos.git
synced 2025-04-20 20:36:35 +00:00
- Enable "Full Maps" by default
- IP addresses are now registry-configured, per-adapter - Minor bugfix for off-by-one with extended attributes svn path=/trunk/; revision=7105
This commit is contained in:
parent
fd2014a883
commit
0e8ef19002
10 changed files with 147 additions and 33 deletions
|
@ -716,7 +716,7 @@ NdisRegisterProtocol(
|
|||
InitializeListHead(&Protocol->AdapterListHead);
|
||||
|
||||
/*
|
||||
* bind the adapter to all of its miniports
|
||||
* bind the protocol to all of its miniports
|
||||
*
|
||||
* open registry path
|
||||
* get list of devices from Bind key
|
||||
|
|
|
@ -499,12 +499,13 @@ VOID ProtocolBindAdapter(
|
|||
* BindContext: Handle provided by NDIS to track pending binding operations
|
||||
* DeviceName: Name of the miniport device to bind to
|
||||
* SystemSpecific1: Pointer to a registry path with protocol-specific configuration information
|
||||
* SystemSpecific2: Unused
|
||||
* SystemSpecific2: Unused & must not be touched
|
||||
*/
|
||||
{
|
||||
/* XXX confirm that this is still true, or re-word the following comment */
|
||||
/* we get to ignore BindContext because we will never pend an operation with NDIS */
|
||||
TI_DbgPrint(DEBUG_DATALINK, ("Called.\n"));
|
||||
*Status = LANRegisterAdapter(DeviceName);
|
||||
TI_DbgPrint(DEBUG_DATALINK, ("Called with registry path %wZ\n", SystemSpecific1));
|
||||
*Status = LANRegisterAdapter(DeviceName, SystemSpecific1);
|
||||
}
|
||||
|
||||
|
||||
|
@ -591,7 +592,8 @@ VOID LANTransmit(
|
|||
|
||||
|
||||
VOID BindAdapter(
|
||||
PLAN_ADAPTER Adapter)
|
||||
PLAN_ADAPTER Adapter,
|
||||
PNDIS_STRING RegistryPath)
|
||||
/*
|
||||
* FUNCTION: Binds a LAN adapter to IP layer
|
||||
* ARGUMENTS:
|
||||
|
@ -653,16 +655,87 @@ VOID BindAdapter(
|
|||
return;
|
||||
}
|
||||
|
||||
/* FIXME: Get address from registry.
|
||||
For now just use a private address, eg. 10.0.0.100 */
|
||||
Address = AddrBuildIPv4(0x6400000A);
|
||||
// Address = AddrBuildIPv4(0x6048F2D1); // 209.242.72.96
|
||||
if (!Address) {
|
||||
TI_DbgPrint(MIN_TRACE, ("Insufficient resources.\n"));
|
||||
FreeTDPackets(Adapter);
|
||||
IPDestroyInterface(Adapter->Context);
|
||||
return;
|
||||
}
|
||||
{
|
||||
/*
|
||||
* Query per-adapter configuration from the registry
|
||||
* In case anyone is curious: there *is* an Ndis configuration api
|
||||
* for this sort of thing, but it doesn't really support things like
|
||||
* REG_MULTI_SZ very well, and there is a note in the DDK that says that
|
||||
* protocol drivers developed for win2k and above just use the native
|
||||
* services (ZwOpenKey, etc).
|
||||
*/
|
||||
|
||||
OBJECT_ATTRIBUTES Attributes;
|
||||
HANDLE RegHandle;
|
||||
NTSTATUS Status;
|
||||
UNICODE_STRING ValueName;
|
||||
UCHAR buf[1024];
|
||||
PKEY_VALUE_PARTIAL_INFORMATION Information = (PKEY_VALUE_PARTIAL_INFORMATION)buf;
|
||||
ULONG ResultLength;
|
||||
ANSI_STRING AnsiAddress;
|
||||
UNICODE_STRING UnicodeAddress;
|
||||
ULONG AnsiLen;
|
||||
|
||||
InitializeObjectAttributes(&Attributes, RegistryPath, OBJ_CASE_INSENSITIVE, 0, 0);
|
||||
Status = ZwOpenKey(&RegHandle, GENERIC_READ, &Attributes);
|
||||
|
||||
if(!NT_SUCCESS(Status))
|
||||
{
|
||||
TI_DbgPrint(MIN_TRACE, ("Unable to open protocol-specific registry key: 0x%x\n", Status));
|
||||
|
||||
/* XXX how do we proceed? No ip address, no parameters... do we guess? */
|
||||
FreeTDPackets(Adapter);
|
||||
IPDestroyInterface(Adapter->Context);
|
||||
return;
|
||||
}
|
||||
|
||||
RtlInitUnicodeString(&ValueName, L"IPAddress");
|
||||
ZwQueryValueKey(RegHandle, &ValueName, KeyValuePartialInformation, Information, sizeof(buf), &ResultLength);
|
||||
ZwClose(RegHandle);
|
||||
|
||||
/* IP address is stored as a REG_MULTI_SZ - we only pay attention to the first one though */
|
||||
TI_DbgPrint(MIN_TRACE, ("Information DataLength: 0x%x\n", Information->DataLength));
|
||||
|
||||
UnicodeAddress.Buffer = (PWCHAR)&Information->Data;
|
||||
UnicodeAddress.Length = Information->DataLength;
|
||||
UnicodeAddress.MaximumLength = Information->DataLength;
|
||||
|
||||
AnsiLen = RtlUnicodeStringToAnsiSize(&UnicodeAddress);
|
||||
|
||||
if(!AnsiLen)
|
||||
{
|
||||
TI_DbgPrint(MIN_TRACE, ("Unable to calculate address length\n"));
|
||||
FreeTDPackets(Adapter);
|
||||
IPDestroyInterface(Adapter->Context);
|
||||
return;
|
||||
}
|
||||
|
||||
AnsiAddress.Buffer = ExAllocatePoolWithTag(PagedPool, AnsiLen, 0x01020304);
|
||||
|
||||
if(!AnsiAddress.Buffer)
|
||||
{
|
||||
TI_DbgPrint(MIN_TRACE, ("Insufficient resources.\n"));
|
||||
FreeTDPackets(Adapter);
|
||||
IPDestroyInterface(Adapter->Context);
|
||||
return;
|
||||
}
|
||||
|
||||
RtlUnicodeStringToAnsiString(&AnsiAddress, &UnicodeAddress, FALSE);
|
||||
|
||||
AnsiAddress.Buffer[AnsiAddress.Length] = 0;
|
||||
|
||||
Address = AddrBuildIPv4(inet_addr(AnsiAddress.Buffer));
|
||||
|
||||
if (!Address) {
|
||||
TI_DbgPrint(MIN_TRACE, ("Insufficient resources.\n"));
|
||||
FreeTDPackets(Adapter);
|
||||
IPDestroyInterface(Adapter->Context);
|
||||
return;
|
||||
}
|
||||
|
||||
TI_DbgPrint(MID_TRACE, ("--> Our IP address on this interface: 0x%x\n", inet_addr(AnsiAddress.Buffer)));
|
||||
}
|
||||
|
||||
/* Create a net table entry for this interface */
|
||||
if (!IPCreateNTE(IF, Address, 8)) {
|
||||
TI_DbgPrint(MIN_TRACE, ("Insufficient resources.\n"));
|
||||
|
@ -721,7 +794,8 @@ VOID UnbindAdapter(
|
|||
|
||||
|
||||
NDIS_STATUS LANRegisterAdapter(
|
||||
PNDIS_STRING AdapterName)
|
||||
PNDIS_STRING AdapterName,
|
||||
PNDIS_STRING RegistryPath)
|
||||
/*
|
||||
* FUNCTION: Registers protocol with an NDIS adapter
|
||||
* ARGUMENTS:
|
||||
|
@ -734,6 +808,7 @@ NDIS_STATUS LANRegisterAdapter(
|
|||
PLAN_ADAPTER IF;
|
||||
NDIS_STATUS NdisStatus;
|
||||
NDIS_STATUS OpenStatus;
|
||||
PNDIS_CONFIGURATION_PARAMETER Parameter;
|
||||
UINT MediaIndex;
|
||||
NDIS_MEDIUM MediaArray[MAX_MEDIA];
|
||||
UINT AddressOID;
|
||||
|
@ -874,7 +949,7 @@ NDIS_STATUS LANRegisterAdapter(
|
|||
&AdapterListLock);
|
||||
|
||||
/* Bind adapter to IP layer */
|
||||
BindAdapter(IF);
|
||||
BindAdapter(IF, RegistryPath);
|
||||
|
||||
TI_DbgPrint(DEBUG_DATALINK, ("Leaving.\n"));
|
||||
|
||||
|
@ -952,7 +1027,7 @@ NTSTATUS LANRegisterProtocol(
|
|||
ProtChars.MinorNdisVersion = NDIS_VERSION_MINOR;
|
||||
ProtChars.Name.Length = Name->Length;
|
||||
ProtChars.Name.Buffer = Name->Buffer;
|
||||
ProtChars.Name.MaximumLength = Name->MaximumLength;
|
||||
ProtChars.Name.MaximumLength = Name->MaximumLength;
|
||||
ProtChars.OpenAdapterCompleteHandler = ProtocolOpenAdapterComplete;
|
||||
ProtChars.CloseAdapterCompleteHandler = ProtocolCloseAdapterComplete;
|
||||
ProtChars.ResetCompleteHandler = ProtocolResetComplete;
|
||||
|
@ -963,7 +1038,7 @@ NTSTATUS LANRegisterProtocol(
|
|||
ProtChars.ReceiveCompleteHandler = ProtocolReceiveComplete;
|
||||
ProtChars.StatusHandler = ProtocolStatus;
|
||||
ProtChars.StatusCompleteHandler = ProtocolStatusComplete;
|
||||
ProtChars.BindAdapterHandler = ProtocolBindAdapter;
|
||||
ProtChars.BindAdapterHandler = ProtocolBindAdapter;
|
||||
|
||||
/* Try to register protocol */
|
||||
NdisRegisterProtocol(&NdisStatus,
|
||||
|
|
|
@ -73,6 +73,9 @@ PADDRESS_FILE AddrSearchFirst(
|
|||
PADDRESS_FILE AddrSearchNext(
|
||||
PAF_SEARCH SearchContext);
|
||||
|
||||
ULONG inet_addr(
|
||||
PCSTR AddrString);
|
||||
|
||||
#endif /* __ADDRESS_H */
|
||||
|
||||
/* EOF */
|
||||
|
|
|
@ -81,7 +81,8 @@ typedef struct LAN_ADAPTER {
|
|||
|
||||
|
||||
NDIS_STATUS LANRegisterAdapter(
|
||||
PNDIS_STRING AdapterName);
|
||||
PNDIS_STRING AdapterName,
|
||||
PNDIS_STRING RegistryPath);
|
||||
|
||||
NDIS_STATUS LANUnregisterAdapter(
|
||||
PLAN_ADAPTER Adapter);
|
||||
|
|
|
@ -414,4 +414,43 @@ PADDRESS_FILE AddrSearchNext(
|
|||
return NULL;
|
||||
}
|
||||
|
||||
ULONG inet_addr(PCSTR AddrString)
|
||||
/*
|
||||
* Convert an ansi string dotted-quad address to a ulong
|
||||
* NOTES:
|
||||
* - this isn't quite like the real inet_addr() - * it doesn't
|
||||
* handle "10.1" and similar - but it's good enough.
|
||||
* - Returns in *host* byte order, unlike real inet_addr()
|
||||
*/
|
||||
{
|
||||
ULONG Octets[4] = {0,0,0,0};
|
||||
ULONG i = 0;
|
||||
|
||||
if(!AddrString)
|
||||
return -1;
|
||||
|
||||
while(*AddrString)
|
||||
{
|
||||
CHAR c = *AddrString;
|
||||
AddrString++;
|
||||
|
||||
if(c == '.')
|
||||
{
|
||||
i++;
|
||||
continue;
|
||||
}
|
||||
|
||||
if(c < '0' || c > '9')
|
||||
return -1;
|
||||
|
||||
Octets[i] *= 10;
|
||||
Octets[i] += (c - '0');
|
||||
|
||||
if(Octets[i] > 255)
|
||||
return -1;
|
||||
}
|
||||
|
||||
return (Octets[3] << 24) + (Octets[2] << 16) + (Octets[1] << 8) + Octets[0];
|
||||
}
|
||||
|
||||
/* EOF */
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
#include <rosrtl/string.h>
|
||||
|
||||
#ifdef DBG
|
||||
DWORD DebugTraceLevel = MIN_TRACE;
|
||||
DWORD DebugTraceLevel = -1;
|
||||
#endif /* DBG */
|
||||
|
||||
PDEVICE_OBJECT TCPDeviceObject = NULL;
|
||||
|
@ -190,8 +190,10 @@ CP
|
|||
TDI_TRANSPORT_ADDRESS_LENGTH) == TDI_TRANSPORT_ADDRESS_LENGTH)) {
|
||||
/* This is a request to open an address */
|
||||
CP
|
||||
|
||||
/* XXX This should probably be done in IoCreateFile() */
|
||||
/* Parameter checks */
|
||||
Address = (PTA_IP_ADDRESS)(EaInfo->EaName + EaInfo->EaNameLength);
|
||||
Address = (PTA_IP_ADDRESS)(EaInfo->EaName + EaInfo->EaNameLength + 1); //0-term
|
||||
if ((EaInfo->EaValueLength < sizeof(TA_IP_ADDRESS)) ||
|
||||
(Address->TAAddressCount != 1) ||
|
||||
(Address->Address[0].AddressLength < TDI_ADDRESS_LENGTH_IP) ||
|
||||
|
@ -389,9 +391,9 @@ NTSTATUS TiCleanupFileObject(
|
|||
|
||||
|
||||
NTSTATUS
|
||||
//#ifndef _MSC_VER
|
||||
#ifndef _MSC_VER
|
||||
STDCALL_FUNC
|
||||
//#endif
|
||||
#endif
|
||||
TiDispatchOpenClose(
|
||||
IN PDEVICE_OBJECT DeviceObject,
|
||||
IN PIRP Irp)
|
||||
|
|
|
@ -41,8 +41,6 @@ extern ULONG DebugTraceLevel;
|
|||
|
||||
#endif /* _MSC_VER */
|
||||
|
||||
/* in ndis.h now */
|
||||
#if 0
|
||||
#ifdef ASSERT
|
||||
#undef ASSERT
|
||||
#endif
|
||||
|
@ -52,7 +50,6 @@ extern ULONG DebugTraceLevel;
|
|||
#else /* NASSERT */
|
||||
#define ASSERT(x) if (!(x)) { TDI_DbgPrint(MIN_TRACE, ("Assertion "#x" failed at %s:%d\n", __FILE__, __LINE__)); KeBugCheck(0); }
|
||||
#endif /* NASSERT */
|
||||
#endif
|
||||
#define ASSERT_IRQL(x) ASSERT(KeGetCurrentIrql() <= (x))
|
||||
|
||||
#else /* DBG */
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# $Id: makefile,v 1.9 2003/11/20 06:31:51 vizzini Exp $
|
||||
# $Id: makefile,v 1.10 2003/12/17 23:34:35 vizzini Exp $
|
||||
|
||||
PATH_TO_TOP = ../../..
|
||||
|
||||
|
@ -6,7 +6,7 @@ TARGET_TYPE = driver
|
|||
|
||||
TARGET_NAME = tditest
|
||||
|
||||
TARGET_CFLAGS = -I./include -Wall -Werror
|
||||
TARGET_CFLAGS = -I./include -Wall -Werror -DDBG=1
|
||||
|
||||
TARGET_OBJECTS = \
|
||||
tditest/tditest.o
|
||||
|
|
|
@ -878,9 +878,6 @@ VOID TdiUnload(
|
|||
ObReferenceObjectByHandle(SendThread, THREAD_ALL_ACCESS, NULL, KernelMode, &SendThreadObject, NULL);
|
||||
ObReferenceObjectByHandle(ReceiveThread, THREAD_ALL_ACCESS, NULL, KernelMode, &ReceiveThreadObject, NULL);
|
||||
|
||||
ASSERT(ReceiveThreadObject);
|
||||
ASSERT(SendThreadObject);
|
||||
|
||||
KeSetEvent(&StopEvent, 0, FALSE);
|
||||
|
||||
/* Wait for send thread to stop */
|
||||
|
|
|
@ -9,7 +9,7 @@ HOST = mingw32-windows
|
|||
endif
|
||||
|
||||
# Build map files which includes source and asm code
|
||||
# FULL_MAP = yes
|
||||
FULL_MAP = yes
|
||||
|
||||
# Default to no PCH support
|
||||
ifeq ($(ROS_USE_PCH),)
|
||||
|
|
Loading…
Reference in a new issue