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: optprint.c,v 1.6 2002/07/13 15:59:49 darrenr Exp $
7*0Sstevel@tonic-gate  */
8*0Sstevel@tonic-gate #include "ipf.h"
9*0Sstevel@tonic-gate 
10*0Sstevel@tonic-gate 
11*0Sstevel@tonic-gate void optprint(sec, optmsk, optbits)
12*0Sstevel@tonic-gate u_short *sec;
13*0Sstevel@tonic-gate u_long optmsk, optbits;
14*0Sstevel@tonic-gate {
15*0Sstevel@tonic-gate 	u_short secmsk = sec[0], secbits = sec[1];
16*0Sstevel@tonic-gate 	struct ipopt_names *io, *so;
17*0Sstevel@tonic-gate 	char *s;
18*0Sstevel@tonic-gate 
19*0Sstevel@tonic-gate 	s = " opt ";
20*0Sstevel@tonic-gate 	for (io = ionames; io->on_name; io++)
21*0Sstevel@tonic-gate 		if ((io->on_bit & optmsk) &&
22*0Sstevel@tonic-gate 		    ((io->on_bit & optmsk) == (io->on_bit & optbits))) {
23*0Sstevel@tonic-gate 			if ((io->on_value != IPOPT_SECURITY) ||
24*0Sstevel@tonic-gate 			    (!secmsk && !secbits)) {
25*0Sstevel@tonic-gate 				printf("%s%s", s, io->on_name);
26*0Sstevel@tonic-gate 				if (io->on_value == IPOPT_SECURITY)
27*0Sstevel@tonic-gate 					io++;
28*0Sstevel@tonic-gate 				s = ",";
29*0Sstevel@tonic-gate 			}
30*0Sstevel@tonic-gate 		}
31*0Sstevel@tonic-gate 
32*0Sstevel@tonic-gate 
33*0Sstevel@tonic-gate 	if (secmsk & secbits) {
34*0Sstevel@tonic-gate 		printf("%ssec-class", s);
35*0Sstevel@tonic-gate 		s = " ";
36*0Sstevel@tonic-gate 		for (so = secclass; so->on_name; so++)
37*0Sstevel@tonic-gate 			if ((secmsk & so->on_bit) &&
38*0Sstevel@tonic-gate 			    ((so->on_bit & secmsk) == (so->on_bit & secbits))) {
39*0Sstevel@tonic-gate 				printf("%s%s", s, so->on_name);
40*0Sstevel@tonic-gate 				s = ",";
41*0Sstevel@tonic-gate 			}
42*0Sstevel@tonic-gate 	}
43*0Sstevel@tonic-gate 
44*0Sstevel@tonic-gate 	if ((optmsk && (optmsk != optbits)) ||
45*0Sstevel@tonic-gate 	    (secmsk && (secmsk != secbits))) {
46*0Sstevel@tonic-gate 		s = " ";
47*0Sstevel@tonic-gate 		printf(" not opt");
48*0Sstevel@tonic-gate 		if (optmsk != optbits) {
49*0Sstevel@tonic-gate 			for (io = ionames; io->on_name; io++)
50*0Sstevel@tonic-gate 				if ((io->on_bit & optmsk) &&
51*0Sstevel@tonic-gate 				    ((io->on_bit & optmsk) !=
52*0Sstevel@tonic-gate 				     (io->on_bit & optbits))) {
53*0Sstevel@tonic-gate 					if ((io->on_value != IPOPT_SECURITY) ||
54*0Sstevel@tonic-gate 					    (!secmsk && !secbits)) {
55*0Sstevel@tonic-gate 						printf("%s%s", s, io->on_name);
56*0Sstevel@tonic-gate 						s = ",";
57*0Sstevel@tonic-gate 						if (io->on_value ==
58*0Sstevel@tonic-gate 						    IPOPT_SECURITY)
59*0Sstevel@tonic-gate 							io++;
60*0Sstevel@tonic-gate 					} else
61*0Sstevel@tonic-gate 						io++;
62*0Sstevel@tonic-gate 				}
63*0Sstevel@tonic-gate 		}
64*0Sstevel@tonic-gate 
65*0Sstevel@tonic-gate 		if (secmsk != secbits) {
66*0Sstevel@tonic-gate 			printf("%ssec-class", s);
67*0Sstevel@tonic-gate 			s = " ";
68*0Sstevel@tonic-gate 			for (so = secclass; so->on_name; so++)
69*0Sstevel@tonic-gate 				if ((so->on_bit & secmsk) &&
70*0Sstevel@tonic-gate 				    ((so->on_bit & secmsk) !=
71*0Sstevel@tonic-gate 				     (so->on_bit & secbits))) {
72*0Sstevel@tonic-gate 					printf("%s%s", s, so->on_name);
73*0Sstevel@tonic-gate 					s = ",";
74*0Sstevel@tonic-gate 				}
75*0Sstevel@tonic-gate 		}
76*0Sstevel@tonic-gate 	}
77*0Sstevel@tonic-gate }
78