xref: /titanic_50/usr/src/cmd/ipf/lib/common/optprint.c (revision 6185db853e024a486ff8837e6784dd290d866112)
1 /*
2  * Copyright (C) 1993-2001 by Darren Reed.
3  *
4  * See the IPFILTER.LICENCE file for details on licencing.
5  *
6  * $Id: optprint.c,v 1.6 2002/07/13 15:59:49 darrenr Exp $
7  */
8 #include "ipf.h"
9 
10 
11 void optprint(sec, optmsk, optbits)
12 u_short *sec;
13 u_long optmsk, 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 				if (io->on_value == IPOPT_SECURITY)
27 					io++;
28 				s = ",";
29 			}
30 		}
31 
32 
33 	if (secmsk & secbits) {
34 		printf("%ssec-class", s);
35 		s = " ";
36 		for (so = secclass; so->on_name; so++)
37 			if ((secmsk & so->on_bit) &&
38 			    ((so->on_bit & secmsk) == (so->on_bit & secbits))) {
39 				printf("%s%s", s, so->on_name);
40 				s = ",";
41 			}
42 	}
43 
44 	if ((optmsk && (optmsk != optbits)) ||
45 	    (secmsk && (secmsk != secbits))) {
46 		s = " ";
47 		printf(" not opt");
48 		if (optmsk != optbits) {
49 			for (io = ionames; io->on_name; io++)
50 				if ((io->on_bit & optmsk) &&
51 				    ((io->on_bit & optmsk) !=
52 				     (io->on_bit & optbits))) {
53 					if ((io->on_value != IPOPT_SECURITY) ||
54 					    (!secmsk && !secbits)) {
55 						printf("%s%s", s, io->on_name);
56 						s = ",";
57 						if (io->on_value ==
58 						    IPOPT_SECURITY)
59 							io++;
60 					} else
61 						io++;
62 				}
63 		}
64 
65 		if (secmsk != secbits) {
66 			printf("%ssec-class", s);
67 			s = " ";
68 			for (so = secclass; so->on_name; so++)
69 				if ((so->on_bit & secmsk) &&
70 				    ((so->on_bit & secmsk) !=
71 				     (so->on_bit & secbits))) {
72 					printf("%s%s", s, so->on_name);
73 					s = ",";
74 				}
75 		}
76 	}
77 }
78