1 2 /* 3 * Copyright (C) 2012 by Darren Reed. 4 * 5 * See the IPFILTER.LICENCE file for details on licencing. 6 * 7 * $Id$ 8 */ 9 10 #include <sys/ioctl.h> 11 #include <fcntl.h> 12 13 #include "ipf.h" 14 #include "netinet/ipl.h" 15 16 int 17 checkrev(char *ipfname) 18 { 19 static int vfd = -1; 20 struct friostat fio; 21 ipfobj_t obj; 22 23 bzero((caddr_t)&obj, sizeof(obj)); 24 obj.ipfo_rev = IPFILTER_VERSION; 25 obj.ipfo_size = sizeof(fio); 26 obj.ipfo_ptr = (void *)&fio; 27 obj.ipfo_type = IPFOBJ_IPFSTAT; 28 29 if ((vfd == -1) && ((vfd = open(ipfname, O_RDONLY)) == -1)) { 30 perror("open device"); 31 return (-1); 32 } 33 34 if (ioctl(vfd, SIOCGETFS, &obj)) { 35 ipferror(vfd, "ioctl(SIOCGETFS)"); 36 close(vfd); 37 vfd = -1; 38 return (-1); 39 } 40 41 if (strncmp(IPL_VERSION, fio.f_version, sizeof(fio.f_version))) { 42 return (-1); 43 } 44 return (0); 45 } 46