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 11 #include "ipf.h" 12 13 14 /* 15 * ECN is a new addition to TCP - RFC 2481 16 */ 17 #ifndef TH_ECN 18 # define TH_ECN 0x40 19 #endif 20 #ifndef TH_CWR 21 # define TH_CWR 0x80 22 #endif 23 24 extern char flagset[]; 25 extern u_char flags[]; 26 27 28 u_char tcpflags(char *flgs) 29 { 30 u_char tcpf = 0; 31 char *s, *t; 32 33 for (s = flgs; *s; s++) { 34 if (*s == 'W') 35 tcpf |= TH_CWR; 36 else { 37 if (!(t = strchr(flagset, *s))) { 38 return (0); 39 } 40 tcpf |= flags[t - flagset]; 41 } 42 } 43 return (tcpf); 44 } 45