Main Page | Modules | Alphabetical List | Data Structures | File List | Data Fields | Globals | Related Pages

inet.c File Reference


Detailed Description

Internet status.

Author:
Raphael Manfredi
Date:
2001-2003

#include "common.h"
#include "inet.h"
#include "nodes.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 */
 Startup period: we send pongs.

#define FW_GRACE_INTERVAL   3600 /**< Every hour, new grace period */
 Every hour, new grace period.

#define FW_PERIODIC_GRACE   120 /**< We send pongs for 2 minutes */
 We send pongs for 2 minutes.

#define FW_INCOMING_WINDOW   3600 /**< Incoming monitoring window */
 Incoming monitoring window.

#define FW_SOLICITED_WINDOW   3600 /**< Solicited UDP monitoring window */
 Solicited UDP monitoring window.

#define FW_UDP_WINDOW   120 /**< 2 minutes, in most firewalls */
 2 minutes, in most firewalls

#define OUTGOING_WINDOW   150 /**< Outgoing monitoring window */
 Outgoing monitoring window.


Functions

 RCSID ("$Id:inet.c, v 1.25 2005/09/10 08:17:28 daichik Exp $")
void inet_set_is_connected (gboolean val)
 Sets our internet connection status.

ip_recordip_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)
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.

gpointer incoming_ev = NULL
 Callout queue timer.

gpointer incoming_udp_ev = NULL
 Idem.

gpointer solicited_udp_ev = NULL
 Idem.

GHashTable * outgoing_udp = NULL
 Maps "IP" => "ip_record".

guint32 activity_seen = 0
 Activity recorded in period.

gpointer outgoing_ev = NULL
 Callout queue timer.


Define Documentation

#define FW_GRACE_INTERVAL   3600 /**< Every hour, new grace period */
 

Every hour, new grace period.

#define FW_INCOMING_WINDOW   3600 /**< Incoming monitoring window */
 

Incoming monitoring window.

#define FW_PERIODIC_GRACE   120 /**< We send pongs for 2 minutes */
 

We send pongs for 2 minutes.

#define FW_SOLICITED_WINDOW   3600 /**< Solicited UDP monitoring window */
 

Solicited UDP monitoring window.

#define FW_STARTUP_GRACE   300 /**< Startup period: we send pongs */
 

Startup period: we send pongs.

#define FW_UDP_WINDOW   120 /**< 2 minutes, in most firewalls */
 

2 minutes, in most firewalls

#define OUTGOING_WINDOW   150 /**< Outgoing monitoring window */
 

Outgoing monitoring window.


Function Documentation

void check_outgoing_connection cqueue_t unused_cq,
gpointer  unused_obj
[static]
 

This callback is periodically called when there has been outgoing connections attempted.

void free_ip_record gpointer  key,
gpointer  value,
gpointer  unused_udata
[static]
 

Hash table iteration callback to free the "ip_record" structure.

void got_no_connection cqueue_t unused_cq,
gpointer  unused_obj
[static]
 

This is a callback invoked when no incoming connection has been received for some amount of time.

We conclude we became firewalled.

void got_no_udp_solicited cqueue_t unused_cq,
gpointer  unused_obj
[static]
 

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.

void got_no_udp_unsolicited cqueue_t unused_cq,
gpointer  unused_obj
[static]
 

This is a callback invoked when no unsolicited UDP datagrams have been received for some amount of time.

We conclude we became firewalled.

gboolean inet_can_answer_ping void   ) 
 

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.

void inet_close void   ) 
 

Shutdown cleanup.

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_firewalled void   ) 
 

Called when we enter the firewalled status (TCP).

void inet_got_incoming const host_addr_t  addr  ) 
 

Called when we got an incoming connection from another computer at `ip'.

void inet_init void   ) 
 

Initialization code.

void inet_not_firewalled void   )  [static]
 

Called when we have determined we are definitely not TCP-firewalled.

void inet_read_activity void   ) 
 

Called when reading activity occurred during a b/w scheduling period.

void inet_set_is_connected gboolean  val  )  [static]
 

Sets our internet connection status.

void inet_udp_firewalled void   ) 
 

Called when we enter the firewalled status (UDP).

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_got_solicited void   )  [static]
 

Called whenever we receive solicited UDP traffic.

void inet_udp_got_unsolicited_incoming void   )  [static]
 

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.

void inet_udp_not_firewalled void   )  [static]
 

Called when we have determined we are definitely not UDP-firewalled.

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.

void ip_record_destroy cqueue_t unused_cq,
gpointer  obj
[static]
 

Callout queue callback, invoked when it's time to destroy the record.

void ip_record_free struct ip_record ipr  )  [static]
 

Free ip_record structure.

void ip_record_free_remove struct ip_record ipr  )  [static]
 

Free ip_record structure and remove it from the `outgoing_udp' table.

struct ip_record* ip_record_make const host_addr_t  addr  )  [static]
 

Create a new ip_record structure.

void ip_record_touch struct ip_record ipr  )  [static]
 

Touch ip_record when we send a new datagram to that IP.

gboolean is_local_addr const host_addr_t  addr  )  [static]
 

Returns:
whether ip is that of the local machine of in the same local network area.

RCSID "$Id:inet.  c,
v 1.25 2005/09/10 08:17:28 daichik Exp $" 
 


Variable Documentation

guint32 activity_seen = 0 [static]
 

Activity recorded in period.

time_t fw_time = 0 [static]
 

When we last became firewalled.

gpointer incoming_ev = NULL [static]
 

Callout queue timer.

gpointer incoming_udp_ev = NULL [static]
 

Idem.

gpointer outgoing_ev = NULL [static]
 

Callout queue timer.

GHashTable* outgoing_udp = NULL [static]
 

Maps "IP" => "ip_record".

gpointer solicited_udp_ev = NULL [static]
 

Idem.


Generated on Sun Feb 12 10:50:03 2006 for Gtk-Gnutella by doxygen 1.3.6