TR181-XPON  1.4.0
TR-181 PON manager.
dm_info.h File Reference
#include <stdbool.h>
#include <stdint.h>

Go to the source code of this file.

Data Structures

struct  _param_info
 
struct  _object_info
 

Macros

#define ENABLE_PARAM   "Enable"
 
#define NAME_PARAM   "Name"
 
#define NAME_PARAM_LEN   4
 

Typedefs

typedef enum _xpon_object_id object_id_t
 
typedef struct _param_info param_info_t
 
typedef struct _object_info object_info_t
 

Enumerations

enum  _xpon_object_id {
  obj_id_onu = 0 , obj_id_software_image , obj_id_ethernet_uni , obj_id_ani ,
  obj_id_gem_port , obj_id_transceiver , obj_id_ani_tc_onu_activation , obj_id_ani_tc_authentication ,
  obj_id_ani_tc_performance_thresholds , obj_id_ani_tc_alarms , obj_id_nbr , obj_id_unknown = obj_id_nbr
}
 

Functions

bool dm_info_init (void)
 
object_id_t dm_get_object_id (const char *path)
 
const object_info_tdm_get_object_info (object_id_t id)
 
bool dm_get_object_param_info (object_id_t id, const param_info_t **param_info, uint32_t *size)
 

Detailed Description

Info related to the TR-181 XPON DM known at compile time.

Definition in file dm_info.h.

Macro Definition Documentation

◆ ENABLE_PARAM

#define ENABLE_PARAM   "Enable"

Definition at line 74 of file dm_info.h.

◆ NAME_PARAM

#define NAME_PARAM   "Name"

Definition at line 76 of file dm_info.h.

◆ NAME_PARAM_LEN

#define NAME_PARAM_LEN   4

Definition at line 77 of file dm_info.h.

Typedef Documentation

◆ object_id_t

◆ object_info_t

typedef struct _object_info object_info_t

Info which is known at compile time about an object in the XPON DM.

  • id: unique ID identifying an object in the DM
  • name: symbolic name for 'id'. Mainly intended for log messages. E.g., "SoftwareImage".
  • generic_path: object path with all instance indexes replaced by 'x', e.g., "XPON.ONU.x.SoftwareImage"
  • key_name: the name of the parameter which is the unique key of the template object. Only applicable for template objects.
  • key_max_value: if the key referred to by 'key_name' is an uint32, this field indicates its max value.
  • singletons: string of comma-separated strings identifying the children which are singletons.
  • templates: string of comma-separated strings identifying the children which are templates.
  • params: pointer to array with info about the params of this object.
  • n_params: number of params in the array pointed to by 'params'
  • has_rw_enable: true if the object has a read-write Enable parameter. The code only looks at this field when creating a new instance of a template object.

◆ param_info_t

typedef struct _param_info param_info_t

Enumeration Type Documentation

◆ _xpon_object_id

Enumerator
obj_id_onu 
obj_id_software_image 
obj_id_ethernet_uni 
obj_id_ani 
obj_id_gem_port 
obj_id_transceiver 
obj_id_ani_tc_onu_activation 
obj_id_ani_tc_authentication 
obj_id_ani_tc_performance_thresholds 
obj_id_ani_tc_alarms 
obj_id_nbr 
obj_id_unknown 

Definition at line 79 of file dm_info.h.

79  {
80  obj_id_onu = 0,
83  obj_id_ani,
90  obj_id_nbr,
92 } object_id_t;
enum _xpon_object_id object_id_t
@ obj_id_ani
Definition: dm_info.h:83
@ obj_id_nbr
Definition: dm_info.h:90
@ obj_id_gem_port
Definition: dm_info.h:84
@ obj_id_onu
Definition: dm_info.h:80
@ obj_id_ani_tc_authentication
Definition: dm_info.h:87
@ obj_id_ethernet_uni
Definition: dm_info.h:82
@ obj_id_ani_tc_alarms
Definition: dm_info.h:89
@ obj_id_software_image
Definition: dm_info.h:81
@ obj_id_unknown
Definition: dm_info.h:91
@ obj_id_ani_tc_performance_thresholds
Definition: dm_info.h:88
@ obj_id_transceiver
Definition: dm_info.h:85
@ obj_id_ani_tc_onu_activation
Definition: dm_info.h:86

