mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 06:38:20 +00:00
Add support for mobile IPv6 Mobility Header (RFC 6275).
- Accessible at script-layer through 'mobile_ipv6_message' event. - All Mobile IPv6 analysis now enabled through --enable-mobile-ipv6 configure-time option, otherwise the mobility header, routing type 2, and Home Address Destination option are ignored.
This commit is contained in:
parent
29724415c3
commit
91330f1e1c
37 changed files with 688 additions and 134 deletions
|
@ -12,6 +12,7 @@
|
|||
#include "Reporter.h"
|
||||
#include "net_util.h"
|
||||
#include "IPAddr.h"
|
||||
#include "IP.h"
|
||||
|
||||
// - adapted from tcpdump
|
||||
// Returns the ones-complement checksum of a chunk of b short-aligned bytes.
|
||||
|
@ -53,6 +54,31 @@ int icmp_checksum(const struct icmp* icmpp, int len)
|
|||
return sum;
|
||||
}
|
||||
|
||||
#ifdef ENABLE_MOBILE_IPV6
|
||||
int mobility_header_checksum(const IP_Hdr* ip)
|
||||
{
|
||||
const ip6_mobility* mh = ip->MobilityHeader();
|
||||
|
||||
if ( ! mh ) return 0;
|
||||
|
||||
uint32 sum = 0;
|
||||
uint8 mh_len = 8 + 8 * mh->ip6mob_len;
|
||||
|
||||
if ( mh_len % 2 == 1 )
|
||||
reporter->Weird(ip->SrcAddr(), ip->DstAddr(), "odd_mobility_hdr_len");
|
||||
|
||||
sum = ones_complement_checksum(ip->SrcAddr(), sum);
|
||||
sum = ones_complement_checksum(ip->DstAddr(), sum);
|
||||
// Note, for IPv6, strictly speaking the protocol and length fields are
|
||||
// 32 bits rather than 16 bits. But because the upper bits are all zero,
|
||||
// we get the same checksum either way.
|
||||
sum += htons(IPPROTO_MOBILITY);
|
||||
sum += htons(mh_len);
|
||||
sum = ones_complement_checksum(mh, mh_len, sum);
|
||||
|
||||
return sum;
|
||||
}
|
||||
#endif
|
||||
|
||||
#define CLASS_A 0x00000000
|
||||
#define CLASS_B 0x80000000
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue