Listening to PPP traffic over modem

Hello, fellow developers!

Remember the packet.sys sample from Microsoft,
the one that attaches to the MAC driver and can listen to
the traffic and send frames over the network?

I need to do the same, but for a modem. i.e.: I should attach
my driver to the modem driver, and send/receive packets
using it (thus, bypassing the system’s TCP/IP stack).

In other words - I want to build my own TCP/IP stack.

The problem is, that I don’t want to handle all kinds of
layer 2 protocols (ppp, slip, adsl(?), isdn-ppp etc.).

Is there a way for me to be attached to an upper-layer driver,
which is still under the TCP/IP stack?

Currently, I’m trying to attach to the NdisWan driver, and just
“snoop” the traffic - I want to print all packets sent.

However, when I try to make the packet.sys sample to attach
the NdisWan, it fails.

Any ideas? Any suggestions for places I can look at?
Does anybody know how the TCP/IP stack uses the NdisWan?

best regards,

  • Barak Mandelovich

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

On NT and Win 2000, I used a modified version of the IMSAMP driver provided
by Jim Mateer (it captures all TCP/IP traffic - TCP, UDP, ICMP, etc.), which
can be found here:

http://www.pcausa.com/resources/ndisimfaq.htm#PCAUSANDISIM

It works with RAS; the major changes (for supporting RAS/NdisWan adapters)
are in the .INF file and the medium reported by the driver in
MiniportInitialize must be NdisMedium802_3, rather than NdisMediumWan. You
might also have to disable IP Header Compression on the dial-up networking
entry for the modem, as well.

To get it work on Win 2K, you can install it using a modified version of the
filter sample in the network section of the Win 2K DDK; in the DriverEntry
function, when filling in the DriverObject->MajorFunction table, save the
original DriverObject’s IRP_MJ_PNP, IRP_MJ_POWER, and IRP_MJ_SYSTEM_CONTROL
handlers; you’ll want to place these in your DriverObject when calling
IoCreateDevice. I suppose this won’t be a true WDM driver, but it does work.

Ed

----- Original Message -----
From: Barak Mandelovich
To: NT Developers Interest List
Sent: Wednesday, August 02, 2000 11:07 AM
Subject: [ntdev] Listening to PPP traffic over modem

> Hello, fellow developers!
>
> Remember the packet.sys sample from Microsoft,
> the one that attaches to the MAC driver and can listen to
> the traffic and send frames over the network?
>
> I need to do the same, but for a modem. i.e.: I should attach
> my driver to the modem driver, and send/receive packets
> using it (thus, bypassing the system’s TCP/IP stack).
>
> In other words - I want to build my own TCP/IP stack.
>
> The problem is, that I don’t want to handle all kinds of
> layer 2 protocols (ppp, slip, adsl(?), isdn-ppp etc.).
>
> Is there a way for me to be attached to an upper-layer driver,
> which is still under the TCP/IP stack?
>
> Currently, I’m trying to attach to the NdisWan driver, and just
> “snoop” the traffic - I want to print all packets sent.
>
> However, when I try to make the packet.sys sample to attach
> the NdisWan, it fails.
>
> Any ideas? Any suggestions for places I can look at?
> Does anybody know how the TCP/IP stack uses the NdisWan?
>
>
> best regards,
>
> - 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’)
>

Hi!

Well, I really don’t want to use an intermediate driver,
since it’ll slow the entire machine down.

In addition, my driver will not work all the time, so
it’s a waste putting an IM driver that just passes
frames… Think of the overhead…

I want to put my driver above the layer 2 protocol,
regardless of its type. I want my stack to be able to
send IP datagrams without worrying about anything else.

If possible, I also don’t want to make the user reboot
his machine. I want to bind my driver dynamically,
but let’s leave it to later times.

If this is not possible - does anybody know why can’t
the packet.sys sample attach itself over the NdisWan driver?
The driver reports that it founds a MAC driver call NdisWan6, and
binds to it, but when I do a CreateFile(), it fails with error code 25
(SEEK_ERROR !!!). The PacketOpenAdapterComplete() then reports failure.

Note that in this stage, all I want to do is listen to the network…

Ideas?

regards,

  • Barak Mandelovich

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

-----Original Message-----
From: Ed Lau [mailto:xxxxx@midcore.com]
Sent: Wednesday, August 02, 2000 5:05 PM
To: NT Developers Interest List
Subject: [ntdev] Re: Listening to PPP traffic over modem

