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


C++ process_packet函数代码示例

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


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

示例1: dispose_packet

static int
dispose_packet(char *recv_buf, int recv_len, int *p_valid_flag)
{
    int             replica_num;
    char           *packet;
    bool            packet_valid = false;
    tc_ip_header_t *ip_header;

    packet = recv_buf;

    if (is_packet_needed((const char *) packet)) {

        replica_num = clt_settings.replica_num;
        ip_header   = (tc_ip_header_t *) packet;

        if (LOCALHOST == ip_header->saddr) {
            if (0 != clt_settings.lo_tf_ip) {
                ip_header->saddr = clt_settings.lo_tf_ip;
            }
        }

        if (replica_num > 1) {
            packet_valid = process_packet(true, packet, recv_len);
            replicate_packs(packet, recv_len, replica_num);
        }else{
            packet_valid = process_packet(false, packet, recv_len);
        }
    }

    if (p_valid_flag) {
        *p_valid_flag = (packet_valid == true ? 1 : 0);
    }

    return TC_OK;  
}
开发者ID:CyaLiven,项目名称:tcpcopy,代码行数:35,代码来源:tc_packets_module.c

示例2: dispose_packet

static int
dispose_packet(unsigned char *frame, int frame_len, int ip_recv_len,
               int *p_valid_flag)
{
    int             replica_num;
    bool            packet_valid = false;
    unsigned char  *packet;
    tc_ip_header_t *ip_header;

    packet = frame + ETHERNET_HDR_LEN;

    if (is_packet_needed(packet)) {

        replica_num = clt_settings.replica_num;
        ip_header   = (tc_ip_header_t *) packet;

        if (clt_settings.clt_tf_ip != 0) {
            ip_header->saddr = clt_settings.clt_tf_ip;
        }

        if (replica_num > 1) {
            packet_valid = process_packet(true, frame, frame_len);
            replicate_packs(frame, frame_len, replica_num);
        } else {
            packet_valid = process_packet(false, frame, frame_len);
        }
    }

    if (p_valid_flag) {
        *p_valid_flag = (packet_valid == true ? 1 : 0);
    }

    return TC_OK;
}
开发者ID:hanjinze,项目名称:tcpcopy,代码行数:34,代码来源:tc_packets_module.c

示例3: sizeof

void udp_data_handler::on_read(int fd)
{
    udp_packet* p = (udp_packet*)m_buf ;
    static const int UDP_RECV_SIZE = MAX_BUF_SIZE-sizeof(udp_packet) -1 ;
    do
    {
        socklen_t  addrlen = sizeof(p->addr);
        p->data_size = recvfrom(fd,p->data,UDP_RECV_SIZE,0,(sockaddr*)&p->addr,&addrlen) ;
        if(p->data_size <= 0 )
        {
            if (errno != EAGAIN &&  errno != EINTR)
            {
                handle_error(ERROR_TYPE_SYSTEM)  ;
                return ;
            }

            break ;
        }
        else
        {
            p->data[p->data_size] = 0 ;
            process_packet(p) ;
        }

    }while(m_options & OPTION_READALL) ;

}
开发者ID:freedream520,项目名称:id_server,代码行数:27,代码来源:udp_data_handler.cpp

示例4: send_faked_rst

static void 
send_faked_rst(tc_user_t *u)
{
    tc_ip_header_t   *ip_header;
    tc_tcp_header_t  *tcp_header;
    unsigned char    *p, frame[FAKE_FRAME_LEN];

    memset(frame, 0, FAKE_FRAME_LEN);
    p = frame + ETHERNET_HDR_LEN;
    ip_header  = (tc_ip_header_t *) p;
    tcp_header = (tc_tcp_header_t *) (p + IP_HEADER_LEN);

    ip_header->version  = 4;
    ip_header->ihl      = IP_HEADER_LEN/4;
    ip_header->frag_off = htons(IP_DF); 
    ip_header->ttl      = 64; 
    ip_header->protocol = IPPROTO_TCP;
    ip_header->tot_len  = htons(FAKE_MIN_IP_DATAGRAM_LEN);
    ip_header->saddr    = u->src_addr;
    ip_header->daddr    = u->dst_addr;
    tcp_header->source  = u->src_port;
    tcp_header->dest    = u->dst_port;
    tcp_header->seq     = u->exp_seq;
    tcp_header->ack_seq = u->exp_ack_seq;
    tcp_header->window  = htons(65535); 
    tcp_header->ack     = 1;
    tcp_header->rst     = 1;
    tcp_header->doff    = TCP_HEADER_DOFF_MIN_VALUE;

    process_packet(u, frame);
}
开发者ID:chu888chu888,项目名称:Linux-gryphon,代码行数:31,代码来源:tc_user.c

