mirror of
https://github.com/zeek/zeek.git
synced 2025-10-14 04:28:20 +00:00
Refactoring various usages of new IPAddr class.
Reducing number of places that internal representation was exposed via GetBytes/CopyIPv6. Also fixed a bug in remask_addr bif.
This commit is contained in:
parent
d887eb3178
commit
d7dafe2fe2
24 changed files with 301 additions and 267 deletions
12
src/PIA.cc
12
src/PIA.cc
|
@ -199,21 +199,17 @@ void PIA_TCP::FirstPacket(bool is_orig, const IP_Hdr* ip)
|
|||
ip4_hdr = new IP_Hdr((const struct ip*) ip4);
|
||||
}
|
||||
|
||||
const uint32* obytes;
|
||||
const uint32* rbytes;
|
||||
Conn()->OrigAddr().GetBytes(&obytes);
|
||||
Conn()->RespAddr().GetBytes(&rbytes);
|
||||
if ( is_orig )
|
||||
{
|
||||
memcpy(&ip4->ip_src.s_addr, obytes, sizeof(uint32));
|
||||
memcpy(&ip4->ip_dst.s_addr, rbytes, sizeof(uint32));
|
||||
Conn()->OrigAddr().CopyIPv4(&ip4->ip_src);
|
||||
Conn()->RespAddr().CopyIPv4(&ip4->ip_dst);
|
||||
tcp4->th_sport = htons(Conn()->OrigPort());
|
||||
tcp4->th_dport = htons(Conn()->RespPort());
|
||||
}
|
||||
else
|
||||
{
|
||||
memcpy(&ip4->ip_src.s_addr, rbytes, sizeof(uint32));
|
||||
memcpy(&ip4->ip_dst.s_addr, obytes, sizeof(uint32));
|
||||
Conn()->RespAddr().CopyIPv4(&ip4->ip_src);
|
||||
Conn()->OrigAddr().CopyIPv4(&ip4->ip_dst);
|
||||
tcp4->th_sport = htons(Conn()->RespPort());
|
||||
tcp4->th_dport = htons(Conn()->OrigPort());
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue