How to do raw Ethernet under Win32?

Discussion in 'Python' started by Grant Edwards, Jul 23, 2003.

  1. 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...
    Grant Edwards, Jul 23, 2003
    #1
    1. Advertising

  2. In article <3f1ed31a$0$181$>, 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!!
    Grant Edwards, Jul 23, 2003
    #2
    1. Advertising

  3. In article <>, 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??
    Grant Edwards, Jul 24, 2003
    #3
  4. Grant Edwards wrote:
    > In article <>, 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
    =?ISO-8859-1?Q?Gerhard_H=E4ring?=, Jul 24, 2003
    #4
  5. "Grant Edwards" <> wrote in message
    news:3f1ed31a$0$181$...
    > 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...
    Leopold Faschalek, Jul 24, 2003
    #5
  6. In article <GHOTa.3$-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!!
    Grant Edwards, Jul 24, 2003
    #6
  7. In article <>, Gerhard Häring wrote:
    > Grant Edwards wrote:
    >> In article <>, 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
    Grant Edwards, Jul 24, 2003
    #7
  8. 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
    =?ISO-8859-1?Q?Gerhard_H=E4ring?=, Jul 24, 2003
    #8
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Raw Ethernet Packet Capture

    , Oct 22, 2007, in forum: C Programming
    Replies:
    12
    Views:
    6,909
  2. Schmigz

    win32::SerialPort; Sending Raw Data

    Schmigz, Jan 26, 2004, in forum: Perl Misc
    Replies:
    2
    Views:
    283
    Schmigz
    Jan 26, 2004
  3. khanta
    Replies:
    2
    Views:
    56
    Mark Lawrence
    Feb 21, 2014
  4. Chris Angelico
    Replies:
    0
    Views:
    45
    Chris Angelico
    Feb 19, 2014
  5. Chris Angelico
    Replies:
    0
    Views:
    44
    Chris Angelico
    Feb 19, 2014
Loading...

Share This Page