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

Go to the source code of this file.

Functions

static int call_pon_ctrl_function_common (const char *const func_name, amxc_var_t *args, amxc_var_t *ret)
 
static void set_max_nr_of_onus (void)
 
void pon_ctrl_init (void)
 
void pon_ctrl_set_enable (const char *const path, bool enable)
 
int pon_ctrl_get_list_of_instances (const char *const path, amxc_var_t *ret)
 
int pon_ctrl_get_object_content (const char *const path, uint32_t index, amxc_var_t *ret)
 
int pon_ctrl_get_param_values (const char *const path, const char *const names, amxc_var_t *ret)
 
void pon_ctrl_handle_file_descriptor (int fd)
 
void pon_ctrl_set_password (const char *const ani_path, const char *const password, bool hex)
 

Variables

static const char *const MOD_PON_CTRL = "pon_ctrl"
 
static const char *const SET_MAX_NR_OF_ONUS = "set_max_nr_of_onus"
 
static const char *const SET_ENABLE = "set_enable"
 
static const char *const GET_LIST_OF_INSTANCES = "get_list_of_instances"
 
static const char *const GET_OBJECT_CONTENT = "get_object_content"
 
static const char *const GET_PARAM_VALUES = "get_param_values"
 
static const char *const HANDLE_FILE_DESCRIPTOR = "handle_file_descriptor"
 
static const char *const SET_PASSWORD = "set_password"
 

Function Documentation

◆ call_pon_ctrl_function_common()

static int call_pon_ctrl_function_common ( const char *const  func_name,
amxc_var_t *  args,
amxc_var_t *  ret 
)
static

Definition at line 85 of file pon_ctrl.c.

87  {
88 
89  int rc = -1;
90  amxc_var_t* ret_dummy = NULL;
91 
92  when_null_trace(args, exit, ERROR, "args is NULL");
93 
94  const char* const so_name = mod_get_vendor_module_loaded(); /* shared_object_name */
95  when_null_trace(so_name, exit, ERROR, "No vendor module loaded");
96 
97  if(NULL == ret) {
98  if(amxc_var_new(&ret_dummy)) {
99  SAH_TRACEZ_ERROR(ME, "Failed to allocate memory");
100  goto exit;
101  }
102  }
103 
104  rc = amxm_execute_function(so_name, MOD_PON_CTRL, func_name, args,
105  ret ? ret : ret_dummy);
106  if(rc) {
107  SAH_TRACEZ_ERROR(ME, "%s.%s.%s() failed: rc=%d", so_name, MOD_PON_CTRL,
108  func_name, rc);
109  }
110 
111 exit:
112  if(ret_dummy != NULL) {
113  amxc_var_delete(&ret_dummy);
114  }
115  return rc;
116 }
const char * mod_get_vendor_module_loaded(void)
Definition: module_mgmt.c:326
static const char *const MOD_PON_CTRL
Definition: pon_ctrl.c:75
#define ME
Definition: xpon_trace.h:78
Here is the call graph for this function:
Here is the caller graph for this function:

◆ pon_ctrl_get_list_of_instances()

int pon_ctrl_get_list_of_instances ( const char *const  path,
amxc_var_t *  ret 
)

Ask vendor module which instances exist for a template object.

Parameters
[in]pathpath to template object, e.g. "XPON.ONU" or "XPON.ONU.1.SoftwareImage"
[in,out]retfunction returns result via this parameter. See below for more info.

The param ret should be an htable with following keys upon success:

  • 'indexes': a string with comma-separated integers representing the instance indexes. It's an empty string if no instances exist.
Returns
0 on success, -1 upon error

Definition at line 187 of file pon_ctrl.c.

187  {
188 
189  amxc_var_t args;
190  amxc_var_init(&args);
191  amxc_var_set(cstring_t, &args, path);
192 
193  const int rc =
195 
196  amxc_var_clean(&args);
197  return rc;
198 }
static const char *const GET_LIST_OF_INSTANCES
Definition: pon_ctrl.c:79
static int call_pon_ctrl_function_common(const char *const func_name, amxc_var_t *args, amxc_var_t *ret)
Definition: pon_ctrl.c:85
Here is the call graph for this function:
Here is the caller graph for this function:

◆ pon_ctrl_get_object_content()

