All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Zaborowski <andrew.zaborowski@intel.com>
To: ell@lists.linux.dev
Subject: [PATCH 4/7] rtnl: Add l_rtnl_address_get_in_addr
Date: Mon, 19 Sep 2022 15:31:02 +0200	[thread overview]
Message-ID: <20220919133105.3129080-4-andrew.zaborowski@intel.com> (raw)
In-Reply-To: <20220919133105.3129080-1-andrew.zaborowski@intel.com>

Similar to l_rtnl_route_get_dst_in_addr add a getter for the raw address
value, avoiding extra string conversions.
---
 ell/ell.sym | 1 +
 ell/rtnl.c  | 9 +++++++++
 ell/rtnl.h  | 1 +
 3 files changed, 11 insertions(+)

diff --git a/ell/ell.sym b/ell/ell.sym
index a28eb55..d76b2ea 100644
--- a/ell/ell.sym
+++ b/ell/ell.sym
@@ -626,6 +626,7 @@ global:
 	l_rtnl_address_clone;
 	l_rtnl_address_free;
 	l_rtnl_address_get_address;
+	l_rtnl_address_get_in_addr;
 	l_rtnl_address_get_family;
 	l_rtnl_address_get_prefix_length;
 	l_rtnl_address_get_broadcast;
diff --git a/ell/rtnl.c b/ell/rtnl.c
index 2483e82..5909c4b 100644
--- a/ell/rtnl.c
+++ b/ell/rtnl.c
@@ -180,6 +180,15 @@ LIB_EXPORT bool l_rtnl_address_get_address(const struct l_rtnl_address *addr,
 						out_buf);
 }
 
+LIB_EXPORT const void *l_rtnl_address_get_in_addr(
+					const struct l_rtnl_address *addr)
+{
+	if (unlikely(!addr))
+		return NULL;
+
+	return addr->family == AF_INET ? (void *) &addr->in_addr : &addr->in6_addr;
+}
+
 LIB_EXPORT uint8_t l_rtnl_address_get_family(const struct l_rtnl_address *addr)
 {
 	if (unlikely(!addr))
diff --git a/ell/rtnl.h b/ell/rtnl.h
index ffd1d73..1e6b1fa 100644
--- a/ell/rtnl.h
+++ b/ell/rtnl.h
@@ -44,6 +44,7 @@ void l_rtnl_address_free(struct l_rtnl_address *addr);
 DEFINE_CLEANUP_FUNC(l_rtnl_address_free);
 bool l_rtnl_address_get_address(const struct l_rtnl_address *addr,
 				char *out_buf);
+const void *l_rtnl_address_get_in_addr(const struct l_rtnl_address *addr);
 uint8_t l_rtnl_address_get_family(const struct l_rtnl_address *addr);
 uint8_t l_rtnl_address_get_prefix_length(const struct l_rtnl_address *addr);
 bool l_rtnl_address_get_broadcast(const struct l_rtnl_address *addr,
-- 
2.34.1


  parent reply	other threads:[~2022-09-19 13:31 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-19 13:30 [PATCH 1/7] icmp6: Save SLAAC prefixes from RAs Andrew Zaborowski
2022-09-19 13:31 ` [PATCH 2/7] icmp6: Parse RDNSS and DNSSL options Andrew Zaborowski
2022-09-19 13:31 ` [PATCH 3/7] icmp6: Switch socket from AF_INET6 to AF_PACKET Andrew Zaborowski
2022-09-19 13:31 ` Andrew Zaborowski [this message]
2022-09-19 13:31 ` [PATCH 5/7] netconfig: Decouple icmp6 start from dhcp6 start Andrew Zaborowski
2022-09-19 13:31 ` [PATCH 6/7] netconfig: Create SLAAC address Andrew Zaborowski
2022-09-19 13:31 ` [PATCH 7/7] netconfig: Control optimistic DAD Andrew Zaborowski
2022-09-19 18:43   ` Denis Kenzior
2022-09-19 23:56     ` Andrew Zaborowski

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=20220919133105.3129080-4-andrew.zaborowski@intel.com \
    --to=andrew.zaborowski@intel.com \
    --cc=ell@lists.linux.dev \
    /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.