LinuxQuestions.org
Visit Jeremy's Blog.
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 04-25-2008, 11:07 PM   #1
nasim751
Member
 
Registered: Jan 2008
Posts: 40

Rep: Reputation: 15
Post Header Problem


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);
 }
}
 
Old 04-26-2008, 12:28 AM   #2
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 678Reputation: 678Reputation: 678Reputation: 678Reputation: 678Reputation: 678
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.

Last edited by jschiwal; 04-26-2008 at 12:53 AM.
 
  


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
problem with header files(.h) hoshangi Programming 6 01-09-2008 02:07 AM
kde header problem bhert SUSE / openSUSE 6 12-30-2006 03:45 PM
Problem with c header file alaios Programming 4 09-03-2005 09:06 PM
Problem with Delivered-To Header waremock Linux - Enterprise 1 11-08-2004 08:48 AM
strange header problem irfanhab Programming 11 09-10-2004 01:10 AM

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

All times are GMT -5. The time now is 04:49 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