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