Commit 6ba0390
authored
libpcap: show error when a BPF filter fails to compile (#5022)
Closes #4587.
compile_filter() reported "Failed to compile filter expression X (-1)",
giving no hint why the filter was rejected: a syntax error, or a filter
incompatible with the link-layer type (for example a wlan filter on an
Ethernet interface).
Compile through a pcap handle in both the linktype and interface paths
(pcap_open_dead needs neither an interface nor root) and, on failure,
retrieve the message from pcap_geterr(). The exception now reads e.g.
"... (802.11 link-layer types supported only on 802.11)" or
"... (can't parse filter expression: syntax error)".
Adds a regression test in test/regression.uts.
AI-Assisted: yes (Claude Opus 4.8)
Co-authored-by: Eugen Goebel <eugen-goebel@users.noreply.github.com>1 parent abdf889 commit 6ba0390
2 files changed
Lines changed: 30 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
79 | 79 | | |
80 | 80 | | |
81 | 81 | | |
| 82 | + | |
82 | 83 | | |
83 | | - | |
| 84 | + | |
84 | 85 | | |
85 | 86 | | |
86 | 87 | | |
| |||
109 | 110 | | |
110 | 111 | | |
111 | 112 | | |
112 | | - | |
113 | | - | |
114 | | - | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
115 | 116 | | |
116 | 117 | | |
117 | 118 | | |
| |||
121 | 122 | | |
122 | 123 | | |
123 | 124 | | |
124 | | - | |
125 | | - | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
126 | 135 | | |
127 | 136 | | |
128 | | - | |
129 | 137 | | |
130 | | - | |
| 138 | + | |
131 | 139 | | |
| 140 | + | |
132 | 141 | | |
133 | 142 | | |
134 | 143 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2478 | 2478 | | |
2479 | 2479 | | |
2480 | 2480 | | |
| 2481 | + | |
| 2482 | + | |
| 2483 | + | |
| 2484 | + | |
| 2485 | + | |
| 2486 | + | |
| 2487 | + | |
| 2488 | + | |
| 2489 | + | |
| 2490 | + | |
| 2491 | + | |
| 2492 | + | |
| 2493 | + | |
2481 | 2494 | | |
2482 | 2495 | | |
2483 | 2496 | | |
| |||
0 commit comments