TR181-XPON  1.4.0
TR-181 PON manager.
dm_events.c File Reference
#include <amxc/amxc.h>
#include <amxc/amxc_macros.h>
#include "ani.h"
#include "object_intf_priv.h"
#include "password.h"
#include "persistency.h"
#include "pon_ctrl.h"
#include "restore_to_hal.h"
#include "xpon_trace.h"

Go to the source code of this file.

Functions

static int isdot (int c)
 
static void onu_or_ani_enable_changed (const amxc_var_t *const event_data, bool onu)
 
void _onu_enable_changed (UNUSED const char *const event_name, const amxc_var_t *const event_data, UNUSED void *const priv)
 
void _ani_enable_changed (UNUSED const char *const event_name, const amxc_var_t *const event_data, UNUSED void *const priv)
 
void _interface_object_added (UNUSED const char *const event_name, const amxc_var_t *const event_data, UNUSED void *const priv)
 
void _status_changed (UNUSED const char *const event_name, const amxc_var_t *const event_data, UNUSED void *const priv)
 
void _password_changed (UNUSED const char *const event_name, const amxc_var_t *const event_data, UNUSED void *const priv)
 

Detailed Description

Handles functions called by the Ambiorix framework upon certain events triggered by changes to the XPON DM.

The file odl/tr181-xpon_definition.odl specifies which functions the Ambiorix framework should call upon certain events. E.g., the file specifies that Ambiorix should call the function

  • onu_enable_changed() or
  • ani_enable_changed() if the Enable parameter of an XPON.ONU or XPON.ONU.x.ANI instance is changed respectively.

Definition in file dm_events.c.

Function Documentation

◆ _ani_enable_changed()

void _ani_enable_changed ( UNUSED const char *const  event_name,
const amxc_var_t *const  event_data,
UNUSED void *const  priv 
)

The Enable param of an XPON.ONU.x.ANI instance changed value.

Parameters
[in]event_datahas path and new value of the Enable param which changed value.

Definition at line 169 of file dm_events.c.

171  {
172 
173  onu_or_ani_enable_changed(event_data, /*onu=*/ false);
174 }
static void onu_or_ani_enable_changed(const amxc_var_t *const event_data, bool onu)
Definition: dm_events.c:107
Here is the call graph for this function:

◆ _interface_object_added()

void _interface_object_added ( UNUSED const char *const  event_name,
const amxc_var_t *const  event_data,
UNUSED void *const  priv 
)

The component added an instance of an interface object.

Parameters
[in]event_datahas path and index of instance added

The function attaches private data to the instance to support the LastChange parameter.

Definition at line 184 of file dm_events.c.

186  {
187  oipriv_attach_private_data(event_data);
188 }
void oipriv_attach_private_data(const amxc_var_t *const data)
Here is the call graph for this function:

◆ _onu_enable_changed()

void _onu_enable_changed ( UNUSED const char *const  event_name,
const amxc_var_t *const  event_data,
UNUSED void *const  priv 
)

The Enable param of an XPON.ONU instance changed value.

Parameters
[in]event_datahas path and new value of the Enable param which changed value.

Definition at line 156 of file dm_events.c.

158  {
159 
160  onu_or_ani_enable_changed(event_data, /*onu=*/ true);
161 }
Here is the call graph for this function:

◆ _password_changed()

void _password_changed ( UNUSED const char *const  event_name,
const amxc_var_t *const  event_data,
UNUSED void *const  priv 
)

The Password parameter of an ANI instance changed value.

Parameters
[in]event_datacontains both the path of TC.Authentication object of the ANI instance whose Password parameter changed value, and the new value for that Password

The function does not need to check if the password is valid: _check_password() already did that.

The function (indirectly) forwards the value to:

  • the vendor module
  • the part of this plugin responsible for the upgrade persistent settings

Definition at line 219 of file dm_events.c.

