mirror of
https://gitlab.nic.cz/labs/bird.git
synced 2024-12-22 09:41:54 +00:00
Filter: Convert more methods to use METHOD_R()
This commit is contained in:
parent
4cdd6f2ea0
commit
ab61476ebf
@ -1034,10 +1034,7 @@
|
|||||||
((net_addr_roa6 *) v1.val.net)->max_pxlen);
|
((net_addr_roa6 *) v1.val.net)->max_pxlen);
|
||||||
]]);
|
]]);
|
||||||
|
|
||||||
/* Get ROA ASN or community ASN part */
|
/* Get ROA ASN */
|
||||||
METHOD_R(T_PAIR, asn, T_INT, i, v1.val.i >> 16);
|
|
||||||
METHOD_R(T_LC, asn, T_INT, i, v1.val.lc.asn);
|
|
||||||
|
|
||||||
METHOD(T_NET, asn, 0, [[
|
METHOD(T_NET, asn, 0, [[
|
||||||
if (!net_is_roa(v1.val.net))
|
if (!net_is_roa(v1.val.net))
|
||||||
runtime( "ROA expected" );
|
runtime( "ROA expected" );
|
||||||
@ -1047,7 +1044,6 @@
|
|||||||
((net_addr_roa6 *) v1.val.net)->asn);
|
((net_addr_roa6 *) v1.val.net)->asn);
|
||||||
]]);
|
]]);
|
||||||
|
|
||||||
|
|
||||||
/* Convert prefix to IP */
|
/* Convert prefix to IP */
|
||||||
METHOD_R(T_NET, ip, T_IP, ip, net_prefix(v1.val.net));
|
METHOD_R(T_NET, ip, T_IP, ip, net_prefix(v1.val.net));
|
||||||
|
|
||||||
@ -1059,81 +1055,47 @@
|
|||||||
RESULT(T_RD, ec, net_rd(v1.val.net));
|
RESULT(T_RD, ec, net_rd(v1.val.net));
|
||||||
}
|
}
|
||||||
|
|
||||||
INST(FI_AS_PATH_FIRST, 1, 1) { /* Get first ASN from AS PATH */
|
/* Get first ASN from AS PATH */
|
||||||
ARG(1, T_PATH);
|
METHOD_R(T_PATH, first, T_INT, i, ({ u32 as = 0; as_path_get_first(v1.val.ad, &as); as; }));
|
||||||
METHOD_CONSTRUCTOR("first");
|
|
||||||
u32 as = 0;
|
|
||||||
as_path_get_first(v1.val.ad, &as);
|
|
||||||
RESULT(T_INT, i, as);
|
|
||||||
}
|
|
||||||
|
|
||||||
INST(FI_AS_PATH_LAST, 1, 1) { /* Get last ASN from AS PATH */
|
/* Get last ASN from AS PATH */
|
||||||
ARG(1, T_PATH);
|
METHOD_R(T_PATH, last, T_INT, i, ({ u32 as = 0; as_path_get_last(v1.val.ad, &as); as; }));
|
||||||
METHOD_CONSTRUCTOR("last");
|
|
||||||
u32 as = 0;
|
|
||||||
as_path_get_last(v1.val.ad, &as);
|
|
||||||
RESULT(T_INT, i, as);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Get last ASN from non-aggregated part of AS PATH */
|
/* Get last ASN from non-aggregated part of AS PATH */
|
||||||
METHOD_R(T_PATH, last_nonaggregated, T_INT, i, as_path_get_last_nonaggregated(v1.val.ad));
|
METHOD_R(T_PATH, last_nonaggregated, T_INT, i, as_path_get_last_nonaggregated(v1.val.ad));
|
||||||
|
|
||||||
|
/* Get ASN part from the standard community ASN */
|
||||||
|
METHOD_R(T_PAIR, asn, T_INT, i, v1.val.i >> 16);
|
||||||
|
|
||||||
/* Get data part from the standard community */
|
/* Get data part from the standard community */
|
||||||
METHOD_R(T_PAIR, data, T_INT, i, v1.val.i & 0xFFFF);
|
METHOD_R(T_PAIR, data, T_INT, i, v1.val.i & 0xFFFF);
|
||||||
|
|
||||||
|
/* Get ASN part from the large community */
|
||||||
|
METHOD_R(T_LC, asn, T_INT, i, v1.val.lc.asn);
|
||||||
|
|
||||||
/* Get data1 part from the large community */
|
/* Get data1 part from the large community */
|
||||||
METHOD_R(T_LC, data1, T_INT, i, v1.val.lc.ldp1);
|
METHOD_R(T_LC, data1, T_INT, i, v1.val.lc.ldp1);
|
||||||
|
|
||||||
/* Get data2 part from the large community */
|
/* Get data2 part from the large community */
|
||||||
METHOD_R(T_LC, data2, T_INT, i, v1.val.lc.ldp2);
|
METHOD_R(T_LC, data2, T_INT, i, v1.val.lc.ldp2);
|
||||||
|
|
||||||
INST(FI_CLIST_MIN, 1, 1) { /* Get minimum element from list */
|
/* Get minimum element from clist */
|
||||||
ARG(1, T_CLIST);
|
METHOD_R(T_CLIST, min, T_PAIR, i, ({ u32 val = 0; int_set_min(v1.val.ad, &val); val; }));
|
||||||
METHOD_CONSTRUCTOR("min");
|
|
||||||
u32 val = 0;
|
|
||||||
int_set_min(v1.val.ad, &val);
|
|
||||||
RESULT(T_PAIR, i, val);
|
|
||||||
}
|
|
||||||
|
|
||||||
INST(FI_CLIST_MAX, 1, 1) { /* Get minimum element from list */
|
/* Get maximum element from clist */
|
||||||
ARG(1, T_CLIST);
|
METHOD_R(T_CLIST, max, T_PAIR, i, ({ u32 val = 0; int_set_max(v1.val.ad, &val); val; }));
|
||||||
METHOD_CONSTRUCTOR("max");
|
|
||||||
u32 val = 0;
|
|
||||||
int_set_max(v1.val.ad, &val);
|
|
||||||
RESULT(T_PAIR, i, val);
|
|
||||||
}
|
|
||||||
|
|
||||||
INST(FI_ECLIST_MIN, 1, 1) { /* Get minimum element from list */
|
/* Get minimum element from eclist */
|
||||||
ARG(1, T_ECLIST);
|
METHOD_R(T_ECLIST, min, T_EC, ec, ({ u64 val = 0; ec_set_min(v1.val.ad, &val); val; }));
|
||||||
METHOD_CONSTRUCTOR("min");
|
|
||||||
u64 val = 0;
|
|
||||||
ec_set_min(v1.val.ad, &val);
|
|
||||||
RESULT(T_EC, ec, val);
|
|
||||||
}
|
|
||||||
|
|
||||||
INST(FI_ECLIST_MAX, 1, 1) { /* Get minimum element from list */
|
/* Get maximum element from eclist */
|
||||||
ARG(1, T_ECLIST);
|
METHOD_R(T_ECLIST, max, T_EC, ec, ({ u64 val = 0; ec_set_max(v1.val.ad, &val); val; }));
|
||||||
METHOD_CONSTRUCTOR("max");
|
|
||||||
u64 val = 0;
|
|
||||||
ec_set_max(v1.val.ad, &val);
|
|
||||||
RESULT(T_EC, ec, val);
|
|
||||||
}
|
|
||||||
|
|
||||||
INST(FI_LCLIST_MIN, 1, 1) { /* Get minimum element from list */
|
/* Get minimum element from lclist */
|
||||||
ARG(1, T_LCLIST);
|
METHOD_R(T_LCLIST, min, T_LC, lc, ({ lcomm val = {}; lc_set_min(v1.val.ad, &val); val; }));
|
||||||
METHOD_CONSTRUCTOR("min");
|
|
||||||
lcomm val = {};
|
|
||||||
lc_set_min(v1.val.ad, &val);
|
|
||||||
RESULT(T_LC, lc, val);
|
|
||||||
}
|
|
||||||
|
|
||||||
INST(FI_LCLIST_MAX, 1, 1) { /* Get minimum element from list */
|
/* Get maximum element from lclist */
|
||||||
ARG(1, T_LCLIST);
|
METHOD_R(T_LCLIST, max, T_LC, lc, ({ lcomm val = {}; lc_set_max(v1.val.ad, &val); val; }));
|
||||||
METHOD_CONSTRUCTOR("max");
|
|
||||||
lcomm val = {};
|
|
||||||
lc_set_max(v1.val.ad, &val);
|
|
||||||
RESULT(T_LC, lc, val);
|
|
||||||
}
|
|
||||||
|
|
||||||
INST(FI_RETURN, 1, 0) {
|
INST(FI_RETURN, 1, 0) {
|
||||||
NEVER_CONSTANT;
|
NEVER_CONSTANT;
|
||||||
|
Loading…
Reference in New Issue
Block a user