TR181-XPON  1.4.0
TR-181 PON manager.
pon_stat.c File Reference
#include "pon_stat.h"
#include <amxc/amxc_macros.h>
#include <amxp/amxp.h>
#include <amxc/amxc.h>
#include <amxd/amxd_types.h>
#include <amxo/amxo.h>
#include "data_model.h"
#include "dm_xpon_mngr.h"
#include "pon_ctrl.h"
#include "xpon_trace.h"

Go to the source code of this file.

Functions

int dm_instance_added (UNUSED const char *function_name, amxc_var_t *args, UNUSED amxc_var_t *ret)
 
int dm_instance_removed (UNUSED const char *function_name, amxc_var_t *args, UNUSED amxc_var_t *ret)
 
int dm_object_changed (UNUSED const char *function_name, amxc_var_t *args, UNUSED amxc_var_t *ret)
 
int dm_add_or_change_instance (UNUSED const char *function_name, amxc_var_t *args, UNUSED amxc_var_t *ret)
 
int omci_reset_mib (UNUSED const char *function_name, amxc_var_t *args, UNUSED amxc_var_t *ret)
 
static void handle_fd (int fd, UNUSED void *priv)
 
static int watch_file_descriptor_common (amxc_var_t *args, bool start)
 
int watch_file_descriptor_start (UNUSED const char *function_name, amxc_var_t *args, UNUSED amxc_var_t *ret)
 
int watch_file_descriptor_stop (UNUSED const char *function_name, amxc_var_t *args, UNUSED amxc_var_t *ret)
 
int dm_set_xpon_parameter (UNUSED const char *function_name, amxc_var_t *args, UNUSED amxc_var_t *ret)
 

Function Documentation

◆ dm_add_or_change_instance()

int dm_add_or_change_instance ( UNUSED const char *  function_name,
amxc_var_t *  args,
UNUSED amxc_var_t *  ret 
)

Add or update an instance in the XPON DM.

