我在做一个捕包器程序,我想使界面友好一些,请问在linux下有这样的工具吗,如windows下的VC(在线)

wangbangjie 2004-05-08 03:16:06
我在做一个捕包器程序,我想使界面友好一些,请问在linux下有这样的工具吗,如windows下的VC(在线)
...全文
118 10 打赏 收藏 举报
写回复
10 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
treetree123 2004-07-30
Magic C++,完全兼容VC++
  • 打赏
  • 举报
回复
tengulre 2004-07-29
curses.h
  • 打赏
  • 举报
回复
city_goal 2004-07-28
什么都想自己开发
还玩什么linux

看看/教堂与集市/


东西总是人开发出来的,重要的是不要做比人已经做的很好、很完善的东西,做东西要有点创新性
  • 打赏
  • 举报
回复
walkonthesky 2004-06-17
什么都想自己开发
还玩什么linux

看看/教堂与集市/
  • 打赏
  • 举报
回复
CoolQ 2004-05-13
现成的Ethereal已经做得很好了,为什么要重复劳动呢?
  • 打赏
  • 举报
回复
jellen 2004-05-13
用Gtk+也行,在gnome下直接用C调用Gtk+2.0函数库
  • 打赏
  • 举报
回复
wangbangjie 2004-05-13
可是我在kdevelop下要运用libpcap,怎么连啊?也就是编译时出现"1.c:17:18: pcap.h: No such file or directory "的问题.请问怎么解决!
  • 打赏
  • 举报
回复
wangbangjie 2004-05-13
#include <pcap.h>
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>

#define BUFSIZ 1000
#define PCAP_ERRBUF_SIZE 200
void Display( const u_char * packet, const size_t length );

/* list all packets be filtered */
void my_callback ( u_char * none, const struct pcap_pkthdr * pkthdr, const u_char * packet )
{
Display( ( u_char * )packet, ( size_t )( pkthdr->caplen ) );
return;
}

int main(int argc,char **argv)
{
int i;
char *dev;
char errbuf[PCAP_ERRBUF_SIZE];
pcap_t* descr;
const u_char *packet;
struct pcap_pkthdr hdr;
struct ether_header *eptr;
struct bpf_program fp;
bpf_u_int32 maskp;
bpf_u_int32 netp;

if(argc != 2){
fprintf(stdout,"Usage: %s \"filter program\"\n" ,argv[0]);
return 0;
}

/* grab a device */
dev = pcap_lookupdev(errbuf);
if(dev == NULL) {
fprintf(stderr,"%s\n",errbuf);
exit(1);
}

/* ask pcap for the network address and mask of the device */
pcap_lookupnet(dev,&netp,&maskp,errbuf);

/* open device for reading this time lets set it in promiscuous
* mode so we can monitor traffic to another machine */
descr = pcap_open_live(dev,BUFSIZ,1,-1,errbuf);
if(descr == NULL) {
printf("pcap_open_live(): %s\n",errbuf);
exit(1);
}

/* Lets try and compile the program.. non-optimized */
if(pcap_compile(descr,&fp,argv[1],0,netp) == -1) {
fprintf(stderr,"Error calling pcap_compile\n");
exit(1);
}

/* set the compiled program as the filter */
if(pcap_setfilter(descr,&fp) == -1) {
fprintf(stderr,"Error setting filter\n");
exit(1);
}

/* capture packets */
pcap_loop(descr,-1,my_callback,NULL);

return 0;
}

void Display ( const u_char * packet, const size_t length )
{
u_long offset;
int i, j, k;

printf( "packet [ %lu bytes ]: \n", ( long unsigned int )length );
if ( length <= 0 ) {
return;
}
i = 0;
offset = 0;
for ( k = length / 16; k > 0; k--, offset += 16 ){
printf( "%08X ", ( unsigned int )offset );
for ( j = 0; j < 16; j++, i++ ) {
if ( j == 8 ){
printf( "-%02X", packet[i] );
}
else printf( " %02X", packet[i] );
}
printf( " " );
i -= 16;
for ( j = 0; j < 16; j++, i++ ) {
/* if ( isprint( (int)packet[i] ) ) */
if ( ( packet[i] >= ' ' ) && ( packet[i] <= 255 ) ) {
printf( "%c", packet[i] );
}
else printf( "." );
}
printf( "\n" );
}
k = length - i;
if ( k <= 0 ){
return;
}
printf( "%08X ", ( unsigned int )offset );
for ( j = 0 ; j < k; j++, i++ ){
if ( j == 8 ){
printf( "-%02X", packet[i] );
}
else printf( " %02X", packet[i] );
}
i -= k;
for ( j = 16 - k; j > 0; j-- ) {
printf( " " );
}
printf( " " );
for ( j = 0; j < k; j++, i++ ){
if ( ( packet[i] >= ' ' ) && ( packet[i] <= 255 ) ) {
printf( "%c", packet[i] );
}
else {
printf( "." );
}
}
printf( "\n" );
return;
}

此程序运行时还有1.o: In function `main':
/root/capture/capture/1.c:55: undefined reference to `pcap_lookupdev'
/root/capture/capture/1.c:62: undefined reference to `pcap_lookupnet'
/root/capture/capture/1.c:73: undefined reference to `pcap_compile'
/root/capture/capture/1.c:85: undefined reference to `pcap_loop'
collect2: ld returned 1 exit status
的错误,不知怎么调试.
  • 打赏
  • 举报
回复
myvanilla 2004-05-12
用 kylix 也可以
  • 打赏
  • 举报
回复
hatecoding 2004-05-10
KDevelop + QT

  • 打赏
  • 举报
回复
相关推荐
发帖
Linux/Unix社区
加入

1.8w+

社区成员

Linux/Unix社区 专题技术讨论区
社区管理员
  • 专题技术讨论区社区
申请成为版主
帖子事件
创建了帖子
2004-05-08 03:16
社区公告
暂无公告