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

settings.c File Reference


Detailed Description

Gtk-Gnutella configuration.

Author:
Raphael Manfredi

Richard Eckart

Date:
2001-2003

#include "common.h"
#include "lib/eval.h"
#include "settings.h"
#include "search.h"
#include "hosts.h"
#include "upload_stats.h"
#include "sockets.h"
#include "inet.h"
#include "hcache.h"
#include "downloads.h"
#include "share.h"
#include "if/gnet_property.h"
#include "if/gnet_property_priv.h"
#include "if/core/main.h"
#include "if/core/net_stats.h"
#include "if/bridge/c2ui.h"
#include "lib/cq.h"
#include "lib/file.h"
#include "lib/glib-missing.h"
#include "lib/tm.h"
#include "lib/override.h"

Data Structures

struct  prop_map
 The property maps contain informaiton about which widget should reflect which property. More...


Defines

#define debug   dbg
#define PID_FILE_MODE   (S_IRUSR | S_IWUSR) /* 0600 */
#define CONFIG_DIR_MODE
#define RESET_PROP_TM   (10*60*1000) /**< 10 minutes in ms */
 10 minutes in ms

#define PROPERTY_MAP_SIZE   G_N_ELEMENTS(property_map)

Typedefs

typedef prop_map prop_map_t

Functions

 RCSID ("$Id:settings.c, v 1.51 2005/12/08 00:49:08 cbiere Exp $")
void settings_callbacks_init (void)
void settings_callbacks_shutdown (void)
void update_uptimes (void)
 Called at shutdown time to update the average_uptime property before saving the properties to disk.

host_addr_t listen_address (gboolean update)
void listen_address_update (void)
host_addr_t listen_addr (void)
gint ensure_unicity (const gchar *file)
 Look for any existing PID file.

void save_pid (gint fd)
 Write our pid to the pidfile.

guint64 settings_getphysmemsize (void)
void settings_init (void)
const gchar * settings_config_dir (void)
 Get the config directory.

const gchar * settings_home_dir (void)
 Gets the home dir.

void settings_remove_pidfile (void)
 Remove pidfile.

void settings_addr_changed (const host_addr_t new_addr, const host_addr_t peer)
 This routine is called when we determined that our IP was no longer the one we computed.

guint32 settings_max_msg_size (void)
 Maximum message payload size we are configured to handle.

void settings_ask_for_property (const gchar *name, const gchar *value)
 Ask them to set a property to be able to run.

void settings_shutdown (void)
 Called at exit time to flush the property files.

void settings_save_if_dirty (void)
 Save settings if dirty.

void settings_close (void)
 Finally free all memory allocated.

void gnet_get_bw_stats (gnet_bw_source type, gnet_bw_stats_t *s)
guint32 get_average_ip_lifetime (time_t now)
 Compute the EMA of the IP address lifetime up to now, but do not update the property.

void update_address_lifetime (void)
 Called whenever the IP address we advertise changed.

guint32 get_average_servent_uptime (time_t now)
 Compute the EMA of the averate servent uptime, up to now, but do not update the property.

gboolean up_connections_changed (property_t prop)
gboolean max_connections_changed (property_t prop)
gboolean max_hosts_cached_changed (property_t prop)
gboolean max_ultra_hosts_cached_changed (property_t prop)
gboolean max_bad_hosts_cached_changed (property_t prop)
gboolean enable_udp_changed (property_t prop)
gboolean listen_port_changed (property_t prop)
gboolean network_protocol_changed (property_t prop)
gboolean bw_http_in_enabled_changed (property_t prop)
gboolean bw_http_out_enabled_changed (property_t prop)
gboolean bw_gnet_in_enabled_changed (property_t prop)
gboolean bw_gnet_out_enabled_changed (property_t prop)
gboolean bw_gnet_lin_enabled_changed (property_t prop)
gboolean bw_gnet_lout_enabled_changed (property_t prop)
gboolean node_sendqueue_size_changed (property_t unused_prop)
gboolean scan_extensions_changed (property_t prop)
gboolean file_path_changed (property_t prop)
gboolean shared_dirs_paths_changed (property_t prop)
gboolean local_netmasks_string_changed (property_t prop)
gboolean hard_ttl_limit_changed (property_t prop)
gboolean max_ttl_changed (property_t prop)
gboolean bw_http_in_changed (property_t prop)
gboolean bw_http_out_changed (property_t prop)
gboolean bw_gnet_in_changed (property_t prop)
gboolean bw_gnet_out_changed (property_t prop)
gboolean bw_gnet_lin_changed (property_t prop)
gboolean bw_gnet_lout_changed (property_t prop)
gboolean bw_allow_stealing_changed (property_t prop)
gboolean node_online_mode_changed (property_t prop)
gboolean lib_debug_changed (property_t unused_prop)
gboolean force_local_addr_changed (property_t prop)
gboolean local_addr_changed (property_t prop)
gboolean configured_peermode_changed (property_t prop)
gboolean current_peermode_changed (property_t prop)
gboolean download_rx_size_changed (property_t prop)
gboolean node_rx_size_changed (property_t prop)
void reset_property_cb (cqueue_t *unused_cq, gpointer obj)
 callout queue callback

