decode: return bool network layer

So that the caller can set the correct event type on error.
pull/4802/head
Victor Julien 5 years ago
parent 328a94206e
commit d5712efc91

@ -87,8 +87,11 @@ int DecodeVLAN(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p,
p->vlan_id[p->vlan_idx++] = (uint16_t)GET_VLAN_ID(vlan_hdr);
DecodeNetworkLayer(tv, dtv, proto, p, pkt + VLAN_HEADER_LEN, len - VLAN_HEADER_LEN);
if (DecodeNetworkLayer(tv, dtv, proto, p,
pkt + VLAN_HEADER_LEN, len - VLAN_HEADER_LEN) == false) {
ENGINE_SET_INVALID_EVENT(p, VLAN_UNKNOWN_TYPE);
return TM_ECODE_FAILED;
}
return TM_ECODE_OK;
}

@ -1189,7 +1189,9 @@ static inline void DecodeLinkLayer(ThreadVars *tv, DecodeThreadVars *dtv,
}
}
static inline void DecodeNetworkLayer(ThreadVars *tv, DecodeThreadVars *dtv,
/** \brief decode network layer
* \retval bool true if successful, false if unknown */
static inline bool DecodeNetworkLayer(ThreadVars *tv, DecodeThreadVars *dtv,
const uint16_t proto, Packet *p, const uint8_t *data, const uint32_t len)
{
switch (proto) {
@ -1235,10 +1237,10 @@ static inline void DecodeNetworkLayer(ThreadVars *tv, DecodeThreadVars *dtv,
}
break;
default:
SCLogDebug("unknown ether type: %" PRIx32 "", proto);
ENGINE_SET_INVALID_EVENT(p, VLAN_UNKNOWN_TYPE); // TODO
break;
SCLogDebug("unknown ether type: %" PRIx16 "", proto);
return false;
}
return true;
}
#endif /* __DECODE_H__ */

Loading…
Cancel
Save