1 /* ****************************************************************
3 * Copyright 2015 Samsung Electronics All Rights Reserved.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
19 ******************************************************************/
23 * This file contains the APIs for routing message parser.
25 #ifndef ROUTING_MESSAGE_PARSER_H_
26 #define ROUTING_MESSAGE_PARSER_H_
28 #include "ulinklist.h"
29 #include "uarraylist.h"
38 * Constructs payload with its Gateway ID. This payload is
39 * shared between the gateways during initial discovery.
40 * @param[in] gatewayId Gateway ID.
41 * @param[out] payload Encoded Payload for Gateway ID.
42 * @return ::OC_STACK_OK or Appropriate error code.
44 OCStackResult RMPConstructGatewayPayload(uint32_t gatewayId, OCRepPayload **payload);
47 * Constructs payload with the Gateway ID and routing table
48 * This payload is shared for any observe response or notification.
49 * @param[in] gatewayId Gateway ID.
50 * @param[in] seqNum Sequence Number of Gateway.
51 * @param[in] routingtable linklist with Routing Table Entries.
52 * @param[in] isUpdateSeqNeeded Response type of payload response/notification.
53 * @param[out] payload Payload with gateway Data.
54 * @return ::OC_STACK_OK or Appropriate error code.
56 OCStackResult RMPConstructObserveResPayload(uint32_t gatewayId, uint32_t seqNum,
57 const u_linklist_t *routingtable, bool isUpdateSeqNeeded,
58 OCRepPayload **payload);
61 * Constructs payload with the own GatewayID and the nodes that are removed from the routing table.
62 * @param[in] gatewayId Gateway ID.
63 * @param[in] seqNum Sequence Number of Gateway.
64 * @param[in] removedGateways linklist with Removed gateway entries.
65 * @param[in] isUpdateSeqNeeded Response type of payload response/notification.
66 * @param[out] removedPayload Encoded Payloads of removed routing table entries.
67 * @return ::OC_STACK_OK or Appropriate error code.
69 OCStackResult RMPConstructRemovalPayload(uint32_t gatewayId, uint32_t seqNum,
70 const u_linklist_t *removedGateways, bool isUpdateSeqNeeded,
71 OCRepPayload **removedPayload);
74 * Parse payload for request and get gateway id.
75 * @param[in] payload Payload.
76 * @param[in] payloadSize Payload Size.
77 * @param[out] gatewayId Gateway Id.
78 * @return ::OC_STACK_OK or Appropriate error code.
80 OCStackResult RMPParseRequestPayload(const uint8_t* payload, size_t payloadSize,
84 * Parse payload for response and get required info.
85 * @param[in] payload Payload with gateways route table encoded.
86 * @param[in/out] seqNum Sequence Number of Gateway.
87 * @param[in/out] gatewayId Gateway Id.
88 * @param[in/out] gatewayTable Parsed routing table from Payload.
89 * @param[out] isUpdateSeqNeeded Response type of payload response/notification.
90 * @return ::OC_STACK_OK or Appropriate error code.
92 OCStackResult RMPParseResponsePayload(const OCRepPayload *payload, uint32_t *gatewayId,
93 uint32_t *seqNum, u_linklist_t **gatewayTable,
94 bool *isUpdateSeqNeeded);
98 * @param[in/out] payload Encoded Payload for Gateway ID.
100 void RMPFreePayload(OCRepPayload *payload);
106 #endif /* ROUTING_MESSAGE_PARSER_H_ */