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