From: Davide Caratti <davide.caratti@gmail.com>
To: ell@lists.01.org
Subject: [PATCH 2/2] avoid using inet_aton()
Date: Thu, 03 Jun 2021 11:50:03 +0200 [thread overview]
Message-ID: <febf75f8dd0a4a97e4d650a8655752aef0aa685e.1622713571.git.davide.caratti@gmail.com> (raw)
In-Reply-To: <cover.1622713571.git.davide.caratti@gmail.com>
[-- Attachment #1: Type: text/plain, Size: 2302 bytes --]
use inet_pton(AF_INET,...), like it's done elsewhere for IPv6.
Signed-off-by: Davide Caratti <davide.caratti@gmail.com>
---
ell/dhcp-server.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/ell/dhcp-server.c b/ell/dhcp-server.c
index 43f06b3..e39e456 100644
--- a/ell/dhcp-server.c
+++ b/ell/dhcp-server.c
@@ -773,7 +773,7 @@ LIB_EXPORT bool l_dhcp_server_start(struct l_dhcp_server *server)
/* Assign a default netmask if not already */
if (!server->netmask) {
- if (inet_aton("255.255.255.0", &ia) < 0)
+ if (inet_pton(AF_INET,"255.255.255.0", &ia) != 1)
return false;
server->netmask = ia.s_addr;
@@ -890,12 +890,12 @@ LIB_EXPORT bool l_dhcp_server_set_ip_range(struct l_dhcp_server *server,
if (unlikely(!server || !start_ip || !end_ip))
return false;
- if (inet_aton(start_ip, &_host_addr) == 0)
+ if (inet_pton(AF_INET, start_ip, &_host_addr) != 1)
return false;
start = ntohl(_host_addr.s_addr);
- if (inet_aton((const char *) end_ip, &_host_addr) == 0)
+ if (inet_pton(AF_INET, (const char *) end_ip, &_host_addr) != 1)
return false;
server->start_ip = start;
@@ -952,7 +952,7 @@ LIB_EXPORT bool l_dhcp_server_set_ip_address(struct l_dhcp_server *server,
if (unlikely(!server))
return false;
- if (inet_aton(ip, &ia) < 0)
+ if (inet_pton(AF_INET, ip, &ia) != 1)
return false;
server->address = ia.s_addr;
@@ -980,7 +980,7 @@ LIB_EXPORT bool l_dhcp_server_set_netmask(struct l_dhcp_server *server,
if (unlikely(!server || !mask))
return false;
- if (inet_aton(mask, &ia) < 0)
+ if (inet_pton(AF_INET, mask, &ia) != 1)
return false;
server->netmask = ia.s_addr;
@@ -996,7 +996,7 @@ LIB_EXPORT bool l_dhcp_server_set_gateway(struct l_dhcp_server *server,
if (unlikely(!server || !ip))
return false;
- if (inet_aton(ip, &ia) < 0)
+ if (inet_pton(AF_INET, ip, &ia) != 1)
return false;
server->gateway = ia.s_addr;
@@ -1017,7 +1017,7 @@ LIB_EXPORT bool l_dhcp_server_set_dns(struct l_dhcp_server *server, char **dns)
for (i = 0; dns[i]; i++) {
struct in_addr ia;
- if (inet_aton(dns[i], &ia) < 0)
+ if (inet_pton(AF_INET, dns[i], &ia) != 1)
goto failed;
dns_list[i] = ia.s_addr;
--
2.31.1
next prev parent reply other threads:[~2021-06-03 9:50 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-03 9:50 [PATCH 0/2] avoid using inet_ntoa() and inet_aton() Davide Caratti
2021-06-03 9:50 ` [PATCH 1/2] avoid using inet_ntoa() Davide Caratti
2021-06-04 16:01 ` Denis Kenzior
2021-06-07 17:00 ` d. caratti
2021-06-07 18:41 ` Denis Kenzior
2021-06-08 12:46 ` d. caratti
2021-06-08 16:22 ` Denis Kenzior
2021-06-09 10:18 ` d. caratti
2021-06-10 22:12 ` Denis Kenzior
2021-06-03 9:50 ` Davide Caratti [this message]
2021-06-04 15:41 ` [PATCH 2/2] avoid using inet_aton() 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=febf75f8dd0a4a97e4d650a8655752aef0aa685e.1622713571.git.davide.caratti@gmail.com \
--to=davide.caratti@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).