From mboxrd@z Thu Jan 1 00:00:00 1970 Content-Type: multipart/mixed; boundary="===============5921050471141762714==" MIME-Version: 1.0 From: Tim Kourt Subject: [PATCH] dhcp: Add domain name option handler Date: Fri, 06 Dec 2019 15:21:44 -0800 Message-ID: <20191206232144.3331-1-tim.a.kourt@linux.intel.com> List-Id: To: ell@lists.01.org --===============5921050471141762714== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Add parser and accessor for the domain name lease option. --- ell/dhcp-lease.c | 24 +++++++++++++++++++++++- ell/dhcp-private.h | 1 + ell/dhcp.h | 1 + 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/ell/dhcp-lease.c b/ell/dhcp-lease.c index 5f801e7..06ef76a 100644 --- a/ell/dhcp-lease.c +++ b/ell/dhcp-lease.c @@ -45,6 +45,8 @@ void _dhcp_lease_free(struct l_dhcp_lease *lease) return; = l_free(lease->dns); + l_free(lease->domain_name); + l_free(lease); } = @@ -99,6 +101,18 @@ struct l_dhcp_lease *_dhcp_lease_parse_options(struct d= hcp_message_iter *iter) } } break; + case L_DHCP_OPTION_DOMAIN_NAME: + if (l < 1) + break; + + lease->domain_name =3D l_new(char, l + 1); + + memcpy(lease->domain_name, v, l); + + if (lease->domain_name[l - 1] !=3D '\0') + lease->domain_name[l] =3D '\0'; + + break; default: break; } @@ -135,7 +149,7 @@ struct l_dhcp_lease *_dhcp_lease_parse_options(struct d= hcp_message_iter *iter) = return lease; error: - l_free(lease); + _dhcp_lease_free(lease); return NULL; } = @@ -212,6 +226,14 @@ LIB_EXPORT char **l_dhcp_lease_get_dns(const struct l_= dhcp_lease *lease) return dns_list; } = +LIB_EXPORT char *l_dhcp_lease_get_domain_name(const struct l_dhcp_lease *l= ease) +{ + if (unlikely(!lease)) + return NULL; + + return l_strdup(lease->domain_name); +} + LIB_EXPORT uint32_t l_dhcp_lease_get_t1(const struct l_dhcp_lease *lease) { if (unlikely(!lease)) diff --git a/ell/dhcp-private.h b/ell/dhcp-private.h index 6554fc6..a75bb8b 100644 --- a/ell/dhcp-private.h +++ b/ell/dhcp-private.h @@ -120,6 +120,7 @@ struct l_dhcp_lease { uint32_t t2; uint32_t router; uint32_t *dns; + char *domain_name; }; = struct l_dhcp_lease *_dhcp_lease_new(void); diff --git a/ell/dhcp.h b/ell/dhcp.h index c3a4988..b8a5b41 100644 --- a/ell/dhcp.h +++ b/ell/dhcp.h @@ -95,6 +95,7 @@ char *l_dhcp_lease_get_netmask(const struct l_dhcp_lease = *lease); char *l_dhcp_lease_get_broadcast(const struct l_dhcp_lease *lease); char *l_dhcp_lease_get_server_id(const struct l_dhcp_lease *lease); char **l_dhcp_lease_get_dns(const struct l_dhcp_lease *lease); +char *l_dhcp_lease_get_domain_name(const struct l_dhcp_lease *lease); = uint32_t l_dhcp_lease_get_t1(const struct l_dhcp_lease *lease); uint32_t l_dhcp_lease_get_t2(const struct l_dhcp_lease *lease); -- = 2.13.6 --===============5921050471141762714==--