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

C++ pcap_breakloop函数代码示例

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

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



在下文中一共展示了pcap_breakloop函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: signal_alarm

static void
signal_alarm (int signo)
{
    extern enum STATE state;
    extern char dev_if_name[];

    switch (state) {
        case ONLINE:
            keep_alive();
            alarm(30);
            break;

        case STARTED:
            fprintf(stderr, "\n&&Error: Packet sent but no reply. Please check network link to %s.\n", dev_if_name);
            pcap_breakloop (handle);
            break;

        case STATUS_ERROR:
            if (exit_counter) {
                exit_counter--;
                fprintf(stdout, "Please wait until session ends ... %2d\r", exit_counter);
                fflush (stdout);
                alarm(1);
            }
            else {
                fprintf(stdout, "\n&&Info: Program Exit.         \n");
                pcap_breakloop (handle);
            }
            break;

        default:
            break;
    }
}
开发者ID:BGCX261,项目名称:zruijie4gzhu-svn-to-git,代码行数:34,代码来源:main.c


示例2: action_eapol_failre

void
action_eapol_failre(const struct eap_header *eap_head,
                        const struct pcap_pkthdr *packetinfo,
                        const uint8_t *packet)
{
    extern int          background;
    extern int          exit_flag;
    extern pthread_t    exit_waiter_id;

    state = READY;
    fprintf(stdout, ">>Protocol: EAP_FAILURE\n");
    if(state == ONLINE){
        fprintf(stdout, "&&Info: SERVER Forced Logoff\n");
    }
    if (state == STARTED){
        fprintf(stdout, "&&Info: Invalid Username or Client info mismatch.\n");
    }
    if (state == ID_AUTHED){
        fprintf(stdout, "&&Info: Invalid Password.\n");
    }
    print_server_info (packet, packetinfo->caplen, EAP_FAILURE);
    if (exit_flag) {
        fprintf(stdout, "&&Info: Session Ended.\n");
        pcap_breakloop (handle);
    }
    else{
        exit_flag = 1;
        if (pthread_create (&exit_waiter_id, NULL,
                    thread_wait_exit, NULL) != 0) {
            fprintf(stderr, "@@Fatal ERROR: Thread failure.\n");
            exit (EXIT_FAILURE);
        }
    }
}
开发者ID:BGCX261,项目名称:zruijie4gzhu-svn-to-git,代码行数:34,代码来源:eap_protocol.c


示例3: ewpcap_error

void
ewpcap_error(EWPCAP_STATE *ep, char *msg)
{
    int rv = 0;

    if (ep->p == NULL)
        return;

    /* {ewpcap_error, Ref, Error} */
    rv = enif_send(
             NULL,
             &ep->pid,
             ep->env,
             enif_make_tuple3(ep->env,
                              atom_ewpcap_error,
                              enif_make_copy(ep->env, ep->ref),
                              enif_make_string(ep->env, msg, ERL_NIF_LATIN1)
                             )
         );

    if (!rv)
        pcap_breakloop(ep->p);

    enif_clear_env(ep->env);
}
开发者ID:hfeeki,项目名称:ewpcap,代码行数:25,代码来源:ewpcap.c


示例4: PcapCallbackLoop

static void PcapCallbackLoop(char *user, struct pcap_pkthdr *h, u_char *pkt)
{
    SCEnter();

    PcapThreadVars *ptv = (PcapThreadVars *)user;
    Packet *p = PacketGetFromQueueOrAlloc();
    struct timeval current_time;

    if (unlikely(p == NULL)) {
        SCReturn;
    }

    PKT_SET_SRC(p, PKT_SRC_WIRE);
    p->ts.tv_sec = h->ts.tv_sec;
    p->ts.tv_usec = h->ts.tv_usec;
    SCLogDebug("p->ts.tv_sec %"PRIuMAX"", (uintmax_t)p->ts.tv_sec);
    p->datalink = ptv->datalink;

    ptv->pkts++;
    ptv->bytes += h->caplen;
    (void) SC_ATOMIC_ADD(ptv->livedev->pkts, 1);
    p->livedev = ptv->livedev;

    if (unlikely(PacketCopyData(p, pkt, h->caplen))) {
        TmqhOutputPacketpool(ptv->tv, p);
        SCReturn;
    }

    switch (ptv->checksum_mode) {
        case CHECKSUM_VALIDATION_AUTO:
            if (ptv->livedev->ignore_checksum) {
                p->flags |= PKT_IGNORE_CHECKSUM;
            } else if (ChecksumAutoModeCheck(ptv->pkts,
                        SC_ATOMIC_GET(ptv->livedev->pkts),
                        SC_ATOMIC_GET(ptv->livedev->invalid_checksums))) {
                ptv->livedev->ignore_checksum = 1;
                p->flags |= PKT_IGNORE_CHECKSUM;
            }
            break;
        case CHECKSUM_VALIDATION_DISABLE:
            p->flags |= PKT_IGNORE_CHECKSUM;
            break;
        default:
            break;
    }

    if (TmThreadsSlotProcessPkt(ptv->tv, ptv->slot, p) != TM_ECODE_OK) {
        pcap_breakloop(ptv->pcap_handle);
        ptv->cb_result = TM_ECODE_FAILED;
    }

    /* Trigger one dump of stats every second */
    TimeGet(&current_time);
    if (current_time.tv_sec != ptv->last_stats_dump) {
        PcapDumpCounters(ptv);
        ptv->last_stats_dump = current_time.tv_sec;
    }

    SCReturn;
}
开发者ID:norg,项目名称:suricata,代码行数:60,代码来源:source-pcap.c


