Solved "use of undeclared identifier 'IFNAMSIZ' char ifname[IFNAMSIZ];" error in pfvar.h

I'm trying to compile a simple file based on the example introduced in the pf(4).

My code looks like this:
Code:
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/ioctl.h>
#include <sys/fcntl.h>     // manipulate file descriptor                                              
#include <net/pfvar.h>
#include <net/if.h>
#include <netinet/in.h>
#include <err.h>


int main() {

  return 0;

}

On cc -o pftest pftest.c I get this:

Code:
In file included from pftest.c:7:
/usr/include/net/pfvar.h:151:18: error: use of undeclared identifier 'IFNAMSIZ'
                char                     ifname[IFNAMSIZ];
                                                ^
/usr/include/net/pfvar.h:415:18: error: use of undeclared identifier 'IFNAMSIZ'
        char                             ifname[IFNAMSIZ];
                                                ^
/usr/include/net/pfvar.h:568:17: error: use of undeclared identifier 'IFNAMSIZ'
        char                     ifname[IFNAMSIZ];
                                        ^
/usr/include/net/pfvar.h:853:16: error: use of undeclared identifier 'IFNAMSIZ'
        char             ifname[IFNAMSIZ];
                                ^
/usr/include/net/pfvar.h:1130:21: error: use of undeclared identifier 'IFNAMSIZ'
        char                             pfik_name[IFNAMSIZ];
                                                   ^
/usr/include/net/pfvar.h:1134:21: error: use of undeclared identifier 'IFNAMSIZ'
        char                             pfik_name[IFNAMSIZ];
                                                   ^
/usr/include/net/pfvar.h:1321:15: error: use of undeclared identifier 'IFNAMSIZ'
        char            ifname[IFNAMSIZ];

Looking at the pfvar.h there is no
Code:
ifname[IFNAMSIZ];
at any of the lines specified by the compiler. For example, this is line 151
Code:
#define PF_RULES_ASSERT()      rw_assert(&pf_rules_lock, RA_LOCKED)
, this is line 415
Code:
SLIST_HEAD(pf_osfp_enlist, pf_osfp_entry) fp_oses; /* list of matches */
, etc. The bottom line is that those errors do not correspond to the src. file.

What am I missing? Thanks.
 
tobik, thank you for catching that PF error, I edited my post to (hopefully) reflect the change. Adding the if.h header did it. Thanks so much.

fnoyanisi, thank you for the link. I was actually looking for something like that (a place where I can reference header contains).
 
Last edited by a moderator:
Back
Top