From: Arran Cudbard-Bell Date: Thu, 15 Jun 2023 15:17:11 +0000 (-0400) Subject: xlat: Expose the protocol xlat registraiton function X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1754a5fbb8fe7feebafed447dd03f15d6fee7342;p=thirdparty%2Ffreeradius-server.git xlat: Expose the protocol xlat registraiton function --- diff --git a/src/lib/unlang/xlat.h b/src/lib/unlang/xlat.h index f9aba933c28..3d41debe192 100644 --- a/src/lib/unlang/xlat.h +++ b/src/lib/unlang/xlat.h @@ -502,6 +502,7 @@ xlat_action_t unlang_xlat_yield(request_t *request, /* * xlat_builtin.c */ +int xlat_protocols_register(void); int xlat_init(void); void xlat_free(void); diff --git a/src/lib/unlang/xlat_builtin.c b/src/lib/unlang/xlat_builtin.c index d9e909e234b..d9076f51d4c 100644 --- a/src/lib/unlang/xlat_builtin.c +++ b/src/lib/unlang/xlat_builtin.c @@ -3191,6 +3191,9 @@ static int xlat_protocol_register(fr_dict_t const *dict) if (tp_decode) { snprintf(buffer, sizeof(buffer), "%s.decode", name); + /* May be called multiple times, so just skip protocols we've already registered */ + if (xlat_func_find(buffer, -1)) return 1; + if (unlikely((xlat = xlat_func_register(NULL, buffer, protocol_decode_xlat, FR_TYPE_UINT32)) == NULL)) return -1; xlat_func_args_set(xlat, protocol_decode_xlat_args); /* coverity[suspicious_sizeof] */ @@ -3206,6 +3209,8 @@ static int xlat_protocol_register(fr_dict_t const *dict) if (tp_encode) { snprintf(buffer, sizeof(buffer), "%s.encode", name); + if (xlat_func_find(buffer, -1)) return 1; + if (unlikely((xlat = xlat_func_register(NULL, buffer, protocol_encode_xlat, FR_TYPE_OCTETS)) == NULL)) return -1; xlat_func_args_set(xlat, protocol_encode_xlat_args); /* coverity[suspicious_sizeof] */ @@ -3216,7 +3221,9 @@ static int xlat_protocol_register(fr_dict_t const *dict) return 0; } -static int xlat_protocol_init(void) +/** Register xlats for any loaded dictionaries + */ +int xlat_protocols_register(void) { fr_dict_t *dict; fr_dict_global_ctx_iter_t iter;