基于DPDK的解析流量包程序(参考pdump,纯测试能否可行)

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include <stdbool.h>

#include <rte_byteorder.h>

#include <rte_ether.h>
#include <rte_ip.h>
#include <rte_tcp.h>
#include <rte_udp.h>
#include <rte_net.h>

#include <rte_ether.h>
#include <rte_ethdev.h>
#include <rte_mempool.h>
#include <rte_mbuf.h>
#include <rte_flow.h>

static volatile bool force_quit;

#define MBUF_CACHE_SIZE 250
#define NUM_MBUFS 8191
#define RX_RING_SIZE 128
#define TX_RING_SIZE 512



static const struct rte_eth_conf port_conf_default = {
   
	.rxmode = {
    .max_rx_pkt_len = ETHER_MAX_LEN }
};

static void 
main_loop(void){
   

    struct rte_mbuf *mbufs[32];
    struct ether_hdr *eth_hdr;
    struct ipv4_hdr *ipv4_hdr;
    struct tcp_hdr *tcp_hdr;
    struct udp_hdr *udp_hdr;
	uint32_t tcp_or_udp;
    uint32_t l3_ptypes;
    struct rte_flow_error error;
    uint16_t nb_rx;
    uint8_t port_id = 0;
    uint16_t nr_queues = 0;
    uint16_t nb_pkts = 32;
    uint16_t i;
    
    while(!force_quit){
   
        //单队列网卡,不用for循环遍历队列
        nb_rx = rte_eth_rx_burst(port_id,nr_queues,mbufs,nb_pkts)
  • 2
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值