ONLP
Open Network Linux Platform APIs
Data Structures | Macros | Typedefs | Enumerations | Functions | Variables
oids.h File Reference

Object Identifiers. More...

#include <onlp/onlp_config.h>
#include <stdint.h>
#include <AIM/aim_pvs.h>
#include <IOF/iof.h>
#include <BigList/biglist.h>
#include <cjson/cJSON.h>

Go to the source code of this file.

Data Structures

struct  onlp_oid_hdr_s
 

Macros

#define ONLP_OID_TYPE_GET(_id)   ( ( (_id) >> 24) )
 
#define ONLP_OID_TYPE_CREATE(_type, _id)   ( ( (_type) << 24) | (_id))
 
#define ONLP_OID_IS_TYPE(_type, _id)   (ONLP_OID_TYPE_GET((_id)) == _type)
 
#define ONLP_OID_ID_GET(_id)   (_id & 0xFFFFFF)
 
#define ONLP_OID_TYPE_VALIDATE(_type, _oid)
 
#define ONLP_OID_TYPE_VALIDATE_NR(_type, _oid)
 
#define ONLP_OID_TYPE_VALIDATE_GET_ID(_type, _oid, _id)
 
#define ONLP_OID_TYPE_VALIDATE_GET_ID_NR(_type, _oid, _id)
 
#define ONLP_OID_IS_TYPE_FLAGS(_flags, _id)   ((_flags & (1 << ONLP_OID_TYPE_GET(_id))))
 
#define ONLP_OID_IS_TYPE_FLAGSZ(_flags, _id)   ((_flags == 0) || ONLP_OID_IS_TYPE_FLAGS(_flags, _id))
 
#define ONLP_CHASSIS_ID_CREATE(_id)   ONLP_OID_TYPE_CREATE(ONLP_OID_TYPE_CHASSIS, _id)
 
#define ONLP_THERMAL_ID_CREATE(_id)   ONLP_OID_TYPE_CREATE(ONLP_OID_TYPE_THERMAL, _id)
 
#define ONLP_FAN_ID_CREATE(_id)   ONLP_OID_TYPE_CREATE(ONLP_OID_TYPE_FAN, _id)
 
#define ONLP_PSU_ID_CREATE(_id)   ONLP_OID_TYPE_CREATE(ONLP_OID_TYPE_PSU, _id)
 
#define ONLP_LED_ID_CREATE(_id)   ONLP_OID_TYPE_CREATE(ONLP_OID_TYPE_LED, _id)
 
#define ONLP_SFP_ID_CREATE(_id)   ONLP_OID_TYPE_CREATE(ONLP_OID_TYPE_SFP, _id)
 
#define ONLP_MODULE_ID_CREATE(_id)   ONLP_OID_TYPE_CREATE(ONLP_OID_TYPE_MODULE, _id)
 
#define ONLP_GENERIC_ID_CREATE(_id)   ONLP_OID_TYPE_CREATE(ONLP_OID_TYPE_GENERIC, _id)
 
#define ONLP_OID_IS_CHASSIS(_id)   ONLP_OID_IS_TYPE(ONLP_OID_TYPE_CHASSIS, _id)
 
#define ONLP_OID_CHASSIS_VALIDATE(_id)   ONLP_OID_TYPE_VALIDATE(ONLP_OID_TYPE_CHASSIS, _id)
 
#define ONLP_OID_CHASSIS_VALIDATE_NR(_id)   ONLP_OID_TYPE_VALIDATE_NR(ONLP_OID_TYPE_CHASSIS, _id)
 
#define ONLP_OID_IS_THERMAL(_id)   ONLP_OID_IS_TYPE(ONLP_OID_TYPE_THERMAL, _id)
 
#define ONLP_OID_THERMAL_VALIDATE(_id)   ONLP_OID_TYPE_VALIDATE(ONLP_OID_TYPE_THERMAL, _id)
 
#define ONLP_OID_THERMAL_VALIDATE_NR(_id)   ONLP_OID_TYPE_VALIDATE_NR(ONLP_OID_TYPE_THERMAL, _id)
 
#define ONLP_OID_THERMAL_VALIDATE_GET_ID(_oid, _id)   ONLP_OID_TYPE_VALIDATE_GET_ID(ONLP_OID_TYPE_THERMAL, _oid, _id)
 
#define ONLP_OID_THERMAL_VALIDATE_GET_ID_NR(_oid, _id)   ONLP_OID_TYPE_VALIDATE_GET_ID_NR(ONLP_OID_TYPE_THERMAL, _oid, _id)
 