221  {
222 
223  amxc_string_t path_no_dot; /* path with dot at the end trimmed */
224  amxc_string_t ani_instance;
225  amxc_string_init(&path_no_dot, 0);
226  amxc_string_init(&ani_instance, 0);
227 
228  const char* const path = GETP_CHAR(event_data, "path");
229  const char* const password = GETP_CHAR(event_data, "parameters.Password.to");
230 
231  when_null_trace(path, exit, ERROR, "path is NULL");
232  when_null_trace(password, exit, ERROR, "password is NULL");
233 
234  SAH_TRACEZ_DEBUG(ME, "path='%s' password='%s'", path, password);
235 
236  amxc_string_set(&path_no_dot, path);
237  amxc_string_trimr(&path_no_dot, isdot);
238 
239  const char* const path_no_dot_cstr = amxc_string_get(&path_no_dot, 0);
240 
241  if(!ani_strip_tc_authentication(path_no_dot_cstr, &ani_instance)) {
242  SAH_TRACEZ_ERROR(ME, "%s: failed to check password", path_no_dot_cstr);
243  goto exit;
244  }
245 
246  const char* const ani_instance_cstr = amxc_string_get(&ani_instance, 0);
247  passwd_set_password(ani_instance_cstr, password);
248 
249 exit:
250  amxc_string_clean(&path_no_dot);
251  amxc_string_clean(&ani_instance);
252 }
bool ani_strip_tc_authentication(const char *const ani_auth_path, amxc_string_t *const ani_path)
Definition: ani.c:86
static int isdot(int c)
Definition: dm_events.c:91
void passwd_set_password(const char *const ani_auth_path, const char *const password)
Definition: password.c:168
#define SAH_TRACEZ_DEBUG(zone, format,...)
Definition: xpon_trace.h:115
#define ME
Definition: xpon_trace.h:78
Here is the call graph for this function:

◆ _status_changed()

void _status_changed ( UNUSED const char *const  event_name,
const amxc_var_t *const  event_data,
UNUSED void *const  priv 
)

The Status parameter of an interface object changed value.

Parameters
[in]event_datahas path of object whose Status parameter changed value

The function updates the 'last_change' timestamp in the private data attached to the object.

Definition at line 198 of file dm_events.c.

200  {
201 
202  oipriv_update_last_change(event_data);
203 }
void oipriv_update_last_change(const amxc_var_t *const data)
Here is the call graph for this function:

◆ isdot()

static int isdot ( int  c)
static

Definition at line 91 of file dm_events.c.

91  {
92  return (c == '.') ? 1 : 0;
93 }
Here is the caller graph for this function:

◆ onu_or_ani_enable_changed()

static void onu_or_ani_enable_changed ( const amxc_var_t *const  event_data,
bool  onu 
)
static

The Enable param of an XPON.ONU or XPON.ONU.x.ANI instance changed value.

Parameters
[in]event_datahas path and new value of the Enable param which changed value.
[in]onuIf true, Enable of an ONU instance changed, else Enable of an ANI instance changed

The function forwards the value to:

  • the vendor module
  • the persistency part of this plugin

When enabling an ONU, avoid enabling the ONU while tr181-xpon is still busy querying whether the ONU has EthernetUNI and ANI instances. Schedule a task to enable the ONU in the near future.

restore_to_hal part maybe still has task to enable the object towards the hal. Remove that task if this function asks to disable the object.

Definition at line 107 of file dm_events.c.

107  {
108 
109  const char* const path = GETP_CHAR(event_data, "path");
110  const bool enable = GETP_BOOL(event_data, "parameters.Enable.to");
111 
112  when_null_trace(path, exit, ERROR, "path is NULL");
113 
114  SAH_TRACEZ_INFO(ME, "path='%s' enable=%d", path, enable);
115 
116  amxc_string_t path_no_dot; /* path with dot at the end trimmed */
117  amxc_string_init(&path_no_dot, 0);
118  amxc_string_set(&path_no_dot, path);
119  amxc_string_trimr(&path_no_dot, isdot);
120 
121  const char* const path_no_dot_cstr = amxc_string_get(&path_no_dot, 0);
122 
128  if(enable && onu) {
129  rth_schedule_enable(path_no_dot_cstr);
130  } else {
131  pon_ctrl_set_enable(path_no_dot_cstr, enable);
132  }
133  persistency_enable(path_no_dot_cstr, enable);
134 
139  if(!enable) {
140  rth_disable(path_no_dot_cstr);
141  }
142 
143  amxc_string_clean(&path_no_dot);
144 
145 exit:
146  return;
147 }
void persistency_enable(const char *const object, bool enable)
Definition: persistency.c:248
void pon_ctrl_set_enable(const char *const path, bool enable)
Definition: pon_ctrl.c:153
void rth_schedule_enable(const char *const object)
void rth_disable(const char *const object)
Here is the call graph for this function:
Here is the caller graph for this function: