当前位置: 首页>>代码示例>>C++>>正文


C++ pcap_breakloop函数代码示例

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


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


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