473,432 Members | 1,450 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,432 software developers and data experts.

How to do raw Ethernet under Win32?

How does one do raw Ethernet under Win32? Ultimately, I want
to do it in a Python program, but if somebody can point me to a
clue on how to do it from C, I could probably figure out the
rest.

I want to:

1) Send an arbitrary Ethernet packet. [Well, not completely
arbitrary, the source MAC will be "right", but the protocol
number is a proprietary (not IP) one, and the packet isn't
anything standard.

2) Receive any incoming packets with a specified protocl
number -- same proto number as in 1) above.

I've got a program that works under Linux, and I'd like to be
able to port it to Win32...

--
Grant Edwards grante Yow! I have seen these
at EGG EXTENDERS in my
visi.com Supermarket... I have read
theINSTRUCTIONS...
Jul 18 '05 #1
7 11487
In article <3f*********************@newsreader.visi.com>, Grant Edwards wrote:
How does one do raw Ethernet under Win32? Ultimately, I want
to do it in a Python program, but if somebody can point me to a
clue on how to do it from C, I could probably figure out the
rest.


It looks like I can _almost_ do what I want with the python
wrapper around the windows pcap lib. WinPcap has a
sendpacket() funcation which doesn't seem to be made visible by
the Windows version of pylibpcap, so that's something I'll have
to look into.

It's probably not the optimal way to receive packets, but I
only have to do a few.

--
Grant Edwards grante Yow! My DIGITAL WATCH
at has an automatic SNOOZE
visi.com FEATURE!!
Jul 18 '05 #2
In article <ma*********************************@python.org> , Gerhard Häring wrote:
It looks like I can _almost_ do what I want with the python
wrapper around the windows pcap lib.


Where's PyLibpCap for Windows available?


Here's where I got it from:

http://ghaering.de/python/unsupported/pylibpcap/ ;)

I'd take a whack at finishing it, but I don't have a Windows C compiler.

--
Grant Edwards grante Yow! Did you find a
at DIGITAL WATCH in YOUR box
visi.com of VELVEETA??
Jul 18 '05 #3
Grant Edwards wrote:
In article <ma*********************************@python.org> , Gerhard Häring wrote:
It looks like I can _almost_ do what I want with the python
wrapper around the windows pcap lib.


Where's PyLibpCap for Windows available?


Here's where I got it from:

http://ghaering.de/python/unsupported/pylibpcap/ ;)

I'd take a whack at finishing it, but I don't have a Windows C compiler..


The guy you got this from used MINGW, the free GNU compiler for Windows
to do the original port:

http://mingw.sourceforge.net/

:)

-- Gerhard

Jul 18 '05 #4
"Grant Edwards" <gr****@visi.com> wrote in message
news:3f*********************@newsreader.visi.com.. .
How does one do raw Ethernet under Win32? Ultimately, I want
to do it in a Python program, but if somebody can point me to a
clue on how to do it from C, I could probably figure out the
rest.

I want to:

1) Send an arbitrary Ethernet packet. [Well, not completely
arbitrary, the source MAC will be "right", but the protocol
number is a proprietary (not IP) one, and the packet isn't
anything standard.

2) Receive any incoming packets with a specified protocl
number -- same proto number as in 1) above.

I've got a program that works under Linux, and I'd like to be
able to port it to Win32...

the new winsock2.h supports more socket types:
/*
* Types
*/
#define SOCK_STREAM 1 /* stream socket */
#define SOCK_DGRAM 2 /* datagram socket */
#define SOCK_RAW 3 /* raw-protocol interface */
#define SOCK_RDM 4 /* reliably-delivered message */
#define SOCK_SEQPACKET 5 /* sequenced packet stream */

so you have only to define 3 as type in the socket() call

greetings
Leopold Faschalek
--
Grant Edwards grante Yow! I have seen these
at EGG EXTENDERS in my
visi.com Supermarket... I have read theINSTRUCTIONS...