示例5: endless_loop

static void
endless_loop(void)
{
    val_context_t *context;

    /*
     * signal handlers to exit gracefully
     */
#ifdef SIGTERM
    signal(SIGTERM, sig_shutdown);
#endif
#ifdef SIGINT
    signal(SIGINT, sig_shutdown);
#endif

    /*
     * open a port and process incoming packets
     */
    port_setup(1153);
    if (VAL_NO_ERROR != val_create_context(NULL, &context)) {
        val_log(NULL, LOG_ERR, "Cannot create validator context. Exiting.");
        return;
    }

    while (!done) {
        wait_for_packet();
        process_packet(context);
    }

    val_free_context(context);

    val_free_validator_state();
}
开发者ID:DNSSEC-Tools,项目名称:DNSSEC-Tools,代码行数:33,代码来源:validator_driver.c

示例6: replicate_packs

static void
replicate_packs(unsigned char *frame, int frame_len, int replica_num)
{
    int              i;
    uint32_t         size_ip;
    uint16_t         orig_port, addition, dest_port, rand_port;
    unsigned char   *packet;
    tc_ip_header_t  *ip_header;
    tc_udp_header_t *udp_header;

    packet     = frame + ETHERNET_HDR_LEN;
    ip_header  = (tc_ip_header_t *) packet;
    size_ip    = ip_header->ihl << 2;
    udp_header = (tc_udp_header_t *) ((char *) ip_header + size_ip);
    orig_port  = ntohs(udp_header->source);

    tc_log_debug1(LOG_DEBUG, 0, "orig port:%u", orig_port);

    rand_port = clt_settings.rand_port_shifted;
    for (i = 1; i < replica_num; i++) {
        addition   = (((i << 1) - 1) << 5) + rand_port;
        dest_port  = get_appropriate_port(orig_port, addition);

        tc_log_debug2(LOG_DEBUG, 0, "new port:%u,add:%u", dest_port, addition);

        udp_header->source = htons(dest_port);
        process_packet(true, frame, frame_len);
    }
}
开发者ID:hanjinze,项目名称:tcpcopy,代码行数:29,代码来源:tc_packets_module.c

示例7: loop_lidar

// To main
void loop_lidar() {

  while (Serial1.available() && lidar_idx < BYTES_PER_PACKET) {

  	// Skip to beginning of packet
  	if (Serial1.peek() != 0xFA) {
  		Serial1.read();
  	} else {
  		// Found beginning
  		// Serial.print("Reset... ");
  		// Serial.println(lidar_idx);
  		lidar_idx = 0;
  		lidar_buf[lidar_idx++] = Serial1.read();

  		// Copy either entire packet or until we find the start of the next packet
  		while (lidar_idx < BYTES_PER_PACKET && Serial1.peek() != 0xFA) {
  			if (Serial1.available()) {
	  			// Serial.print(Serial1.peek(), HEX);
	  			// Serial.print(" ");
	  			lidar_buf[lidar_idx++] = Serial1.read();
	  		}
  		}
  	}
  }

  // we read an entire packet
  if (lidar_idx == BYTES_PER_PACKET) {
  	// Serial.println("Processing...");
  	process_packet();
  	lidar_idx = 0;
  }
}
开发者ID:ese-519,项目名称:teamcaravan,代码行数:33,代码来源:Lidar.cpp

示例8: pwn

static void pwn(const char * fname)
{
	REQUIRE(fname != NULL);

	struct wif * wi;
	char crap[2048];
	int rc;

	if (strlen(fname) + 7 >= sizeof(crap))
	{
		printf("Filename too long, aborting\n");
		return;
	}

	memset(crap, 0, sizeof(crap));
	snprintf(crap, sizeof(crap), "file://%s", fname);

	wi = wi_open(crap);
	if (!wi)
	{
		printf("Bad file - skipping %s\n", fname);
		return;
	}

	while ((rc = wi_read(wi, (unsigned char *) crap, sizeof(crap), NULL)) > 0)
		process_packet(crap, rc);

	wi_close(wi);
}
开发者ID:JoeGilkey,项目名称:carnivore,代码行数:29,代码来源:wpaclean.c

