10Sstevel@tonic-gate /* 20Sstevel@tonic-gate * Copyright (C) 1993-2001 by Darren Reed. 30Sstevel@tonic-gate * 40Sstevel@tonic-gate * See the IPFILTER.LICENCE file for details on licencing. 50Sstevel@tonic-gate * 6*2393Syz155240 * $Id: checkrev.c,v 1.12.2.1 2004/03/09 14:44:39 darrenr Exp $ 70Sstevel@tonic-gate */ 80Sstevel@tonic-gate 90Sstevel@tonic-gate #include <sys/ioctl.h> 100Sstevel@tonic-gate #include <fcntl.h> 110Sstevel@tonic-gate 120Sstevel@tonic-gate #include "ipf.h" 13*2393Syz155240 #include "netinet/ipl.h" 140Sstevel@tonic-gate checkrev(ipfname)150Sstevel@tonic-gateint checkrev(ipfname) 160Sstevel@tonic-gate char *ipfname; 170Sstevel@tonic-gate { 18*2393Syz155240 static int vfd = -1; 190Sstevel@tonic-gate struct friostat fio, *fiop = &fio; 200Sstevel@tonic-gate ipfobj_t ipfo; 210Sstevel@tonic-gate 220Sstevel@tonic-gate bzero((caddr_t)&ipfo, sizeof(ipfo)); 230Sstevel@tonic-gate ipfo.ipfo_rev = IPFILTER_VERSION; 240Sstevel@tonic-gate ipfo.ipfo_size = sizeof(*fiop); 250Sstevel@tonic-gate ipfo.ipfo_ptr = (void *)fiop; 260Sstevel@tonic-gate ipfo.ipfo_type = IPFOBJ_IPFSTAT; 270Sstevel@tonic-gate 28*2393Syz155240 if ((vfd == -1) && ((vfd = open(ipfname, O_RDONLY)) == -1)) { 290Sstevel@tonic-gate perror("open device"); 300Sstevel@tonic-gate return -1; 310Sstevel@tonic-gate } 320Sstevel@tonic-gate 330Sstevel@tonic-gate if (ioctl(vfd, SIOCGETFS, &ipfo)) { 340Sstevel@tonic-gate perror("ioctl(SIOCGETFS)"); 350Sstevel@tonic-gate close(vfd); 36*2393Syz155240 vfd = -1; 370Sstevel@tonic-gate return -1; 380Sstevel@tonic-gate } 390Sstevel@tonic-gate 400Sstevel@tonic-gate if (strncmp(IPL_VERSION, fio.f_version, sizeof(fio.f_version))) { 410Sstevel@tonic-gate return -1; 420Sstevel@tonic-gate } 430Sstevel@tonic-gate return 0; 440Sstevel@tonic-gate } 45