<commit_before>/*
 *
 * (C) 2005-17 - ntop.org
 *
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesses General Public License as published by
 * the Free Software Foundation; either version 2.1 of the License, or
 * (at your option) any later version.
 *
 */

#ifndef _PFRING_H_
#define _PFRING_H_

/**
 * @mainpage  Main Page
 *
 *            PF_RING API documentation.
 */

/**
 * @file pfring.h
 *
 * @brief      PF_RING library header file.
 * @details    This header file must be included in any PF_RING-based applications.
 */

#include <sys/types.h>
#include <stdio.h>
#include <stdarg.h>

#ifndef HAVE_PCAP
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/mman.h>
#include <errno.h>
#include <poll.h>
#include <sys/socket.h>
#include <linux/sockios.h>
#endif

#ifdef ENABLE_BPF
#include <pcap/pcap.h>
#include <pcap/bpf.h>
#endif

#include <linux/if_packet.h>
#include <arpa/inet.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <sys/time.h>
#include <time.h>
#include <poll.h>
#include <string.h>
#include <pthread.h>
#include <linux/pf_ring.h>
#include <linux/if_ether.h>

#ifdef HAVE_REDIRECTOR
#include <librdi.h>
#endif

#define MAX_CAPLEN             65535
#define PAGE_SIZE               4096

#define DEFAULT_POLL_DURATION   500

#define POLL_SLEEP_STEP           10 /* ns = 0.1 ms */
#define POLL_SLEEP_MIN          POLL_SLEEP_STEP
#define POLL_SLEEP_MAX          1000 /* ns */
#define POLL_QUEUE_MIN_LEN       500 /* # packets */

#ifndef HAVE_RW_LOCK
#define pthread_rwlock_t       pthread_mutex_t
#define pthread_rwlock_init    pthread_mutex_init
#define pthread_rwlock_rdlock  pthread_mutex_lock
#define pthread_rwlock_wrlock  pthread_mutex_lock
#define pthread_rwlock_unlock  pthread_mutex_unlock
#define pthread_rwlock_destroy pthread_mutex_destroy
#endif

#define timespec_is_before(a, b) \
  ((((a)->tv_sec<(b)->tv_sec)||(((a)->tv_sec==(b)->tv_sec)&&((a)->tv_nsec<(b)->tv_nsec)))?1:0)

/* ********************************* */

#ifndef likely
#define likely(x)       __builtin_expect((x),1)
#endif

#ifndef unlikely
#define unlikely(x)     __builtin_expect((x),0)
#endif

/* ********************************* */

/*
  See also __builtin_prefetch
  http://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html
*/
#define prefetch(x) __asm volatile("prefetcht0 %0" :: "m" (*(const unsigned long *)x));

/* ********************************* */

