summaryrefslogtreecommitdiffhomepage
path: root/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkAddressMap.h
blob: c6418f35b4354e564012defdc507efdb6fc5db1c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
/**************************************************************************//**
  \file nwkAddressMap.h

  \brief The access interface to the address map..

  \author
    Atmel Corporation: http://www.atmel.com \n
    Support email: avr@atmel.com

  Copyright (c) 2008-2011, Atmel Corporation. All rights reserved.
  Licensed under Atmel's Limited License Agreement (BitCloudTM).

  \internal
   History:
    2010-07-04  Max Gekk - Created.
   Last change:
    $Id: nwkAddressMap.h 17448 2011-06-09 13:53:59Z ataradov $
 ******************************************************************************/
#if !defined _NWK_ADDRESS_MAP_H
#define _NWK_ADDRESS_MAP_H

/******************************************************************************
                                Includes section
 ******************************************************************************/
#include <appFramework.h>
#include <nwkSystem.h>
#include <nwkCommon.h>

/******************************************************************************
                                 Types section
 ******************************************************************************/
/** Type of size of the address map. */
typedef uint8_t NwkSizeOfAddressMap_t;

/** Type of index of the address map. */
typedef NwkSizeOfAddressMap_t NwkAddressMapIndex_t;

/** Type of entry of the address map. */
typedef struct _NwkAddressMapEntry_t
{
  /** The entry is busy (true) or not (false). */
  bool busy               : 1;
  /** Conflict of short addresses is detected (true) or not (false). */
  bool conflict           : 1;
  NwkBitField_t reserved  : 6;
  /** A network address (16-bit). */
  ShortAddr_t shortAddr;
  /** IEEE address (64-bit). */
  ExtAddr_t extAddr;
} NwkAddressMapEntry_t;

/** Type of the address map. */
typedef struct _NwkAddressMap_t
{
  /** Array of address map entries. */
  NwkAddressMapEntry_t *table;
  /** Pointer to memory area after last entry of the address map. */
  NwkAddressMapEntry_t *end;
  /** Current position for a new entry. */
  NwkAddressMapEntry_t *current;
} NwkAddressMap_t;

/******************************************************************************
                               Prototypes section
 ******************************************************************************/
/**************************************************************************//**
  \brief Add a short and extended addresses in the address map.

  \param[in] shortAddr - a short address.
  \param[in] extAddr - an extended address.
  \param[in] isConflict - 'true' if shortAddr conflict with other short address
                          in the network otherwise 'false'.
  \return None.
 ******************************************************************************/
NWK_PRIVATE void nwkAddToAddressMap(const ShortAddr_t shortAddr,
  const ExtAddr_t extAddr, const bool isConflict);

/**************************************************************************//**
  \brief Find entry in the address map by IEEE address.

  \param[in] extAddr - pointer to IEEE extended 64-bit address.
  \return Pointer to an entry in the address map.
 ******************************************************************************/
NWK_PRIVATE NwkAddressMapEntry_t*
  nwkFindAddressMapEntryByExtAddr(const ExtAddr_t *const extAddr);

/**************************************************************************//**
  \brief Find entry in the address map by short address.

  \param[in] shortAddr - a network short address.
  \return Pointer to an entry in the address map.
 ******************************************************************************/
NWK_PRIVATE NwkAddressMapEntry_t*
  nwkFindAddressMapEntryByShortAddr(const ShortAddr_t shortAddr);

#if defined _RESOLVE_ADDR_CONFLICT_
/**************************************************************************//**
  \brief Find entry in the address map with conflicted short address.

  \return Pointer to an entry in the address map.
 ******************************************************************************/
NWK_PRIVATE NwkAddressMapEntry_t* nwkFindAddrMapConflictEntry(void);
#endif /* _RESOLVE_ADDR_CONFLICT_ */

/**************************************************************************//**
  \brief Get maximum size of NWK address map.
 ******************************************************************************/
NWK_PRIVATE NwkSizeOfAddressMap_t nwkAddrMapSize(void);

/**************************************************************************//**
  \brief Reset the address map.
 ******************************************************************************/
NWK_PRIVATE void nwkResetAddressMap(void);

#endif /* _NWK_ADDRESS_MAP_H */
/** eof nwkAddressMap.h */