Hi All

I am writing a NDIS intermediate filter driver, to analyse the network
traffic. I need to know what is the type of the packet which i received
from ProtocolRecieve() & ProtocolRecievePacket() callback routines i.e.
whether the packet is of UDP or TCP etc.??

In case anybody knows about this then please let me know.

Thanks in advance

Saurav

Re: what is NDIS packet type by soviet_bloke

soviet_bloke
Mon Dec 25 10:57:19 CST 2006

As far as anyone below TCPIP.SYS on the stack is concerned, there is no
distinction between TCP and UDP packets - this distinction is made only
by TCPIP.SYS and its clients. ProtocolRecieve() &
ProtocolRecievePacket() that are implemented by your IM driver deal not
with IP packets but with respectively lookahead buffer and NDIS_PACKET
that store the IP packet (or, in former case, at least its headers).
Therefore, you have to analyze this buffer or NDIS_PACKET in
ProtocolRecieve() or ProtocolRecievePacket() callbacks, so that you can
interpret IP packet's header

Anton Bassov

Saurav wrote:
> Hi All
>
> I am writing a NDIS intermediate filter driver, to analyse the network
> traffic. I need to know what is the type of the packet which i received
> from ProtocolRecieve() & ProtocolRecievePacket() callback routines i.e.
> whether the packet is of UDP or TCP etc.??
>
> In case anybody knows about this then please let me know.
>
> Thanks in advance
>
> Saurav


Re: what is NDIS packet type by Thomas

Thomas
Mon Dec 25 13:16:13 CST 2006

The articles "Extending the PassThru NDIS IM Driver..." illustrates simple
inspection of packets. There are three parts to the article, with the first
two in the "Archives" section at wd-3.com. See:

http://www.wd-3.com

Thomas F. Divine

<soviet_bloke@hotmail.com> wrote in message
news:1167065839.240627.205240@i12g2000cwa.googlegroups.com...
> As far as anyone below TCPIP.SYS on the stack is concerned, there is no
> distinction between TCP and UDP packets - this distinction is made only
> by TCPIP.SYS and its clients. ProtocolRecieve() &
> ProtocolRecievePacket() that are implemented by your IM driver deal not
> with IP packets but with respectively lookahead buffer and NDIS_PACKET
> that store the IP packet (or, in former case, at least its headers).
> Therefore, you have to analyze this buffer or NDIS_PACKET in
> ProtocolRecieve() or ProtocolRecievePacket() callbacks, so that you can
> interpret IP packet's header
>
> Anton Bassov
>
> Saurav wrote:
>> Hi All
>>
>> I am writing a NDIS intermediate filter driver, to analyse the network
>> traffic. I need to know what is the type of the packet which i received
>> from ProtocolRecieve() & ProtocolRecievePacket() callback routines i.e.
>> whether the packet is of UDP or TCP etc.??
>>
>> In case anybody knows about this then please let me know.
>>
>> Thanks in advance
>>
>> Saurav
>


Re: what is NDIS packet type by soviet_bloke

soviet_bloke
Mon Dec 25 14:43:49 CST 2006

Thomas,

Certainly, I read your articles - you did really a good job, as you
always do. Hopefully, the OP will find them of great help - if I got
his question right, for the time being he believes that one can tell
TCP packets from UDP ones without packet inspection, i.e. purely from
context in which his callbacks are invoked. Therefore, I told him that
he has to get this info himself from lookahead buffer of from
NDIS_PACKET that gets passed to his callback - there is no other way to
do it at the level below TCPIP.SYS, because IM in itself is not
concerned about the details of high-level protocols, unless you program
it to do so....


Anton Bassov

Thomas F. Divine wrote:
> The articles "Extending the PassThru NDIS IM Driver..." illustrates simple
> inspection of packets. There are three parts to the article, with the first
> two in the "Archives" section at wd-3.com. See:
>
> http://www.wd-3.com
>
> Thomas F. Divine
>
> <soviet_bloke@hotmail.com> wrote in message
> news:1167065839.240627.205240@i12g2000cwa.googlegroups.com...
> > As far as anyone below TCPIP.SYS on the stack is concerned, there is no
> > distinction between TCP and UDP packets - this distinction is made only
> > by TCPIP.SYS and its clients. ProtocolRecieve() &
> > ProtocolRecievePacket() that are implemented by your IM driver deal not
> > with IP packets but with respectively lookahead buffer and NDIS_PACKET
> > that store the IP packet (or, in former case, at least its headers).
> > Therefore, you have to analyze this buffer or NDIS_PACKET in
> > ProtocolRecieve() or ProtocolRecievePacket() callbacks, so that you can
> > interpret IP packet's header
> >
> > Anton Bassov
> >
> > Saurav wrote:
> >> Hi All
> >>
> >> I am writing a NDIS intermediate filter driver, to analyse the network
> >> traffic. I need to know what is the type of the packet which i received
> >> from ProtocolRecieve() & ProtocolRecievePacket() callback routines i.e.
> >> whether the packet is of UDP or TCP etc.??
> >>
> >> In case anybody knows about this then please let me know.
> >>
> >> Thanks in advance
> >>
> >> Saurav
> >


Re: what is NDIS packet type by Stephan

Stephan
Tue Jan 02 05:11:32 CST 2007

NDIS does not know anything about packet types. Strictly speaking, NDIS
handles (raw) frames rather than packets as a packet is what you find
behind the MAC header.

Determination of the "packet type" takes several steps:

Check the "type code / length" field in the MAC header. Note that all
network fields are in high-low (big endian) order. If the type/length
is greater than 1500 decimal (5DC hex), then this is an Ethernet type
code, see

