base/frameworks/tunnels/main.bro
- 
Tunnel
This script handles the tracking/logging of tunnels (e.g. Teredo,
AYIYA, or IP-in-IP such as 6to4 where “IP” is either IPv4 or IPv6).
For any connection that occurs over a tunnel, information about its
encapsulating tunnels is also found in the tunnel field of
connection.
Detailed Interface
Options
- 
Tunnel::expiration_interval
- 
The amount of time a tunnel is not used in establishment of new
connections before it is considered inactive/expired. 
 
State Variables
- 
Tunnel::active
- 
Currently active tunnels.  That is, tunnels for which new,
encapsulated connections have been seen in the interval indicated by
Tunnel::expiration_interval.
 
 
Types
- 
Tunnel::Action
- 
| Type: | enum
 
Tunnel::DISCOVERA new tunnel (encapsulating “connection”) has been seen. 
Tunnel::CLOSEA tunnel connection has closed. 
Tunnel::EXPIRENo new connections over a tunnel happened in the amount of
time indicated by Tunnel::expiration_interval. | 
|---|
 
 - Types of interesting activity that can occur with a tunnel. 
- 
Tunnel::Info
- 
| Type: | record
 
ts: time&logTime at which some tunnel activity occurred.uid: string&log&optionalThe unique identifier for the tunnel, which may correspond
to a connection’s uid field for non-IP-in-IP tunnels.
This is optional because there could be numerous connections
for payload proxies like SOCKS but we should treat it as a
single tunnel.id: conn_id&logThe tunnel “connection” 4-tuple of endpoint addresses/ports.
For an IP tunnel, the ports will be 0.tunnel_type: Tunnel::Type&logThe type of tunnel.action: Tunnel::Action&logThe type of activity that occurred. | 
|---|
 
 - The record type which contains column fields of the tunnel log. 
 
Functions
- 
Tunnel::close
- 
Removes a single tunnel from the Tunnel::activetable
and logs the closing/expiration of the tunnel.
 
| Tunnel: | The tunnel which has closed or expired. | 
|---|
 | Action: | The specific reason for the tunnel ending. | 
|---|
 
 
- 
Tunnel::expire
- 
Logs a single tunnel “connection” with action
Tunnel::EXPIREand removes it from theTunnel::activetable.
 
| T: | A table of tunnels. | 
|---|
 | Idx: | The index of the tunnel table corresponding to the tunnel to expire. | 
|---|
 | Returns: | 0secs, which when this function is used as an &expire_func, indicates to remove the element at
idx immediately. | 
|---|
 
 
- 
Tunnel::register
- 
Logs a single tunnel “connection” with action
Tunnel::DISCOVERif it’s not already in theTunnel::activetable and adds it if not.
 
- 
Tunnel::register_all
- 
Logs all tunnels in an encapsulation chain with action
Tunnel::DISCOVERthat aren’t already in theTunnel::activetable and adds them if not.