Parameters
[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, this component ends up calling 'dm_add_instance()', else it ends up calling '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 htable with the keys 'path' and 'parameters'.

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.

Returns
0 on success, else -1.

Definition at line 166 of file pon_stat.c.

168  {
169  SAH_TRACEZ_INFO(ME, "called");
170  return dm_add_or_change_instance_impl(args);
171 }
int dm_add_or_change_instance_impl(const amxc_var_t *const args)
Definition: data_model.c:922
#define ME
Definition: xpon_trace.h:78
Here is the call graph for this function:

◆ dm_instance_added()

int dm_instance_added ( UNUSED const char *  function_name,
amxc_var_t *  args,
UNUSED amxc_var_t *  ret 
)

amxo.h includes amxo_types.h, which requires amxd/amxd_types.h. That header needs amxp_signal_mngr_t. Add an instance to the XPON DM.

Parameters
[in]args: must be htable with the keys 'path', 'index' and 'keys'. The htable normally also has an entry with the key 'parameters'.
Returns
0 on success, else -1.

Definition at line 95 of file pon_stat.c.

97  {
98 
99  SAH_TRACEZ_INFO(ME, "called");
100  return dm_add_instance(args);
101 }
int dm_add_instance(const amxc_var_t *const args)
Definition: data_model.c:762
Here is the call graph for this function:

◆ dm_instance_removed()

int dm_instance_removed ( UNUSED const char *  function_name,
amxc_var_t *  args,
UNUSED amxc_var_t *  ret 
)

Remove an instance from the XPON DM.

Parameters
[in]args: must be htable with the keys 'path' and 'index'
Returns
0 on success, else -1.

Definition at line 110 of file pon_stat.c.

112  {
113 
114  SAH_TRACEZ_INFO(ME, "called");
115  return dm_remove_instance(args);
116 }
int dm_remove_instance(const amxc_var_t *const args)
Definition: data_model.c:788
Here is the call graph for this function:

◆ dm_object_changed()

int dm_object_changed ( UNUSED const char *  function_name,
amxc_var_t *  args,
UNUSED amxc_var_t *  ret 
)

Update one of more params of an object in the XPON DM.

Parameters
[in]args: must be htable with the keys 'path' and 'parameters'
Returns
0 on success, else -1.

Definition at line 125 of file pon_stat.c.

127  {
128 
129  SAH_TRACEZ_INFO(ME, "called");
130  return dm_change_object(args);
131 }
int dm_change_object(const amxc_var_t *const args)
Definition: data_model.c:821
Here is the call graph for this function:

◆ dm_set_xpon_parameter()

int dm_set_xpon_parameter ( UNUSED const char *  function_name,
amxc_var_t *  args,
UNUSED amxc_var_t *  ret 
)

Update a parameter of the XPON object.

Parameters
[in]argsmust be htable with the keys 'name' and 'value'.
Returns
0 on success, else -1.

Definition at line 277 of file pon_stat.c.

279  {
280 
281  SAH_TRACEZ_INFO(ME, "called");
282  return dm_set_xpon_parameter_impl(args);
283 }
int dm_set_xpon_parameter_impl(const amxc_var_t *const args)
Definition: data_model.c:1106
Here is the call graph for this function:

◆ handle_fd()

static void handle_fd ( int  fd,
UNUSED void *  priv 
)
static

Definition at line 190 of file pon_stat.c.

190  {
191  when_false_trace(fd > 0, exit, ERROR, "Invalid fd [%d]", fd);
192 
193  SAH_TRACEZ_DEBUG(ME, "fd=%d readable", fd);
195 
196 exit:
197  return;
198 }
void pon_ctrl_handle_file_descriptor(int fd)
Definition: pon_ctrl.c:277
#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:

◆ omci_reset_mib()

int omci_reset_mib ( UNUSED const char *  function_name,
amxc_var_t *  args,
UNUSED amxc_var_t *  ret 
)

Notify plugin an OMCI reset MIB message was received for an ONU.

Parameters
[in]args: must be htable with the key 'index'. The 'index' must indicate for which XPON.ONU instance an OMCI reset MIB is received.
Returns
0 on success, else -1.

Definition at line 182 of file pon_stat.c.

184  {
185 
186  SAH_TRACEZ_INFO(ME, "called");
187  return dm_omci_reset_mib(args);
188 }
int dm_omci_reset_mib(const amxc_var_t *const args)
Definition: data_model.c:1049
Here is the call graph for this function:

◆ watch_file_descriptor_common()

static int watch_file_descriptor_common ( amxc_var_t *  args,
bool  start 
)
static

Definition at line 201 of file pon_stat.c.

202  {
203  int rc = -1;
204  amxo_parser_t* const parser = xpon_mngr_get_parser();
205  when_null(parser, exit);
206  when_null(args, exit);
207 
208  const uint32_t type = amxc_var_type_of(args);
209  when_false_trace(type == AMXC_VAR_ID_FD, exit, ERROR,
210  "Type of 'args' = %d != FD", type);
211  const int fd = amxc_var_constcast(fd_t, args);
212  when_false_trace(fd > 0, exit, ERROR, "Invalid fd [%d]", fd);
213 
214  if(start) {
215  if(amxo_connection_add(parser, fd, handle_fd, NULL, AMXO_CUSTOM, NULL) != 0) {
216  SAH_TRACEZ_ERROR(ME, "Failed to start monitoring fd=%d", fd);
217  goto exit;
218  }
219  } else {
220  if(amxo_connection_remove(parser, fd) != 0) {
221  SAH_TRACEZ_ERROR(ME, "Failed to stop monitoring fd=%d", fd);
222  goto exit;
223  }
224  }
225 
226  rc = 0;
227 
228 exit:
229  return rc;
230 }
amxo_parser_t *PRIVATE xpon_mngr_get_parser(void)
static void handle_fd(int fd, UNUSED void *priv)
Definition: pon_stat.c:190
Here is the call graph for this function:
Here is the caller graph for this function:

◆ watch_file_descriptor_start()

int watch_file_descriptor_start ( UNUSED const char *  function_name,
amxc_var_t *  args,
UNUSED amxc_var_t *  ret 
)

Start monitoring a file descriptor.

Parameters
[in]args: must be of type AMXC_VAR_ID_FD.

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.
  • ...
Returns
0 on success, else -1.

Definition at line 245 of file pon_stat.c.

247  {
248  return watch_file_descriptor_common(args, /*start=*/ true);
249 }
static int watch_file_descriptor_common(amxc_var_t *args, bool start)
Definition: pon_stat.c:201
Here is the call graph for this function:

◆ watch_file_descriptor_stop()

int watch_file_descriptor_stop ( UNUSED const char *  function_name,
amxc_var_t *  args,
UNUSED amxc_var_t *  ret 
)

Stop monitoring a file descriptor.

Parameters
[in]args: must be of type AMXC_VAR_ID_FD.

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.
  • ...
Returns
0 on success, else -1.

Definition at line 264 of file pon_stat.c.

266  {
267  return watch_file_descriptor_common(args, /*start=*/ false);
268 }
Here is the call graph for this function: