From fd932429d3a656fccabcda934932d008dae6e526 Mon Sep 17 00:00:00 2001 From: Omar Date: Thu, 28 Sep 2017 11:14:11 +0100 Subject: [PATCH] Ticket refs #12762: Device will not always send OUI in Inform --- dm/dmtree/common/deviceinfo.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/dm/dmtree/common/deviceinfo.c b/dm/dmtree/common/deviceinfo.c index 70c6c83..9fd4067 100644 --- a/dm/dmtree/common/deviceinfo.c +++ b/dm/dmtree/common/deviceinfo.c @@ -47,14 +47,31 @@ char *get_deviceid_manufactureroui() char str[16]; char *mac = NULL; json_object *res; + FILE *nvrammac=NULL; + char macreadfile[18]={0}; - dmuci_get_option_value_string("cwmp", "cpe", "override_oui", &v); if (v[0] == '\0') { dmubus_call("router.system", "info", UBUS_ARGS{{}}, 0, &res); - if(!(res)) + if(!(res)){ db_get_value_string("hw", "board", "BaseMacAddr", &mac); + if(!mac || strlen(mac)==0 ){ + if ((nvrammac = fopen("/proc/nvram/BaseMacAddr", "r")) == NULL) + { + mac = NULL; + } + else{ + fscanf(nvrammac,"%[^\n]", macreadfile); + macreadfile[17]='\0'; + sscanf(macreadfile,"%2c %2c %2c", str, str+2, str+4); + str[6]='\0'; + v = dmstrdup(str); // MEM WILL BE FREED IN DMMEMCLEAN + fclose(nvrammac); + return v; + } + } + } else mac = dm_ubus_get_value(res, 2, "system", "basemac"); if(mac)