mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 06:38:20 +00:00
Merge remote-tracking branch 'origin/master' into topic/icmp6
This commit is contained in:
commit
79a6da285f
95 changed files with 4365 additions and 1210 deletions
|
@ -38,33 +38,6 @@ int ones_complement_checksum(const IPAddr& a, uint32 sum)
|
|||
return ones_complement_checksum(bytes, len*4, sum);
|
||||
}
|
||||
|
||||
int tcp_checksum(const struct ip* ip, const struct tcphdr* tp, int len)
|
||||
{
|
||||
// ### Note, this is only correct for IPv4. This routine is only
|
||||
// used by the connection compressor (which we turn off for IPv6
|
||||
// traffic).
|
||||
|
||||
int tcp_len = tp->th_off * 4 + len;
|
||||
uint32 sum;
|
||||
|
||||
if ( len % 2 == 1 )
|
||||
// Add in pad byte.
|
||||
sum = htons(((const u_char*) tp)[tcp_len - 1] << 8);
|
||||
else
|
||||
sum = 0;
|
||||
|
||||
sum = ones_complement_checksum((void*) &ip->ip_src.s_addr, 4, sum);
|
||||
sum = ones_complement_checksum((void*) &ip->ip_dst.s_addr, 4, sum);
|
||||
|
||||
uint32 addl_pseudo =
|
||||
(htons(IPPROTO_TCP) << 16) | htons((unsigned short) tcp_len);
|
||||
|
||||
sum = ones_complement_checksum((void*) &addl_pseudo, 4, sum);
|
||||
sum = ones_complement_checksum((void*) tp, tcp_len, sum);
|
||||
|
||||
return sum;
|
||||
}
|
||||
|
||||
int udp_checksum(const struct ip* ip, const struct udphdr* up, int len)
|
||||
{
|
||||
uint32 sum;
|
||||
|
@ -191,12 +164,11 @@ const char* fmt_conn_id(const IPAddr& src_addr, uint32 src_port,
|
|||
const char* fmt_conn_id(const uint32* src_addr, uint32 src_port,
|
||||
const uint32* dst_addr, uint32 dst_port)
|
||||
{
|
||||
IPAddr src(IPAddr::IPv6, src_addr, IPAddr::Network);
|
||||
IPAddr dst(IPAddr::IPv6, dst_addr, IPAddr::Network);
|
||||
IPAddr src(IPv6, src_addr, IPAddr::Network);
|
||||
IPAddr dst(IPv6, dst_addr, IPAddr::Network);
|
||||
return fmt_conn_id(src, src_port, dst, dst_port);
|
||||
}
|
||||
|
||||
|
||||
uint32 extract_uint32(const u_char* data)
|
||||
{
|
||||
uint32 val;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue