From ccfa48a24aea64d1a844fb97cfe15965197c0908 Mon Sep 17 00:00:00 2001 From: Alexander Zubkov Date: Mon, 26 Jun 2023 15:35:22 +0200 Subject: [PATCH] RAdv: Use new syntax for custom options And use WALK_LIST macro --- proto/radv/config.Y | 10 ++++++---- proto/radv/packets.c | 6 ++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/proto/radv/config.Y b/proto/radv/config.Y index 5c213d50..db683194 100644 --- a/proto/radv/config.Y +++ b/proto/radv/config.Y @@ -42,7 +42,7 @@ CF_KEYWORDS(RADV, PREFIX, INTERFACE, MIN, MAX, RA, DELAY, INTERVAL, SOLICITED, RETRANS, TIMER, CURRENT, HOP, LIMIT, DEFAULT, VALID, PREFERRED, MULT, LIFETIME, SKIP, ONLINK, AUTONOMOUS, RDNSS, DNSSL, NS, DOMAIN, LOCAL, TRIGGER, SENSITIVE, PREFERENCE, LOW, MEDIUM, HIGH, PROPAGATE, ROUTE, - ROUTES, RA_PREFERENCE, RA_LIFETIME) + ROUTES, RA_PREFERENCE, RA_LIFETIME, CUSTOM, OPTION, TYPE, VALUE) CF_ENUM(T_ENUM_RA_PREFERENCE, RA_PREF_, LOW, MEDIUM, HIGH) @@ -50,6 +50,8 @@ CF_ENUM(T_ENUM_RA_PREFERENCE, RA_PREF_, LOW, MEDIUM, HIGH) CF_GRAMMAR +kw_sym: CUSTOM | OPTION | VALUE ; + proto: radv_proto ; radv_proto_start: proto_start RADV @@ -71,7 +73,7 @@ radv_proto_item: | PREFIX radv_prefix { add_tail(&RADV_CFG->pref_list, NODE this_radv_prefix); } | RDNSS { init_list(&radv_dns_list); } radv_rdnss { add_tail_list(&RADV_CFG->rdnss_list, &radv_dns_list); } | DNSSL { init_list(&radv_dns_list); } radv_dnssl { add_tail_list(&RADV_CFG->dnssl_list, &radv_dns_list); } - | OTHER TYPE expr BYTESTRING { radv_add_to_custom_list(&RADV_CFG->custom_list, $3, $4); } + | CUSTOM OPTION TYPE expr VALUE BYTESTRING { radv_add_to_custom_list(&RADV_CFG->custom_list, $4, $6); } | TRIGGER net_ip6 { RADV_CFG->trigger = $2; } | PROPAGATE ROUTES bool { RADV_CFG->propagate_routes = $3; } ; @@ -136,10 +138,10 @@ radv_iface_item: | PREFIX radv_prefix { add_tail(&RADV_IFACE->pref_list, NODE this_radv_prefix); } | RDNSS { init_list(&radv_dns_list); } radv_rdnss { add_tail_list(&RADV_IFACE->rdnss_list, &radv_dns_list); } | DNSSL { init_list(&radv_dns_list); } radv_dnssl { add_tail_list(&RADV_IFACE->dnssl_list, &radv_dns_list); } - | OTHER TYPE expr BYTESTRING { radv_add_to_custom_list(&RADV_IFACE->custom_list, $3, $4); } + | CUSTOM OPTION TYPE expr VALUE BYTESTRING { radv_add_to_custom_list(&RADV_IFACE->custom_list, $4, $6); } | RDNSS LOCAL bool { RADV_IFACE->rdnss_local = $3; } | DNSSL LOCAL bool { RADV_IFACE->dnssl_local = $3; } - | OTHER LOCAL bool { RADV_IFACE->custom_local = $3; } + | CUSTOM OPTION LOCAL bool { RADV_IFACE->custom_local = $4; } ; radv_preference: diff --git a/proto/radv/packets.c b/proto/radv/packets.c index d1f86ec1..77c98794 100644 --- a/proto/radv/packets.c +++ b/proto/radv/packets.c @@ -264,9 +264,8 @@ radv_prepare_dnssl(struct radv_iface *ifa, list *dnssl_list, char **buf, char *b static int radv_prepare_custom(struct radv_iface *ifa, list *custom_list, char **buf, char *bufend) { - struct radv_custom_config *ccf = HEAD(*custom_list); - - while(NODE_VALID(ccf)) + struct radv_custom_config *ccf; + WALK_LIST(ccf, *custom_list) { struct radv_opt_custom *op = (void *) *buf; /* Add 2 octets for type and size and 8 - 1 for ceiling the division up to 8 octets */ @@ -280,7 +279,6 @@ radv_prepare_custom(struct radv_iface *ifa, list *custom_list, char **buf, char memcpy(op->payload, ccf->payload->data, ccf->payload->length); *buf += 8 * op->length; - ccf = NODE_NEXT(ccf); } return 0;