summaryrefslogtreecommitdiffhomepage
path: root/digital/zigbit/bitcloud/stack/Components/NWK/include/private/nwkRouteRequest.h
blob: 45bf6d03054651c062d2234ea9e85c8a63f54f05 (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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
/**************************************************************************//**
  \file nwkRouteRequest.h

  \brief Interface of route request commands.

  \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:
    2007-09-17 V. Panov - Created.
    2008-12-10 M. Gekk  - Optimization of NWK memory.
    2009-11-20 M. Gekk  - Refactoring.
   Last change:
    $Id: nwkRouteRequest.h 18498 2011-09-12 08:49:29Z mgekk $
 ******************************************************************************/
#if !defined _NWK_ROUTE_REQUEST_H
#define _NWK_ROUTE_REQUEST_H

/******************************************************************************
                              Includes section
 ******************************************************************************/
#include <nwkConfig.h>
#include <nwkSystem.h>
#include <appFramework.h>
#include <nldeData.h>
#include <nwkFrame.h>
#include <nwkRouteDiscoveryTable.h>

/******************************************************************************
                              Define(s) section
 ******************************************************************************/
/** Transmission parameters of route request command. */
#define NWK_INITIAL_ROUTE_REQ_TX_PARAMETERS \
  {NWK_TX_DELAY_INITIAL_ROUTE_REQUEST, NULL, nwkConfirmRouteRequestTx, true}
#define NWK_ROUTE_REQ_TX_PARAMETERS \
  {NWK_TX_DELAY_ROUTE_REQUEST, NULL, NULL, true}
#define NWK_INITIAL_MANYTOONE_ROUTE_REQ_TX_PARAMETERS \
  {NWK_TX_DELAY_INITIAL_MANYTOONE_ROUTE_REQUEST, NULL, nwkConfirmRouteRequestTx, true}
#define NWK_MANYTOONE_ROUTE_REQ_TX_PARAMETERS \
  {NWK_TX_DELAY_MANYTOONE_ROUTE_REQUEST, NULL, NULL, true}

/******************************************************************************
                                Types section
 ******************************************************************************/
/** Many-to-One field values. See ZigBee spec r18, 3.4.1.3.1.1, page 320. */
typedef enum _NwkRReqManyToOneFlag_t
{
  /** The route request is not a many-to-one route request. */
  NWK_RREQ_IS_NOT_MANY_TO_ONE = 0,
  /** The route request is a many-to-one route request and the sender supports
   * a route record table.*/
  NWK_RREQ_IS_MANY_TO_ONE = 1,
  /** The route request is a many-to-one route request and the sender does not
   * support a route record table. */
  NWK_RREQ_IS_MANY_TO_ONE_NO_RREC_TABLE = 2,
  NWK_RREQ_RESERVED_MANY_TO_ONE_FLAG = 3
} NwkRReqManyToOneFlag_t;

BEGIN_PACK
/** Route request command options field. ZigBee spec r18, 3.4.1.3.1, page 320. 
 **/
typedef struct PACK _NwkRouteRequestOptions_t
{
  LITTLE_ENDIAN_OCTET(5, (
    NwkBitField_t reserved1 : 3,
    /** The many-to-one field shall have one of the non-reserved values shown
     * in ZigBee spec r18, Table 3.41 and type NwkRReqManyToOneFlag_t. */
    NwkBitField_t manyToOne : 2,
    /** The destination IEEE address field is a single-bit field. It shall have
     * a value of 1 if, and only if, the command frame contains the destination
     * IEEE address. ZigBee spec r18, 3.4.1.3.1.2, page 321. */
    NwkBitField_t dstExt    : 1,
    /** The multicast sub-field is a single-bit field. It shall have a value
     * of 1 if, and only if, the command frame is a request for a route
     * to a multicast group... ZigBee spec r18, 3.4.1.3.1.3, page 321. */
    NwkBitField_t multicast : 1,
    NwkBitField_t reserved2 : 1
  ))
} NwkRouteRequestOptions_t;
END_PACK

BEGIN_PACK
/** Route request command frame format. See ZigBee spec r18,
 * Figure 3.11, page 319. */
typedef struct PACK _NwkRouteRequestPayload_t
{
  /** The identifier of the route request command. */
  uint8_t commandId;
  /** Route request command options field. See NwkRouteRequestOptions_t. */
  NwkRouteRequestOptions_t options;
  /** The route request identifier is an 8-bit sequence number for route
   * requests and is incremented by 1 every time the NWK layer on a particular
   * device issues a route request. ZigBee spec r18, 3.4.1.3.2, page 321. */
  NwkRouteRequestId_t identifier;
  /** The destination address shall be 2 octets in length and represents
   * the intended destination of the route request command frame.
   * ZigBee spec r18, 3.4.1.3.3. */
  ShortAddr_t dstAddr;
  /** The path cost field is eight bits in length and is used to accumulate
   * routing cost information as a route request command frame moves through
   * the network. ZigBee spec r18, 3.4.1.3.4, page 321; sub-clause 3.6.3.5.2. */
  NwkPathCost_t pathCost;
  /** The destination IEEE address shall be 8 octets in length and represents
   * the IEEE address of the destination of the route request command frame.
   ** ZigBee spec r18, 3.4.1.3.5, page 321. */
  ExtAddr_t dstExtAddr;
} NwkRouteRequestPayload_t;
END_PACK

/******************************************************************************
                               Prototypes section
 ******************************************************************************/
#if defined NWK_ROUTING_CAPACITY \
  && (defined _NWK_MESH_ROUTING_ || defined _NWK_MANY_TO_ONE_ROUTING_)
/**************************************************************************//**
  \brief Action when route request command received.

  \param[in] payload - pointer to payload of route request command.
  \param[in] header - pointer to raw network header of route request command.
  \param[in] parse - parsed header fields.

  \return 'true' if continue processing of command packet otherwise 'false'.
 ******************************************************************************/
NWK_PRIVATE bool nwkRouteRequestFrameInd(const uint8_t *const payload,
  const NwkFrameHeader_t *const header, const NwkParseHeader_t *const parse);

/**************************************************************************//**
  \brief Prepare header and payload of the route request command.

  \param[in] outPkt - pointer to output packet.
  \param[in] entry - pointer to a route discovery entry.
  \return None.
 ******************************************************************************/
NWK_PRIVATE void nwkPrepareRouteRequestTx(NwkOutputPacket_t *const outPkt,
  NwkRouteDiscoveryEntry_t *const entry);

#else /* NWK_ROUTING_CAPACITY and (_NWK_MESH_ROUTING_ or _NWK_MANY_TO_ONE_ROUTING_) */

#define nwkRouteRequestFrameInd NULL

#endif /* NWK_ROUTING_CAPACITY and (_NWK_MESH_ROUTING_ or _NWK_MANY_TO_ONE_ROUTING_) */
#endif /* _NWK_ROUTE_REQUEST_H */
/** eof nwkRouteRequest.h */