On NT and Win 2000, I used a modified version of the IMSAMP driver provided
by Jim Mateer (it captures all TCP/IP traffic - TCP, UDP, ICMP, etc.), which
can be found here:

http://www.pcausa.com/resources/ndisimfaq.htm#PCAUSANDISIM

It works with RAS; the major changes (for supporting RAS/NdisWan adapters)
are in the .INF file and the medium reported by the driver in
MiniportInitialize must be NdisMedium802_3, rather than NdisMediumWan. You
might also have to disable IP Header Compression on the dial-up networking
entry for the modem, as well.

To get it work on Win 2K, you can install it using a modified version of the
filter sample in the network section of the Win 2K DDK; in the DriverEntry
function, when filling in the DriverObject->MajorFunction table, save the
original DriverObject’s IRP_MJ_PNP, IRP_MJ_POWER, and IRP_MJ_SYSTEM_CONTROL
handlers; you’ll want to place these in your DriverObject when calling
IoCreateDevice. I suppose this won’t be a true WDM driver, but it does work.

Ed

----- Original Message -----
From: Barak Mandelovich
To: NT Developers Interest List
Sent: Wednesday, August 02, 2000 11:07 AM
Subject: [ntdev] Listening to PPP traffic over modem

> Hello, fellow developers!
>
> Remember the packet.sys sample from Microsoft,
> the one that attaches to the MAC driver and can listen to
> the traffic and send frames over the network?
>
> I need to do the same, but for a modem. i.e.: I should attach
> my driver to the modem driver, and send/receive packets
> using it (thus, bypassing the system’s TCP/IP stack).
>
> In other words - I want to build my own TCP/IP stack.
>
> The problem is, that I don’t want to handle all kinds of
> layer 2 protocols (ppp, slip, adsl(?), isdn-ppp etc.).
>
> Is there a way for me to be attached to an upper-layer driver,
> which is still under the TCP/IP stack?
>
> Currently, I’m trying to attach to the NdisWan driver, and just
> “snoop” the traffic - I want to print all packets sent.
>
> However, when I try to make the packet.sys sample to attach
> the NdisWan, it fails.
>
> Any ideas? Any suggestions for places I can look at?
> Does anybody know how the TCP/IP stack uses the NdisWan?
>
>
> best regards,
>
> - 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’)
>


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

Barak,

there should be no problem attaching a protocol driver as a packet.sys to
NdisWan adapters. I believe I did it several years ago when learnt NDIS but
forgot details. Currently I’m attaching NdisWan adapters from IM drivers
which isn’t different in principle (IM driver protocol part works as a
normal protocol driver).

You should examine return code to see what is wrong. A wild shot: are you
giving proper medium array to NdisOpenAdapter()? It must contain
NdisMediumWan for NdisWan adapters.

Best regards,