示例5: cb_byte_buffer_dispatch

/**
 * ByteBuffer dispatcher that allocates a new java.nio.ByteBuffer and dispatches
 * it to java listener.
 */
void cb_byte_buffer_dispatch(u_char *user, const pcap_pkthdr *pkt_header,
		const u_char *pkt_data) {

	cb_byte_buffer_t *data = (cb_byte_buffer_t *)user;

	JNIEnv *env = data->env;

	setJMemoryPhysical(env, data->header, toLong((void*)pkt_header));

	jobject buffer = env->NewDirectByteBuffer((void *)pkt_data,
			pkt_header->caplen);
	if (buffer == NULL) {
		return;
	}

	env->CallVoidMethod(
			data->obj,
			data->mid,
			(jobject) data->header,
			(jobject) buffer,
			(jobject) data->user);

	env->DeleteLocalRef(buffer);

	if (env->ExceptionCheck() == JNI_TRUE) {
		data->exception = env->ExceptionOccurred();
		pcap_breakloop(data->p);
	}
}
开发者ID:HevLfreis,项目名称:Devicejudge,代码行数:33,代码来源:jnetpcap_utils.cpp


示例6: pcap_breakloop

void TrainDialog::timerFired() {
  progressBar->setValue(progressBar->value() + 1);
  std::cout << "Ticking: " << progressBar->value();
  if (progressBar->value() == TRAIN_TIME_S) {
    pcap_breakloop(PacketSniffer::instance()->handle);
  }
}
开发者ID:JasonZigelbaum,项目名称:Outgoing-Packet-Tool,代码行数:7,代码来源:train-dialog.cpp


示例7: 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


示例8: shutdown_all

void shutdown_all(int sig)
{
	fprintf(stdout,"Leaving...\n");

	if (0 != talker) {
		send_process('L'); /** send leave */
	}

	send_process('M'); /** mrp disconnect */
	close(control_socket);

	if (NULL != handle) {
		pcap_breakloop(handle);
		pcap_close(handle);
	}

#ifdef LIBSND
	if (NULL != snd_file) {
		sf_write_sync(snd_file);
		sf_close(snd_file);
	}
#endif

	if (NULL != client) {
		fprintf(stdout, "jack\n");
		jack_client_close(client);
		jack_ringbuffer_free(ringbuffer);
	}

	exit(0);
}
开发者ID:GerryKurz,项目名称:Open-AVB,代码行数:31,代码来源:jack_listener.c


示例9: pcap_breakloop

void CommsThread::setNetworkInterface(int value) {
    if (value != interfaceNumber && scheduledNewInterface == false) {
        //qDebug() << "got signal from UI";
        scheduledNewInterface = true;
        interfaceNumber = value;

        if (fp != NULL) {
            pcap_breakloop(fp);
            pcap_close(fp);
        }

        streamManager.removeAll();

        if (interfaceTimeout == NULL) {
            interfaceTimeout = new QTimer(this);
            interfaceTimeout->setInterval(NETWORK_INTERFACE_OFF_DELAY);
            interfaceTimeout->setSingleShot(true);
            connect(interfaceTimeout, SIGNAL(timeout()), SLOT(timerDone()));
        }

        if (interfaceTimeout->isActive()) {
            interfaceTimeout->setInterval(NETWORK_INTERFACE_OFF_DELAY);
            qDebug() << interfaceTimeout;
        }
        else {
            interfaceTimeout->start();
        }

        // TODO still not correct: "left over" data in table
        //QTimer::singleShot(NETWORK_INTERFACE_OFF_DELAY, this, SLOT(timerDone()));   // allow time for network interface to stop
    }
}
开发者ID:UIKit0,项目名称:discover,代码行数:32,代码来源:CommsThread.cpp


