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