]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Rewrite create_route() using ip_addr instead of net_addr
authorIgor Putovny <igor.putovny@nic.cz>
Wed, 12 Feb 2025 16:12:10 +0000 (17:12 +0100)
committerIgor Putovny <igor.putovny@nic.cz>
Wed, 12 Feb 2025 16:12:10 +0000 (17:12 +0100)
proto/aggregator/aggregator.c

index 8e9b062a36ab23cf6d8bf337f490cdd92301145d..8d95a1be9db7b7f90709b1a90c9c454db84558b9 100644 (file)
@@ -378,29 +378,15 @@ aggregator_withdraw_rte(struct aggregator_proto *p)
 static void aggregator_bucket_update(struct aggregator_proto *p, struct aggregator_bucket *bucket, struct network *net);
 
 static void
-create_route_ip4(struct aggregator_proto *p, const struct net_addr_ip4 *addr, struct aggregator_bucket *bucket)
+create_route(struct aggregator_proto *p, ip_addr prefix, u32 pxlen, struct aggregator_bucket *bucket)
 {
-  struct {
-    struct network net;
-    union net_addr_union u;
-  } net_placeholder;
-
-  assert(addr->type == NET_IP4);
-  net_copy_ip4((struct net_addr_ip4 *)&net_placeholder.net.n.addr, addr);
-  aggregator_bucket_update(p, bucket, &net_placeholder.net);
-}
+  struct net_addr addr = { 0 };
+  net_fill_ipa(&addr, prefix, pxlen);
 
-static void
-create_route_ip6(struct aggregator_proto *p, const struct net_addr_ip6 *addr, struct aggregator_bucket *bucket)
-{
-  struct {
-    struct network n;
-    union net_addr_union u;
-  } net_placeholder;
+  struct network *n = allocz(sizeof(*n) + sizeof(struct net_addr));
+  net_copy(n->n.addr, &addr);
 
-  assert(addr->type == NET_IP6);
-  net_copy_ip6((struct net_addr_ip6 *)&net_placeholder.n.n.addr, addr);
-  aggregator_bucket_update(p, bucket, &net_placeholder.n);
+  aggregator_bucket_update(p, bucket, n);
 }
 
 /*