From: Denis Kenzior <denkenz@gmail.com>
To: ell@lists.01.org
Subject: Re: [PATCH] dhcp: Add domain name option handler
Date: Mon, 21 Oct 2019 10:50:55 -0500 [thread overview]
Message-ID: <fe3ac0de-38d4-e9bd-691a-d2b3d7202c62@gmail.com> (raw)
In-Reply-To: <20191018222919.11454-1-tim.a.kourt@linux.intel.com>
[-- Attachment #1: Type: text/plain, Size: 2792 bytes --]
Hi Tim,
On 10/18/19 5:29 PM, Tim Kourt wrote:
> Add parser and accessor for domain name lease option.
> ---
> ell/dhcp-lease.c | 16 +++++++++++++++-
> ell/dhcp-private.h | 1 +
> ell/dhcp.h | 1 +
> 3 files changed, 17 insertions(+), 1 deletion(-)
>
> diff --git a/ell/dhcp-lease.c b/ell/dhcp-lease.c
> index a48cfa4..ba57322 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,10 @@ struct l_dhcp_lease *_dhcp_lease_parse_options(struct dhcp_message_iter *iter)
> }
> }
> break;
> + case L_DHCP_OPTION_DOMAIN_NAME:
> + if (l >= 1)
> + lease->domain_name = l_strdup(v);
> + break;
No. You cannot assume that v is null terminated. Nobody will guarantee
that the packets coming from the 'dhcp server' aren't fuzzed or are not
from dhcp server at all.
> default:
> break;
> }
> @@ -124,7 +130,7 @@ struct l_dhcp_lease *_dhcp_lease_parse_options(struct dhcp_message_iter *iter)
>
> return lease;
> error:
> - l_free(lease);
> + _dhcp_lease_free(lease);
> return NULL;
> }
>
> @@ -201,6 +207,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 *lease)
> +{
> + if (unlikely(!lease))
> + return NULL;
> +
> + return l_strdup(lease->domain_name);
Strictly speaking this can be const char *, but okay.
> +}
> +
> 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);
>
Regards,
-Denis
next prev parent reply other threads:[~2019-10-21 15:50 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-18 22:29 [PATCH] dhcp: Add domain name option handler Tim Kourt
2019-10-21 15:50 ` Denis Kenzior [this message]
-- strict thread matches above, loose matches on Subject: below --
2019-12-06 23:21 Tim Kourt
2019-12-09 15:20 ` Denis Kenzior
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=fe3ac0de-38d4-e9bd-691a-d2b3d7202c62@gmail.com \
--to=denkenz@gmail.com \
--cc=ell@lists.01.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.