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


C++ dump_packet函数代码示例

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


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

示例1: main

int
main(int argc, char *argv[])
{
	int			 ch, i, r;
	uint16_t		 type = T_A;
	char			 buf[1024], *host;

	while((ch = getopt(argc, argv, "et:")) !=  -1) {
		switch(ch) {
		case 'e':
			long_err += 1;
			break;
		case 't':
			if ((type = strtotype(optarg)) == 0)
				usage();
			break;
		default:
			usage();
			/* NOTREACHED */
		}
	}
	argc -= optind;
	argv += optind;

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

		if (i)
			printf("\n");

		printf("===> \"%s\"\n", argv[i]);
		host = gethostarg(argv[i]);

		errno = 0;
		h_errno = 0;
		gai_errno = 0;
		rrset_errno = 0;

		r = res_mkquery(QUERY, host, C_IN, type, NULL, 0, NULL, buf, sizeof(buf));
		if (r != -1) {
			dump_packet(buf, r);
			printf(";; MSG SIZE %i\n", r);
		}
		print_errors();
	}

	return (0);
}
开发者ID:Basskrapfen,项目名称:openbsd,代码行数:47,代码来源:res_mkquery.c

示例2: dump_to_file

void dump_to_file(struct dump_file *dump_file, 
                  void *pip, 
                  void *plast)
{
    //open a new dump file
    if (dump_file->win_start.tv_sec == -1 &&
        dump_file->win_start.tv_usec == -1) {
        dump_file->fp = new_dump_file(dump_file);
        dump_file->win_start.tv_sec = current_time.tv_sec;
        dump_file->win_start.tv_usec = current_time.tv_usec;
    }
    else if (slice_win > 0) {
        //check if current dump window is ended
        double diff = elapsed(dump_file->win_start, current_time) / 1000000;
        if (diff >= slice_win) {
#ifdef HAVE_ZLIB
	    if (zlib_dump)
             { 
               gzclose(dump_file->fp);
	     }
	    else
#endif
             { 
	       fflush(dump_file->fp);
               fclose(dump_file->fp);
	     }
            dump_file->seq_num++;

            // compute the current timestamp of dumping window
            // considering that there can be windows without traffic
            // associated
            dump_file->win_start.tv_sec += 
                ((long)diff / slice_win) * slice_win;
            dump_file->fp = new_dump_file(dump_file);
        }
    }

    //dump current packet
    dump_packet(dump_file->fp, pip, plast);

    //if (timestamp.tv_sec == -1) {
    //    fprintf(fp_log, "dump start: %s\n", Timestamp());
    //}
    last_dump_tm = current_time;
    if (first_dump_tm.tv_sec == -1) 
        first_dump_tm = current_time;
}
开发者ID:andreaaraldo,项目名称:mytstat,代码行数:47,代码来源:dump.c

示例3: flush_read

int flush_read(struct astribank_device *astribank)
{
	char		tmpbuf[BUFSIZ];
	int		ret;

	DBG("starting...\n");
	memset(tmpbuf, 0, BUFSIZ);
	ret = recv_usb(astribank, tmpbuf, BUFSIZ, 1);
	if(ret < 0 && ret != -ETIMEDOUT) {
		ERR("ret=%d\n", ret);
		return ret;
	} else if(ret > 0) {
		DBG("Got %d bytes:\n", ret);
		dump_packet(LOG_DEBUG, DBG_MASK, __FUNCTION__, tmpbuf, ret);
	}
	return 0;
}
开发者ID:boylubis,项目名称:ctsoft,代码行数:17,代码来源:astribank_usb.c

示例4: xusb_flushread

int xusb_flushread(struct xusb *xusb)
{
	char		tmpbuf[BUFSIZ];
	int		ret;

	DBG("starting...\n");
	memset(tmpbuf, 0, BUFSIZ);
	ret = xusb_recv(xusb, tmpbuf, BUFSIZ, 1);
	if(ret < 0 && ret != -ETIMEDOUT) {
		ERR("ret=%d\n", ret);
		return ret;
	} else if(ret > 0) {
		DBG("Got %d bytes:\n", ret);
		dump_packet(LOG_DEBUG, DBG_MASK, __FUNCTION__, tmpbuf, ret);
	}
	return 0;
}
开发者ID:YongHoJang,项目名称:dahdi-tools,代码行数:17,代码来源:xusb.c

