1
2 /*
3 * Copyright (C) 2012 by Darren Reed.
4 *
5 * See the IPFILTER.LICENCE file for details on licencing.
6 *
7 * $Id$
8 */
9 #include "ipf.h"
10
11
12 void
optprint(u_short * sec,u_long optmsk,u_long optbits)13 optprint(u_short *sec, u_long optmsk, u_long optbits)
14 {
15 u_short secmsk = sec[0], secbits = sec[1];
16 struct ipopt_names *io, *so;
17 char *s;
18
19 s = " opt ";
20 for (io = ionames; io->on_name; io++)
21 if ((io->on_bit & optmsk) &&
22 ((io->on_bit & optmsk) == (io->on_bit & optbits))) {
23 if ((io->on_value != IPOPT_SECURITY) ||
24 (!secmsk && !secbits)) {
25 printf("%s%s", s, io->on_name);
26 /*
27 * Because the ionames table has this entry
28 * twice.
29 */
30 if (io->on_value == IPOPT_SECURITY)
31 io++;
32 s = ",";
33 }
34 }
35
36
37 if (secmsk & secbits) {
38 printf("%ssec-class", s);
39 s = " ";
40 for (so = secclass; so->on_name; so++)
41 if ((secmsk & so->on_bit) &&
42 ((so->on_bit & secmsk) == (so->on_bit & secbits))) {
43 printf("%s%s", s, so->on_name);
44 s = ",";
45 }
46 }
47
48 if ((optmsk && (optmsk != optbits)) ||
49 (secmsk && (secmsk != secbits))) {
50 s = " ";
51 printf(" not opt");
52 if (optmsk != optbits) {
53 for (io = ionames; io->on_name; io++)
54 if ((io->on_bit & optmsk) &&
55 ((io->on_bit & optmsk) !=
56 (io->on_bit & optbits))) {
57 if ((io->on_value != IPOPT_SECURITY) ||
58 (!secmsk && !secbits)) {
59 printf("%s%s", s, io->on_name);
60 s = ",";
61 if (io->on_value ==
62 IPOPT_SECURITY)
63 io++;
64 } else
65 io++;
66 }
67 }
68
69 if (secmsk != secbits) {
70 printf("%ssec-class", s);
71 s = " ";
72 for (so = secclass; so->on_name; so++)
73 if ((so->on_bit & secmsk) &&
74 ((so->on_bit & secmsk) !=
75 (so->on_bit & secbits))) {
76 printf("%s%s", s, so->on_name);
77 s = ",";
78 }
79 }
80 }
81 }
82