TR181-XPON
1.4.0
TR-181 PON manager.
|
#include "upgrade_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 <amxc/amxc_string.h>
#include "file_utils.h"
#include "password_constants.h"
#include "persistency.h"
#include "xpon_trace.h"
Go to the source code of this file.
Macros | |
#define | _GNU_SOURCE |
#define | UPGR_STORAGE_DIR_OVERALL "/cfg/system/" |
#define | UPGR_STORAGE_DIR_COMPONENT UPGR_STORAGE_DIR_OVERALL "tr181-xpon/" |
#define | ASCII_PASSWORD_FILE_INDEX 0 |
#define | HEX_PASSWORD_FILE_INDEX 1 |
Functions | |
void | upgr_persistency_init (void) |
void | upgr_persistency_cleanup (void) |
static void | create_password_file_path (const char *const ani_object, bool hex, amxc_string_t *const file_path) |
void | upgr_persistency_set_password (const char *const ani_path, const char *const password, bool hex) |
bool | upgr_persistency_get_password (const char *const ani_path, char *const password, bool *hex) |
Variables | |
static char * | s_upgr_storage_dir = NULL |
#define _GNU_SOURCE |
Define _GNU_SOURCE to avoid following error: implicit declaration of function ‘strdup’
Definition at line 68 of file upgrade_persistency.c.
#define ASCII_PASSWORD_FILE_INDEX 0 |
Definition at line 222 of file upgrade_persistency.c.
#define HEX_PASSWORD_FILE_INDEX 1 |
Definition at line 223 of file upgrade_persistency.c.
#define UPGR_STORAGE_DIR_COMPONENT UPGR_STORAGE_DIR_OVERALL "tr181-xpon/" |
Definition at line 99 of file upgrade_persistency.c.
#define UPGR_STORAGE_DIR_OVERALL "/cfg/system/" |
Folder for upgrade persistent settings.
TODO This folder is hardcoded for now. It must be made configurable.
Definition at line 98 of file upgrade_persistency.c.
|
static |
void upgr_persistency_cleanup | ( | void | ) |
Clean up the part responsible for the upgrade persistent settings.
The plugin must call this function once when stopping.
Definition at line 152 of file upgrade_persistency.c.
bool upgr_persistency_get_password | ( | const char *const | ani_path, |
char *const | password, | ||
bool * | hex | ||
) |
Get the saved password for a certain ANI instance.
[in] | ani_path | path to ANI instance, e.g. "XPON.ONU.1.ANI.1" |
[in,out] | password | the function writes the saved password to this parameter if a saved password for the ANI exists. If no saved password exists, the function does not write to this parameter. The caller must pass a buffer of size MAX_PASSWORD_LEN_PLUS_ONE to ensure this function has enough space to write a password. |
[in,out] | hex | the function sets this parameter to true if the password it writes to password is in hexadecimal format. |
If no saved password exists for the ANI, the function does not update password or hex, and returns true.
Definition at line 242 of file upgrade_persistency.c.
void upgr_persistency_init | ( | void | ) |
Initialize the part responsible for the upgrade persistent settings.
The plugin must call this function once at startup after it has called persistency_init(): if this function can not use the folder for upgrade persistent files, it uses the folder for reboot persistent files created by persistency_init().
Definition at line 112 of file upgrade_persistency.c.
void upgr_persistency_set_password | ( | const char *const | ani_path, |
const char *const | password, | ||
bool | hex | ||
) |
Save the password of a certain ANI instance.
[in] | ani_path | path to ANI instance, e.g. "XPON.ONU.1.ANI.1" |
[in] | password | new value for the parameter Password of the ANI referred to by ani_path |
[in] | hex | if true password is in hexadecimal format; if false, password is in ASCII format. The function only uses this parameter if password is not empty. |
If password is empty, the function removes any files storing the password for the ANI instance.
Definition at line 185 of file upgrade_persistency.c.
|
static |
Definition at line 102 of file upgrade_persistency.c.