~ubuntu-branches/ubuntu/karmic/conntrack/karmic

« back to all changes in this revision

Viewing changes to extensions/libct_proto_icmp.c

  • Committer: Bazaar Package Importer
  • Author(s): Andres Rodriguez
  • Date: 2009-06-18 18:27:31 UTC
  • mfrom: (3.1.2 squeeze)
  • Revision ID: james.westby@ubuntu.com-20090618182731-xlunt56xusrrif92
Tags: 1:0.9.12-1ubuntu1
* Merge from debian unstable (LP: #380358), remaining changes:
  - Error on fwrite failure in src/read_config_lex.c.
  - Patch from Kees Cook to not ignore return value of chdir call.
* debian/copyright: Updated download site.

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
#include <netinet/in.h> /* For htons */
18
18
#include <netinet/ip_icmp.h>
19
19
#include <libnetfilter_conntrack/libnetfilter_conntrack.h>
20
 
#include <libnetfilter_conntrack/libnetfilter_conntrack_icmp.h>
 
20
 
 
21
enum {
 
22
        CT_ICMP_TYPE    = (1 << 0),
 
23
        CT_ICMP_CODE    = (1 << 1),
 
24
        CT_ICMP_ID      = (1 << 2),
 
25
};
21
26
 
22
27
static struct option opts[] = {
23
28
        {"icmp-type", 1, 0, '1'},
67
72
                 unsigned int *flags)
68
73
{
69
74
        switch(c) {
 
75
                u_int8_t tmp;
 
76
                u_int16_t id;
70
77
                case '1':
71
 
                        if (!optarg)
72
 
                                break;
73
 
 
74
 
                        nfct_set_attr_u8(ct, 
75
 
                                         ATTR_ICMP_TYPE,
76
 
                                         atoi(optarg));
77
 
 
 
78
                        tmp = atoi(optarg);
 
79
                        nfct_set_attr_u8(ct, ATTR_ICMP_TYPE, tmp);
78
80
                        nfct_set_attr_u8(ct, ATTR_L4PROTO, IPPROTO_ICMP);
79
 
 
80
 
                        *flags |= ICMP_TYPE;
 
81
                        *flags |= CT_ICMP_TYPE;
81
82
                        break;
82
83
                case '2':
83
 
                        if (!optarg)
84
 
                                break;
85
 
 
86
 
                        nfct_set_attr_u8(ct, 
87
 
                                         ATTR_ICMP_CODE,
88
 
                                         atoi(optarg));
89
 
 
 
84
                        tmp = atoi(optarg);
 
85
                        nfct_set_attr_u8(ct, ATTR_ICMP_CODE, tmp);
90
86
                        nfct_set_attr_u8(ct, ATTR_L4PROTO, IPPROTO_ICMP);
91
 
 
92
 
                        *flags |= ICMP_CODE;
 
87
                        *flags |= CT_ICMP_CODE;
93
88
                        break;
94
89
                case '3':
95
 
                        if (!optarg)
96
 
                                break;
97
 
 
98
 
                        nfct_set_attr_u16(ct,
99
 
                                          ATTR_ICMP_ID,
100
 
                                          htons(atoi(optarg)));
101
 
 
 
90
                        id = htons(atoi(optarg));
 
91
                        nfct_set_attr_u16(ct, ATTR_ICMP_ID, id);
102
92
                        nfct_set_attr_u8(ct, ATTR_L4PROTO, IPPROTO_ICMP);
103
 
 
104
 
                        *flags |= ICMP_ID;
 
93
                        *flags |= CT_ICMP_ID;
105
94
                        break;
106
95
        }
107
96
        return 1;