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

guid.c File Reference


Detailed Description

Globally Unique ID (GUID) manager.

HEC generation code is courtesy of Charles Michael Heard (initially written for ATM, but adapted for GTKG, with leading coset leader changed).

Author:
Raphael Manfredi
Date:
2002-2003

#include "common.h"
#include "guid.h"
#include "lib/misc.h"
#include "lib/endian.h"
#include "if/gnet_property_priv.h"
#include "lib/override.h"

Defines

#define GUID_PONG_CACHING   0x01
#define GUID_PERSISTENT   0x02
#define GUID_REQUERY   0x01 /**< Cleared means initial query */
 Cleared means initial query.

#define HEC_GENERATOR   0x107 /**< x^8 + x^2 + x + 1 */
 x^8 + x^2 + x + 1

#define HEC_GTKG_MASK   0x0c3 /**< HEC GTKG's mask */
 HEC GTKG's mask.


Functions

 RCSID ("$Id:guid.c, v 1.12 2005/08/27 14:54:27 rmanfredi Exp $")
void guid_gen_syndrome_table (void)
 Generate a table of CRC-8 syndromes for all possible input bytes.

guint16 guid_gtkg_encode_version (guint major, guint minor, gboolean rel)
 Encode major/minor version into 16 bits.

guint8 guid_hec (const gchar *xuid)
 Compute GUID's HEC over bytes 1..15.

void guid_init (void)
 Initialize GUID management.

void guid_flag_modern (gchar *muid)
 Make sure the MUID we use in initial handshaking pings are marked specially to indicate we're modern nodes.

void guid_flag_gtkg (gchar *xuid)
 Flag a GUID/MUID as being from GTKG, by patching `xuid' in place.

gboolean guid_extract_gtkg_info (const guint8 *xuid, gint start, guint8 *majp, guint8 *minp, gboolean *relp)
 Decode major/minor and release information from the specified two contiguous GUID bytes.

gboolean guid_is_gtkg (const gchar *guid, guint8 *majp, guint8 *minp, gboolean *relp)
 Test whether GUID is that of GTKG, and extract version major/minor, along with release status provided the `majp', `minp' and `relp' are non-NULL.

gboolean guid_is_requery (const gchar *xuid)
 Test whether a GTKG MUID in a Query is marked as being a retry.

void guid_random_muid (gchar *muid)
 Generate a new random GUID, flagged as GTKG.

void guid_ping_muid (gchar *muid)
 Generate a new random (modern) message ID for pings.

void guid_query_muid (gchar *muid, gboolean initial)
 Generate a new random message ID for queries.

void guid_flag_oob_gtkg (gchar *xuid)
 Flag a MUID for OOB queries as being from GTKG, by patching `xuid' in place.

gboolean guid_oob_is_gtkg (const gchar *guid, guint8 *majp, guint8 *minp, gboolean *relp)
 Test whether GUID is that of GTKG, and extract version major/minor, along with release status provided the `majp', `minp' and `relp' are non-NULL.

gboolean guid_query_muid_is_gtkg (const gchar *guid, gboolean oob, guint8 *majp, guint8 *minp, gboolean *relp)
 Check whether the MUID of a query is that of GTKG.

void guid_query_oob_muid (gchar *muid, const host_addr_t addr, guint16 port, gboolean initial)
 Generate GUID for a query with OOB results delivery.

void guid_oob_get_addr_port (const gchar *guid, host_addr_t *addr, guint16 *port)
 Extract the IP and port number from the GUID of queries marked for OOB query hit delivery.


Variables

const gchar blank_guid [GUID_RAW_SIZE] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }
guint8 syndrome_table [256]
guint16 gtkg_version_mark


Define Documentation

#define GUID_PERSISTENT   0x02
 

#define GUID_PONG_CACHING   0x01
 

#define GUID_REQUERY   0x01 /**< Cleared means initial query */
 

Cleared means initial query.

#define HEC_GENERATOR   0x107 /**< x^8 + x^2 + x + 1 */
 

x^8 + x^2 + x + 1

#define HEC_GTKG_MASK   0x0c3 /**< HEC GTKG's mask */
 

HEC GTKG's mask.


Function Documentation

gboolean guid_extract_gtkg_info const guint8 *  xuid,
gint  start,
guint8 *  majp,
guint8 *  minp,
gboolean *  relp
[static]
 

