日期:2014-05-16  浏览次数:20694 次

调个网络嗅探器的程序 出错了
]liang@ubuntu:~/Documents/6$ cat main.c
#include "rawsocsniffer.h"
//#include <linux/if_ether.h>
#include <arpa/inet.h>
#include <iostream>
using namespace std;
int main(int argc, char ** argv)
{
  //rawsocsniffer sniffer(htons(ETH_P_ALL));
  rawsocsniffer sniffer(htons(0x0003));
  char ch;
  filter myfilter;
  memset(&myfilter,0,sizeof(myfilter));
  while((ch=getopt(argc, argv,"s:d:atui"))!=-1)
  {
switch (ch)
{
case 's':
myfilter.sip=inet_addr(optarg);
break;
case 'd':
myfilter.dip=inet_addr(optarg);
break;
case 'a':
sniffer.setbit((myfilter.protocol),1);
break;
case 't':
sniffer.setbit((myfilter.protocol),2);
break;
case 'u':
sniffer.setbit((myfilter.protocol),3);
break;
case 'i':
sniffer.setbit((myfilter.protocol),4);
break;
default:
break;
}
  }
  cout<<"create sniffer succeed."<<endl;
   
  //set sniffer filter;
  sniffer.setfilter(myfilter);
   
  //sniffer initialize
  if(!sniffer.init())
  {
cout<<"sniffer initialize error!"<<endl;
exit(-1);
  }

  //start to capture packets;
  sniffer.sniffer();
}
liang@ubuntu:~/Documents/6$ 
liang@ubuntu:~/Documents/6$ make
g++ -c main.c
main.c: In function ‘int main(int, char**)’:
main.c:12: error: ‘memset’ was not declared in this scope
main.c:48: error: ‘exit’ was not declared in this scope
make: *** [main.o] Error 1

还有其他的文件,这个是虾米错误啊???

------解决方案--------------------
#include <stdio.h>
基本的没有包含。。