示例10: CatchAlarm

/* Function handlet for SIGALRM */
void CatchAlarm(int signum)     
{
    
	printf("\n\t\tTIMEOUT :-(\n");
	pcap_breakloop(descr);
    	pcap_close(descr);
}
开发者ID:anujakench,项目名称:Final-Year-Project,代码行数:8,代码来源:master.c


示例11: capture_close

void
capture_close()
{
    capture_info_t *capinfo;

    // Nothing to close
    if (vector_count(capture_cfg.sources) == 0)
        return;

    // Stop all captures
    vector_iter_t it = vector_iterator(capture_cfg.sources);
    while ((capinfo = vector_iterator_next(&it))) {
        //Close PCAP file
        if (capinfo->handle) {
            pcap_breakloop(capinfo->handle);
            pthread_join(capinfo->capture_t, NULL);
            pcap_close(capinfo->handle);
        }
    }

    // Close dump file
    if (capture_cfg.pd) {
        dump_close(capture_cfg.pd);
    }
}
开发者ID:cruzccl,项目名称:sngrep,代码行数:25,代码来源:capture.c


示例12: p_breakloop

static PyObject * p_breakloop (PyObject *self, PyObject *args)
{
  pcap_t * ppcap;
  if (!PyArg_ParseTuple(args, "l", (long int*)&ppcap)) return NULL;
  pcap_breakloop(ppcap);
  Py_RETURN_NONE;
}
开发者ID:14gr1010,项目名称:software,代码行数:7,代码来源:pxpcap.cpp


示例13: unload_module

static int unload_module(void) {
	unsigned int i = 0;

	LNOTICE("unloaded module %s", module_name);

	for (i = 0; i < profile_size; i++) {

		if(sniffer_proto[i]) {
  		    pcap_breakloop(sniffer_proto[i]);
  		    pthread_join(call_thread[i],NULL);
		}

		if (reasm[i] != NULL) {
                	reasm_ip_free(reasm[i]);  
                        reasm[i] = NULL;
                }

                if (tcpreasm[i] != NULL) {
                        tcpreasm_ip_free(tcpreasm[i]);
                        tcpreasm[i] = NULL;
                }


		free_profile(i);
	}
	/* Close socket */
	//pcap_close(sniffer_proto);
	return 0;
}
开发者ID:mslehto,项目名称:captagent,代码行数:29,代码来源:socket_pcap.c


示例14: PcapFileCallbackLoop

void PcapFileCallbackLoop(char *user, struct pcap_pkthdr *h, u_char *pkt) {
    SCEnter();

    PcapFileThreadVars *ptv = (PcapFileThreadVars *)user;
    Packet *p = PacketGetFromQueueOrAlloc();

    if (unlikely(p == NULL)) {
        SCReturn;
    }
    PACKET_PROFILING_TMM_START(p, TMM_RECEIVEPCAPFILE);

    p->ts.tv_sec = h->ts.tv_sec;
    p->ts.tv_usec = h->ts.tv_usec;
    SCLogDebug("p->ts.tv_sec %"PRIuMAX"", (uintmax_t)p->ts.tv_sec);
    p->datalink = pcap_g.datalink;
    p->pcap_cnt = ++pcap_g.cnt;

    ptv->pkts++;
    ptv->bytes += h->caplen;

    if (unlikely(PacketCopyData(p, pkt, h->caplen))) {
        TmqhOutputPacketpool(ptv->tv, p);
        PACKET_PROFILING_TMM_END(p, TMM_RECEIVEPCAPFILE);
        SCReturn;
    }
    PACKET_PROFILING_TMM_END(p, TMM_RECEIVEPCAPFILE);

    if (TmThreadsSlotProcessPkt(ptv->tv, ptv->slot, p) != TM_ECODE_OK) {
        pcap_breakloop(pcap_g.pcap_handle);
        ptv->cb_result = TM_ECODE_FAILED;
    }

    SCReturn;
}
开发者ID:gcordrey,项目名称:suricata,代码行数:34,代码来源:source-pcap-file.c


示例15: sigint_handler

