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