Linux - NetworkingThis forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
int i = 0;
int s; /*socketdescriptor*/
int frameCount = 1;
int MAX_FRAMES = 1000;
s = socket(AF_PACKET, SOCK_RAW, ntohs(ETH_P_ALL));
if (s == -1) { printf("ERROR BINDING SOCKET...\n"); exit(0); }
unsigned char* buffer = (unsigned char*)malloc(ETH_FRAME_LEN);
memset(buffer, '\0', ETH_FRAME_LEN);
/*Buffer for ethernet frame*/
int length = 0; /*length of the received frame*/
the packets are going from computer to computer and also from the board to the computer ... but vice versa is not happening.. the received length on the board is coming 0 ..
we are not able to figure out why our codes are giving us problem ... someone plz help us !!
Also, raw socket mode requires root privileges.
--- rod.
Hey,
Thanks but that doesn't seem to be the problem because we have the root privileges.
Also we are getting the ping packets and we are able to send these raw packets.
Any other suggestions?
Some code I've used has a note that the SOCK_RAW parameter was not working for me (and I never studied it to find out why), but the working code uses 'AF_INET, SOCK_PACKET' as the first two args to the socket() function. It may or may not be relevant, but this code uses a main loop that calls select() to detect incoming traffic (various sockets), and then uses read() to fetch the data.
Nothing I see in your code jumps out at me (but it would have made it a lot easier to read if it had been posted in [CODE] tags).
Is there any other network code in your board that is fully functional?
HEY!
There is no other network code on the board . I think the problem is at a much lower level than the application code. Because the code or even tcpdump does not even show the incoming ping packets. It just prints all the outgoing ping packets. Is there any problem with linux 2.4 that we are using. And can you help as to how should we go about it.
HEY!
There is no other network code on the board .
You did say that you could send from the board to a computer, and that ping works at some level. Ergo, you've got networking. What is the output of /sbin/ifconfig? What is the output of netstat -i?
--- rod.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.