summaryrefslogtreecommitdiff
path: root/proto/babel/babel.c
diff options
context:
space:
mode:
authorMaria Matejka <mq@ucw.cz>2022-04-10 19:31:50 +0200
committerMaria Matejka <mq@ucw.cz>2022-05-04 15:37:41 +0200
commitc1194ab7edbb17cb7371ac38e6eab5ae3ae72163 (patch)
tree821c04b0900ddc33c6bd20c4ca93dd30aa8a23b4 /proto/babel/babel.c
parentef4313e1667a8745c8d8813ac78342ec7c035895 (diff)
Protocols use EA_LITERAL_* to set attributes
Diffstat (limited to 'proto/babel/babel.c')
-rw-r--r--proto/babel/babel.c36
1 files changed, 13 insertions, 23 deletions
diff --git a/proto/babel/babel.c b/proto/babel/babel.c
index a6cc7aa3..db710a0d 100644
--- a/proto/babel/babel.c
+++ b/proto/babel/babel.c
@@ -640,6 +640,18 @@ babel_announce_rte(struct babel_proto *p, struct babel_entry *e)
if (r)
{
+ struct {
+ ea_list l;
+ eattr a[3];
+ } eattrs = {
+ .l.count = 3,
+ .a = {
+ EA_LITERAL_EMBEDDED(EA_BABEL_METRIC, T_INT, 0, r->metric),
+ EA_LITERAL_STORE_ADATA(EA_BABEL_ROUTER_ID, T_OPAQUE, 0, &r->router_id, sizeof(r->router_id)),
+ EA_LITERAL_EMBEDDED(EA_BABEL_SEQNO, T_INT, 0, r->seqno),
+ }
+ };
+
rta a0 = {
.source = RTS_BABEL,
.scope = SCOPE_UNIVERSE,
@@ -648,29 +660,7 @@ babel_announce_rte(struct babel_proto *p, struct babel_entry *e)
.from = r->neigh->addr,
.nh.gw = r->next_hop,
.nh.iface = r->neigh->ifa->iface,
- .eattrs = alloca(sizeof(ea_list) + 3*sizeof(eattr)),
- };
-
- *a0.eattrs = (ea_list) { .count = 3 };
- a0.eattrs->attrs[0] = (eattr) {
- .id = EA_BABEL_METRIC,
- .type = T_INT,
- .u.data = r->metric,
- };
-
- struct adata *ad = alloca(sizeof(struct adata) + sizeof(u64));
- ad->length = sizeof(u64);
- memcpy(ad->data, &(r->router_id), sizeof(u64));
- a0.eattrs->attrs[1] = (eattr) {
- .id = EA_BABEL_ROUTER_ID,
- .type = T_OPAQUE,
- .u.ptr = ad,
- };
-
- a0.eattrs->attrs[2] = (eattr) {
- .id = EA_BABEL_SEQNO,
- .type = T_INT,
- .u.data = r->seqno,
+ .eattrs = &eattrs.l,
};
/*