Function Documentation

◆ dm_get_object_id()

object_id_t dm_get_object_id ( const char *  path)

Return the ID of an object.

Parameters
[in]pathobject path, e.g., "XPON.ONU.1.SoftwareImage".

Example: if path is "XPON.ONU.1.SoftwareImage", the function returns obj_id_software_image

Returns
one of the value of object_id_t smaller than obj_id_nbr upon success, else obj_id_unknown

Definition at line 380 of file dm_info.c.

380  {
381 
383 
384  amxc_string_t generic_path_str;
385  amxc_string_init(&generic_path_str, 0);
386 
387  if(!dm_convert_to_generic_path(path, &generic_path_str)) {
388  goto exit;
389  }
390 
391  const char* const generic_path = amxc_string_get(&generic_path_str, 0);
392  const size_t generic_path_len = strlen(generic_path);
393 
394  uint32_t i;
395  size_t len;
396  for(i = 0; i < obj_id_nbr; ++i) {
397  len = strlen(OBJECT_INFO[i].generic_path);
398  if((generic_path_len == len) &&
399  (strncmp(generic_path, OBJECT_INFO[i].generic_path, len) == 0)) {
400  id = OBJECT_INFO[i].id;
401  break;
402  }
403  }
404 
405 exit:
406  amxc_string_clean(&generic_path_str);
407  return id;
408 }
static bool dm_convert_to_generic_path(const char *path, amxc_string_t *generic_path)
Definition: dm_info.c:320
const object_info_t OBJECT_INFO[obj_id_nbr]
Definition: dm_info.c:171
object_id_t id
Definition: dm_info.h:123
Here is the call graph for this function:
Here is the caller graph for this function:

◆ dm_get_object_info()

const object_info_t* dm_get_object_info ( object_id_t  id)

Definition at line 410 of file dm_info.c.

410  {
411  if(id < obj_id_nbr) {
412  return &OBJECT_INFO[id];
413  }
414 
415  SAH_TRACEZ_ERROR(ME, "Invalid id [%d]", id);
416  return NULL;
417 }
#define ME
Definition: xpon_trace.h:78
Here is the caller graph for this function:

◆ dm_get_object_param_info()

bool dm_get_object_param_info ( object_id_t  id,
const param_info_t **  param_info,
uint32_t *  size 
)

Return info about the params of an object.

Parameters
[in]idobject ID
[in,out]param_infofunction passes info about the params of the object via this param.
[in,out]sizenr of elems in param_info
Returns
true on success, else false

Definition at line 429 of file dm_info.c.

431  {
432  if(id < obj_id_nbr) {
433  *param_info = OBJECT_INFO[id].params;
434  *size = OBJECT_INFO[id].n_params;
435  return true;
436  }
437  SAH_TRACEZ_ERROR(ME, "Invalid id [%d]", id);
438  return false;
439 }
const param_info_t * params
Definition: dm_info.h:130
uint32_t n_params
Definition: dm_info.h:131
Here is the caller graph for this function:

◆ dm_info_init()

bool dm_info_init ( void  )

Initialize the dm_info part.

The function only runs a sanity check on the OBJECT_INFO array.

The plugin must call this function once at startup.

Returns
true on success, else false

Definition at line 297 of file dm_info.c.

297  {
298  uint32_t i;
299  for(i = 0; i < obj_id_nbr; ++i) {
300  if(OBJECT_INFO[i].id != i) {
301  SAH_TRACEZ_ERROR(ME, "OBJECT_INFO[%d].id=%d != %d",
302  i, OBJECT_INFO[i].id, i);
303  return false;
304  }
305  }
306  return true;
307 }
Here is the caller graph for this function: