[PATCH 2/6] udhcpc6: Add DHCPv6 env helper

Walter Harms wharms at bfs.de
Tue May 8 16:29:24 UTC 2018


Add string_option_to_env() to easily generate environment variables for
known simple options.

Signed-off-by: Samuel Mendoza-Jonas <sam at mendozajonas.com>
---
 networking/udhcp/d6_dhcpc.c | 31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)

diff --git a/networking/udhcp/d6_dhcpc.c b/networking/udhcp/d6_dhcpc.c
index 85d9da724..0d3894c86 100644
--- a/networking/udhcp/d6_dhcpc.c
+++ b/networking/udhcp/d6_dhcpc.c
@@ -195,6 +195,37 @@ static char** new_env(void)
 	return &client6_data.env_ptr[client6_data.env_idx++];
 }
 +static char *string_option_to_env(uint8_t *option, uint8_t *option_end)
+{
+	const char *ptr, *name = NULL;
+	uint8_t val_len;
+	int i;
+
+	ptr = d6_option_strings;
+	i = 0;
+	while (ptr && strlen(ptr)) {

maybe 
  ptr && *ptr
would do here also ?


+		if (d6_optflags[i].code == option[1]) {
+			name = ptr;
+			break;
+		}
+		ptr += strlen(ptr) + 1;
+		i++;
+	}


More information about the busybox mailing list