示例5: recv_usb

int recv_usb(const char *msg, struct my_usb_device *mydev, char *buf, size_t len, int timeout)
{
	int	ret;

	if(mydev->my_ep_in & USB_ENDPOINT_OUT) {
		ERR("recv_usb called with an output endpoint 0x%x\n", mydev->my_ep_in);
		return -EINVAL;
	}
	ret = usb_bulk_read(mydev->handle, mydev->my_ep_in, buf, len, timeout);
	if(ret < 0) {
		ERR("bulk_read from endpoint 0x%x failed: %s\n", mydev->my_ep_in, usb_strerror());
		return ret;
	}
	if(verbose >= LOG_DEBUG)
		dump_packet(msg, buf, ret);
	return ret;
}
开发者ID:commshare,项目名称:squeezeterisk,代码行数:17,代码来源:fpga_load.c

示例6: xusb_recv

int xusb_recv(struct xusb *xusb, char *buf, size_t len, int timeout)
{
	int	ret;

	if(EP_IN(xusb) & USB_ENDPOINT_OUT) {
		ERR("%s called with an output endpoint 0x%x\n", __FUNCTION__, EP_IN(xusb));
		return -EINVAL;
	}
	ret = usb_bulk_read(xusb->handle, EP_IN(xusb), buf, len, timeout);
	if(ret < 0) {
		DBG("bulk_read from endpoint 0x%x failed: (%d) %s\n",
			EP_IN(xusb), ret, usb_strerror());
		memset(buf, 0, len);
		return ret;
	}
	dump_packet(LOG_DEBUG, DBG_MASK, __FUNCTION__, buf, ret);
	return ret;
}
开发者ID:YongHoJang,项目名称:dahdi-tools,代码行数:18,代码来源:xusb.c

示例7: test_rtsp

int test_rtsp(char *url)
{
    int err;
    AVFormatContext *ic = NULL;
    AVInputFormat *fmt = &ff_rtsp_demuxer;
    AVFormatParameters params, *ap = &params;
    AVPacket cur_pkt, *pkt = &cur_pkt;

    memset(ap, 0, sizeof(*ap));

    ic = avformat_alloc_context();
    if(ic == NULL)
        return 0;

    ic->iformat = fmt;
    strcpy(ic->filename, url);

    if (fmt->priv_data_size > 0) {
        ic->priv_data = av_mallocz(fmt->priv_data_size);
        if (!ic->priv_data) {
            return 0;
        }
    } else {
        ic->priv_data = NULL;
    }

    err = ic->iformat->read_header(ic, ap);
    if (err < 0)
        return 0;

    while(1) {
        av_init_packet(pkt);
        //err = ic->iformat->read_packet(ic, pkt);
        err = av_read_packet(ic, pkt);
        if (err < 0)
            return 0;
        printf("stream: %d, len: %d, pts: %lld\n", pkt->stream_index, pkt->size, pkt->pts);
        dump_packet(pkt);
        if (pkt->destruct) pkt->destruct(pkt);
        pkt->data = NULL; pkt->size = 0;
    }

    return 1;
}
开发者ID:FreeSrk,项目名称:omx,代码行数:44,代码来源:test.c

示例8: TRACE

status_t
IPCP::Send(struct mbuf *packet, uint16 protocolNumber)
{
	TRACE("IPCP: Send(0x%X)\n", protocolNumber);
	
	if((protocolNumber == IP_PROTOCOL && State() == PPP_OPENED_STATE)
			|| protocolNumber == IPCP_PROTOCOL) {
#if DEBUG
		dump_packet(packet, "outgoing");
#endif
		Interface().UpdateIdleSince();
		return SendToNext(packet, protocolNumber);
	}
	
	ERROR("IPCP: Send() failed because of wrong state or protocol number!\n");
	
	m_freem(packet);
	return B_ERROR;
}
开发者ID:DonCN,项目名称:haiku,代码行数:19,代码来源:Protocol.cpp

