* [PATCH 1/4] rtnl: Add l_rtnl_route_set_gateway
@ 2022-01-03 14:18 Andrew Zaborowski
0 siblings, 0 replies; 3+ messages in thread
From: Andrew Zaborowski @ 2022-01-03 14:18 UTC (permalink / raw)
To: ell
[-- Attachment #1: Type: text/plain, Size: 1915 bytes --]
Allow creating prefix routes for off-link prefixes, i.e. ones that
should be routed through a gateway.
---
ell/ell.sym | 1 +
ell/rtnl.c | 16 ++++++++++++++++
ell/rtnl.h | 1 +
3 files changed, 18 insertions(+)
diff --git a/ell/ell.sym b/ell/ell.sym
index 51db458..e581add 100644
--- a/ell/ell.sym
+++ b/ell/ell.sym
@@ -633,6 +633,7 @@ global:
l_rtnl_route_free;
l_rtnl_route_get_family;
l_rtnl_route_get_gateway;
+ l_rtnl_route_set_gateway;
l_rtnl_route_get_lifetime;
l_rtnl_route_set_lifetime;
l_rtnl_route_get_mtu;
diff --git a/ell/rtnl.c b/ell/rtnl.c
index 4a1a248..ee6dc9a 100644
--- a/ell/rtnl.c
+++ b/ell/rtnl.c
@@ -403,6 +403,22 @@ LIB_EXPORT bool l_rtnl_route_get_gateway(const struct l_rtnl_route *rt,
out_buf);
}
+LIB_EXPORT bool l_rtnl_route_set_gateway(struct l_rtnl_route *rt,
+ const char *address)
+{
+ if (unlikely(!rt))
+ return false;
+
+ switch (rt->family) {
+ case AF_INET:
+ return inet_pton(AF_INET, address, &rt->gw.in_addr) == 1;
+ case AF_INET6:
+ return inet_pton(AF_INET6, address, &rt->gw.in6_addr) == 1;
+ default:
+ return false;
+ }
+}
+
LIB_EXPORT uint32_t l_rtnl_route_get_lifetime(const struct l_rtnl_route *rt)
{
if (unlikely(!rt))
diff --git a/ell/rtnl.h b/ell/rtnl.h
index 274816c..70cbaec 100644
--- a/ell/rtnl.h
+++ b/ell/rtnl.h
@@ -69,6 +69,7 @@ void l_rtnl_route_free(struct l_rtnl_route *rt);
DEFINE_CLEANUP_FUNC(l_rtnl_route_free);
uint8_t l_rtnl_route_get_family(const struct l_rtnl_route *rt);
bool l_rtnl_route_get_gateway(const struct l_rtnl_route *rt, char *out_buf);
+bool l_rtnl_route_set_gateway(struct l_rtnl_route *rt, const char *address);
uint32_t l_rtnl_route_get_lifetime(const struct l_rtnl_route *rt);
bool l_rtnl_route_set_lifetime(struct l_rtnl_route *rt, uint32_t lt);
uint32_t l_rtnl_route_get_mtu(const struct l_rtnl_route *rt);
--
2.32.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH 1/4] rtnl: Add l_rtnl_route_set_gateway
@ 2022-01-05 14:20 Andrew Zaborowski
0 siblings, 0 replies; 3+ messages in thread
From: Andrew Zaborowski @ 2022-01-05 14:20 UTC (permalink / raw)
To: ell
[-- Attachment #1: Type: text/plain, Size: 1130 bytes --]
Hi Denis,
On Mon, 3 Jan 2022 at 19:54, Denis Kenzior <denkenz(a)gmail.com> wrote:
> On 1/3/22 08:18, Andrew Zaborowski wrote:
> > Allow creating prefix routes for off-link prefixes, i.e. ones that
> > should be routed through a gateway.
> > ---
> > ell/ell.sym | 1 +
> > ell/rtnl.c | 16 ++++++++++++++++
> > ell/rtnl.h | 1 +
> > 3 files changed, 18 insertions(+)
> >
>
> <snip>
>
> >
> > +LIB_EXPORT bool l_rtnl_route_set_gateway(struct l_rtnl_route *rt,
> > + const char *address)
> > +{
> > + if (unlikely(!rt))
> > + return false;
> > +
> > + switch (rt->family) {
> > + case AF_INET:
> > + return inet_pton(AF_INET, address, &rt->gw.in_addr) == 1;
> > + case AF_INET6:
> > + return inet_pton(AF_INET6, address, &rt->gw.in6_addr) == 1;
> > + default:
> > + return false;
> > + }
> > +}
> > +
>
> Since we already have l_rtnl_route_new_gateway, would this make more sense as a
> dedicated constructor? Something like l_rtnl_route_new_static?
Ok.
Best regards
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH 1/4] rtnl: Add l_rtnl_route_set_gateway
@ 2022-01-03 18:37 Denis Kenzior
0 siblings, 0 replies; 3+ messages in thread
From: Denis Kenzior @ 2022-01-03 18:37 UTC (permalink / raw)
To: ell
[-- Attachment #1: Type: text/plain, Size: 1008 bytes --]
Hi Andrew,
On 1/3/22 08:18, Andrew Zaborowski wrote:
> Allow creating prefix routes for off-link prefixes, i.e. ones that
> should be routed through a gateway.
> ---
> ell/ell.sym | 1 +
> ell/rtnl.c | 16 ++++++++++++++++
> ell/rtnl.h | 1 +
> 3 files changed, 18 insertions(+)
>
<snip>
>
> +LIB_EXPORT bool l_rtnl_route_set_gateway(struct l_rtnl_route *rt,
> + const char *address)
> +{
> + if (unlikely(!rt))
> + return false;
> +
> + switch (rt->family) {
> + case AF_INET:
> + return inet_pton(AF_INET, address, &rt->gw.in_addr) == 1;
> + case AF_INET6:
> + return inet_pton(AF_INET6, address, &rt->gw.in6_addr) == 1;
> + default:
> + return false;
> + }
> +}
> +
Since we already have l_rtnl_route_new_gateway, would this make more sense as a
dedicated constructor? Something like l_rtnl_route_new_static?
> LIB_EXPORT uint32_t l_rtnl_route_get_lifetime(const struct l_rtnl_route *rt)
> {
> if (unlikely(!rt))
Regards,
-Denis
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-01-05 14:20 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-03 14:18 [PATCH 1/4] rtnl: Add l_rtnl_route_set_gateway Andrew Zaborowski
2022-01-03 18:37 Denis Kenzior
2022-01-05 14:20 Andrew Zaborowski
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.