PageRenderTime 69ms CodeModel.GetById 25ms RepoModel.GetById 1ms app.codeStats 0ms

/wimax-20110419/InfraStack/OSAgnostic/WiMax/Agents/NDnS/L4_db/NDnSAgent_DB_Common.c

#
C | 3091 lines | 2035 code | 458 blank | 598 comment | 485 complexity | 9985a71b5db6d1946c761a1b2ac2392c MD5 | raw file
Possible License(s): BSD-3-Clause
  1. /**************************************************************************
  2. Copyright (c) 2007-2008, Intel Corporation. All rights reserved.
  3. Redistribution and use in source and binary forms, with or without
  4. modification, are permitted provided that the following conditions are met:
  5. 1. Redistributions of source code must retain the above copyright notice,
  6. this list of conditions and the following disclaimer.
  7. 2. Redistributions in binary form must reproduce the above copyright
  8. notice, this list of conditions and the following disclaimer in the
  9. documentation and/or other materials provided with the distribution.
  10. 3. Neither the name of the Intel Corporation nor the names of its
  11. contributors may be used to endorse or promote products derived from
  12. this software without specific prior written permission.
  13. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  14. AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  15. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  16. ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
  17. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  18. CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  19. SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  20. INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  21. CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  22. ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  23. POSSIBILITY OF SUCH DAMAGE.
  24. ***************************************************************************/
  25. #include "NDnSAgent_DB_Internal.h"
  26. #include "wimax_osal_config_controler.h"
  27. #include "L4ConfigurationManager.h"
  28. #include "wimax_osal_services_cmn.h"
  29. //This file includes the following method groups:
  30. // 1. Init for all of the different structs
  31. // 2. Alloc for "tag named" structs ((Allocates by setting a tag name))
  32. // 3. Get for "tag named" structs ((Gets a struct according to its tag name)).
  33. // 4. NAP ID handling methods
  34. // 5. Generic methods to set different APDO type values.
  35. int l4db_CompareString(const char *str1, const char *str2)
  36. {
  37. int status=0;
  38. if(!str1 || !str2)
  39. return -1;
  40. else
  41. {
  42. if ((status = strcmp(str1, str2))==0)
  43. {
  44. //TRACE(TR_MOD_NDNS_AGENT, TR_SEV_NOTICE, "l4db_CompareString: compared between 2 strings and got TRUE");
  45. }
  46. else
  47. {
  48. //TRACE(TR_MOD_NDNS_AGENT, TR_SEV_ERR, "l4db_CompareString: compared between 2 strings and got not the same.");
  49. }
  50. return status;
  51. }
  52. }
  53. /// <summary>
  54. /// Returns true if the nspId exists in the DB and one of the subscribers is activated
  55. /// </summary>
  56. BOOL l4db_IsHomeNsp(wmx_NSPid_t nspID)
  57. {
  58. pProvisionedNsp_t pFoundNsp;
  59. int i;
  60. size_t tempStrLen = 0;
  61. //check if this NSP is provisioned
  62. pFoundNsp = l4db_GetProvisionedNspById(nspID);
  63. if(NULL == pFoundNsp)
  64. {
  65. //this NSP ID isn't provisioned
  66. return FALSE;
  67. }
  68. //check if this is a home NSP == provisioned but not activated
  69. //check the primary subscription
  70. if(TRUE == pFoundNsp->subscriptionParams.primary.activated)
  71. {
  72. return TRUE;
  73. }
  74. //check the other subscriptions
  75. for(i = 0 ; i < WMX_NSP_SUBSCRIBERS_MAX_NUM ; i++)
  76. {
  77. tempStrLen = OSAL_strnlen(pFoundNsp->subscriptionParams.other[i].tagName, MAX_TAG_NAME_SIZE);
  78. if(0 != tempStrLen && MAX_TAG_NAME_SIZE != tempStrLen)
  79. {
  80. if(TRUE == pFoundNsp->subscriptionParams.other[i].subscriberInfo.activated)
  81. {
  82. return TRUE;
  83. }
  84. }
  85. }
  86. // Non of the subscribers was activated
  87. return FALSE;
  88. }
  89. // Copy the src NAP ID to the dst NAP ID
  90. void l4db_CopyNapID(wmx_NAPid_t srcNapID, wmx_pNAPid_t pDstNapID)
  91. {
  92. if (pDstNapID != NULL)
  93. {
  94. OSAL_memcpy_s(pDstNapID, sizeof(wmx_NAPid_t), srcNapID, sizeof(wmx_NAPid_t));
  95. }
  96. }
  97. /// <summary>
  98. /// Sets the NAP ID to an empty one
  99. /// </summary>
  100. BOOL l4db_SetNapidEmpty(wmx_NAPid_t napID)
  101. {
  102. BOOL rc = FALSE;
  103. if(napID)
  104. {
  105. napID[0] = (UINT8)L4DB_INVALID_INDEX;
  106. napID[1] = (UINT8)L4DB_INVALID_INDEX;
  107. napID[2] = (UINT8)L4DB_INVALID_INDEX;
  108. rc = TRUE;
  109. }
  110. return rc;
  111. }
  112. /// <summary>
  113. /// Checks if two NAP IDs are equal
  114. /// </summary>
  115. BOOL l4db_IsNapidEqualEx(wmx_NAPid_t napID1,wmx_NAPid_t napID2, wmx_BsIdType_t napIdType)
  116. {
  117. BOOL rc = FALSE;
  118. if(napID1 && napID2)
  119. {
  120. switch(napIdType)
  121. {
  122. case COMPRESSED_BSID:
  123. case COMPRESSED_NAP:
  124. rc = (napID1[2] == napID2[2]);
  125. break;
  126. case FULL_BSID:
  127. case FULL_NAP:
  128. default:
  129. rc = ((napID1[0] == napID2[0]) &&
  130. (napID1[1] == napID2[1])&&
  131. (napID1[2] == napID2[2]));
  132. break;
  133. }
  134. }
  135. return rc;
  136. }
  137. /// <summary>
  138. /// Checks if FULL two NAP IDs are equal
  139. /// </summary>
  140. BOOL l4db_IsNapidEqual(wmx_NAPid_t napID1,wmx_NAPid_t napID2)
  141. {
  142. return l4db_IsNapidEqualEx(napID1, napID2, FULL_NAP);
  143. }
  144. /// <summary>
  145. /// Converts NAPId int to a NAPId type
  146. /// </summary>
  147. /// <returns>void</returns>
  148. void l4db_ConvertNapIdIntToNapIdType(wmx_NAPid_t pNapId,int IntNapId)
  149. {
  150. UINT32 napID;
  151. if(NULL == pNapId)
  152. {
  153. return;
  154. }
  155. napID = IntNapId;
  156. pNapId[2] = (UINT8)(napID & 0xff);
  157. napID >>= 8;
  158. pNapId[1] = (UINT8)(napID & 0xff);
  159. napID >>= 8;
  160. pNapId[0] = (UINT8)(napID & 0xff);
  161. }
  162. /// <summary>
  163. /// Converts NAPId type to a NAPId int
  164. /// </summary>
  165. /// <returns>void</returns>
  166. void l4db_ConvertNapIdTypeToNapIdInt(wmx_NAPid_t pNapId, int * IntNapId)
  167. {
  168. if(NULL == pNapId)
  169. {
  170. return;
  171. }
  172. *IntNapId = 0;
  173. *IntNapId |= pNapId[0];
  174. *IntNapId <<= 8;
  175. *IntNapId |= pNapId[1];
  176. *IntNapId <<= 8;
  177. *IntNapId |= pNapId[2];
  178. }
  179. /// <summary>
  180. /// Converts NAPId string to NAPId
  181. /// </summary>
  182. /// <returns>void</returns>
  183. void l4db_ConvertNapIdStrToNapIdType(wmx_NAPid_t pNapId, const char *str)
  184. {
  185. UINT32 napID;
  186. if((NULL == pNapId) || (NULL == str))
  187. {
  188. return;
  189. }
  190. OSAL_sscanf_s(str, "%x", &napID);
  191. l4db_ConvertNapIdIntToNapIdType(pNapId,napID);
  192. }
  193. /// <summary>
  194. /// Converts NAPId value to string
  195. /// </summary>
  196. /// <returns>void</returns>
  197. void l4db_ConvertNapIdToStr(wmx_NAPid_t pNapId, char *str)
  198. {
  199. UINT32 napID;
  200. if((NULL == pNapId) || (NULL == str))
  201. {
  202. return;
  203. }
  204. napID = 0;
  205. napID = pNapId[0];
  206. napID <<= 8;
  207. napID |= pNapId[1];
  208. napID <<= 8;
  209. napID |= pNapId[2];
  210. OSAL_itoa_s(napID, str, 10, 16);
  211. }
  212. /// <summary>
  213. /// Converts a bollean value from string to BOOL
  214. /// </summary>
  215. UINT8 l4db_ConvertToBoolVal(const char* val)
  216. {
  217. if((FALSE == l4db_CompareString(val, L4DB_XML_TRUE_STR)) ||
  218. (FALSE == l4db_CompareString(val, L4DB_XML_ONE_STR)))
  219. {
  220. return TRUE;
  221. }
  222. else
  223. {
  224. return FALSE;
  225. }
  226. }
  227. /// <summary>
  228. /// Returns TRUE if the NSP ID== NAP ID bit is set
  229. /// </summary>
  230. /// <param name="napID">(IN) napID to check</<param>
  231. BOOL l4db_TestNapIdNspIdBit(wmx_BSid_t bsID)
  232. {
  233. if ((bsID[4] & 0x80) > 0) // The msb of the 4th byte
  234. {
  235. return TRUE;
  236. }
  237. return FALSE;
  238. }
  239. /// <summary>
  240. /// Returns TRUE if the NAP ID== NSP ID bit is set and the IDs are equal
  241. /// </summary>
  242. /// <param name="napID">(IN) napID to compare</<param>
  243. /// <param name="nspID">(IN) nspID to compare</<param>
  244. BOOL l4db_CompareNapIdNspId(wmx_BSid_t bsID, wmx_NSPid_t nspID)
  245. {
  246. int napIdInt;
  247. if (l4db_TestNapIdNspIdBit(bsID) == TRUE)
  248. {
  249. l4db_ConvertNapIdTypeToNapIdInt(bsID, &napIdInt); // Take only the first 3 bytes
  250. if (nspID == (wmx_NSPid_t)napIdInt)
  251. {
  252. return TRUE;
  253. }
  254. }
  255. return FALSE;
  256. }
  257. /// <summary>
  258. /// Copy string value from psDst to psSrc or otherwise according to cmd
  259. /// </summary>
  260. /// <param name="psDst">first string
  261. /// <param name="len">length of buffer to copy to
  262. /// <param name="psSrc">second string
  263. /// <param name="pBufferSize"> INOUT pointer for second string length.
  264. // If it's get command the function will set the length of the output string. If command is != GET the parm can be NULL
  265. /// <param name="APDOType"> should be APDO_String!!!!
  266. /// <param name="cmd"> if cmd is "GET" we will copy SRC->DST otherwise we will copy DST->SRC
  267. /// <returns>wmx_Status_t</returns>
  268. wmx_Status_t l4db_SetStringValueNew(char *pDBData,
  269. size_t DbLen,
  270. char *psSrc,
  271. int *pSrcSize,
  272. wmx_pAPDOType_t pAPDOType,
  273. apdo_DbCmd_t cmd)
  274. {
  275. wmx_Status_t rc = WMX_ST_FAIL;
  276. if((NULL == pDBData) || (NULL == psSrc))
  277. {
  278. TRACE(TR_MOD_NDNS_AGENT, TR_SEV_ERR, "l4db_SetStringValueNew pDBData or str are NULL");
  279. return WMX_ST_FAIL;
  280. }
  281. switch(cmd)
  282. {
  283. case APDO_AddCmd: // DB Add command
  284. case APDO_UpdateCmd: // DB update command
  285. if(NULL == pAPDOType)
  286. {
  287. TRACE(TR_MOD_NDNS_AGENT, TR_SEV_ERR, "l4db_SetStringValueNew pAPDOType is NULL");
  288. return WMX_ST_FAIL;
  289. }
  290. if (APDO_String != *pAPDOType)
  291. {
  292. TRACE(TR_MOD_NDNS_AGENT, TR_SEV_ERR, "l4db_SetStringValueNew pAPDOType is not an APDO_String");
  293. return WMX_ST_FAIL;
  294. }
  295. if(DbLen <= (size_t)OSAL_strnlen(psSrc, MAX_STRING_VALIDATE))//TODO - change this after we stop passing dummystrlen
  296. {
  297. //buffer is to small
  298. return WMX_ST_FAIL;
  299. }
  300. OSAL_strncpy_s(pDBData, DbLen, psSrc, *pSrcSize);
  301. pDBData[DbLen -1 ]= '\0';
  302. rc = WMX_ST_OK;
  303. break;
  304. case APDO_GetCmd: // DB get command
  305. if((NULL == pAPDOType) || (NULL == pSrcSize))
  306. {
  307. TRACE(TR_MOD_NDNS_AGENT, TR_SEV_ERR, "l4db_SetStringValueNew pAPDOType or pSrcSize are NULL");
  308. return WMX_ST_FAIL;
  309. }
  310. OSAL_strncpy_s(psSrc, *pSrcSize, pDBData, DbLen);
  311. psSrc[*pSrcSize -1 ]='\0';
  312. *pSrcSize = (UINT32)OSAL_strnlen(psSrc, MAX_STRING_VALIDATE);
  313. *pAPDOType = APDO_String;
  314. rc = WMX_ST_OK;
  315. break;
  316. case APDO_DeleteCmd: // DB delete command
  317. pDBData[0] = '\0';
  318. rc = WMX_ST_OK;
  319. break;
  320. }
  321. return rc;
  322. }
  323. /// <summary>
  324. /// According of command will copy string->int or int->string
  325. /// </summary>
  326. /// <param name="psDst"> String value
  327. /// <param name="pdwInt"> pointer to int value
  328. /// <param name="pDstSize"> INOUT pointer for second string length.
  329. // If it's get command the function will set the length of the output string. If command is != GET the parm can be NULL
  330. /// <param name="cmd"> if cmd is "GET" we will copy psDst->pdwInt otherwise we will copy pdwInt->psDst
  331. /// <returns>wmx_Status_t</returns>
  332. wmx_Status_t l4db_SetIntegerValueNew(int *pDBData,
  333. int *pDstSize,
  334. int *pdwInData,
  335. wmx_pAPDOType_t pAPDOType,
  336. apdo_DbCmd_t cmd)
  337. {
  338. int sizeOfArg = sizeof(int);
  339. wmx_Status_t rc = WMX_ST_FAIL;
  340. if((NULL == pDBData) || (NULL == pdwInData))
  341. {
  342. TRACE(TR_MOD_NDNS_AGENT, TR_SEV_ERR, "l4db_SetIntegerValueNew pDBData or pdwInData are NULL");
  343. return rc;
  344. }
  345. switch(cmd)
  346. {
  347. case APDO_AddCmd: // DB Add command
  348. case APDO_UpdateCmd: // DB update command
  349. if((NULL == pAPDOType) || ((*pAPDOType != APDO_Integer) && (*pAPDOType != APDO_String)))
  350. {
  351. TRACE(TR_MOD_NDNS_AGENT, TR_SEV_ERR, "l4db_SetIntegerValueNew pAPDOType is NULL or not APDO_Integer");
  352. return rc;
  353. }
  354. if(*pAPDOType == APDO_Integer)
  355. {
  356. *pDBData = *pdwInData;
  357. }
  358. else //redbend support only strings
  359. {
  360. *pDBData = atoi((char*)pdwInData);
  361. }
  362. rc = WMX_ST_OK;
  363. break;
  364. case APDO_GetCmd: // DB get command
  365. if((NULL == pAPDOType) || (NULL == pDstSize))
  366. {
  367. TRACE(TR_MOD_NDNS_AGENT, TR_SEV_ERR, "l4db_SetIntegerValueNew pAPDOType or pDstSrcSize are NULL");
  368. return rc;
  369. }
  370. if(*pDstSize >= sizeOfArg)
  371. {
  372. *pAPDOType = APDO_Integer;
  373. *pDstSize = sizeOfArg;
  374. *pdwInData = *pDBData;
  375. rc = WMX_ST_OK;
  376. }
  377. break;
  378. case APDO_DeleteCmd: // DB delete command
  379. *pDBData = 0;
  380. rc = WMX_ST_OK;
  381. break;
  382. }
  383. return rc;
  384. }
  385. /// <summary>
  386. /// According of command will copy string->double or double->string
  387. /// </summary>
  388. /// <param name="psDst"> String value
  389. /// <param name="pDstSize"> INOUT pointer for second string length.
  390. // If it's get command the function will set the length of the output string. If command is != GET the parm can be NULL
  391. /// <param name="pdwDouble"> pointer to double value
  392. /// <param name="cmd"> if cmd is "GET" we will copy psDst->pdwDouble otherwise we will copy pdwDouble->psDst
  393. /// <returns>wmx_Status_t</returns>
  394. wmx_Status_t l4db_SetDoubleValueNew(double *pDBData,
  395. int *pDstSize,
  396. double * pdwInData,
  397. wmx_pAPDOType_t pAPDOType,
  398. apdo_DbCmd_t cmd)
  399. {
  400. int sizeOfArg = sizeof(double);
  401. wmx_Status_t rc = WMX_ST_FAIL;
  402. if((NULL == pDBData) || (NULL == pdwInData))
  403. {
  404. TRACE(TR_MOD_NDNS_AGENT, TR_SEV_ERR, "l4db_SetDoubleValueNew pDBData or pdwInData are NULL");
  405. return rc;
  406. }
  407. switch(cmd)
  408. {
  409. case APDO_AddCmd: // DB Add command
  410. case APDO_UpdateCmd: // DB update command
  411. if((NULL == pAPDOType) || (*pAPDOType != APDO_Double))
  412. {
  413. TRACE(TR_MOD_NDNS_AGENT, TR_SEV_ERR, "l4db_SetDoubleValueNew pAPDOType is NULL or not APDO_Double");
  414. return rc;
  415. }
  416. *pDBData = *pdwInData;
  417. rc = WMX_ST_OK;
  418. break;
  419. case APDO_GetCmd: // DB get command
  420. if((NULL == pAPDOType) || (NULL == pDstSize))
  421. {
  422. TRACE(TR_MOD_NDNS_AGENT, TR_SEV_ERR, "l4db_SetDoubleValueNew pAPDOType or pDstSize are NULL");
  423. return rc;
  424. }
  425. if(*pDstSize >= sizeOfArg)
  426. {
  427. *pAPDOType = APDO_Double;
  428. *pDstSize = sizeOfArg;
  429. *pdwInData = *pDBData;
  430. rc = WMX_ST_OK;
  431. }
  432. break;
  433. case APDO_DeleteCmd: // DB delete command
  434. *pDBData = 0;
  435. rc = WMX_ST_OK;
  436. break;
  437. }
  438. return rc;
  439. }
  440. /// <summary>
  441. /// According of command will copy string->bool or bool->string
  442. /// </summary>
  443. /// <param name="psDst"> String value
  444. /// <param name="pDstSize"> INOUT pointer for second string length.
  445. // If it's get command the function will set the length of the output string. If command is != GET the parm can be NULL
  446. /// <param name="pdwBool"> pointer to BOOL value
  447. /// <param name="cmd"> if cmd is "GET" we will copy psDst->pdwBool otherwise we will copy pdwBool->psDst
  448. /// <returns>wmx_Status_t</returns>
  449. wmx_Status_t l4db_SetBoolValueNew(BOOL *pDBData,
  450. int *pDstSize,
  451. BOOL* pdwInData,
  452. wmx_pAPDOType_t pAPDOType,
  453. apdo_DbCmd_t cmd)
  454. {
  455. int sizeOfArg = sizeof(BOOL);
  456. wmx_Status_t rc = WMX_ST_FAIL;
  457. if((NULL == pDBData) || (NULL == pdwInData))
  458. {
  459. TRACE(TR_MOD_NDNS_AGENT, TR_SEV_ERR, "l4db_SetBoolValueNew pDBData or pdwInData are NULL");
  460. return rc;
  461. }
  462. switch(cmd)
  463. {
  464. case APDO_AddCmd: // DB Add command
  465. case APDO_UpdateCmd: // DB update commandm
  466. if((NULL == pAPDOType) || ((*pAPDOType != APDO_Bool) && (*pAPDOType != APDO_String)))
  467. {
  468. TRACE(TR_MOD_NDNS_AGENT, TR_SEV_ERR, "l4db_SetBoolValueNew pAPDOType is NULL or not APDO_Bool");
  469. return rc;
  470. }
  471. if(*pAPDOType == APDO_Bool)
  472. {
  473. *pDBData = *pdwInData;
  474. }
  475. else
  476. {
  477. *pDBData = l4db_ConvertToBoolVal((const char *)pdwInData);
  478. }
  479. rc = WMX_ST_OK;
  480. break;
  481. case APDO_GetCmd: // DB get command
  482. if((NULL == pAPDOType) || (NULL == pDstSize))
  483. {
  484. TRACE(TR_MOD_NDNS_AGENT, TR_SEV_ERR, "l4db_SetBoolValueNew pAPDOType or pDstSize are NULL");
  485. return rc;
  486. }
  487. if(*pDstSize >= sizeOfArg)
  488. {
  489. *pAPDOType = APDO_Bool;
  490. *pDstSize = sizeOfArg;
  491. *pdwInData = *pDBData;
  492. rc = WMX_ST_OK;
  493. }
  494. break;
  495. case APDO_DeleteCmd: // DB delete command
  496. *pDBData = 0;
  497. rc = WMX_ST_OK;
  498. break;
  499. }
  500. return rc;
  501. }
  502. /// <summary>
  503. /// According of command will copy string->double or double->string
  504. /// </summary>
  505. /// <param name="psDst"> String value
  506. /// <param name="pDstSize"> INOUT pointer for second string length.
  507. // If it's get command the function will set the length of the output string. If command is != GET the parm can be NULL
  508. /// <param name="pdwDouble"> pointer to double value
  509. /// <param name="cmd"> if cmd is "GET" we will copy psDst->pdwDouble otherwise we will copy pdwDouble->psDst
  510. /// <returns>pointer for wmx_pNSPFullData_t which we allocated or NULL if error </returns>
  511. wmx_Status_t l4db_SetFloatValueNew(float *pDBData,
  512. int *pDstSize,
  513. float * pdwInData,
  514. wmx_pAPDOType_t pAPDOType,
  515. apdo_DbCmd_t cmd)
  516. {
  517. int sizeOfArg = sizeof(float);
  518. wmx_Status_t rc = WMX_ST_FAIL;
  519. if((NULL == pDBData) || (NULL == pdwInData))
  520. {
  521. TRACE(TR_MOD_NDNS_AGENT, TR_SEV_ERR, "l4db_SetFloatValueNew pDBData or pdwInData are NULL");
  522. return rc;
  523. }
  524. switch(cmd)
  525. {
  526. case APDO_AddCmd: // DB Add command
  527. case APDO_UpdateCmd: // DB update command
  528. if((NULL == pAPDOType) || (*pAPDOType != APDO_Bool))
  529. {
  530. TRACE(TR_MOD_NDNS_AGENT, TR_SEV_ERR, "l4db_SetFloatValueNew pAPDOType is NULL or not APDO_Float");
  531. return rc;
  532. }
  533. *pDBData = *pdwInData;
  534. rc = WMX_ST_OK;
  535. break;
  536. case APDO_GetCmd: // DB get command
  537. if((NULL == pAPDOType) || (NULL == pDstSize))
  538. {
  539. TRACE(TR_MOD_NDNS_AGENT, TR_SEV_ERR, "l4db_SetFloatValueNew pAPDOType or pDstSize are NULL");
  540. return rc;
  541. }
  542. if(*pDstSize >= sizeOfArg)
  543. {
  544. *pAPDOType = APDO_Float;
  545. *pDstSize = sizeOfArg;
  546. *pdwInData = *pDBData;
  547. rc = WMX_ST_OK;
  548. }
  549. break;
  550. case APDO_DeleteCmd: // DB delete command
  551. *pDBData = 0;
  552. rc = WMX_ST_OK;
  553. break;
  554. }
  555. return rc;
  556. }
  557. /// <summary>
  558. /// Converts UINT32 value to BOOL string
  559. /// </summary>
  560. /// <returns>pointer to "True" or "False" string</returns>
  561. void l4db_GetBoolStr(BOOL value, char * boolStr)
  562. {
  563. if(TRUE == value)
  564. {
  565. OSAL_strcpy_s(boolStr, strlen(L4DB_XML_TRUE_STR) + 1, L4DB_XML_TRUE_STR);
  566. }
  567. else
  568. {
  569. OSAL_strcpy_s(boolStr, strlen(L4DB_XML_FALSE_STR) + 1, L4DB_XML_FALSE_STR);
  570. }
  571. }
  572. /// <summary>
  573. /// Get tokens from input path
  574. /// </summary>
  575. /// <param name="psPath">(IN) pointer to current place in path
  576. /// <param name="psToken">(OUT) output of token string (if we found)
  577. /// <param name="psTokenValue">(OUT) output of token value (if we found)
  578. /// <returns>pointer for next place in path </returns>
  579. char* l4db_GetTokensFromPath(IN char *psPath,
  580. char** psToken,
  581. char** psTokenValue)
  582. {
  583. // here is example of valid path
  584. // "/NSP/2/NetworkParameters/NSP_name=Sprint/"
  585. int i = 0;
  586. char* nextPath = NULL;
  587. if((NULL == psToken) || (NULL == psTokenValue))
  588. {
  589. TRACE(TR_MOD_NDNS_AGENT, TR_SEV_ERR, "l4db_GetTokensFromPath psToken or psTokenValue are NULL");
  590. return nextPath;
  591. }
  592. *psToken = C_L4DB_EMPTY_STRING;
  593. *psTokenValue = C_L4DB_EMPTY_STRING;
  594. if(NULL == psPath)
  595. {
  596. return NULL;
  597. }
  598. while(psPath[i] == '/')
  599. {
  600. i++;
  601. }
  602. // Set the token pointer
  603. *psToken = &psPath[i];
  604. while(psPath[i] && (psPath[i] != '/'))
  605. {
  606. if(psPath[i] == '=')
  607. {
  608. // we found valType
  609. psPath[i] = '\0';
  610. i++;
  611. // set value of token value
  612. *psTokenValue = &psPath[i];
  613. }
  614. i++;
  615. }
  616. if(psPath[i] == '/')
  617. {
  618. psPath[i] = '\0';
  619. i++;
  620. nextPath = &psPath[i];
  621. }
  622. if((NULL != nextPath) && (0 == nextPath[0]))
  623. {
  624. nextPath = NULL;
  625. }
  626. return nextPath;
  627. }
  628. /// <summary>
  629. /// Init a channel info with default values
  630. /// </summary>
  631. void l4db_InitChannelInfo(pChannelInfo_t pChannelInfo)
  632. {
  633. //init the tag name
  634. pChannelInfo->tagName[0] = '\0';
  635. pChannelInfo->id[0] = '\0';
  636. pChannelInfo->bw = L4DB_INVALID_INDEX;
  637. pChannelInfo->duplexMode = (wmx_DuplexMode_t)L4DB_INVALID_INDEX;
  638. pChannelInfo->fft = (UINT32)L4DB_INVALID_INDEX;
  639. pChannelInfo->firstFreq = (UINT32)L4DB_INVALID_INDEX;
  640. pChannelInfo->lastFreq = (UINT32)L4DB_INVALID_INDEX;
  641. pChannelInfo->nextFreq = 10000; //(wmx_NextFreqStep_t)L4DB_INVALID_INDEX;
  642. pChannelInfo->ttl = 0;
  643. pChannelInfo->lastFoundInNbrAdv = FALSE;
  644. memset(pChannelInfo->preambleBitmap, 0xFF, PREAMBLES_LENGTH);
  645. }
  646. /// <summary>
  647. /// Init a channel plan with default values
  648. /// </summary>
  649. void l4db_InitChannelPlan(pChannelPlan_t pChannelPlan)
  650. {
  651. int i;
  652. for(i = 0 ; i < WMX_CHANNELS_MAX_NUM ; i++)
  653. {
  654. l4db_InitChannelInfo(&pChannelPlan->channels[i]);
  655. }
  656. for(i = 0 ; i < WMX_CHANNELS_MAX_NUM ; i++)
  657. {
  658. pChannelPlan->linkQuality[i] = 0;
  659. }
  660. pChannelPlan->bw = L4DB_INVALID_INDEX;
  661. pChannelPlan->fft = L4DB_INVALID_INDEX;
  662. pChannelPlan->duplexMode = (wmx_DuplexMode_t)L4DB_INVALID_INDEX;
  663. pChannelPlan->channelsSize = 0;
  664. }
  665. /// <summary>
  666. /// Init a channel ref with default values
  667. /// </summary>
  668. void l4db_InitChannelRef(pChPlanRefId_t pChannelRef)
  669. {
  670. pChannelRef->id[0] = '\0';
  671. pChannelRef->tagName[0] = '\0';
  672. }
  673. /// <summary>
  674. /// Init a NAP with default values
  675. /// </summary>
  676. void l4db_InitNap(pL4db_Nap_t pNap)
  677. {
  678. int i;
  679. //set the NAP id to an empty Id
  680. l4db_SetNapidEmpty((wmx_pNAPid_t)&pNap->napID);
  681. //init the priority
  682. pNap->priority = (wmx_Priority_t)L4DB_INVALID_INDEX;
  683. //init the tag name
  684. pNap->tagName[0] = '\0';
  685. //init the change count
  686. pNap->changeCount = (UINT32)L4DB_INVALID_INDEX;
  687. //init the channel plan
  688. for(i = 0 ; i < WMX_CHANNELS_MAX_NUM ; i++)
  689. {
  690. l4db_InitChannelRef(&pNap->channelPlanRefIds[i]);
  691. }
  692. pNap->channelRefsSize = 0;
  693. //init the channel plan
  694. l4db_InitChannelPlan(&pNap->discoveredChannelPlan);
  695. }
  696. /// <summary>
  697. /// Init a roaming info with default values
  698. /// </summary>
  699. void l4db_InitRoamingInfo(pRoamingPartnerInfo_t pRoamingInfo)
  700. {
  701. //init the tag name
  702. pRoamingInfo->tagName[0] = '\0';
  703. //init the V_NSP ID
  704. pRoamingInfo->vNspID = (wmx_NSPid_t)L4DB_INVALID_INDEX;
  705. pRoamingInfo->priority = (wmx_Priority_t)L4DB_INVALID_INDEX;
  706. }
  707. /// <summary>
  708. /// Init an srv realm with default values - NOT SUPPORTED NOW
  709. /// </summary>
  710. void l4db_InitSrvRealm(pSrvRealm_t pSrvRealm)
  711. {
  712. //init the tag name
  713. pSrvRealm->tagName[0] = '\0';
  714. pSrvRealm->srvRealm[0] = '\0';
  715. }
  716. /// <summary>
  717. /// Init a cert info with default values
  718. /// </summary>
  719. void l4db_InitCertInfo(pCert_t pCert)
  720. {
  721. //init the tag name
  722. pCert->tagName[0] = '\0';
  723. //pCert->certType = L4DB_INVALID_INDEX;
  724. pCert->certType[0] = '\0';
  725. pCert->serNum[0] = '\0';
  726. pCert->issuer[0] = '\0';
  727. //pCert->thumbPrint = (UINT32)L4DB_INVALID_INDEX; //NOT SUPPORTED NOW
  728. }
  729. /// <summary>
  730. /// Init an EAP info with default values
  731. /// </summary>
  732. void l4db_InitEapInfo(pEAP_t pEap)
  733. {
  734. int i;
  735. pEap->tagName[0] = '\0';
  736. pEap->id[0] = '\0';
  737. pEap->provisionedPseudoId[0] = '\0';
  738. pEap->vendorId = (UINT32)L4DB_INVALID_INDEX;
  739. pEap->vendorType = (UINT32)L4DB_INVALID_INDEX;
  740. pEap->EAPMethod = (UINT32)L4DB_INVALID_INDEX;
  741. pEap->encaps = (UINT32)L4DB_INVALID_INDEX;
  742. pEap->id[0] = '\0';
  743. pEap->Password[0] = '\0';
  744. pEap->realm[0] = '\0';
  745. pEap->usePrivacy = FALSE;
  746. pEap->vfySrvRealm = L4DB_INVALID_INDEX;
  747. //init the srv realms - NOT SUPPORTED NOW
  748. for(i = 0 ; i < MAX_NUM_OF_SRV_REALMS ; i++)
  749. {
  750. l4db_InitSrvRealm(&pEap->srvRealms[i]);
  751. }
  752. pEap->srvRealmsSize = 0;
  753. for(i = 0 ; i < MAX_NUM_OF_CERTS ; i++)
  754. {
  755. l4db_InitCertInfo(&pEap->certs[i]);
  756. }
  757. pEap->certsSize = 0;
  758. }
  759. /// <summary>
  760. /// Init a primary subscription info with default values
  761. /// </summary>
  762. void l4db_InitPrimarySubscription(pSubscriberInfo_t pSubscriptionInfo)
  763. {
  764. int i;
  765. pSubscriptionInfo->name[0] = '\0';
  766. pSubscriptionInfo->activated = FALSE;
  767. for(i = 0 ; i < MAX_NUM_OF_EAP_METHODS ; i++)
  768. {
  769. l4db_InitEapInfo(&pSubscriptionInfo->eapInfo[i]);
  770. }
  771. pSubscriptionInfo->eapInfoSize = 0;
  772. }
  773. /// <summary>
  774. /// Init a primary subscription info with default values
  775. /// </summary>
  776. void l4db_InitOtherSubscription(pOtherSubsInfo_t pSubscriptionInfo)
  777. {
  778. int i;
  779. //init the tag name
  780. pSubscriptionInfo->tagName[0] = '\0';
  781. pSubscriptionInfo->subscriberInfo.name[0] = '\0';
  782. pSubscriptionInfo->subscriberInfo.activated = FALSE;
  783. //init the EAP entries
  784. for(i = 0 ; i < MAX_NUM_OF_EAP_METHODS ; i++)
  785. {
  786. l4db_InitEapInfo(&pSubscriptionInfo->subscriberInfo.eapInfo[i]);
  787. }
  788. pSubscriptionInfo->subscriberInfo.eapInfoSize = 0;
  789. }
  790. /// <summary>
  791. /// Init the subscription parameters
  792. /// </summary>
  793. void l4db_InitSubscriptionParams(pSubscriptionParams_t pSubscriptionParams)
  794. {
  795. int i;
  796. l4db_InitPrimarySubscription(&pSubscriptionParams->primary);
  797. //init the other subscription
  798. for(i = 0 ; i < WMX_NSP_SUBSCRIBERS_MAX_NUM ; i++)
  799. {
  800. l4db_InitOtherSubscription(&pSubscriptionParams->other[i]);
  801. }
  802. pSubscriptionParams->otherSize = 0;
  803. }
  804. /// <summary>
  805. /// Init HNSP with default values
  806. /// </summary>
  807. void l4db_InitHnsp(pHomeNsp_t pHnsp)
  808. {
  809. //set the H NSP ID's to an invalid value
  810. pHnsp->nspId = (wmx_NSPid_t) L4DB_INVALID_INDEX;
  811. pHnsp->tagName[0] = '\0';
  812. }
  813. /// <summary>
  814. /// Init RAPL params with default values
  815. /// </summary>
  816. void l4db_InitRapl(pRapl_t pRapl)
  817. {
  818. int i;
  819. for(i = 0 ; i < MAX_ROAMING_PARTNERS ; i++)
  820. {
  821. l4db_InitRoamingInfo(&pRapl->roamingPartners[i]);
  822. }
  823. pRapl->roamingPartnersSize = 0;
  824. pRapl->any = ListFirst;
  825. pRapl->selectPolicy = spStrict;
  826. }
  827. /// <summary>
  828. /// Init capl with default values
  829. /// </summary>
  830. void l4db_InitCapl(pCapl_t pCapl)
  831. {
  832. int i;
  833. for(i = 0 ; i < WMX_NAPS_MAX_NUM ; i++)
  834. {
  835. l4db_InitNap(&pCapl->naps[i]);
  836. }
  837. pCapl->napsSize = 0;
  838. pCapl->any = ListFirst;
  839. pCapl->selectPolicy = spStrict;
  840. }
  841. /// <summary>
  842. /// Init NW params with default values
  843. /// </summary>
  844. void l4db_InitNwParams(pNwParams_t pNwParams)
  845. {
  846. int i;
  847. //sets the NSPs names to be an empty string
  848. pNwParams->provisionedName[0] = '\0';
  849. pNwParams->name16g[0] = '\0';
  850. pNwParams->serverID[0] = '\0';
  851. //Init H NSPs
  852. for(i = 0 ; i < WMX_NSP_IDS_MAX_NUM ; i++)
  853. {
  854. l4db_InitHnsp(& pNwParams->hNsps[i]);
  855. }
  856. pNwParams->hNspsSize = 0;
  857. //init the default channel plan
  858. l4db_InitChannelPlan(&pNwParams->channelPlan);
  859. //init the CAPL
  860. l4db_InitCapl(&pNwParams->capl);
  861. //init the RAPL
  862. l4db_InitRapl(&pNwParams->rapl);
  863. //init the polling interval
  864. pNwParams->pollingInterval = -1; //the device SHALL perform ONLY ONE client initiated management session to the
  865. //OMA-DM server, following the time the device obtains an IP address from the operator???s network.
  866. pNwParams->pollingAttempts = 10; // If polling attempts will be enabled we use this value to do 10 retries for client initiated.
  867. }
  868. /// <summary>
  869. /// Init one Contact info with default values
  870. /// </summary>
  871. void l4db_InitContactInfo(pContactsInfo_t pContactInfo)
  872. {
  873. pContactInfo->uri[0] = '\0';
  874. pContactInfo->text[0] = '\0';
  875. pContactInfo->tagName[0] = '\0';
  876. pContactInfo->uriType = (UINT32)L4DB_INVALID_INDEX;
  877. }
  878. /// <summary>
  879. /// Init pNSP with default values
  880. /// </summary>
  881. void l4db_InitNsp(pProvisionedNsp_t pNsp)
  882. {
  883. int i;
  884. memset(pNsp, 0x0, sizeof(*pNsp));
  885. //state the this NSP has been initialized
  886. pNsp->fIsAllocated = TRUE;
  887. pNsp->tagName[0] = '\0';
  888. l4db_InitNwParams(&pNsp->nwParams);
  889. //init the contacts
  890. for(i = 0 ; i < MAX_NUM_OF_CONTACTS ; i++)
  891. {
  892. l4db_InitContactInfo(&pNsp->contacts[i]);
  893. }
  894. //init the primary subscription info
  895. l4db_InitPrimarySubscription(&pNsp->subscriptionParams.primary);
  896. //init the other subscription
  897. for(i = 0 ; i < WMX_NSP_SUBSCRIBERS_MAX_NUM ; i++)
  898. {
  899. l4db_InitOtherSubscription(&pNsp->subscriptionParams.other[i]);
  900. }
  901. pNsp->subscriptionParams.otherSize = 0;
  902. }
  903. /// <summary>
  904. /// Init a 16g NSP info struct
  905. /// </summary>
  906. void l4db_InitNsp16gInfo(pNspInfo_16G pNsp16gInfo)
  907. {
  908. pNsp16gInfo->name[0] = '\0';
  909. pNsp16gInfo->nspID = (wmx_NSPid_t)L4DB_INVALID_INDEX;
  910. pNsp16gInfo->visitedRealm[0] = '\0';
  911. }
  912. /// <summary>
  913. /// Init a discovered NAP
  914. /// </summary>
  915. void l4db_InitDiscoveredNap(pDiscoveredNap_t pNap)
  916. {
  917. int i;
  918. //set the NAP ID to be an empty ID
  919. l4db_SetNapidEmpty((wmx_pNAPid_t)&pNap->napID);
  920. pNap->isLastDetected = FALSE;
  921. //set all NSP IDs to an invalid index
  922. for(i = 0 ; i < ARRAY_SIZE(pNap->nspInfo) ; i++)
  923. {
  924. l4db_InitNsp16gInfo(&pNap->nspInfo[i]);
  925. }
  926. //init the change count
  927. pNap->changeCount = (UINT32)L4DB_INVALID_INDEX;
  928. pNap->nspInfoSize = 0;
  929. //init the channel plan
  930. l4db_InitChannelPlan(&pNap->channelPlan);
  931. }
  932. /// <summary>
  933. /// Init the general Nds settings
  934. /// </summary>
  935. void l4db_InitGeneralSettings(pNdsSettings_t pSettings)
  936. {
  937. int i;
  938. //Init the unprovisioned profiles
  939. for(i = 0 ; i < MAX_NUM_OF_RECENT_NSPS ; i++)
  940. {
  941. pSettings->unprovisionedProfiles[i].nspID = (wmx_NSPid_t)L4DB_INVALID_INDEX;
  942. l4db_SetNapidEmpty((wmx_pNAPid_t)&pSettings->unprovisionedProfiles[i].napID);
  943. l4db_InitChannelPlan((pChannelPlan_t)&pSettings->unprovisionedProfiles[i].channelPlan);
  944. }
  945. //set the recent NSP size to zero
  946. pSettings->unprovisionedProfilesSize = 0;
  947. pSettings->lastConnectedNSP.recentNspID = (wmx_NSPid_t)L4DB_INVALID_INDEX;
  948. pSettings->lastConnectedNSP.numOfConnectedNapIDs = 0;
  949. //init the link loss params
  950. pSettings->longLinkLossParams.repetition = L4DB_INVALID_INDEX;
  951. pSettings->longLinkLossParams.time = (UINT32)L4DB_INVALID_INDEX;
  952. pSettings->shortLinkLossParams.repetition = L4DB_INVALID_INDEX;
  953. pSettings->shortLinkLossParams.time = (UINT32)L4DB_INVALID_INDEX;
  954. //set default values
  955. pSettings->connectMode = UserManScanManConnect;
  956. pSettings->swRfState = Off;
  957. pSettings->allowAutoActivate = FALSE;
  958. pSettings->allowFastReconnect = TRUE;
  959. pSettings->thCriteria.cinrTH = (wmx_CinrThreshold_t)L4DB_INVALID_INDEX;
  960. pSettings->thCriteria.rssiTH = (wmx_RssiThreshold_t)L4DB_INVALID_INDEX;
  961. pSettings->roamingMode = UserEnableRoaming;
  962. pSettings->currentPreferredNSP = (wmx_NSPid_t)L4DB_INVALID_INDEX;
  963. pSettings->setPreferredNspOnConnect = FALSE;
  964. }
  965. /// <summary>
  966. /// Init the device certificates
  967. /// </summary>
  968. void l4db_InitDeviceCerts(pDeviceCertificates_t pDeviceCerts)
  969. {
  970. pDeviceCerts->clientCert[0] = '\0';
  971. pDeviceCerts->privateKey[0] = '\0';
  972. pDeviceCerts->rootCert[0] = '\0';
  973. }
  974. /// <summary>
  975. /// Init the dev detail struct
  976. /// </summary>
  977. void l4db_InitDevDetail(pDevDetail_t pDevDetail)
  978. {
  979. BOOL res;
  980. // Nardimon - add get devtype from registry
  981. OSAL_strncpy_s(pDevDetail->devType, (sizeof(char)*MAX_DEV_TYPE_SIZE),"Nothing", (7*sizeof(char)));
  982. res = L4Configurations_getApdoDevDetailsDevType(pDevDetail->devType);
  983. if (!res || strcmp(pDevDetail->devType, "Nothing"))
  984. {
  985. TRACE(TR_MOD_NDNS_AGENT, TR_SEV_DEBUG, "---- DevType RegPatch ---- l4db_InitDevDetail - L4Configurations_getApdoDevDetailsDevType returned [%d]. with value [%s]. Using default - Laptop ---- DevType RegPatch ---- ",res,pDevDetail->devType);
  986. OSAL_strncpy_s(pDevDetail->devType, (sizeof(char)*MAX_DEV_TYPE_SIZE),"Laptop", (6*sizeof(char)));
  987. }
  988. TRACE(TR_MOD_NDNS_AGENT, TR_SEV_DEBUG, "---- DevType RegPatch ---- l4db_InitDevDetail - L4Configurations_getApdoDevDetailsDevType returned [%d]. with Value [%s] ---- DevType RegPatch ---- ",res,pDevDetail->devType);
  989. pDevDetail->fwVersion[0] = '\0';
  990. pDevDetail->swVersion[0] = '\0';
  991. pDevDetail->hwVersion[0] = '\0';
  992. pDevDetail->ext.SwV2[0] = '\0';
  993. OSAL_strncpy_s(pDevDetail->uri.MaxDepth, MAX_DEV_DETAIL_URI_FIELD_SIZE, "0", 2);
  994. OSAL_strncpy_s(pDevDetail->uri.MaxTotLen, MAX_DEV_DETAIL_URI_FIELD_SIZE, "0", 2);
  995. OSAL_strncpy_s(pDevDetail->uri.MaxSegLen, MAX_DEV_DETAIL_URI_FIELD_SIZE, "0", 2);
  996. OSAL_strncpy_s(pDevDetail->lrgObj, MAX_BOOL_VAL_SIZE, L4DB_XML_FALSE_STR, OSAL_strnlen(L4DB_XML_FALSE_STR, MAX_BOOL_VAL_SIZE - 1));
  997. }
  998. /// <summary>
  999. /// Init the dev info struct
  1000. /// </summary>
  1001. void l4db_InitDevInfo(pDevInfo_t pDevInfo)
  1002. {
  1003. OSAL_memcpy_s(pDevInfo->manufacturer, MAX_MAN_NAME_SIZE, DEFAULT_DEV_INFO_MAN,
  1004. sizeof(DEFAULT_DEV_INFO_MAN));
  1005. OSAL_memcpy_s(pDevInfo->model, MAX_MOD_NAME_SIZE, DEFAULT_DEV_INFO_MOD,
  1006. sizeof(DEFAULT_DEV_INFO_MOD));
  1007. pDevInfo->devID[0] = '\0';
  1008. }
  1009. /// <summary>
  1010. /// Init the dev info struct
  1011. /// </summary>
  1012. void l4db_InitWimaxRadioModule(pWmxRadioModule_t pWmxRadioModule)
  1013. {
  1014. pWmxRadioModule->tagName[0] = '\0';
  1015. pWmxRadioModule->productVersions.fwVersion[0] = '\0';
  1016. pWmxRadioModule->productVersions.swVersion[0] = '\0';
  1017. pWmxRadioModule->productVersions.hwVersion[0] = '\0';
  1018. pWmxRadioModule->macAddress[0] = '\0';
  1019. pWmxRadioModule->productVersions.manufacturer[0] = '\0';
  1020. pWmxRadioModule->productVersions.model[0] = '\0';
  1021. //SPLock
  1022. pWmxRadioModule->spLock.lockStatus = TRUE;
  1023. pWmxRadioModule->spLock.operatorName[0] = '\0';
  1024. pWmxRadioModule->spLock.lock[0] = '\0';
  1025. }
  1026. /// <summary>
  1027. /// Init the wimax struct
  1028. /// </summary>
  1029. void l4db_InitWimax(pWimax_t pWimax)
  1030. {
  1031. int i;
  1032. BOOL res;
  1033. for(i = 0 ; i < MAX_NUM_OF_WIMAX_RADIO_MOD ; i++)
  1034. {
  1035. l4db_InitWimaxRadioModule(&pWimax->radioModules[i]);
  1036. }
  1037. // Init with one default radio module
  1038. OSAL_strncpy_s(pWimax->radioModules[0].tagName, MAX_TAG_NAME_SIZE, DEFAULT_RADIO_MODULE_NODE,
  1039. strlen(DEFAULT_RADIO_MODULE_NODE));
  1040. pWimax->radioModules[0].productVersions.manufacturer[0] = '\0';
  1041. pWimax->radioModules[0].macAddress[0] = '\0';
  1042. pWimax->radioModules[0].productVersions.model[0] = '\0';
  1043. pWimax->wmxRadioModulesSize = 1;
  1044. pWimax->terminalEquipment.devId[0] = '\0';
  1045. OSAL_strncpy_s(pWimax->terminalEquipment.devType, MAX_DEV_TYPE_SIZE, DEFAULT_DEV_TYPE, sizeof(DEFAULT_DEV_TYPE));
  1046. pWimax->terminalEquipment.productVersions.fwVersion[0] = '\0';
  1047. pWimax->terminalEquipment.productVersions.hwVersion[0] = '\0';
  1048. pWimax->terminalEquipment.productVersions.manufacturer[0] = '\0';
  1049. pWimax->terminalEquipment.productVersions.model[0] = '\0';
  1050. pWimax->devCap.updateMethods.clientInitiated.pollingSupported = TRUE;
  1051. pWimax->devCap.updateMethods.clientInitiated.pollingInterval = 1;
  1052. pWimax->devCap.updateMethods.clientInitiated.pollingAttempts = 10;
  1053. // Init SW version with OS version
  1054. res = OSAL_GetOSVersion(pWimax->terminalEquipment.productVersions.swVersion);
  1055. if (!res)
  1056. {
  1057. TRACE(TR_MOD_NDNS_AGENT, TR_SEV_ERR, "l4db_InitWimax - Failed to build OS version string.");
  1058. }
  1059. }
  1060. /// <summary>
  1061. /// Init the FUMO section
  1062. /// </summary>
  1063. void l4db_InitFumoNode(pFumoParams_t pFumoParams)
  1064. {
  1065. memset(pFumoParams, 0x0, sizeof(*pFumoParams));
  1066. //state the this NSP has been initialized
  1067. pFumoParams->fIsAllocated = TRUE;
  1068. pFumoParams->tagName[0] = '\0';
  1069. // MZUR TODO Completer init
  1070. pFumoParams->pkgName[0] = '\0';
  1071. pFumoParams->pkgVersion[0] = '\0';
  1072. pFumoParams->downloadAndUpdatePkgURL[0] = '\0';
  1073. pFumoParams->downloadPkgURL[0] = '\0';
  1074. pFumoParams->state = dsDownloadIdle;
  1075. }
  1076. /// <summary>
  1077. /// Init the FUMO internal section
  1078. /// </summary>
  1079. void l4db_InitFumoInternalNode(pFumoInternalParams_t pFumoInternalParams)
  1080. {
  1081. pFumoInternalParams->fumoNodePath[0] = '\0';
  1082. pFumoInternalParams->pkgFileName[0] = '\0';
  1083. pFumoInternalParams->pkgPath[0] = '\0';
  1084. pFumoInternalParams->fumoOperation = 0;
  1085. }
  1086. /// <summary>
  1087. /// Init the APDO internal parameters section
  1088. /// </summary>
  1089. void l4db_InitAPDOInternalParametersNode(pAPDOInternalParams_t pAPDOInternalParams)
  1090. {
  1091. int i;
  1092. l4db_InitFumoInternalNode(&pAPDOInternalParams->fumoInternal);
  1093. pAPDOInternalParams->defaultRealm[0] = '\0';
  1094. pAPDOInternalParams->installStatus = isIdle;
  1095. pAPDOInternalParams->bek[0] = '\0';
  1096. //init all entries in NSPsToDmAcc
  1097. for(i=0; i<ARRAY_SIZE(pAPDOInternalParams->nspsToDmAcc); i++)
  1098. {
  1099. pAPDOInternalParams->nspsToDmAcc[i].tagName[0] = '\0';
  1100. pAPDOInternalParams->nspsToDmAcc[i].toDMAcc[0] = '\0';
  1101. }
  1102. //init all entries in apdo operator configurations
  1103. for(i=0; i<MAX_NUM_OF_CONFIGURATIONS; i++)
  1104. {
  1105. OSAL_strncpy_s(pAPDOInternalParams->configurations[i].nspTagName, MAX_SIZE_OF_NSP_NAME,
  1106. L4DB_XML_APDO_CONFIG_UNAVAILABLE, strlen(L4DB_XML_APDO_CONFIG_UNAVAILABLE));
  1107. pAPDOInternalParams->configurations[i].preProvBStrap = FALSE;
  1108. pAPDOInternalParams->configurations[i].pollingInterval = FALSE;
  1109. pAPDOInternalParams->configurations[i].blockUDP = TRUE;
  1110. pAPDOInternalParams->configurations[i].pollingAttempts = FALSE;
  1111. pAPDOInternalParams->configurations[i].disableOTAP = FALSE;
  1112. pAPDOInternalParams->configurations[i].disablePseudoNAI = FALSE;
  1113. }
  1114. for (i=0; i<ARRAY_SIZE(pAPDOInternalParams->bootstrapInfo); i++)
  1115. {
  1116. pAPDOInternalParams->bootstrapInfo[i].tagName[0] = '\0';
  1117. pAPDOInternalParams->bootstrapInfo[i].serverID[0] = '\0';
  1118. pAPDOInternalParams->bootstrapInfo[i].serverUserName[0] = '\0';
  1119. pAPDOInternalParams->bootstrapInfo[i].clientUserName[0] = '\0';
  1120. pAPDOInternalParams->bootstrapInfo[i].portNbr[0] = '\0';
  1121. pAPDOInternalParams->bootstrapInfo[i].serverURL[0] = '\0';
  1122. }
  1123. }
  1124. /// <summary>
  1125. /// Converts and RF state to a string
  1126. /// </summary>
  1127. /// <returns>pointer to "On" or "Off" string</returns>
  1128. char* l4db_GetRfStateStr(wmx_RfStatus_t state)
  1129. {
  1130. if (state == On)
  1131. return L4DB_XML_ON_STR;
  1132. else
  1133. return L4DB_XML_OFF_STR;
  1134. }
  1135. /// <summary>
  1136. /// Converts and RF state str to an RF state type
  1137. /// </summary>
  1138. /// <returns>wmx_RfStatus_t</returns>
  1139. wmx_RfStatus_t l4db_GetRfStateFromStr(const char* psState)
  1140. {
  1141. wmx_RfStatus_t state;
  1142. if(FALSE == l4db_CompareString(psState,L4DB_XML_ON_STR))
  1143. state = On;
  1144. else
  1145. state = Off;
  1146. return state;
  1147. }
  1148. /// <summary>
  1149. /// Dealloc NSP from the DB
  1150. /// </summary>
  1151. /// <param name="serverId">(IN) server ID
  1152. /// <returns>pointer for wmx_pNSPFullData_t which we found or NULL </returns>
  1153. wmx_Status_t l4db_DeAllocNsp(wmx_NSPid_t nspID)
  1154. {
  1155. pProvisionedNsp_t pFoundNsp = NULL;
  1156. pFoundNsp = l4db_GetProvisionedNspById(nspID);
  1157. if(NULL != pFoundNsp)
  1158. {
  1159. l4db_InitNsp(pFoundNsp);
  1160. }
  1161. return WMX_ST_OK;
  1162. }
  1163. /// <summary>
  1164. /// Gets the channel info which has the given tag name
  1165. /// </summary>
  1166. pChannelInfo_t l4db_GetChannelInfo(pChannelPlan_t pChannelPlan, char * tagName)
  1167. {
  1168. int i;
  1169. pChannelInfo_t pFoundChannelInfo = NULL;
  1170. if((NULL == pChannelPlan) || (NULL == tagName))
  1171. {
  1172. TRACE(TR_MOD_NDNS_AGENT, TR_SEV_ERR, "l4db_GetChannelInfo pChannelPlan or tagName are NULL");
  1173. return pFoundChannelInfo;
  1174. }
  1175. for(i = 0 ; i < WMX_CHANNELS_MAX_NUM ; i++)
  1176. {
  1177. if(FALSE == l4db_CompareString(tagName, pChannelPlan->channels[i].tagName))
  1178. {
  1179. pFoundChannelInfo = &pChannelPlan->channels[i];
  1180. break;
  1181. }
  1182. }
  1183. return pFoundChannelInfo;
  1184. }
  1185. /// <summary>
  1186. /// Gets the channel ref which has the given tag name
  1187. /// </summary>
  1188. pChPlanRefId_t l4db_GetChannelRef(pChPlanRefId_t pChannelRefs, char * tagName)
  1189. {
  1190. int i;
  1191. pChPlanRefId_t pFoundChannelRef = NULL;
  1192. if((NULL == pChannelRefs) || (NULL == tagName))
  1193. {
  1194. TRACE(TR_MOD_NDNS_AGENT, TR_SEV_ERR, "l4db_GetChannelRef pChannelRef or tagName are NULL");
  1195. return pFoundChannelRef;
  1196. }
  1197. for(i = 0 ; i < WMX_CHANNELS_MAX_NUM ; i++)
  1198. {
  1199. if(FALSE == l4db_CompareString(tagName, pChannelRefs[i].tagName))
  1200. {
  1201. pFoundChannelRef = &pChannelRefs[i];
  1202. break;
  1203. }
  1204. }
  1205. return pFoundChannelRef;
  1206. }
  1207. /// <summary>
  1208. /// Gets the NAP info for the NAP which has the given tag name
  1209. /// </summary>
  1210. pL4db_Nap_t l4db_GetCaplNapInfo(pL4db_Nap_t pNaps, char * tagName)
  1211. {
  1212. int i;
  1213. pL4db_Nap_t pFoundNapInfo = NULL;
  1214. if((NULL == pNaps) || (NULL == tagName))
  1215. {
  1216. TRACE(TR_MOD_NDNS_AGENT, TR_SEV_ERR, "l4db_GetCaplNapInfo pNaps or tagName are NULL");
  1217. return pFoundNapInfo;
  1218. }
  1219. for(i = 0 ; i < WMX_NAPS_MAX_NUM ; i++)
  1220. {
  1221. if(FALSE == l4db_CompareString(tagName, pNaps[i].tagName))
  1222. {
  1223. pFoundNapInfo = &pNaps[i];
  1224. break;
  1225. }
  1226. }
  1227. return pFoundNapInfo;
  1228. }
  1229. /// <summary>
  1230. /// Gets the home NSP which has the given tag
  1231. /// </summary>
  1232. pHomeNsp_t l4db_GetHnsp(pHomeNsp_t pHnsps, char * tagName)
  1233. {
  1234. int i;
  1235. pHomeNsp_t pFoundHnsp = NULL;
  1236. if((NULL == pHnsps) || (NULL == tagName))
  1237. {
  1238. TRACE(TR_MOD_NDNS_AGENT, TR_SEV_ERR, "l4db_GetHnsp pHnsps or tagName are NULL");
  1239. return pFoundHnsp;
  1240. }
  1241. for(i = 0 ; i < WMX_NSP_IDS_MAX_NUM ; i++)
  1242. {
  1243. if(FALSE == l4db_CompareString(tagName, pHnsps[i].tagName))
  1244. {
  1245. pFoundHnsp = &pHnsps[i];
  1246. break;
  1247. }
  1248. }
  1249. return pFoundHnsp;
  1250. }
  1251. /// <summary>
  1252. /// Gets the contact info which has the given tag
  1253. /// </summary>
  1254. pContactsInfo_t l4db_GetContactInfo(pContactsInfo_t pContacts, char * tagName)
  1255. {
  1256. int i;
  1257. pContactsInfo_t pFoundContact = NULL;
  1258. if((NULL == pContacts) || (NULL == tagName))
  1259. {
  1260. TRACE(TR_MOD_NDNS_AGENT, TR_SEV_ERR, "l4db_GetContactInfo: pContacts or tagName are NULL");
  1261. return pFoundContact;
  1262. }
  1263. for(i = 0 ; i < MAX_NUM_OF_CONTACTS ; i++)
  1264. {
  1265. if(FALSE == l4db_CompareString(tagName, pContacts[i].tagName))
  1266. {
  1267. pFoundContact = &pContacts[i];
  1268. break;
  1269. }
  1270. }
  1271. return pFoundContact;
  1272. }
  1273. /// <summary>
  1274. /// Gets the srv realm which has the given tag - NOT SUPPORTED NOW
  1275. /// </summary>
  1276. pSrvRealm_t l4db_GetSrvRealm(pSrvRealm_t psrvRealms, char * tagName)
  1277. {
  1278. int i;
  1279. pSrvRealm_t pFoundSrvRealm = NULL;
  1280. if((NULL == psrvRealms) || (NULL == tagName))
  1281. {
  1282. TRACE(TR_MOD_NDNS_AGENT, TR_SEV_ERR, "l4db_GetSrvRealm psrvRealms or tagName are NULL");
  1283. return pFoundSrvRealm;
  1284. }
  1285. for(i = 0 ; i < MAX_NUM_OF_SRV_REALMS ; i++)
  1286. {
  1287. if(FALSE == l4db_CompareString(tagName, psrvRealms[i].tagName))
  1288. {
  1289. pFoundSrvRealm = &psrvRealms[i];
  1290. break;
  1291. }
  1292. }
  1293. return pFoundSrvRealm;
  1294. }
  1295. /// <summary>
  1296. /// Gets the EAP entry which has the given tag name
  1297. /// </summary>
  1298. pEAP_t l4db_GetEap(pEAP_t pEaps, char * tagName)
  1299. {
  1300. int i;
  1301. pEAP_t pFoundEap = NULL;
  1302. if((NULL == pEaps) || (NULL == tagName))
  1303. {
  1304. TRACE(TR_MOD_NDNS_AGENT, TR_SEV_ERR, "l4db_GetEap pEaps or tagName are NULL");
  1305. return pFoundEap;
  1306. }
  1307. for(i = 0 ; i < MAX_NUM_OF_EAP_METHODS ; i++)
  1308. {
  1309. if(FALSE == l4db_CompareString(tagName, pEaps[i].tagName))
  1310. {
  1311. pFoundEap = &pEaps[i];
  1312. break;
  1313. }
  1314. }
  1315. return pFoundEap;
  1316. }
  1317. /// <summary>
  1318. /// Gets the other subscription entry which has the given tag name
  1319. /// </summary>
  1320. pOtherSubsInfo_t l4db_GetOtherSubsc(pOtherSubsInfo_t pSubscribers, char * tagName)
  1321. {
  1322. int i;
  1323. pOtherSubsInfo_t pFoundSubsc = NULL;
  1324. if((NULL == pSubscribers) || (NULL == tagName))
  1325. {
  1326. TRACE(TR_MOD_NDNS_AGENT, TR_SEV_ERR, "l4db_GetOtherSubsc pSubscribers or tagName are NULL");
  1327. return pFoundSubsc;
  1328. }
  1329. for(i = 0 ; i < WMX_NSP_SUBSCRIBERS_MAX_NUM ; i++)
  1330. {
  1331. if(FALSE == l4db_CompareString(tagName, pSubscribers[i].tagName))
  1332. {
  1333. pFoundSubsc = &pSubscribers[i];
  1334. break;
  1335. }
  1336. }
  1337. return pFoundSubsc;
  1338. }
  1339. /// <summary>
  1340. /// Gets the cert info which has the given tag name
  1341. /// </summary>
  1342. pCert_t l4db_GetCert(pCert_t pCerts, char * tagName)
  1343. {
  1344. int i;
  1345. pCert_t pFoundCert = NULL;
  1346. if((NULL == pCerts) || (NULL == tagName))
  1347. {
  1348. TRACE(TR_MOD_NDNS_AGENT, TR_SEV_ERR, "l4db_GetCert pCerts or tagName are NULL");
  1349. return pFoundCert;
  1350. }
  1351. for(i = 0 ; i < MAX_NUM_OF_CERTS ; i++)
  1352. {
  1353. if(FALSE == l4db_CompareString(tagName, pCerts[i].tagName))
  1354. {
  1355. pFoundCert = &pCerts[i];
  1356. break;
  1357. }
  1358. }
  1359. return pFoundCert;
  1360. }
  1361. /// <summary>
  1362. /// Gets the roaming info which has the given tag name
  1363. /// </summary>
  1364. pRoamingPartnerInfo_t l4db_GetRoamingInfo(pRoamingPartnerInfo_t pRoamingInfos, char * tagName)
  1365. {
  1366. int i;
  1367. pRoamingPartnerInfo_t pFoundRoamingInfo = NULL;
  1368. if((NULL == pRoamingInfos) || (NULL == tagName))
  1369. {
  1370. TRACE(TR_MOD_NDNS_AGENT, TR_SEV_ERR, "l4db_GetRoamingInfo pRoamingInfos or tagName are NULL");
  1371. return pFoundRoamingInfo;
  1372. }
  1373. for(i = 0 ; i < MAX_ROAMING_PARTNERS ; i++)
  1374. {
  1375. if(FALSE == l4db_CompareString(tagName, pRoamingInfos[i].tagName))
  1376. {
  1377. pFoundRoamingInfo = &pRoamingInfos[i];
  1378. break;
  1379. }
  1380. }
  1381. return pFoundRoamingInfo;
  1382. }
  1383. /// <summary>
  1384. /// Gets the wimax radio module which has the given tag name
  1385. /// </summary>
  1386. pWmxRadioModule_t l4db_GetWmxRadioModule(pWmxRadioModule_t pWmxRadioModules, UINT32 size, char * tagName)
  1387. {
  1388. UINT32 i;
  1389. pWmxRadioModule_t pFoundWmxRadioModule = NULL;
  1390. if((NULL == pWmxRadioModules) || (NULL == tagName))
  1391. {
  1392. TRACE(TR_MOD_NDNS_AGENT, TR_SEV_ERR, "l4db_GetWmxRadioModule pWmxRadioModules or tagName are NULL");
  1393. return pFoundWmxRadioModule;
  1394. }
  1395. for(i = 0 ; i < size ; i++)
  1396. {
  1397. if(FALSE == l4db_CompareString(tagName, pWmxRadioModules[i].tagName))
  1398. {
  1399. pFoundWmxRadioModule = &pWmxRadioModules[i];
  1400. break;
  1401. }
  1402. }
  1403. return pFoundWmxRadioModule;
  1404. }
  1405. /// <summary>
  1406. /// Gets the NSPs in the NSPsToDMAcc list which has the given tag name
  1407. /// </summary>
  1408. pNSPToDMAcc_t l4db_GetNSPsToDMAccStruct(pAPDOInternalParams_t pApdoInternal, char* tagName)
  1409. {
  1410. UINT32 i;
  1411. pNSPToDMAcc_t pFoundNSP = NULL;
  1412. if((NULL == pApdoInternal) || (NULL == tagName))
  1413. {
  1414. TRACE(TR_MOD_NDNS_AGENT, TR_SEV_ERR, "l4db_GetNSPsToDMAccStruct pApdoInternal or tagName are NULL");
  1415. return pFoundNSP;
  1416. }
  1417. for(i=0; i<WMX_NSPS_TO_DMACC_NODES_MAX_NUM; i++)
  1418. {
  1419. if(FALSE == l4db_CompareString(tagName, pApdoInternal->nspsToDmAcc[i].tagName))
  1420. {
  1421. pFoundNSP = &pApdoInternal->nspsToDmAcc[i];
  1422. break;
  1423. }
  1424. }
  1425. return pFoundNSP;
  1426. }
  1427. /// <summary>
  1428. /// Gets the bootstrap info of the suitable nsp
  1429. /// </summary>
  1430. pBootstrapInfo_t l4db_GetBootstrapInfoStruct(pAPDOInternalParams_t pApdoInternal, char* tagName)
  1431. {
  1432. UINT32 i;
  1433. pBootstrapInfo_t pFoundInfo = NULL;
  1434. if((NULL == pApdoInternal) || (NULL == tagName))
  1435. {
  1436. TRACE(TR_MOD_NDNS_AGENT, TR_SEV_ERR, "l4db_GetBootstrapInfoStruct pApdoInternal or tagName are NULL");
  1437. return pFoundInfo;
  1438. }
  1439. for(i=0; i<WMX_NSPS_MAX_NUM; i++)
  1440. {
  1441. if(FALSE == l4db_CompareString(tagName, pApdoInternal->bootstrapInfo[i].tagName))
  1442. {
  1443. pFoundInfo = &pApdoInternal->bootstrapInfo[i];
  1444. break;
  1445. }
  1446. }
  1447. return pFoundInfo;
  1448. }
  1449. /// Alloc Channel Info
  1450. /// </summary>
  1451. /// <param name="pChannelPlan">(IN) a channel plan to search in </<param>
  1452. /// <param name="tagName">(IN) the channel's tagName </<param>
  1453. /// <returns>pointer for pChannelInfo_t which has been allocated or NULL if there is no space </returns>
  1454. pChannelInfo_t l4db_AllocChannelInfo(pChannelPlan_t pChannelPlan, char * tagName)
  1455. {
  1456. int i;
  1457. pChannelInfo_t pFoundChannelInfo = NULL;
  1458. if(NULL == pChannelPlan)
  1459. {
  1460. TRACE(TR_MOD_NDNS_AGENT, TR_SEV_ERR, "l4db_AllocChannelInfo: pChannelPlan is NULL");
  1461. return pFoundChannelInfo;
  1462. }
  1463. for(i = 0 ; i< WMX_CHANNELS_MAX_NUM ; i++)
  1464. {
  1465. if(FALSE == l4db_CompareString(pChannelPlan->channels[i].tagName, C_L4DB_EMPTY_STRING))
  1466. {
  1467. OSAL_strcpy_s(pChannelPlan->channels[i].tagName, MAX_TAG_NAME_SIZE, tagName);
  1468. pFoundChannelInfo = &pChannelPlan->channels[i];
  1469. break;
  1470. }
  1471. }
  1472. if (pFoundChannelInfo != NULL)
  1473. {
  1474. pChannelPlan->channelsSize++;
  1475. }
  1476. return pFoundChannelInfo;
  1477. }
  1478. /// <summary>
  1479. /// Alloc Channel Ref
  1480. /// </summary>
  1481. /// <param name="pChannelRef">(IN) a channel refs to search in </<param>
  1482. /// <param name="tagName">(IN) the channel's tagName </<param>
  1483. /// <returns>pointer for pChannelInfo_t which has been allocated or NULL if there is no space </returns>
  1484. pChPlanRefId_t l4db_AllocChannelRef(pChPlanRefId_t pChannelRefs, char * tagName)
  1485. {
  1486. int i;
  1487. pChPlanRefId_t pFoundChannelRef = NULL;
  1488. if(NULL == pChannelRefs)
  1489. {
  1490. TRACE(TR_MOD_NDNS_AGENT, TR_SEV_ERR, "l4db_AllocChannelInfo: pChannelRef is NULL");
  1491. return pFoundChannelRef;
  1492. }
  1493. for(i = 0 ; i< WMX_CHANNELS_MAX_NUM ; i++)
  1494. {
  1495. if(FALSE == l4db_CompareString(pChannelRefs[i].tagName, C_L4DB_EMPTY_STRING))
  1496. {
  1497. OSAL_strcpy_s(pChannelRefs[i].tagName, MAX_TAG_NAME_SIZE, tagName);
  1498. pFoundChannelRef = &pChannelRefs[i];
  1499. break;
  1500. }
  1501. }
  1502. return pFoundChannelRef;
  1503. }
  1504. /// <summary>
  1505. /// Alloc H_NSP info
  1506. /// </summary>
  1507. /// <param name="pHnsp">(IN) an array of Hnsps </<param>
  1508. /// <param name="tagName">(IN) the H_NSP's tagName </<param>
  1509. /// <returns>a pointer to a home nsp which has been allocated or NULL if there is not enough space </returns>
  1510. pHomeNsp_t l4db_AllocHnsp(pHomeNsp_t pHnsps, char * tagName)
  1511. {
  1512. int i;
  1513. pHomeNsp_t pFoundHnsp = NULL;
  1514. if(NULL == pHnsps)
  1515. {
  1516. TRACE(TR_MOD_NDNS_AGENT, TR_SEV_ERR, "l4db_AllocHnsp: pHnsps is NULL");
  1517. return pFoundHnsp;
  1518. }
  1519. for(i = 0 ; i < WMX_NSP_IDS_MAX_NUM ; i++)
  1520. {
  1521. if(FALSE == l4db_CompareString(pHnsps[i].tagName, C_L4DB_EMPTY_STRING))
  1522. {
  1523. OSAL_strcpy_s(pHnsps[i].tagName, MAX_TAG_NAME_SIZE, tagName);
  1524. pFoundHnsp = &pHnsps[i];
  1525. break;
  1526. }
  1527. }
  1528. return pFoundHnsp;
  1529. }
  1530. /// <summary>
  1531. /// Alloc a NAP in the CAPL
  1532. /// </summary>
  1533. /// <param name="pNaps">(IN) an array of Naps </<param>
  1534. /// <param name="tagName">(IN) the NAP's tagName </<param>
  1535. /// <returns>a pointer to the NAP which has been allocated or NULL if there is not enough space </returns>
  1536. pL4db_Nap_t l4db_AllocCaplNap(pL4db_Nap_t pNaps, char * tagName)
  1537. {
  1538. int i;
  1539. pL4db_Nap_t pFoundNap = NULL;
  1540. if(NULL == pNaps)
  1541. {
  1542. TRACE(TR_MOD_NDNS_AGENT, TR_SEV_ERR, "l4db_AllocCaplNap: pNaps is NULL");
  1543. return pFoundNap;
  1544. }
  1545. for(i = 0 ; i < WMX_NAPS_MAX_NUM ; i++)
  1546. {
  1547. if(FALSE == l4db_CompareString(pNaps[i].tagName, C_L4DB_EMPTY_STRING))
  1548. {
  1549. OSAL_strcpy_s(pNaps[i].tagName, MAX_TAG_NAME_SIZE, tagName);
  1550. pFoundNap = &pNaps[i];
  1551. break;
  1552. }
  1553. }
  1554. return pFoundNap;
  1555. }
  1556. /// <summary>
  1557. /// Alloc a NSPToDMAcc node in the NSPsToDMAcc array
  1558. /// </summary>
  1559. /// <param name="pNSPToDMAcc">(IN) an array of NSPToDMAcc </<param>
  1560. /// <param name="tagName">(IN) the NSP's tagName </<param>
  1561. /// <returns>a pointer to the NSPToDMAcc which has been allocated or NULL if there is not enough space </returns>
  1562. pNSPToDMAcc_t l4db_AllocNSPToDMAcc(pNSPToDMAcc_t pNSPsToDMAcc, char* tagName)
  1563. {
  1564. int i;
  1565. pNSPToDMAcc_t pFoundNSPToDMAcc = NULL;
  1566. if ((NULL == pNSPsToDMAcc) || (tagName == NULL))
  1567. {
  1568. TRACE(TR_MOD_NDNS_AGENT, TR_SEV_ERR, "l4db_AllocNSPsToDMAcc: pNSPsToDMAcc is NULL");
  1569. return pFoundNSPToDMAcc;
  1570. }
  1571. for(i=0; i<WMX_NSPS_TO_DMACC_NODES_MAX_NUM; i++)
  1572. {
  1573. if(FALSE == l4db_CompareString(pNSPsToDMAcc[i].tagName, C_L4DB_EMPTY_STRING))
  1574. {
  1575. OSAL_strcpy_s(pNSPsToDMAcc[i].tagName, MAX_TAG_NAME_SIZE, tagName);
  1576. pFoundNSPToDMAcc = &pNSPsToDMAcc[i];
  1577. break;
  1578. }
  1579. }
  1580. return pFoundNSPToDMAcc;
  1581. }
  1582. pBootstrapInfo_t l4db_AllocBootstrapInfo(pBootstrapInfo_t pBootstrapInfo, char* tagName)
  1583. {
  1584. int i;
  1585. pBootstrapInfo_t pFoundInfo = NULL;
  1586. if(NULL == pBootstrapInfo)
  1587. {
  1588. TRACE(TR_MOD_NDNS_AGENT, TR_SEV_ERR, "l4db_AllocBootstrapInfo: pBootstrapInfo is NULL");
  1589. return pFoundInfo;
  1590. }
  1591. for(i=0; i<WMX_NSPS_MAX_NUM; i++)
  1592. {
  1593. if(FALSE == l4db_CompareString(pBootstrapInfo[i].tagName, C_L4DB_EMPTY_STRING))
  1594. {
  1595. OSAL_strcpy_s(pBootstrapInfo[i].tagName, MAX_TAG_NAME_SIZE, tagName);
  1596. pFoundInfo = &pBootstrapInfo[i];
  1597. break;
  1598. }
  1599. }
  1600. return pFoundInfo;
  1601. }
  1602. /// <summary>
  1603. /// Alloc a URI
  1604. /// </summary>
  1605. /// <param name="pUris">(IN) an array of Naps </<param>
  1606. /// <param name="tagName">(IN) the URI's tagName </<param>
  1607. /// <returns>a pointer to the URI which has been allocated or NULL if there is not enough space </returns>
  1608. pContactsInfo_t l4db_AllocContactInfo(pContactsInfo_t pContacts, char * tagName)
  1609. {
  1610. int i;
  1611. pContactsInfo_t pFoundContact = NULL;
  1612. if(NULL == pContacts)
  1613. {
  1614. TRACE(TR_MOD_NDNS_AGENT, TR_SEV_ERR, "l4db_AllocUri: pUris is NULL");
  1615. return pFoundContact;
  1616. }
  1617. for(i = 0 ; i < WMX_URI_MAX_NUM ; i++)
  1618. {
  1619. if(FALSE == l4db_CompareString(pContacts[i].tagName, C_L4DB_EMPTY_STRING))
  1620. {
  1621. OSAL_strcpy_s(pContacts[i].tagName, MAX_TAG_NAME_SIZE, tagName);
  1622. pFoundContact = &pContacts[i];
  1623. break;
  1624. }
  1625. }
  1626. return pFoundContact;
  1627. }
  1628. /// <summary>
  1629. /// Alloc an srv realm
  1630. /// </summary>
  1631. /// <param name="pSrvRealms">(IN) an array of Naps </<param>
  1632. /// <param name="tagName">(IN) the srv realm's tagName </<param>
  1633. /// <returns>a pointer to the srv realm which has been allocated or NULL if there is not enough space </returns>
  1634. pSrvRealm_t l4db_AllocSrvRealm(pSrvRealm_t pSrvRealms, char * tagName)
  1635. {
  1636. int i;
  1637. pSrvRealm_t pFoundSrvRealm = NULL;
  1638. if(NULL == pSrvRealms)
  1639. {
  1640. TRACE(TR_MOD_NDNS_AGENT, TR_SEV_ERR, "l4db_AllocSrvRealm: pSrvRealms is NULL");
  1641. return pFoundSrvRealm;
  1642. }
  1643. for(i = 0 ; i < MAX_NUM_OF_SRV_REALMS ; i++)
  1644. {
  1645. if(FALSE == l4db_CompareString(pSrvRealms[i].tagName, C_L4DB_EMPTY_STRING))
  1646. {
  1647. OSAL_strcpy_s(pSrvRealms[i].tagName, MAX_TAG_NAME_SIZE, tagName);
  1648. pFoundSrvRealm = &pSrvRealms[i];
  1649. break;
  1650. }
  1651. }
  1652. return pFoundSrvRealm;
  1653. }
  1654. /// <summary>
  1655. /// Alloc a cert
  1656. /// </summary>
  1657. /// <param name="pCerts">(IN) an array of certs </<param>
  1658. /// <param name="tagName">(IN) the cert's tagName </<param>
  1659. /// <returns>a pointer to the cert which has been allocated or NULL if there is not enough space </returns>
  1660. pCert_t l4db_AllocCert(pCert_t pCerts, char * tagName)
  1661. {
  1662. int i;
  1663. pCert_t pFoundCert = NULL;
  1664. if(NULL == pCerts)
  1665. {
  1666. TRACE(TR_MOD_NDNS_AGENT, TR_SEV_ERR, "l4db_AllocCert: pCerts is NULL");
  1667. return pFoundCert;
  1668. }
  1669. for(i = 0 ; i < MAX_NUM_OF_CERTS ; i++)
  1670. {
  1671. if(FALSE == l4db_CompareString(pCerts[i].tagName, C_L4DB_EMPTY_STRING))
  1672. {
  1673. OSAL_strcpy_s(pCerts[i].tagName, MAX_TAG_NAME_SIZE, tagName);
  1674. pFoundCert = &pCerts[i];
  1675. break;
  1676. }
  1677. }
  1678. return pFoundCert;
  1679. }
  1680. /// <summary>
  1681. /// Alloc an EAP entry
  1682. /// </summary>
  1683. /// <param name="pEaps">(IN) an array of EAPs </<param>
  1684. /// <param name="tagName">(IN) the EAP's tagName </<param>
  1685. /// <returns>a pointer to the EAP which has been allocated or NULL if there is not enough space </returns>
  1686. pEAP_t l4db_AllocEap(pEAP_t pEaps, char * tagName)
  1687. {
  1688. int i;
  1689. pEAP_t pFoundEap = NULL;
  1690. if(NULL == pEaps)
  1691. {
  1692. TRACE(TR_MOD_NDNS_AGENT, TR_SEV_ERR, "l4db_AllocEap: pEaps is NULL");
  1693. return pFoundEap;
  1694. }
  1695. for(i = 0 ; i < MAX_EAP_METHOD_SIZE ; i++)
  1696. {
  1697. if(FALSE == l4db_CompareString(pEaps[i].tagName, C_L4DB_EMPTY_STRING))
  1698. {
  1699. OSAL_strcpy_s(pEaps[i].tagName, MAX_TAG_NAME_SIZE, tagName);
  1700. pFoundEap = &pEaps[i];
  1701. break;
  1702. }
  1703. }
  1704. return pFoundEap;
  1705. }
  1706. /// <summary>
  1707. /// Alloc an other subscription
  1708. /// </summary>
  1709. /// <param name="pSubscribers">(IN) an array of other subscriptions </<param>
  1710. /// <param name="tagName">(IN) the other subscription's tagName </<param>
  1711. /// <returns>a pointer to the other subscription which has been allocated or NULL if there is not enough space </returns>
  1712. pOtherSubsInfo_t l4db_AllocOtherSubsc(pOtherSubsInfo_t pSubscribers, char * tagName)
  1713. {
  1714. int i;
  1715. pOtherSubsInfo_t pFoundSubsc = NULL;
  1716. if(NULL == pSubscribers)
  1717. {
  1718. TRACE(TR_MOD_NDNS_AGENT, TR_SEV_ERR, "l4db_AllocOtherSubsc: pSubscribers is NULL");
  1719. return pFoundSubsc;
  1720. }
  1721. for(i = 0 ; i < WMX_NSP_SUBSCRIBERS_MAX_NUM ; i++)
  1722. {
  1723. if(FALSE == l4db_CompareString(pSubscribers[i].tagName, C_L4DB_EMPTY_STRING))
  1724. {
  1725. OSAL_strcpy_s(pSubscribers[i].tagName, MAX_TAG_NAME_SIZE, tagName);
  1726. pFoundSubsc = &pSubscribers[i];
  1727. break;
  1728. }
  1729. }
  1730. return pFoundSubsc;
  1731. }
  1732. /// <summary>
  1733. /// Alloc an NSP
  1734. /// </summary>
  1735. /// <param name="tagName">(IN) the NSP's tagName </<param>
  1736. /// <returns>a pointer to the NSP which has been allocated or NULL if there is not enough space </returns>
  1737. pProvisionedNsp_t l4db_AllocNsp(char * tagName)
  1738. {
  1739. pProvisionedNsp_t pNsp = l4db_GetEmptyNsp();
  1740. if(NULL != pNsp)
  1741. {
  1742. OSAL_strcpy_s(pNsp->tagName, MAX_TAG_NAME_SIZE, tagName);
  1743. l4db_AddNSPToNSPsToDMAccStruct(pNsp->tagName);
  1744. }
  1745. else
  1746. {
  1747. TRACE(TR_MOD_NDNS_AGENT, TR_SEV_ERR, "l4db_AllocNsp: unable to allocate a new NSP in the L4db");
  1748. }
  1749. return pNsp;
  1750. }
  1751. /// <summary>
  1752. /// Alloc a roaming info subscription
  1753. /// </summary>
  1754. /// <param name="pRoamingInfos">(IN) an array of roaming infos</<param>
  1755. /// <param name="tagName">(IN) the other roaming info's tagName </<param>
  1756. /// <returns>a pointer to the roaming info which has been allocated or NULL if there is not enough space </returns>
  1757. pRoamingPartnerInfo_t l4db_AllocRoamingInfo(pRoamingPartnerInfo_t pRoamingInfos, char * tagName)
  1758. {
  1759. int i;
  1760. pRoamingPartnerInfo_t pFoundRoamingInfo = NULL;
  1761. if(NULL == pRoamingInfos)
  1762. {
  1763. TRACE(TR_MOD_NDNS_AGENT, TR_SEV_ERR, "l4db_AllocRoamingInfo: pRoamingInfos is NULL");
  1764. return pFoundRoamingInfo;
  1765. }
  1766. for(i = 0 ; i < MAX_ROAMING_PARTNERS ; i++)
  1767. {
  1768. if(FALSE == l4db_CompareString(pRoamingInfos[i].tagName, C_L4DB_EMPTY_STRING))
  1769. {
  1770. OSAL_strcpy_s(pRoamingInfos[i].tagName, MAX_TAG_NAME_SIZE, tagName);
  1771. pFoundRoamingInfo = &pRoamingInfos[i];
  1772. break;
  1773. }
  1774. }
  1775. return pFoundRoamingInfo;
  1776. }
  1777. /// <summary>
  1778. /// Alloc a Fumo node
  1779. /// </summary>
  1780. /// <param name="tagName">(IN) The new node tagName </<param>
  1781. /// <returns>a pointer to the node which has been allocated or NULL if there is not enough space </returns>
  1782. pFumoParams_t l4db_AllocFumoNode(char * tagName)
  1783. {
  1784. pFumoParams_t pFumoNode = l4db_GetEmptyFumoNode();
  1785. if(NULL != pFumoNode)
  1786. {
  1787. OSAL_strcpy_s(pFumoNode->tagName, MAX_TAG_NAME_SIZE, tagName);
  1788. }
  1789. else
  1790. {
  1791. TRACE(TR_MOD_NDNS_AGENT, TR_SEV_ERR, "l4db_AllocFumoNode: unable to allocate a new Fumo node in the L4db");
  1792. }
  1793. return pFumoNode;
  1794. }
  1795. /// <summary>
  1796. /// Copy a channle plan with ordering its array elements
  1797. /// </summary>
  1798. /// <param name="pDest">(OUT) the destionation channel plan </<param>
  1799. /// <param name="src">(IN) the source channel plan </<param>
  1800. void l4db_CopyChannelPlan(pChannelPlan_t pDest, pChannelPlan_t pSrc)
  1801. {
  1802. int i;
  1803. UINT32 size = 0;
  1804. size_t tempStrLen = 0;
  1805. //TRACE(TR_MOD_NDNS_AGENT, TR_SEV_DEBUG, "l4db_CopyChannelPlan(IN)");
  1806. pDest->bw = pSrc->bw;
  1807. pDest->duplexMode = pSrc->duplexMode;
  1808. pDest->fft = pSrc->fft;
  1809. //copy allocated channels to the des
  1810. for(i = 0 ; i < WMX_CHANNELS_MAX_NUM ; i++)
  1811. {
  1812. tempStrLen = OSAL_strnlen(pSrc->channels[i].tagName, MAX_TAG_NAME_SIZE);
  1813. if(0 != tempStrLen && MAX_TAG_NAME_SIZE != tempStrLen)
  1814. {
  1815. memcpy(&pDest->channels[size], &pSrc->channels[i], sizeof(pDest->channels[size]));
  1816. memcpy(&pDest->linkQuality[size], &pSrc->linkQuality[i], sizeof(pDest->linkQuality[size]));
  1817. size++;
  1818. }
  1819. }
  1820. //update the number elements in the channels array
  1821. pDest->channelsSize = size;
  1822. //TRACE(TR_MOD_NDNS_AGENT, TR_SEV_DEBUG, "l4db_CopyChannelPlan(OUT)");
  1823. }
  1824. /// <summary>
  1825. /// Copy a channle plan with ordering its array elements
  1826. /// </summary>
  1827. /// <param name="pDest">(OUT) the destionation channel plan </<param>
  1828. /// <param name="src">(IN) the source channel plan </<param>
  1829. void l4db_CopyChannelPlanWithInit(pChannelPlan_t pDest, pChannelPlan_t pSrc)
  1830. {
  1831. UINT32 i;
  1832. //add tag names to the allocated channels and copy them
  1833. for(i = 0 ; i < pSrc->channelsSize ; i++)
  1834. {
  1835. l4db_CreateChannelTagName(pSrc->channels[i].tagName, i);
  1836. memcpy(&pDest->channels[i], &pSrc->channels[i], sizeof(pDest->channels[i]));
  1837. }
  1838. pDest->bw = pSrc->bw;
  1839. pDest->fft = pSrc->fft;
  1840. pDest->duplexMode = pSrc->duplexMode;
  1841. pDest->channelsSize = pSrc->channelsSize;
  1842. //init the other channels
  1843. for(i = pSrc->channelsSize ; i < WMX_CHANNELS_MAX_NUM ; i++)
  1844. {
  1845. l4db_InitChannelInfo(&pDest->channels[i]);
  1846. }
  1847. }
  1848. /// <summary>
  1849. /// Copy a channels ref array
  1850. /// </summary>
  1851. /// <param name="pDest">(OUT) the destionation channel ref </<param>
  1852. /// <param name="src">(IN) the source channel ref </<param>
  1853. void l4db_CopyChannelsRefs(pL4db_Nap_t pDest, pL4db_Nap_t pSrc)
  1854. {
  1855. int i;
  1856. UINT32 size = 0;
  1857. size_t tempStrLen = 0;
  1858. //copy allocated channels to the des
  1859. for(i = 0 ; i < WMX_CHANNELS_MAX_NUM ; i++)
  1860. {
  1861. tempStrLen = OSAL_strnlen(pSrc->channelPlanRefIds[i].tagName, MAX_TAG_NAME_SIZE);
  1862. if(0 != tempStrLen && MAX_TAG_NAME_SIZE != tempStrLen)
  1863. {
  1864. memcpy(&pDest->channelPlanRefIds[size], &pSrc->channelPlanRefIds[i], sizeof(pDest->channelPlanRefIds[size]));
  1865. size++;
  1866. }
  1867. }
  1868. //update the number elements in the channels array
  1869. pDest->channelRefsSize = size;
  1870. }
  1871. BOOL l4db_ValidateChannel(pChannelInfo_t channel)
  1872. {
  1873. if((channel->firstFreq % 250) != 0)
  1874. {
  1875. TRACE(TR_MOD_NDNS_AGENT, TR_SEV_ERR, "Channel with invalid frequency of %u found. Discarding channel", channel->firstFreq);
  1876. return FALSE;
  1877. }
  1878. return TRUE;
  1879. }
  1880. // The function returns TRUE if the channels are equal. Compare the preambles if requested.
  1881. BOOL l4db_IsChannelsEqual(pChannelInfo_t pCh1, pChannelInfo_t pCh2, BOOL isComparePreambles)
  1882. {
  1883. BOOL res = FALSE;
  1884. UINT32 i;
  1885. if (pCh1 != NULL &&
  1886. pCh2 != NULL)
  1887. {
  1888. if (pCh1->bw == pCh2->bw &&
  1889. pCh1->fft == pCh2->fft &&
  1890. pCh1->firstFreq == pCh2->firstFreq &&
  1891. pCh1->lastFreq == pCh2->lastFreq &&
  1892. (pCh1->firstFreq + pCh1->nextFreq >= pCh1->lastFreq || //if this is true - no need to compare the nextFreq
  1893. pCh1->nextFreq == pCh2->nextFreq)) // nextFreq causes the generation of a new channel
  1894. {
  1895. if (pCh1->firstFreq + pCh1->nextFreq >= pCh1->lastFreq)
  1896. {
  1897. //TODO: [Oran] finish
  1898. }
  1899. if (isComparePreambles)
  1900. {
  1901. for (i = 0; i < PREAMBLES_LENGTH; ++i)
  1902. {
  1903. if (pCh1->preambleBitmap[i] != pCh2->preambleBitmap[i])
  1904. {
  1905. break;
  1906. }
  1907. }
  1908. if (i == PREAMBLES_LENGTH) // all preambles are equal
  1909. {
  1910. res = TRUE;
  1911. }
  1912. }
  1913. else
  1914. {
  1915. res = TRUE;
  1916. }
  1917. }
  1918. }
  1919. return res;
  1920. }
  1921. void l4db_AddChannelsNoDuplicates(pChannelInfo_t pDest, wmx_LinkQuality_t pDestlinkQuality[WMX_CHANNELS_MAX_NUM], UINT32 *destSize, pChannelInfo_t pSrc, UINT32 srcSize, wmx_LinkQuality_t pSrcLinkQuality[WMX_CHANNELS_MAX_NUM], BOOL isComparePreambles)
  1922. {
  1923. UINT32 i, j;
  1924. TRACE(TR_MOD_NDNS_AGENT, TR_SEV_DEBUG, "l4db_AddChannelsNoDuplicates [IN]");
  1925. // Copy the dest channels that were not copied yet (that do not appear in the Src NbrAdv)
  1926. for (i = 0; i < srcSize; i++)
  1927. {
  1928. if(!l4db_ValidateChannel(&pSrc[i]))
  1929. {
  1930. continue;
  1931. }
  1932. for (j = 0; j < *destSize; j++)
  1933. {
  1934. if (l4db_IsChannelsEqual(&(pDest[j]), &(pSrc[i]), isComparePreambles))
  1935. {
  1936. TRACE(TR_MOD_NDNS_AGENT, TR_SEV_DEBUG, "l4db_AddChannelsNoDuplicates :frequency = %d, src link quality = %d, dst link quality = %d", pSrc[i].firstFreq, pSrcLinkQuality[i], pDestlinkQuality[j]);
  1937. pDestlinkQuality[j] = pSrcLinkQuality[i];
  1938. TRACE(TR_MOD_NDNS_AGENT, TR_SEV_DEBUG, "l4db_AddChannelsNoDuplicates :pDest[j].ttl = [%d], pSrc[i]=[%d]",pDest[j].ttl , pSrc[i].ttl);
  1939. pDest[j].ttl = pSrc[i].ttl;
  1940. break;
  1941. }
  1942. }
  1943. if (j == *destSize)
  1944. {
  1945. if (*destSize == WMX_CHANNELS_MAX_NUM)
  1946. {
  1947. break; // There is no place for more channels
  1948. }
  1949. // New channel to add
  1950. pDest[j] = pSrc[i];
  1951. pDestlinkQuality[j] = pSrcLinkQuality[i];
  1952. (*destSize)++;
  1953. }
  1954. }
  1955. TRACE(TR_MOD_NDNS_AGENT, TR_SEV_DEBUG, "l4db_AddChannelsNoDuplicates [OUT]");
  1956. }
  1957. /// <summary>
  1958. /// Merge the channel plans. Keep the order so the NbrAdv are first and then the by TTL order. Assumes that the TTL
  1959. /// of the source that is not from NbrAdv is lower then the destination's TTL. (the Src is older channels)
  1960. /// </summary>
  1961. /// <param name="pDest">(IN, OUT) the destination channel plan </<param>
  1962. /// <param name="pSrc">(IN) the source channel plan </<param>
  1963. void l4db_MergeChannelPlans(pChannelPlan_t pDest, pChannelPlan_t pSrc, BOOL isComparePreambles)
  1964. {
  1965. UINT32 srcIndex, destIndex, tmpIndex;
  1966. pChannelPlan_t pDestLocal, pSrcLocal;
  1967. ChannelPlan_t tmpChannelPlan;
  1968. UINT32 i =0;
  1969. // Args validation
  1970. if (pSrc == NULL ||
  1971. pDest == NULL)
  1972. {
  1973. return;
  1974. }
  1975. if (pDest->channelsSize == 0 || pSrc->channelsSize == 0)
  1976. {
  1977. TRACE(TR_MOD_NDNS_AGENT, TR_SEV_ALERT, "l4db_MergeChannelPlans: pDest->channelsSize = %d, pSrc->channelsSize = %d",
  1978. pDest->channelsSize, pSrc->channelsSize);
  1979. return;
  1980. }
  1981. pDestLocal = malloc (pDest->channelsSize * sizeof(ChannelPlan_t));
  1982. if (pDestLocal == NULL)
  1983. {
  1984. TRACE(TR_MOD_NDNS_AGENT, TR_SEV_ALERT, "l4db_MergeChannelPlans: malloc returned NULL");
  1985. return;
  1986. }
  1987. pDestLocal->channelsSize = pDest->channelsSize;
  1988. pDestLocal->bw = pDest->bw;
  1989. // pDestLocal->DummyForCompilerHappy = pDest->DummyForCompilerHappy;
  1990. pDestLocal->duplexMode = pDest->duplexMode;
  1991. pDestLocal->fft = pDest->fft;
  1992. pSrcLocal = malloc (pSrc->channelsSize * sizeof(ChannelPlan_t));
  1993. if (pSrcLocal == NULL)
  1994. {
  1995. free(pDestLocal);
  1996. TRACE(TR_MOD_NDNS_AGENT, TR_SEV_ALERT, "l4db_MergeChannelPlans: malloc returned NULL");
  1997. return;
  1998. }
  1999. pSrcLocal->channelsSize = pSrc->channelsSize;
  2000. pSrcLocal->bw = pSrc->bw;
  2001. // pSrcLocal->DummyForCompilerHappy = pSrc->DummyForCompilerHappy;
  2002. pSrcLocal->duplexMode = pSrc->duplexMode;
  2003. pSrcLocal->fft = pSrc->fft;
  2004. srcIndex = destIndex = tmpIndex = 0;
  2005. for (i=0 ; i < pSrc->channelsSize ; i ++)
  2006. {
  2007. OSAL_memcpy_s(&pSrcLocal->channels[i].bw, sizeof(wmx_BW_t),&pSrc->channels[i].bw ,sizeof(wmx_BW_t));
  2008. OSAL_memcpy_s(&pSrcLocal->channels[i].duplexMode, sizeof(wmx_DuplexMode_t),&pSrc->channels[i].duplexMode ,sizeof(wmx_DuplexMode_t));
  2009. OSAL_memcpy_s(&pSrcLocal->channels[i].fft, sizeof(wmx_FFT_t),&pSrc->channels[i].fft ,sizeof(wmx_FFT_t));
  2010. OSAL_memcpy_s(&pSrcLocal->channels[i].firstFreq, sizeof(wmx_Frequency_t),&pSrc->channels[i].firstFreq ,sizeof(wmx_Frequency_t));
  2011. OSAL_memcpy_s(&pSrcLocal->channels[i].id, (sizeof(CHAR)*MAX_REF_ID_NAME_SIZE),&pSrc->channels[i].id ,(sizeof(CHAR)*MAX_REF_ID_NAME_SIZE));
  2012. OSAL_memcpy_s(&pSrcLocal->channels[i].lastFoundInNbrAdv, sizeof(BOOL),&pSrc->channels[i].lastFoundInNbrAdv ,sizeof(BOOL));
  2013. OSAL_memcpy_s(&pSrcLocal->channels[i].lastFreq, sizeof(wmx_Frequency_t),&pSrc->channels[i].lastFreq ,sizeof(wmx_Frequency_t));
  2014. OSAL_memcpy_s(&pSrcLocal->channels[i].nextFreq, sizeof(wmx_NextFreqStep_t),&pSrc->channels[i].nextFreq ,sizeof(wmx_NextFreqStep_t));
  2015. OSAL_memcpy_s(&pSrcLocal->channels[i].preambleBitmap, sizeof(wmx_Preambles_t),&pSrc->channels[i].preambleBitmap ,sizeof(wmx_Preambles_t));
  2016. OSAL_memcpy_s(&pSrcLocal->channels[i].tagName, (sizeof(CHAR)*MAX_TAG_NAME_SIZE),&pSrc->channels[i] .tagName,(sizeof(CHAR)*MAX_TAG_NAME_SIZE));
  2017. OSAL_memcpy_s(&pSrcLocal->channels[i].ttl, sizeof(UINT32),&pSrc->channels[i].ttl,sizeof(UINT32));
  2018. OSAL_memcpy_s(&pSrcLocal->linkQuality[i], sizeof(UINT32),&pSrc->linkQuality[i],sizeof(UINT32));
  2019. }
  2020. for (i=0 ; i < pDest->channelsSize ; i ++)
  2021. {
  2022. OSAL_memcpy_s(&pDestLocal->channels[i].bw, sizeof(wmx_BW_t),&pDest->channels[i].bw ,sizeof(wmx_BW_t));
  2023. OSAL_memcpy_s(&pDestLocal->channels[i].duplexMode, sizeof(wmx_DuplexMode_t),&pDest->channels[i].duplexMode ,sizeof(wmx_DuplexMode_t));
  2024. OSAL_memcpy_s(&pDestLocal->channels[i].fft, sizeof(wmx_FFT_t),&pDest->channels[i].fft ,sizeof(wmx_FFT_t));
  2025. OSAL_memcpy_s(&pDestLocal->channels[i].firstFreq, sizeof(wmx_Frequency_t),&pDest->channels[i].firstFreq ,sizeof(wmx_Frequency_t));
  2026. OSAL_memcpy_s(&pDestLocal->channels[i].id, (sizeof(CHAR)*MAX_REF_ID_NAME_SIZE),&pDest->channels[i].id ,(sizeof(CHAR)*MAX_REF_ID_NAME_SIZE));
  2027. OSAL_memcpy_s(&pDestLocal->channels[i].lastFoundInNbrAdv, sizeof(BOOL),&pDest->channels[i].lastFoundInNbrAdv ,sizeof(BOOL));
  2028. OSAL_memcpy_s(&pDestLocal->channels[i].lastFreq, sizeof(wmx_Frequency_t),&pDest->channels[i].lastFreq ,sizeof(wmx_Frequency_t));
  2029. OSAL_memcpy_s(&pDestLocal->channels[i].nextFreq, sizeof(wmx_NextFreqStep_t),&pDest->channels[i].nextFreq ,sizeof(wmx_NextFreqStep_t));
  2030. OSAL_memcpy_s(&pDestLocal->channels[i].preambleBitmap, sizeof(wmx_Preambles_t),&pDest->channels[i].preambleBitmap ,sizeof(wmx_Preambles_t));
  2031. OSAL_memcpy_s(&pDestLocal->channels[i].tagName, (sizeof(CHAR)*MAX_TAG_NAME_SIZE),&pDest->channels[i] .tagName,(sizeof(CHAR)*MAX_TAG_NAME_SIZE));
  2032. OSAL_memcpy_s(&pDestLocal->channels[i].ttl, sizeof(UINT32),&pDest->channels[i].ttl,sizeof(UINT32));
  2033. OSAL_memcpy_s(&pDestLocal->linkQuality[i], sizeof(UINT32),&pDest->linkQuality[i],sizeof(UINT32));
  2034. }
  2035. // Copy the NbrAdv channels of the dest
  2036. while ( destIndex < pDestLocal->channelsSize &&
  2037. pDestLocal->channels[destIndex].lastFoundInNbrAdv == TRUE )
  2038. {
  2039. if(l4db_ValidateChannel(&pDestLocal->channels[destIndex]))
  2040. {
  2041. //OSAL_memcpy_s(&tmpChannelPlan.channels[tmpIndex], sizeof(ChannelInfo_t),&pDest->channels[destIndex] ,sizeof(ChannelInfo_t));
  2042. OSAL_memcpy_s(&tmpChannelPlan.channels[tmpIndex].bw, sizeof(wmx_BW_t),&pDestLocal->channels[destIndex].bw ,sizeof(wmx_BW_t));
  2043. OSAL_memcpy_s(&tmpChannelPlan.channels[tmpIndex].duplexMode, sizeof(wmx_DuplexMode_t),&pDestLocal->channels[destIndex].duplexMode ,sizeof(wmx_DuplexMode_t));
  2044. OSAL_memcpy_s(&tmpChannelPlan.channels[tmpIndex].fft, sizeof(wmx_FFT_t),&pDestLocal->channels[destIndex].fft ,sizeof(wmx_FFT_t));
  2045. OSAL_memcpy_s(&tmpChannelPlan.channels[tmpIndex].firstFreq, sizeof(wmx_Frequency_t),&pDestLocal->channels[destIndex].firstFreq ,sizeof(wmx_Frequency_t));
  2046. OSAL_memcpy_s(&tmpChannelPlan.channels[tmpIndex].id, (sizeof(CHAR)*MAX_REF_ID_NAME_SIZE),&pDestLocal->channels[destIndex].id ,(sizeof(CHAR)*MAX_REF_ID_NAME_SIZE));
  2047. OSAL_memcpy_s(&tmpChannelPlan.channels[tmpIndex].lastFoundInNbrAdv, sizeof(BOOL),&pDestLocal->channels[destIndex].lastFoundInNbrAdv ,sizeof(BOOL));
  2048. OSAL_memcpy_s(&tmpChannelPlan.channels[tmpIndex].lastFreq, sizeof(wmx_Frequency_t),&pDestLocal->channels[destIndex].lastFreq ,sizeof(wmx_Frequency_t));
  2049. OSAL_memcpy_s(&tmpChannelPlan.channels[tmpIndex].nextFreq, sizeof(wmx_NextFreqStep_t),&pDestLocal->channels[destIndex].nextFreq ,sizeof(wmx_NextFreqStep_t));
  2050. OSAL_memcpy_s(&tmpChannelPlan.channels[tmpIndex].preambleBitmap, sizeof(wmx_Preambles_t),&pDestLocal->channels[destIndex].preambleBitmap ,sizeof(wmx_Preambles_t));
  2051. OSAL_memcpy_s(&tmpChannelPlan.channels[tmpIndex].tagName, (sizeof(CHAR)*MAX_TAG_NAME_SIZE),&pDestLocal->channels[destIndex] .tagName,(sizeof(CHAR)*MAX_TAG_NAME_SIZE));
  2052. OSAL_memcpy_s(&tmpChannelPlan.channels[tmpIndex].ttl, sizeof(UINT32),&pDestLocal->channels[destIndex] .ttl,sizeof(UINT32));
  2053. OSAL_memcpy_s(&tmpChannelPlan.linkQuality[tmpIndex], sizeof(UINT32),&pDestLocal->linkQuality[destIndex],sizeof(UINT32));
  2054. //tmpChannelPlan.channels[tmpIndex] = pDest->channels[destIndex];
  2055. destIndex++;
  2056. tmpIndex++;
  2057. }
  2058. }
  2059. // Copy the NbrAdv channels of the source
  2060. while ( srcIndex < pSrcLocal->channelsSize &&
  2061. pSrcLocal->channels[srcIndex].lastFoundInNbrAdv == TRUE )
  2062. {
  2063. if(l4db_ValidateChannel(&pSrcLocal->channels[srcIndex]))
  2064. {
  2065. //OSAL_memcpy_s(&tmpChannelPlan.channels[tmpIndex], sizeof(ChannelInfo_t),&pSrc->channels[srcIndex] ,sizeof(ChannelInfo_t));
  2066. OSAL_memcpy_s(&tmpChannelPlan.channels[tmpIndex].bw, sizeof(wmx_BW_t),&pSrcLocal->channels[srcIndex].bw ,sizeof(wmx_BW_t));
  2067. OSAL_memcpy_s(&tmpChannelPlan.channels[tmpIndex].duplexMode, sizeof(wmx_DuplexMode_t),&pSrcLocal->channels[srcIndex].duplexMode ,sizeof(wmx_DuplexMode_t));
  2068. OSAL_memcpy_s(&tmpChannelPlan.channels[tmpIndex].fft, sizeof(wmx_FFT_t),&pSrcLocal->channels[srcIndex].fft ,sizeof(wmx_FFT_t));
  2069. OSAL_memcpy_s(&tmpChannelPlan.channels[tmpIndex].firstFreq, sizeof(wmx_Frequency_t),&pSrcLocal->channels[srcIndex].firstFreq ,sizeof(wmx_Frequency_t));
  2070. OSAL_memcpy_s(&tmpChannelPlan.channels[tmpIndex].id, (sizeof(CHAR)*MAX_REF_ID_NAME_SIZE),&pSrcLocal->channels[srcIndex].id ,(sizeof(CHAR)*MAX_REF_ID_NAME_SIZE));
  2071. OSAL_memcpy_s(&tmpChannelPlan.channels[tmpIndex].lastFoundInNbrAdv, sizeof(BOOL),&pSrcLocal->channels[srcIndex].lastFoundInNbrAdv ,sizeof(BOOL));
  2072. OSAL_memcpy_s(&tmpChannelPlan.channels[tmpIndex].lastFreq, sizeof(wmx_Frequency_t),&pSrcLocal->channels[srcIndex].lastFreq ,sizeof(wmx_Frequency_t));
  2073. OSAL_memcpy_s(&tmpChannelPlan.channels[tmpIndex].nextFreq, sizeof(wmx_NextFreqStep_t),&pSrcLocal->channels[srcIndex].nextFreq ,sizeof(wmx_NextFreqStep_t));
  2074. OSAL_memcpy_s(&tmpChannelPlan.channels[tmpIndex].preambleBitmap, sizeof(wmx_Preambles_t),&pSrcLocal->channels[srcIndex].preambleBitmap ,sizeof(wmx_Preambles_t));
  2075. OSAL_memcpy_s(&tmpChannelPlan.channels[tmpIndex].tagName, (sizeof(CHAR)*MAX_TAG_NAME_SIZE),&pSrcLocal->channels[srcIndex] .tagName,(sizeof(CHAR)*MAX_TAG_NAME_SIZE));
  2076. OSAL_memcpy_s(&tmpChannelPlan.channels[tmpIndex].ttl, sizeof(UINT32),&pSrcLocal->channels[srcIndex] .ttl,sizeof(UINT32));
  2077. OSAL_memcpy_s(&tmpChannelPlan.linkQuality[tmpIndex], sizeof(UINT32),&pSrcLocal->linkQuality[srcIndex],sizeof(UINT32));
  2078. //tmpChannelPlan.channels[tmpIndex] = pSrc->channels[srcIndex];
  2079. srcIndex++;
  2080. tmpIndex++;
  2081. }
  2082. }
  2083. // Copy the rest of the Src channels (the ones that are after the NbrAdv)
  2084. l4db_AddChannelsNoDuplicates(tmpChannelPlan.channels,
  2085. tmpChannelPlan.linkQuality,
  2086. &tmpIndex,
  2087. pSrcLocal->channels + srcIndex,
  2088. pSrcLocal->channelsSize - srcIndex,
  2089. pSrcLocal->linkQuality + srcIndex,
  2090. isComparePreambles);
  2091. /*L4db_PrintDiscoveredNAPsList();
  2092. TRACE(TR_MOD_NDNS_AGENT, TR_SEV_ERR, "l4db_MergeChannelPlans -- > After first l4db_AddChannelsNoDuplicates");*/
  2093. // Copy the dest channels that were not copied yet (that do not appear in the Src NbrAdv)
  2094. l4db_AddChannelsNoDuplicates(tmpChannelPlan.channels,
  2095. tmpChannelPlan.linkQuality,
  2096. &tmpIndex,
  2097. pDestLocal->channels + destIndex,
  2098. pDestLocal->channelsSize - destIndex,
  2099. pDestLocal->linkQuality + destIndex,
  2100. isComparePreambles);
  2101. /*L4db_PrintDiscoveredNAPsList();
  2102. TRACE(TR_MOD_NDNS_AGENT, TR_SEV_ERR, "l4db_MergeChannelPlans -- > After second l4db_AddChannelsNoDuplicates");*/
  2103. // Copy the result to the Dest array
  2104. if (tmpIndex > 0)
  2105. {
  2106. for (i=0 ; i < tmpIndex ; i++)
  2107. {
  2108. OSAL_memcpy_s(&pDest->channels[i].bw, sizeof(wmx_BW_t),&tmpChannelPlan.channels[i].bw ,sizeof(wmx_BW_t));
  2109. OSAL_memcpy_s(&pDest->channels[i].duplexMode, sizeof(wmx_DuplexMode_t),&tmpChannelPlan.channels[i].duplexMode ,sizeof(wmx_DuplexMode_t));
  2110. OSAL_memcpy_s(&pDest->channels[i].fft, sizeof(wmx_FFT_t),&tmpChannelPlan.channels[i].fft ,sizeof(wmx_FFT_t));
  2111. OSAL_memcpy_s(&pDest->channels[i].firstFreq, sizeof(wmx_Frequency_t),&tmpChannelPlan.channels[i].firstFreq ,sizeof(wmx_Frequency_t));
  2112. OSAL_memcpy_s(&pDest->channels[i].id, (sizeof(CHAR)*MAX_REF_ID_NAME_SIZE),&tmpChannelPlan.channels[i].id ,(sizeof(CHAR)*MAX_REF_ID_NAME_SIZE));
  2113. OSAL_memcpy_s(&pDest->channels[i].lastFoundInNbrAdv, sizeof(BOOL),&tmpChannelPlan.channels[i].lastFoundInNbrAdv ,sizeof(BOOL));
  2114. OSAL_memcpy_s(&pDest->channels[i].lastFreq, sizeof(wmx_Frequency_t),&tmpChannelPlan.channels[i].lastFreq ,sizeof(wmx_Frequency_t));
  2115. OSAL_memcpy_s(&pDest->channels[i].nextFreq, sizeof(wmx_NextFreqStep_t),&tmpChannelPlan.channels[i].nextFreq ,sizeof(wmx_NextFreqStep_t));
  2116. OSAL_memcpy_s(&pDest->channels[i].preambleBitmap, sizeof(wmx_Preambles_t),&tmpChannelPlan.channels[i].preambleBitmap ,sizeof(wmx_Preambles_t));
  2117. OSAL_memcpy_s(&pDest->channels[i].tagName, (sizeof(CHAR)*MAX_TAG_NAME_SIZE),&tmpChannelPlan.channels[i] .tagName,(sizeof(CHAR)*MAX_TAG_NAME_SIZE));
  2118. OSAL_memcpy_s(&pDest->channels[i].ttl, sizeof(UINT32),&tmpChannelPlan.channels[i].ttl,sizeof(UINT32));
  2119. OSAL_memcpy_s(&pDest->linkQuality[i], sizeof(UINT32),&tmpChannelPlan.linkQuality[i],sizeof(UINT32));
  2120. //OSAL_memcpy_s (&pDest->channels[i], sizeof(ChannelInfo_t), &tmpChannelPlan.channels[i], sizeof(ChannelInfo_t));
  2121. /*OSAL_memcpy_s(&(pDest->channels), WMX_CHANNELS_MAX_NUM * sizeof(ChannelInfo_t),
  2122. &(tmpChannelPlan.channels), WMX_CHANNELS_MAX_NUM * sizeof(ChannelInfo_t));*/
  2123. }
  2124. pDest->channelsSize = tmpIndex;
  2125. }
  2126. free(pSrcLocal);
  2127. free(pDestLocal);
  2128. }
  2129. /// <summary>
  2130. /// Copy an eap info with ordering its array elements
  2131. /// </summary>
  2132. /// <param name="pDest">(OUT) the destionation </<param>
  2133. /// <param name="src">(IN) the source </<param>
  2134. void l4db_CopyEapInfo(pEAP_t pDest, pEAP_t pSrc)
  2135. {
  2136. int i;
  2137. UINT32 size = 0;
  2138. size_t tempStrLen = 0;
  2139. //copy the tagName
  2140. OSAL_strcpy_s(pDest->tagName, MAX_TAG_NAME_SIZE, pSrc->tagName);
  2141. //copy the EAP method
  2142. pDest->EAPMethod = pSrc->EAPMethod;
  2143. //copy the vendor id
  2144. pDest->vendorId = pSrc->vendorId;
  2145. //copy the vendor type
  2146. pDest->vendorType = pSrc->vendorType;
  2147. //copy user name
  2148. OSAL_strcpy_s(pDest->id, WMX_SUBSCRIBER_ID_MAX_SIZE, pSrc->id);
  2149. //copy the pseudo id
  2150. OSAL_strcpy_s(pDest->provisionedPseudoId, WMX_SUBSCRIBER_ID_MAX_SIZE, pSrc->provisionedPseudoId);
  2151. //copy the password
  2152. OSAL_strcpy_s(pDest->Password, MAX_EAP_PASSWORD_SIZE, pSrc->Password);
  2153. //copy the realm
  2154. OSAL_strcpy_s(pDest->realm, MAX_REALM_SIZE, pSrc->realm);
  2155. //copy use pseudo
  2156. pDest->usePrivacy = pSrc->usePrivacy;
  2157. //copy encaps
  2158. pDest->encaps = pSrc->encaps;
  2159. //copy vfy srv realms - NOT SUPPORTED NOW
  2160. //pDest->vfySrvRealm = pSrc->vfySrvRealm;
  2161. //copy the srv realms - NOT SUPPORTED NOW
  2162. //for(i = 0 ; i < MAX_NUM_OF_SRV_REALMS ; i++)
  2163. //{
  2164. // if(0 != strlen(pSrc->srvRealms[i].tagName))
  2165. // {
  2166. // memcpy(&pDest->srvRealms[size], &pSrc->srvRealms[i], sizeof(pDest->srvRealms[size]));
  2167. // size++;
  2168. // }
  2169. //}
  2170. //pDest->srvRealmsSize = size;
  2171. //size = 0;
  2172. //copy the certs
  2173. for(i = 0 ; i < MAX_NUM_OF_CERTS ; i++)
  2174. {
  2175. tempStrLen = OSAL_strnlen(pSrc->certs[i].tagName, MAX_TAG_NAME_SIZE);
  2176. if(0 != tempStrLen && MAX_TAG_NAME_SIZE != tempStrLen)
  2177. {
  2178. memcpy(&pDest->certs[size], &pSrc->certs[i], sizeof(pDest->certs[size]));
  2179. size++;
  2180. }
  2181. }
  2182. pDest->certsSize = size;
  2183. }
  2184. /// <summary>
  2185. /// Copy a subscription params with ordering its array elements
  2186. /// </summary>
  2187. /// <param name="pDest">(OUT) the destionation </<param>
  2188. /// <param name="src">(IN) the source </<param>
  2189. void l4db_CopySubscriptionParams(pSubscriptionParams_t pDest, pSubscriptionParams_t pSrc)
  2190. {
  2191. int i, j;
  2192. UINT32 eapsSize = 0, otherSize = 0;
  2193. size_t tempStrLen = 0;
  2194. //copy the primary
  2195. //name
  2196. OSAL_strcpy_s(pDest->primary.name, WMX_SUBSCRIBER_NAME_MAX_SIZE, pSrc->primary.name);
  2197. //activated
  2198. pDest->primary.activated = pSrc->primary.activated;
  2199. //eap info
  2200. for(i = 0 ; i < MAX_NUM_OF_EAP_METHODS ; i++)
  2201. {
  2202. tempStrLen = OSAL_strnlen(pSrc->primary.eapInfo[i].tagName, MAX_TAG_NAME_SIZE);
  2203. if(0 != tempStrLen && MAX_TAG_NAME_SIZE != tempStrLen)
  2204. {
  2205. l4db_CopyEapInfo(&pDest->primary.eapInfo[eapsSize], &pSrc->primary.eapInfo[i]);
  2206. eapsSize++;
  2207. }
  2208. }
  2209. pDest->primary.eapInfoSize = eapsSize;
  2210. eapsSize = 0;
  2211. //other subscriptions
  2212. for(i = 0 ; i < WMX_NSP_SUBSCRIBERS_MAX_NUM ; i++)
  2213. {
  2214. tempStrLen = OSAL_strnlen(pSrc->other[i].tagName, MAX_TAG_NAME_SIZE);
  2215. if(0 != tempStrLen && MAX_TAG_NAME_SIZE != tempStrLen)
  2216. {
  2217. //copy the tag name
  2218. OSAL_strcpy_s(pDest->other[otherSize].tagName, MAX_TAG_NAME_SIZE, pSrc->other[i].tagName);
  2219. //copy the name
  2220. //name
  2221. OSAL_strcpy_s(pDest->other[otherSize].subscriberInfo.name, WMX_SUBSCRIBER_NAME_MAX_SIZE, pSrc->other[i].subscriberInfo.name);
  2222. //activated
  2223. pDest->other[otherSize].subscriberInfo.activated = pSrc->other[i].subscriberInfo.activated;
  2224. //Eap
  2225. for(j = 0 ; j < MAX_NUM_OF_EAP_METHODS ; j++)
  2226. {
  2227. tempStrLen= OSAL_strnlen(pSrc->other[i].subscriberInfo.eapInfo[j].tagName, MAX_TAG_NAME_SIZE);
  2228. if(0 != tempStrLen && MAX_TAG_NAME_SIZE != tempStrLen)
  2229. {
  2230. l4db_CopyEapInfo(&pDest->other[otherSize].subscriberInfo.eapInfo[eapsSize], &pSrc->other[i].subscriberInfo.eapInfo[j]);
  2231. eapsSize++;
  2232. }
  2233. }
  2234. pDest->other[otherSize].subscriberInfo.eapInfoSize = eapsSize;
  2235. otherSize++;
  2236. }
  2237. }
  2238. pDest->otherSize = otherSize;
  2239. }
  2240. /// <summary>
  2241. /// Copy a nw params with ordering its array elements
  2242. /// </summary>
  2243. /// <param name="pDest">(OUT) the destionation </<param>
  2244. /// <param name="src">(IN) the source </<param>
  2245. void l4db_CopyNwParams(pNwParams_t pDest, pNwParams_t pSrc)
  2246. {
  2247. int i, j;
  2248. UINT32 size = 0, innerSize = 0;
  2249. size_t tempStrLen = 0;
  2250. //copy the provisioned name
  2251. OSAL_strcpy_s(pDest->provisionedName, WMX_NSP_NAME_MAX_SIZE, pSrc->provisionedName);
  2252. // copy the server ID
  2253. OSAL_strcpy_s(pDest->serverID, MAX_SERVER_ID_SIZE, pSrc->serverID);
  2254. //copy the capl
  2255. pDest->capl.any = pSrc->capl.any;
  2256. for(i = 0 ; i < WMX_NAPS_MAX_NUM ; i++)
  2257. {
  2258. tempStrLen = OSAL_strnlen(pSrc->capl.naps[i].tagName, MAX_TAG_NAME_SIZE + 1);
  2259. if(0 != tempStrLen && (MAX_TAG_NAME_SIZE + 1) != tempStrLen)
  2260. {
  2261. for(j = 0 ; j < WMX_CHANNELS_MAX_NUM ; j++)
  2262. {
  2263. tempStrLen = OSAL_strnlen(pSrc->capl.naps[i].channelPlanRefIds[j].tagName, MAX_TAG_NAME_SIZE);
  2264. if(0 != tempStrLen && MAX_TAG_NAME_SIZE != tempStrLen)
  2265. {
  2266. memcpy(&pDest->capl.naps[size].channelPlanRefIds[innerSize],
  2267. &pSrc->capl.naps[i].channelPlanRefIds[j],
  2268. sizeof(pDest->capl.naps[size].channelPlanRefIds[innerSize]));
  2269. innerSize++;
  2270. }
  2271. }
  2272. //update the number of entries in the rapl
  2273. pDest->capl.naps[size].channelRefsSize = innerSize;
  2274. memcpy(pDest->capl.naps[size].napID,
  2275. pSrc->capl.naps[i].napID,
  2276. sizeof(pDest->capl.naps[size].napID));
  2277. pDest->capl.naps[size].priority = pSrc->capl.naps[i].priority;
  2278. OSAL_strcpy_s(pDest->capl.naps[size].tagName, MAX_TAG_NAME_SIZE, pSrc->capl.naps[i].tagName);
  2279. size++;
  2280. }
  2281. }
  2282. //update the number of entries in the capl
  2283. pDest->capl.napsSize = size;
  2284. size = 0;
  2285. //copy the rapl
  2286. pDest->rapl.any = pSrc->rapl.any;
  2287. for(i = 0 ; i < MAX_ROAMING_PARTNERS ; i++)
  2288. {
  2289. tempStrLen = OSAL_strnlen(pSrc->rapl.roamingPartners[i].tagName, MAX_TAG_NAME_SIZE);
  2290. if(0 != tempStrLen && MAX_TAG_NAME_SIZE != tempStrLen)
  2291. {
  2292. memcpy(&pDest->rapl.roamingPartners[size], &pSrc->rapl.roamingPartners[i], sizeof(pDest->rapl.roamingPartners[size]));
  2293. size++;
  2294. }
  2295. }
  2296. //update the number of entries in the rapl
  2297. pDest->rapl.roamingPartnersSize = size;
  2298. size = 0;
  2299. //copy the channel plan
  2300. l4db_CopyChannelPlan(&pDest->channelPlan, &pSrc->channelPlan);
  2301. //copy the hNsps
  2302. for(i = 0 ; i < WMX_NSP_IDS_MAX_NUM ; i++)
  2303. {
  2304. tempStrLen = OSAL_strnlen(pSrc->hNsps[i].tagName, MAX_TAG_NAME_SIZE);
  2305. if(0 != tempStrLen && MAX_TAG_NAME_SIZE != tempStrLen)
  2306. {
  2307. pDest->hNsps[size].nspId = pSrc->hNsps[i].nspId;
  2308. size++;
  2309. }
  2310. }
  2311. //update the number of elements in the hNsps array
  2312. pDest->hNspsSize = size;
  2313. //copy the polling interval
  2314. pDest->pollingInterval = pSrc->pollingInterval;
  2315. pDest->pollingAttempts = pSrc->pollingAttempts;
  2316. }
  2317. /// <summary>
  2318. /// Copy an NSP with ordering its array elements
  2319. /// </summary>
  2320. /// <param name="pDest">(OUT) the destionation </<param>
  2321. /// <param name="src">(IN) the source </<param>
  2322. void l4db_CopyProvisionedNsp(pProvisionedNsp_t pDest, pProvisionedNsp_t pSrc)
  2323. {
  2324. int i;
  2325. int size = 0;
  2326. size_t tempStrLen = 0;
  2327. //copy the tag name
  2328. OSAL_strcpy_s(pDest->tagName, MAX_TAG_NAME_SIZE, pSrc->tagName);
  2329. //copy the nw params
  2330. l4db_CopyNwParams(&pDest->nwParams, &pSrc->nwParams);
  2331. //copy subscription params
  2332. l4db_CopySubscriptionParams(&pDest->subscriptionParams, &pSrc->subscriptionParams);
  2333. //copy the contacts
  2334. for(i = 0 ; i < MAX_NUM_OF_CONTACTS ; i++)
  2335. {
  2336. tempStrLen = OSAL_strnlen(pSrc->contacts[i].tagName, MAX_TAG_NAME_SIZE);
  2337. if(0 != tempStrLen && MAX_TAG_NAME_SIZE != tempStrLen)
  2338. {
  2339. memcpy(&pDest->contacts[size], &pSrc->contacts[i], sizeof(pDest->contacts[size]));
  2340. size++;
  2341. }
  2342. }
  2343. pDest->contactsSize = size;
  2344. }
  2345. /// <summary>
  2346. /// Copy a discovered nap
  2347. /// </summary>
  2348. /// <param name="pDest">(OUT) the destionation </<param>
  2349. /// <param name="src">(IN) the source </<param>
  2350. void l4db_CopyDiscoveredNap(pL4db_Nap_t dst, pDiscoveredNap_t src)
  2351. {
  2352. memcpy(dst->napID, src->napID, sizeof(dst->napID));
  2353. dst->changeCount = src->changeCount;
  2354. l4db_CopyChannelPlan(&dst->discoveredChannelPlan, &src->channelPlan);
  2355. }
  2356. /// <summary>
  2357. /// Copy a provisioned nap
  2358. /// </summary>
  2359. /// <param name="pDest">(OUT) the destionation </<param>
  2360. /// <param name="src">(IN) the source </<param>
  2361. void l4db_CopyProvisionedNap(pL4db_Nap_t dst, pL4db_Nap_t src)
  2362. {
  2363. memcpy(dst->napID, src->napID, sizeof(dst->napID));
  2364. OSAL_strcpy_s(dst->tagName, MAX_TAG_NAME_SIZE, src->tagName);
  2365. dst->priority = src->priority;
  2366. l4db_CopyChannelsRefs(dst, src);
  2367. }
  2368. /// <summary>
  2369. /// creates a channel's dummy tag name
  2370. /// </summary>
  2371. /// <param name="tagName">(OUT) the tag name to be created </<param>
  2372. /// <param name="channelIndex">(IN) the index in the channel array</<param>
  2373. void l4db_CreateChannelTagName(char * tagName, int channelIndex)
  2374. {
  2375. OSAL_strcpy_s(tagName, 3, C_L4DB_EMPTY_STRING);//L4DB_CHANNEL_TAG_NAME_PREFIX);
  2376. OSAL_itoa_s(channelIndex, tagName, MAX_TAG_NAME_SIZE - strlen(C_L4DB_EMPTY_STRING), 10);
  2377. tagName[3] = '\0';
  2378. }
  2379. /// <summary>
  2380. /// checks if it is legal to add the given NAP ID to the DB. If it already exists in this NSP
  2381. /// under a different tag name, it is illegal
  2382. /// </summary>
  2383. /// <param name="napID">(IN) the requested NAP ID </param>
  2384. /// <param name="napTagName">(IN) the nap's tag name </param>
  2385. /// <param name="nspTagName">(IN) the nsp's tag name </param>
  2386. /// <returns>TRUE is legal and FALSE otherwise </returns>
  2387. BOOL l4db_IsLegalToAddNapId(wmx_NAPid_t napID, char * napTagName, char * nspTagName)
  2388. {
  2389. int i;
  2390. pProvisionedNsp_t pFoundNsp;
  2391. //get our NSP
  2392. pFoundNsp = l4db_GetProvisionedNspByTagName(nspTagName);
  2393. if(NULL == pFoundNsp)
  2394. {
  2395. return TRUE; //the NSP doesn't exist yet, therefore this addition is legal
  2396. }
  2397. for(i = 0 ; i < WMX_NAPS_MAX_NUM ; i++)
  2398. {
  2399. if(TRUE == l4db_IsNapidEqual(napID, pFoundNsp->nwParams.capl.naps[i].napID))
  2400. {
  2401. //if their tag names aren't equal, this addition is illegal
  2402. if(TRUE == l4db_CompareString(napTagName, pFoundNsp->nwParams.capl.naps[i].tagName))
  2403. {
  2404. return FALSE;
  2405. }
  2406. }
  2407. }
  2408. return TRUE;
  2409. }
  2410. int l4db_CompareNapRSSIandCINR(const void * elem1, const void * elem2)
  2411. {
  2412. wmx_pNAP_t nap1, nap2;
  2413. nap1 = (wmx_pNAP_t)elem1;
  2414. nap2 = (wmx_pNAP_t)elem2;
  2415. if (nap1->bestCINR > nap2->bestCINR ||
  2416. (nap1->bestCINR == nap2->bestCINR && nap1->bestRssi > nap2->bestRssi))
  2417. {
  2418. return 1;
  2419. }
  2420. else if(nap1->bestCINR < nap2->bestCINR ||
  2421. (nap1->bestCINR == nap2->bestCINR && nap1->bestRssi < nap2->bestRssi))
  2422. {
  2423. return -1;
  2424. }
  2425. else
  2426. {
  2427. return 0;
  2428. }
  2429. }
  2430. int l4db_CompareNapPriority(const void * elem1, const void * elem2)
  2431. {
  2432. int compareResult = 0;
  2433. pL4db_Nap_t nap1, nap2;
  2434. nap1 = (pL4db_Nap_t)elem1;
  2435. nap2 = (pL4db_Nap_t)elem2;
  2436. if(nap1->priority > nap2->priority)
  2437. {
  2438. compareResult = 1;
  2439. }
  2440. else if(nap1->priority < nap2->priority)
  2441. {
  2442. compareResult = -1;
  2443. }
  2444. return compareResult;
  2445. }
  2446. //compare the channels by the ttl and if they equal compare the boolean lastFoundInNbrAdv
  2447. int l4db_CompareChannelInfoByAge(const void * elem1, const void * elem2)
  2448. {
  2449. pChannelInfo_t ChannelInfo1, ChannelInfo2;
  2450. int compareResult = 0;
  2451. ChannelInfo1 = (pChannelInfo_t)elem1;
  2452. ChannelInfo2 = (pChannelInfo_t)elem2;
  2453. //The sorting is by the lastFoundInNbrAdv and then by the ttl
  2454. if(TRUE == ChannelInfo1->lastFoundInNbrAdv && FALSE == ChannelInfo2->lastFoundInNbrAdv)
  2455. {
  2456. compareResult = -1;
  2457. }
  2458. else
  2459. {
  2460. if(FALSE == ChannelInfo1->lastFoundInNbrAdv && TRUE == ChannelInfo2->lastFoundInNbrAdv)
  2461. {
  2462. compareResult = 1;
  2463. }
  2464. else
  2465. {
  2466. if(ChannelInfo1->ttl > ChannelInfo2->ttl)
  2467. {
  2468. compareResult = -1;
  2469. }
  2470. else if(ChannelInfo1->ttl < ChannelInfo2->ttl)
  2471. {
  2472. compareResult = 1;
  2473. }
  2474. }
  2475. }
  2476. return compareResult;
  2477. }
  2478. /// <summary>
  2479. // This function builds the parameter as a concatenation between the following:
  2480. // ./WiMAX/WiMAXRadioModule/0/Man
  2481. // -
  2482. // ./WiMAX/WiMAXRadioModule/0/Mod
  2483. // -
  2484. // ./WiMAX/WiMAXRadioModule/0/SwV
  2485. // -
  2486. // ./DevDetail/SwV
  2487. // -
  2488. // ./WiMAX/TerminalEquipment/SwV
  2489. // -
  2490. // ./WiMAX/TerminalEquipment/Man
  2491. /// </summary>
  2492. void l4db_BuildVersionString(char pVersion[MAX_SWV2_NAME_SIZE])
  2493. {
  2494. pWmxRadioModule_t pRadioModule;
  2495. pTerminalEquipment_t pTermEquipment;
  2496. pDevDetail_t pDevDetail;
  2497. pDevInfo_t pDevInfo;
  2498. BOOL res;
  2499. char fixSpecialCharacters[MAX_REGISTRY_ANSWER] = DEFAULT_TRUE_LOWER;
  2500. pRadioModule = l4db_GetWmxRadioModuleStruct(0);
  2501. pTermEquipment = l4db_GetTeminalEquipmentStruct();
  2502. pDevDetail = l4db_GetDevDetail();
  2503. pDevInfo = l4db_GetDevInfo();
  2504. pVersion[0] = '\0';
  2505. TRACE(TR_MOD_NDNS_AGENT, TR_SEV_DEBUG, "l4db_InitWimax - pDevDetail->devType = [%s].",pDevDetail->devType);
  2506. if (( FALSE == (OSAL_stricmp ("",pDevDetail->devType))) || ( FALSE == (OSAL_stricmp ("Null",pDevDetail->devType))))
  2507. {
  2508. TRACE(TR_MOD_NDNS_AGENT, TR_SEV_DEBUG, "l4db_InitWimax - using default Laptop pDevDetail->devType = [%s].",pDevDetail->devType);
  2509. OSAL_strncpy_s(pDevDetail->devType, (sizeof(char)*MAX_DEV_TYPE_SIZE),"Laptop", (6*sizeof(char)));
  2510. }
  2511. TRACE(TR_MOD_NDNS_AGENT, TR_SEV_DEBUG, "l4db_InitWimax - after copy pDevDetail->devType = [%s].",pDevDetail->devType);
  2512. if (( FALSE == (OSAL_stricmp (L4DB_DEV_TYPE_CONST,pDevDetail->devType))) || ( FALSE == (OSAL_stricmp (L4DB_DEV_TYPE_UPPER_CONST,pDevDetail->devType))) || ( FALSE == (OSAL_stricmp ("",pDevDetail->devType)))){
  2513. TRACE(TR_MOD_NDNS_AGENT, TR_SEV_DEBUG, "l4db_InitWimax - building SWV2 for Laptop.");
  2514. // V5 SWV2
  2515. OSAL_strncat_s(pVersion, MAX_SWV2_NAME_SIZE, pDevDetail->devType, OSAL_strnlen(pDevDetail->devType, MAX_DEV_TYPE_SIZE));
  2516. OSAL_strncat_s(pVersion, MAX_SWV2_NAME_SIZE, L4DB_XML_TOKEN_DASH, strlen(L4DB_XML_TOKEN_DASH));
  2517. OSAL_strncat_s(pVersion, MAX_SWV2_NAME_SIZE, pRadioModule->productVersions.manufacturer, OSAL_strnlen(pRadioModule->productVersions.manufacturer, MAX_MAN_NAME_SIZE));
  2518. OSAL_strncat_s(pVersion, MAX_SWV2_NAME_SIZE, L4DB_XML_TOKEN_DASH, strlen(L4DB_XML_TOKEN_DASH));
  2519. OSAL_strncat_s(pVersion, MAX_SWV2_NAME_SIZE, pRadioModule->productVersions.model, OSAL_strnlen(pRadioModule->productVersions.model, MAX_MOD_NAME_SIZE));
  2520. OSAL_strncat_s(pVersion, MAX_SWV2_NAME_SIZE, L4DB_XML_TOKEN_DASH, strlen(L4DB_XML_TOKEN_DASH));
  2521. OSAL_strncat_s(pVersion, MAX_SWV2_NAME_SIZE, pRadioModule->productVersions.swVersion, OSAL_strnlen(pRadioModule->productVersions.swVersion, MAX_VERSION_SIZE));
  2522. OSAL_strncat_s(pVersion, MAX_SWV2_NAME_SIZE, L4DB_XML_TOKEN_DASH, strlen(L4DB_XML_TOKEN_DASH));
  2523. OSAL_strncat_s(pVersion, MAX_SWV2_NAME_SIZE, pTermEquipment->productVersions.manufacturer, OSAL_strnlen(pTermEquipment->productVersions.manufacturer, WMX_MANUFACTURER_NAME_MAX_LENGTH));
  2524. OSAL_strncat_s(pVersion, MAX_SWV2_NAME_SIZE, L4DB_XML_TOKEN_DASH, strlen(L4DB_XML_TOKEN_DASH));
  2525. OSAL_strncat_s(pVersion, MAX_SWV2_NAME_SIZE, pRadioModule->productVersions.swVersion, OSAL_strnlen(pRadioModule->productVersions.swVersion, MAX_VERSION_SIZE));
  2526. OSAL_strncat_s(pVersion, MAX_SWV2_NAME_SIZE, L4DB_XML_TOKEN_DASH, strlen(L4DB_XML_TOKEN_DASH));
  2527. // Init SW version with OS version
  2528. res = OSAL_GetOSVersion(pTermEquipment->productVersions.swVersion);
  2529. if (!res)
  2530. {
  2531. TRACE(TR_MOD_NDNS_AGENT, TR_SEV_ERR, "l4db_InitWimax - Failed to build OS version string.");
  2532. }
  2533. OSAL_strncat_s(pVersion, MAX_SWV2_NAME_SIZE, pTermEquipment->productVersions.swVersion, OSAL_strnlen(pTermEquipment->productVersions.swVersion, MAX_VERSION_SIZE));
  2534. //OSAL_strncat_s(pVersion, MAX_SWV2_NAME_SIZE, L4DB_XML_TOKEN_DASH, strlen(L4DB_XML_TOKEN_DASH));
  2535. ////V4 swv2
  2536. //OSAL_strncat_s(pVersion, MAX_SWV2_NAME_SIZE, pRadioModule->productVersions.manufacturer, OSAL_strnlen(pRadioModule->productVersions.manufacturer, MAX_MAN_NAME_SIZE));
  2537. //OSAL_strncat_s(pVersion, MAX_SWV2_NAME_SIZE, L4DB_XML_TOKEN_DASH, strlen(L4DB_XML_TOKEN_DASH));
  2538. //OSAL_strncat_s(pVersion, MAX_SWV2_NAME_SIZE, pRadioModule->productVersions.model, OSAL_strnlen(pRadioModule->productVersions.model, MAX_MOD_NAME_SIZE));
  2539. //OSAL_strncat_s(pVersion, MAX_SWV2_NAME_SIZE, L4DB_XML_TOKEN_DASH, strlen(L4DB_XML_TOKEN_DASH));
  2540. //OSAL_strncat_s(pVersion, MAX_SWV2_NAME_SIZE, pRadioModule->productVersions.swVersion, OSAL_strnlen(pRadioModule->productVersions.swVersion, MAX_VERSION_SIZE));
  2541. //OSAL_strncat_s(pVersion, MAX_SWV2_NAME_SIZE, L4DB_XML_TOKEN_DASH, strlen(L4DB_XML_TOKEN_DASH));
  2542. //OSAL_strncat_s(pVersion, MAX_SWV2_NAME_SIZE, pDevDetail->swVersion, OSAL_strnlen(pDevDetail->swVersion, MAX_VERSION_SIZE));
  2543. //OSAL_strncat_s(pVersion, MAX_SWV2_NAME_SIZE, L4DB_XML_TOKEN_DASH, strlen(L4DB_XML_TOKEN_DASH));
  2544. //
  2545. //// Init SW version with OS version
  2546. //res = l4db_GetOSVersion(pTermEquipment->productVersions.swVersion);
  2547. //if (!res)
  2548. //{
  2549. // TRACE(TR_MOD_NDNS_AGENT, TR_SEV_ERR, "l4db_InitWimax - Failed to build OS version string.");
  2550. //}
  2551. //OSAL_strncat_s(pVersion, MAX_SWV2_NAME_SIZE, pTermEquipment->productVersions.swVersion, OSAL_strnlen(pTermEquipment->productVersions.swVersion, MAX_VERSION_SIZE));
  2552. //OSAL_strncat_s(pVersion, MAX_SWV2_NAME_SIZE, L4DB_XML_TOKEN_DASH, strlen(L4DB_XML_TOKEN_DASH));
  2553. //OSAL_strncat_s(pVersion, MAX_SWV2_NAME_SIZE, pTermEquipment->productVersions.manufacturer, OSAL_strnlen(pTermEquipment->productVersions.manufacturer, MAX_MAN_NAME_SIZE));
  2554. }else {
  2555. // Not Laptop Device
  2556. // V5 SWV2
  2557. TRACE(TR_MOD_NDNS_AGENT, TR_SEV_DEBUG, "l4db_InitWimax - building SWV2 for non Laptop.");
  2558. OSAL_strncat_s(pVersion, MAX_SWV2_NAME_SIZE, pDevDetail->devType, OSAL_strnlen(pDevDetail->devType, MAX_DEV_TYPE_SIZE));
  2559. OSAL_strncat_s(pVersion, MAX_SWV2_NAME_SIZE, L4DB_XML_TOKEN_DASH, strlen(L4DB_XML_TOKEN_DASH));
  2560. OSAL_strncat_s(pVersion, MAX_SWV2_NAME_SIZE, pRadioModule->productVersions.manufacturer, OSAL_strnlen(pRadioModule->productVersions.manufacturer, MAX_MAN_NAME_SIZE));
  2561. OSAL_strncat_s(pVersion, MAX_SWV2_NAME_SIZE, L4DB_XML_TOKEN_DASH, strlen(L4DB_XML_TOKEN_DASH));
  2562. OSAL_strncat_s(pVersion, MAX_SWV2_NAME_SIZE, pRadioModule->productVersions.model, OSAL_strnlen(pRadioModule->productVersions.model, MAX_MOD_NAME_SIZE));
  2563. OSAL_strncat_s(pVersion, MAX_SWV2_NAME_SIZE, L4DB_XML_TOKEN_DASH, strlen(L4DB_XML_TOKEN_DASH));
  2564. OSAL_strncat_s(pVersion, MAX_SWV2_NAME_SIZE, pRadioModule->productVersions.swVersion, OSAL_strnlen(pRadioModule->productVersions.swVersion, MAX_VERSION_SIZE));
  2565. OSAL_strncat_s(pVersion, MAX_SWV2_NAME_SIZE, L4DB_XML_TOKEN_DASH, strlen(L4DB_XML_TOKEN_DASH));
  2566. OSAL_strncat_s(pVersion, MAX_SWV2_NAME_SIZE, pDevInfo->manufacturer, OSAL_strnlen(pDevInfo->manufacturer, MAX_MAN_NAME_SIZE));
  2567. OSAL_strncat_s(pVersion, MAX_SWV2_NAME_SIZE, L4DB_XML_TOKEN_DASH, strlen(L4DB_XML_TOKEN_DASH));
  2568. OSAL_strncat_s(pVersion, MAX_SWV2_NAME_SIZE, pDevInfo->model, OSAL_strnlen(pDevInfo->model, MAX_MOD_NAME_SIZE));
  2569. OSAL_strncat_s(pVersion, MAX_SWV2_NAME_SIZE, L4DB_XML_TOKEN_DASH, strlen(L4DB_XML_TOKEN_DASH));
  2570. OSAL_strncat_s(pVersion, MAX_SWV2_NAME_SIZE, pDevDetail->swVersion, OSAL_strnlen(pDevDetail->swVersion, MAX_VERSION_SIZE));
  2571. OSAL_strncat_s(pVersion, MAX_SWV2_NAME_SIZE, L4DB_XML_TOKEN_DASH, strlen(L4DB_XML_TOKEN_DASH));
  2572. // Init SW version with OS version
  2573. res = OSAL_GetOSVersion(pTermEquipment->productVersions.swVersion);
  2574. if (!res)
  2575. {
  2576. TRACE(TR_MOD_NDNS_AGENT, TR_SEV_ERR, "l4db_InitWimax - Failed to build OS version string.");
  2577. }
  2578. OSAL_strncat_s(pVersion, MAX_SWV2_NAME_SIZE, pTermEquipment->productVersions.swVersion, OSAL_strnlen(pTermEquipment->productVersions.swVersion, MAX_VERSION_SIZE));
  2579. //OSAL_strncat_s(pVersion, MAX_SWV2_NAME_SIZE, L4DB_XML_TOKEN_DASH, strlen(L4DB_XML_TOKEN_DASH));
  2580. }
  2581. L4Configurations_getAPDOFixSpecialCharacters(fixSpecialCharacters);
  2582. // Default if no registry is to do special characters fix. only if key exist and false we won't do fix
  2583. if (OSAL_stricmp(DEFAULT_TRUE_LOWER, fixSpecialCharacters) == 0)
  2584. {
  2585. l4db_RemoveSpecialCharacters(pVersion);
  2586. }
  2587. TRACE(TR_MOD_NDNS_AGENT, TR_SEV_DEBUG, "l4db_InitWimax - swv2 = [%s].",pVersion);
  2588. }
  2589. /// <summary>
  2590. // This function recieves a string and removes special characters and spaces
  2591. /// </summary>
  2592. void l4db_RemoveSpecialCharacters(char* string)
  2593. {
  2594. UINT32 i;
  2595. UINT32 currCharIndex = 0;
  2596. char currChar;
  2597. size_t tempStrLen = 0;
  2598. tempStrLen = OSAL_strnlen(string, MAX_STRING_VALIDATE);
  2599. if((MAX_STRING_VALIDATE) != tempStrLen)
  2600. {
  2601. for (i=0; i<tempStrLen; i++)
  2602. {
  2603. currChar = string[i];
  2604. if (0 == OSAL_CAPI_strncmp(&currChar, ":", 1))
  2605. {
  2606. OSAL_memcpy_s(&string[currCharIndex], 1, L4DB_XML_TOKEN_DOT, 1);
  2607. currCharIndex++;
  2608. }
  2609. // Skip the following special characters
  2610. else if ((0 != OSAL_CAPI_strncmp(&currChar, "/", 1)) &&
  2611. (0 != OSAL_CAPI_strncmp(&currChar, "(", 1)) &&
  2612. (0 != OSAL_CAPI_strncmp(&currChar, "\\", 1)) &&
  2613. (0 != OSAL_CAPI_strncmp(&currChar, ")", 1)) &&
  2614. (0 != OSAL_CAPI_strncmp(&currChar, "+", 1)) &&
  2615. (0 != OSAL_CAPI_strncmp(&currChar, " ", 1)))
  2616. {
  2617. if (i > currCharIndex)
  2618. {
  2619. OSAL_memcpy_s(&string[currCharIndex], 1, &string[i], 1);
  2620. }
  2621. currCharIndex++;
  2622. }
  2623. }
  2624. }
  2625. string[currCharIndex] = '\0';
  2626. }