void sigint_handler(int signum)
{
	fprintf(stdout,"Leaving...\n");
	
	if (0 != talker)
		send_leave();

	if (2 > control_socket)
	{
		close(control_socket);
		mrp_disconnect();
	}

#ifdef PCAP
	if (NULL != handle) 
	{
		pcap_breakloop(handle);
		pcap_close(handle);
	}
#endif
	
#ifdef LIBSND
	sf_write_sync(snd_file);
	sf_close(snd_file);
#endif
}
开发者ID:MamataBhat,项目名称:Open_AVB,代码行数:26,代码来源:simple_listener.c


示例16: terminate

void terminate() {
    if (handle != 0) {
        pcap_breakloop(handle);
        printf("terminate!\n");
    }
    pcap_close(handle);
}
开发者ID:1057437122,项目名称:hello-openwrt,代码行数:7,代码来源:parser.c


示例17: ctrl_c

void ctrl_c(){
	printf("Exiting\n");
	fprintf(file,"r_sum:%d,s_sum:%d\n",r_sum,s_sum);
	pcap_breakloop(handle);
	pcap_close(handle);
	exit(0);
}
开发者ID:simondchen,项目名称:codebase,代码行数:7,代码来源:linkcap.c


示例18: tcp_kill_cb

static void
tcp_kill_cb(u_char *user, const struct pcap_pkthdr *pcap, const u_char *pkt)
{
	struct libnet_ipv4_hdr *ip;
	struct libnet_tcp_hdr *tcp;
	char ctext[64];
	u_int32_t seq, win;
	int i, len;
	libnet_t *l;

	l = (libnet_t *)user;
	pkt += pcap_off;
	len = pcap->caplen - pcap_off;

	ip = (struct libnet_ipv4_hdr *)pkt;
	if (ip->ip_p != IPPROTO_TCP)
		return;
	
	tcp = (struct libnet_tcp_hdr *)(pkt + (ip->ip_hl << 2));
	if (tcp->th_flags & (TH_SYN|TH_FIN|TH_RST))
		return;

	seq = ntohl(tcp->th_ack);
	win = ntohs(tcp->th_win);
	
	snprintf(ctext, sizeof(ctext), "%s:%d > %s:%d:",
		 libnet_addr2name4(ip->ip_src.s_addr, LIBNET_DONT_RESOLVE),
		 ntohs(tcp->th_sport),
		 libnet_addr2name4(ip->ip_dst.s_addr, LIBNET_DONT_RESOLVE),
		 ntohs(tcp->th_dport));
	
	for (i = 0; i < Opt_severity; i++) {
		seq += (i * win);
		
		libnet_clear_packet(l);
		
		libnet_build_tcp(ntohs(tcp->th_dport), ntohs(tcp->th_sport),
				 seq, 0, TH_RST, 0, 0, 0, LIBNET_TCP_H, 
				 NULL, 0, l, 0);
		
		libnet_build_ipv4(LIBNET_IPV4_H + LIBNET_TCP_H, 0,
				  libnet_get_prand(LIBNET_PRu16), 0, 64,
				  IPPROTO_TCP, 0, ip->ip_dst.s_addr,
				  ip->ip_src.s_addr, NULL, 0, l, 0);
		
		if (libnet_write(l) < 0)
			warn("write");
		
		fprintf(stderr, "%s R %lu:%lu(0) win 0\n",
                        ctext,
                        (unsigned long) seq,
                        (unsigned long) seq);
	}

        ++kill_counter;
        if (Opt_max_kill && kill_counter >= Opt_max_kill) {
          pcap_breakloop(pd);
        }
}
开发者ID:beaufour,项目名称:tcpkill,代码行数:59,代码来源:tcpkill.c


示例19: ctrl_c

/* gracefully handle a Control C */
void
ctrl_c ( )
{
  printf ("Exiting\n");
  pcap_breakloop (handle);  /* tell pcap_loop or pcap_dispatch to stop capturing */
  pcap_close(handle);
  return;
}
开发者ID:liqinliqin,项目名称:c,代码行数:9,代码来源:arpsniff.c


示例20: stop_fun

static void stop_fun()
{
	pthread_kill(cappid, SIGUSR1);
	if (pd != NULL) {
		pcap_breakloop(pd);
		pd = NULL;
	}
}
开发者ID:ChenyuanHu,项目名称:nptool,代码行数:8,代码来源:main.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ pcap_close函数代码示例发布时间:2022-05-30
下一篇:
C++ pcap_activate函数代码示例发布时间: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