int pon_ctrl_get_object_content ( const char *const  path,
uint32_t  index,
amxc_var_t *  ret 
)

Ask vendor module for the content (parameter values) of an object.

Parameters
[in]pathobject path. This can be a singleton or template object.
[in]indexinstance index when querying the content of an instance. Must be 0 when querying a singleton.
[in,out]retfunction returns result via this parameter. See below for more info.

The param ret should be an htable with following keys upon success:

  • 'parameters': values for the parameters of the object
  • 'keys': only present in ret when querying an instance. It should contain values for the keys of the template object.
Returns
0 on success, -1 upon error

Definition at line 216 of file pon_ctrl.c.

216  {
217 
218  amxc_var_t args;
219  amxc_var_init(&args);
220 
221  amxc_var_set_type(&args, AMXC_VAR_ID_HTABLE);
222  amxc_var_add_key(cstring_t, &args, "path", path);
223  if(index) {
224  amxc_var_add_key(uint32_t, &args, "index", index);
225  }
226 
227  const int rc = call_pon_ctrl_function_common(GET_OBJECT_CONTENT, &args, ret);
228 
229  amxc_var_clean(&args);
230  return rc;
231 }
static const char *const GET_OBJECT_CONTENT
Definition: pon_ctrl.c:80
Here is the call graph for this function:
Here is the caller graph for this function:

◆ pon_ctrl_get_param_values()

int pon_ctrl_get_param_values ( const char *const  path,
const char *const  names,
amxc_var_t *  ret 
)

Ask vendor module for the values of one or more parameters of an object.

Parameters
[in]pathobject path of a singleton or an instance
[in]namesparameter names formatted as a comma-separated list. The vendor module might support passing max 1 parameter name. Example: "RxPower".
[in,out]retfunction returns result via this parameter. See below for more info.

The param ret should be an htable with following keys upon success:

  • 'parameters': values for the requested parameter(s) of the object
Returns
0 on success, -1 upon error

Definition at line 248 of file pon_ctrl.c.

250  {
251 
252  amxc_var_t args;
253  amxc_var_init(&args);
254 
255  amxc_var_set_type(&args, AMXC_VAR_ID_HTABLE);
256  amxc_var_add_key(cstring_t, &args, "path", path);
257  amxc_var_add_key(cstring_t, &args, "names", names);
258 
259  SAH_TRACEZ_DEBUG(ME, "path='%s' names='%s'", path, names);
260  const int rc = call_pon_ctrl_function_common(GET_PARAM_VALUES, &args, ret);
261 
262  amxc_var_clean(&args);
263  return rc;
264 }
static const char *const GET_PARAM_VALUES
Definition: pon_ctrl.c:81
#define SAH_TRACEZ_DEBUG(zone, format,...)
Definition: xpon_trace.h:115
Here is the call graph for this function:
Here is the caller graph for this function:

◆ pon_ctrl_handle_file_descriptor()

void pon_ctrl_handle_file_descriptor ( int  fd)

Ask vendor module to handle (a message arriving on) a file descriptor.

Parameters
[in]fdthe file descriptor to handle

Examples for the file descriptor:

  • file descriptor of the socket the vendor module uses for IPC with the vendor specific PON/OMCI stack.
  • file descriptor of a socket to monitor netlink messages from the kernel.
  • ...

Definition at line 277 of file pon_ctrl.c.

277  {
278 
279  amxc_var_t var;
280  amxc_var_init(&var);
281  amxc_var_set(fd_t, &var, fd);
283  amxc_var_clean(&var);
284 }
static const char *const HANDLE_FILE_DESCRIPTOR
Definition: pon_ctrl.c:82
Here is the call graph for this function:
Here is the caller graph for this function:

◆ pon_ctrl_init()

void pon_ctrl_init ( void  )

Initialize the pon_ctrl part of this plugin.

The function forwards value of MAX_NR_OF_ONUS to the vendor module.

The plugin must call this function once at startup, after loading the vendor module.

Definition at line 142 of file pon_ctrl.c.

142  {
144 }
static void set_max_nr_of_onus(void)
Definition: pon_ctrl.c:122
Here is the call graph for this function:
Here is the caller graph for this function:

◆ pon_ctrl_set_enable()

void pon_ctrl_set_enable ( const char *const  path,
bool  enable 
)

Let vendor module know that a read-write Enable field was changed.

