#include <locale>
#include <libintl.h>
#include <iostream>
#include <string>
#include <pcap.h>
#define _(data) gettext(data)
#include "ether.hpp"
int main(int argc, char* argv[])
{
std::locale host_locale("");
textdomain("pcap");
bindtextdomain("libpcap", "language");
char error_buf[PCAP_ERRBUF_SIZE];
char* device_name = pcap_lookupdev(error_buf);
if (device_name == NULL)
{
std::cout<<error_buf<<std::endl;
return -1;
}
std::cout<<device_name<<std::endl;
/*
bpf_u_int32 net;
bpf_u_int32 mask;
if (pcap_lookupnet(device_name, &net, &mask, error_buf) == -1)
{
std::cout<<error_buf<<std::endl;
return -1;
}
*/
pcap_t* session = pcap_open_live(device_name, BUFSIZ, 1, -1, error_buf);
if (session == NULL)
{
std::cout<<error_buf<<std::endl;
return -1;
}
/*
bpf_program fp;
const char* filter = "tcp";
if (pcap_compile(session, &fp, filter, 1, mask) < 0)
{
std::cout<<pcap_geterr(session)<<std::endl;
pcap_close(session);
return -1;
}
if (pcap_setfilter(session, &fp) < 0)
{
std::cout<<pcap_geterr(session)<<std::endl;
pcap_close(session);
return -1;
}*/
if (pcap_loop(session, -1, del_ether, NULL) == -1)
{
std::cout<<pcap_geterr(session)<<std::endl;
pcap_close(session);
return -1;
}
return 0;
}
#include <libintl.h>
#include <iostream>
#include <string>
#include <pcap.h>
#define _(data) gettext(data)
#include "ether.hpp"
int main(int argc, char* argv[])
{
std::locale host_locale("");
textdomain("pcap");
bindtextdomain("libpcap", "language");
char error_buf[PCAP_ERRBUF_SIZE];
char* device_name = pcap_lookupdev(error_buf);
if (device_name == NULL)
{
std::cout<<error_buf<<std::endl;
return -1;
}
std::cout<<device_name<<std::endl;
/*
bpf_u_int32 net;
bpf_u_int32 mask;
if (pcap_lookupnet(device_name, &net, &mask, error_buf) == -1)
{
std::cout<<error_buf<<std::endl;
return -1;
}
*/
pcap_t* session = pcap_open_live(device_name, BUFSIZ, 1, -1, error_buf);
if (session == NULL)
{
std::cout<<error_buf<<std::endl;
return -1;
}
/*
bpf_program fp;
const char* filter = "tcp";
if (pcap_compile(session, &fp, filter, 1, mask) < 0)
{
std::cout<<pcap_geterr(session)<<std::endl;
pcap_close(session);
return -1;
}
if (pcap_setfilter(session, &fp) < 0)
{
std::cout<<pcap_geterr(session)<<std::endl;
pcap_close(session);
return -1;
}*/
if (pcap_loop(session, -1, del_ether, NULL) == -1)
{
std::cout<<pcap_geterr(session)<<std::endl;
pcap_close(session);
return -1;
}
return 0;
}