1 /* 2 * Copyright (C) 2014 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #ifndef SYNCML_DM_DATA_TYPES_H 18 #define SYNCML_DM_DATA_TYPES_H 19 20 #ifdef __cplusplus 21 extern "C" { 22 #endif 23 24 /*================================================================================================== 25 26 Header Name: syncml_dm_data_types.h 27 28 General Description: This contains declaration of DM engine general enums and data structures. 29 30 ==================================================================================================*/ 31 32 #include "dmtError.h" 33 #include "dmMemory.h" 34 #include "dmtDefs.h" 35 36 /*================================================================================================== 37 CONSTANTS 38 ==================================================================================================*/ 39 40 #define DM_MD5_DIGEST_LENGTH 16 /* For package 0 data */ 41 42 #define SYNCML_DM_MAX_SERVER_ALLOWED 3 /* for Current implementation */ 43 44 #define SYNCML_DM_URI_MAX_DEPTH 20 //Max allowed levels 45 46 /* The DDF file for Motorola SyncML DM devices defines MaxTotLen = 127, and MaxSegLen = 32. 47 MaxTotLen is limited to 127 due to persistent storage implementation. It serializes the tree 48 structure into a flat file using WBXML format; opaque data values are stored with a multi-byte 49 integer encoded length. The implementation of the mb_uint_32 format is limited to encode/decode 50 up to the value 127. Anywhere memory is allocated for the Max URI length should use 51 SYNCML_DM_URI_MAX_TOTAL_LENGTH+1 to account for a null string terminator, since the code works 52 with the URI as a string. In the same manner, SYNCML_DM_URI_MAX_SEGMENT_LENGTH+1 should be used 53 to account for its string terminator. Note! The SyncML specs state that by default, characters 54 are encoded in UTF-8. The MaxTotLen and MaxSegLen values indicate the number of characters the 55 device allows, which may be LESS than the number of bytes it actually takes to UTF-8 encode the 56 string. In theory, the size in bytes of the memory to hold these strings should be much larger, 57 to allow the UTF-8 encoded data to fit (as much as 2 or 3 times the size, worst case). At the 58 moment, the byte-size and character-length for these limits are coded to be the same, which 59 always works if the characters are ASCII. */ 60 61 #define SYNCML_DM_URI_MAX_TOTAL_LENGTH 255 // will use too many stack spaces 62 #define SYNCML_DM_URI_MAX_SEGMENT_LENGTH 120 63 64 #define SYNCML_DM_MAX_TITLE_LENGTH 255 65 #define SYNCML_DM_MAX_TSTAMP_LENGTH 17 66 #define SYNCML_DM_STR_MAX_LEN 120 /* Max length of a string leaf node data value. */ 67 #define SYNCML_DM_MAX_OBJ_SIZE 262080 // This is the maximum FOTA obj size required by TRS. 68 69 #define DEFAULT_DM_SMLTK_WORKSPACE_SIZE (120*1024) 70 71 #define DM_MSG_OVERHEAD 600 /* SyncML DM document overhead (none data part). */ 72 extern INT32 g_iDMWorkspaceSize; 73 74 #define DM_FSTAB_FILENAME "fstab" 75 #define DM_ROOT_MDF_FILENAME "root.bmdf" 76 #define DM_PLUGINS_INI_FILENAME "sysplugins.ini" 77 #define DM_PLIGINS_INI_FILEEXTENSION "ini" 78 #define DM_MDF_FILEEXTENSION "bmdf" 79 #define DM_DEFAULT_ACL_FILENAME "acl.dat" 80 #define DM_DEFAULT_EVENT_FILENAME "event.dat" 81 #define DM_DATASUBFOLDER "" 82 83 #define DM_MAX_CONFIG_LINE 400 84 85 86 /*================================================================================================== 87 GLOBAL VARIABLES DECLARATION 88 ==================================================================================================*/ 89 /* These strings are used throughout the DM engine code. They are externed here to keep them 90 * in one ROM location. Please see the actual value definitions in "syncml_dm_main.cc". 91 */ 92 93 #define SYNCML_CONTENT_TYPE_DM_WBXML "application/vnd.syncml.dm+wbxml" 94 #define SYNCML_CONTENT_TYPE_DM_XML "application/vnd.syncml.dm+xml" 95 #define SYNCML_CONTENT_TYPE_DM_TNDS_WBXML "application/vnd.syncml.dmtnds+wbxml" 96 #define SYNCML_CONTENT_TYPE_DM_TNDS_XML "application/vnd.syncml.dmtnds+xml" 97 #define SYNCML_DM_PROTOCOL_VERSION_1_2 "DM/1.2" 98 #define SYNCML_DM_PROTOCOL_VERSION_1_1 "DM/1.1" 99 100 101 #define RECV_WORKSPACE_NAME "Received SyncML Document" 102 #define SEND_WORKSPACE_NAME "Send SyncML Document" 103 #define CACHE_WORKSPACE_NAME "SyncML Document Cache" 104 105 #define DM_DEV_INFO_URI_PAK1 "./DevInfo?list=Struct" 106 107 #define RECV_WORKSPACE_NAME "Received SyncML Document" 108 #define SEND_WORKSPACE_NAME "Send SyncML Document" 109 #define CACHE_WORKSPACE_NAME "SyncML Document Cache" 110 111 #define DM_ROOT_URI "." 112 #define DM_STR_SLASH "/" 113 #define DM_INBOX "./Inbox" 114 #define DM_DMACC_1_1_URI "./SyncML/DMAcc" 115 #define DM_DMACC_1_2_URI "./DMAcc" 116 #define DM_DMCON_URI "./SyncML/Con" 117 118 #define DM_APPID "AppID" 119 #define DM_SERVERID_1_2 "ServerID" 120 #define DM_SERVERID_1_1 "ServerId" 121 122 #define MNG_OBJID_DMACC1 "urn:oma:mo:oma-dm-dmacc:1.0" 123 #define MNG_OBJID_DMACC2 "org.openmobilealliance/1.0/w7" 124 125 #define DM_NAME "Name" 126 #define DM_PREFCONREF "PrefConRef" 127 #define DM_CONREF "ConRef" 128 #define DM_TOCONREF "ToConRef" 129 #define DM_APPADDR "AppAddr" 130 #define DM_ADDR "Addr" 131 #define DM_ADDRTYPE "AddrType" 132 #define DM_PORT "Port" 133 #define DM_PORTNBR "PortNbr" 134 #define DM_USERNAME "UserName" 135 #define DM_AUTHPREF "AuthPref" 136 #define DM_CLIENTNONCE "ClientNonce" 137 #define DM_SERVERNONCE "ServerNonce" 138 #define DM_CLIENTPW "ClientPW" 139 #define DM_SERVERPW "ServerPW" 140 141 // OMA DM 1.2 changes 142 #define DM_AAUTHPREF "AAuthPref" 143 #define DM_APPAUTH "AppAuth" 144 #define DM_AAUTHLEVEL "AAuthLevel" 145 #define DM_AAUTHTYPE "AAuthType" 146 #define DM_AAUTHNAME "AAuthName" 147 #define DM_AAUTHSECRET "AAuthSecret" 148 #define DM_AAUTHDATA "AAuthData" 149 #define DM_EXT "Ext" 150 #define DM_LASTCLIENTAUTHTYPE "LastClientAuthType" 151 152 // Application service 153 #define DM_APPID_VALUE "w7" 154 155 #define DM_AUTHLEVEL_CLCRED "CLCRED" 156 #define DM_AUTHLEVEL_SRVCRED "SRVCRED" 157 #define DM_AUTHLEVEL_OBEX "OBEX" 158 #define DM_AUTHLEVEL_HTTP "HTTP" 159 160 #define DM_AUTHTYPE_HTTPBASIC "HTTP-BASIC" 161 #define DM_AUTHTYPE_HTTPDIGEST "HTTP-DIGEST" 162 #define DM_AUTHTYPE_BASIC "BASIC" 163 #define DM_AUTHTYPE_DIGEST "DIGEST" 164 #define DM_AUTHTYPE_HMAC "HMAC" 165 #define DM_AUTHTYPE_TRANPORT "TRANSPORT" 166 // end of OMA DM 1.2 changes 167 168 #define DM_DEV_INFO_URI_PAK1 "./DevInfo?list=Struct" 169 #define DM_DEV_INFO_DEVID_URI "./DevInfo/DevId" 170 #define DM_DEV_INFO_MOD_URI "./DevInfo/Mod" 171 #define DM_DEV_INFO_MAN_URI "./DevInfo/Man" 172 173 #define SYNCML_AUTH_MAC "syncml:auth-MAC" 174 #define SYNCML_AUTH_MD5 "syncml:auth-md5" 175 #define SYNCML_AUTH_BASIC "syncml:auth-basic" 176 #define SYNCML_B64 "b64" 177 #define SYNCML_MAC_ALG "MD5" 178 179 #define SYNCML_SYNCHDR "SyncHdr" 180 #define SYNCML_REPLACE "Replace" 181 #define SYNCML_ALERT "Alert" 182 183 /*================================================================================================== 184 ENUMS 185 ==================================================================================================*/ 186 /* Need to find the right global .h file for these defines */ 187 188 typedef UINT32 MAX_MSG_SIZE_T; 189 190 /* These enum values are used to indicate the node scope for DMTNM_NODE_SCOPE */ 191 enum 192 { 193 DMTNM_NODE_PERMANENT = 1, 194 DMTNM_NODE_DYNAMIC = 2 195 }; 196 typedef UINT8 DMTNM_NODE_SCOPE; 197 198 enum 199 { 200 DMTNM_NODE_INTERIOR = 1, 201 DMTNM_NODE_LEAF = 2 202 }; 203 typedef UINT8 DMTNM_NODE_TYPE; 204 205 /* These enum values are used to indicate command type for SYNCML_DM_COMMAND_T. 206 * DON'T CHANGE THE ORDER OF THIS ENUM, TEHY ARE USED BY FEATURE DATABASES. */ 207 enum 208 { 209 SYNCML_DM_NO_COMMAND, 210 SYNCML_DM_ADD, 211 SYNCML_DM_DELETE, 212 SYNCML_DM_REPLACE, 213 SYNCML_DM_GET, 214 SYNCML_DM_RENAME, 215 SYNCML_DM_EXEC, 216 SYNCML_DM_COPY, 217 SYNCML_DM_ALERT, 218 SYNCML_DM_HEADER, 219 SYNCML_DM_STATUS, 220 SYNCML_DM_ATOMIC, 221 SYNCML_DM_SEQUENCE, 222 SYNCML_DM_MAX_CMD, 223 SYNCML_DM_ADD_CHILD, 224 SYNCML_DM_RELEASE, 225 SYNCML_DM_ROLLBACK, 226 SYNCML_DM_COMMIT 227 }; 228 typedef UINT8 SYNCML_DM_COMMAND_T; 229 230 /* These enum values are used to indicate the format of the data for SYNCML_DM_FORMAT_T */ 231 enum 232 { 233 SYNCML_DM_FORMAT_BIN = SYNCML_DM_DATAFORMAT_BIN, 234 SYNCML_DM_FORMAT_BOOL = SYNCML_DM_DATAFORMAT_BOOL, 235 SYNCML_DM_FORMAT_B64 = SYNCML_DM_DATAFORMAT_B64, 236 SYNCML_DM_FORMAT_CHR = SYNCML_DM_DATAFORMAT_STRING, 237 SYNCML_DM_FORMAT_INT = SYNCML_DM_DATAFORMAT_INT, 238 SYNCML_DM_FORMAT_NODE = SYNCML_DM_DATAFORMAT_NODE, 239 SYNCML_DM_FORMAT_NULL = SYNCML_DM_DATAFORMAT_NULL, 240 SYNCML_DM_FORMAT_XML = SYNCML_DM_DATAFORMAT_XML, 241 SYNCML_DM_FORMAT_FLOAT = SYNCML_DM_DATAFORMAT_FLOAT, 242 SYNCML_DM_FORMAT_DATE = SYNCML_DM_DATAFORMAT_DATE, 243 SYNCML_DM_FORMAT_TIME = SYNCML_DM_DATAFORMAT_TIME, 244 SYNCML_DM_FORMAT_TEST = 9, 245 SYNCML_DM_FORMAT_INVALID = 21, 246 SYNCML_DM_FORMAT_NODE_PDATA = 22 /* special type for serialization only */ 247 }; 248 typedef UINT8 SYNCML_DM_FORMAT_T; 249 250 251 /* These values came from the DM spec, are used for SYNCML_DM_ALERT_CODE. */ 252 enum 253 { 254 DM_ALERT_DISPLAY = 1100, 255 DM_ALERT_CONTINUE_OR_ABORT = 1101, 256 DM_ALERT_TEXT_INPUT = 1102, 257 DM_ALERT_SINGLE_CHOICE = 1103, 258 DM_ALERT_MULTIPLE_CHOICE = 1104, 259 DM_ALERT_SERVER_INITIATED_MGMT = 1200, 260 DM_ALERT_CLIENT_INITIATED_MGMT = 1201, 261 DM_ALERT_NEXT_MESSAGE = 1222, 262 DM_ALERT_SESSION_ABORT = 1223, 263 DM_ALERT_END_OF_DATA_NOT_RECEIVED = 1225, 264 DM_ALERT_FIRMWARE_UPDATE = 1226 265 }; 266 typedef UINT16 SYNCML_DM_ALERT_CODE; 267 268 269 /* These enum values are used to indicate the state of Security for the DM User Agent 270 * SYNCML_DM_SEC_STATE_FLAG_T */ 271 /* NOTE: DO NOT change numeric values, since bitwise operations used */ 272 enum { 273 DM_CLIENT_NO_SERVER_NO_AUTH = 0, /* Neither client nor server are authenticated.*/ 274 DM_CLIENT_NO_SERVER_Y_AUTH = 1, /* Server Authenticated, Client not authenticated.*/ 275 DM_CLIENT_Y_SERVER_NO_AUTH = 2, /* Client Authenticated, Server not authenticated.*/ 276 DM_BOTH_CLIENT_SERVER_AUTH = 3 /* Both Client and Server Authenticated.*/ 277 }; 278 typedef UINT8 SYNCML_DM_SEC_STATE_FLAG_T; 279 280 281 /* These enum values are used to indicate the URI checking result for SYNCML_DM_URI_RESULT_T */ 282 enum 283 { 284 SYNCML_DM_COMMAND_ON_NODE, /* means URI doesnt have any special case */ 285 SYNCML_DM_COMMAND_ON_ACL_PROPERTY, /* ?prop=ACL or ?prop=Name , Format etc */ 286 SYNCML_DM_COMMAND_ON_FORMAT_PROPERTY, 287 SYNCML_DM_COMMAND_ON_NAME_PROPERTY, 288 SYNCML_DM_COMMAND_ON_SIZE_PROPERTY, 289 SYNCML_DM_COMMAND_ON_ESN_PROPERTY, 290 SYNCML_DM_COMMAND_ON_TYPE_PROPERTY, 291 SYNCML_DM_COMMAND_ON_TITLE_PROPERTY, 292 SYNCML_DM_COMMAND_ON_TSTAMP_PROPERTY, 293 SYNCML_DM_COMMAND_ON_VERNO_PROPERTY, 294 SYNCML_DM_COMMAND_ON_UNKNOWN_PROPERTY, 295 SYNCML_DM_COMMAND_LIST_STRUCT, /* ?list=Struct found in URI */ 296 SYNCML_DM_COMMAND_LIST_STRUCTDATA, /* ?list=StructData found in URI */ 297 SYNCML_DM_COMMAND_LIST_TNDS, /* ?list=TNDS found in URI */ 298 SYNCML_DM_COMMAND_URI_TOO_LONG, /* URI is too long */ 299 SYNCML_DM_COMMAND_INVALID_URI /* URI was invalid */ 300 }; 301 typedef UINT8 SYNCML_DM_URI_RESULT_T; 302 303 304 enum 305 { 306 SYNCML_DM_ALERT_NONE, 307 SYNCML_DM_ALERT_CANCEL, 308 SYNCML_DM_ALERT_NO 309 }; 310 typedef UINT8 SYNCML_DM_ALERT_RES_T; 311 312 313 /*================================================================================================== 314 Structures 315 ==================================================================================================*/ 316 317 /* This buffer is used to hold syncml document data */ 318 typedef struct 319 { 320 UINT32 dataSize; 321 UINT8 *pData; 322 } SYNCML_DM_INDIRECT_BUFFER_T; 323 324 325 typedef struct 326 { 327 BOOLEAN _AuthFlag; 328 CPCHAR _pServerId; 329 UINT8 *_md5Digest; 330 UINT8 *_pTrigger; 331 UINT8 _triggerLen; 332 } SYNCML_DM_AuthContext_T; 333 334 /*================================================================================================*/ 335 #ifdef __cplusplus 336 } 337 #endif 338 339 #endif /* SYNCML_DM_DATA_TYPES_H */ 340