diff --git a/common/rdm/ResponderHelper.cpp b/common/rdm/ResponderHelper.cpp index 73edd3fb7..33930e7c1 100644 --- a/common/rdm/ResponderHelper.cpp +++ b/common/rdm/ResponderHelper.cpp @@ -1132,7 +1132,7 @@ RDMResponse *ResponderHelper::GetIFCInterfaceFixedLabel( } Interface interface; - if (!FindInterface(network_manager, &interface, index)) { + if (!FindIFCInterface(network_manager, &interface, index)) { return NackWithReason(request, NR_DATA_OUT_OF_RANGE); } @@ -1174,7 +1174,7 @@ RDMResponse *ResponderHelper::GetIFCInterfaceType( } Interface interface; - if (!FindInterface(network_manager, &interface, index)) { + if (!FindIFCInterface(network_manager, &interface, index)) { return NackWithReason(request, NR_DATA_OUT_OF_RANGE); } @@ -1212,7 +1212,7 @@ RDMResponse *ResponderHelper::GetIFCIPV4DNS( // TODO(Peter): For now we always return a common set of DNS servers as long // as any valid interface is supplied Interface interface; - if (!FindInterface(network_manager, &interface, index)) { + if (!FindIFCInterface(network_manager, &interface, index)) { // TODO(Peter): Should this be NR_INTERFACE_UNAVAILABLE? return NackWithReason(request, NR_DATA_OUT_OF_RANGE); } @@ -1270,7 +1270,7 @@ RDMResponse *ResponderHelper::GetIFCDNSLabel( // TODO(Peter): For now we always return the one hostname as long as any // valid interface is supplied Interface interface; - if (!FindInterface(network_manager, &interface, index)) { + if (!FindIFCInterface(network_manager, &interface, index)) { // TODO(Peter): Should this be NR_INTERFACE_UNAVAILABLE? return NackWithReason(request, NR_DATA_OUT_OF_RANGE); } @@ -1318,7 +1318,7 @@ RDMResponse *ResponderHelper::GetIFCDNSDomain( // TODO(Peter): For now we always return the one domain name as long as any // valid interface is supplied Interface interface; - if (!FindInterface(network_manager, &interface, index)) { + if (!FindIFCInterface(network_manager, &interface, index)) { // TODO(Peter): Should this be NR_INTERFACE_UNAVAILABLE? return NackWithReason(request, NR_DATA_OUT_OF_RANGE); } @@ -1510,6 +1510,20 @@ bool ResponderHelper::IsInterfaceIndexValidInterface(Interface interface) { return IsInterfaceIndexValid(interface.index); } +bool ResponderHelper::FindIFCInterface( + const NetworkManagerInterface *network_manager, + Interface *interface, uint32_t index) { + if (!IsIFCInterfaceIndexValid(index)) { + // Invalid index + return false; + } + + InterfacePicker::Options options; + options.specific_only = true; + return network_manager->GetInterfacePicker()->ChooseInterface( + interface, index, options); +} + bool ResponderHelper::IsIFCInterfaceIndexValid(uint32_t index) { return (index >= MIN_RDM_IFC_INTERFACE_INDEX && index <= MAX_RDM_IFC_INTERFACE_INDEX); diff --git a/include/ola/rdm/ResponderHelper.h b/include/ola/rdm/ResponderHelper.h index b67d2b473..8b8567b08 100644 --- a/include/ola/rdm/ResponderHelper.h +++ b/include/ola/rdm/ResponderHelper.h @@ -304,6 +304,10 @@ class ResponderHelper { uint32_t index); static bool IsInterfaceIndexValid(uint32_t index); static bool IsInterfaceIndexValidInterface(ola::network::Interface interface); + static bool FindIFCInterface( + const NetworkManagerInterface *network_manager, + ola::network::Interface *interface, + uint32_t index); static bool IsIFCInterfaceIndexValid(uint32_t index); static bool IsIFCInterfaceIndexValidInterface(ola::network::Interface interface); };