Jul 18 '05 #5
In article <GH****************@news.salzburg-online.at>, Leopold Faschalek wrote:
How does one do raw Ethernet under Win32? Ultimately, I want
to do it in a Python program, but if somebody can point me to a
clue on how to do it from C, I could probably figure out the
rest.
the new winsock2.h supports more socket types:
/*
* Types
*/
#define SOCK_STREAM 1 /* stream socket */
#define SOCK_DGRAM 2 /* datagram socket */
#define SOCK_RAW 3 /* raw-protocol interface */
#define SOCK_RDM 4 /* reliably-delivered message */
#define SOCK_SEQPACKET 5 /* sequenced packet stream */

so you have only to define 3 as type in the socket() call


I've seen vague references to this in some FAQs but could never
find out if it actually worked or how to specified what
Ethernet protocol you wanted to receive on the socket.

--
Grant Edwards grante Yow! The PINK SOCKS were
at ORIGINALLY from 1952!! But
visi.com they went to MARS around
1953!!
Jul 18 '05 #6
In article <ma**********************************@python.org >, Gerhard Häring wrote:
Grant Edwards wrote:
In article <ma*********************************@python.org> , Gerhard Häring wrote:
It looks like I can _almost_ do what I want with the python
wrapper around the windows pcap lib.

Where's PyLibpCap for Windows available?


Here's where I got it from:

http://ghaering.de/python/unsupported/pylibpcap/ ;)

I'd take a whack at finishing it, but I don't have a Windows C compiler.


The guy you got this from used MINGW, the free GNU compiler for Windows
to do the original port:

http://mingw.sourceforge.net/

:)


Cool! Be sure to thank him for the work if you see him.

I've never done any SWIG stuff before, but it looks like all I
have to do is add some stuff to the .i file to export the
pcap_sendpacket() function.

--
Grant Edwards grante Yow! I LIKE Aisle 7a.
at
visi.com
Jul 18 '05 #7
Grant Edwards wrote:
I've never done any SWIG stuff before, but it looks like all I
have to do is add some stuff to the .i file to export the
pcap_sendpacket() function.


I haven't done any SWIG work, either (apart from unsuccessful tries at
adding something to wxPython once). Instead I directly hacked the SWIG
generated C code, so my patch is little but a quick hack.

It's also some time ago and I never used the thing myself, so don't ask
me about details :-)

-- Gerhard

Jul 18 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Chaser | last post by:
Hi folks, Just wondering if anyone knows where I can find modules for NI-488.2 GPIB and for a generic ethercard? Thanks.
3
by: Ophir | last post by:
Hi all ! Are there any windows API to get information about ethernet cards installed on the computer? Tried to search msdn but came out short. I need to get all present networking cards...
5
by: MLH | last post by:
Well one thing I've wanted to do is be able to PHYSICALLY connect and dis- connect a PC's xBASE-T connection via program control. The idea is... Instead of plugging your standard R-J45...
1
by: The 2nd Nin | last post by:
I am looking to produce a C++ program capable of sending relatively large packets via ethernet at a maximum rate of ~2.5KHz (2500 packets / s) under a Win32 platform (2K/XP). Does anyone have any...
13
by: KiwiGenie | last post by:
I am trying to connect to the internet using a USB Ethernet adapter. It installs but won't connect to my dsl modem. The ethernet light on the modem doesn't even light up, though the same cable works...
11
by: gustavo.samour | last post by:
Hi, I am writing a very basic raw ethernet sniffer based on what I found in Andreas Schaufler's raw ethernet article: http://aschauf.landshut.org/fh/linux/udp_vs_raw/ch01s03.html I'm trying...
1
by: kavok | last post by:
I am writing a software that needs to sniff packets in the network (raw ethernet) and also, with another thread send regular UDP packets with the common socket API's. However, when the RAW...
3
by: jh3530 | last post by:
Hello, my apologies for the lame question, but I can't seem to figure this one out. I was recently given a laptop from my inlaws that is running windows 98. I wanted to get internet access on it,...
1
by: grndvl1 | last post by:
I am attempting to write an abstract layer to make Ethernet and Serial seemless in my application. I have an interface that is the what I call ILayer it has the method stubs for connect, disconnect,...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.