Fix generic and module stubs.

This commit is contained in:
Jeffrey Townsend
2019-01-09 03:02:21 +00:00
parent 92d1fbbbaf
commit 51eef5e2a6
6 changed files with 362 additions and 65 deletions

View File

@@ -0,0 +1,67 @@
/************************************************************
* <bsn.cl fy=2014 v=onl>
*
* 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.
*
* </bsn.cl>
********************************************************//**
*
* @file
* @brief Generic OID Platform Implementation.
* @addtogroup generici
* @{
*
***********************************************************/
#ifndef __ONLP_GENERICI_H__
#define __ONLP_GENERICI_H__
#include <onlp/generic.h>
/**
* @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__ */
/* @} */

View File

@@ -0,0 +1,67 @@
/************************************************************
* <bsn.cl fy=2014 v=onl>
*
* 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.
*
* </bsn.cl>
********************************************************//**
*
* @file
* @brief Module OID Platform Implementation.
* @addtogroup modulei
* @{
*
***********************************************************/
#ifndef __ONLP_MODULEI_H__
#define __ONLP_MODULEI_H__
#include <onlp/module.h>
/**
* @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__ */
/* @} */

View File

@@ -1,49 +1,89 @@
#include <onlp/generic.h>
#include <onlp/platformi/generici.h>
#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;
}

View File

@@ -1,48 +1,89 @@
#include <onlp/module.h>
#include <onlp/platformi/modulei.h>
#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;
}

View File

@@ -0,0 +1,41 @@
/************************************************************
* <bsn.cl fy=2014 v=onl>
*
* 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.
*
* </bsn.cl>
************************************************************
*
*
***********************************************************/
#include <onlp/platformi/generici.h>
#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);
};

View File

@@ -0,0 +1,41 @@
/************************************************************
* <bsn.cl fy=2014 v=onl>
*
* 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.
*
* </bsn.cl>
************************************************************
*
*
***********************************************************/
#include <onlp/platformi/modulei.h>
#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);
};