gboolean file_descriptor_x_changed (property_t prop)

Variables

const gchar config_file [] = "config_gnet"
const gchar ul_stats_file [] = "upload_stats"
gchar * home_dir = NULL
gchar * config_dir = NULL
prop_set_tproperties = NULL
const gchar pidfile [] = "gtk-gnutella.pid"
gpointer ev_file_descriptor_shortage = NULL
gpointer ev_file_descriptor_runout = NULL
prop_map_t property_map []
gboolean init_list [GNET_PROPERTY_NUM]


Define Documentation

#define CONFIG_DIR_MODE
 

Value:

/* 0750 */ \
    (S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP)

#define debug   dbg
 

#define PID_FILE_MODE   (S_IRUSR | S_IWUSR) /* 0600 */
 

#define PROPERTY_MAP_SIZE   G_N_ELEMENTS(property_map)
 

#define RESET_PROP_TM   (10*60*1000) /**< 10 minutes in ms */
 

10 minutes in ms


Typedef Documentation

typedef struct prop_map prop_map_t
 


Function Documentation

gboolean bw_allow_stealing_changed property_t  prop  )  [static]
 

gboolean bw_gnet_in_changed property_t  prop  )  [static]
 

gboolean bw_gnet_in_enabled_changed property_t  prop  )  [static]
 

gboolean bw_gnet_lin_changed property_t  prop  )  [static]
 

gboolean bw_gnet_lin_enabled_changed property_t  prop  )  [static]
 

gboolean bw_gnet_lout_changed property_t  prop  )  [static]
 

gboolean bw_gnet_lout_enabled_changed property_t  prop  )  [static]
 

gboolean bw_gnet_out_changed property_t  prop  )  [static]
 

gboolean bw_gnet_out_enabled_changed property_t  prop  )  [static]
 

gboolean bw_http_in_changed property_t  prop  )  [static]
 

gboolean bw_http_in_enabled_changed property_t  prop  )  [static]
 

gboolean bw_http_out_changed property_t  prop  )  [static]
 

gboolean bw_http_out_enabled_changed property_t  prop  )  [static]
 

gboolean configured_peermode_changed property_t  prop  )  [static]
 

gboolean current_peermode_changed property_t  prop  )  [static]
 

gboolean download_rx_size_changed property_t  prop  )  [static]
 

gboolean enable_udp_changed property_t  prop  )  [static]
 

gint ensure_unicity const gchar *  file  )  [static]
 

Look for any existing PID file.

If found, look at the pid recorded there and make sure it has died. Abort operations if it hasn't...

Returns:
-1 on failure, the file descriptor of the pidfile otherwise.

gboolean file_descriptor_x_changed property_t  prop  )  [static]
 

gboolean file_path_changed property_t  prop  )  [static]
 

gboolean force_local_addr_changed property_t  prop  )  [static]
 

guint32 get_average_ip_lifetime time_t  now  ) 
 

Compute the EMA of the IP address lifetime up to now, but do not update the property.

guint32 get_average_servent_uptime time_t  now  ) 
 

Compute the EMA of the averate servent uptime, up to now, but do not update the property.

void gnet_get_bw_stats gnet_bw_source  type,
gnet_bw_stats_t s
 

