mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-19 15:14:23 +01:00
common/features: expose feature bitmap low-level functions.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
committed by
neil saitug
parent
58f448904c
commit
2e3eadbe91
@@ -21,7 +21,7 @@ static const u32 our_globalfeatures[] = {
|
||||
*
|
||||
* All data fields are unsigned big-endian unless otherwise specified.
|
||||
*/
|
||||
static void set_bit(u8 **ptr, u32 bit)
|
||||
void set_feature_bit(u8 **ptr, u32 bit)
|
||||
{
|
||||
size_t len = tal_count(*ptr);
|
||||
if (bit / 8 >= len) {
|
||||
@@ -46,7 +46,7 @@ static u8 *mkfeatures(const tal_t *ctx, const u32 *arr, size_t n)
|
||||
u8 *f = tal_arr(ctx, u8, 0);
|
||||
|
||||
for (size_t i = 0; i < n; i++)
|
||||
set_bit(&f, arr[i]);
|
||||
set_feature_bit(&f, arr[i]);
|
||||
return f;
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ u8 *get_offered_localfeatures(const tal_t *ctx)
|
||||
our_localfeatures, ARRAY_SIZE(our_localfeatures));
|
||||
}
|
||||
|
||||
static bool feature_set(const u8 *features, size_t bit)
|
||||
bool feature_is_set(const u8 *features, size_t bit)
|
||||
{
|
||||
size_t bytenum = bit / 8;
|
||||
|
||||
@@ -74,8 +74,8 @@ static bool feature_set(const u8 *features, size_t bit)
|
||||
|
||||
bool feature_offered(const u8 *features, size_t f)
|
||||
{
|
||||
return feature_set(features, COMPULSORY_FEATURE(f))
|
||||
|| feature_set(features, OPTIONAL_FEATURE(f));
|
||||
return feature_is_set(features, COMPULSORY_FEATURE(f))
|
||||
|| feature_is_set(features, OPTIONAL_FEATURE(f));
|
||||
}
|
||||
|
||||
static bool feature_supported(int feature_bit,
|
||||
@@ -124,8 +124,8 @@ bool features_supported(const u8 *globalfeatures, const u8 *localfeatures)
|
||||
{
|
||||
/* BIT 2 would logically be "compulsory initial_routing_sync", but
|
||||
* that does not exist, so we special case it. */
|
||||
if (feature_set(localfeatures,
|
||||
COMPULSORY_FEATURE(LOCAL_INITIAL_ROUTING_SYNC)))
|
||||
if (feature_is_set(localfeatures,
|
||||
COMPULSORY_FEATURE(LOCAL_INITIAL_ROUTING_SYNC)))
|
||||
return false;
|
||||
|
||||
return all_supported_features(globalfeatures,
|
||||
|
||||
Reference in New Issue
Block a user