Review your favorite Linux distribution.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 10-14-2003, 01:33 AM   #1
Registered: Aug 2003
Location: DMZ
Distribution: Ubuntu
Posts: 144

Rep: Reputation: 15

Hey pals
Here we meet again

I wanted to do a program which does some packet injection such as arp requests etc.

So I heard there is a library for that called libnet (

But nfortunately the man pages written with it are very short and miss many details, so does any one know a documentation or a detailed tutorial or howto to help me understand how to use this library

Also If anyone knows a better library please tell me

Last edited by gr33ndata; 10-14-2003 at 08:43 AM.
Old 10-14-2003, 11:37 AM   #2
Senior Member
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: Debian
Posts: 2,536

Rep: Reputation: 110Reputation: 110
Check the sources for these tools:
Old 10-14-2003, 02:24 PM   #3
Registered: Aug 2003
Location: DMZ
Distribution: Ubuntu
Posts: 144

Original Poster
Rep: Reputation: 15
Thanks a lot HKO

Now I have one more question

I wrote a program to send arp

--------------------START OF CODE-------------------------------------------------------------------

#include <libnet.h>

int main(int argc,char** argv){

u_long ip_src;
u_char ip_dst[4] = {0x0a,0x00,0x00,0x04};
u_char enet_src[6] = {0x00,0x01,0x02,0x03,0x04,0x05};
u_char enet_dst[6] = {0xff,0xff,0xff,0xff,0xff,0xff};

libnet_t* l;
libnet_ptag_t t;
char* device;
char errorBuffer[LIBNET_ERRBUF_SIZE];

if(argc>=2) device=argv[1];

l = libnet_init(LIBNET_LINK_ADV,device,errorBuffer);
fprintf(stderr,"\nError in libnet_init(): %s",errorBuffer);
return -1;

ip_src = libnet_get_ipaddr4(l);

t = libnet_build_arp(ARPHRD_ETHER,ETHERTYPE_IP,6,4,ARPOP_REPLY,enet_src,(u_char*)&ip_src,enet_dst,ip_dst ,NULL,0,l,0);
fprintf(stderr,"\nError in libnet_build_arp(): %s",libnet_geterror(l));
return -1;

t = libnet_autobuild_ethernet(enet_dst,ETHERTYPE_ARP,l);
fprintf(stderr,"\nError in libnet_autobuild_ethernet(): %s",libnet_geterror(l));
return -1;

int x=libnet_write(l);
fprintf(stderr,"\nError in libnet_write(): %s \n",libnet_geterror(l));
return -1;


--------------------------END OF CODE-------------------------------------------

And whenever I run it the computer hangs !!

So does anyone know what's wrong with it ??


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Libnet performance fr_laz Linux - Networking 0 10-31-2005 11:42 AM
libnet problem zaichik Programming 0 08-06-2005 06:30 PM
libnet problems StraitFaced Linux - Software 0 05-21-2005 06:04 PM
Libnet - Libnids Shu Linux - Software 0 07-15-2003 06:42 PM
libnet problems vexer Slackware 4 06-08-2003 08:35 AM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:17 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration