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