What's the most raw networking library?

  • Thread starter Tomás Ó hÉilidhe
  • Start date
T

Tomás Ó hÉilidhe

(I have posted this separately to comp.lang.c++ and comp.lang.c,
reason being that I'd like a response from both communities, but I
haven't cross-posted it because I think it's best not to mix C and C++
discussion)

I want to get into doing some network programming. I'd like to find a
good cross-platform networking library, but failing that, I'd settle
for something that'll work on Linux. I don't mind whether the libary
is C or whether it's C++, I'll work with either.

I don't want the library to be so raw as that I have to calculate my
own Frame Check Sequence for the frames I send, but I would like a
great deal of control, e.g. I'd like to be able to model a frame that
has a particular destination, a particular source, a particular
protocol value. And within the actual frame data, I'd like to be able
to specify whatever I want, any stream of 1's and 0's. For instance,
I'd like to model my own ARP request frame.

The machines I'll be working with will all satisfy the following
criteria:
1) CHAR_BIT == 8
2) I can specify to the compiler not to put padding between
structure members

OK so let's say I want to send an ARP request. I'd like to put
together an ARP header as follows:

typedef struct ARPHeader {
uint8 hardware_type[2],
proto_type[2],
hardware_len,
proto_len,
op[2],
src_MAC[6],
src_IP[4],
dest_MAC[6],
dest_IP[4]
} ARPHeader;


I'd then make an ARPHeader object and populate it:

ARPHeader arph = { /* blah blah blah */ };

And then I'd like to send the data out as a frame, e.g. something
like:

void LibraryFunctionForSendingFrame(uint8 dest[6],
uint8 src[6],
unsigned data_len,
uint8 const *data);

LibraryFunctionForSendingFrame(broadcast_addr,my_mac,sizeof
arph,arph);

Is there any kind of networking library that gives me this kind of
maticulous control? Also, I want to be able to listen to the NIC to
see if I get an ARP response.

And just for kicks, is there any kind of networking library that will
give you even *greater* control than this, e.g. one that will let you
specify a dodgy frame length and a dodgy Frame Check Sequence?
 
C

Christopher

(I have posted this separately to comp.lang.c++ and comp.lang.c,
reason being that I'd like a response from both communities, but I
haven't cross-posted it because I think it's best not to mix C and C++
discussion)

I want to get into doing some network programming. I'd like to find a
good cross-platform networking library, but failing that, I'd settle
for something that'll work on Linux. I don't mind whether the libary
is C or whether it's C++, I'll work with either.

I don't want the library to be so raw as that I have to calculate my
own Frame Check Sequence for the frames I send, but I would like a
great deal of control, e.g. I'd like to be able to model a frame that
has a particular destination, a particular source, a particular
protocol value. And within the actual frame data, I'd like to be able
to specify whatever I want, any stream of 1's and 0's. For instance,
I'd like to model my own ARP request frame.

The machines I'll be working with will all satisfy the following
criteria:
1) CHAR_BIT == 8
2) I can specify to the compiler not to put padding between
structure members

OK so let's say I want to send an ARP request. I'd like to put
together an ARP header as follows:

typedef struct ARPHeader {
uint8 hardware_type[2],
proto_type[2],
hardware_len,
proto_len,
op[2],
src_MAC[6],
src_IP[4],
dest_MAC[6],
dest_IP[4]
} ARPHeader;

I'd then make an ARPHeader object and populate it:

ARPHeader arph = { /* blah blah blah */ };

And then I'd like to send the data out as a frame, e.g. something
like:

void LibraryFunctionForSendingFrame(uint8 dest[6],
uint8 src[6],
unsigned data_len,
uint8 const *data);

LibraryFunctionForSendingFrame(broadcast_addr,my_mac,sizeof
arph,arph);

Is there any kind of networking library that gives me this kind of
maticulous control? Also, I want to be able to listen to the NIC to
see if I get an ARP response.

And just for kicks, is there any kind of networking library that will
give you even *greater* control than this, e.g. one that will let you
specify a dodgy frame length and a dodgy Frame Check Sequence?


How about you ask in one of the 10+ newsgroups dedicated to network
programming?!
Or are you looking for another excuse to advertise your silly proposal
for the 'lets talk about every c++ library in existance' ng here
again?
 
J

jason.cipriani


You can do everything that you described in your post using just BSD
sockets with SOCK_RAW types (on Windows you'd have to enumerate
protocols to find the one you want, but once you create the socket the
API is roughly the same)... see the man page:

http://swoolley.org/man.cgi/7/raw

The data structures for common frame packet headers are in many system
include files already.

See Beej's guide to network programming, and the WinSock FAQ it links
to, to get a handle on cross-platformness:

http://beej.us/guide/bgnet/

Start with those. That's about all the help you'll get here...

How about you ask in one of the 10+ newsgroups dedicated to network
programming?!

Jason
 
E

Erik Wikström

(I have posted this separately to comp.lang.c++ and comp.lang.c,
reason being that I'd like a response from both communities, but I
haven't cross-posted it because I think it's best not to mix C and C++
discussion)

I want to get into doing some network programming. I'd like to find a
good cross-platform networking library, but failing that, I'd settle
for something that'll work on Linux. I don't mind whether the libary
is C or whether it's C++, I'll work with either.

Perhaps BSD sockets is what you are looking for, I think they are part
of the POSIX specification which makes then available on many platforms.
They are also quite low-level and allows for using raw sockets.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top