<commit_before>#ifndef __COMMON_H__
#define __COMMON_H__

#include <bsd/sys/queue.h>
#include <json-c/json.h>
#include <pcap/pcap.h>
#include <pcre.h>

#include <rte_log.h>
#include <rte_lpm.h>
#include <rte_mbuf.h>

#include <rte_ether.h>
#include <rte_arp.h>
#include <rte_ip.h>
#include <rte_icmp.h>
#include "ss_icmp6.h"
#include <rte_tcp.h>
#include <rte_udp.h>

/* CONSTANTS */

#define RTE_LOGTYPE_SS RTE_LOGTYPE_USER1

#define SS_INT16_SIZE         2
#define SS_ADDR_STR_SIZE     64

#define SS_V4_ADDR_SIZE       4
#define SS_V6_ADDR_SIZE      16
#define SS_V4_PREFIX_MAX     32
#define SS_V6_PREFIX_MAX    128

/* should be enough for the nanomsg queue URL */
#define NN_URL_MAX 256

/* enough to hold [max_ipv6]/128 plus a bit extra */
#define CIDR_LENGTH_MAX 64

#define ETHER_TYPE_IPV4 ETHER_TYPE_IPv4
#define ETHER_TYPE_IPV6 ETHER_TYPE_IPv6

/* TYPEDEFS */

typedef struct rte_mbuf rte_mbuf_t;

typedef struct rte_hash rte_hash_t;
typedef struct rte_lpm  rte_lpm4_t;
typedef struct rte_lpm6 rte_lpm6_t;

typedef struct icmp_hdr icmpv4_hdr;

/* DATA TYPES */

struct ip4_addr {
    uint32_t addr;
};

typedef struct ip4_addr ip4_addr;

struct ip6_addr {
    uint8_t addr[16];
};

typedef struct ip6_addr ip6_addr;

struct ip_addr {
    uint8_t family;
    uint8_t prefix;
    union {
        struct ip4_addr ipv4;
        struct ip6_addr ipv6;
    };
};

typedef struct ip_addr ip_addr;

struct ss_frame_s {
    unsigned int      port_id;
    rte_mbuf_t        mbuf;
    
    struct ether_hdr* ethernet;
    struct arp_hdr*   arp;
    struct ipv4_hdr*  ipv4;
    struct ipv6_hdr*  ipv6;
    struct icmp_hdr   icmp4;
    struct icmp6_hdr  icmp6;
    struct tcp_hdr    tcp;
    struct udp_hdr    udp;<commit_msg>common.h: correct some of the packet header structs<commit_after>#ifndef __COMMON_H__
#define __COMMON_H__

#include <bsd/sys/queue.h>
#include <json-c/json.h>
#include <pcap/pcap.h>
#include <pcre.h>

#include <rte_log.h>
#include <rte_lpm.h>
#include <rte_mbuf.h>

#include <rte_ether.h>
#include <rte_arp.h>
#include <rte_ip.h>
#include <rte_icmp.h>
#include "ss_icmp6.h"
#include <rte_tcp.h>
#include <rte_udp.h>

/* CONSTANTS */

#define RTE_LOGTYPE_SS RTE_LOGTYPE_USER1

#define SS_INT16_SIZE         2
#define SS_ADDR_STR_SIZE     64

#define SS_V4_ADDR_SIZE       4
#define SS_V6_ADDR_SIZE      16
#define SS_V4_PREFIX_MAX     32
#define SS_V6_PREFIX_MAX    128

/* should be enough for the nanomsg queue URL */
#define NN_URL_MAX 256

/* enough to hold [max_ipv6]/128 plus a bit extra */
#define CIDR_LENGTH_MAX 64

#define ETHER_TYPE_IPV4 ETHER_TYPE_IPv4
#define ETHER_TYPE_IPV6 ETHER_TYPE_IPv6

/* TYPEDEFS */

typedef struct rte_mbuf rte_mbuf_t;

typedef struct rte_hash rte_hash_t;
typedef struct rte_lpm  rte_lpm4_t;
typedef struct rte_lpm6 rte_lpm6_t;

typedef struct ether_hdr ether_hdr_t;
typedef struct ipv4_hdr  ipv4_hdr_t;
typedef struct ipv6_hdr  ipv6_hdr_t;
typedef struct icmp_hdr  icmpv4_hdr_t;
typedef struct icmp6_hdr icmpv6_hdr_t;
typedef struct tcp_hdr   tcp_hdr_t;
typedef struct udp_hdr   udp_hdr_t;

/* DATA TYPES */

struct ip4_addr {
    uint32_t addr;
};

typedef struct ip4_addr ip4_addr;

struct ip6_addr {
    uint8_t addr[16];
};

typedef struct ip6_addr ip6_addr;

struct ip_addr {
    uint8_t family;
    uint8_t prefix;
    union {
        struct ip4_addr ipv4;
        struct ip6_addr ipv6;
    };
};

typedef struct ip_addr ip_addr;

struct ss_frame_s {
    unsigned int      port_id;
    uint32_t          length;
    rte_mbuf_t*       mbuf;
    
    struct ether_hdr* eth;
    struct arp_hdr*   arp;
    struct ipv4_hdr*  ipv4;
    struct ipv6_hdr*  ipv6;
    struct icmp_hdr   icmp4;
    struct icmp6_hdr  icmp6;
    struct tcp_hdr    tcp;
    struct udp_hdr    udp;
{'fraction_non_alphanumeric': 0.07925033467202142, 'fraction_numerical': 0.03427041499330656, 'mean_word_length': 3.5896805896805897, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3568751', 'n_tokens_mistral': 1673, 'n_tokens_neox': 1593, 'n_words': 370}