示例9: aprsis_got_packet

static gboolean aprsis_got_packet(GIOChannel *gio, GIOCondition condition, gpointer data) {
	// callback when GIOChannel tells us there's an APRS packet to be handled
	GIOStatus ret;
	GError *err = NULL;
	gchar *msg;
	gsize len;
	aprsis_ctx *ctx = (aprsis_ctx *) data;

	if (condition & G_IO_HUP)
		g_error ("Read end of pipe died!");   // FIXME - handle this more gracefully

	if (condition & G_IO_ERR) {
		g_message ("IO error");
		return FALSE;
	}
		
	ret = g_io_channel_read_line (gio, &msg, &len, NULL, &err);
	if (ret == G_IO_STATUS_ERROR)  g_message("Error reading: %s", err->message);
	if (ret == G_IO_STATUS_EOF) {
		g_message("EOF (server disconnected)");
		return FALSE; // shut down the callback, for now 
	}
	
	aprsis_write_log(ctx, msg, len);
	
	if (msg[0] == '#') {
		printf("can ignore comment message: %s\n", msg);
	} else {
		printf ("\n------------------------------------------\nRead %u bytes: %s", (unsigned int) len, msg);
		process_packet(msg);
	}

	g_free(msg);
	return TRUE;
}
开发者ID:TaylanUB,项目名称:aprsmap,代码行数:35,代码来源:aprsis.c

示例10: replicate_packs

/* replicate packets for multiple-copying */
static void
replicate_packs(char *packet, int length, int replica_num)
{
    int               i;
    uint16_t          orig_port, addition, dest_port, rand_port;
    uint32_t          size_ip;
    tc_tcp_header_t  *tcp_header;
    tc_ip_header_t   *ip_header;
    
    ip_header  = (tc_ip_header_t *) packet;
    size_ip    = ip_header->ihl << 2;
    tcp_header = (tc_tcp_header_t *) ((char *) ip_header + size_ip);
    rand_port  = clt_settings.rand_port_shifted;
    orig_port  = ntohs(tcp_header->source);

    tc_log_debug1(LOG_DEBUG, 0, "orig port:%u", orig_port);

    for (i = 1; i < replica_num; i++) {

        addition   = (((i << 1) - 1) << 5) + rand_port;
        dest_port  = get_appropriate_port(orig_port, addition);
        tcp_header->source = htons(dest_port);
        process_packet(true, packet, length);

        tc_log_debug2(LOG_DEBUG, 0, "new port:%u,add:%u", dest_port, addition);
    }
}
开发者ID:fengzanfeng,项目名称:tcpcopy,代码行数:28,代码来源:tc_packets_module.c

示例11: dbg_get_request

struct dbg_request dbg_get_request(struct dbg_context* dbg)
{
    /* Can't ask for the next request until you've satisfied the
     * current one, for requests that need an immediate
     * response. */
    assert(!request_needs_immediate_response(&dbg->req));

    if (sniff_packet(dbg) && dbg_is_resume_request(&dbg->req)) {
        /* There's no new request data available and gdb has
         * already asked us to resume.  OK, do that (or keep
         * doing that) now. */
        return dbg->req;
    }

    while (1) {
        /* There's either new request data, or we have nothing
         * to do.  Either way, block until we read a complete
         * packet from gdb. */
        read_packet(dbg);

        if (process_packet(dbg)) {
            /* We couldn't process the packet internally,
             * so the target has to do something. */
            return dbg->req;
        }
        /* The packet we got was "internal", gdb details.
         * Nothing for the target to do yet.  Keep waiting. */
    }
}
开发者ID:smillaedler,项目名称:rr,代码行数:29,代码来源:dbg_gdb.c

示例12: process_nfq_packet

