xref: /netbsd-src/external/bsd/ipf/dist/lib/printtcpflags.c (revision bc4097aacfdd9307c19b7947c13c6ad6982527a9)
1*bc4097aaSchristos /*	$NetBSD: printtcpflags.c,v 1.1.1.1 2012/03/23 21:20:10 christos Exp $	*/
2*bc4097aaSchristos 
3*bc4097aaSchristos #include "ipf.h"
4*bc4097aaSchristos 
5*bc4097aaSchristos 
6*bc4097aaSchristos void
printtcpflags(tcpf,tcpfm)7*bc4097aaSchristos printtcpflags(tcpf, tcpfm)
8*bc4097aaSchristos 	u_32_t tcpf, tcpfm;
9*bc4097aaSchristos {
10*bc4097aaSchristos 	u_char *t;
11*bc4097aaSchristos 	char *s;
12*bc4097aaSchristos 
13*bc4097aaSchristos 	if (tcpf & ~TCPF_ALL) {
14*bc4097aaSchristos 		PRINTF("0x%x", tcpf);
15*bc4097aaSchristos 	} else {
16*bc4097aaSchristos 		for (s = flagset, t = flags; *s; s++, t++) {
17*bc4097aaSchristos 			if (tcpf & *t)
18*bc4097aaSchristos 				(void)putchar(*s);
19*bc4097aaSchristos 		}
20*bc4097aaSchristos 	}
21*bc4097aaSchristos 
22*bc4097aaSchristos 	if (tcpfm) {
23*bc4097aaSchristos 		(void)putchar('/');
24*bc4097aaSchristos 		if (tcpfm & ~TCPF_ALL) {
25*bc4097aaSchristos 			PRINTF("0x%x", tcpfm);
26*bc4097aaSchristos 		} else {
27*bc4097aaSchristos 			for (s = flagset, t = flags; *s; s++, t++)
28*bc4097aaSchristos 				if (tcpfm & *t)
29*bc4097aaSchristos 					(void)putchar(*s);
30*bc4097aaSchristos 		}
31*bc4097aaSchristos 	}
32*bc4097aaSchristos }
33