Imported Upstream version 1.1.0
[platform/upstream/iotivity.git] / resource / csdk / routing / include / routingmanager.h
1 /* ****************************************************************
2  *
3  * Copyright 2015 Samsung Electronics All Rights Reserved.
4  *
5  *
6  *
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
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
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.
18  *
19  ******************************************************************/
20
21 /**
22  * @file
23  * This file contains the APIs for routing manager.
24  */
25 #ifndef ROUTING_MANAGER_H_
26 #define ROUTING_MANAGER_H_
27
28 #include "octypes.h"
29 #include "ocserverrequest.h"
30 #include "ocresource.h"
31 #include "routingutility.h"
32
33 #ifdef __cplusplus
34 extern "C"
35 {
36 #endif
37
38 /**
39  * Initialize the Routing Manager.
40  * @return  ::OC_STACK_OK or Appropriate error code.
41  */
42 // TODO: Future addition pertaining to security, RM should be given ACL callback from RI.
43 OCStackResult RMInitialize();
44
45 /**
46  * Terminates the Routing Manager.
47  * @return  ::OC_STACK_OK or Appropriate error code.
48  */
49 OCStackResult RMTerminate();
50
51 /**
52  * This API will be called from RI layer whenever there is a request for the GATEWAY
53  * Virtual Resource.
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.
57  */
58 OCStackResult RMHandleGatewayRequest(OCServerRequest *request, const OCResource *resource);
59
60 /**
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.
67  */
68 OCStackResult RMHandleResponsePayload(const OCDevAddr *devAddr, const OCRepPayload *payload);
69
70 /**
71  * Process the routing manager timer to send notification to all the observers.
72  */
73 void RMProcess();
74
75 /**
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.
79  */
80 OCStackResult RMGetGatewayPayload(OCRepPayload **payload);
81
82 /**
83  * API to get the gateway UUID of its own.
84  * @return  Gateway UUID.
85  */
86 uint32_t RMGetGatewayId();
87
88 /**
89  * API to get the multicast sequence number..
90  * @return  Multicast sequence number.
91  */
92 uint16_t RMGetMcastSeqNumber();
93
94 /**
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
101  *                               "destination".
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.
105  */
106 OCStackResult RMHandleRequest(CARequestInfo_t *message, const CAEndpoint_t *sender,
107                               bool *selfDestination, bool *isEmptyMsg);
108
109 /**
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
116  *                               for its own.
117  * @return  ::CA_STATUS_OK or Appropriate error code.
118  */
119 OCStackResult RMHandleResponse(CAResponseInfo_t *message, const CAEndpoint_t *sender,
120                                bool *selfDestination);
121
122 #ifdef __cplusplus
123 } /* extern "C" */
124 #endif
125
126 #endif /* ROUTING_MANAGER_H_ */