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