#ifdef __cplusplus
extern "C" {
#endif

#ifdef SAFE_RING_MODE
static char staticBucket[2048];
#endif

typedef void (*pfringProcesssPacket)(const struct pfring_pkthdr *h, const u_char *p, const u_char *user_bytes);

/* ********************************* */

typedef struct __pfring pfring; /* Forward declaration */

/* ********************************* */

typedef struct {
  u_int32_t max_packet_size;
  u_int32_t rx_ring_slots;
  u_int32_t tx_ring_slots;
} pfring_card_settings;

/* ********************************* */

typedef struct {
  u_int64_t recv, drop;
} pfring_stat;

/* ********************************* */

typedef enum {
  hardware_and_software = 0,
  hardware_only,
  software_only
} filtering_mode;

/* ********************************* */

typedef enum {
  FULL_PACKET_SLICING = 0,
  L2_SLICING = 2,
  L3_SLICING = 3,
  L4_SLICING = 4
} packet_slicing_level;<commit_msg>added shunt pkts to stats<commit_after>/*
 *
 * (C) 2005-17 - ntop.org
 *
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesses General Public License as published by
 * the Free Software Foundation; either version 2.1 of the License, or
 * (at your option) any later version.
 *
 */

#ifndef _PFRING_H_
#define _PFRING_H_

/**
 * @mainpage  Main Page
 *
 *            PF_RING API documentation.
 */

/**
 * @file pfring.h
 *
 * @brief      PF_RING library header file.
 * @details    This header file must be included in any PF_RING-based applications.
 */

#include <sys/types.h>
#include <stdio.h>
#include <stdarg.h>

#ifndef HAVE_PCAP
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/mman.h>
#include <errno.h>
#include <poll.h>
#include <sys/socket.h>
#include <linux/sockios.h>
#endif

#ifdef ENABLE_BPF
#include <pcap/pcap.h>
#include <pcap/bpf.h>
#endif

#include <linux/if_packet.h>
#include <arpa/inet.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <sys/time.h>
#include <time.h>
#include <poll.h>
#include <string.h>
#include <pthread.h>
#include <linux/pf_ring.h>
#include <linux/if_ether.h>

#ifdef HAVE_REDIRECTOR
#include <librdi.h>
#endif

#define MAX_CAPLEN             65535
#define PAGE_SIZE               4096

#define DEFAULT_POLL_DURATION   500

#define POLL_SLEEP_STEP           10 /* ns = 0.1 ms */
#define POLL_SLEEP_MIN          POLL_SLEEP_STEP
#define POLL_SLEEP_MAX          1000 /* ns */
#define POLL_QUEUE_MIN_LEN       500 /* # packets */

#ifndef HAVE_RW_LOCK
#define pthread_rwlock_t       pthread_mutex_t
#define pthread_rwlock_init    pthread_mutex_init
#define pthread_rwlock_rdlock  pthread_mutex_lock
#define pthread_rwlock_wrlock  pthread_mutex_lock
#define pthread_rwlock_unlock  pthread_mutex_unlock
#define pthread_rwlock_destroy pthread_mutex_destroy
#endif

#define timespec_is_before(a, b) \
  ((((a)->tv_sec<(b)->tv_sec)||(((a)->tv_sec==(b)->tv_sec)&&((a)->tv_nsec<(b)->tv_nsec)))?1:0)

/* ********************************* */

#ifndef likely
#define likely(x)       __builtin_expect((x),1)
#endif

#ifndef unlikely
#define unlikely(x)     __builtin_expect((x),0)
#endif

/* ********************************* */

/*
  See also __builtin_prefetch
  http://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html
*/
#define prefetch(x) __asm volatile("prefetcht0 %0" :: "m" (*(const unsigned long *)x));

/* ********************************* */

#ifdef __cplusplus
extern "C" {
#endif

#ifdef SAFE_RING_MODE
static char staticBucket[2048];
#endif

typedef void (*pfringProcesssPacket)(const struct pfring_pkthdr *h, const u_char *p, const u_char *user_bytes);

/* ********************************* */

typedef struct __pfring pfring; /* Forward declaration */

/* ********************************* */

typedef struct {
  u_int32_t max_packet_size;
  u_int32_t rx_ring_slots;
  u_int32_t tx_ring_slots;
} pfring_card_settings;

/* ********************************* */

typedef struct {
  u_int64_t recv;
  u_int64_t drop;
  u_int64_t shunt;
} pfring_stat;

/* ********************************* */

typedef enum {
  hardware_and_software = 0,
  hardware_only,
  software_only
} filtering_mode;

/* ********************************* */

typedef enum {
  FULL_PACKET_SLICING = 0,
  L2_SLICING = 2,
  L3_SLICING = 3,
  L4_SLICING = 4
} packet_slicing_level;
{'fraction_non_alphanumeric': 0.1964154546790069, 'fraction_numerical': 0.017335096224474805, 'mean_word_length': 4.327073552425665, 'pattern_counts': {'":': 0, '<': 61, '<?xml version=': 0, '>': 69, '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': '3910905', 'n_tokens_mistral': 2631, 'n_tokens_neox': 2501, 'n_words': 558}