/** * 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. */ static bool guid_oob_is_gtkg(const guid_t *guid, uint8 *majp, uint8 *minp, bool *relp) { uint8 hec; if (!guid_extract_gtkg_info(guid, 4, majp, minp, relp)) return FALSE; /* Marking incorrect, no need to compute HEC */ /* * The HEC for OOB queries was made of the first 15 bytes for versions * up to 0.98.4u (legacy encoding). Starting with 0.98.4, we have a * different way of encoding the HEC to preserve its integrity even in * the advent of OOB-proxying. * * Also bit 0 of the HEC is not significant (used to mark requeries) * therefore it is masked out for comparison purposes. */ hec = peek_u8(&guid->v[15]) & ~GUID_REQUERY; if (*majp >0 || *minp >= 99) return booleanize((guid_hec_oob(guid) & ~GUID_REQUERY) == hec); /* * Transition period for servents earlier than 0.99: try the legacy marking * for 0.97 and earlier. For 0.98, try the legacy marking first, then the * new marking. */ if (*minp <= 97) return booleanize((guid_hec_oob_legacy(guid) & ~GUID_REQUERY) == hec); return booleanize((guid_hec_oob_legacy(guid) & ~GUID_REQUERY) == hec) || booleanize((guid_hec_oob(guid) & ~GUID_REQUERY) == hec); }
/** * Flag a MUID for OOB queries as being from GTKG, by patching `guid' in place. * * Bytes 4/5 become the GTKG version mark. * Byte 15 becomes the HEC of the leading 15 bytes. */ static void guid_flag_oob_gtkg(struct guid *muid) { poke_be16(&muid->v[4], gtkg_version_mark); muid->v[15] = guid_hec_oob(muid); /* guid_hec() skips leading byte */ }