tcp_flags.c revision 170268
11553Srgrimes/* $FreeBSD: head/contrib/ipfilter/lib/tcp_flags.c 170268 2007-06-04 02:54:36Z darrenr $ */ 21553Srgrimes 31553Srgrimes/* 41553Srgrimes * Copyright (C) 2000-2004 by Darren Reed. 51553Srgrimes * 61553Srgrimes * See the IPFILTER.LICENCE file for details on licencing. 71553Srgrimes * 81553Srgrimes * $Id: tcp_flags.c,v 1.8.2.1 2006/06/16 17:21:17 darrenr Exp $ 91553Srgrimes */ 101553Srgrimes 111553Srgrimes#include "ipf.h" 121553Srgrimes 131553Srgrimesextern char flagset[]; 141553Srgrimesextern u_char flags[]; 151553Srgrimes 161553Srgrimes 171553Srgrimesu_char tcp_flags(flgs, mask, linenum) 181553Srgrimeschar *flgs; 191553Srgrimesu_char *mask; 201553Srgrimesint linenum; 211553Srgrimes{ 221553Srgrimes u_char tcpf = 0, tcpfm = 0; 231553Srgrimes char *s; 241553Srgrimes 251553Srgrimes s = strchr(flgs, '/'); 261553Srgrimes if (s) 271553Srgrimes *s++ = '\0'; 281553Srgrimes 291553Srgrimes if (*flgs == '0') { 30114601Sobrien tcpf = strtol(flgs, NULL, 0); 311553Srgrimes } else { 3228643Ssteve tcpf = tcpflags(flgs); 331553Srgrimes } 341553Srgrimes 351553Srgrimes if (s != NULL) { 361553Srgrimes if (*s == '0') 371553Srgrimes tcpfm = strtol(s, NULL, 0); 381553Srgrimes else 39114601Sobrien tcpfm = tcpflags(s); 4028643Ssteve } 41119856Scharnier 4299141Sjmallett if (!tcpfm) { 4399141Sjmallett if (tcpf == TH_SYN) 4499141Sjmallett tcpfm = 0xff & ~(TH_ECN|TH_CWR); 451553Srgrimes else 461553Srgrimes tcpfm = 0xff & ~(TH_ECN); 471553Srgrimes } 481553Srgrimes *mask = tcpfm; 491553Srgrimes return tcpf; 501553Srgrimes} 511553Srgrimes