• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ pcap_dump_close函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中pcap_dump_close函数的典型用法代码示例。如果您正苦于以下问题:C++ pcap_dump_close函数的具体用法?C++ pcap_dump_close怎么用?C++ pcap_dump_close使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了pcap_dump_close函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:shishuhua068,项目名称:ostinato-dpdk,代码行数:35,代码来源:dpdkport.cpp


示例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;
}
开发者ID:poperbu,项目名称:pcap,代码行数:28,代码来源:pcap_file.c


示例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;
}
开发者ID:bgmilne,项目名称:freeradius-server,代码行数:35,代码来源:pcap.c


示例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__);
}
开发者ID:terry2012,项目名称:magictrain,代码行数:26,代码来源:pcapCore.cpp


示例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);  
}
开发者ID:sugarguo,项目名称:work,代码行数:29,代码来源:vimtest.c


示例6: dump_close

void
dump_close(pcap_dumper_t *pd)
{
    if (!pd)
        return;
    pcap_dump_close(pd);
}
开发者ID:jungle-boogie,项目名称:sngrep,代码行数:7,代码来源:capture.c


示例7: close_pcap_handler

static void close_pcap_handler(pcap_dumper_t *pdumper)
{
	if(NULL == pdumper)
		return;
	
	pcap_dump_close(pdumper);
}
开发者ID:misslio,项目名称:lctools,代码行数:7,代码来源:write_single_packet.c


示例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);
  }
}
开发者ID:dot-Sean,项目名称:tcpslice,代码行数:26,代码来源:sessions.c


示例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;
}
开发者ID:di3online,项目名称:http-sniffer,代码行数:59,代码来源:tracedump.c


示例10: psirp_debug_cleanup

void
psirp_debug_cleanup(void) {
#ifdef HAVE_LIBPCAP
    if (NULL != dumpfd) {
        pcap_dump_close(dumpfd);
    }
#endif /* HAVE_LIBPCAP */
}
开发者ID:srcman,项目名称:blackhawk,代码行数:8,代码来源:psirp_debug.c


示例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;
}
开发者ID:revel8n,项目名称:pcsx2,代码行数:9,代码来源:pcap_io.cpp


示例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);
}
开发者ID:DNS-OARC,项目名称:dnscap,代码行数:9,代码来源:royparse.c


示例13: SaveAndExit

void SaveAndExit(int param)
{
	if (mode == trainingMode_capture)
	{
		pcap_dump_close(pcapDumpStream);
	}

	exit(EXIT_SUCCESS);
}
开发者ID:PherricOxide,项目名称:Nova,代码行数:9,代码来源:NovaTrainer.cpp


示例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);
	}
}
开发者ID:BackupTheBerlios,项目名称:vermont-svn,代码行数:9,代码来源:PCAPExporterModule.cpp


示例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;
}
开发者ID:Paxy,项目名称:Jpcap,代码行数:9,代码来源:JpcapWriter.c


示例16: vpi_pcapdump_interface_destroy

int
vpi_pcapdump_interface_destroy(vpi_interface_t* _vi)
{
    VICAST(vi, _vi);
    pcap_dump_close(vi->pcap_dumper);
    pcap_close(vi->pcap);
    aim_free(vi);
    return 0;
}
开发者ID:Broadcom-Switch,项目名称:of-dpa,代码行数:9,代码来源:vpi_interface_pcapdump.c


示例17: pcap_fin_output

static int pcap_fin_output(libtrace_out_t *libtrace)
{
    if (OUTPUT.trace.dump) {
        pcap_dump_flush(OUTPUT.trace.dump);
        pcap_dump_close(OUTPUT.trace.dump);
    }
    pcap_close(OUTPUT.trace.pcap);
    free(libtrace->format_data);
    return 0;
}
开发者ID:superpig0501,项目名称:libtrace,代码行数:10,代码来源:format_pcap.c


示例18: sigproc

void sigproc(int sig) {

	pfring_close(handle);
	pfring_breakloop(handle);
	pcap_dump_close(dumper);

	printf("\nSniffer closed. %d files written to disk.\n",filenumber);

 	exit(0);
}
开发者ID:abhishekchandratre,项目名称:project,代码行数:10,代码来源:pfring_sniffer.c


示例19: close_write_pkts_to_files

void close_write_pkts_to_files() {
    ht_kf_destory(flow_seqid_hashmap, HASH_MAP_SIZE);

    int node_idx = 0;
    for (node_idx = 0; node_idx < NUM_SENDERS; ++node_idx) {
        pcap_close(pd[node_idx]);
        pcap_dump_close(pdumper[node_idx]);
        fclose(fp[node_idx]);
    }
}
开发者ID:cfdream,项目名称:CM_testbed_code,代码行数:10,代码来源:writePacketToPcapFile.c


示例20: pcap_dealloc

static void
pcap_dealloc(register pcapdumper* pp)
{
  if ( pp->dumper )
    pcap_dump_close(pp->dumper);

  pp->dumper = NULL;

  PyObject_Del(pp);
}
开发者ID:neirbowj,项目名称:pcapy,代码行数:10,代码来源:pcapdumper.c



注:本文中的pcap_dump_close函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ pcap_dump_open函数代码示例发布时间:2022-05-30
下一篇:
C++ pcap_dump函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap