//def_type.h
typedef struct iphdr{
unsigned int ip_version :4; //ip version set to 4
unsigned int ip_length :4; //length of ip header in 32_bit words
unsigned char ip_tos; //type of service
unsigned short ip_total_len; //total length of ip datagram in byte
unsigned short ip__id; //destification
unsigned short ip_flags; //
unsigned char ip_ttl; //time to live
unsigned char ip_protocal; //identifies the correct transport protocal
unsigned short ip_cksum; //check ip header
unsigned int ip_source; //source of the ip datagram
unsigned int ip_dest; //destination of the datagram
};
struct tcphdr{
unsigned short tcp_source_port;
unsigned short tcp_dest_port;
unsigned int tcp_seq; //sequence of the tcp datagram
unsigned int tcp_ackno; //sequence of the next tcp datagram the reveiver expects
unsigned int tcp_res:6, //little-endian
tcp_hlen:4, //length of tcp header
tcp_urg:1, //urgent pointer
tcp_ack:1, //acknow
tcp_psh:1, //push flag
tcp_rst:1, //reset flag
tcp_fin:1; //finish flag
unsigned short tcp_winsize; //maxinum number of bytes able to recieve
unsigned short
tcp_cksum; //checksum of the tcp datagram
unsigned short tcp_urgent; //avaible when urg=1
};
struct udphdr{
unsigned short udp_source_port;
unsigned short udp_dest_port;
unsigned int udp_len; //length of udp datagram
unsigned int udp_cksum; //checksum of the udp
};
struct icmphdr{
unsigned char icmp_type; //type of icmp
unsigned char icmp_code;
};
struct packet{ //put those msg into the table
int ID;
unsigned int source;
unsigned int dest;
char time[9];
unsigned char ptlk;
unsigned char *msg; //other msg such as TTL,sequence,windows size
};
}
*************error*****在别处还没有调用以上的结构
[root@localhost sniffer]# qmake -o makefile sniffer.pro
[root@localhost sniffer]# make
g++ -c -pipe -Wall -W -O2 -
march=i386 -mcpu=i686 -g -DGLX_GLXEXT_LEGACY -fno-use-cxa-atexit -fno-exceptions -DQT_NO_DEBUG -
I/usr/lib/qt-3.1/mkspecs/default -I. -I/usr/lib/qt-3.1/include -I.ui/ -I.moc/ -o .obj/main.o main.cpp
In file included from
main.cpp:4:
def_type.h:7: redefinition of `struct iphdr'
def_type.h:7: previous definition of `struct iphdr'
def_type.h:20: redefinition of `struct tcphdr'
def_type.h:20: previous definition of `struct tcphdr'
def_type.h:36: redefinition of `struct udphdr'
def_type.h:36: previous definition of `struct udphdr'
def_type.h:42: redefinition of `struct icmphdr'
def_type.h:42: previous definition of `struct icmphdr'
def_type.h:46: redefinition of `struct packet'
def_type.h:46: previous definition of `struct packet'
make: *** [.obj/main.o] Error 1