1 2 /* 3 * Copyright (C) 2012 by Darren Reed. 4 * 5 * See the IPFILTER.LICENCE file for details on licencing. 6 * 7 * $Id$ 8 */ 9 10 #include "ipf.h" 11 12 13 /* 14 * ECN is a new addition to TCP - RFC 2481 15 */ 16 #ifndef TH_ECN 17 # define TH_ECN 0x40 18 #endif 19 #ifndef TH_CWR 20 # define TH_CWR 0x80 21 #endif 22 23 extern char flagset[]; 24 extern u_char flags[]; 25 26 27 u_char tcpflags(char *flgs) 28 { 29 u_char tcpf = 0; 30 char *s, *t; 31 32 for (s = flgs; *s; s++) { 33 if (*s == 'W') 34 tcpf |= TH_CWR; 35 else { 36 if (!(t = strchr(flagset, *s))) { 37 return (0); 38 } 39 tcpf |= flags[t - flagset]; 40 } 41 } 42 return (tcpf); 43 } 44