From 51eef5e2a6e341b05e2e2df63bcde94f01897c47 Mon Sep 17 00:00:00 2001 From: Jeffrey Townsend Date: Wed, 9 Jan 2019 03:02:21 +0000 Subject: [PATCH] Fix generic and module stubs. --- .../onlp/module/inc/onlp/platformi/generici.h | 67 +++++++++++ .../onlp/module/inc/onlp/platformi/modulei.h | 67 +++++++++++ .../any/onlp/src/onlp/module/src/generic.c | 106 ++++++++++++------ .../any/onlp/src/onlp/module/src/module.c | 105 +++++++++++------ .../module/src/generici.c | 41 +++++++ .../module/src/modulei.c | 41 +++++++ 6 files changed, 362 insertions(+), 65 deletions(-) create mode 100644 packages/base/any/onlp/src/onlp/module/inc/onlp/platformi/generici.h create mode 100644 packages/base/any/onlp/src/onlp/module/inc/onlp/platformi/modulei.h create mode 100644 packages/base/any/onlp/src/onlp_platform_defaults/module/src/generici.c create mode 100644 packages/base/any/onlp/src/onlp_platform_defaults/module/src/modulei.c diff --git a/packages/base/any/onlp/src/onlp/module/inc/onlp/platformi/generici.h b/packages/base/any/onlp/src/onlp/module/inc/onlp/platformi/generici.h new file mode 100644 index 00000000..478a86aa --- /dev/null +++ b/packages/base/any/onlp/src/onlp/module/inc/onlp/platformi/generici.h @@ -0,0 +1,67 @@ +/************************************************************ + * + * + * Copyright 2014, 2015 Big Switch Networks, Inc. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ********************************************************//** + * + * @file + * @brief Generic OID Platform Implementation. + * @addtogroup generici + * @{ + * + ***********************************************************/ +#ifndef __ONLP_GENERICI_H__ +#define __ONLP_GENERICI_H__ + +#include + +/** + * @brief Software initialization of the Generic module. + */ +int onlp_generici_sw_init(void); + +/** + * @brief Hardware initialization of the Generic module. + * @param flags The hardware initialization flags. + */ +int onlp_generici_hw_init(uint32_t flags); + +/** + * @brief Deinitialize the generic software module. + * @note The primary purpose of this API is to properly + * deallocate any resources used by the module in order + * faciliate detection of real resouce leaks. + */ +int onlp_generici_sw_denit(void); + +/** + * @brief Retrieve the generic's oid header. + * @param id The generic oid. + * @param[out] rv Receives the header. + */ +int onlp_generici_hdr_get(onlp_oid_id_t id, onlp_oid_hdr_t* rv); + +/** + * @brief Get the information for the given generic OID. + * @param id The Generic OID + * @param[out] rv Receives the generic information. + */ +int onlp_generici_info_get(onlp_oid_id_t id, onlp_generic_info_t* rv); + +#endif /* __ONLP_GENERICI_H__ */ +/* @} */ diff --git a/packages/base/any/onlp/src/onlp/module/inc/onlp/platformi/modulei.h b/packages/base/any/onlp/src/onlp/module/inc/onlp/platformi/modulei.h new file mode 100644 index 00000000..3b9960ed --- /dev/null +++ b/packages/base/any/onlp/src/onlp/module/inc/onlp/platformi/modulei.h @@ -0,0 +1,67 @@ +/************************************************************ + * + * + * Copyright 2014, 2015 Big Switch Networks, Inc. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ********************************************************//** + * + * @file + * @brief Module OID Platform Implementation. + * @addtogroup modulei + * @{ + * + ***********************************************************/ +#ifndef __ONLP_MODULEI_H__ +#define __ONLP_MODULEI_H__ + +#include + +/** + * @brief Software initialization of the Module module. + */ +int onlp_modulei_sw_init(void); + +/** + * @brief Hardware initialization of the Module module. + * @param flags The hardware initialization flags. + */ +int onlp_modulei_hw_init(uint32_t flags); + +/** + * @brief Deinitialize the module software module. + * @note The primary purpose of this API is to properly + * deallocate any resources used by the module in order + * faciliate detection of real resouce leaks. + */ +int onlp_modulei_sw_denit(void); + +/** + * @brief Retrieve the module's oid header. + * @param id The module oid. + * @param[out] rv Receives the header. + */ +int onlp_modulei_hdr_get(onlp_oid_id_t id, onlp_oid_hdr_t* rv); + +/** + * @brief Get the information for the given module OID. + * @param id The Module OID + * @param[out] rv Receives the module information. + */ +int onlp_modulei_info_get(onlp_oid_id_t id, onlp_module_info_t* rv); + +#endif /* __ONLP_MODULEI_H__ */ +/* @} */ diff --git a/packages/base/any/onlp/src/onlp/module/src/generic.c b/packages/base/any/onlp/src/onlp/module/src/generic.c index beaabe44..e9de65b4 100644 --- a/packages/base/any/onlp/src/onlp/module/src/generic.c +++ b/packages/base/any/onlp/src/onlp/module/src/generic.c @@ -1,49 +1,89 @@ #include +#include +#include "onlp_int.h" +#include "onlp_locks.h" +#include "onlp_log.h" + +static int +onlp_generic_sw_init_locked__(void) +{ + return onlp_generici_sw_init(); +} +ONLP_LOCKED_API0(onlp_generic_sw_init); + +static int +onlp_generic_hw_init_locked__(uint32_t flags) +{ + return onlp_generici_hw_init(flags); +} +ONLP_LOCKED_API1(onlp_generic_hw_init, uint32_t, flags); + + +static int +onlp_generic_sw_denit_locked__(void) +{ + return onlp_generici_sw_denit(); +} +ONLP_LOCKED_API0(onlp_generic_sw_denit); + +static int +onlp_generic_hdr_get_locked__(onlp_oid_t oid, onlp_oid_hdr_t* hdr) +{ + int rv; + onlp_oid_id_t id; + + ONLP_OID_GENERIC_VALIDATE_GET_ID(oid, id); + ONLP_PTR_VALIDATE_ZERO(hdr); + + rv = onlp_log_error(0, + onlp_generici_hdr_get(id, hdr), + "generici hdr get %{onlp_oid}", oid); + hdr->id = oid; + return rv; +} +ONLP_LOCKED_API2(onlp_generic_hdr_get, onlp_oid_t, oid, onlp_oid_hdr_t*, hdr) + +static int +onlp_generic_info_get_locked__(onlp_oid_t oid, onlp_generic_info_t* info) +{ + int rv; + onlp_oid_id_t id; + + ONLP_OID_GENERIC_VALIDATE_GET_ID(oid, id); + ONLP_PTR_VALIDATE_ZERO(info); + + rv = onlp_log_error(0, + onlp_generici_info_get(id, info), + "generici info get %{onlp_oid}", oid); + + info->hdr.id = oid; + return rv; +} +ONLP_LOCKED_API2(onlp_generic_info_get, onlp_oid_t, oid, onlp_generic_info_t*, info) int -onlp_generic_sw_init(void) +onlp_generic_info_to_user_json(onlp_generic_info_t* info, cJSON** cjp, uint32_t flags) { - return 0; + cJSON* object; + + onlp_info_to_user_json_create(&info->hdr, &object, flags); + return onlp_info_to_user_json_finish(&info->hdr, object, cjp, flags); } int -onlp_generic_hw_init(uint32_t flags) +onlp_generic_info_to_json(onlp_generic_info_t* info, cJSON** cjp, uint32_t flags) { - return 0; -} + cJSON* cj; -int -onlp_generic_sw_denit(void) -{ - return 0; -} - -int -onlp_generic_hdr_get(onlp_oid_t oid, onlp_oid_hdr_t* hdr) -{ - return ONLP_STATUS_E_UNSUPPORTED; -} - -int -onlp_generic_info_get(onlp_oid_t id, onlp_generic_info_t* info) -{ - return ONLP_STATUS_E_UNSUPPORTED; -} - -int -onlp_generic_info_to_user_json(onlp_generic_info_t* info, cJSON** rv, uint32_t flags) -{ - return 0; -} - -int -onlp_generic_info_to_json(onlp_generic_info_t* info, cJSON** rv, uint32_t flags) -{ - return 0; + ONLP_IF_ERROR_RETURN(onlp_info_to_json_create(&info->hdr, &cj, flags)); + return onlp_info_to_json_finish(&info->hdr, cj, cjp, flags); } int onlp_generic_info_from_json(cJSON* cj, onlp_generic_info_t* info) { + memset(info, 0, sizeof(*info)); + + ONLP_IF_ERROR_RETURN(onlp_oid_hdr_from_json(cj, &info->hdr)); return 0; } diff --git a/packages/base/any/onlp/src/onlp/module/src/module.c b/packages/base/any/onlp/src/onlp/module/src/module.c index 611801ef..e7e0e869 100644 --- a/packages/base/any/onlp/src/onlp/module/src/module.c +++ b/packages/base/any/onlp/src/onlp/module/src/module.c @@ -1,48 +1,89 @@ #include +#include +#include "onlp_int.h" +#include "onlp_locks.h" +#include "onlp_log.h" + +static int +onlp_module_sw_init_locked__(void) +{ + return onlp_modulei_sw_init(); +} +ONLP_LOCKED_API0(onlp_module_sw_init); + +static int +onlp_module_hw_init_locked__(uint32_t flags) +{ + return onlp_modulei_hw_init(flags); +} +ONLP_LOCKED_API1(onlp_module_hw_init, uint32_t, flags); + + +static int +onlp_module_sw_denit_locked__(void) +{ + return onlp_modulei_sw_denit(); +} +ONLP_LOCKED_API0(onlp_module_sw_denit); + +static int +onlp_module_hdr_get_locked__(onlp_oid_t oid, onlp_oid_hdr_t* hdr) +{ + int rv; + onlp_oid_id_t id; + + ONLP_OID_MODULE_VALIDATE_GET_ID(oid, id); + ONLP_PTR_VALIDATE_ZERO(hdr); + + rv = onlp_log_error(0, + onlp_modulei_hdr_get(id, hdr), + "modulei hdr get %{onlp_oid}", oid); + hdr->id = oid; + return rv; +} +ONLP_LOCKED_API2(onlp_module_hdr_get, onlp_oid_t, oid, onlp_oid_hdr_t*, hdr) + +static int +onlp_module_info_get_locked__(onlp_oid_t oid, onlp_module_info_t* info) +{ + int rv; + onlp_oid_id_t id; + + ONLP_OID_MODULE_VALIDATE_GET_ID(oid, id); + ONLP_PTR_VALIDATE_ZERO(info); + + rv = onlp_log_error(0, + onlp_modulei_info_get(id, info), + "modulei info get %{onlp_oid}", oid); + + info->hdr.id = oid; + return rv; +} +ONLP_LOCKED_API2(onlp_module_info_get, onlp_oid_t, oid, onlp_module_info_t*, info) int -onlp_module_sw_init(void) +onlp_module_info_to_user_json(onlp_module_info_t* info, cJSON** cjp, uint32_t flags) { - return 0; + cJSON* object; + + onlp_info_to_user_json_create(&info->hdr, &object, flags); + return onlp_info_to_user_json_finish(&info->hdr, object, cjp, flags); } int -onlp_module_hw_init(uint32_t flags) +onlp_module_info_to_json(onlp_module_info_t* info, cJSON** cjp, uint32_t flags) { - return 0; -} + cJSON* cj; -int -onlp_module_sw_denit(void) -{ - return 0; -} - -int -onlp_module_hdr_get(onlp_oid_t id, onlp_oid_hdr_t* hdr) -{ - return ONLP_STATUS_E_UNSUPPORTED; -} - -int -onlp_module_info_get(onlp_oid_t id, onlp_module_info_t* info) -{ - return ONLP_STATUS_E_UNSUPPORTED; -} - -int -onlp_module_info_to_user_json(onlp_module_info_t* info, cJSON** rv, uint32_t flags) -{ - return 0; -} -int -onlp_module_info_to_json(onlp_module_info_t* info, cJSON** rv, uint32_t flags) -{ - return 0; + ONLP_IF_ERROR_RETURN(onlp_info_to_json_create(&info->hdr, &cj, flags)); + return onlp_info_to_json_finish(&info->hdr, cj, cjp, flags); } int onlp_module_info_from_json(cJSON* cj, onlp_module_info_t* info) { + memset(info, 0, sizeof(*info)); + + ONLP_IF_ERROR_RETURN(onlp_oid_hdr_from_json(cj, &info->hdr)); return 0; } diff --git a/packages/base/any/onlp/src/onlp_platform_defaults/module/src/generici.c b/packages/base/any/onlp/src/onlp_platform_defaults/module/src/generici.c new file mode 100644 index 00000000..12fb5ffb --- /dev/null +++ b/packages/base/any/onlp/src/onlp_platform_defaults/module/src/generici.c @@ -0,0 +1,41 @@ +/************************************************************ + * + * + * Copyright 2014, 2015 Big Switch Networks, Inc. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * + ***********************************************************/ +#include +#include "onlp_platform_defaults_int.h" +#include "onlp_platform_defaults_log.h" + +__ONLP_DEFAULTI_IMPLEMENTATION_OPTIONAL(onlp_generici_sw_init(void)); +__ONLP_DEFAULTI_IMPLEMENTATION_OPTIONAL(onlp_generici_sw_denit(void)); +__ONLP_DEFAULTI_IMPLEMENTATION_OPTIONAL(onlp_generici_hw_init(uint32_t flags)); +__ONLP_DEFAULTI_IMPLEMENTATION(onlp_generici_hdr_get(onlp_oid_id_t id, onlp_oid_hdr_t* hdr)); + +/* + * There are no fields defined in the genericinfo structure. As a result + * we provide a default implementation which populates the OID header. + */ +int __ONLP_DEFAULTI +onlp_generici_info_get(onlp_oid_id_t id, onlp_generic_info_t* info) +{ + return onlp_generici_hdr_get(id, &info->hdr); +}; diff --git a/packages/base/any/onlp/src/onlp_platform_defaults/module/src/modulei.c b/packages/base/any/onlp/src/onlp_platform_defaults/module/src/modulei.c new file mode 100644 index 00000000..6446f26d --- /dev/null +++ b/packages/base/any/onlp/src/onlp_platform_defaults/module/src/modulei.c @@ -0,0 +1,41 @@ +/************************************************************ + * + * + * Copyright 2014, 2015 Big Switch Networks, Inc. + * + * Licensed under the Eclipse Public License, Version 1.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.eclipse.org/legal/epl-v10.html + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + * + * + ************************************************************ + * + * + ***********************************************************/ +#include +#include "onlp_platform_defaults_int.h" +#include "onlp_platform_defaults_log.h" + +__ONLP_DEFAULTI_IMPLEMENTATION_OPTIONAL(onlp_modulei_sw_init(void)); +__ONLP_DEFAULTI_IMPLEMENTATION_OPTIONAL(onlp_modulei_sw_denit(void)); +__ONLP_DEFAULTI_IMPLEMENTATION_OPTIONAL(onlp_modulei_hw_init(uint32_t flags)); +__ONLP_DEFAULTI_IMPLEMENTATION(onlp_modulei_hdr_get(onlp_oid_id_t id, onlp_oid_hdr_t* hdr)); + +/* + * There are no fields defined in the module info structure. As a result + * we provide a default implementation which populates the OID header. + */ +int __ONLP_DEFAULTI +onlp_modulei_info_get(onlp_oid_id_t id, onlp_module_info_t* info) +{ + return onlp_modulei_hdr_get(id, &info->hdr); +};