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