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: ipoptsec.c,v 1.2 2002/01/28 06:50:46 darrenr Exp $
7*0Sstevel@tonic-gate */
8*0Sstevel@tonic-gate
9*0Sstevel@tonic-gate #include "ipf.h"
10*0Sstevel@tonic-gate
11*0Sstevel@tonic-gate
12*0Sstevel@tonic-gate struct ipopt_names secclass[] = {
13*0Sstevel@tonic-gate { IPSO_CLASS_RES4, 0x01, 0, "reserv-4" },
14*0Sstevel@tonic-gate { IPSO_CLASS_TOPS, 0x02, 0, "topsecret" },
15*0Sstevel@tonic-gate { IPSO_CLASS_SECR, 0x04, 0, "secret" },
16*0Sstevel@tonic-gate { IPSO_CLASS_RES3, 0x08, 0, "reserv-3" },
17*0Sstevel@tonic-gate { IPSO_CLASS_CONF, 0x10, 0, "confid" },
18*0Sstevel@tonic-gate { IPSO_CLASS_UNCL, 0x20, 0, "unclass" },
19*0Sstevel@tonic-gate { IPSO_CLASS_RES2, 0x40, 0, "reserv-2" },
20*0Sstevel@tonic-gate { IPSO_CLASS_RES1, 0x80, 0, "reserv-1" },
21*0Sstevel@tonic-gate { 0, 0, 0, NULL } /* must be last */
22*0Sstevel@tonic-gate };
23*0Sstevel@tonic-gate
24*0Sstevel@tonic-gate
seclevel(slevel)25*0Sstevel@tonic-gate u_char seclevel(slevel)
26*0Sstevel@tonic-gate char *slevel;
27*0Sstevel@tonic-gate {
28*0Sstevel@tonic-gate struct ipopt_names *so;
29*0Sstevel@tonic-gate
30*0Sstevel@tonic-gate for (so = secclass; so->on_name; so++)
31*0Sstevel@tonic-gate if (!strcasecmp(slevel, so->on_name))
32*0Sstevel@tonic-gate break;
33*0Sstevel@tonic-gate
34*0Sstevel@tonic-gate if (!so->on_name) {
35*0Sstevel@tonic-gate fprintf(stderr, "no such security level: %s\n", slevel);
36*0Sstevel@tonic-gate return 0;
37*0Sstevel@tonic-gate }
38*0Sstevel@tonic-gate return (u_char)so->on_value;
39*0Sstevel@tonic-gate }
40*0Sstevel@tonic-gate
41*0Sstevel@tonic-gate
secbit(class)42*0Sstevel@tonic-gate u_char secbit(class)
43*0Sstevel@tonic-gate int class;
44*0Sstevel@tonic-gate {
45*0Sstevel@tonic-gate struct ipopt_names *so;
46*0Sstevel@tonic-gate
47*0Sstevel@tonic-gate for (so = secclass; so->on_name; so++)
48*0Sstevel@tonic-gate if (so->on_value == class)
49*0Sstevel@tonic-gate break;
50*0Sstevel@tonic-gate
51*0Sstevel@tonic-gate if (!so->on_name) {
52*0Sstevel@tonic-gate fprintf(stderr, "no such security class: %d\n", class);
53*0Sstevel@tonic-gate return 0;
54*0Sstevel@tonic-gate }
55*0Sstevel@tonic-gate return (u_char)so->on_bit;
56*0Sstevel@tonic-gate }
57