blob: 077ebe5ca6b72337d6ca5d3aef2008360868f6c9 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
--- ioctl_helpers.c.orig 2021-04-19 18:12:17 UTC
+++ ioctl_helpers.c
@@ -160,46 +160,3 @@ radix_get_tstats(int dev, struct pfr_tstats **tstats,
*tstats = (struct pfr_tstats *)pt.pfrio_buffer;
return pt.pfrio_size;
}
-
-
-int
-get_states(int dev, struct pf_state **states) {
- struct pfioc_states ps;
- caddr_t inbuf, newinbuf;
- size_t len = 0;
-
- inbuf = newinbuf = NULL;
- memset(&ps, 0, sizeof(struct pfioc_states));
- *states = NULL;
- for (;;) {
- ps.ps_len = len;
- if (len) {
- newinbuf = realloc(inbuf, len);
- if (newinbuf == NULL) {
- if (inbuf != NULL) {
- free(inbuf);
- inbuf = newinbuf = NULL;
- return (-1);
- }
- }
- ps.ps_buf = inbuf = newinbuf;
- }
- if (ioctl(dev, DIOCGETSTATES, &ps) < 0) {
- if (inbuf != NULL) {
- free(inbuf);
- inbuf = newinbuf = NULL;
- }
- return (-1);
- }
- if (ps.ps_len + sizeof(struct pfioc_states) < len)
- break; /* We have states! */
- if (ps.ps_len == 0)
- return (0); /* No states available */
- if (len == 0)
- len = ps.ps_len;
- len *= 2;
- }
-
- *states = ps.ps_states;
- return ps.ps_len / sizeof(struct pf_state);
-}
|