Michal Vodicka
Veridicom
(RKK - Skytale)
[WWW: http://www.veridicom.com , http://www.skytale.com]


From: Barak Mandelovich[SMTP:xxxxx@mercury.co.il]
Reply To: NT Developers Interest List
Sent: Wednesday, August 02, 2000 6:13 PM
To: NT Developers Interest List
Subject: [ntdev] Re: Listening to PPP traffic over modem

Hi!

Well, I really don’t want to use an intermediate driver,
since it’ll slow the entire machine down.

In addition, my driver will not work all the time, so
it’s a waste putting an IM driver that just passes
frames… Think of the overhead…

I want to put my driver above the layer 2 protocol,
regardless of its type. I want my stack to be able to
send IP datagrams without worrying about anything else.

If possible, I also don’t want to make the user reboot
his machine. I want to bind my driver dynamically,
but let’s leave it to later times.

If this is not possible - does anybody know why can’t
the packet.sys sample attach itself over the NdisWan driver?
The driver reports that it founds a MAC driver call NdisWan6, and
binds to it, but when I do a CreateFile(), it fails with error code 25
(SEEK_ERROR !!!). The PacketOpenAdapterComplete() then reports failure.

Note that in this stage, all I want to do is listen to the network…

Ideas?

regards,

  • Barak Mandelovich

> ----------

From: Ed Lau[SMTP:xxxxx@midcore.com]
Reply To: NT Developers Interest List
Sent: Wednesday, August 02, 2000 5:05 PM
To: NT Developers Interest List
Subject: [ntdev] Re: Listening to PPP traffic over modem

To get it work on Win 2K, you can install it using a modified version of
the
filter sample in the network section of the Win 2K DDK; in the DriverEntry
function, when filling in the DriverObject->MajorFunction table, save the
original DriverObject’s IRP_MJ_PNP, IRP_MJ_POWER, and
IRP_MJ_SYSTEM_CONTROL
handlers; you’ll want to place these in your DriverObject when calling
IoCreateDevice. I suppose this won’t be a true WDM driver, but it does
work.

A small comment: you should use NdisMRegisterDevice() instead. It will
handle properly dispatch table manipulation, function forwarding and also
creates symbolic link. The only problem with it is when you want to have own
device extension (not big problem) or when you want to create exclusive
device. NDIS developers in their endless wisdom forgot to add this parameter
:frowning: (a hack: this flag can be changed directly in DEVICE_OBJECT).

Best regards,

Michal Vodicka
Veridicom
(RKK - Skytale)
[WWW: http://www.veridicom.com , http://www.skytale.com]

Hello!

First, thanks for your reply.
Well, you were right – the medium was incorrect.

But now, I have other problems:
a. when the driver starts listening - the modem stops responding.
That it, I do a CreateFile(), the driver binds to NdisWan, and then
I cannot access the network (frames are not transmitted) !
Note that the driver does NOT bind itself instead of TCP/IP,
but rather in addition to it. Any idea why the packets are blocked?

b. Now I need two drivers, which are basically the same:
One for modem, and one for Ethernet.
Can’t I use a single driver?

c. Suppose I want to write a “raw” protocol stack - a stack that loads
itself on top of layer 2 protocol, gets a buffer from the user
and transmits it over the network. (This is what the TCP/IP stack does:
it loads itself on top of layer 2, regardless of its (layer 2’s) type.
If I could do this - it’ll solve all of my problems, and I’ll be
grateful forever…

thanks in advance,

  • Barak Mandelovich

You should examine return code to see what is wrong. A wild shot: are you
giving proper medium array to NdisOpenAdapter()? It must contain
NdisMediumWan for NdisWan adapters.


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

> Any ideas? Any suggestions for places I can look at?

Does anybody know how the TCP/IP stack uses the NdisWan?

My NDIS knowledge is very far from perfect, but NdisWan is an intermediate
driver with IIRC Ethernet upper end which binds itself to WAN lower-end
drivers
(to the miniports with WAN upper end).
So, this is an intermediate layer between the WAN miniports and TCP/IP.
It provides compression and encryption.
The WAN miniport is AsyncMac.sys (for COM-port-attached modems at least.
Don’t know where is a place for modem.sys in this picture. Does AsyncMac
talks to modem.sys or to serial.sys?).

Max

Barak,

sorry for late reply, I had a holiday. Reading your other mails, I would
recommend to read whole NDIS and maybe TDI documentation at first. It
contains answers to most of your questions. Also, you should examine
available NDIS samples.


From: Barak Mandelovich[SMTP:xxxxx@mercury.co.il]
Reply To: NT Developers Interest List
Sent: Thursday, August 03, 2000 10:21 AM
To: NT Developers Interest List
Subject: [ntdev] Re: Listening to PPP traffic over modem

Hello!

First, thanks for your reply.
Well, you were right – the medium was incorrect.

You see, basic thing. NDIS isn’t so complicated but one had to understand
how things work before using…

But now, I have other problems:
a. when the driver starts listening - the modem stops responding.
That it, I do a CreateFile(), the driver binds to NdisWan, and then
I cannot access the network (frames are not transmitted) !
Note that the driver does NOT bind itself instead of TCP/IP,
but rather in addition to it. Any idea why the packets are blocked?

Please read NDIS_WAN_LINE_UP event documentation. NdisWan interface is
connection oriented and you have to do special processing with MAC addresses
if you want to send packets to network.

b. Now I need two drivers, which are basically the same:
One for modem, and one for Ethernet.
Can’t I use a single driver?

Why not? Just bind all interfaces you need and process packets according to
used media. I’m processing Ethernet, FDDI, Token Ring and NdisWan packets in
one IM driver.

c. Suppose I want to write a “raw” protocol stack - a stack that loads
itself on top of layer 2 protocol, gets a buffer from the user
and transmits it over the network. (This is what the TCP/IP stack does:
it loads itself on top of layer 2, regardless of its (layer 2’s) type.
If I could do this - it’ll solve all of my problems, and I’ll be
grateful forever…

No problem. Just build a packet and send it using NdisSend().

Best regards,

Michal Vodicka
Veridicom
(RKK - Skytale)
[WWW: http://www.veridicom.com , http://www.skytale.com]