Decode major/minor and release information from the specified two contiguous GUID bytes.

Parameters:
xuid is the GUID considered
start is the offset of the markup (2 or 4) in the GUID
majp is filled with the major version if it's a GTKG markup
minp is filled with the minor version if it's a GTKG markup
relp is filled with the release status if it's a GTKG markup
Returns:
whether we recognized a GTKG markup.

void guid_flag_gtkg gchar *  xuid  )  [static]
 

Flag a GUID/MUID as being from GTKG, by patching `xuid' in place.

Bytes 2/3 become the GTKG version mark. Byte 0 becomes the HEC of the remaining 15 bytes.

void guid_flag_modern gchar *  muid  )  [static]
 

Make sure the MUID we use in initial handshaking pings are marked specially to indicate we're modern nodes.

void guid_flag_oob_gtkg gchar *  xuid  )  [static]
 

Flag a MUID for OOB queries as being from GTKG, by patching `xuid' in place.

Bytes 4/5 become the GTKG version mark. Byte 15 becomes the HEC of the leading 15 bytes.

void guid_gen_syndrome_table void   )  [static]
 

Generate a table of CRC-8 syndromes for all possible input bytes.

guint16 guid_gtkg_encode_version guint  major,
guint  minor,
gboolean  rel
[static]
 

Encode major/minor version into 16 bits.

If `rel' is true, we're a release, otherwise we're unstable or a beta.

guint8 guid_hec const gchar *  xuid  )  [static]
 

Compute GUID's HEC over bytes 1..15.

void guid_init void   ) 
 

Initialize GUID management.

gboolean guid_is_gtkg const gchar *  guid,
guint8 *  majp,
guint8 *  minp,
gboolean *  relp
 

Test whether GUID is that of GTKG, and extract version major/minor, along with release status provided the `majp', `minp' and `relp' are non-NULL.

gboolean guid_is_requery const gchar *  xuid  ) 
 

Test whether a GTKG MUID in a Query is marked as being a retry.

void guid_oob_get_addr_port const gchar *  guid,
host_addr_t addr,
guint16 *  port
 

Extract the IP and port number from the GUID of queries marked for OOB query hit delivery.

Bytes 0 to 3 of the guid are the 4 octet bytes of the IP address. Bytes 13 and 14 are the little endian representation of the port.

gboolean guid_oob_is_gtkg const gchar *  guid,
guint8 *  majp,
guint8 *  minp,
gboolean *  relp
[static]
 

Test whether GUID is that of GTKG, and extract version major/minor, along with release status provided the `majp', `minp' and `relp' are non-NULL.

void guid_ping_muid gchar *  muid  ) 
 

Generate a new random (modern) message ID for pings.

void guid_query_muid gchar *  muid,
gboolean  initial
 

Generate a new random message ID for queries.

If `initial' is false, this is a requery.

gboolean guid_query_muid_is_gtkg const gchar *  guid,
gboolean  oob,
guint8 *  majp,
guint8 *  minp,
gboolean *  relp
 

Check whether the MUID of a query is that of GTKG.

GTKG uses GUID tagging, but unfortunately, the bytes uses to store the IP and port for OOB query hit delivery conflict with the bytes used for the tagging. Hence the need for a special routine.

Parameters:
guid the MUID of the message
oob whether the query requests OOB query hit delivery
majp where the major release version is written, if GTKG
minp where the minor release version is written, if GTKG
relp where the release indicator gets written, if GTKG

void guid_query_oob_muid gchar *  muid,
const host_addr_t  addr,
guint16  port,
gboolean  initial
 

Generate GUID for a query with OOB results delivery.

If `initial' is false, this is a requery.

Bytes 0 to 3 if the GUID are the 4 octet bytes of the IP address. Bytes 13 and 14 are the little endian representation of the port. Byte 15 holds an HEC with bit 0 indicating a requery.

void guid_random_muid gchar *  muid  ) 
 

Generate a new random GUID, flagged as GTKG.

RCSID "$Id:guid.  c,
v 1.12 2005/08/27 14:54:27 rmanfredi Exp $" 
 


Variable Documentation

const gchar blank_guid[GUID_RAW_SIZE] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }
 

guint16 gtkg_version_mark [static]
 

guint8 syndrome_table[256] [static]
 


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