TR181-XPON  1.4.0
TR-181 PON manager.
dm_info.c File Reference
#include "dm_info.h"
#include <string.h>
#include <amxc/amxc.h>
#include <amxc/amxc_macros.h>
#include "xpon_trace.h"

Go to the source code of this file.

Macros

#define ARRAY_SIZE(arr)   (sizeof(arr) / sizeof((arr)[0]))
 

Functions

bool dm_info_init (void)
 
static bool dm_convert_to_generic_path (const char *path, amxc_string_t *generic_path)
 
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)
 

Variables

static const param_info_t ONU_PARAMS []
 
static const param_info_t SOFTWARE_IMAGE_PARAMS []
 
static const param_info_t ETHERNET_UNI_PARAMS []
 
static const param_info_t ANI_PARAMS []
 
static const param_info_t GEM_PORT_PARAMS []
 
static const param_info_t TRANSCEIVER_PARAMS []
 
static const param_info_t ONU_ACTIVATION_PARAMS []
 
static const param_info_t AUTHENTICATION_PARAMS []
 
static const param_info_t PERFORMANCE_THRESHOLDS_PARAMS []
 
static const param_info_t TC_ALARMS_PARAMS []
 
const object_info_t OBJECT_INFO [obj_id_nbr]
 

Macro Definition Documentation

◆ ARRAY_SIZE

#define ARRAY_SIZE (   arr)    (sizeof(arr) / sizeof((arr)[0]))

Definition at line 77 of file dm_info.c.

Function Documentation

◆ dm_convert_to_generic_path()

static bool dm_convert_to_generic_path ( const char *  path,
amxc_string_t *  generic_path 
)
static

Convert an actual path to a generic path.

Parameters
[in]pathactual path with real instance indexes, e.g., "XPON.ONU.1.ANI.1.Transceiver"
[in,out]generic_paththe function returns the generic version of path. The generic version of a path is the path with all instance indexes replaced by 'x', e.g., "XPON.ONU.x.ANI.x.Transceiver".
Returns
true on success, else false

Definition at line 320 of file dm_info.c.

320  {
321 
322  bool rv = false;
323  when_null(path, exit_no_cleanup);
324  when_null(generic_path, exit_no_cleanup);
325 
326  amxc_llist_t list;
327  amxc_llist_init(&list);
328 
329  amxc_string_t input;
330  amxc_string_init(&input, 0);
331  amxc_string_set(&input, path);
332 
333  if(AMXC_STRING_SPLIT_OK != amxc_string_split_to_llist(&input, &list, '.')) {
334  SAH_TRACEZ_ERROR(ME, "Failed to split '%s'", path);
335  goto exit;
336  }
337 
338  /* Remove the last elem from 'list' if it's numeric */
339  amxc_llist_it_t* last_it = amxc_llist_get_last(&list);
340  when_null(last_it, exit);
341  amxc_string_t* const last_elem = amxc_string_from_llist_it(last_it);
342  if(amxc_string_is_numeric(last_elem)) {
343  amxc_llist_take_last(&list);
344  amxc_string_list_it_free(last_it);
345  }
346 
347  amxc_llist_iterate(it, &list) {
348  amxc_string_t* part = amxc_string_from_llist_it(it);
349  if(amxc_string_is_numeric(part)) {
350  amxc_string_set(part, "x");
351  }
352  }
353 
354  if(amxc_string_join_llist(generic_path, &list, '.') != 0) {
355  SAH_TRACEZ_ERROR(ME, "Failed to generate generic path from '%s'", path);
356  goto exit;
357  }
358  rv = true;
359 
360 exit:
361  amxc_llist_clean(&list, amxc_string_list_it_free);
362  amxc_string_clean(&input);
363 
364 exit_no_cleanup:
365  return rv;
366 }
#define ME
Definition: xpon_trace.h:78
Here is the caller graph for this function:

◆ 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
enum _xpon_object_id object_id_t
@ obj_id_nbr
Definition: dm_info.h:90
@ obj_id_unknown
Definition: dm_info.h:91
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 }
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:

Variable Documentation

◆ ANI_PARAMS

const param_info_t ANI_PARAMS[]
static
Initial value:
= {
{ .name = ENABLE_PARAM, .type = AMXC_VAR_ID_BOOL },
{ .name = "Status", .type = AMXC_VAR_ID_CSTRING },
{ .name = "LastChange", .type = AMXC_VAR_ID_UINT32 },
{ .name = "PONMode", .type = AMXC_VAR_ID_CSTRING }
}
#define ENABLE_PARAM
Definition: dm_info.h:74

Definition at line 103 of file dm_info.c.

◆ AUTHENTICATION_PARAMS

const param_info_t AUTHENTICATION_PARAMS[]
static
Initial value:
= {
{ .name = "Password", .type = AMXC_VAR_ID_CSTRING },
{ .name = "HexadecimalPassword", .type = AMXC_VAR_ID_BOOL }
}

Definition at line 138 of file dm_info.c.

◆ ETHERNET_UNI_PARAMS

const param_info_t ETHERNET_UNI_PARAMS[]
static
Initial value:
= {
{ .name = "Enable", .type = AMXC_VAR_ID_BOOL },
{ .name = "Status", .type = AMXC_VAR_ID_CSTRING },
{ .name = "LastChange", .type = AMXC_VAR_ID_UINT32 },
{ .name = "ANIs", .type = AMXC_VAR_ID_CSV_STRING },
{ .name = "InterdomainID", .type = AMXC_VAR_ID_CSTRING },
{ .name = "InterdomainName", .type = AMXC_VAR_ID_CSTRING },
}

