NDIS question

Hi, guys!

I have a simple question regarding NDIS drivers:
I have an intermediate driver, that gets an NDIS packet,
and sends it up to the transport layer (the ImSamp.sys example).

My question is: In this driver, when I have the NDIS_PACKET structures,
how can I access the data itself?

I read in the DDK that I must use NDIS functions for this,
and that I cannot just access the MDL…

I think that the data is in PNDIS_PACKET ->Private ->Head.
Am I right? If I do - which NDIS function retrieves it?

If I’m wrong - where is the data itself?

thanks in advance,

  • Barak Mandelovich

Barak Mandelovich xxxxx@mercury.co.il
Mercury Interactive ltd.

Barak -

The function NdisQueryPacket(…) will return an NDIS_BUFFER; you can then
use NdisQueryBuffer(…) to get to the data itself.

Ed

MidCore Software, Inc.
www.midcore.com

----- Original Message -----
From: “Barak Mandelovich”
To: “NT Developers Interest List”
Sent: Thursday, August 10, 2000 12:25 PM
Subject: [ntdev] NDIS question

> Hi, guys!
>
> I have a simple question regarding NDIS drivers:
> I have an intermediate driver, that gets an NDIS packet,
> and sends it up to the transport layer (the ImSamp.sys example).
>
> My question is: In this driver, when I have the NDIS_PACKET structures,
> how can I access the data itself?
>
> I read in the DDK that I must use NDIS functions for this,
> and that I cannot just access the MDL…
>
> I think that the data is in PNDIS_PACKET ->Private ->Head.
> Am I right? If I do - which NDIS function retrieves it?
>
> If I’m wrong - where is the data itself?
>
> thanks in advance,
>
> - Barak Mandelovich
>
>
> ------------------------------------------------------------------------
> Barak Mandelovich xxxxx@mercury.co.il
> Mercury Interactive ltd.
> ------------------------------------------------------------------------
>
>
> —
> You are currently subscribed to ntdev as: xxxxx@midcore.com
> To unsubscribe send a blank email to $subst(‘Email.Unsub’)
>

Barak -

You may also have to use NdisgetFirstBufferFromPacket(…) if the packet
descriptor maps multiple buffers. This method is (as documented in the DDK)
faster than calling NdisQueryPacket(…)

Ed

MidCore Software, Inc.
www.midcore.com

----- Original Message -----
From: “Barak Mandelovich”
To: “NT Developers Interest List”
Sent: Thursday, August 10, 2000 12:25 PM
Subject: [ntdev] NDIS question

> Hi, guys!
>
> I have a simple question regarding NDIS drivers:
> I have an intermediate driver, that gets an NDIS packet,
> and sends it up to the transport layer (the ImSamp.sys example).
>
> My question is: In this driver, when I have the NDIS_PACKET structures,
> how can I access the data itself?
>
> I read in the DDK that I must use NDIS functions for this,
> and that I cannot just access the MDL…
>
> I think that the data is in PNDIS_PACKET ->Private ->Head.
> Am I right? If I do - which NDIS function retrieves it?
>
> If I’m wrong - where is the data itself?
>
> thanks in advance,
>
> - Barak Mandelovich
>
>
> ------------------------------------------------------------------------
> Barak Mandelovich xxxxx@mercury.co.il
> Mercury Interactive ltd.
> ------------------------------------------------------------------------
>
>
> —
> You are currently subscribed to ntdev as: xxxxx@midcore.com
> To unsubscribe send a blank email to $subst(‘Email.Unsub’)
>

Each NDIS_PACKET is a “coathanger” structure that is used to make a linked
list (or “chain”) of NDIS_BUFFER structures. The chain may consist of only
one NDIS_BUFFER or it may contain more than one NDIS_BUFFER.

You can use NDIS functions such as NdisQueryPacket to find out the total
length of the packet data, how many NDIS_BUFFERS are chained to a
NDIS_PACKET, etc.

A NDIS_BUFFER or “memory descriptor” points to an array of bytes that
represent part (or possibly all, if there is only one chained NDIS_BUFFER)
of the Ethernet packet being sent or received.

