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