Definition at line 94 of file dm_info.c.

◆ GEM_PORT_PARAMS

const param_info_t GEM_PORT_PARAMS[]
static
Initial value:
= {
{ .name = "Direction", .type = AMXC_VAR_ID_CSTRING },
{ .name = "PortType", .type = AMXC_VAR_ID_CSTRING }
}

Definition at line 110 of file dm_info.c.

◆ OBJECT_INFO

const object_info_t OBJECT_INFO[obj_id_nbr]

Array with info about objects in the XPON DM.

The 'id' of the element at index 'i' must have 'i' as value.

Definition at line 171 of file dm_info.c.

◆ ONU_ACTIVATION_PARAMS

const param_info_t ONU_ACTIVATION_PARAMS[]
static
Initial value:
= {
{ .name = "ONUState", .type = AMXC_VAR_ID_CSTRING },
{ .name = "VendorID", .type = AMXC_VAR_ID_CSTRING },
{ .name = "SerialNumber", .type = AMXC_VAR_ID_CSTRING },
{ .name = "ONUID", .type = AMXC_VAR_ID_UINT32 }
}

Definition at line 131 of file dm_info.c.

◆ ONU_PARAMS

const param_info_t ONU_PARAMS[]
static
Initial value:
= {
{ .name = ENABLE_PARAM, .type = AMXC_VAR_ID_BOOL },
{ .name = "Version", .type = AMXC_VAR_ID_CSTRING },
{ .name = "EquipmentID", .type = AMXC_VAR_ID_CSTRING },
{ .name = "UsePPTPEthernetUNIasIFtoNonOmciDomain", .type = AMXC_VAR_ID_BOOL }
}

Definition at line 80 of file dm_info.c.

◆ PERFORMANCE_THRESHOLDS_PARAMS

const param_info_t PERFORMANCE_THRESHOLDS_PARAMS[]
static
Initial value:
= {
{ .name = "SignalFail", .type = AMXC_VAR_ID_UINT32 },
{ .name = "SignalDegrade", .type = AMXC_VAR_ID_UINT32 }
}

Definition at line 143 of file dm_info.c.

◆ SOFTWARE_IMAGE_PARAMS

const param_info_t SOFTWARE_IMAGE_PARAMS[]
static
Initial value:
= {
{ .name = "Version", .type = AMXC_VAR_ID_CSTRING },
{ .name = "IsCommitted", .type = AMXC_VAR_ID_BOOL },
{ .name = "IsActive", .type = AMXC_VAR_ID_BOOL },
{ .name = "IsValid", .type = AMXC_VAR_ID_BOOL }
}

Definition at line 87 of file dm_info.c.

◆ TC_ALARMS_PARAMS

const param_info_t TC_ALARMS_PARAMS[]
static
Initial value:
= {
{ .name = "LOS", .type = AMXC_VAR_ID_BOOL },
{ .name = "LOF", .type = AMXC_VAR_ID_BOOL },
{ .name = "SF", .type = AMXC_VAR_ID_BOOL },
{ .name = "SD", .type = AMXC_VAR_ID_BOOL },
{ .name = "LCDG", .type = AMXC_VAR_ID_BOOL },
{ .name = "TF", .type = AMXC_VAR_ID_BOOL },
{ .name = "SUF", .type = AMXC_VAR_ID_BOOL },
{ .name = "MEM", .type = AMXC_VAR_ID_BOOL },
{ .name = "DACT", .type = AMXC_VAR_ID_BOOL },
{ .name = "DIS", .type = AMXC_VAR_ID_BOOL },
{ .name = "MIS", .type = AMXC_VAR_ID_BOOL },
{ .name = "PEE", .type = AMXC_VAR_ID_BOOL },
{ .name = "RDI", .type = AMXC_VAR_ID_BOOL },
{ .name = "LODS", .type = AMXC_VAR_ID_BOOL },
{ .name = "ROGUE", .type = AMXC_VAR_ID_BOOL }
}

Definition at line 148 of file dm_info.c.

◆ TRANSCEIVER_PARAMS

const param_info_t TRANSCEIVER_PARAMS[]
static
Initial value:
= {
{ .name = "Identifier", .type = AMXC_VAR_ID_UINT32 },
{ .name = "VendorName", .type = AMXC_VAR_ID_CSTRING },
{ .name = "VendorPartNumber", .type = AMXC_VAR_ID_CSTRING },
{ .name = "VendorRevision", .type = AMXC_VAR_ID_CSTRING },
{ .name = "PONMode", .type = AMXC_VAR_ID_CSTRING },
{ .name = "Connector", .type = AMXC_VAR_ID_CSTRING },
{ .name = "NominalBitRateDownstream", .type = AMXC_VAR_ID_UINT32 },
{ .name = "NominalBitRateUpstream", .type = AMXC_VAR_ID_UINT32 },
{ .name = "RxPower", .type = AMXC_VAR_ID_INT32 },
{ .name = "TxPower", .type = AMXC_VAR_ID_INT32 },
{ .name = "Voltage", .type = AMXC_VAR_ID_UINT32 },
{ .name = "Bias", .type = AMXC_VAR_ID_UINT32 },
{ .name = "Temperature", .type = AMXC_VAR_ID_INT32 }
}

Definition at line 115 of file dm_info.c.