PF_RING API
API documentation for PF_RING: high-speed packet capture, filtering and analysis framework.
pfring.h
Go to the documentation of this file.
1 /*
2  *
3  * (C) 2005-2018 - ntop.org
4  *
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU Lesses General Public License as published by
8  * the Free Software Foundation; either version 2.1 of the License, or
9  * (at your option) any later version.
10  *
11  */
12 
13 #ifndef _PFRING_H_
14 #define _PFRING_H_
15 
29 #include <sys/types.h>
30 #include <stdio.h>
31 #include <stdarg.h>
32 
33 #ifndef HAVE_PCAP
34 #include <stdio.h>
35 #include <stdlib.h>
36 #include <string.h>
37 #include <unistd.h>
38 #include <sys/mman.h>
39 #include <errno.h>
40 #include <poll.h>
41 #include <sys/socket.h>
42 #include <linux/sockios.h>
43 #endif
44 
45 #ifdef ENABLE_BPF
46 #include <pcap/pcap.h>
47 #include <pcap/bpf.h>
48 #endif
49 
50 #include <linux/if_packet.h>
51 #include <arpa/inet.h>
52 #include <sys/ioctl.h>
53 #include <sys/socket.h>
54 #include <sys/un.h>
55 #include <sys/time.h>
56 #include <time.h>
57 #include <poll.h>
58 #include <string.h>
59 #include <pthread.h>
60 #include <linux/pf_ring.h>
61 #include <linux/if_ether.h>
62 
63 #ifdef HAVE_REDIRECTOR
64 #include <librdi.h>
65 #endif
66 
67 #define MAX_CAPLEN 65535
68 #define PAGE_SIZE 4096
69 
70 #define DEFAULT_POLL_DURATION 500
71 
72 #define POLL_SLEEP_STEP 10 /* ns = 0.1 ms */
73 #define POLL_SLEEP_MIN POLL_SLEEP_STEP
74 #define POLL_SLEEP_MAX 1000 /* ns */
75 #define POLL_QUEUE_MIN_LEN 500 /* # packets */
76 
77 #define pfring_rwlock_t pthread_rwlock_t
78 #define pfring_rwlock_init pthread_rwlock_init
79 #define pfring_rwlock_rdlock pthread_rwlock_rdlock
80 #define pfring_rwlock_wrlock pthread_rwlock_wrlock
81 #define pfring_rwlock_unlock pthread_rwlock_unlock
82 #define pfring_rwlock_destroy pthread_rwlock_destroy
83 
84 #define timespec_is_before(a, b) \
85  ((((a)->tv_sec<(b)->tv_sec)||(((a)->tv_sec==(b)->tv_sec)&&((a)->tv_nsec<(b)->tv_nsec)))?1:0)
86 
87 /* ********************************* */
88 
89 #ifndef likely
90 #define likely(x) __builtin_expect((x),1)
91 #endif
92 
93 #ifndef unlikely
94 #define unlikely(x) __builtin_expect((x),0)
95 #endif
96 
97 /* ********************************* */
98 
99 /* See also __builtin_prefetch
100  * http://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html */
101 #define prefetch(x) __asm volatile("prefetcht0 %0" :: "m" (*(const unsigned long *)x));
102 
103 /* ********************************* */
104 
105 #ifdef __cplusplus
106 extern "C" {
107 #endif
108 
109 #ifdef SAFE_RING_MODE
110 static char staticBucket[2048];
111 #endif
112 
113 typedef void (*pfringProcesssPacket)(const struct pfring_pkthdr *h, const u_char *p, const u_char *user_bytes);
114 
115 /* ********************************* */
116 
117 typedef struct __pfring pfring; /* Forward declaration */
118 
119 /* ********************************* */
120 
121 typedef struct {
122  u_int32_t max_packet_size;
123  u_int32_t rx_ring_slots;
124  u_int32_t tx_ring_slots;
126 
127 /* ********************************* */
128 
129 typedef struct {
130  u_int64_t recv;
131  u_int64_t drop;
132  u_int64_t shunt;
133 } pfring_stat;
134 
135 /* ********************************* */
136 
137 typedef enum {
138  hardware_and_software = 0,
139  hardware_only,
140  software_only
141 } filtering_mode;
142 
143 /* ********************************* */
144 
145 typedef enum {
146  FULL_PACKET_SLICING = 0,
147  L2_SLICING = 2,
148  L3_SLICING = 3,
149  L4_SLICING = 4
150 } packet_slicing_level;
151 
152 /* ********************************* */
153 
154 typedef enum {
155  PCAP_CHUNK,
156  PCAP_NSEC_CHUNK,
157  UNKNOWN_CHUNK_TYPE
158 } pfring_chunk_type;
159 
160 typedef struct {
161  u_int32_t length;
162  pfring_chunk_type type;
164 
165 /* ********************************* */
166 
167 #ifndef BPF_RELEASE
169  u_int bf_len;
170  void *bf_insns;
171 };
172 #endif
173 
174 /* ********************************* */
175 
176 typedef struct pfring_if {
177  char *name;
178  char *system_name;
179  char *module;
180  char *sn;
181  char mac[6];
182  struct { /* Bus ID: "%04X:%02X:%02X.%X", slot, bus, device, function */
183  int slot;
184  int bus;
185  int device;
186  int function;
187  } bus_id;
188  int status; /* 1: up, 0: down*/
189  int license; /* 1: valid, 0: invalid or not installed */
190  struct pfring_if *next;
191 } pfring_if_t;
192 
193 /* ********************************* */
194 
195 struct __pfring {
196  u_int8_t initialized;
197  u_int8_t enabled;
198  u_int8_t long_header;
199 
200  u_int8_t force_timestamp;
201  u_int8_t strip_hw_timestamp;
202 
203  u_int8_t disable_parsing;
204 
205  u_int8_t disable_timestamp;
206  u_int8_t ixia_timestamp_enabled;
207  u_int8_t vss_apcon_timestamp_enabled;
208 
209  u_int8_t chunk_mode_enabled;
210 
211  u_int8_t userspace_bpf;
212  u_int8_t force_userspace_bpf;
213 
214  u_int32_t rss_mode;
215  packet_direction direction; /* Specify the capture direction for packets */
216  socket_mode mode;
217 
218 #ifdef BPF_RELEASE
219  struct bpf_program
220 #else
221  struct pfring_bpf_program
222 #endif
223  userspace_bpf_filter;
224 
225  /* Hardware Timestamp */
226  struct {
227  u_int8_t force_timestamp;
228  u_int8_t is_silicom_hw_timestamp_card;
229  u_int8_t enable_hw_timestamp;
230  u_int8_t last_hw_timestamp_head_offset;
231  struct timespec last_hw_timestamp;
232  } hw_ts;
233 
234  struct {
235  u_int8_t enabled_rx_packet_send;
236  struct pfring_pkthdr *last_received_hdr; /* Header of the past packet that has been received on this socket */
237  } tx;
238 
239  u_int8_t zc_device;
240 
241  void *priv_data; /* module private data */
242 
243  void (*close) (pfring *);
244  int (*stats) (pfring *, pfring_stat *);
245  int (*recv) (pfring *, u_char**, u_int, struct pfring_pkthdr *, u_int8_t);
246  int (*set_poll_watermark) (pfring *, u_int16_t);
247  int (*set_poll_watermark_timeout) (pfring *, u_int16_t);
248  int (*set_poll_duration) (pfring *, u_int);
249  int (*set_tx_watermark) (pfring *, u_int16_t);
250  int (*set_channel_id) (pfring *, u_int32_t);
251  int (*set_channel_mask) (pfring *, u_int64_t);
252  int (*set_application_name) (pfring *, char *);
253  int (*set_application_stats) (pfring *, char *);
254  char* (*get_appl_stats_file_name) (pfring *ring, char *path, u_int path_len);
255  int (*set_vlan_id) (pfring *, u_int16_t);
256  int (*bind) (pfring *, char *);
257  int (*send) (pfring *, char *, u_int, u_int8_t);
258  int (*send_get_time) (pfring *, char *, u_int, struct timespec *);
259  u_int8_t (*get_num_rx_channels) (pfring *);
260  int (*get_card_settings) (pfring *, pfring_card_settings *);
261  int (*set_sampling_rate) (pfring *, u_int32_t);
262  int (*set_packet_slicing) (pfring *, packet_slicing_level, u_int32_t);
263  int (*get_selectable_fd) (pfring *);
264  int (*set_direction) (pfring *, packet_direction);
265  int (*set_socket_mode) (pfring *, socket_mode);
266  int (*set_cluster) (pfring *, u_int, cluster_type);
267  int (*remove_from_cluster) (pfring *);
268  int (*set_master_id) (pfring *, u_int32_t);
269  int (*set_master) (pfring *, pfring *);
270  u_int32_t (*get_ring_id) (pfring *);
271  u_int32_t (*get_num_queued_pkts) (pfring *);
272  int (*get_hash_filtering_rule_stats)(pfring *, hash_filtering_rule *, char *, u_int *);
273  int (*handle_hash_filtering_rule) (pfring *, hash_filtering_rule *, u_char);
274  int (*purge_idle_hash_rules) (pfring *, u_int16_t);
275  int (*add_filtering_rule) (pfring *, filtering_rule *);
276  int (*remove_filtering_rule) (pfring *, u_int16_t);
277  int (*purge_idle_rules) (pfring *, u_int16_t);
278  int (*get_filtering_rule_stats) (pfring *, u_int16_t, char *, u_int *);
279  int (*toggle_filtering_policy) (pfring *, u_int8_t);
280  int (*enable_rss_rehash) (pfring *);
281  int (*poll) (pfring *, u_int);
282  int (*is_pkt_available) (pfring *);
283  int (*next_pkt_time) (pfring *, struct timespec *);
284  int (*next_pkt_raw_timestamp) (pfring *, u_int64_t *ts);
285  int (*version) (pfring *, u_int32_t *);
286  int (*get_bound_device_address) (pfring *, u_char [6]);
287  int (*get_bound_device_ifindex) (pfring *, int *);
288  int (*get_device_ifindex) (pfring *, char *, int *);
289  u_int16_t (*get_slot_header_len) (pfring *);
290  int (*set_virtual_device) (pfring *, virtual_filtering_device_info *);
291  int (*add_hw_rule) (pfring *, hw_filtering_rule *);
292  int (*remove_hw_rule) (pfring *, u_int16_t);
293  int (*loopback_test) (pfring *, char *, u_int, u_int);
294  int (*enable_ring) (pfring *);
295  int (*disable_ring) (pfring *);
296  void (*shutdown) (pfring *);
297  int (*set_bpf_filter) (pfring *, char *);
298  int (*remove_bpf_filter) (pfring *);
299  int (*get_device_clock) (pfring *, struct timespec *);
300  int (*set_device_clock) (pfring *, struct timespec *);
301  int (*adjust_device_clock) (pfring *, struct timespec *, int8_t);
302  void (*sync_indexes_with_kernel) (pfring *);
303  int (*send_last_rx_packet) (pfring *, int);
304  void (*flush_tx_packets) (pfring *);
305  int (*register_zerocopy_tx_ring) (pfring *, pfring *);
306  int (*recv_chunk) (pfring *, void **, pfring_chunk_info *, u_int8_t);
307  int (*set_bound_dev_name) (pfring *, char *);
308  int (*get_metadata) (pfring *, u_char **, u_int32_t *);
309  u_int32_t (*get_interface_speed) (pfring *);
310 
311  /* Silicom Redirector Only */
312  struct {
313  int8_t device_id;
314  int8_t port_id;
315  } rdi;
316 
317  filtering_mode ft_mode;
318  pfring_device_type ft_device_type;
319 
320  /* All devices */
321  char *buffer;
322  char *slots;
323  char *device_name;
324 
325  u_int32_t caplen;
326  u_int16_t slot_header_len;
327  u_int16_t mtu /* 0 = unknown */;
328 
329  u_int32_t sampling_rate;
330  u_int32_t sampling_counter;
331 
332  packet_slicing_level slicing_level;
333 
334  u_int32_t slicing_additional_bytes;
335 
336  u_int8_t is_shutting_down;
337  u_int8_t socket_default_accept_policy;
338 
339  int fd;
340  int device_id;
341 
342  FlowSlotInfo *slots_info;
343 
344  u_int32_t poll_sleep;
345  u_int16_t poll_duration;
346 
347  u_int8_t promisc;
348  u_int8_t ft_enabled; /* PF_RING FT support enabled */
349  u_int8_t reentrant;
350  u_int8_t break_recv_loop;
351  u_long num_poll_calls;
352 
353  pfring_rwlock_t rx_lock;
354  pfring_rwlock_t tx_lock;
355 
356  u_int32_t flags;
357 
358  void *ft; /* PF_RING FT handle */
359 
360  struct sockaddr_ll sock_tx;
361 
362  /* Reflector socket (copy RX packets onto it) */
363  pfring *reflector_socket;
364 
365  /* Semi-ZC devices (1-copy) */
366  pfring *one_copy_rx_pfring;
367 };
368 
369 /* ********************************* */
370 
371 #define PF_RING_ZC_SYMMETRIC_RSS (1 << 0)
372 #define PF_RING_REENTRANT (1 << 1)
373 #define PF_RING_LONG_HEADER (1 << 2)
374 #define PF_RING_PROMISC (1 << 3)
375 #define PF_RING_TIMESTAMP (1 << 4)
376 #define PF_RING_HW_TIMESTAMP (1 << 5)
377 #define PF_RING_RX_PACKET_BOUNCE (1 << 6)
378 #define PF_RING_ZC_FIXED_RSS_Q_0 (1 << 7)
379 #define PF_RING_STRIP_HW_TIMESTAMP (1 << 8)
380 #define PF_RING_DO_NOT_PARSE (1 << 9)
381 #define PF_RING_DO_NOT_TIMESTAMP (1 << 10)
382 #define PF_RING_CHUNK_MODE (1 << 11)
383 #define PF_RING_IXIA_TIMESTAMP (1 << 12)
384 #define PF_RING_USERSPACE_BPF (1 << 13)
385 #define PF_RING_ZC_NOT_REPROGRAM_RSS (1 << 14)
386 #define PF_RING_VSS_APCON_TIMESTAMP (1 << 15)
387 #define PF_RING_ZC_IPONLY_RSS (1 << 16)
388 #define PF_RING_FLOW_OFFLOAD (1 << 17)
389 #define PF_RING_FLOW_OFFLOAD_NOUPDATES (1 << 18)
390 #define PF_RING_FLOW_OFFLOAD_NORAWDATA (1 << 19)
391 #define PF_RING_L7_FILTERING (1 << 20)
393 /* ********************************* */
394 
395 /* backward compatibility */
396 #define PF_RING_DNA_SYMMETRIC_RSS PF_RING_ZC_SYMMETRIC_RSS
397 #define PF_RING_DNA_FIXED_RSS_Q_0 PF_RING_ZC_FIXED_RSS_Q_0
398 
399 /* ********************************* */
400 
412 pfring *pfring_open(const char *device_name, u_int32_t caplen, u_int32_t flags);
413 
424 u_int8_t pfring_open_multichannel(const char *device_name, u_int32_t caplen,
425  u_int32_t flags, pfring *ring[MAX_NUM_RX_CHANNELS]);
426 
431 void pfring_shutdown(pfring *ring);
432 
437 void pfring_config(u_short cpu_percentage);
438 
447 int pfring_loop(pfring *ring, pfringProcesssPacket looper,
448  const u_char *user_bytes, u_int8_t wait_for_packet);
449 
454 void pfring_breakloop(pfring *);
455 
461 void pfring_close(pfring *ring);
462 
469 int pfring_stats(pfring *ring, pfring_stat *stats);
470 
484 int pfring_recv(pfring *ring, u_char** buffer, u_int buffer_len,
485  struct pfring_pkthdr *hdr, u_int8_t wait_for_incoming_packet);
486 
499 int pfring_recv_parsed(pfring *ring, u_char** buffer, u_int buffer_len,
500  struct pfring_pkthdr *hdr, u_int8_t wait_for_incoming_packet,
501  u_int8_t level /* 1..4 */, u_int8_t add_timestamp, u_int8_t add_hash);
502 
509 int pfring_get_metadata(pfring *ring, u_char **metadata, u_int32_t *metadata_len);
510 
521 int pfring_set_poll_watermark(pfring *ring, u_int16_t watermark);
522 
531 int pfring_set_poll_watermark_timeout(pfring *ring, u_int16_t poll_watermark_timeout);
532 
539 int pfring_set_poll_duration(pfring *ring, u_int duration);
540 
547 int pfring_set_tx_watermark(pfring *ring, u_int16_t watermark);
548 
562 int pfring_add_hw_rule(pfring *ring, hw_filtering_rule *rule);
563 
570 int pfring_remove_hw_rule(pfring *ring, u_int16_t rule_id);
571 
578 int pfring_set_channel_id(pfring *ring, u_int32_t channel_id);
579 
586 int pfring_set_channel_mask(pfring *ring, u_int64_t channel_mask);
587 
599 int pfring_set_application_name(pfring *ring, char *name);
600 
607 int pfring_set_application_stats(pfring *ring, char *stats);
608 
616 char* pfring_get_appl_stats_file_name(pfring *ring, char *path, u_int path_len);
617 
624 int pfring_set_vlan_id(pfring *ring, u_int16_t vlan_id);
625 
632 int pfring_bind(pfring *ring, char *device_name);
633 
649 int pfring_send(pfring *ring, char *pkt, u_int pkt_len, u_int8_t flush_packet);
650 
660 int pfring_send_get_time(pfring *ring, char *pkt, u_int pkt_len, struct timespec *ts);
661 
667 u_int8_t pfring_get_num_rx_channels(pfring *ring);
668 
676 int pfring_set_sampling_rate(pfring *ring, u_int32_t rate /* 1 = no sampling */);
677 
685 int pfring_set_packet_slicing(pfring *ring, packet_slicing_level level, u_int32_t additional_bytes);
686 
694 
702 int pfring_set_direction(pfring *ring, packet_direction direction);
703 
710 int pfring_set_socket_mode(pfring *ring, socket_mode mode);
711 
723 int pfring_set_cluster(pfring *ring, u_int clusterId, cluster_type the_type);
724 
732 
739 int pfring_set_master_id(pfring *ring, u_int32_t master_id);
740 
747 int pfring_set_master(pfring *ring, pfring *master);
748 
754 u_int32_t pfring_get_ring_id(pfring *ring);
755 
762 u_int32_t pfring_get_num_queued_pkts(pfring *ring);
763 
774  hash_filtering_rule* rule_to_add,
775  u_char add_rule);
776 
801 int pfring_add_filtering_rule(pfring *ring, filtering_rule* rule_to_add);
802 
809 int pfring_remove_filtering_rule(pfring *ring, u_int16_t rule_id);
810 
817 int pfring_purge_idle_hash_rules(pfring *ring, u_int16_t inactivity_sec);
818 
825 int pfring_purge_idle_rules(pfring *ring, u_int16_t inactivity_sec);
826 
837  hash_filtering_rule* rule,
838  char *stats, u_int *stats_len);
839 
850 int pfring_get_filtering_rule_stats(pfring *ring, u_int16_t rule_id,
851  char* stats, u_int *stats_len);
852 
861 int pfring_toggle_filtering_policy(pfring *ring, u_int8_t rules_default_accept_policy);
862 
870 
877 int pfring_poll(pfring *ring, u_int wait_duration);
878 
885 
892 int pfring_next_pkt_time(pfring *ring, struct timespec *ts);
893 
900 int pfring_next_pkt_raw_timestamp(pfring *ring, u_int64_t *timestamp_ns);
901 
906 void pfring_version_noring(u_int32_t *version);
907 
914 int pfring_version(pfring *ring, u_int32_t *version);
915 
922 int pfring_set_reflector_device(pfring *ring, char *device_name);
923 
930 int pfring_get_bound_device_address(pfring *ring, u_char mac_address[6]);
931 
937 u_int16_t pfring_get_slot_header_len(pfring *ring);
938 
945 int pfring_get_bound_device_ifindex(pfring *ring, int *if_index);
946 
954 int pfring_get_device_ifindex(pfring *ring, char *device_name, int *if_index);
955 
962 int pfring_set_virtual_device(pfring *ring, virtual_filtering_device_info *info);
963 
973 int pfring_loopback_test(pfring *ring, char *buffer, u_int buffer_len, u_int test_len);
974 
980 int pfring_enable_ring(pfring *ring);
981 
987 int pfring_disable_ring(pfring *ring);
988 
997 int pfring_set_bpf_filter(pfring *ring, char *filter_buffer);
998 
1004 int pfring_remove_bpf_filter(pfring *ring);
1005 
1013 int pfring_set_filtering_mode(pfring *ring, filtering_mode mode);
1014 
1021 int pfring_get_device_clock(pfring *ring, struct timespec *ts);
1022 
1029 int pfring_set_device_clock(pfring *ring, struct timespec *ts);
1030 
1038 int pfring_adjust_device_clock(pfring *ring, struct timespec *offset, int8_t sign);
1039 
1045 
1052 int pfring_send_last_rx_packet(pfring *ring, int tx_interface_id);
1053 
1059 int pfring_get_link_status(pfring *ring);
1060 
1067 int pfring_flush_tx_packets(pfring *ring);
1068 
1075 int pfring_search_payload(pfring *ring, char *string_to_search);
1076 
1077 /* Utils (defined in pfring_utils.c) */
1078 
1090 int pfring_parse_pkt(u_char *pkt, struct pfring_pkthdr *hdr, u_int8_t level /* 2..4 */,
1091  u_int8_t add_timestamp /* 0,1 */, u_int8_t add_hash /* 0,1 */);
1098 int pfring_set_if_promisc(const char *device, int set_promisc);
1099 
1106 int pfring_set_promisc(pfring *ring, int set_promisc);
1107 
1116 char* pfring_format_numbers(double val, char *buf, u_int buf_len, u_int8_t add_decimals);
1117 
1126 int pfring_enable_hw_timestamp(pfring *ring, char *device_name, u_int8_t enable_rx, u_int8_t enable_tx);
1127 
1133 int pfring_get_mtu_size(pfring *ring);
1134 
1142 
1151 int pfring_print_parsed_pkt(char *buff, u_int buff_len, const u_char *p, const struct pfring_pkthdr *h);
1152 
1161 int pfring_print_pkt(char *buff, u_int buff_len, const u_char *p, u_int len, u_int caplen);
1162 
1171 int pfring_recv_chunk(pfring *ring, void **chunk, pfring_chunk_info *chunk_info, u_int8_t wait_for_incoming_chunk);
1172 
1179 int pfring_set_bound_dev_name(pfring *ring, char *custom_dev_name);
1180 
1188 int pfring_read_ixia_hw_timestamp(u_char *buffer, u_int32_t buffer_len, struct timespec *ts);
1189 
1197 void pfring_handle_ixia_hw_timestamp(u_char* buffer, struct pfring_pkthdr *hdr);
1198 
1206 int pfring_read_vss_apcon_hw_timestamp(u_char *buffer, u_int32_t buffer_len, struct timespec *ts);
1207 
1215 void pfring_handle_vss_apcon_hw_timestamp(u_char* buffer, struct pfring_pkthdr *hdr);
1216 
1222 u_int32_t pfring_get_interface_speed(pfring *ring);
1223 
1229 
1234 void pfring_freealldevs(pfring_if_t *list);
1235 
1236 /* ********************************* */
1237 
1238 int pfring_parse_bpf_filter(char *filter_buffer, u_int caplen,
1239  #ifdef BPF_RELEASE
1240  struct bpf_program
1241 #else
1242  struct pfring_bpf_program
1243 #endif
1244  *filter);
1245 
1246 void pfring_free_bpf_filter(
1247 #ifdef BPF_RELEASE
1248  struct bpf_program
1249 #else
1250  struct pfring_bpf_program
1251 #endif
1252  *filter);
1253 
1254 u_int32_t pfring_bpf_filter(void *bpf_insn, u_char *buffer, u_int32_t caplen, u_int32_t len);
1255 
1256 /* ********************************* */
1257 
1258 /* pfring_utils.h */
1259 int32_t gmt_to_local(time_t t);
1260 
1261 /* ********************************* */
1262 
1263 typedef struct {
1264  char *name;
1265  int (*open) (pfring *);
1266  pfring_if_t *(*findalldevs) (void);
1268 
1270  const char *name; /* Function name */
1271  void (*ptr)(void); /* Function pointer */
1272 };
1273 
1274 /* ********************************* */
1275 
1276 void pfring_thirdparty_lib_init(const char* thirdparty_lib_name,
1277  struct thirdparty_func thirdparty_function_ptr[]);
1278 
1279 #ifdef __cplusplus
1280 }
1281 #endif
1282 
1283 #endif /* _PFRING_H_ */
1284 
int pfring_set_packet_slicing(pfring *ring, packet_slicing_level level, u_int32_t additional_bytes)
int pfring_set_application_name(pfring *ring, char *name)
int pfring_print_parsed_pkt(char *buff, u_int buff_len, const u_char *p, const struct pfring_pkthdr *h)
int pfring_send_get_time(pfring *ring, char *pkt, u_int pkt_len, struct timespec *ts)
void pfring_freealldevs(pfring_if_t *list)
int pfring_set_poll_watermark(pfring *ring, u_int16_t watermark)
int pfring_is_pkt_available(pfring *ring)
int pfring_get_device_ifindex(pfring *ring, char *device_name, int *if_index)
void pfring_close(pfring *ring)
int pfring_set_bound_dev_name(pfring *ring, char *custom_dev_name)
Definition: pfring.h:160
Definition: pfring.h:1263
void pfring_sync_indexes_with_kernel(pfring *ring)
int pfring_set_direction(pfring *ring, packet_direction direction)
u_int8_t pfring_open_multichannel(const char *device_name, u_int32_t caplen, u_int32_t flags, pfring *ring[MAX_NUM_RX_CHANNELS])
int pfring_set_virtual_device(pfring *ring, virtual_filtering_device_info *info)
int pfring_purge_idle_rules(pfring *ring, u_int16_t inactivity_sec)
Definition: pfring.h:129
int pfring_remove_from_cluster(pfring *ring)
int pfring_set_application_stats(pfring *ring, char *stats)
Definition: pf_ring.h:338
void pfring_version_noring(u_int32_t *version)
int pfring_set_poll_watermark_timeout(pfring *ring, u_int16_t poll_watermark_timeout)
int pfring_flush_tx_packets(pfring *ring)
pfring_if_t * pfring_findalldevs(void)
int pfring_set_if_promisc(const char *device, int set_promisc)
int pfring_version(pfring *ring, u_int32_t *version)
int pfring_read_vss_apcon_hw_timestamp(u_char *buffer, u_int32_t buffer_len, struct timespec *ts)
void pfring_shutdown(pfring *ring)
int pfring_get_device_clock(pfring *ring, struct timespec *ts)
u_int32_t pfring_get_ring_id(pfring *ring)
u_int32_t pfring_get_interface_speed(pfring *ring)
int pfring_remove_filtering_rule(pfring *ring, u_int16_t rule_id)
Definition: pfring.h:176
int pfring_set_sampling_rate(pfring *ring, u_int32_t rate)
int pfring_read_ixia_hw_timestamp(u_char *buffer, u_int32_t buffer_len, struct timespec *ts)
PF_RING kernel module header file.
int pfring_toggle_filtering_policy(pfring *ring, u_int8_t rules_default_accept_policy)
Definition: pfring.h:195
int pfring_adjust_device_clock(pfring *ring, struct timespec *offset, int8_t sign)
int pfring_bind(pfring *ring, char *device_name)
Definition: pfring.h:168
int pfring_set_tx_watermark(pfring *ring, u_int16_t watermark)
int pfring_set_channel_id(pfring *ring, u_int32_t channel_id)
int pfring_purge_idle_hash_rules(pfring *ring, u_int16_t inactivity_sec)
int pfring_get_card_settings(pfring *ring, pfring_card_settings *settings)
int pfring_get_hash_filtering_rule_stats(pfring *ring, hash_filtering_rule *rule, char *stats, u_int *stats_len)
void pfring_breakloop(pfring *)
int pfring_parse_pkt(u_char *pkt, struct pfring_pkthdr *hdr, u_int8_t level, u_int8_t add_timestamp, u_int8_t add_hash)
void pfring_handle_ixia_hw_timestamp(u_char *buffer, struct pfring_pkthdr *hdr)
int pfring_enable_hw_timestamp(pfring *ring, char *device_name, u_int8_t enable_rx, u_int8_t enable_tx)
pfring * pfring_open(const char *device_name, u_int32_t caplen, u_int32_t flags)
int pfring_set_reflector_device(pfring *ring, char *device_name)
int pfring_set_vlan_id(pfring *ring, u_int16_t vlan_id)
int pfring_recv_parsed(pfring *ring, u_char **buffer, u_int buffer_len, struct pfring_pkthdr *hdr, u_int8_t wait_for_incoming_packet, u_int8_t level, u_int8_t add_timestamp, u_int8_t add_hash)
int pfring_enable_rss_rehash(pfring *ring)
int pfring_loop(pfring *ring, pfringProcesssPacket looper, const u_char *user_bytes, u_int8_t wait_for_packet)
int pfring_stats(pfring *ring, pfring_stat *stats)
int pfring_get_bound_device_address(pfring *ring, u_char mac_address[6])
int pfring_set_channel_mask(pfring *ring, u_int64_t channel_mask)
int pfring_recv_chunk(pfring *ring, void **chunk, pfring_chunk_info *chunk_info, u_int8_t wait_for_incoming_chunk)
int pfring_set_master(pfring *ring, pfring *master)
int pfring_get_bound_device_ifindex(pfring *ring, int *if_index)
int pfring_set_filtering_mode(pfring *ring, filtering_mode mode)
Definition: pfring.h:121
int pfring_handle_hash_filtering_rule(pfring *ring, hash_filtering_rule *rule_to_add, u_char add_rule)
int pfring_send_last_rx_packet(pfring *ring, int tx_interface_id)
int pfring_set_cluster(pfring *ring, u_int clusterId, cluster_type the_type)
int pfring_get_selectable_fd(pfring *ring)
int pfring_get_metadata(pfring *ring, u_char **metadata, u_int32_t *metadata_len)
int pfring_set_bpf_filter(pfring *ring, char *filter_buffer)
int pfring_remove_hw_rule(pfring *ring, u_int16_t rule_id)
int pfring_get_filtering_rule_stats(pfring *ring, u_int16_t rule_id, char *stats, u_int *stats_len)
char * pfring_get_appl_stats_file_name(pfring *ring, char *path, u_int path_len)
int pfring_get_link_status(pfring *ring)
int pfring_remove_bpf_filter(pfring *ring)
int pfring_recv(pfring *ring, u_char **buffer, u_int buffer_len, struct pfring_pkthdr *hdr, u_int8_t wait_for_incoming_packet)
u_int32_t pfring_get_num_queued_pkts(pfring *ring)
u_int8_t pfring_get_num_rx_channels(pfring *ring)
char * pfring_format_numbers(double val, char *buf, u_int buf_len, u_int8_t add_decimals)
int pfring_loopback_test(pfring *ring, char *buffer, u_int buffer_len, u_int test_len)
void pfring_handle_vss_apcon_hw_timestamp(u_char *buffer, struct pfring_pkthdr *hdr)
int pfring_print_pkt(char *buff, u_int buff_len, const u_char *p, u_int len, u_int caplen)
int pfring_set_poll_duration(pfring *ring, u_int duration)
int pfring_poll(pfring *ring, u_int wait_duration)
int pfring_next_pkt_time(pfring *ring, struct timespec *ts)
int pfring_set_device_clock(pfring *ring, struct timespec *ts)
u_int16_t pfring_get_slot_header_len(pfring *ring)
int pfring_disable_ring(pfring *ring)
int pfring_next_pkt_raw_timestamp(pfring *ring, u_int64_t *timestamp_ns)
Definition: pfring.h:1269
int pfring_search_payload(pfring *ring, char *string_to_search)
void pfring_config(u_short cpu_percentage)
int pfring_add_hw_rule(pfring *ring, hw_filtering_rule *rule)
int pfring_set_master_id(pfring *ring, u_int32_t master_id)
int pfring_get_mtu_size(pfring *ring)
int pfring_set_socket_mode(pfring *ring, socket_mode mode)
int pfring_set_promisc(pfring *ring, int set_promisc)
int pfring_add_filtering_rule(pfring *ring, filtering_rule *rule_to_add)
int pfring_send(pfring *ring, char *pkt, u_int pkt_len, u_int8_t flush_packet)
int pfring_enable_ring(pfring *ring)