#define ONLP_OID_IS_FAN(_id)   ONLP_OID_IS_TYPE(ONLP_OID_TYPE_FAN, _id)
 
#define ONLP_OID_FAN_VALIDATE(_id)   ONLP_OID_TYPE_VALIDATE(ONLP_OID_TYPE_FAN, _id)
 
#define ONLP_OID_FAN_VALIDATE_NR(_id)   ONLP_OID_TYPE_VALIDATE_NR(ONLP_OID_TYPE_FAN, _id)
 
#define ONLP_OID_FAN_VALIDATE_GET_ID(_oid, _id)   ONLP_OID_TYPE_VALIDATE_GET_ID(ONLP_OID_TYPE_FAN, _oid, _id)
 
#define ONLP_OID_FAN_VALIDATE_GET_ID_NR(_oid, _id)   ONLP_OID_TYPE_VALIDATE_GET_ID_NR(ONLP_OID_TYPE_FAN, _oid, _id)
 
#define ONLP_OID_IS_PSU(_id)   ONLP_OID_IS_TYPE(ONLP_OID_TYPE_PSU, _id)
 
#define ONLP_OID_PSU_VALIDATE(_id)   ONLP_OID_TYPE_VALIDATE(ONLP_OID_TYPE_PSU, _id)
 
#define ONLP_OID_PSU_VALIDATE_NR(_id)   ONLP_OID_TYPE_VALIDATE_NR(ONLP_OID_TYPE_PSU, _id)
 
#define ONLP_OID_PSU_VALIDATE_GET_ID(_oid, _id)   ONLP_OID_TYPE_VALIDATE_GET_ID(ONLP_OID_TYPE_PSU, _oid, _id)
 
#define ONLP_OID_PSU_VALIDATE_GET_ID_NR(_oid, _id)   ONLP_OID_TYPE_VALIDATE_GET_ID_NR(ONLP_OID_TYPE_PSU, _oid, _id)
 
#define ONLP_OID_IS_LED(_id)   ONLP_OID_IS_TYPE(ONLP_OID_TYPE_LED, _id)
 
#define ONLP_OID_LED_VALIDATE(_id)   ONLP_OID_TYPE_VALIDATE(ONLP_OID_TYPE_LED, _id)
 
#define ONLP_OID_LED_VALIDATE_NR(_id)   ONLP_OID_TYPE_VALIDATE_NR(ONLP_OID_TYPE_LED, _id)
 
#define ONLP_OID_LED_VALIDATE_GET_ID(_oid, _id)   ONLP_OID_TYPE_VALIDATE_GET_ID(ONLP_OID_TYPE_LED, _oid, _id)
 
#define ONLP_OID_LED_VALIDATE_GET_ID_NR(_oid, _id)   ONLP_OID_TYPE_VALIDATE_GET_ID_NR(ONLP_OID_TYPE_LED, _oid, _id)
 
#define ONLP_OID_IS_SFP(_id)   ONLP_OID_IS_TYPE(ONLP_OID_TYPE_SFP, _id)
 
#define ONLP_OID_SFP_VALIDATE(_id)   ONLP_OID_TYPE_VALIDATE(ONLP_OID_TYPE_SFP, _id)
 
#define ONLP_OID_SFP_VALIDATE_NR(_id)   ONLP_OID_TYPE_VALIDATE_NR(ONLP_OID_TYPE_SFP, _id)
 
#define ONLP_OID_SFP_VALIDATE_GET_ID(_oid, _id)   ONLP_OID_TYPE_VALIDATE_GET_ID(ONLP_OID_TYPE_SFP, _oid, _id)
 
#define ONLP_OID_SFP_VALIDATE_GET_ID_NR(_oid, _id)   ONLP_OID_TYPE_VALIDATE_GET_ID_NR(ONLP_OID_TYPE_SFP, _oid, _id)
 
#define ONLP_OID_IS_MODULE(_id)   ONLP_OID_IS_TYPE(ONLP_OID_TYPE_MODULE, _id)
 
#define ONLP_OID_MODULE_VALIDATE(_id)   ONLP_OID_TYPE_VALIDATE(ONLP_OID_TYPE_MODULE, _id)
 
#define ONLP_OID_MODULE_VALIDATE_NR(_id)   ONLP_OID_TYPE_VALIDATE_NR(ONLP_OID_TYPE_MODULE, _id)
 
#define ONLP_OID_MODULE_VALIDATE_GET_ID(_oid, _id)   ONLP_OID_TYPE_VALIDATE_GET_ID(ONLP_OID_TYPE_MODULE, _oid, _id)
 