static int process_nfq_packet(struct nfq_q_handle *qh,
        struct nfgenmsg *nfmsg,
        struct nfq_data *nfa,
        void *data)
{
    struct nfqnl_msg_packet_hdr *ph;
    int pkt_len = 0;
    int verdict;
    unsigned char *full_packet;
    fko_srv_options_t   *opts = (fko_srv_options_t *)data;

    ph = nfq_get_msg_packet_hdr(nfa);
    if (ph) {

        /* --DSS for ref
          id = ntohl(ph->packet_id);
          hook = ph->hook;
          hw_proto = ph->protocol;
        */

        /* Retrieve packet payload
        */
        pkt_len = nfq_get_payload(nfa, &full_packet);

        process_packet(opts, pkt_len, full_packet);

        /* Verdict on what to do with the packet.  If it is coming from
         * the INPUT chain (NF_IP_LOCAL_IN), then it is assumed to be
         * a spa packet and can be dropped. Otherwise, let it through.
        */
        verdict = (ph->hook == NF_IP_LOCAL_IN) ? NF_DROP : NF_ACCEPT;
        nfq_set_verdict(qh, ph->packet_id, verdict, 0, NULL);
    }
    return 0;
}
开发者ID:tmcanally,项目名称:fwknop,代码行数:35,代码来源:nfq_capture.c

示例13: main

int main(int argc, char** argv){
  FILE* log;
  int saddr_size, data_size, sock_raw;
  struct sockaddr saddr;
  unsigned char* buffer = (unsigned char*)malloc(BUFFER_SIZE);
  log = fopen(argv[1], "w");
  if(log == NULL)
    printf("Error creating '%s' file.\n", argv[1]);
  printf("===Starting Sniffy==\n");
  sock_raw = socket(AF_PACKET, SOCK_RAW, htons(ETH_P_ALL));
  if(sock_raw < 0){
    perror("SOCKET ERROR");
    return 1;
  }

  while(1){
    saddr_size = sizeof(saddr);
    data_size = recvfrom(sock_raw, buffer, BUFFER_SIZE, 0, &saddr, (socklen_t*)&saddr_size);
    if(data_size < 0)
      printf("recvfrom error: could not get packets\n");
    process_packet(log, buffer, data_size);
  }
  close(sock_raw);
  free(buffer);
  printf("===Sniffy Finished===\n");
  return 0;
}
开发者ID:muhammadkhan,项目名称:Sniffy,代码行数:27,代码来源:main.c

示例14: nfqueue_cb

// function callback for packet processing
// ---------------------------------------
static int nfqueue_cb(struct nfq_q_handle *qh, struct nfgenmsg *nfmsg,
                      struct nfq_data *nfa, void *data) {
    struct nfqnl_msg_packet_hdr *ph;
    int id_protocol = 0, id = 0, len = 0;
    unsigned char *full_packet; // get data of packet (payload)
    unsigned char *new_packet = NULL;
    
    ph = nfq_get_msg_packet_hdr(nfa);
    if (ph) {
        len = nfq_get_payload(nfa, &full_packet);
        id = ntohl(ph->packet_id);
        id_protocol = identify_ip_protocol(full_packet);
        if (id_protocol == IPPROTO_UDP) { /* Only UDP packets */
            printf("Packet from %s:%d", get_src_ip_str(full_packet), get_udp_src_port(full_packet));
            printf(" to %s:%d\n", get_dst_ip_str(full_packet), get_tcp_dst_port(full_packet));
            /* Process packet... */
            new_packet = process_packet(full_packet, &len, ph->hook);
        }
        // let the packet continue on.  NF_ACCEPT will pass the packet
        // -----------------------------------------------------------
        if (new_packet) {
            nfq_set_verdict(qh, id, NF_ACCEPT, len, new_packet);
            free(new_packet);
        }
        else
            nfq_set_verdict(qh, id, NF_ACCEPT, 0, NULL);
    } else {
        printf("NFQUEUE: can't get msg packet header.\n");
        return ERR;		// from nfqueue source: 0 = ok, >0 = soft error, <0 hard error
    }

    return OK;
}
开发者ID:dlebedev,项目名称:udpsocksify,代码行数:35,代码来源:udps.c

示例15: process_packet

void ReplayAudioIngest::run_thread( ) {
    IOAudioPacket *in;
    for (;;) {
        in = pipe->get( );
        process_packet(in);
        delete in;
    }
}
开发者ID:DigiDaz,项目名称:exacore,代码行数:8,代码来源:replay_audio_ingest.cpp


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