Created
July 25, 2016 18:49
-
-
Save J-Gras/f6bfb6092d29aa0e9c53eb98e23a7955 to your computer and use it in GitHub Desktop.
Logging of first packet's source IP.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Adds first packet's source IP to conn.log. | |
redef record connection += { | |
first_pkt_src: addr &optional; | |
}; | |
redef record Conn::Info += { | |
## Source address of the first packet. | |
first_pkt_src: addr &optional &log; | |
}; | |
event new_connection(c: connection) | |
{ | |
local hdr: raw_pkt_hdr = get_current_packet_header(); | |
if ( hdr?$ip ) | |
c$first_pkt_src = hdr$ip$src; | |
else if (hdr?$ip6 ) | |
c$first_pkt_src = hdr$ip6$src; | |
} | |
event connection_state_remove(c: connection) | |
{ | |
if ( c?$first_pkt_src ) | |
c$conn$first_pkt_src = c$first_pkt_src; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment