2 * Copyright (C) 1993-2001 by Darren Reed.
4 * See the IPFILTER.LICENCE file for details on licencing.
6 * $Id: addicmp.c,v 1.10.2.1 2004/12/09 19:41:16 darrenr Exp $
14 char *icmptypes
[MAX_ICMPTYPE
+ 1] = {
15 "echorep", NULL
, NULL
, "unreach", "squench",
16 "redir", NULL
, NULL
, "echo", "routerad",
17 "routersol", "timex", "paramprob", "timest", "timestrep",
18 "inforeq", "inforep", "maskreq", "maskrep", "END"
22 * set the icmp field to the correct type if "icmp" word is found
24 int addicmp(cp
, fp
, linenum
)
35 if (!fp
->fr_proto
) /* to catch lusers */
36 fp
->fr_proto
= IPPROTO_ICMP
;
38 if (!ratoi(**cp
, &i
, 0, 255)) {
40 "%d: Invalid icmp-type (%s) specified\n",
45 for (t
= icmptypes
, i
= 0; ; t
++, i
++) {
48 if (!strcasecmp("END", *t
)) {
52 if (!strcasecmp(*t
, **cp
))
57 "%d: Unknown icmp-type (%s) specified\n",
62 fp
->fr_icmp
= (u_short
)(i
<< 8);
63 fp
->fr_icmpm
= (u_short
)0xff00;
68 if (**cp
&& strcasecmp("code", **cp
))
72 if (!ratoi(**cp
, &i
, 0, 255)) {
74 "%d: Invalid icmp code (%s) specified\n",
82 "%d: Unknown icmp code (%s) specified\n",
88 fp
->fr_icmp
|= (u_short
)i
;
89 fp
->fr_icmpm
= (u_short
)0xffff;