Linux - SoftwareThis 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
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.
hello,
I am using 2.6 Ubuntu. So i mentioned in my program #define _USE_BSD_ even though missing header information and getting this error. Can any one help me?
Quote:
‘struct tcphdr’ has no member named ‘th_flags’
tcpg.c:139: error: ‘struct tcphdr’ has no member named ‘th_flags’
tcpg.c:140: error: ‘struct tcphdr’ has no member named ‘th_seq’
tcpg.c:140: error: ‘struct tcphdr’ has no member named ‘th_seq’
tcpg.c: In function ‘tcpg_syn’:
tcpg.c:152: error: ‘struct tcphdr’ has no member named ‘th_flags’
tcpg.c:152: error: ‘struct tcphdr’ has no member named ‘th_flags’
tcpg.c:153: error: ‘struct tcphdr’ has no member named ‘th_sport’
tcpg.c:153: error: ‘struct tcphdr’ has no member named ‘th_dport’
Code:
#define TCPG_SYN
/* Log QUESO probes. */
#define TCPG_QUESO
/* SYN flooding detection. */
#define TCPG_SYNFLOOD
/* WinNuke detection. */
#define TCPG_OOB
/* Log LAND attacks. */
#define TCPG_LAND
/* Log HPing probes and port 0 connection packets. */
#define TCPG_HPING
/* Shell daemon default port probe detection. */
#define TCPG_PORTD
/* Kill connections to TCP port TCPG_KILL. */
#define TCPG_KILL 110
/* DON'T CHANGE ANYTHING BELOW THIS LINE !!!!!!!!!!!!!! */
/* DON'T CHANGE ANYTHING BELOW THIS LINE !!!!!!!!!!!!!! */
/* DON'T CHANGE ANYTHING BELOW THIS LINE !!!!!!!!!!!!!! */
/* Biggest list of includes you've ever seen, eh?! =;-) */
#include <libnet.h>
#include <syslog.h>
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <string.h>
#define __USE_BSD_
#include <netinet/tcp.h>
/******************* Why not make all variables global ?!************************/
struct ippkt {
struct iphdr ip;
struct tcphdr tcp;
char buffer[5000];
} pkt;
int s, lns;
struct in_addr src_addr;
u_char *buff;
u_int sport, dport;
void tcpg_syn();
void tcpg_hping();
void tcpg_synflood();
void tcpg_portd();
void tcpg_queso();
void tcpg_land();
void tcpg_oob();
void tcpg_die();
void tcpg_init();
void tcpg_kill(u_short);
problem in here...........
Code:
void tcpg_kill(u_short kport)
{
u_long src_ip=0, dst_ip=0, ack;
/* The following kills all TCP connections to port kport ! */
/* WARNING: This part does not make any checks !!! */
if(ntohs(pkt.tcp.th_dport)==kport)
{
sport=ntohs(pkt.tcp.th_sport);
dport=ntohs(pkt.tcp.th_dport);
src_ip=pkt.ip.daddr;
dst_ip=pkt.ip.saddr;
ack=ntohl(pkt.tcp.th_seq)+1;
buff=malloc(TCP_H+IP_H);
bzero(buff, TCP_H+IP_H);
build_ip(TCP_H, IPTOS_LOWDELAY | IPTOS_THROUGHPUT, 242, 0, 64, IPPROTO_TCP, src_ip, dst_ip, NULL, 0, buff);
build_tcp(sport, dport, ack, ack, TH_RST, 4096, 0, NULL, 0, buff+IP_H);
do_checksum(buff, IPPROTO_TCP, TCP_H);
lns=open_raw_sock(IPPROTO_RAW);
syslog(LOG_INFO, "WARNING: Killing connection from %s to port %d.", inet_ntoa(src_addr), kport);
write_ip(lns, buff, IP_H+TCP_H);
close(lns);
}
}
According to man feature_test_macros, there is a _BSD_SOURCE macro, but it doesn't list a _USE_BSD_ macro.
Also, I think a feature test macro should be defined before any other includes. The includes may differ depending on which you used. So some structures may be different then you want because when the include file was read in, _BSD_SOURCE wasn't defined.
The netinet/tcp.h header uses __FAVOR_BSD and not _USE_BSD_ in my version at least.
Look at your tcp.h file and see which it uses.
Using _BSD_SOURCE will define __USE_BSD.
Code:
#ifdef _BSD_SOURCE
# define __USE_BSD 1
#endif
and __FAVOR_BSD:
Code:
/* If _BSD_SOURCE was defined by the user, favor BSD over POSIX. */
#if defined _BSD_SOURCE && \
!(defined _POSIX_SOURCE || defined _POSIX_C_SOURCE || \
defined _XOPEN_SOURCE || defined _XOPEN_SOURCE_EXTENDED || \
defined _GNU_SOURCE || defined _SVID_SOURCE)
# define __FAVOR_BSD 1
#endif
So defining _BSD_SOURCE at the beginning of your program may fix your problem.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.