19 #include <sys/types.h>
21 #include "rdk_safeclib.h"
23 #include <syscfg/syscfg.h>
25 #include <glib/gprintf.h>
26 #include <glib/gstdio.h>
32 #include <platform_hal.h>
34 #if defined(CLIENT_XCAL_SERVER) && !defined(BROADBAND)
38 #include <arpa/inet.h>
40 gboolean bSerialNum=FALSE;
41 #define BOOL unsigned char
42 #define ACCOUNTID_SIZE 30
45 #ifndef CLIENT_XCAL_SERVER
47 gboolean result = FALSE;
48 gchar* udhcpcvendorfile = NULL;
50 result = g_file_get_contents (
"//etc//udhcpc.vendor_specific", &udhcpcvendorfile, NULL, &error);
51 if (result == FALSE) {
52 g_message(
"Problem in reading /etc/udhcpcvendorfile file %s", error->message);
58 gchar **tokens = g_strsplit_set(udhcpcvendorfile,
" \n\t\b\0", -1);
59 guint toklength = g_strv_length(tokens);
61 for (loopvar=0; loopvar<toklength; loopvar++)
64 if (g_strrstr(g_strstrip(tokens[loopvar]),
"SUBOPTION4"))
66 if ((loopvar+1) < toklength )
68 g_string_assign(ownSerialNo, g_strstrip(tokens[loopvar+2]));
70 g_message(
"serialNumber fetched from udhcpcvendorfile:%s", ownSerialNo->str);
82 g_clear_error(&error);
84 if (udhcpcvendorfile) g_free(udhcpcvendorfile);
87 gboolean result = FALSE;
88 char serialNumber[50] = {0};
89 if ( platform_hal_GetSerialNumber(serialNumber) == 0)
91 g_message(
"serialNumber returned from hal:%s", serialNumber);
92 g_string_assign(ownSerialNo, serialNumber);
98 g_error(
"Unable to get SerialNumber");
104 IARM_Result_t iarmRet = IARM_RESULT_IPCCORE_FAIL;
105 memset(¶m, 0,
sizeof(param));
106 param.
type = mfrSERIALIZED_TYPE_SERIALNUMBER;
108 if(iarmRet == IARM_RESULT_SUCCESS)
112 g_message(
" serialized data %s \n",param.
buffer );
113 g_string_assign(ownSerialNo,param.
buffer);
119 g_message(
" serialized data is empty \n" );
126 g_message(
"IARM CALL failed for mfrtype \n");
131 int getipaddress(
const char *ifname,
char *ipAddressBuffer,gboolean ipv6Enabled)
133 struct ifaddrs *ifAddrStruct = NULL;
134 struct ifaddrs *ifa = NULL;
135 void *tmpAddrPtr = NULL;
136 getifaddrs(&ifAddrStruct);
141 for (ifa = ifAddrStruct; ifa != NULL; ifa = ifa->ifa_next) {
142 if (ifa->ifa_addr == NULL)
continue;
143 if (ipv6Enabled ==
TRUE) {
146 rc = strcmp_s(ifa->ifa_name,strlen(ifa->ifa_name),ifname,&ind);
148 if (((!ind) && (rc == EOK)) && (ifa ->ifa_addr->sa_family == AF_INET6)) {
149 tmpAddrPtr = &((
struct sockaddr_in6 *)ifa->ifa_addr)->sin6_addr;
150 inet_ntop(AF_INET6, tmpAddrPtr, ipAddressBuffer, INET6_ADDRSTRLEN);
151 if (strcmp_s(ifa->ifa_name,strlen(ifa->ifa_name),ifname,&ind)==EOK){
157 if (ifa ->ifa_addr->sa_family == AF_INET) {
159 tmpAddrPtr = &((
struct sockaddr_in *)ifa->ifa_addr)->sin_addr;
160 inet_ntop(AF_INET, tmpAddrPtr, ipAddressBuffer, INET_ADDRSTRLEN);
162 rc = strcmp_s(ifa->ifa_name,strlen(ifa->ifa_name),ifname,&ind);
164 if((!ind) && (rc == EOK)) {
171 if (ifAddrStruct != NULL) freeifaddrs(ifAddrStruct);
174 BOOL check_null(
char *str)
189 BOOL getAccountId(
char *outValue)
191 char temp[ACCOUNTID_SIZE] = {0};
194 rc = syscfg_get(NULL,
"AccountID", temp,
sizeof(temp));
197 if ((outValue != NULL))
199 strncpy(outValue, temp, ACCOUNTID_SIZE-1);
205 g_message(
"getAccountId: Unable to get the Account Id");
210 BOOL getAccountId(
char *outValue)
212 gboolean result = FALSE;
214 RFC_ParamData_t param = {0};
215 WDMP_STATUS status = getRFCParameter(
"XUPNP",
"Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.Feature.AccountInfo.AccountID",¶m);
216 if (status == WDMP_SUCCESS)
218 if (((param.value == NULL)))
220 g_message(
"getAccountId : NULL string !");
225 if (strncpy(outValue,param.value, ACCOUNTID_SIZE-1))
233 g_message(
"getAccountId: getRFCParameter Failed : %s\n", getRFCErrorString(status));
236 g_message(
"Not built with RFC support.");