#define ONLP_OID_MODULE_VALIDATE_GET_ID_NR(_oid, _id)   ONLP_OID_TYPE_VALIDATE_GET_ID_NR(ONLP_OID_TYPE_MODULE, _oid, _id)
 
#define ONLP_OID_IS_GENERIC(_id)   ONLP_OID_IS_TYPE(ONLP_OID_TYPE_GENERIC, _id)
 
#define ONLP_OID_GENERIC_VALIDATE(_id)   ONLP_OID_TYPE_VALIDATE(ONLP_OID_TYPE_GENERIC, _id)
 
#define ONLP_OID_GENERIC_VALIDATE_NR(_id)   ONLP_OID_TYPE_VALIDATE_NR(ONLP_OID_TYPE_GENERIC, _id)
 
#define ONLP_OID_GENERIC_VALIDATE_GET_ID(_oid, _id)   ONLP_OID_TYPE_VALIDATE_GET_ID(ONLP_OID_TYPE_GENERIC, _oid, _id)
 
#define ONLP_OID_GENERIC_VALIDATE_GET_ID_NR(_oid, _id)   ONLP_OID_TYPE_VALIDATE_GET_ID_NR(ONLP_OID_TYPE_GENERIC, _oid, _id)
 
#define ONLP_OID_ID_VALIDATE_RANGE(_id, _min, _max)   ( (_id) >= (_min) && (_id) <= (_max)) ? ONLP_STATUS_OK : ONLP_STATUS_E_INVALID
 
#define ONLP_OID_CHASSIS   ONLP_OID_TYPE_CREATE(ONLP_OID_TYPE_CHASSIS, 1)
 
#define ONLP_OID_DESC_SIZE   128
 
#define ONLP_OID_TABLE_SIZE   256
 
#define ONLP_OID_TABLE_SIZE_BYTES   (sizeof(onlp_oid_t)*ONLP_OID_TABLE_SIZE)
 
#define ONLP_OID_TABLE_COPY(_dst, _src)   memcpy(_dst, _src, ONLP_OID_TABLE_SIZE_BYTES)
 
#define ONLP_OID_TABLE_CLEAR(_table)   memset(_table, 0, ONLP_OID_TABLE_SIZE_BYTES)
 
#define ONLP_OID_THERMAL_ENTRY(_id, _desc, _parent_type, _parent_id)   { ONLP_THERMAL_ID_CREATE(_id), _desc, ONLP_OID_TYPE_CREATE(_parent_type, _parent_id) }
 
#define ONLP_OID_STATUS_FLAGS_GET(_ptr)   (((onlp_oid_hdr_t*)_ptr)->status)
 
#define ONLP_OID_STATUS_FLAGS_CLR(_ptr)   ONLP_OID_STATUS_FLAGS_GET(_ptr) = 0
 
#define ONLP_OID_STATUS_FLAG_GET_VALUE(_ptr, _name)   AIM_FLAG_GET_VALUE(ONLP_OID_STATUS_FLAGS_GET(_ptr), ONLP_OID_STATUS_FLAG_##_name)
 
#define ONLP_OID_STATUS_FLAG_SET_VALUE(_ptr, _name, _value)   AIM_FLAG_SET_VALUE(ONLP_OID_STATUS_FLAGS_GET(_ptr), ONLP_OID_STATUS_FLAG_##_name, _value)
 
#define ONLP_OID_STATUS_FLAG_SET(_ptr, _name)   AIM_FLAG_SET(ONLP_OID_STATUS_FLAGS_GET(_ptr), ONLP_OID_STATUS_FLAG_##_name)
 
#define ONLP_OID_STATUS_FLAG_CLR(_ptr, _name)   AIM_FLAG_CLR(ONLP_OID_STATUS_FLAGS_GET(_ptr), ONLP_OID_STATUS_FLAG_##_name)
 
#define ONLP_OID_STATUS_FLAG_IS_SET(_ptr, _name)   AIM_FLAG_IS_SET(ONLP_OID_STATUS_FLAGS_GET(_ptr), ONLP_OID_STATUS_FLAG_##_name)
 
#define ONLP_OID_STATUS_FLAG_NOT_SET(_ptr, _name)   AIM_FLAG_NOT_SET(ONLP_OID_STATUS_FLAGS_GET(_ptr), ONLP_OID_STATUS_FLAG_##_name)
 
