TR181-XPON
1.4.0
TR-181 PON manager.
|
#include "persistency.h"
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#include <amxc/amxc_macros.h>
#include "dm_xpon_mngr.h"
#include "xpon_trace.h"
Go to the source code of this file.
Macros | |
#define | _GNU_SOURCE |
Functions | |
static char * | get_storage_dir (void) |
void | persistency_init (void) |
void | persistency_cleanup (void) |
const char * | persistency_get_folder (void) |
static void | touch_file (const char *const file) |
static void | create_enabled_file_path (amxc_string_t *const file_path, const char *const object) |
void | persistency_enable (const char *const object, bool enable) |
bool | persistency_is_enabled (const char *const object) |
Variables | |
static const char *const | STORAGE_DIR = "/etc/config/tr181-xpon/" |
static char * | s_storage_dir = NULL |
Functionality related to saving and querying the reboot persistent settings. The only read-write parameters in the BBF XPON DM which need to be reboot persistent are:
The object instances do not exist right after the plugin has loaded the odl files defining the DM, and the _defaults.odl file. The plugin creates them afterwards, while querying the state in the HAL, or when it receives a notification from the HAL to create such an instance. Therefore the plugin does not use the odl mechanism (via a _save.odl file) to save and restore the values of the Enable parameters above.
If one of the Enable parameters is set to true, the persistency part creates an empty file in the storage dir of this plugin. E.g., if XPON.ONU.1.Enable is set to true, it creates XPON.ONU.1_enabled.txt. If the plugin after reboot creates the instance XPON.ONU.1, it checks if that file exists to determine if it should set XPON.ONU.1.Enable to true.
Definition in file persistency.c.
#define _GNU_SOURCE |
Define _GNU_SOURCE to avoid following error: implicit declaration of function ‘strdup’
Definition at line 92 of file persistency.c.
|
static |
|
static |
Return the storage dir.
The returned pointer must be freed.
Definition at line 127 of file persistency.c.
void persistency_cleanup | ( | void | ) |
Clean up the persistency part.
The plugin must call this function once when stopping.
Definition at line 198 of file persistency.c.
void persistency_enable | ( | const char *const | object, |
bool | enable | ||
) |
Save whether object is enabled or disabled.
[in] | object | path to object in DM being enabled/disabled, e.g., "XPON.ONU.1" |
[in] | enable | true if object is enabled, else false |
Definition at line 248 of file persistency.c.
const char* persistency_get_folder | ( | void | ) |
Get the folder for reboot persistent settings for this plugin.
It typically returns "/etc/config/tr181-xpon/".
Definition at line 210 of file persistency.c.
void persistency_init | ( | void | ) |
Initialize the persistency part.
Ask the parser for the storage dir. If the parser returns NULL, take STORAGE_DIR as storage dir. Create the storage dir if it does not exist. Store the selected dir in s_storage_dir upon success, else set s_storage_dir to NULL.
Under normal circumstances the parser returns the storage dir, the dir exists, and this function sets s_storage_dir to that value.
The plugin must call this function once at startup.
mkdir() can not create all folders in a path at once. But we assume that all folders except for the last one in s_storage_dir exist. It's also unlikely we end up here. amxrt normally has already created the folder.
Definition at line 161 of file persistency.c.
bool persistency_is_enabled | ( | const char *const | object | ) |
Return true if object identified by 'object' is enabled.
[in] | object | path to object in DM being queried, e.g. "XPON.ONU.1". |
Definition at line 280 of file persistency.c.
|
static |
Touch file if it does not exist yet.
[in] | file | file path |
Definition at line 219 of file persistency.c.
|
static |
Definition at line 118 of file persistency.c.
|
static |
Definition at line 115 of file persistency.c.