Parameters
[in]pathpath of object whose Enable field was changed, e.g., "XPON.ONU.1", or "XPON.ONU.1.ANI.1"
[in]enabletrue if Enable field was set to true, else false

Definition at line 153 of file pon_ctrl.c.

153  {
154 
155  amxc_var_t args;
156  amxc_var_init(&args);
157 
158  SAH_TRACEZ_DEBUG(ME, "path='%s' enable=%d", path, enable);
159 
160  amxc_var_set_type(&args, AMXC_VAR_ID_HTABLE);
161 
162  amxc_var_add_key(cstring_t, &args, "path", path);
163  amxc_var_add_key(bool, &args, "enable", enable);
164 
165  if(call_pon_ctrl_function_common(SET_ENABLE, &args, NULL)) {
166  SAH_TRACEZ_ERROR(ME, "path='%s' enable=%d: %s() failed",
167  path, enable, SET_ENABLE);
168  }
169 
170  amxc_var_clean(&args);
171 }
static const char *const SET_ENABLE
Definition: pon_ctrl.c:78
Here is the call graph for this function:
Here is the caller graph for this function:

◆ pon_ctrl_set_password()

void pon_ctrl_set_password ( const char *const  ani_path,
const char *const  password,
bool  hex 
)

Ask vendor module to apply the password.

Parameters
[in]ani_pathpath to ANI instance, e.g. "XPON.ONU.1.ANI.1"
[in]passwordnew value for the parameter Password of the ANI referred to by ani_path
[in]hexfalse if password is in ASCII format; true if password is in hexadecimal format

Definition at line 295 of file pon_ctrl.c.

297  {
298  amxc_var_t args;
299  amxc_var_init(&args);
300 
301  amxc_var_set_type(&args, AMXC_VAR_ID_HTABLE);
302  amxc_var_add_key(cstring_t, &args, "ani_path", ani_path);
303  amxc_var_add_key(cstring_t, &args, "password", password);
304  amxc_var_add_key(bool, &args, "is_hexadecimal_password", hex);
305 
306  SAH_TRACEZ_DEBUG(ME, "ani_path='%s' password='%s' hex=%d", ani_path, password, hex);
308  amxc_var_clean(&args);
309 }
static const char *const SET_PASSWORD
Definition: pon_ctrl.c:83
Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_max_nr_of_onus()

static void set_max_nr_of_onus ( void  )
static

Forward value of MAX_NR_OF_ONUS to the vendor module.

Definition at line 122 of file pon_ctrl.c.

122  {
123  amxc_var_t args;
124  amxc_var_init(&args);
125  amxc_var_set(uint32_t, &args, MAX_NR_OF_ONUS);
126 
128  SAH_TRACEZ_ERROR(ME, "Failed to set max nr of ONUs");
129  }
130 
131  amxc_var_clean(&args);
132 }
static const char *const SET_MAX_NR_OF_ONUS
Definition: pon_ctrl.c:77
Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ GET_LIST_OF_INSTANCES

const char* const GET_LIST_OF_INSTANCES = "get_list_of_instances"
static

Definition at line 79 of file pon_ctrl.c.

◆ GET_OBJECT_CONTENT

const char* const GET_OBJECT_CONTENT = "get_object_content"
static

Definition at line 80 of file pon_ctrl.c.

◆ GET_PARAM_VALUES

const char* const GET_PARAM_VALUES = "get_param_values"
static

Definition at line 81 of file pon_ctrl.c.

◆ HANDLE_FILE_DESCRIPTOR

const char* const HANDLE_FILE_DESCRIPTOR = "handle_file_descriptor"
static

Definition at line 82 of file pon_ctrl.c.

◆ MOD_PON_CTRL

const char* const MOD_PON_CTRL = "pon_ctrl"
static

Definition at line 75 of file pon_ctrl.c.

◆ SET_ENABLE

const char* const SET_ENABLE = "set_enable"
static

Definition at line 78 of file pon_ctrl.c.

◆ SET_MAX_NR_OF_ONUS

const char* const SET_MAX_NR_OF_ONUS = "set_max_nr_of_onus"
static

Definition at line 77 of file pon_ctrl.c.

◆ SET_PASSWORD

const char* const SET_PASSWORD = "set_password"
static

Definition at line 83 of file pon_ctrl.c.