1 2 /* 3 * Copyright (C) 2000-2004 by Darren Reed. 4 * 5 * See the IPFILTER.LICENCE file for details on licencing. 6 * 7 * $Id: tcp_flags.c,v 1.8.2.1 2006/06/16 17:21:17 darrenr Exp $ 8 */ 9 10 #include "ipf.h" 11 12 extern char flagset[]; 13 extern u_char flags[]; 14 15 16 u_char tcp_flags(char *flgs, u_char *mask, int linenum) 17 { 18 u_char tcpf = 0, tcpfm = 0; 19 char *s; 20 21 s = strchr(flgs, '/'); 22 if (s) 23 *s++ = '\0'; 24 25 if (*flgs == '0') { 26 tcpf = strtol(flgs, NULL, 0); 27 } else { 28 tcpf = tcpflags(flgs); 29 } 30 31 if (s != NULL) { 32 if (*s == '0') 33 tcpfm = strtol(s, NULL, 0); 34 else 35 tcpfm = tcpflags(s); 36 } 37 38 if (!tcpfm) { 39 if (tcpf == TH_SYN) 40 tcpfm = 0xff & ~(TH_ECN|TH_CWR); 41 else 42 tcpfm = 0xff & ~(TH_ECN); 43 } 44 *mask = tcpfm; 45 return (tcpf); 46 } 47