示例9: dump_packet

status_t
IPCP::ReceiveIPPacket(struct mbuf *packet, uint16 protocolNumber)
{
	if(protocolNumber != IP_PROTOCOL || State() != PPP_OPENED_STATE)
		return PPP_UNHANDLED;
	
	// TODO: add VJC support (the packet would be decoded here)
	
	if (gProto[IPPROTO_IP] && gProto[IPPROTO_IP]->pr_input) {
#if DEBUG
		dump_packet(packet, "incoming");
#endif
		Interface().UpdateIdleSince();
		gProto[IPPROTO_IP]->pr_input(packet, 0);
		return B_OK;
	} else {
		ERROR("IPCP: Error: Could not find input function for IP!\n");
		m_freem(packet);
		return B_ERROR;
	}
}
开发者ID:DonCN,项目名称:haiku,代码行数:21,代码来源:Protocol.cpp

示例10: hvsi_recv_response

static void hvsi_recv_response(struct hvsi_struct *hp, uint8_t *packet)
{
	struct hvsi_query_response *resp = (struct hvsi_query_response *)packet;

	switch (hp->state) {
		case HVSI_WAIT_FOR_VER_RESPONSE:
			__set_state(hp, HVSI_WAIT_FOR_VER_QUERY);
			break;
		case HVSI_WAIT_FOR_MCTRL_RESPONSE:
			hp->mctrl = 0;
			if (resp->u.mctrl_word & HVSI_TSDTR)
				hp->mctrl |= TIOCM_DTR;
			if (resp->u.mctrl_word & HVSI_TSCD)
				hp->mctrl |= TIOCM_CD;
			__set_state(hp, HVSI_OPEN);
			break;
		default:
			printk(KERN_ERR "hvsi%i: unexpected query response: ", hp->index);
			dump_packet(packet);
			break;
	}
}
开发者ID:Antonio-Zhou,项目名称:Linux-2.6.11,代码行数:22,代码来源:hvsi.c

示例11: ipt_log_packet

static void
ipt_log_packet(u_int8_t pf,
	       unsigned int hooknum,
	       const struct sk_buff *skb,
	       const struct net_device *in,
	       const struct net_device *out,
	       const struct nf_loginfo *loginfo,
	       const char *prefix)
{
	struct sbuff *m = sb_open();

	if (!loginfo)
		loginfo = &default_loginfo;

	sb_add(m, "<%d>%sIN=%s OUT=%s ", loginfo->u.log.level,
	       prefix,
	       in ? in->name : "",
	       out ? out->name : "");
#ifdef CONFIG_BRIDGE_NETFILTER
	if (skb->nf_bridge) {
		const struct net_device *physindev;
		const struct net_device *physoutdev;

		physindev = skb->nf_bridge->physindev;
		if (physindev && in != physindev)
			sb_add(m, "PHYSIN=%s ", physindev->name);
		physoutdev = skb->nf_bridge->physoutdev;
		if (physoutdev && out != physoutdev)
			sb_add(m, "PHYSOUT=%s ", physoutdev->name);
	}
#endif

	if (in != NULL)
		dump_mac_header(m, loginfo, skb);

	dump_packet(m, loginfo, skb, 0);

	sb_close(m);
}
开发者ID:faux123,项目名称:pantech_vega_racer_2_kernel,代码行数:39,代码来源:ipt_LOG.c

示例12: l2cap_send_connectionless

int l2cap_send_connectionless(uint16_t handle, uint16_t cid, uint8_t * buffer, uint16_t len) {
    // printf("l2cap_send_connectionless\n");

    int pb = hci_non_flushable_packet_boundary_flag_supported() ? 0x00 : 0x02;

    // 0 - Connection handle : PB=pb : BC=00
    bt_store_16(packet_buffer, 0, handle | (pb << 12) | (0 << 14));
    // 2 - ACL length
    bt_store_16(packet_buffer, 2,  len + 4);
    // 4 - L2CAP packet length
    bt_store_16(packet_buffer, 4,  len + 0);
    // 6 - L2CAP channel DEST
    bt_store_16(packet_buffer, 6, cid);

    memcpy(&packet_buffer[8], buffer, len);
    hci_dump_packet(HCI_ACL_DATA_PACKET, 0, &packet_buffer[0], len + 8);

    dump_packet(HCI_ACL_DATA_PACKET, packet_buffer, len + 8);
    packet_buffer_len = len + 8;

    return 0;
}
开发者ID:ChangeTsai,项目名称:btstack,代码行数:22,代码来源:mock.c

