PageRenderTime 67ms CodeModel.GetById 29ms RepoModel.GetById 0ms app.codeStats 1ms

/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

Large files files are truncated, but you can click here to view the full file

  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_ER

Large files files are truncated, but you can click here to view the full file