Apply Upstream code (2021-03-15)
[platform/upstream/connectedhomeip.git] / src / messaging / Flags.h
1 /*
2  *
3  *    Copyright (c) 2020-2021 Project CHIP Authors
4  *    All rights reserved.
5  *
6  *    Licensed under the Apache License, Version 2.0 (the "License");
7  *    you may not use this file except in compliance with the License.
8  *    You may obtain a copy of the License at
9  *
10  *        http://www.apache.org/licenses/LICENSE-2.0
11  *
12  *    Unless required by applicable law or agreed to in writing, software
13  *    distributed under the License is distributed on an "AS IS" BASIS,
14  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  *    See the License for the specific language governing permissions and
16  *    limitations under the License.
17  */
18
19 /**
20  *    @file
21  *      This file defines flags for messaging layer.
22  */
23
24 #pragma once
25
26 #include <stdint.h>
27 #include <support/BitFlags.h>
28
29 namespace chip {
30 namespace Messaging {
31
32 /**
33  *  @brief
34  *    Flags associated with a inbound or outbound CHIP message.
35  *
36  *    The values defined here are for use within the ChipMessageInfo.Flags field.
37  */
38 enum class MessageFlagValues : uint32_t
39 {
40     /**< Indicates that the existing source node identifier must be reused. */
41     kReuseSourceId = 0x00000020,
42     /**< Indicates that the CHIP message is already encoded. */
43     kMessageEncoded = 0x00001000,
44     /**< Indicates that default IPv6 source address selection should be used when sending IPv6 multicast messages. */
45     kDefaultMulticastSourceAddress = 0x00002000,
46     /**< Indicates that the sender of the  message requested an acknowledgment. */
47     kPeerRequestedAck = 0x00004000,
48     /**< Indicates that the message is a duplicate of a previously received message. */
49     kDuplicateMessage = 0x00008000,
50     /**< Indicates that the peer's group key message counter is not synchronized. */
51     kPeerGroupMsgIdNotSynchronized = 0x00010000,
52     /**< Indicates that the source of the message is the initiator of the CHIP exchange. */
53     kFromInitiator = 0x00020000,
54     /**< Indicates that message is being sent/received via the local ephemeral UDP port. */
55     kViaEphemeralUDPPort = 0x00040000,
56 };
57
58 using MessageFlags = BitFlags<MessageFlagValues>;
59
60 enum class SendMessageFlags : uint16_t
61 {
62     kNone = 0x0000,
63     /**< Used to indicate that automatic retransmission is enabled. */
64     kAutoRetrans = 0x0001,
65     /**< Used to indicate that a response is expected within a specified timeout. */
66     kExpectResponse = 0x0002,
67     /**< Used to indicate that the source node ID in the message header can be reused. */
68     kReuseSourceId = 0x0020,
69     /**< Used to indicate that the message is already encoded. */
70     kAlreadyEncoded = 0x0080,
71     /**< Used to indicate that default IPv6 source address selection should be used when sending IPv6 multicast messages. */
72     kDefaultMulticastSourceAddress = 0x0100,
73     /**< Used to indicate that the current message is the initiator of the exchange. */
74     kFromInitiator = 0x0200,
75     /**< Suppress the auto-request acknowledgment feature when sending a message. */
76     kNoAutoRequestAck = 0x0400,
77 };
78
79 using SendFlags = BitFlags<SendMessageFlags>;
80
81 } // namespace Messaging
82 } // namespace chip