[PATCH] dhcp6: change option code to uint16_t
by James Prestwood
GCC-10 appears to have gotten "smarter" (or pickier) and passing
unnamed enums as an argument expecting a named enum results in
an error. The internal APIs in dhcp6 have been changed to take a
uint16_t instead of enum l_dhcp6_option. This allows both public
and internal DHCP options to be passed to these builder APIs.
---
ell/dhcp6.c | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/ell/dhcp6.c b/ell/dhcp6.c
index 31b07c1..894252e 100644
--- a/ell/dhcp6.c
+++ b/ell/dhcp6.c
@@ -226,8 +226,7 @@ static uint8_t *option_reserve(struct dhcp6_message_builder *builder,
return p;
}
-static void option_start(struct dhcp6_message_builder *builder,
- enum l_dhcp6_option type)
+static void option_start(struct dhcp6_message_builder *builder, uint16_t type)
{
builder->option_start = builder->options_pos;
l_put_be16(type, option_reserve(builder, OPTION_HEADER_LEN));
@@ -244,7 +243,7 @@ static void option_finalize(struct dhcp6_message_builder *builder)
}
static void option_append_uint16(struct dhcp6_message_builder *builder,
- enum l_dhcp6_option type, uint16_t v)
+ uint16_t type, uint16_t v)
{
uint8_t *p = option_reserve(builder, OPTION_HEADER_LEN + sizeof(v));
@@ -254,8 +253,7 @@ static void option_append_uint16(struct dhcp6_message_builder *builder,
}
static void option_append_bytes(struct dhcp6_message_builder *builder,
- enum l_dhcp6_option type,
- const void *bytes, uint16_t len)
+ uint16_t type, const void *bytes, uint16_t len)
{
uint8_t *p = option_reserve(builder, OPTION_HEADER_LEN + len);
@@ -453,7 +451,7 @@ static void option_append_option_request(struct dhcp6_message_builder *builder,
static int option_append_ia_common(struct l_dhcp6_client *client,
struct dhcp6_message_builder *builder,
- enum l_dhcp6_option option)
+ uint16_t option)
{
option_start(builder, option);
--
2.26.2
5 months, 1 week
[PATCH] dhcp6: change option code to uint16_t
by James Prestwood
GCC-10 appears to have gotten "smarter" (or pickier) and passing
unnamed enums as an argument expecting a named enum results in
an error. The internal APIs in dhcp6 have been changed to take a
uint16_t instead of enum l_dhcp6_option. This allows both public
and internal DHCP options to be passed to these builder APIs.
---
ell/dhcp6.c | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/ell/dhcp6.c b/ell/dhcp6.c
index 31b07c1..894252e 100644
--- a/ell/dhcp6.c
+++ b/ell/dhcp6.c
@@ -226,8 +226,7 @@ static uint8_t *option_reserve(struct dhcp6_message_builder *builder,
return p;
}
-static void option_start(struct dhcp6_message_builder *builder,
- enum l_dhcp6_option type)
+static void option_start(struct dhcp6_message_builder *builder, uint16_t type)
{
builder->option_start = builder->options_pos;
l_put_be16(type, option_reserve(builder, OPTION_HEADER_LEN));
@@ -244,7 +243,7 @@ static void option_finalize(struct dhcp6_message_builder *builder)
}
static void option_append_uint16(struct dhcp6_message_builder *builder,
- enum l_dhcp6_option type, uint16_t v)
+ uint16_t type, uint16_t v)
{
uint8_t *p = option_reserve(builder, OPTION_HEADER_LEN + sizeof(v));
@@ -254,8 +253,7 @@ static void option_append_uint16(struct dhcp6_message_builder *builder,
}
static void option_append_bytes(struct dhcp6_message_builder *builder,
- enum l_dhcp6_option type,
- const void *bytes, uint16_t len)
+ uint16_t type, const void *bytes, uint16_t len)
{
uint8_t *p = option_reserve(builder, OPTION_HEADER_LEN + len);
@@ -453,7 +451,7 @@ static void option_append_option_request(struct dhcp6_message_builder *builder,
static int option_append_ia_common(struct l_dhcp6_client *client,
struct dhcp6_message_builder *builder,
- enum l_dhcp6_option option)
+ uint16_t option)
{
option_start(builder, option);
--
2.26.2
5 months, 1 week
[PATCH 1/2] settings: Add l_settings_{set,get}_bytes
by Andrew Zaborowski
---
I went for "bytes" instead of "hexstring" because the latter is the
encoding while the former is the type of data stored.
---
ell/ell.sym | 2 ++
ell/settings.c | 37 +++++++++++++++++++++++++++++++++++++
ell/settings.h | 7 +++++++
3 files changed, 46 insertions(+)
diff --git a/ell/ell.sym b/ell/ell.sym
index 044cf3c..66e0f08 100644
--- a/ell/ell.sym
+++ b/ell/ell.sym
@@ -444,6 +444,8 @@ global:
l_settings_set_double;
l_settings_get_float;
l_settings_set_float;
+ l_settings_get_bytes;
+ l_settings_set_bytes;
l_settings_remove_group;
l_settings_remove_key;
l_settings_has_embedded_group;
diff --git a/ell/settings.c b/ell/settings.c
index dac45c9..68f7a4a 100644
--- a/ell/settings.c
+++ b/ell/settings.c
@@ -1325,6 +1325,43 @@ LIB_EXPORT bool l_settings_set_float(struct l_settings *settings,
return l_settings_set_value(settings, group_name, key, buf);
}
+LIB_EXPORT uint8_t *l_settings_get_bytes(const struct l_settings *settings,
+ const char *group_name,
+ const char *key,
+ size_t *out_len)
+{
+ const char *value = l_settings_get_value(settings, group_name, key);
+
+ if (!value)
+ return NULL;
+
+ if (value[0] == '\0') {
+ *out_len = 0;
+
+ /* Return something that can be l_freed but is not a NULL */
+ return l_memdup("", 1);
+ }
+
+ return l_util_from_hexstring(value, out_len);
+}
+
+LIB_EXPORT bool l_settings_set_bytes(struct l_settings *settings,
+ const char *group_name, const char *key,
+ const uint8_t *value, size_t value_len)
+{
+ char *buf;
+
+ if (unlikely(!settings || !value))
+ return false;
+
+ if (value_len)
+ buf = l_util_hexstring(value, value_len);
+ else
+ buf = l_strdup("");
+
+ return set_value(settings, group_name, key, buf);
+}
+
LIB_EXPORT bool l_settings_remove_group(struct l_settings *settings,
const char *group_name)
{
diff --git a/ell/settings.h b/ell/settings.h
index e4203af..f95ed9b 100644
--- a/ell/settings.h
+++ b/ell/settings.h
@@ -119,6 +119,13 @@ bool l_settings_get_float(const struct l_settings *settings,
bool l_settings_set_float(struct l_settings *settings, const char *group_name,
const char *key, float in);
+uint8_t *l_settings_get_bytes(const struct l_settings *settings,
+ const char *group_name, const char *key,
+ size_t *out_len);
+bool l_settings_set_bytes(struct l_settings *settings, const char *group_name,
+ const char *key,
+ const uint8_t *value, size_t value_len);
+
bool l_settings_remove_key(struct l_settings *settings, const char *group_name,
const char *key);
bool l_settings_remove_group(struct l_settings *settings,
--
2.25.1
5 months, 3 weeks
[PATCH 1/2] build: pass -no-undefined properly
by Ross Burton
From: Ross Burton <ross.burton(a)arm.com>
-no-undefined was added to the libell.la LDFLAGS in commit 8391d72d,
back in 2012, as part of adding versioning. I believe there was some
confusion here as passing -no-undefined to libtool is different to
passing -no-undefined to the linker. The former changes libtool's
behaviour on Windows hosts related to static libraries, the latter will
warn if symbols are used but not defined.
---
Makefile.am | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Makefile.am b/Makefile.am
index 4eb20c6..395edc3 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -138,7 +138,7 @@ ell_libell_la_SOURCES = $(linux_headers) \
ell/gpio.c \
ell/path.c
-ell_libell_la_LDFLAGS = -no-undefined \
+ell_libell_la_LDFLAGS = -Wl,--no-undefined \
-Wl,--version-script=$(top_srcdir)/ell/ell.sym \
-version-info $(ELL_CURRENT):$(ELL_REVISION):$(ELL_AGE)
--
2.28.0
5 months, 3 weeks