replace : iotivity -> iotivity-sec
[platform/upstream/iotivity.git] / resource / csdk / security / provisioning / include / pmtypes.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 #ifndef OC_PROVISIONING_TYPES_H
22 #define OC_PROVISIONING_TYPES_H
23
24 #include <stdbool.h>
25 #include "securevirtualresourcetypes.h"
26
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
30
31 /**
32  * Node to construct list of UUID pair list.
33  */
34 typedef struct OCPairList OCPairList_t;
35 struct OCPairList
36 {
37     OicUuid_t dev;
38     OicUuid_t dev2;
39     OCPairList_t *next;
40 };
41
42 /**
43  * Node to construct UUID linked list.
44  */
45 typedef struct OCUuidList  OCUuidList_t;
46 struct OCUuidList
47 {
48     OicUuid_t dev;
49     OCUuidList_t *next;
50 };
51
52 /*
53  * Device's power on/off state.
54  */
55 typedef enum {
56     DEV_STATUS_ON = (1 << 0),
57     DEV_STATUS_OFF = (1 << 1)
58 }DeviceStatus;
59
60 /**
61  * Device Information of discoverd unowned/owned device(s) for provisioning.
62  */
63 typedef struct OCProvisionDev
64 {
65     OCDevAddr       endpoint;        /**< target address **/
66     OicSecPstat_t   *pstat;          /**< Pointer to target's pstat resource. **/
67     OicSecDoxm_t    *doxm;           /**< Pointer to target's doxm resource. **/
68     OCConnectivityType connType;     /**< Connectivity type of endpoint */
69     uint16_t        securePort;      /**< secure port **/
70 #ifdef WITH_TCP
71     uint16_t        tcpPort;         /**< tcp port **/
72 #endif
73     char             secVer[OIC_SEC_MAX_VER_LEN];         /**< security version **/
74     DeviceStatus    devStatus;       /**< status of device **/
75     OCDoHandle    handle;
76     struct OCProvisionDev  *next;    /**< Next pointer. **/
77 }OCProvisionDev_t;
78
79 /**
80  * Device Information of discoverd direct pairing device(s).
81  */
82 typedef struct OCDirectPairingDev
83 {
84     OCDevAddr               endpoint;
85     OCConnectivityType   connType;
86     uint16_t                     securePort;
87     bool              edp;
88     OicSecPrm_t  *prm;
89     size_t            prmLen;
90     OicUuid_t       deviceID;
91     OicUuid_t       rowner;
92     struct OCDirectPairingDev *next;
93 } OCDirectPairingDev_t;
94
95 /**
96  * Result information for each target device.
97  */
98 typedef struct OCPMResult{
99     OicUuid_t      deviceId;
100     OCStackResult  res;
101 }OCProvisionResult_t;
102
103 /**
104  * Owner device type
105  */
106 typedef enum OwnerType{
107     SUPER_OWNER = 0,
108     SUB_OWNER = 1
109 }OwnerType_t;
110
111 /**
112  * Index value to access OxM allow table
113  */
114 typedef enum OxmAllowTableIdx {
115     OXM_IDX_JUST_WORKS = 0,
116     OXM_IDX_MV_JUST_WORKS,
117 #ifdef MULTIPLE_OWNER
118     OXM_IDX_PRECONFIG_PIN,
119 #endif
120     OXM_IDX_RANDOM_DEVICE_PIN,
121     OXM_IDX_MANUFACTURER_CERTIFICATE,
122     OXM_IDX_CON_MFG_CERT,
123     OXM_IDX_DECENTRALIZED_PUBLIC_KEY,
124     OXM_IDX_COUNT,
125     OXM_IDX_UNKNOWN
126 }OxmAllowTableIdx_t;
127
128 /**
129  * Callback function definition of provisioning API
130  *
131  * @param[OUT] ctx - If user set his/her context, it will be returned here.
132  * @param[OUT] nOfRes - total number of results, it depends on using which provisioning API.
133  * @param[OUT] arr - Array of OCPMResult_t, each OCPMResult_t contains result for target Device.
134  * @param[OUT} hasError - If there is no error, it's returned with 'false' but if there is a single
135  *                        or more error is/are occured during operation, it will be 'true'.
136  */
137 typedef void (*OCProvisionResultCB)(void* ctx, int nOfRes, OCProvisionResult_t *arr, bool hasError);
138
139
140 /**
141  * Callback function definition of direct-pairing
142  *
143  * @param[OUT] ctx - User context which will be returned wth callback
144  * @param[OUT] peer - pairing device info.
145  * @param[OUT} result - It's returned with 'OC_STACK_XXX'. It will return 'OC_STACK_OK'
146  *                                   if D2D pairing is success without error
147  */
148 typedef void (*OCDirectPairingResultCB)(void *ctx, OCDirectPairingDev_t *peer, OCStackResult result);
149
150
151 #ifdef __cplusplus
152 }
153 #endif
154
155 #endif //OC_PROVISIONING_TYPES_H