~ubuntu-branches/ubuntu/precise/suricata/precise-proposed

« back to all changes in this revision

Viewing changes to src/detect-flags.c

  • Committer: Bazaar Package Importer
  • Author(s): Pierre Chifflier
  • Date: 2010-06-19 17:39:14 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20100619173914-5vkjfgz24mbia29z
Tags: 0.9.2-1
ImportedĀ UpstreamĀ versionĀ 0.9.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
111
111
{
112
112
    SCEnter();
113
113
 
114
 
    int ret = 0;
115
114
    uint8_t flags = 0;
116
115
    DetectFlagsData *de = (DetectFlagsData *)m->ctx;
117
116
 
118
 
    if(!de || !PKT_IS_IPV4(p) || !p || !p->tcph)
119
 
        return ret;
 
117
    if(!(PKT_IS_TCP(p))) {
 
118
        SCReturnInt(0);
 
119
    }
120
120
 
121
121
    flags = p->tcph->th_flags;
122
122
 
125
125
            SCReturnInt(1);
126
126
        }
127
127
 
128
 
        SCReturnInt(ret);
 
128
        SCReturnInt(0);
129
129
    }
130
130
 
131
131
    flags &= de->ignored_flags;
132
132
 
133
 
    switch(de->modifier)    {
 
133
    switch (de->modifier) {
134
134
        case MODIFIER_ANY:
135
 
            if((flags & de->flags) > 0) {
 
135
            if ((flags & de->flags) > 0) {
136
136
                SCReturnInt(1);
137
137
            }
138
 
            SCReturnInt(ret);
 
138
            SCReturnInt(0);
139
139
 
140
140
        case MODIFIER_PLUS:
141
 
            if(((flags & de->flags) == de->flags)) {
 
141
            if (((flags & de->flags) == de->flags)) {
142
142
                SCReturnInt(1);
143
143
            }
144
 
            SCReturnInt(ret);
 
144
            SCReturnInt(0);
145
145
 
146
146
        case MODIFIER_NOT:
147
 
            if((flags & de->flags) != de->flags) {
 
147
            if ((flags & de->flags) != de->flags) {
148
148
                SCReturnInt(1);
149
149
            }
150
 
            SCReturnInt(ret);
 
150
            SCReturnInt(0);
151
151
 
152
152
        default:
153
153
            SCLogDebug("flags %"PRIu8" and de->flags %"PRIu8"",flags,de->flags);
154
 
            if(flags == de->flags) {
 
154
            if (flags == de->flags) {
155
155
                SCReturnInt(1);
156
156
            }
157
157
    }
158
158
 
159
 
    SCReturnInt(ret);
 
159
    SCReturnInt(0);
160
160
}
161
161
 
162
162
/**