diff options
author | Mikael Magnusson <mikma@users.sourceforge.net> | 2023-11-25 22:00:44 +0100 |
---|---|---|
committer | Mikael Magnusson <mikma@users.sourceforge.net> | 2023-11-25 22:00:44 +0100 |
commit | 99b97e628e0fe06dbeadee8c6b959b4c9bc92777 (patch) | |
tree | 2c9c46588e4a7b888afa89527f9316aa585b69d3 | |
parent | d38fe44d1f974a2e1ef6b25f7a26e650bf8bc8d4 (diff) | |
parent | ab61476ebf2b8873d542f77069ec111030329268 (diff) |
Merge commit 'ab61476e' into wireguard-next-tmp7-1
-rw-r--r-- | filter/f-inst.c | 84 |
1 files changed, 23 insertions, 61 deletions
diff --git a/filter/f-inst.c b/filter/f-inst.c index 61627b4e..0f9d3fb8 100644 --- a/filter/f-inst.c +++ b/filter/f-inst.c @@ -1059,10 +1059,7 @@ ((net_addr_roa6 *) v1.val.net)->max_pxlen); ]]); - /* Get ROA ASN or community ASN part */ - METHOD_R(T_PAIR, asn, T_INT, i, v1.val.i >> 16); - METHOD_R(T_LC, asn, T_INT, i, v1.val.lc.asn); - + /* Get ROA ASN */ METHOD(T_NET, asn, 0, [[ if (!net_is_roa(v1.val.net)) runtime( "ROA expected" ); @@ -1072,7 +1069,6 @@ ((net_addr_roa6 *) v1.val.net)->asn); ]]); - /* Convert prefix to IP */ METHOD_R(T_NET, ip, T_IP, ip, net_prefix(v1.val.net)); @@ -1084,81 +1080,47 @@ RESULT(T_RD, ec, net_rd(v1.val.net)); } - INST(FI_AS_PATH_FIRST, 1, 1) { /* Get first ASN from AS PATH */ - ARG(1, T_PATH); - METHOD_CONSTRUCTOR("first"); - u32 as = 0; - as_path_get_first(v1.val.ad, &as); - RESULT(T_INT, i, as); - } + /* Get first ASN from AS PATH */ + METHOD_R(T_PATH, first, T_INT, i, ({ u32 as = 0; as_path_get_first(v1.val.ad, &as); as; })); - INST(FI_AS_PATH_LAST, 1, 1) { /* Get last ASN from AS PATH */ - ARG(1, T_PATH); - METHOD_CONSTRUCTOR("last"); - u32 as = 0; - as_path_get_last(v1.val.ad, &as); - RESULT(T_INT, i, as); - } + /* Get last ASN from AS PATH */ + METHOD_R(T_PATH, last, T_INT, i, ({ u32 as = 0; as_path_get_last(v1.val.ad, &as); as; })); /* 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)); + /* 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 */ 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 */ METHOD_R(T_LC, data1, T_INT, i, v1.val.lc.ldp1); /* Get data2 part from the large community */ METHOD_R(T_LC, data2, T_INT, i, v1.val.lc.ldp2); - INST(FI_CLIST_MIN, 1, 1) { /* Get minimum element from list */ - ARG(1, T_CLIST); - METHOD_CONSTRUCTOR("min"); - u32 val = 0; - int_set_min(v1.val.ad, &val); - RESULT(T_PAIR, i, val); - } + /* Get minimum element from clist */ + METHOD_R(T_CLIST, min, T_PAIR, i, ({ u32 val = 0; int_set_min(v1.val.ad, &val); val; })); - INST(FI_CLIST_MAX, 1, 1) { /* Get minimum element from list */ - ARG(1, T_CLIST); - METHOD_CONSTRUCTOR("max"); - u32 val = 0; - int_set_max(v1.val.ad, &val); - RESULT(T_PAIR, i, val); - } + /* Get maximum element from clist */ + METHOD_R(T_CLIST, max, T_PAIR, i, ({ u32 val = 0; int_set_max(v1.val.ad, &val); val; })); - INST(FI_ECLIST_MIN, 1, 1) { /* Get minimum element from list */ - ARG(1, T_ECLIST); - METHOD_CONSTRUCTOR("min"); - u64 val = 0; - ec_set_min(v1.val.ad, &val); - RESULT(T_EC, ec, val); - } + /* Get minimum element from eclist */ + METHOD_R(T_ECLIST, min, T_EC, ec, ({ u64 val = 0; ec_set_min(v1.val.ad, &val); val; })); - INST(FI_ECLIST_MAX, 1, 1) { /* Get minimum element from list */ - ARG(1, T_ECLIST); - METHOD_CONSTRUCTOR("max"); - u64 val = 0; - ec_set_max(v1.val.ad, &val); - RESULT(T_EC, ec, val); - } + /* Get maximum element from eclist */ + METHOD_R(T_ECLIST, max, T_EC, ec, ({ u64 val = 0; ec_set_max(v1.val.ad, &val); val; })); - INST(FI_LCLIST_MIN, 1, 1) { /* Get minimum element from list */ - ARG(1, T_LCLIST); - METHOD_CONSTRUCTOR("min"); - lcomm val = {}; - lc_set_min(v1.val.ad, &val); - RESULT(T_LC, lc, val); - } + /* Get minimum element from lclist */ + METHOD_R(T_LCLIST, min, T_LC, lc, ({ lcomm val = {}; lc_set_min(v1.val.ad, &val); val; })); - INST(FI_LCLIST_MAX, 1, 1) { /* Get minimum element from list */ - ARG(1, T_LCLIST); - METHOD_CONSTRUCTOR("max"); - lcomm val = {}; - lc_set_max(v1.val.ad, &val); - RESULT(T_LC, lc, val); - } + /* Get maximum element from lclist */ + METHOD_R(T_LCLIST, max, T_LC, lc, ({ lcomm val = {}; lc_set_max(v1.val.ad, &val); val; })); INST(FI_RETURN, 1, 0) { NEVER_CONSTANT; |