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