Project

General

Profile

Feature #462 » 0001-Add-support-for-IPv4-in-IPv6.patch

Eric Leblond, 07/16/2012 09:14 AM

View differences:

src/decode-ipv6.c
#define IPV6_EXTHDRS ip6eh.ip6_exthdrs
#define IPV6_EH_CNT ip6eh.ip6_exthdrs_cnt
static int DecodeIPv4inIPv6(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, uint8_t *pkt, uint16_t plen, PacketQueue *pq)
{
/* Try to detect IPv4 in IPv6 */
if (IP_GET_RAW_VER(pkt) == 4) {
if (pq != NULL) {
Packet *tp = PacketPseudoPktSetup(p, pkt, plen, IPPROTO_IP);
if (tp != NULL) {
DecodeTunnel(tv, dtv, tp, GET_PKT_DATA(tp),
GET_PKT_LEN(tp), pq, IPPROTO_IP);
PacketEnqueue(pq,tp);
return 1;
}
}
}
return 0;
}
static void
DecodeIPV6ExtHdrs(ThreadVars *tv, DecodeThreadVars *dtv, Packet *p, uint8_t *pkt, uint16_t len, PacketQueue *pq)
{
......
SCReturn;
default:
if (DecodeIPv4inIPv6(tv, dtv, p, pkt, plen, pq) == 1) {
SCReturn;
}
IPV6_SET_L4PROTO(p,nh);
SCReturn;
}
......
DecodeIPV6ExtHdrs(tv, dtv, p, pkt + IPV6_HEADER_LEN, IPV6_GET_PLEN(p), pq);
break;
default:
if (DecodeIPv4inIPv6(tv, dtv, p, pkt + IPV6_HEADER_LEN, IPV6_GET_PLEN(p), pq) == 1) {
SCReturn;
}
p->proto = IPV6_GET_NH(p);
break;
}
(2-2/2)