HEC generation code is courtesy of Charles Michael Heard (initially written for ATM, but adapted for GTKG, with leading coset leader changed).
#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. | |
| #define | HEC_GENERATOR 0x107 |
| x^8 + x^2 + x + 1 | |
| #define | HEC_GTKG_MASK 0x0c3 |
| HEC GTKG's mask. | |
Functions | |
| 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 |
|
|
|
|
|
|
|
|
Cleared means initial query.
|
|
|
x^8 + x^2 + x + 1
|
|
|
HEC GTKG's mask.
|
|
||||||||||||||||||||||||
|
Decode major/minor and release information from the specified two contiguous GUID bytes.
|
|
|
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. |
|
|
Make sure the MUID we use in initial handshaking pings are marked specially to indicate we're modern nodes.
|
|
|
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. |
|
|
Generate a table of CRC-8 syndromes for all possible input bytes.
|
|
||||||||||||||||
|
Encode major/minor version into 16 bits. If `rel' is true, we're a release, otherwise we're unstable or a beta. |
|
|
Compute GUID's HEC over bytes 1..15.
|
|
|
Initialize GUID management.
|
|
||||||||||||||||||||
|
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.
|
|
|
Test whether a GTKG MUID in a Query is marked as being a retry.
|
|
||||||||||||||||
|
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. |
|
||||||||||||||||||||
|
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.
|
|
|
Generate a new random (modern) message ID for pings.
|
|
||||||||||||
|
Generate a new random message ID for queries. If `initial' is false, this is a requery. |
|
||||||||||||||||||||||||
|
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.
|
|
||||||||||||||||||||
|
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. |
|
|
Generate a new random GUID, flagged as GTKG.
|
|
|
|
|
|
|
|
|
|
1.3.9.1