1 /* 2 * Copyright (C) 1993-2001 by Darren Reed. 3 * 4 * See the IPFILTER.LICENCE file for details on licencing. 5 * 6 * $Id: tcpflags.c,v 1.3 2002/11/02 07:18:01 darrenr Exp $ 7 */ 8 9 #include "ipf.h" 10 11 12 /* 13 * ECN is a new addition to TCP - RFC 2481 14 */ 15 #ifndef TH_ECN 16 # define TH_ECN 0x40 17 #endif 18 #ifndef TH_CWR 19 # define TH_CWR 0x80 20 #endif 21 22 extern char flagset[]; 23 extern u_char flags[]; 24 25 tcpflags(flgs)26u_char tcpflags(flgs) 27 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