示例13: ether_do_interrupt

static void ether_do_interrupt(void)
{
	// Call protocol handler for received packets
	EthernetPacket ether_packet;
	uint32 packet = ether_packet.addr();
	ssize_t length;
	for (;;) {

		// Read packet from Ethernet device
		length = dequeue_packet(Mac2HostAddr(packet));
		if (length < 14)
			break;

#if MONITOR
		bug("Receiving Ethernet packet (%d bytes):\n",(int)length);
		dump_packet( Mac2HostAddr(packet), length );
#endif

		// Dispatch packet
		ether_dispatch_packet(packet, length);
	}
}
开发者ID:tycho,项目名称:sheepshaver,代码行数:22,代码来源:ether_windows.cpp

示例14: nl2_send

int nl2_send(int sock, struct sockaddr_in *addr, znl2msg *msg)
{
    int i;
    int len;
    uint32_t* store;
    znl2msg *flipped;

    if (verbose >= 1)
      fprintf(stdout, "%s: sending %d bytes (message #%d %s) to %s:%d\n",
              progname,
              msg->n.znl2msg_len,
              msg->n.znl2msg_seq, type2s(msg->n.znl2msg_type),
              inet_ntoa(addr->sin_addr), ntohs(addr->sin_port));

    /* 
     * Make a copy of msg before byte flipping it. We're preserving the
     * original so that we can compare the request & reply headers.
     */
    len = msg->n.znl2msg_len;
    flipped = malloc(len);
    memcpy(flipped, msg, len);

    /* Endianess/byte ordering */
    store = (uint32_t*) flipped;
    if (flipped->n.znl2msg_type == ZNL2_SYN || flipped->n.znl2msg_type == ZNL2_FIN) {
        for (i = 0; i < (sizeof(znl2msghdr)/4+2); i++)
            store[i] = psdb_pton(store[i]);
    } else {
        for (i = 0; i < (len/4); i++)
            store[i] = psdb_pton(store[i]);
    }

    if (verbose >= 3)
        dump_packet(flipped, len);

    return sendto(sock, flipped, len, 0, (struct sockaddr *)addr,
                  sizeof(struct sockaddr_in));
}
开发者ID:elambert,项目名称:honeycomb,代码行数:38,代码来源:send.c

示例15: do_uncook_loop

void do_uncook_loop(struct anonflow *flow, struct function *flist)
{
	flist_node_t   *fn;
	struct function *next_func;
	struct headers_data *frag_data;

	flow->uncook_ready = 0;

	for (fn = flist_head(flow->client_headers); fn != NULL; fn = flist_next(fn)) {
		anon_pkthdr_t   frag_pkt_head;
		flow->decoded_packet = NULL;

		frag_data = (struct headers_data *)(fn->data);
		//fprintf(stderr,"(%d) frag_data->caplen: %d %d %x\n",ff++,frag_data->caplen,flist_size(flow->headers),frag_data);

		frag_pkt_head.caplen = frag_data->caplen;
		frag_pkt_head.wlen = frag_data->wlen;
		frag_pkt_head.ts.tv_sec = frag_data->ts.tv_sec;
		frag_pkt_head.ts.tv_usec = frag_data->ts.tv_usec;

		next_func = flist->next;

		while (next_func) {
			if (next_func->function_info->
			    process(flow, next_func->internal_data, frag_data->header,
				    &frag_pkt_head) == 0) {
				break;
			}
			next_func = next_func->next;
		}

		if (next_func == NULL && flow->output_type != NONE) {	//Flow reached its end
			dump_packet(flow, frag_data->header, &frag_pkt_head);
		}
	}

	return;
}
开发者ID:abhisoniks,项目名称:anontool-modified,代码行数:38,代码来源:tool.c


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