141edb306SCy Schubert 241edb306SCy Schubert /* 341edb306SCy Schubert * Copyright (C) 2012 by Darren Reed. 441edb306SCy Schubert * 541edb306SCy Schubert * See the IPFILTER.LICENCE file for details on licencing. 641edb306SCy Schubert * 741edb306SCy Schubert * $Id$ 841edb306SCy Schubert */ 941edb306SCy Schubert 1041edb306SCy Schubert #include "ipf.h" 1141edb306SCy Schubert 1241edb306SCy Schubert 1341edb306SCy Schubert /* 1441edb306SCy Schubert * ECN is a new addition to TCP - RFC 2481 1541edb306SCy Schubert */ 1641edb306SCy Schubert #ifndef TH_ECN 1741edb306SCy Schubert # define TH_ECN 0x40 1841edb306SCy Schubert #endif 1941edb306SCy Schubert #ifndef TH_CWR 2041edb306SCy Schubert # define TH_CWR 0x80 2141edb306SCy Schubert #endif 22*347dd053SRichard Scheffenegger #ifndef TH_AE 23*347dd053SRichard Scheffenegger # define TH_AE 0x100 24*347dd053SRichard Scheffenegger #endif 2541edb306SCy Schubert 2641edb306SCy Schubert extern char flagset[]; 27*347dd053SRichard Scheffenegger extern uint16_t flags[]; 2841edb306SCy Schubert 2941edb306SCy Schubert tcpflags(char * flgs)30*347dd053SRichard Scheffeneggeruint16_t tcpflags(char *flgs) 3141edb306SCy Schubert { 32*347dd053SRichard Scheffenegger uint16_t tcpf = 0; 3341edb306SCy Schubert char *s, *t; 3441edb306SCy Schubert 3541edb306SCy Schubert for (s = flgs; *s; s++) { 3641edb306SCy Schubert if (*s == 'W') 3741edb306SCy Schubert tcpf |= TH_CWR; 3841edb306SCy Schubert else { 3941edb306SCy Schubert if (!(t = strchr(flagset, *s))) { 402582ae57SCy Schubert return (0); 4141edb306SCy Schubert } 4241edb306SCy Schubert tcpf |= flags[t - flagset]; 4341edb306SCy Schubert } 4441edb306SCy Schubert } 452582ae57SCy Schubert return (tcpf); 4641edb306SCy Schubert } 47