How to Access Ethernet Card From C++

This is a discussion on How to Access Ethernet Card From C++ within the C++ Programming forums, part of the General Programming Boards category; I'm trying to write a customized packet sniffer. I don't want to use ethereal or something similar because it's far ...

  1. #1
    Registered User
    Join Date
    Mar 2005
    Location
    Omaha, NE
    Posts
    5

    How to Access Ethernet Card From C++

    I'm trying to write a customized packet sniffer. I don't want to use ethereal or something similar because it's far too advanced for the purposes I want to use it for, not to mention I want to customize my packet sniffer's behavior anyway.

    I have done SO many searches on the internet, I have asked so many of my Counterstrike buddies who program, and I am simply completely lost. I have no idea where to even start. All I know is that I need to be able to access my NIC (in my case, ethernet card) from C++, so that I can monitor the packets coming into it, and going out of it.

    I know that this is a very broad question, and I debated whether or not to post, but I simply am out of ideas. I can't find help anywhere else. Does anyone know where a good place to start is, as far as learning how to program my NIC? Please, any help at all is going to help me.

    cheers,
    drmario

  2. #2
    Registered User
    Join Date
    Jan 2005
    Posts
    847
    I beleive you need to write a NDIS driver but since I have never done this I don't know the specifics on doing that but it might be a usefull searc term. You could also look at the libpcap library. It provides all the functions needed to write a packet sniffer and is open source.

  3. #3
    Registered User
    Join Date
    Mar 2005
    Location
    Omaha, NE
    Posts
    5

    libpcap library

    Thanks for the suggestions. I will do a search on NDIS. As far as the libpcap library goes, I downloaded the source for that. In browsing the source, I was absolutely overwhelmed by the size and complexity of that library. In addition, nowhere in the items included in the download did I find simple documentation on all the functionality provided by the library, or instructions on how to build it using VC++ :-(

    But definite thanks for the NDIS suggestions, will get back to searching the jungle/internet on NDIS thx :-)

    cheers,
    DrMario

  4. #4
    Registered User
    Join Date
    Mar 2004
    Posts
    220
    I'de also be interested in this project you're working on I was planning on doing something like this and eventually adding firewall capabilities (ha), maybe I'm just shooting for the stars? Hehe but it's fun that way.
    OS: Windows XP Pro CE
    IDE: VS .NET 2002
    Preferred Language: C++.

  5. #5
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,546
    I would suggest you write your code in terms of the pcap library simply to save yourself from an awful lot of detailed (and repeated work when you change network cards).

    Digging that far down into the OS is a lot of work (as you've just seen).
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  6. #6
    Registered User
    Join Date
    Mar 2005
    Location
    Omaha, NE
    Posts
    5

    Libpcap a bit ambiguous to me...

    As I previously stated when I downloaded the libpcap library I was simply overwhelmed. So much code... I consider myself an intermediate, at best, programmer and a newbie is probably more accurate. Digging through and looking at the code containd in the header & source files only served to confuse me, and get me angry because I can't successfully break it down and follow it. I can't find a list of the functionality it provides (in the download can't find a list of the functionality) and I can't find an explanation of how to build the library with VC++. Maybe I'm in over my head with this project :-( But thanks for the help, I appreciate it sir :-)

    cheers,
    DrMario

  7. #7
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,546
    Or simply d/l a precompiled win32 libpcap library.
    5-second google found that much...
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Need Help With a BlackJack Program in C
    By Jp2009 in forum C Programming
    Replies: 15
    Last Post: 03-30-2009, 10:06 AM
  2. Bitwise Unwanted Output
    By pobri19 in forum C++ Programming
    Replies: 4
    Last Post: 09-15-2008, 04:07 AM
  3. Vector out of range program crash.
    By Shamino in forum C++ Programming
    Replies: 11
    Last Post: 01-18-2008, 04:37 PM
  4. Segmentation Fault - aaaaaaaah!
    By yogibear in forum C Programming
    Replies: 6
    Last Post: 10-01-2007, 03:21 AM
  5. Blackjack
    By Tommo in forum C Programming
    Replies: 10
    Last Post: 06-20-2007, 08:07 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21