TR181-XPON
1.4.0
TR-181 PON manager.
|
#include "data_model.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <amxc/amxc.h>
#include <amxp/amxp.h>
#include <amxd/amxd_object.h>
#include <amxd/amxd_transaction.h>
#include "ani.h"
#include "dm_actions.h"
#include "dm_info.h"
#include "dm_xpon_mngr.h"
#include "onu_priv.h"
#include "persistency.h"
#include "password.h"
#include "restore_to_hal.h"
#include "xpon_trace.h"
Go to the source code of this file.
Data Structures | |
struct | _dm_action_info |
Macros | |
#define | ADD_INST_N_ARGS_REQUIRED 3 |
#define | REMOVE_INST_N_ARGS_REQUIRED 2 |
#define | CHANGE_OBJ_N_ARGS_REQUIRED 2 |
#define | ADD_OR_CHANGE_INST_N_ARGS_REQUIRED 2 |
Typedefs | |
typedef struct _dm_action_info | dm_action_info_t |
Functions | |
static void | init_dm_action_info (dm_action_info_t *const info) |
static amxd_object_t * | dm_get_xpon_object (void) |
void | dm_set_vendor_module (const char *name) |
void | dm_set_module_error (void) |
static bool | get_ref_to_params (const amxc_var_t *const args, const amxc_var_t **params) |
static bool | process_args_common (const amxc_var_t *const args, dm_action_info_t *info, const char **keys_required, int n_keys_required) |
static bool | process_add_instance_args (const amxc_var_t *const args, dm_action_info_t *info) |
static bool | prepare_adding_instance (const char *const path, uint32_t index, amxd_object_t **templ) |
static bool | add_params_to_transaction (amxd_trans_t *transaction, const amxc_var_t *const params, object_id_t id) |
static void | update_enable (amxd_trans_t *transaction, const char *const path, uint32_t index) |
static void | add_private_data_to_onu (const char *const path, uint32_t index) |
static bool | add_instance (const dm_action_info_t *const info) |
static bool | process_remove_instance_args (const amxc_var_t *const args, dm_action_info_t *info) |
static bool | remove_instance (const dm_action_info_t *const info) |
int | dm_add_instance (const amxc_var_t *const args) |
int | dm_remove_instance (const amxc_var_t *const args) |
int | dm_change_object (const amxc_var_t *const args) |
int | dm_add_or_change_instance_impl (const amxc_var_t *const args) |
static bool | remove_all_instances (amxd_object_t *templ) |
static void | set_ethernet_uni_status_to_down (const amxd_object_t *const onu_instance, const char *const path) |
int | dm_omci_reset_mib (const amxc_var_t *const args) |
int | dm_set_xpon_parameter_impl (const amxc_var_t *const args) |
bool | dm_does_instance_exist (const char *const path, uint32_t index) |
static uint32_t | get_nr_of_instances (const char *const path) |
uint32_t | dm_get_nr_of_ethernet_uni_instances (const char *const onu_path) |
uint32_t | dm_get_nr_of_ani_instances (const char *const onu_path) |
bool | dm_get_param (const char *path, const char *name, amxc_var_t *resp) |
bool | dm_is_hex_password (const char *const ani_path, bool *is_hex) |
bool | dm_get_ani_pon_mode (const char *const ani_path, pon_mode_t *pon_mode) |
Variables | |
static const char * | ADD_INST_PARAMS_REQUIRED [3] |
static const char * | REMOVE_INST_ARGS_REQUIRED [2] |
static const char * | CHANGE_OBJ_ARGS_REQUIRED [2] |
static const char * | ADD_OR_CHANGE_INST_ARGS_REQUIRED [2] |
#define ADD_INST_N_ARGS_REQUIRED 3 |
Include amxp.h to include amxp_signal.h, which defines amxp_signal_mngr_t. amxd_object.h and amxd_transaction.h need it: they include amxd_types.h, which uses amxp_signal_mngr_t.
Definition at line 94 of file data_model.c.
#define ADD_OR_CHANGE_INST_N_ARGS_REQUIRED 2 |
Definition at line 109 of file data_model.c.
#define CHANGE_OBJ_N_ARGS_REQUIRED 2 |
Definition at line 104 of file data_model.c.
#define REMOVE_INST_N_ARGS_REQUIRED 2 |
Definition at line 99 of file data_model.c.
typedef struct _dm_action_info dm_action_info_t |
Info related to actions done on the DM.
The actions are:
Meaning of the fields:
|
static |
Add an instance to the XPON DM.
[in] | info | all the info needed to create the instance |
If the instance to be created has a read-write Enable parameter, and if that instance is enabled according to the persistent data, create the instance with that Enable parameter set to true, and schedule a timer to let this know to the vendor module in 100 ms.
If the instance created is an ONU instance, create and attach private data to the instance to indicate the persistency of the RW Enable parameter has been handled. The ANI also a has RW Enable parameter. The approach with the private data is only done for an ONU because the PON vendor modules create an ONU instance in 2 different ways:
If the instance created is an ANI instance, restore its PON password if there is one.
Definition at line 589 of file data_model.c.
|
static |
Add set value actions to a transaction to set params of an object.
[in,out] | transaction | transaction to add set value actions to |
[in] | params | htable with values for one or more params of an object |
[in] | id | object ID |
The function iterates over all elements in params. It adds a set value action to transaction for each known element.
Definition at line 430 of file data_model.c.
|
static |
Create and attach private data to the ONU instance.
[in] | path | path of the XPON.ONU template. This must be "XPON.ONU". |
[in] | index | index of the ONU instance |
Definition at line 538 of file data_model.c.
int dm_add_instance | ( | const amxc_var_t *const | args | ) |
Add an instance to the XPON DM.
[in] | args | : must be htable with the keys 'path', 'index' and 'keys'. The htable normally also has an entry with the key 'parameters'. |
Definition at line 762 of file data_model.c.
int dm_add_or_change_instance_impl | ( | const amxc_var_t *const | args | ) |
Add or update an instance in the XPON DM.
[in] | args | : must be htable with the keys 'path' and 'index'. It must also have the key 'keys' if the instance does not yet exist, else it must have the key 'parameters'. It's recommended that 'args' has all those 4 keys. See below for more info. |
The function checks if the instance exists. If the instance does not exist, the function calls 'dm_add_instance()', else it calls 'dm_change_object()'.
More info about the parameter args: The path in args must be the template path, e.g. "XPON.ONU.1.SoftwareImage".
If the function finds out the instance does not exist yet, it demands the same from args as dm_instance_added(): it must be an htable with the keys 'path', 'index' and 'keys'.
If the function finds out the instance already exists, it demands the same from args as dm_object_changed(): it must be an htable with the keys 'path' and 'parameters'. If dm_object_changed() sees that args has a value for 'index', it assumes the caller wants to change path.index, not path.
Hence when calling this function, it's recommended args is htable with the keys 'path', 'index', 'keys' and 'parameters'. Then the function finds the required keys, independent from whether the instance already exists or not.
Definition at line 922 of file data_model.c.
int dm_change_object | ( | const amxc_var_t *const | args | ) |
Update one of more params of an object in the XPON DM.
[in] | args | : must be htable with the keys 'path' and 'parameters'. If it has a non-zero value for 'index', the function assumes the caller wants to update the instance 'path'.'index'. |
If the object is an ONU instance, check if the instance has private data. If it doesn't, attach private data, and call update_enable() for that instance. If the ONU instance has no private data yet, this process did not check yet the persistent data to find out if the ONU instance should be enabled.
Definition at line 821 of file data_model.c.
bool dm_does_instance_exist | ( | const char *const | path, |
uint32_t | index | ||
) |
Return true if a certain instance of a template object exists.
[in] | path | object path, e.g., "XPON.ONU" |
[in] | index | the instance index, e.g., 1 |
Definition at line 1141 of file data_model.c.
bool dm_get_ani_pon_mode | ( | const char *const | ani_path, |
pon_mode_t * | pon_mode | ||
) |
Find out the PON Mode of an ANI.
[in] | ani_path | path to ANI instance, e.g. "XPON.ONU.1.ANI.1" |
[in,out] | pon_mode | function sets this to the PON mode of the ANI referred to by ani_path |
Definition at line 1280 of file data_model.c.
uint32_t dm_get_nr_of_ani_instances | ( | const char *const | onu_path | ) |
Return the number of ANI instances for a certain XPON.ONU instance.
[in] | path | path of a certain XPON.ONU instance, e.g. "XPON.ONU.1" |
Definition at line 1198 of file data_model.c.
uint32_t dm_get_nr_of_ethernet_uni_instances | ( | const char *const | onu_path | ) |
Return the number of EthernetUNI instances for a certain XPON.ONU instance.
[in] | path | path of a certain XPON.ONU instance, e.g. "XPON.ONU.1" |
Definition at line 1187 of file data_model.c.
bool dm_get_param | ( | const char * | path, |
const char * | name, | ||
amxc_var_t * | resp | ||
) |
Definition at line 1204 of file data_model.c.
|
static |
Return the "XPON" object from the XPON DM.
Definition at line 153 of file data_model.c.
bool dm_is_hex_password | ( | const char *const | ani_path, |
bool * | is_hex | ||
) |
Find out if password for an ANI instance is in hex format or not.
[in] | ani_path | path to ANI instance, e.g. "XPON.ONU.1.ANI.1" |
[in,out] | is_hex | function sets this to true if the parameter 'HexadecimalPassword' of the ANI instance referred to by ani_path is true |
Definition at line 1236 of file data_model.c.
int dm_omci_reset_mib | ( | const amxc_var_t *const | args | ) |
Handle an OMCI reset MIB message.
[in] | args | : must be htable with the key 'index'. The 'index' must indicate for which XPON.ONU instance an OMCI reset MIB is received |
The function does the following:
Definition at line 1049 of file data_model.c.
int dm_remove_instance | ( | const amxc_var_t *const | args | ) |
Remove an instance from the XPON DM.
[in] | args | : must be htable with the keys 'path' and 'index' |
Definition at line 788 of file data_model.c.
void dm_set_module_error | ( | void | ) |
Set XPON.ModuleError to true.
Definition at line 192 of file data_model.c.
void dm_set_vendor_module | ( | const char * | name | ) |
Set XPON.ModuleName to name.
[in] | name | name of the vendor module, e.g. "mod-xpon-prpl". |
The component should call this function once at startup, after determining which vendor module it should load.
Definition at line 178 of file data_model.c.
int dm_set_xpon_parameter_impl | ( | const amxc_var_t *const | args | ) |
Update a parameter of the XPON object.
[in] | args | must be htable with the keys 'name' and 'value'. |
Definition at line 1106 of file data_model.c.
|
static |
Return the number of instances of a template object.
[in] | path | path of a template object, e.g., "XPON.ONU" or "XPON.ONU.1.ANI" |
Definition at line 1166 of file data_model.c.
|
static |
|
static |
|
static |
Prepare adding an instance to the XPON DM.
[in] | path | object path of a template object, e.g. "XPON.ONU" |
[in] | index | index of instance to be added |
[in,out] | templ | function assigns pointer to template object if instance does not yet exist |
Definition at line 389 of file data_model.c.
|
static |
Process the arguments of dm_add_instance() function call.
[in] | args | must be htable with keys specified by ADD_INST_PARAMS_REQUIRED. The htable normally also has an entry with the key 'parameters'. |
[in,out] | info | the function extracts info from args and assigns it to the fields of this parameter |
It calls process_args_common() with args = ADD_INST_PARAMS_REQUIRED.
In addition it extracts the key value from args and assigns it info->key_value.
Definition at line 326 of file data_model.c.
|
static |
Process the arguments of a function implemented in this file.
[in] | args | must be htable with keys specified by keys_required |
[in,out] | info | the function extracts info from args and assigns it to the fields of this parameter |
[in] | keys_required | list of keys which must be present in args |
[in] | n_keys_required | number of elements in keys_required |
args must always have an entry with key 'path'. The function assigns its value to info->path. It derives the object ID from the path with dm_get_object_id() and assigns it to info->obj_id.
If args contains entries with the key 'index' and/or 'parameters', the function assigns their values to info->index and info->params respectively.
The function returns false if one of the keys specified in keys_required does not occur in args.
Definition at line 244 of file data_model.c.
|
static |
Process the arguments of dm_remove_instance() function call.
[in] | args | must be htable with keys specified by REMOVE_INST_ARGS_REQUIRED |
[in,out] | info | the function extracts info from args and assigns it to the fields of this parameter |
Definition at line 669 of file data_model.c.
|
static |
Remove all instances from a template object.
[in] | templ | template object to remove all instances from |
Example: template can refer to "XPON.ONU.1.ANI.1.TC.GEM.Port".
Definition at line 958 of file data_model.c.
|
static |
Remove an from instance from to the XPON DM.
[in] | info | all the info needed to remove the instance |
The function logs a warning and returns true if the instance does not exist.
Definition at line 695 of file data_model.c.
|
static |
For all EthernetUNI instances of the ONU, set Status to Down if it is Up now.
Definition at line 1011 of file data_model.c.
|
static |
Set the Enable param to true if the object is enabled according to persistency.
Also call rth_schedule_enable().
[in] | transaction | transaction which is going to add an instance |
[in] | path | object path, e.g. "XPON.ONU" |
[in] | index | the index of the object instance |
Definition at line 505 of file data_model.c.
|
static |
Definition at line 95 of file data_model.c.
|
static |
Definition at line 110 of file data_model.c.
|
static |
Definition at line 105 of file data_model.c.
|
static |
Definition at line 100 of file data_model.c.