mirror of
https://dev.iopsys.eu/bbf/icwmp.git
synced 2026-02-15 04:19:07 +01:00
Fix db get of deviceid uci options
This commit is contained in:
parent
fc7687de2d
commit
0652f760cd
4 changed files with 15 additions and 5 deletions
8
common.c
8
common.c
|
|
@ -9,6 +9,7 @@
|
|||
*
|
||||
*/
|
||||
#include <getopt.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include "common.h"
|
||||
|
||||
|
|
@ -191,3 +192,10 @@ int cwmp_asprintf(char **s, const char *format, ...)
|
|||
return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool folder_exists(const char *path)
|
||||
{
|
||||
struct stat folder_stat;
|
||||
|
||||
return (stat(path, &folder_stat) == 0 && S_ISDIR(folder_stat.st_mode));
|
||||
}
|
||||
|
|
|
|||
5
config.c
5
config.c
|
|
@ -517,11 +517,16 @@ int global_conf_init(struct config *conf)
|
|||
|
||||
int cwmp_get_deviceid(struct cwmp *cwmp)
|
||||
{
|
||||
if (folder_exists("/lib/db/config"))
|
||||
cwmp_uci_init(UCI_DB_CONFIG);
|
||||
else
|
||||
cwmp_uci_init(UCI_BOARD_DB_CONFIG);
|
||||
cwmp->deviceid.manufacturer = strdup(cwmp_db_get_value_string("device", "deviceinfo", "Manufacturer")); //TODO free
|
||||
cwmp->deviceid.serialnumber = strdup(cwmp_db_get_value_string("device", "deviceinfo", "SerialNumber"));
|
||||
cwmp->deviceid.productclass = strdup(cwmp_db_get_value_string("device", "deviceinfo", "ProductClass"));
|
||||
cwmp->deviceid.oui = strdup(cwmp_db_get_value_string("device", "deviceinfo", "ManufacturerOUI"));
|
||||
cwmp->deviceid.softwareversion = strdup(cwmp_db_get_value_string("device", "deviceinfo", "SoftwareVersion"));
|
||||
cwmp_uci_exit();
|
||||
return CWMP_OK;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -141,15 +141,11 @@ int cwmp_uci_get_option_value_string(char *package, char *section, char *option,
|
|||
|
||||
char *cwmp_db_get_value_string(char *package, char *section, char *option)
|
||||
{
|
||||
struct uci_context *ucictx = uci_alloc_context();
|
||||
|
||||
struct uci_option *o = NULL;
|
||||
struct uci_element *e;
|
||||
struct uci_ptr ptr = { 0 };
|
||||
|
||||
ucictx->confdir = LIB_DB_CONFIG;
|
||||
|
||||
if (cwmp_uci_lookup_ptr(ucictx, &ptr, package, section, option, NULL))
|
||||
if (cwmp_uci_lookup_ptr(cwmp_uci_ctx, &ptr, package, section, option, NULL))
|
||||
return "";
|
||||
|
||||
e = ptr.last;
|
||||
|
|
|
|||
|
|
@ -449,6 +449,7 @@ void cwmp_add_list_param_value(char *param, char *value, struct list_head *list_
|
|||
void cwmp_del_list_param_value(struct cwmp_param_value *param_value);
|
||||
void cwmp_free_all_list_param_value(struct list_head *list_param_value);
|
||||
int cwmp_asprintf(char **s, const char *format, ...);
|
||||
bool folder_exists(const char *path);
|
||||
|
||||
#ifndef FREE
|
||||
#define FREE(x) \
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue