1*0Sstevel@tonic-gate /* 2*0Sstevel@tonic-gate * Copyright (C) 1993-2001 by Darren Reed. 3*0Sstevel@tonic-gate * 4*0Sstevel@tonic-gate * See the IPFILTER.LICENCE file for details on licencing. 5*0Sstevel@tonic-gate * 6*0Sstevel@tonic-gate * $Id: tcpflags.c,v 1.3 2002/11/02 07:18:01 darrenr Exp $ 7*0Sstevel@tonic-gate */ 8*0Sstevel@tonic-gate 9*0Sstevel@tonic-gate #include "ipf.h" 10*0Sstevel@tonic-gate 11*0Sstevel@tonic-gate 12*0Sstevel@tonic-gate /* 13*0Sstevel@tonic-gate * ECN is a new addition to TCP - RFC 2481 14*0Sstevel@tonic-gate */ 15*0Sstevel@tonic-gate #ifndef TH_ECN 16*0Sstevel@tonic-gate # define TH_ECN 0x40 17*0Sstevel@tonic-gate #endif 18*0Sstevel@tonic-gate #ifndef TH_CWR 19*0Sstevel@tonic-gate # define TH_CWR 0x80 20*0Sstevel@tonic-gate #endif 21*0Sstevel@tonic-gate 22*0Sstevel@tonic-gate extern char flagset[]; 23*0Sstevel@tonic-gate extern u_char flags[]; 24*0Sstevel@tonic-gate 25*0Sstevel@tonic-gate tcpflags(flgs)26*0Sstevel@tonic-gateu_char tcpflags(flgs) 27*0Sstevel@tonic-gate char *flgs; 28*0Sstevel@tonic-gate { 29*0Sstevel@tonic-gate u_char tcpf = 0; 30*0Sstevel@tonic-gate char *s, *t; 31*0Sstevel@tonic-gate 32*0Sstevel@tonic-gate for (s = flgs; *s; s++) { 33*0Sstevel@tonic-gate if (*s == 'W') 34*0Sstevel@tonic-gate tcpf |= TH_CWR; 35*0Sstevel@tonic-gate else { 36*0Sstevel@tonic-gate if (!(t = strchr(flagset, *s))) { 37*0Sstevel@tonic-gate return 0; 38*0Sstevel@tonic-gate } 39*0Sstevel@tonic-gate tcpf |= flags[t - flagset]; 40*0Sstevel@tonic-gate } 41*0Sstevel@tonic-gate } 42*0Sstevel@tonic-gate return tcpf; 43*0Sstevel@tonic-gate } 44