本文整理汇总了C++中pcap_dump_close函数的典型用法代码示例。如果您正苦于以下问题:C++ pcap_dump_close函数的具体用法?C++ pcap_dump_close怎么用?C++ pcap_dump_close使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pcap_dump_close函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: qWarning
/**
* @brief Stop data capturing
*/
void DPDKPort::stopCapture()
{
if(rxState != XTS_RUN)
{
qWarning("Receiver already stopped");
return;
}
quint32 captureDataSize;
dpdk_stop_rx(portId, &captureDataSize);
uint32_t offset = 0;
struct pcap_pkthdr *pHdr = NULL;
u_char *data = NULL;
while (offset < captureDataSize)
{
pHdr = (struct pcap_pkthdr *)(captureBuffer + offset);
offset += sizeof(struct pcap_pkthdr);
data = (u_char *)(captureBuffer + offset);
offset += pHdr->len;
pcap_dump((u_char*)pDumper, pHdr, data);
}
pcap_dump_close(pDumper);
pcap_close(pHandle);
rxState = XTS_DONE;
}
示例2: pcap_file_close
//CLOSE PCAP FILE
void pcap_file_close(t_pcap_file *x){
t_float c;
int conn;
conn=0;
post("pcap: device was not connected NOT connected.");
if (x->x_reading_file == 1){
pcap_close(x->x_pcap_pd.x_handle);
x->x_reading_file=0;
c=x->x_reading_file;
outlet_float(x->x_outlet1,c);
post("pcap: Ok file %s closed.",x->x_rfilename);
conn=1;
}else{
post("pcap: No file opened.");
}
//close dump file if it is open.
if (conn == 1){
if (x->x_pcap_pd.x_write_file==1){
post("pcap: Ok dumpfile %s closed.",x->x_pcap_pd.x_wfilename);
pcap_dump_close(x->x_pcap_pd.x_dumpfile);
x->x_pcap_pd.x_write_file=0;
}
}
x->x_pcap_pd.x_running=0;
}
示例3: _free_pcap
/** Talloc destructor to free pcap resources associated with a handle.
*
* @param pcap to free.
* @return 0
*/
static int _free_pcap(fr_pcap_t *pcap) {
switch (pcap->type) {
case PCAP_INTERFACE_IN:
case PCAP_INTERFACE_OUT:
case PCAP_FILE_IN:
case PCAP_STDIO_IN:
if (pcap->handle) {
pcap_close(pcap->handle);
if (pcap->fd > 0) {
close(pcap->fd);
}
}
break;
case PCAP_FILE_OUT:
case PCAP_STDIO_OUT:
if (pcap->dumper) {
pcap_dump_flush(pcap->dumper);
pcap_dump_close(pcap->dumper);
}
break;
case PCAP_INVALID:
break;
}
return 0;
}
示例4: pcap_breakloop
void Pcap::destroy()
{
// if the pcap is not open, do not need to destroy;
if(!isOpen)
{
return;
}
pcap_breakloop(hd);
pthread_join(process_thread, NULL);
// kill the capturing thread!
//pthread_cancel(pcap_.process_thread);
if(pd != NULL)
{
pcap_dump_flush(pd);
pcap_dump_close(pd);
pd = NULL;
}
pcap_close(hd);
hd = NULL;
isOpen = false;
logger->PrintDebug("[%s:%d] Pcap deleted\n", __FILE__, __LINE__);
}
示例5: main
int main(int argc,char *argv[]){
char *dev, errbuf[PCAP_ERRBUF_SIZE];
int i = 0;
struct bpf_program filter;
char filter_app[] = "src host 192.168.8.144 && arp ";
bpf_u_int32 mask;
bpf_u_int32 net;
pcap_t *handle = NULL;
pcap_dumper_t *pcap_dumper = NULL;
dev = pcap_lookupdev(errbuf);
if(dev == NULL){
fprintf(stderr,"couldn't find default device: %s\n",errbuf);
return(2);
}
prjntf("Device: %s\n",dev);
pcap_lookupnet(dev,&net,&mask,errbuf);
handle = pcap_open_ljve(dev,BUFSIZ,1,0,errbuf);
pcap_compjle(handle,&filter,filter_app,0,net);
pcap_setfjlter(handle,&filter);
pcap_dumper = pcap_dump_open(handle,"ljbcaptest1.pcap");
prjntf("%d*******\n",i);
j = pcap_loop(handle,10,pcap_dump,(u_char *)pcap_dumper);
pcap_dump_flush(pcap_dumper);
pcap_dump_close(pcap_dumper);
prjntf("%d*******\n",i);
pcap_close(handle);
return(0);
}
示例6: dump_close
void
dump_close(pcap_dumper_t *pd)
{
if (!pd)
return;
pcap_dump_close(pd);
}
示例7: close_pcap_handler
static void close_pcap_handler(pcap_dumper_t *pdumper)
{
if(NULL == pdumper)
return;
pcap_dump_close(pdumper);
}
示例8: dumper_too_many_open_files
static void dumper_too_many_open_files(struct shared_dumper **d)
{
struct session *elt;
unsigned int oldest_ten_percent;
oldest_ten_percent = sessions_count / 10;
if (EMFILE == errno && oldest_ten_percent) {
for (elt = first_session; NULL != elt; elt = elt->next) {
if (NULL != elt->dumper->filedesc) {
pcap_dump_close(elt->dumper->filedesc);
elt->dumper->filedesc = NULL;
--dumper_fd_count;
if (!--oldest_ten_percent)
break;
}
}
(*d)->filedesc = pcap_dump_open(nids_params.pcap_desc, (*d)->filename);
}
if (NULL == (*d)->filedesc) {
fprintf(stderr,
"pcap_dump_open: %s: %s\n",
(*d)->filename,
pcap_geterr(nids_params.pcap_desc));
exit(-1);
}
}
示例9: main
int
main(int argc, char *argv[])
{
if(argc < 2)
{
printf("Usage: %s -i interface -f file\n", argv[0]);
return (1);
}
int opt;
while((opt = getopt(argc, argv, ":i:f:h")) != -1)
{
switch(opt)
{
case 'h':
printf("Usage: %s -i interface -f file\n", argv[0]);
return (1);
case 'i':
interface = optarg;
break;
case 'f':
file = optarg;
break;
default: /* '?' */
printf("Usage: %s -i interface -f file\n", argv[0]);
return (1);
}
}
if(interface == NULL)
{
printf("Usage: %s -i interface -f file\n", argv[0]);
return (1);
}
else if(file == NULL)
{
file = "trace.pcap";
}
printf("Beginning capturing...\n");
char errbuf[PCAP_ERRBUF_SIZE];
memset(errbuf, 0, PCAP_ERRBUF_SIZE);
pcap_t *cap = NULL;
struct pcap_pkthdr pkthdr;
cap = pcap_open_live(interface, 65535, 0, 1000, errbuf);
if( cap == NULL)
{
printf("%s\r",errbuf);
exit(1);
}
pcap_dumper_t* dumper;
dumper = pcap_dump_open(cap, file);
pcap_loop(cap, -1, proc_pkt, dumper);
pcap_dump_close(dumper);
pcap_close(cap);
return 0;
}
示例10: psirp_debug_cleanup
void
psirp_debug_cleanup(void) {
#ifdef HAVE_LIBPCAP
if (NULL != dumpfd) {
pcap_dump_close(dumpfd);
}
#endif /* HAVE_LIBPCAP */
}
示例11: pcap_io_close
void pcap_io_close()
{
if(packet_log)
fclose(packet_log);
if(dump_pcap)
pcap_dump_close(dump_pcap);
pcap_close(adhandle);
pcap_io_running=0;
}
示例12: royparse_stop
void royparse_stop()
{
if (q_out != 0) {
pcap_close(pcap);
pcap_dump_close(q_out);
}
if (r_out != stdout)
fclose(r_out);
}
示例13: SaveAndExit
void SaveAndExit(int param)
{
if (mode == trainingMode_capture)
{
pcap_dump_close(pcapDumpStream);
}
exit(EXIT_SUCCESS);
}
示例14: msg
void PCAPExporterModule::performShutdown()
{
if (dumper) {
if (-1 == pcap_dump_flush(dumper)) {
msg(MSG_FATAL, "PCAPExporterModule: Could not flush dump file");
}
pcap_dump_close(dumper);
}
}
示例15: Java_jpcap_JpcapWriter_close
JNIEXPORT void JNICALL
Java_jpcap_JpcapWriter_close(JNIEnv *env,jobject obj){
if(pdt!=NULL){
pcap_dump_close(pdt);
free(pcdd);
pcdd=NULL;
}
pdt=NULL;
}