当前位置: 技术问答>linux和unix
调个网络嗅探器的程序 出错了
来源: 互联网 发布时间:2017-01-23
本文导语: ]liang@ubuntu:~/Documents/6$ cat main.c #include "rawsocsniffer.h" //#include #include #include using namespace std; int main(int argc, char ** argv) { //rawsocsniffer sniffer(htons(ETH_P_ALL)); rawsocsniffer sniffer(htons(0x0003)); char ch; ...
]liang@ubuntu:~/Documents/6$ cat main.c
#include "rawsocsniffer.h"
//#include
#include
#include
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
#include "rawsocsniffer.h"
//#include
#include
#include
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