From: Tim Kourt <tim.a.kourt@linux.intel.com>
To: iwd@lists.01.org
Subject: [PATCH 1/4] net: Add l_net_hostname_is_root
Date: Wed, 11 Dec 2019 15:08:54 -0800 [thread overview]
Message-ID: <20191211230857.20606-1-tim.a.kourt@linux.intel.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 1210 bytes --]
The function identifies if the given hostname is root domain name.
---
ell/net.c | 23 +++++++++++++++++++++++
ell/net.h | 1 +
2 files changed, 24 insertions(+)
diff --git a/ell/net.c b/ell/net.c
index b5b5f9d..3b6e0dc 100644
--- a/ell/net.c
+++ b/ell/net.c
@@ -110,3 +110,26 @@ LIB_EXPORT char *l_net_get_name(uint32_t ifindex)
return l_strdup(ifr.ifr_name);
}
+
+/**
+ * l_net_hostname_is_root:
+ * @hostname: Hostname to validate
+ *
+ * Identifies if the hostname given by @hostname is root domain name or
+ * not.
+ *
+ * Returns: #true if the given hostname is root and #false otherwise.
+ **/
+LIB_EXPORT bool l_net_hostname_is_root(const char *hostname)
+{
+ if (unlikely(!hostname))
+ return false;
+
+ if (!strcmp(hostname, ""))
+ return true;
+
+ if (!strcmp(hostname, "."))
+ return true;
+
+ return false;
+}
diff --git a/ell/net.h b/ell/net.h
index 25b1ca2..7afcf86 100644
--- a/ell/net.h
+++ b/ell/net.h
@@ -32,6 +32,7 @@ extern "C" {
bool l_net_get_mac_address(uint32_t ifindex, uint8_t *out_addr);
char *l_net_get_name(uint32_t ifindex);
+bool l_net_hostname_is_root(const char *hostname);
#ifdef __cplusplus
}
--
2.13.6
next reply other threads:[~2019-12-11 23:08 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-12-11 23:08 Tim Kourt [this message]
2019-12-11 23:08 ` [PATCH 2/4] net: Add l_net_hostname_is_localhost Tim Kourt
2019-12-11 23:08 ` [PATCH 3/4] unit: Add tests for net Tim Kourt
2019-12-11 23:08 ` [PATCH 4/4] dhcp-lease: Add domain name option handler Tim Kourt
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=20191211230857.20606-1-tim.a.kourt@linux.intel.com \
--to=tim.a.kourt@linux.intel.com \
--cc=iwd@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox