#include "common.h"
#include "inet.h"
#include "nodes.h"
#include "sockets.h"
#include "settings.h"
#include "if/gnet_property.h"
#include "if/gnet_property_priv.h"
#include "lib/cq.h"
#include "lib/tm.h"
#include "lib/walloc.h"
#include "lib/override.h"
Data Structures | |
| struct | ip_record |
Defines | |
| #define | FW_STARTUP_GRACE 300 |
| Startup period: we send pongs. | |
| #define | FW_GRACE_INTERVAL 3600 |
| Every hour, new grace period. | |
| #define | FW_PERIODIC_GRACE 120 |
| We send pongs for 2 minutes. | |
| #define | FW_INCOMING_WINDOW 3600 |
| Incoming monitoring window. | |
| #define | FW_SOLICITED_WINDOW 3600 |
| Solicited UDP monitoring window. | |
| #define | FW_UDP_WINDOW 120 |
| 2 minutes, in most firewalls | |
| #define | OUTGOING_WINDOW 150 |
| Outgoing monitoring window. | |
Functions | |
| void | inet_set_is_connected (gboolean val) |
| Sets our internet connection status. | |
| ip_record * | ip_record_make (const host_addr_t addr) |
| Create a new ip_record structure. | |
| void | ip_record_free (struct ip_record *ipr) |
| Free ip_record structure. | |
| void | ip_record_free_remove (struct ip_record *ipr) |
| Free ip_record structure and remove it from the `outgoing_udp' table. | |
| void | ip_record_touch (struct ip_record *ipr) |
| Touch ip_record when we send a new datagram to that IP. | |
| void | ip_record_destroy (cqueue_t *unused_cq, gpointer obj) |
| Callout queue callback, invoked when it's time to destroy the record. | |
| gboolean | is_local_addr (const host_addr_t addr) |
| Checks whether a host address is considered being "local". | |
| void | inet_firewalled (void) |
| Called when we enter the firewalled status (TCP). | |
| void | inet_udp_firewalled (void) |
| Called when we enter the firewalled status (UDP). | |
| void | got_no_udp_solicited (cqueue_t *unused_cq, gpointer unused_obj) |
| This is a callback invoked when no solicited UDP has been received for some amount of time. | |
| void | inet_udp_got_solicited (void) |
| Called whenever we receive solicited UDP traffic. | |
| void | got_no_connection (cqueue_t *unused_cq, gpointer unused_obj) |
| This is a callback invoked when no incoming connection has been received for some amount of time. | |
| void | got_no_udp_unsolicited (cqueue_t *unused_cq, gpointer unused_obj) |
| This is a callback invoked when no unsolicited UDP datagrams have been received for some amount of time. | |
| void | inet_not_firewalled (void) |
| Called when we have determined we are definitely not TCP-firewalled. | |
| void | inet_udp_not_firewalled (void) |
| Called when we have determined we are definitely not UDP-firewalled. | |
| void | inet_got_incoming (const host_addr_t addr) |
| Called when we got an incoming connection from another computer at `ip'. | |
| void | inet_udp_got_unsolicited_incoming (void) |
| Called when we got an incoming unsolicited datagram from another computer at `ip'. | |
| void | inet_udp_got_incoming (const host_addr_t addr) |
| Called when we got an incoming datagram from another computer at `ip'. | |
| void | inet_udp_record_sent (const host_addr_t addr) |
| Record that we sent an UDP datagram to some host, thereby opening a breach on the firewall for the UDP reply. | |
| gboolean | inet_can_answer_ping (void) |
| Check whether we can answer a ping with a pong. | |
| void | check_outgoing_connection (cqueue_t *unused_cq, gpointer unused_obj) |
| This callback is periodically called when there has been outgoing connections attempted. | |
| void | inet_connection_attempted (const host_addr_t addr) |
| Called each time we attempt a connection. | |
| void | inet_connection_succeeded (const host_addr_t addr) |
| Called each time a connection attempt succeeds. | |
| void | inet_read_activity (void) |
| Called when reading activity occurred during a b/w scheduling period. | |
| void | inet_init (void) |
| Initialization code. | |
| void | free_ip_record (gpointer key, gpointer value, gpointer unused_udata) |
| Hash table iteration callback to free the "ip_record" structure. | |
| void | inet_close (void) |
| Shutdown cleanup. | |
Variables | |
| time_t | fw_time = 0 |
| When we last became firewalled. | |
| cevent_t * | incoming_ev |
| Callout queue timer. | |
| cevent_t * | incoming_udp_ev |
| Idem. | |
| cevent_t * | solicited_udp_ev |
| Idem. | |
| GHashTable * | outgoing_udp = NULL |
| Maps "IP" => "ip_record". | |
| gboolean | activity_seen |
| Activity recorded in period. | |
| cevent_t * | outgoing_ev |
| Callout queue timer. | |
|
|
Every hour, new grace period.
|
|
|
Incoming monitoring window.
|
|
|
We send pongs for 2 minutes.
|
|
|
Solicited UDP monitoring window.
|
|
|
Startup period: we send pongs.
|
|
|
2 minutes, in most firewalls
|
|
|
Outgoing monitoring window.
|
|
||||||||||||
|
This callback is periodically called when there has been outgoing connections attempted.
|
|
||||||||||||||||
|
Hash table iteration callback to free the "ip_record" structure.
|
|
||||||||||||
|
This is a callback invoked when no incoming connection has been received for some amount of time. We conclude we became firewalled. |
|
||||||||||||
|
This is a callback invoked when no solicited UDP has been received for some amount of time. We conclude we're no longer able to get solicited UDP traffic. |
|
||||||||||||
|
This is a callback invoked when no unsolicited UDP datagrams have been received for some amount of time. We conclude we became firewalled. |
|
|
Check whether we can answer a ping with a pong. Normally, when we're firewalled, we don't answer. However, if we have a non-private IP and are within a "grace period", act as if we were not: we can only know we're not firewalled when we get an incoming connection. |
|
|
Shutdown cleanup.
|
|
|
Called each time we attempt a connection.
|
|
|
Called each time a connection attempt succeeds.
|
|
|
Called when we enter the firewalled status (TCP).
|
|
|
Called when we got an incoming connection from another computer at `ip'.
|
|
|
Initialization code.
|
|
|
Called when we have determined we are definitely not TCP-firewalled.
|
|
|
Called when reading activity occurred during a b/w scheduling period.
|
|
|
Sets our internet connection status.
|
|
|
Called when we enter the firewalled status (UDP).
|
|
|
Called when we got an incoming datagram from another computer at `ip'.
|
|
|
Called whenever we receive solicited UDP traffic.
|
|
|
Called when we got an incoming unsolicited datagram from another computer at `ip'. i.e. the datagram was sent directly to our listening socket port, and not to a masqueraded port on the firewall opened because we previously sent out an UDP datagram to a host and got its reply. |
|
|
Called when we have determined we are definitely not UDP-firewalled.
|
|
|
Record that we sent an UDP datagram to some host, thereby opening a breach on the firewall for the UDP reply.
|
|
||||||||||||
|
Callout queue callback, invoked when it's time to destroy the record.
|
|
|
Free ip_record structure.
|
|
|
Free ip_record structure and remove it from the `outgoing_udp' table.
|
|
|
Create a new ip_record structure.
|
|
|
Touch ip_record when we send a new datagram to that IP.
|
|
|
Checks whether a host address is considered being "local".
|
|
|
Activity recorded in period.
|
|
|
When we last became firewalled.
|
|
|
Callout queue timer.
|
|
|
Idem.
|
|
|
Callout queue timer.
|
|
|
Maps "IP" => "ip_record".
|
|
|
Idem.
|
1.3.9.1