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 manager.
25 #ifndef ROUTING_MANAGER_H_
26 #define ROUTING_MANAGER_H_
29 #include "ocserverrequest.h"
30 #include "ocresource.h"
31 #include "routingutility.h"
39 * Initialize the Routing Manager.
40 * @return ::OC_STACK_OK or Appropriate error code.
42 // TODO: Future addition pertaining to security, RM should be given ACL callback from RI.
43 OCStackResult RMInitialize();
46 * Terminates the Routing Manager.
47 * @return ::OC_STACK_OK or Appropriate error code.
49 OCStackResult RMTerminate();
52 * This API will be called from RI layer whenever there is a request for the GATEWAY
54 * @param[in,out] request Request Received.
55 * @param[in] resource Resource handle used for sending the response.
56 * @return ::OC_STACK_OK or Appropriate error code.
58 OCStackResult RMHandleGatewayRequest(OCServerRequest *request, const OCResource *resource);
61 * API to handle the Response payload. The Gateway entries are parsed from
62 * the payload using routingmessageparser apis, addition or removal of
63 * Gateway entries is performed.
64 * @param[in] devAddr Address of the Device that sent the payload.
65 * @param[in] resource Response payload.
66 * @return ::OC_STACK_OK or Appropriate error code.
68 OCStackResult RMHandleResponsePayload(const OCDevAddr *devAddr, const OCRepPayload *payload);
71 * Process the routing manager timer to send notification to all the observers.
76 * API to form the payload with gateway ID.
77 * @param[out] payload Payload generated by routing message parser.
78 * @return ::OC_STACK_OK or Appropriate error code.
80 OCStackResult RMGetGatewayPayload(OCRepPayload **payload);
83 * API to get the gateway UUID of its own.
84 * @return Gateway UUID.
86 uint32_t RMGetGatewayId();
89 * API to get the multicast sequence number..
90 * @return Multicast sequence number.
92 uint16_t RMGetMcastSeqNumber();
95 * On reception of request from CA, RI sends to this function.
96 * This checks if the route option is present and adds routing information to
97 * to the route option data.
98 * @param[in,out] message Received coap packet.
99 * @param[in] sender RemoteEndpoint which sent the packet.
100 * @param[out] destination Populated by RM by parsing message, CA then forwards packet to
102 * @param[out] isEmptyMsg Populated by RM by parsing the RouteOption. If the MSGType is ACK
103 * in route option and is for self, then this flag is set.
104 * @return ::CA_STATUS_OK or Appropriate error code.
106 OCStackResult RMHandleRequest(CARequestInfo_t *message, const CAEndpoint_t *sender,
107 bool *selfDestination, bool *isEmptyMsg);
110 * On reception of response from CA, RI sends to this function.
111 * This checks if the route option is present and adds routing information to
112 * to the route option data.
113 * @param[in,out] message Received coap packet.
114 * @param[in] sender RemoteEndpoint which sent the packet.
115 * @param[out] destination Populated by RM by parsing message to know if response is
117 * @return ::CA_STATUS_OK or Appropriate error code.
119 OCStackResult RMHandleResponse(CAResponseInfo_t *message, const CAEndpoint_t *sender,
120 bool *selfDestination);
126 #endif /* ROUTING_MANAGER_H_ */