saddr.h 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. /**************************************************************************************************
  2. Filename: saddr.h
  3. Revised: $Date: 2009-12-10 08:32:15 -0800 (Thu, 10 Dec 2009) $
  4. Revision: $Revision: 21311 $
  5. Description: Zigbee and 802.15.4 device address utility functions.
  6. Copyright 2005-2010 Texas Instruments Incorporated. All rights reserved.
  7. IMPORTANT: Your use of this Software is limited to those specific rights
  8. granted under the terms of a software license agreement between the user
  9. who downloaded the software, his/her employer (which must be your employer)
  10. and Texas Instruments Incorporated (the "License"). You may not use this
  11. Software unless you agree to abide by the terms of the License. The License
  12. limits your use, and you acknowledge, that the Software may not be modified,
  13. copied or distributed unless embedded on a Texas Instruments microcontroller
  14. or used solely and exclusively in conjunction with a Texas Instruments radio
  15. frequency transceiver, which is integrated into your product. Other than for
  16. the foregoing purpose, you may not use, reproduce, copy, prepare derivative
  17. works of, modify, distribute, perform, display or sell this Software and/or
  18. its documentation for any purpose.
  19. YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
  20. PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
  21. INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
  22. NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
  23. TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
  24. NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
  25. LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
  26. INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
  27. OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
  28. OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
  29. (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
  30. Should you have any questions regarding your right to use this Software,
  31. contact Texas Instruments Incorporated at www.TI.com.
  32. **************************************************************************************************/
  33. #ifndef SADDR_H
  34. #define SADDR_H
  35. #ifdef __cplusplus
  36. extern "C" {
  37. #endif
  38. /****************************************************************************
  39. * MACROS
  40. */
  41. /* Extended address length */
  42. #define SADDR_EXT_LEN 8
  43. /* Address modes */
  44. #define SADDR_MODE_NONE 0 /* Address not present */
  45. #define SADDR_MODE_SHORT 2 /* Short address */
  46. #define SADDR_MODE_EXT 3 /* Extended address */
  47. /****************************************************************************
  48. * TYPEDEFS
  49. */
  50. /* Extended address */
  51. typedef uint8 sAddrExt_t[SADDR_EXT_LEN];
  52. /* Combined short/extended device address */
  53. typedef struct
  54. {
  55. union
  56. {
  57. uint16 shortAddr; /* Short address */
  58. sAddrExt_t extAddr; /* Extended address */
  59. } addr;
  60. uint8 addrMode; /* Address mode */
  61. } sAddr_t;
  62. /****************************************************************************
  63. * @fn sAddrCmp
  64. *
  65. * @brief Compare two device addresses.
  66. *
  67. * input parameters
  68. *
  69. * @param pAddr1 - Pointer to first address.
  70. * @param pAddr2 - Pointer to second address.
  71. *
  72. * output parameters
  73. *
  74. * @return TRUE if addresses are equal, FALSE otherwise
  75. */
  76. extern bool sAddrCmp(const sAddr_t *pAddr1, const sAddr_t *pAddr2);
  77. /****************************************************************************
  78. * @fn sAddrIden
  79. *
  80. * @brief Check if two device addresses are identical.
  81. *
  82. * This routine is virtually the same as sAddrCmp, which is used
  83. * to determine if two different addresses are the same. However,
  84. * this routine can be used to determine if an address is the
  85. * same as a previously stored address. The key difference is in
  86. * the former case, if the address mode is "none", then the
  87. * assumption is that the two addresses can not be the same. But
  88. * in the latter case, the address mode itself is being compared.
  89. * So two addresses can be identical even if the address mode is
  90. * "none", as long as the address mode of both addresses being
  91. * compared is the "none".
  92. *
  93. * input parameters
  94. *
  95. * @param pAddr1 - Pointer to first address.
  96. * @param pAddr2 - Pointer to second address.
  97. *
  98. * output parameters
  99. *
  100. * @return TRUE if addresses are identical, FALSE otherwise
  101. */
  102. extern bool sAddrIden(const sAddr_t *pAddr1, const sAddr_t *pAddr2);
  103. /****************************************************************************
  104. * @fn sAddrCpy
  105. *
  106. * @brief Copy a device address.
  107. *
  108. * input parameters
  109. *
  110. * @param pSrc - Pointer to address to copy.
  111. *
  112. * output parameters
  113. *
  114. * @param pDest - Pointer to address of copy.
  115. *
  116. * @return None.
  117. */
  118. extern void sAddrCpy(sAddr_t *pDest, const sAddr_t *pSrc);
  119. /****************************************************************************
  120. * @fn sAddrExtCmp
  121. *
  122. * @brief Compare two extended addresses.
  123. *
  124. * input parameters
  125. *
  126. * @param pAddr1 - Pointer to first address.
  127. * @param pAddr2 - Pointer to second address.
  128. *
  129. * output parameters
  130. *
  131. * @return TRUE if addresses are equal, FALSE otherwise
  132. */
  133. extern bool sAddrExtCmp(const uint8 * pAddr1, const uint8 * pAddr2);
  134. /****************************************************************************
  135. * @fn sAddrExtCpy
  136. *
  137. * @brief Copy an extended address.
  138. *
  139. * input parameters
  140. *
  141. * @param pSrc - Pointer to address to copy.
  142. *
  143. * output parameters
  144. *
  145. * @param pDest - Pointer to address of copy.
  146. *
  147. * @return pDest + SADDR_EXT_LEN.
  148. */
  149. void *sAddrExtCpy(uint8 * pDest, const uint8 * pSrc);
  150. #ifdef __cplusplus
  151. }
  152. #endif
  153. #endif /* SADDR_H */