#define ONLP_OID_PRESENT(_ptr)   ONLP_OID_STATUS_FLAG_IS_SET(_ptr, PRESENT)
 
#define ONLP_OID_FAILED(_ptr)   ONLP_OID_STATUS_FLAG_IS_SET(_ptr, FAILED)
 
#define ONLP_OID_TABLE_ITER_EXPR(_table, _oidp, _expr)
 Iterate over all OIDS in the given table that match the given expression. More...
 
#define ONLP_OID_TABLE_ITER(_table, _oidp)   ONLP_OID_TABLE_ITER_EXPR(_table, _oidp, 1)
 Iterate over all OIDs in the given table. More...
 
#define ONLP_OID_TABLE_ITER_TYPE(_table, _oidp, _type)   ONLP_OID_TABLE_ITER_EXPR(_table, _oidp, ONLP_OID_IS_TYPE(ONLP_OID_TYPE_##_type, *_oidp))
 Iterate over all OIDs in the given table of the given type. More...
 
#define ONLP_OID_JSON_FLAG_VALID(_e)   (onlp_oid_json_flag_valid((_e)))
 
#define ONLP_OID_STATUS_FLAG_VALID(_e)   (onlp_oid_status_flag_valid((_e)))
 
#define ONLP_OID_TYPE_VALID(_e)   (onlp_oid_type_valid((_e)))
 
#define ONLP_OID_TYPE_FLAG_VALID(_e)   (onlp_oid_type_flag_valid((_e)))
 

Typedefs

typedef uint32_t onlp_oid_t
 
typedef uint32_t onlp_oid_id_t
 
typedef enum onlp_oid_json_flag_e onlp_oid_json_flag_t
 
typedef enum onlp_oid_status_flag_e onlp_oid_status_flag_t
 
typedef enum onlp_oid_type_e onlp_oid_type_t
 
typedef enum onlp_oid_type_flag_e onlp_oid_type_flag_t
 
typedef uint32_t onlp_oid_type_flags_t
 
typedef uint32_t onlp_oid_status_flags_t
 
typedef char onlp_oid_desc_t[ONLP_OID_DESC_SIZE]
 
typedef onlp_oid_t onlp_oid_table_t[ONLP_OID_TABLE_SIZE]
 
typedef struct onlp_oid_hdr_s onlp_oid_hdr_t
 
typedef int(* onlp_oid_iterate_f) (onlp_oid_t oid, void *cookie)
 

Enumerations

enum  onlp_oid_json_flag_e {
  ONLP_OID_JSON_FLAG_RECURSIVE = (1 << 0),
  ONLP_OID_JSON_FLAG_UNSUPPORTED_FIELDS = (1 << 1),
  ONLP_OID_JSON_FLAG_TO_USER_JSON = (1 << 2)
}
 
enum  onlp_oid_status_flag_e {
  ONLP_OID_STATUS_FLAG_PRESENT = (1 << 0),
  ONLP_OID_STATUS_FLAG_FAILED = (1 << 1),
  ONLP_OID_STATUS_FLAG_OPERATIONAL = (1 << 2),
  ONLP_OID_STATUS_FLAG_UNPLUGGED = (1 << 3)
}
 
enum  onlp_oid_type_e {
  ONLP_OID_TYPE_CHASSIS = 1,
  ONLP_OID_TYPE_MODULE = 2,
  ONLP_OID_TYPE_THERMAL = 3,
  ONLP_OID_TYPE_FAN = 4,
  ONLP_OID_TYPE_PSU = 5,
  ONLP_OID_TYPE_LED = 6,
  ONLP_OID_TYPE_SFP = 7,
  ONLP_OID_TYPE_GENERIC = 8
}
 
enum  onlp_oid_type_flag_e {
  ONLP_OID_TYPE_FLAG_CHASSIS = (1 << 1),
  ONLP_OID_TYPE_FLAG_MODULE = (1 << 2),
  ONLP_OID_TYPE_FLAG_THERMAL = (1 << 3),
  ONLP_OID_TYPE_FLAG_FAN = (1 << 4),
  ONLP_OID_TYPE_FLAG_PSU = (1 << 5),
  ONLP_OID_TYPE_FLAG_LED = (1 << 6),
  ONLP_OID_TYPE_FLAG_SFP = (1 << 7),
  ONLP_OID_TYPE_FLAG_GENERIC = (1 << 8)
}
 

Functions

int onlp_oid_hdr_get (onlp_oid_t oid, onlp_oid_hdr_t *hdr)
 Get the OID header for a given OID. More...
 
