Skip to content

Commit

Permalink
Merge pull request #943 from utoni/fix/bpf_filter_const
Browse files Browse the repository at this point in the history
Make the bpf filter string for `pfring_set_bpf_filter()` unmutable.
  • Loading branch information
cardigliano authored Jun 10, 2024
2 parents 0d0386d + 81dc912 commit dca676a
Show file tree
Hide file tree
Showing 9 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion userland/lib/pfring.c
Original file line number Diff line number Diff line change
Expand Up @@ -1339,7 +1339,7 @@ int pfring_next_pkt_raw_timestamp(pfring *ring, u_int64_t *ts) {

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

int pfring_set_bpf_filter(pfring *ring, char *filter_buffer) {
int pfring_set_bpf_filter(pfring *ring, const char *filter_buffer) {
int rc = PF_RING_ERROR_NOT_SUPPORTED;

if (!ring)
Expand Down
6 changes: 3 additions & 3 deletions userland/lib/pfring.h
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ struct __pfring {
int (*enable_ring) (pfring *);
int (*disable_ring) (pfring *);
void (*shutdown) (pfring *);
int (*set_bpf_filter) (pfring *, char *);
int (*set_bpf_filter) (pfring *, const char *);
int (*remove_bpf_filter) (pfring *);
int (*get_device_clock) (pfring *, struct timespec *);
int (*set_device_clock) (pfring *, struct timespec *);
Expand Down Expand Up @@ -1066,7 +1066,7 @@ int pfring_disable_ring(pfring *ring);
* @param filter_buffer The filter to set.
* @return 0 on success, a negative value otherwise.
*/
int pfring_set_bpf_filter(pfring *ring, char *filter_buffer);
int pfring_set_bpf_filter(pfring *ring, const char *filter_buffer);

/**
* Remove the BPF filter.
Expand Down Expand Up @@ -1388,7 +1388,7 @@ void pfring_freealldevs(pfring_if_t *list);

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

int pfring_parse_bpf_filter(char *filter_buffer, u_int caplen,
int pfring_parse_bpf_filter(const char *filter_buffer, u_int caplen,
#ifdef BPF_RELEASE
struct bpf_program
#else
Expand Down
2 changes: 1 addition & 1 deletion userland/lib/pfring_mod.c
Original file line number Diff line number Diff line change
Expand Up @@ -941,7 +941,7 @@ int __pfring_mod_remove_bpf_filter(pfring *ring) {

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

int pfring_mod_set_bpf_filter(pfring *ring, char *filter_buffer) {
int pfring_mod_set_bpf_filter(pfring *ring, const char *filter_buffer) {
int rc = -1;
#ifdef ENABLE_BPF
pcap_t *p;
Expand Down
2 changes: 1 addition & 1 deletion userland/lib/pfring_mod.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ int pfring_mod_set_virtual_device(pfring *ring, virtual_filtering_device_info *i
int pfring_mod_loopback_test(pfring *ring, char *buffer, u_int buffer_len, u_int test_len);
int pfring_mod_enable_ring(pfring *ring);
int pfring_mod_disable_ring(pfring *ring);
int pfring_mod_set_bpf_filter(pfring *ring, char *filter_buffer);
int pfring_mod_set_bpf_filter(pfring *ring, const char *filter_buffer);
int pfring_mod_remove_bpf_filter(pfring *ring);
int pfring_mod_send_last_rx_packet(pfring *ring, int tx_interface_id);
void pfring_mod_shutdown(pfring *ring);
Expand Down
2 changes: 1 addition & 1 deletion userland/lib/pfring_mod_pcap.c
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ int pfring_mod_pcap_stats(pfring *ring, pfring_stat *stats) {

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

int pfring_mod_pcap_set_bpf_filter(pfring *ring, char *bpfFilter) {
int pfring_mod_pcap_set_bpf_filter(pfring *ring, const char *bpfFilter) {
pfring_pcap *pcap;
struct bpf_program fcode;
int rc;
Expand Down
2 changes: 1 addition & 1 deletion userland/lib/pfring_mod_pcap.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@ int pfring_mod_pcap_enable_ring(pfring *ring);
int pfring_mod_pcap_stats(pfring *ring, pfring_stat *stats);
int pfring_mod_pcap_set_socket_mode(pfring *ring, socket_mode mode);
int pfring_mod_pcap_set_poll_watermark(pfring *ring, u_int16_t watermark);
int pfring_mod_pcap_set_bpf_filter(pfring *ring, char *filter_buffer);
int pfring_mod_pcap_set_bpf_filter(pfring *ring, const char *filter_buffer);

#endif /* _PFRING_MOD_PCAP_H_ */
2 changes: 1 addition & 1 deletion userland/lib/pfring_mod_sysdig.c
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,7 @@ int pfring_mod_sysdig_get_bound_device_ifindex(pfring *ring, int *if_index) {
The currently accepted syntax is "evt.type=X or evt.type=Y ..." that is a subset
of the syntax supported by the sysdig command
*/
int pfring_mod_sysdig_set_bpf_filter(pfring *ring, char *filter_buffer) {
int pfring_mod_sysdig_set_bpf_filter(pfring *ring, const char *filter_buffer) {
u_int32_t device_id;
pfring_sysdig *sysdig;
char *filter, *item, *where;
Expand Down
2 changes: 1 addition & 1 deletion userland/lib/pfring_mod_sysdig.h
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ int pfring_mod_sysdig_set_socket_mode(pfring *ring, socket_mode mode);
int pfring_mod_sysdig_set_poll_watermark(pfring *ring, u_int16_t watermark);
int pfring_mod_sysdig_stats(pfring *ring, pfring_stat *stats);
int pfring_mod_sysdig_get_bound_device_ifindex(pfring *ring, int *if_index);
int pfring_mod_sysdig_set_bpf_filter(pfring *ring, char *filter_buffer);
int pfring_mod_sysdig_set_bpf_filter(pfring *ring, const char *filter_buffer);
int pfring_mod_sysdig_remove_bpf_filter(pfring *ring);

/* Public functions */
Expand Down
2 changes: 1 addition & 1 deletion userland/lib/pfring_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -851,7 +851,7 @@ int pfring_get_mtu_size(pfring* ring) {

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

int pfring_parse_bpf_filter(char *filter_buffer, u_int caplen,
int pfring_parse_bpf_filter(const char *filter_buffer, u_int caplen,
#ifdef BPF_RELEASE
struct bpf_program
#else
Expand Down

0 comments on commit dca676a

Please sign in to comment.