http://standards.ieee.org/regauth/ethertype/eth.txt

Otherwise, if the type/length is smaller than 1500 decimal, then this
is the length of the payload data behind the MAC header. In this case,
what follows directly behind the MAC header is a three byte 802.2
Logical Link Control (LLC) header consisting of the destination service
access point (DSAP), source SAP (SSAP), and Control fields, see

http://standards.ieee.org/regauth/llc/llcassignments.pdf

If DSAP=SSAP=0xAA and Control=0x03, then what follows next is a five
byte 802.2 SNAP header: 3 bytes OUI (=vendor id, see
http://standards.ieee.org/regauth/oui/index.shtml) and two bytes type
information.

If the OUI = 000000 then the type is an Ethernet type code as already
outlined above.

For more information, see e.g.

http://standards.ieee.org/regauth/publiclistings.html

Now IP uses Ethernet type code 0x0800. TCP, UDP, and others sit on top
of IP so they use the same type code (0x0800). You need to inspect the
IP header in order to determine which protocol follows. That's fpr
further study. See the various RFC documents or get yourself a good
book on network basics.

Stephan
---
Saurav wrote:
> Hi All
>
> I am writing a NDIS intermediate filter driver, to analyse the network
> traffic. I need to know what is the type of the packet which i received
> from ProtocolRecieve() & ProtocolRecievePacket() callback routines i.e.
> whether the packet is of UDP or TCP etc.??
>
> In case anybody knows about this then please let me know.
>
> Thanks in advance
>
> Saurav


Re: what is NDIS packet type by soviet_bloke

soviet_bloke
Tue Jan 02 17:25:11 CST 2007

Stephan,

> Check the "type code / length" field in the MAC header. Note that all
> network fields are in high-low (big endian) order. If the type/length
> is greater than 1500 decimal (5DC hex), then this is an Ethernet type
> code, see
>
> http://standards.ieee.org/regauth/ethertype/eth.txt
>
> Otherwise, if the type/length is smaller than 1500 decimal, then this
> is the length of the payload data behind the MAC header. In this case,
> what follows directly behind the MAC header is a three byte 802.2
> Logical Link Control (LLC) header consisting of the destination service
> access point (DSAP), source SAP (SSAP), and Control fields, see
>
> http://standards.ieee.org/regauth/llc/llcassignments.pdf
>
> If DSAP=SSAP=0xAA and Control=0x03, then what follows next is a five
> byte 802.2 SNAP header: 3 bytes OUI (=vendor id, see
> http://standards.ieee.org/regauth/oui/index.shtml) and two bytes type
> information.
>
> If the OUI = 000000 then the type is an Ethernet type code as already
> outlined above.

I am afraid all the stuff that you mentioned is just irrelevant for IP
packets that are indicated to NDIS IM - they have 14-byte MAC header
with 'Type' field set to 0x0800, which is immediately followed by IP
header and protocol header......



Anton Bassov



Stephan Wolf [MVP] wrote:
> NDIS does not know anything about packet types. Strictly speaking, NDIS
> handles (raw) frames rather than packets as a packet is what you find
> behind the MAC header.
>
> Determination of the "packet type" takes several steps:
>
> Check the "type code / length" field in the MAC header. Note that all
> network fields are in high-low (big endian) order. If the type/length
> is greater than 1500 decimal (5DC hex), then this is an Ethernet type
> code, see
>
> http://standards.ieee.org/regauth/ethertype/eth.txt
>
> Otherwise, if the type/length is smaller than 1500 decimal, then this
> is the length of the payload data behind the MAC header. In this case,
> what follows directly behind the MAC header is a three byte 802.2
> Logical Link Control (LLC) header consisting of the destination service
> access point (DSAP), source SAP (SSAP), and Control fields, see
>
> http://standards.ieee.org/regauth/llc/llcassignments.pdf
>
> If DSAP=SSAP=0xAA and Control=0x03, then what follows next is a five
> byte 802.2 SNAP header: 3 bytes OUI (=vendor id, see
> http://standards.ieee.org/regauth/oui/index.shtml) and two bytes type
> information.
>
> If the OUI = 000000 then the type is an Ethernet type code as already
> outlined above.
>
> For more information, see e.g.
>
> http://standards.ieee.org/regauth/publiclistings.html
>
> Now IP uses Ethernet type code 0x0800. TCP, UDP, and others sit on top
> of IP so they use the same type code (0x0800). You need to inspect the
> IP header in order to determine which protocol follows. That's fpr
> further study. See the various RFC documents or get yourself a good
> book on network basics.
>
> Stephan
> ---
> Saurav wrote:
> > Hi All
> >
> > I am writing a NDIS intermediate filter driver, to analyse the network
> > traffic. I need to know what is the type of the packet which i received
> > from ProtocolRecieve() & ProtocolRecievePacket() callback routines i.e.
> > whether the packet is of UDP or TCP etc.??
> >
> > In case anybody knows about this then please let me know.
> >
> > Thanks in advance
> >
> > Saurav


Re: what is NDIS packet type by Stephan

Stephan
Wed Jan 03 06:49:55 CST 2007

soviet_bloke@hotmail.com wrote:
> I am afraid all the stuff that you mentioned is just irrelevant

No, it is not all irrelevant. It is background information.

> for IP
> packets that are indicated to NDIS IM - they have 14-byte MAC header
> with 'Type' field set to 0x0800, which is immediately followed by IP
> header and protocol header......

And that's just what I also said. Plus that can be derived from "all
the stuff" that I mentioned.

Stephan