How to do raw Ethernet under Win32?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Grant Edwards

    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 ...
  • Grant Edwards

    #2
    Re: How to do raw Ethernet under Win32?

    In article <3f1ed31a$0$181 $a1866201@newsr eader.visi.com> , Grant Edwards wrote:
    [color=blue]
    > 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.[/color]

    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!!

    Comment

    • Grant Edwards

      #3
      Re: How to do raw Ethernet under Win32?

      In article <mailman.105899 6376.9482.pytho n-list@python.org >, Gerhard Häring wrote:[color=blue]
      >[color=green]
      >> It looks like I can _almost_ do what I want with the python
      >> wrapper around the windows pcap lib.[/color]
      >
      > Where's PyLibpCap for Windows available?[/color]

      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??

      Comment

      • Gerhard Häring

        #4
        Re: How to do raw Ethernet under Win32?

        Grant Edwards wrote:[color=blue]
        > In article <mailman.105899 6376.9482.pytho n-list@python.org >, Gerhard Häring wrote:
        > [color=green][color=darkred]
        >>>It looks like I can _almost_ do what I want with the python
        >>>wrapper around the windows pcap lib.[/color]
        >>
        >>Where's PyLibpCap for Windows available?[/color]
        >
        > 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..[/color]

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

        Download MinGW - Minimalist GNU for Windows for free. A native Windows port of the GNU Compiler Collection (GCC) MinGW: A native Windows port of the GNU Compiler Collection (GCC), with freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality.


        :)

        -- Gerhard

        Comment

        • Leopold Faschalek

          #5
          Re: How to do raw Ethernet under Win32?

          "Grant Edwards" <grante@visi.co m> wrote in message
          news:3f1ed31a$0 $181$a1866201@n ewsreader.visi. com...[color=blue]
          > 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...
          >[/color]

          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
          [color=blue]
          > --
          > Grant Edwards grante Yow! I have seen these
          > at EGG EXTENDERS in my
          > visi.com Supermarket... I have[/color]
          read[color=blue]
          > theINSTRUCTIONS ...[/color]


          Comment

          • Grant Edwards

            #6
            Re: How to do raw Ethernet under Win32?

            In article <GHOTa.3$dA6.75 5814@news.salzb urg-online.at>, Leopold Faschalek wrote:
            [color=blue][color=green]
            >> 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.[/color][/color]
            [color=blue]
            > 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[/color]

            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!!

            Comment

            • Grant Edwards

              #7
              Re: How to do raw Ethernet under Win32?

              In article <mailman.105903 4598.31317.pyth on-list@python.org >, Gerhard Häring wrote:[color=blue]
              > Grant Edwards wrote:[color=green]
              >> In article <mailman.105899 6376.9482.pytho n-list@python.org >, Gerhard Häring wrote:
              >>[color=darkred]
              >>>>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?[/color]
              >>
              >> 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.[/color]
              >
              > The guy you got this from used MINGW, the free GNU compiler for Windows
              > to do the original port:
              >
              > http://mingw.sourceforge.net/
              >
              >:)[/color]

              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

              Comment

              • Gerhard Häring

                #8
                Re: How to do raw Ethernet under Win32?

                Grant Edwards wrote:[color=blue]
                > 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.[/color]

                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

                Comment

                Working...