gboolean hard_ttl_limit_changed property_t  prop  )  [static]
 

gboolean lib_debug_changed property_t  unused_prop  )  [static]
 

host_addr_t listen_addr void   ) 
 

Returns:
the currently used local listening address.

host_addr_t listen_address gboolean  update  )  [static]
 

void listen_address_update void   )  [inline, static]
 

gboolean listen_port_changed property_t  prop  )  [static]
 

gboolean local_addr_changed property_t  prop  )  [static]
 

gboolean local_netmasks_string_changed property_t  prop  )  [static]
 

gboolean max_bad_hosts_cached_changed property_t  prop  )  [static]
 

gboolean max_connections_changed property_t  prop  )  [static]
 

gboolean max_hosts_cached_changed property_t  prop  )  [static]
 

gboolean max_ttl_changed property_t  prop  )  [static]
 

gboolean max_ultra_hosts_cached_changed property_t  prop  )  [static]
 

gboolean network_protocol_changed property_t  prop  )  [static]
 

gboolean node_online_mode_changed property_t  prop  )  [static]
 

gboolean node_rx_size_changed property_t  prop  )  [static]
 

gboolean node_sendqueue_size_changed property_t  unused_prop  )  [static]
 

RCSID "$Id:settings.  c,
v 1.51 2005/12/08 00:49:08 cbiere Exp $" 
 

void reset_property_cb cqueue_t unused_cq,
gpointer  obj
[static]
 

callout queue callback

Reset the property.

void save_pid gint  fd  )  [static]
 

Write our pid to the pidfile.

gboolean scan_extensions_changed property_t  prop  )  [static]
 

void settings_addr_changed const host_addr_t  new_addr,
const host_addr_t  peer
 

This routine is called when we determined that our IP was no longer the one we computed.

We base this on some headers sent back when we handshake with other nodes, and as a result, cannot trust the information.

What we do henceforth is trust 3 successive indication that our IP changed, provided we get the same information each time.

--RAM, 13/01/2002

Parameters:
`new_addr' the newly suggested address.
`peer' the IP address of peer which reported the new IP address.
There must be 3 peers from 3 different /16 networks before a change is accepted. Otherwise, it would be very easy to confuse GTKG by connecting 3 times in a row and submitting a *wrong* IP address.

--cbiere, 2004-08-01

void settings_ask_for_property const gchar *  name,
const gchar *  value
 

Ask them to set a property to be able to run.

void settings_callbacks_init void   )  [static]
 

void settings_callbacks_shutdown void   )  [static]
 

void settings_close void   ) 
 

Finally free all memory allocated.

Call after settings_shutdown.

const gchar* settings_config_dir void   ) 
 

Get the config directory.

guint64 settings_getphysmemsize void   )  [static]
 

Returns:
the amount of physical RAM in KB, or zero in case of failure

const gchar* settings_home_dir void   ) 
 

Gets the home dir.

void settings_init void   ) 
 

guint32 settings_max_msg_size void   ) 
 

Maximum message payload size we are configured to handle.

void settings_remove_pidfile void   )  [static]
 

Remove pidfile.

void settings_save_if_dirty void   ) 
 

Save settings if dirty.

void settings_shutdown void   ) 
 

Called at exit time to flush the property files.

gboolean shared_dirs_paths_changed property_t  prop  )  [static]
 

gboolean up_connections_changed property_t  prop  )  [static]
 

void update_address_lifetime void   )  [static]
 

Called whenever the IP address we advertise changed.

Update the average uptime for a given IP address.

void update_uptimes void   )  [static]
 

Called at shutdown time to update the average_uptime property before saving the properties to disk.


Variable Documentation

gchar* config_dir = NULL [static]
 

const gchar config_file[] = "config_gnet" [static]
 

gpointer ev_file_descriptor_runout = NULL [static]
 

gpointer ev_file_descriptor_shortage = NULL [static]
 

gchar* home_dir = NULL [static]
 

gboolean init_list[GNET_PROPERTY_NUM] [static]
 

const gchar pidfile[] = "gtk-gnutella.pid" [static]
 

prop_set_t* properties = NULL [static]
 

prop_map_t property_map[] [static]
 

const gchar ul_stats_file[] = "upload_stats" [static]
 


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