Bruce
Wed Jun 04 09:56:45 PDT 2008
When I saw Paul's reply yesterday, I decided to try it also. So I wrote some
code to output the results of GetAdapterInfo. Of course I cheated as I
always do and copied an example from MSDN.
I also was getting error code 232. I did some digging and debugging and
found that in your code (and similar in the MSDN code) that you are missing
something:
//Call GetAdaptersInfo to get the size of the buffer
ulOutBufLen = 0;
GetAdaptersInfo( NULL, &ulOutBufLen) ;
-- What happens here if ulOutBufLen is zero? I can tell you that, you get
error code 232.
-- So if you add an if condition:
if( ulOutBufLen != 0 )
{
//Now that we know the necessary buffer size, allocate the memory
pAdapterInfo = (IP_ADAPTER_INFO *) malloc( ulOutBufLen );
dwRetVal = GetAdaptersInfo( pAdapterInfo, &ulOutBufLen);
// removed the rest of the code for brevity
}
else
// handle no adapters found
I got lucky, I had intentionally created a Data Abort in my Ethernet driver,
so I know why I didn't have any adapters. But that is another story
(
http://geekswithblogs.net/BruceEitman/archive/2008/06/02/platform-builder-find-the-source-of-a-data-abort-an.aspx).
When I fixed my Ethernet driver, the error went away and I output the
information.
--
Bruce Eitman (eMVP)
Senior Engineer
Bruce.Eitman AT EuroTech DOT com
My BLOG
http://geekswithblogs.net/bruceeitman
EuroTech Inc.
www.EuroTech.com
"Paul G. Tobey [eMVP]" <p space tobey no spam AT no instrument no spam DOT
com> wrote in message news:e8m4awlxIHA.2068@TK2MSFTNGP05.phx.gbl...
> Did you look up the error? 232 does not seem like a reasonable value.
> You aren't using KITL over that Ethernet chip, are you? And you can ping
> the device from your desktop using the IP address of the DM9000 adapter?
> I can't recall the call ever failing for me, unless there's no network
> adapters...
>
> Paul T.
>
> "Raheem" <Raheem@discussions.microsoft.com> wrote in message
> news:E009E93B-20AB-4113-B117-1C74DED74521@microsoft.com...
>> Hi Paul,
>> Linker and IP header files are allright. I debug the code and
>> it is failing at line
>>
>> dwRetVal = GetAdaptersInfo( pAdapterInfo, &ulOutBufLen);
>>
>> dwRetVal value is 232 thats the error code I am getting. It should be
>> actaully zero.
>>
>> GetAdaptersInfo function is failing. Target device has PXA270 and DM9000
>> as
>> MAC and PHY chip.
>>
>> I do not have any idea why it is failing. Do you have any hint.
>>
>> Thanks
>>
>>
>> "Paul G. Tobey [eMVP]" wrote:
>>
>>> "Cannot be accessed" doesn't indicate a problem with the code. Run the
>>> code
>>> in the debugger, not by itself. You have no hope that the code will be
>>> 100%
>>> right the first time (I see one printing problem at first glance);
>>> you're
>>> going to need the debugger. You linked with iphlpapi.lib, yes? Does
>>> your
>>> OS include the IP Helper API? That's the only systemic problem I can
>>> think
>>> of that would prevent the code from running.
>>>
>>> Paul T.
>>>
>>> "Raheem" <Raheem@discussions.microsoft.com> wrote in message
>>> news:79835086-2BB4-4229-B729-279DAA202DDA@microsoft.com...
>>> > Hi Paul,
>>> > I added the code below to the .exe
>>> >
>>> > IP_ADAPTER_INFO *pAdapterInfo;
>>> > IP_ADAPTER_INFO *pAdapter;
>>> > DWORD ulOutBufLen;
>>> >
>>> > //Call GetAdaptersInfo to get the size of the buffer
>>> > ulOutBufLen = 0;
>>> > GetAdaptersInfo( NULL, &ulOutBufLen) ;
>>> >
>>> > //Now that we know the necessary buffer size, allocate the memory
>>> > pAdapterInfo = (IP_ADAPTER_INFO *) malloc( ulOutBufLen );
>>> >
>>> > dwRetVal = GetAdaptersInfo( pAdapterInfo, &ulOutBufLen);
>>> > if (dwRetVal != ERROR_SUCCESS) {
>>> > RETAILMSG(TRUE, (TEXT("Call to GetAdaptersInfo failed, error %d.\n"),
>>> > dwRetVal));
>>> > free (pAdapterInfo);
>>> > return;
>>> > }
>>> >
>>> > //Loop through the adapters and print info on each one.
>>> > pAdapter = pAdapterInfo;
>>> >
>>> > while (pAdapter) {
>>> > RETAILMSG(TRUE, (TEXT("\tAdapter Name: \t%s\n"),
>>> > pAdapter->AdapterName));
>>> > RETAILMSG(TRUE, (TEXT("\tAdapter Desc: \t%s\n"),
>>> > pAdapter->Description));
>>> > RETAILMSG(TRUE, (TEXT("\tAdapter Addr: \t%ld\n"),
>>> > pAdapter->Address));
>>> > RETAILMSG(TRUE, (TEXT("\tIP Address: \t%s\n"),
>>> > pAdapter->IpAddressList.IpAddress.String));
>>> > RETAILMSG(TRUE, (TEXT("\tIP Mask: \t%s\n"),
>>> > pAdapter->IpAddressList.IpMask.String));
>>> >
>>> > It compiled scessfully and I downloaded to traget device which has
>>> > PXA270.
>>> > When I double click to open the .exe file, I get message like "Cannot
>>> > be
>>> > accessed, Make sure that the file is currently not open"
>>> >
>>> > Any idea please ? I think i did it in the right with PB Help
>>> > "GetAdaptersInfo" but no sucess.
>>> >
>>> > Regards
>>> >
>>> >
>>> > "Paul G. Tobey [eMVP]" wrote:
>>> >
>>> >> Interesting how this works. I just wrote code to do this five
>>> >> minutes
>>> >> ago,
>>> >> again. Use GetAdaptersInfo() from the IP Helper API. The Address
>>> >> field
>>> >> contains the hardware address (Ethernet address, in most cases).
>>> >>
>>> >> Paul T.
>>> >>
>>> >> "Raheem" <Raheem@discussions.microsoft.com> wrote in message
>>> >> news:56E11092-9D84-46DC-A9EA-5F6131F92C33@microsoft.com...
>>> >> > Hi All,
>>> >> > I like to read and dipslay the MAC Address of the device.
>>> >> > I
>>> >> > search
>>> >> > on help and it shows that
>>> >> > typedef uchar NDIS_802_11_MAC_ADDRESS[6] contains the MAC address
>>> >> > but
>>> >> > when
>>> >> > i read it always returns Zero.
>>> >> >
>>> >> > Any help please.
>>> >> >
>>> >> > Thanks
>>> >> >
>>> >> >
>>> >>
>>> >>
>>> >>
>>>
>>>
>>>
>
>