You can get a pointer to the first NDIS_BUFFER chained to a NDIS_PACKET by
using the NdisQueryPacket function.

In the simplest case there would be only one NDIS_BUFFER chained to a
packet.

Use the NdisQueryBuffer function to get the VirtualAddress and Length of the
array of bytes that the NDIS_BUFFER points to. It is the VirtualAddress that
you actually can examine as if it was an ordinary character array.

In most cases the first NDIS_BUFFER will contain at least the first 12 bytes
of the 802.3 MAC header or the RFC 894 Ethernet header. In either
encapsulation, the first six bytes (0-5) will be the destination MAC address
and the next six bytes (6-11) should be the source MAC address (usually the
MAC address of the adapter that the packet is being sent on…).

So, the destination MAC address will be found in the first six bytes of the
VirtualAddress from the first NDIS_BUFFER chained to the NDIS_PACKET. TCP/IP
will have already filled these bytes with the destination MAC address at the
time your IM driver is called.

Examine as many of the DDK examples as you can, including MAC driver
samples, protocol driver samples, and possible event the TDI sample. See how
they manipulate NDIS_PACKET and NDIS_BUFFER structures.

Hope this helps a little,

Thomas F. Divine

PCAUSA - Toolkits & Resources For Network Software Developers
NDIS Protocol - NDIS Intermediate Driver - TDI Client - Windows 95
Redirector
http:

----- Original Message -----
From: Barak Mandelovich
To: NT Developers Interest List
Sent: Thursday, August 10, 2000 12:25 PM
Subject: [ntdev] NDIS question

> Hi, guys!
>
> I have a simple question regarding NDIS drivers:
> I have an intermediate driver, that gets an NDIS packet,
> and sends it up to the transport layer (the ImSamp.sys example).
>
> My question is: In this driver, when I have the NDIS_PACKET structures,
> how can I access the data itself?
>
> I read in the DDK that I must use NDIS functions for this,
> and that I cannot just access the MDL…
>
> I think that the data is in PNDIS_PACKET ->Private ->Head.
> Am I right? If I do - which NDIS function retrieves it?
>
> If I’m wrong - where is the data itself?
>
> thanks in advance,
>
> - Barak Mandelovich
>
>
> ------------------------------------------------------------------------
> Barak Mandelovich xxxxx@mercury.co.il
> Mercury Interactive ltd.
> ------------------------------------------------------------------------
>
>
> —
> You are currently subscribed to ntdev as: xxxxx@pcausa.com
> To unsubscribe send a blank email to $subst(‘Email.Unsub’)
></http:>

hi ,
The following are the sequence of calls needed to get the NIDS data from a NDIS PACKET.

1>NdisQueryPacket //This will give you the total packet length and the pointer to first buffer

2>NdisQueryBuffer //This will give you the pointer to actual data in buffer.

3>NdisGetNextBuffer //This will give you the pointer to next buffer in MDL.

Loop 2 and 3 till whole of the packet is collected in a seperate buffer.

Ajitabh

-----Original Message-----
From: Barak Mandelovich [SMTP:xxxxx@mercury.co.il]
Sent: Thursday, August 10, 2000 9:56 PM
To: NT Developers Interest List
Subject: [ntdev] NDIS question

Hi, guys!

I have a simple question regarding NDIS drivers:
I have an intermediate driver, that gets an NDIS packet,
and sends it up to the transport layer (the ImSamp.sys example).

My question is: In this driver, when I have the NDIS_PACKET structures,
how can I access the data itself?

I read in the DDK that I must use NDIS functions for this,
and that I cannot just access the MDL…

I think that the data is in PNDIS_PACKET ->Private ->Head.
Am I right? If I do - which NDIS function retrieves it?

If I’m wrong - where is the data itself?

thanks in advance,

  • Barak Mandelovich

Barak Mandelovich xxxxx@mercury.co.il
Mercury Interactive ltd.


You are currently subscribed to ntdev as: xxxxx@future.futsoft.com
To unsubscribe send a blank email to $subst(‘Email.Unsub’)