int onlp_oid_info_get (onlp_oid_t oid, onlp_oid_hdr_t **info)
 Get the information structure for a given OID. More...
 
int onlp_oid_iterate (onlp_oid_t root, onlp_oid_type_flags_t types, onlp_oid_iterate_f itf, void *cookie)
 Iterate over all platform OIDs. More...
 
int onlp_oid_info_get_all (onlp_oid_t root, onlp_oid_type_flags_t types, uint32_t flags, biglist_t **list)
 Iterate over all given OID types and return their info structures. More...
 
int onlp_oid_hdr_get_all (onlp_oid_t root, onlp_oid_type_flags_t types, uint32_t flags, biglist_t **list)
 Iterate over all given OID types and return their hdr structures. More...
 
int onlp_oid_get_all_free (biglist_t *list)
 Free a list returned by onlp_oid_info_get_all() or onlp_oid_hdr_get_all() More...
 
int onlp_oid_is_present (onlp_oid_t *oid)
 Return whether an OID is present or not.
 
int onlp_oid_to_str (onlp_oid_t oid, char *rstr)
 
int onlp_oid_to_user_str (onlp_oid_t oid, char *rstr)
 
int onlp_oid_from_str (char *str, onlp_oid_t *roid)
 String Represenation -> OID.
 
int onlp_oid_table_to_json (onlp_oid_table_t table, cJSON **cjp)
 OID Table -> JSON. More...
 
int onlp_oid_table_from_json (cJSON *cj, onlp_oid_table_t table)
 JSON -> OID Table. More...
 
int onlp_oid_hdr_to_json (onlp_oid_hdr_t *hdr, cJSON **cj, uint32_t flags)
 OID Header -> JSON. More...
 
int onlp_oid_hdr_from_json (cJSON *cj, onlp_oid_hdr_t *hdr)
 JSON -> OID Header. More...
 
int onlp_oid_info_to_json (onlp_oid_hdr_t *info, cJSON **cj, uint32_t flags)
 OID Info Structure -> JSON. More...
 
int onlp_oid_to_user_json (onlp_oid_t oid, cJSON **rv, uint32_t flags)
 OID -> JSON. More...
 
int onlp_oid_to_json (onlp_oid_t oid, cJSON **rv, uint32_t flags)
 OID -> User JSON. More...
 
int onlp_oid_from_json (cJSON *cj, onlp_oid_hdr_t **hdr, biglist_t **all, uint32_t flags)
 JSON -> OID Information structures. More...
 
int onlp_oid_json_verify (onlp_oid_t oid)
 
const char * onlp_oid_json_flag_name (onlp_oid_json_flag_t e)
 
int onlp_oid_json_flag_value (const char *str, onlp_oid_json_flag_t *e, int substr)
 
const char * onlp_oid_json_flag_desc (onlp_oid_json_flag_t e)
 
int onlp_oid_json_flag_valid (onlp_oid_json_flag_t e)
 
const char * onlp_oid_status_flag_name (onlp_oid_status_flag_t e)
 
int onlp_oid_status_flag_value (const char *str, onlp_oid_status_flag_t *e, int substr)
 
const char * onlp_oid_status_flag_desc (onlp_oid_status_flag_t e)
 
int onlp_oid_status_flag_valid (onlp_oid_status_flag_t e)
 
const char * onlp_oid_type_name (onlp_oid_type_t e)
 
int onlp_oid_type_value (const char *str, onlp_oid_type_t *e, int substr)
 
const char * onlp_oid_type_desc (onlp_oid_type_t e)
 
int onlp_oid_type_valid (onlp_oid_type_t e)
 
const char * onlp_oid_type_flag_name (onlp_oid_type_flag_t e)
 
int onlp_oid_type_flag_value (const char *str, onlp_oid_type_flag_t *e, int substr)
 
const char * onlp_oid_type_flag_desc (onlp_oid_type_flag_t e)
 
int onlp_oid_type_flag_valid (onlp_oid_type_flag_t e)
 

Variables

aim_map_si_t onlp_oid_json_flag_map []
 
aim_map_si_t onlp_oid_json_flag_desc_map []
 
aim_map_si_t onlp_oid_status_flag_map []
 
aim_map_si_t onlp_oid_status_flag_desc_map []
 
aim_map_si_t onlp_oid_type_map []
 
aim_map_si_t onlp_oid_type_desc_map []
 
aim_map_si_t onlp_oid_type_flag_map []
 
aim_map_si_t onlp_oid_type_flag_desc_map []
 

Detailed Description

Object Identifiers.