media/webrtc/signaling/src/sipcc/include/plat_api.h

Thu, 15 Jan 2015 15:59:08 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 15:59:08 +0100
branch
TOR_BUG_9701
changeset 10
ac0c01689b40
permissions
-rw-r--r--

Implement a real Private Browsing Mode condition by changing the API/ABI;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

michael@0 1 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 2 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 4
michael@0 5 #ifndef _PLAT_API_H_
michael@0 6 #define _PLAT_API_H_
michael@0 7
michael@0 8 #include "cc_constants.h"
michael@0 9 #include "cpr_socket.h"
michael@0 10 #include "cc_types.h"
michael@0 11
michael@0 12 /**
michael@0 13 * Define unregister reason
michael@0 14 */
michael@0 15 #define CC_UNREG_REASON_UNSPECIFIED 0
michael@0 16 //Common with what SCCP uses...need to match with J-Side
michael@0 17 #define CC_UNREG_REASON_TCP_TIMEOUT 10
michael@0 18 #define CC_UNREG_REASON_CM_RESET_TCP 12
michael@0 19 #define CC_UNREG_REASON_CM_ABORTED_TCP 13
michael@0 20 #define CC_UNREG_REASON_CM_CLOSED_TCP 14
michael@0 21 #define CC_UNREG_REASON_REG_TIMEOUT 17
michael@0 22 #define CC_UNREG_REASON_FALLBACK 18
michael@0 23 #define CC_UNREG_REASON_PHONE_KEYPAD 20
michael@0 24 #define CC_UNREG_REASON_RESET_RESET 22
michael@0 25 #define CC_UNREG_REASON_RESET_RESTART 23
michael@0 26 #define CC_UNREG_REASON_PHONE_REG_REJ 24
michael@0 27 #define CC_UNREG_REASON_PHONE_INITIALIZED 25
michael@0 28 #define CC_UNREG_REASON_VOICE_VLAN_CHANGED 26
michael@0 29 #define CC_UNREG_REASON_POWER_SAVE_PLUS 32
michael@0 30 //sip specific ones...need to match with J-Side
michael@0 31 #define CC_UNREG_REASON_VERSION_STAMP_MISMATCH 100
michael@0 32 #define CC_UNREG_REASON_VERSION_STAMP_MISMATCH_CONFIG 101
michael@0 33 #define CC_UNREG_REASON_VERSION_STAMP_MISMATCH_SOFTKEY 102
michael@0 34 #define CC_UNREG_REASON_VERSION_STAMP_MISMATCH_DIALPLAN 103
michael@0 35 #define CC_UNREG_REASON_APPLY_CONFIG_RESTART 104
michael@0 36 #define CC_UNREG_REASON_CONFIG_RETRY_RESTART 105
michael@0 37 #define CC_UNREG_REASON_TLS_ERROR 106
michael@0 38 #define CC_UNREG_REASON_RESET_TO_INACTIVE_PARTITION 107
michael@0 39 #define CC_UNREG_REASON_VPN_CONNECTIVITY_LOST 108
michael@0 40
michael@0 41 #define CC_IPPROTO_UDP 17
michael@0 42 #define CC_IPPROTO_TCP 6
michael@0 43
michael@0 44
michael@0 45 /**
michael@0 46 * socket security status
michael@0 47 */
michael@0 48 typedef enum
michael@0 49 {
michael@0 50 PLAT_SOCK_SECURE,
michael@0 51 PLAT_SOCK_NONSECURE
michael@0 52 } plat_soc_status_e;
michael@0 53
michael@0 54 /**
michael@0 55 * socket connection status
michael@0 56 */
michael@0 57 typedef enum
michael@0 58 {
michael@0 59 PLAT_SOCK_CONN_OK,
michael@0 60 PLAT_SOCK_CONN_WAITING,
michael@0 61 PLAT_SOCK_CONN_FAILED
michael@0 62 } plat_soc_connect_status_e;
michael@0 63
michael@0 64 /**
michael@0 65 * socket connection type
michael@0 66 */
michael@0 67 typedef enum
michael@0 68 {
michael@0 69 PLAT_SOCK_CUCM
michael@0 70 } plat_soc_connect_type_e;
michael@0 71
michael@0 72 /**
michael@0 73 * socket connection mode
michael@0 74 */
michael@0 75 typedef enum
michael@0 76 {
michael@0 77 PLAT_SOCK_AUTHENTICATED,
michael@0 78 PLAT_SOCK_ENCRYPTED,
michael@0 79 PLAT_SOCK_NON_SECURE
michael@0 80 } plat_soc_connect_mode_e;
michael@0 81
michael@0 82 /**
michael@0 83 * psipcc core debug categories
michael@0 84 */
michael@0 85 typedef enum
michael@0 86 {
michael@0 87 CC_DEBUG_CCAPP,
michael@0 88 CC_DEBUG_CONFIG_CACHE,
michael@0 89 CC_DEBUG_SIP_ADAPTER,
michael@0 90 CC_DEBUG_CCAPI,
michael@0 91 CC_DEBUG_CC_MSG,
michael@0 92 CC_DEBUG_FIM,
michael@0 93 CC_DEBUG_FSM,
michael@0 94 CC_DEBUG_AUTH,
michael@0 95 CC_DEBUG_GSM,
michael@0 96 CC_DEBUG_LSM,
michael@0 97 CC_DEBUG_FSM_CAC,
michael@0 98 CC_DEBUG_DCSM,
michael@0 99 CC_DEBUG_SIP_TASK,
michael@0 100 CC_DEBUG_SIP_STATE,
michael@0 101 CC_DEBUG_SIP_MSG,
michael@0 102 CC_DEBUG_SIP_REG_STATE,
michael@0 103 CC_DEBUG_SIP_TRX,
michael@0 104 CC_DEBUG_TIMERS,
michael@0 105 CC_DEBUG_SIP_DM,
michael@0 106 CC_DEBUG_CCDEFAULT, /* Always ON by default */
michael@0 107 CC_DEBUG_DIALPLAN,
michael@0 108 CC_DEBUG_KPML,
michael@0 109 CC_DEBUG_REMOTE_CC,
michael@0 110 CC_DEBUG_SIP_PRESENCE,
michael@0 111 CC_DEBUG_CONFIG_APP,
michael@0 112 CC_DEBUG_CALL_EVENT,
michael@0 113 CC_DEBUG_PLAT,
michael@0 114 CC_DEBUG_NOTIFY,
michael@0 115 CC_DEBUG_CPR_MEMORY, /* Has additional parameters - Tracking/poison */
michael@0 116 CC_DEBUG_MAX /* NOT USED */
michael@0 117 } cc_debug_category_e;
michael@0 118
michael@0 119
michael@0 120 /**
michael@0 121 * debug show categories
michael@0 122 */
michael@0 123 typedef enum
michael@0 124 {
michael@0 125 CC_DEBUG_SHOW_FSMCNF,
michael@0 126 CC_DEBUG_SHOW_FSMDEF,
michael@0 127 CC_DEBUG_SHOW_FSMXFR,
michael@0 128 CC_DEBUG_SHOW_FSMB2BCNF,
michael@0 129 CC_DEBUG_SHOW_DCSM,
michael@0 130 CC_DEBUG_SHOW_FIM,
michael@0 131 CC_DEBUG_SHOW_FSM,
michael@0 132 CC_DEBUG_SHOW_LSM,
michael@0 133 CC_DEBUG_SHOW_BULK_REGISTER,
michael@0 134 CC_DEBUG_SHOW_KPML,
michael@0 135 CC_DEBUG_SHOW_REMOTE_CC,
michael@0 136 CC_DEBUG_SHOW_CONFIG_CACHE,
michael@0 137 CC_DEBUG_SHOW_SUBS_STATS,
michael@0 138 CC_DEBUG_SHOW_PUBLISH_STATS,
michael@0 139 CC_DEBUG_SHOW_REGISTER,
michael@0 140 CC_DEBUG_SHOW_DIALPLAN,
michael@0 141 CC_DEBUG_SHOW_CPR_MEMORY, /* Has additional parameters -
michael@0 142 config/heap-gaurd/stat/tracking. */
michael@0 143 CC_DEBUG_SHOW_MAX
michael@0 144 } cc_debug_show_options_e;
michael@0 145
michael@0 146 /**
michael@0 147 * debug clear categories
michael@0 148 */
michael@0 149 typedef enum
michael@0 150 {
michael@0 151 CC_DEBUG_CLEAR_CPR_MEMORY,
michael@0 152 CC_DEBUG_CLEAR_MAX
michael@0 153 } cc_debug_clear_options_e;
michael@0 154
michael@0 155 /**
michael@0 156 * cpr memory debug sub-categories
michael@0 157 */
michael@0 158 typedef enum
michael@0 159 {
michael@0 160 CC_DEBUG_CPR_MEM_TRACKING,
michael@0 161 CC_DEBUG_CPR_MEM_POISON
michael@0 162 } cc_debug_cpr_mem_options_e;
michael@0 163
michael@0 164 /**
michael@0 165 * cpr memory clear sub-commands
michael@0 166 */
michael@0 167 typedef enum
michael@0 168 {
michael@0 169 CC_DEBUG_CLEAR_CPR_TRACKING,
michael@0 170 CC_DEBUG_CLEAR_CPR_STATISTICS
michael@0 171 } cc_debug_clear_cpr_options_e;
michael@0 172
michael@0 173 /**
michael@0 174 * cpr memory show sub-commands
michael@0 175 */
michael@0 176 typedef enum
michael@0 177 {
michael@0 178 CC_DEBUG_SHOW_CPR_CONFIG,
michael@0 179 CC_DEBUG_SHOW_CPR_HEAP_GUARD,
michael@0 180 CC_DEBUG_SHOW_CPR_STATISTICS,
michael@0 181 CC_DEBUG_SHOW_CPR_TRACKING
michael@0 182 } cc_debug_show_cpr_options_e;
michael@0 183
michael@0 184 /**
michael@0 185 * Enabling/disabling debugs
michael@0 186 */
michael@0 187 typedef enum
michael@0 188 {
michael@0 189 CC_DEBUG_DISABLE,
michael@0 190 CC_DEBUG_ENABLE
michael@0 191 } cc_debug_flag_e;
michael@0 192
michael@0 193 // Corresponds to the values for XML tags DHCPv4Status and DHCPv6Status
michael@0 194 typedef enum {
michael@0 195 DHCP_STATUS_GOOD = 1,
michael@0 196 DHCP_STATUS_TIMEOUT,
michael@0 197 DHCP_STATUS_DISABLED
michael@0 198 } dhcp_status_e;
michael@0 199
michael@0 200
michael@0 201 // Corresponds to the value for XML tag for DNSStatusUnifiedCMX
michael@0 202 typedef enum {
michael@0 203 DNS_STATUS_GOOD = 1,
michael@0 204 DNS_STATUS_TIMEOUT,
michael@0 205 DNS_STATUS_DID_NOT_RESOLVE,
michael@0 206 DNS_STATUS_NA_IP_CONFIGURED
michael@0 207 } ucm_dns_resolution_status_e;
michael@0 208
michael@0 209 #define LEN32 32
michael@0 210 #define IP_ADDR_MAX_LEN 32
michael@0 211 #define PORT_MAX_LEN 20
michael@0 212 #define STATUS_MAX_LEN 4
michael@0 213 #define LEN80 80
michael@0 214 #define WIRED_PROP_PREFIX "dhcp.eth0"
michael@0 215 #define WIRELESS_PROP_PREFIX "dhcp.mlan0"
michael@0 216 #define WIRED_INT 1
michael@0 217 #define WIFI_INT 2
michael@0 218
michael@0 219
michael@0 220 /**
michael@0 221 * Called by the thread to initialize any thread specific data
michael@0 222 * once the thread is created.
michael@0 223 *
michael@0 224 * @param[in] tname thread name
michael@0 225 *
michael@0 226 * @return 0 - SUCCESS
michael@0 227 * -1 - FAILURE
michael@0 228 */
michael@0 229 int platThreadInit(char * tname);
michael@0 230
michael@0 231 /**
michael@0 232 * The initial initialization function for any platform related
michael@0 233 * modules
michael@0 234 *
michael@0 235 *
michael@0 236 * @return 0 - SUCCESS
michael@0 237 * -1 - FAILURE
michael@0 238 */
michael@0 239 int platInit();
michael@0 240
michael@0 241 /**
michael@0 242 * The initial initialization function for the debugging/logging
michael@0 243 * modules
michael@0 244 *
michael@0 245 */
michael@0 246 void debugInit();
michael@0 247
michael@0 248 /**
michael@0 249 * Get device model that will be sent to cucm in the UserAgent header
michael@0 250 *
michael@0 251 * @return char * Pointer to the string containing the model number of the phone.
michael@0 252 */
michael@0 253 char *platGetModel();
michael@0 254
michael@0 255 /**
michael@0 256 * plat_audio_device_t
michael@0 257 * Enums for indicating audio device
michael@0 258 */
michael@0 259 typedef enum vcm_audio_device_type {
michael@0 260 VCM_AUDIO_DEVICE_NONE,
michael@0 261 VCM_AUDIO_DEVICE_HEADSET,
michael@0 262 VCM_AUDIO_DEVICE_SPEAKER
michael@0 263 } plat_audio_device_t;
michael@0 264
michael@0 265
michael@0 266 /**
michael@0 267 * Add cc control classifier
michael@0 268 *
michael@0 269 * Called by SIP stack to specify addresses and ports that will be used for call control
michael@0 270 *
michael@0 271 * @param[in] myIPAddr - phone local interface IP Address
michael@0 272 * @param[in] myPort - phone local interface Port
michael@0 273 * @param[in] cucm1IPAddr - CUCM 1 IP Address
michael@0 274 * @param[in] cucm1Port - CUCM 1 Port
michael@0 275 * @param[in] cucm2IPAddr - CUCM 2 IP Address
michael@0 276 * @param[in] cucm2Port - CUCM 2 Port
michael@0 277 * @param[in] cucm3IPAddr - CUCM 3 IP Address
michael@0 278 * @param[in] cucm3Port - CUCM 3 Port
michael@0 279 * @param[in] protocol - CC_IPPROTO_UDP or CC_IP_PROTO_TCP
michael@0 280 *
michael@0 281 * @note : Needed only if using WiFi. If not using Wifi please provide a stub
michael@0 282 */
michael@0 283 void platAddCallControlClassifiers(unsigned long myIPAddr, unsigned short myPort,
michael@0 284 unsigned long cucm1IPAddr, unsigned short cucm1Port,
michael@0 285 unsigned long cucm2IPAddr, unsigned short cucm2Port,
michael@0 286 unsigned long cucm3IPAddr, unsigned short cucm3Port,
michael@0 287 unsigned char protocol);
michael@0 288
michael@0 289 /**
michael@0 290 * Remove cc control classifier.
michael@0 291 *
michael@0 292 * Undo platAddCallControlClassifiers
michael@0 293 */
michael@0 294 void platRemoveCallControlClassifiers();
michael@0 295
michael@0 296 /**
michael@0 297 * Tell whether wifi is supported and active
michael@0 298 *
michael@0 299 * @return boolean wether WLAN is active or not
michael@0 300 */
michael@0 301 cc_boolean platWlanISActive();
michael@0 302
michael@0 303 /**
michael@0 304 * Check if the netowrk interface changed.
michael@0 305 *
michael@0 306 * @return boolean returns TRUE if the network interface has changed
michael@0 307 *
michael@0 308 * @note Most common case is for softphone clients where if a PC is
michael@0 309 * undocked the network interface changes from wired to wireless.
michael@0 310 */
michael@0 311 boolean platIsNetworkInterfaceChanged();
michael@0 312
michael@0 313 /**
michael@0 314 * Get active phone load name
michael@0 315 *
michael@0 316 * Returns the phone images in the active and inactive partitions
michael@0 317 * The phone reports these phone loads to CUCM for display on the Admin page
michael@0 318 *
michael@0 319 * @param[in] image_a : Populate the image name from partition a
michael@0 320 * @param[in] image_b : Populate the image name from partition b
michael@0 321 * @param[in] len : Length of the pointers for image_a and image_b
michael@0 322 * @return 1 - image_a is active
michael@0 323 * 2 - image_b is active
michael@0 324 * -1 - Failure
michael@0 325 */
michael@0 326 int platGetActiveInactivePhoneLoadName(char * image_a, char * image_b, int len);
michael@0 327
michael@0 328 /**
michael@0 329 * Get localized phrase for the specified index
michael@0 330 *
michael@0 331 * @param[in] index the phrase index, see
michael@0 332 * @param[in] phrase the return phrase holder
michael@0 333 * @param[in] len the input length to cap the maximum value
michael@0 334 *
michael@0 335 * @return SUCCESS or FAILURE
michael@0 336 */
michael@0 337 int platGetPhraseText(int index, char* phrase, unsigned int len);
michael@0 338
michael@0 339 /**
michael@0 340 * Set the unregistration reason
michael@0 341 *
michael@0 342 * @param[in] reason see the unregister reason definitions.
michael@0 343 *
michael@0 344 * @note we expect the platform to save this value in Non Volatile memory
michael@0 345 * This will be retrieved later by using platGetUnregReason. This reason is reported to CUCM
michael@0 346 */
michael@0 347 void platSetUnregReason(int reason);
michael@0 348
michael@0 349
michael@0 350 /**
michael@0 351 * Get the unregistration reason code.
michael@0 352 *
michael@0 353 * @return reason code for unregistration
michael@0 354 */
michael@0 355 int platGetUnregReason();
michael@0 356
michael@0 357 /**
michael@0 358 * Sets the time based on Date header in 200 OK from REGISTER request
michael@0 359 * @param void
michael@0 360 * @return void
michael@0 361 */
michael@0 362 void platSetCucmRegTime (void);
michael@0 363
michael@0 364 /**
michael@0 365 * Set the kpml value for application.
michael@0 366 *
michael@0 367 * @param kpml_config the kpml value
michael@0 368 */
michael@0 369 void platSetKPMLConfig(cc_kpml_config_t kpml_config);
michael@0 370
michael@0 371 /**
michael@0 372 * Check if a line has active MWI status
michael@0 373 *
michael@0 374 * @param line
michael@0 375 *
michael@0 376 * @return boolean
michael@0 377 *
michael@0 378 * @note The stack doesn't store the MWI status and expects
michael@0 379 * the application to store that information. The stack
michael@0 380 * queries the mwi status from the application using this method.
michael@0 381 */
michael@0 382 boolean platGetMWIStatus(cc_lineid_t line);
michael@0 383
michael@0 384 /**
michael@0 385 * Check if the speaker or headset is enabled.
michael@0 386 *
michael@0 387 * @return boolean if the speaker or headset is enabled, returns true.
michael@0 388 */
michael@0 389 boolean platGetSpeakerHeadsetMode();
michael@0 390
michael@0 391 /**
michael@0 392 * Secure Socket API's.
michael@0 393 * The pSIPCC expects the following Secure Socket APIs to be implemented in the
michael@0 394 * vendor porting layer.
michael@0 395 */
michael@0 396
michael@0 397 /**
michael@0 398 * platSecIsServerSecure
michael@0 399 *
michael@0 400 * @brief Lookup the secure status of the server
michael@0 401 *
michael@0 402 * This function looks at the the CCM server type by using the security library
michael@0 403 * and returns appropriate indication to the pSIPCC.
michael@0 404 *
michael@0 405 *
michael@0 406 * @return Server is security enabled or not
michael@0 407 * PLAT_SOCK_SECURE or PLAT_SOCK_NONSECURE
michael@0 408 *
michael@0 409 * @note This API maps to the following HandyIron API:
michael@0 410 * int secIsServerSecure(SecServerType type) where type should be SRVR_TYPE_CCM
michael@0 411 */
michael@0 412 plat_soc_status_e platSecIsServerSecure(void);
michael@0 413
michael@0 414
michael@0 415 /**
michael@0 416 * platSecSocConnect
michael@0 417 * @brief Securely connect to a remote server
michael@0 418 *
michael@0 419 * This function uses the security library APIs to connect to a remote server.
michael@0 420 * @param[in] host server addr
michael@0 421 * @param[in] port port number
michael@0 422 * @param[in] ipMode IP mode to indicate v6, v4 or both
michael@0 423 * @param[in] mode blocking connect or not
michael@0 424 * FALSE: non-blocking; TRUE: blocking
michael@0 425 * @param[in] tos TOS value
michael@0 426 * @param[in] connectionMode The mode of the connection
michael@0 427 * (Authenticated/Encrypted)
michael@0 428 * @param[out] localPort local port used for the connection
michael@0 429 *
michael@0 430 * @return client socket descriptor
michael@0 431 * >=0: connected or in progress
michael@0 432 * INVALID SOCKET: failed
michael@0 433 *
michael@0 434 * @pre (hostAndPort not_eq NULL)
michael@0 435 * @pre (localPort not_eq NULL)
michael@0 436 *
michael@0 437 * @note localPort is undefined when the return value is INVALID_SOCKET
michael@0 438 *
michael@0 439 * @note This API maps to the HandyIron APIs as follows:
michael@0 440 * If mode == TRUE (blocking):
michael@0 441 * int secEstablishSecureConnection(const char* serverAddr, *uint32_t port, secConnectionType type)
michael@0 442 * @li ipMode is UNUSED
michael@0 443 * @li "host" maps to "serverAddr", "type" should be determined by an application and use the value from SecServerType.
michael@0 444 * @li localPort is passed in as 0
michael@0 445 * If mode == FALSE (non-blocking):
michael@0 446 * int secConnect(const char* serverAddr, uint32_t port, *secConnectionType type, uint32_t localPort)
michael@0 447 * @li ipMode is UNUSED
michael@0 448 * @li "host" maps to "serverAddr", "type" should be determined by an application and use the value from SecServerType.
michael@0 449 *
michael@0 450 * @note The implementation should use the "setsockopt" to set the "tos" value passed
michael@0 451 * in this API on the created socket.
michael@0 452 *
michael@0 453 */
michael@0 454 cpr_socket_t
michael@0 455 platSecSocConnect (char *host,
michael@0 456 int port,
michael@0 457 int ipMode,
michael@0 458 boolean mode,
michael@0 459 unsigned int tos,
michael@0 460 plat_soc_connect_mode_e connectionMode,
michael@0 461 cc_uint16_t *localPort);
michael@0 462
michael@0 463 /**
michael@0 464 * platSecSockIsConnected
michael@0 465 * Determine the status of a secure connection that was initiated
michael@0 466 * in non-blocking mode
michael@0 467 *
michael@0 468 * @param[in] sock socket descriptor
michael@0 469 *
michael@0 470 * @return connection status
michael@0 471 * @li connection complete: PLAT_SOCK_CONN_OK
michael@0 472 * @li connection waiting: PLAT_SOCK_CONN_WAITING
michael@0 473 * @li connection failed: PLAT_SOCK_CONN_FAILED
michael@0 474 *
michael@0 475 * @note This API maps to the following HandyIron API:
michael@0 476 * int secIsConnectionReady (int connDesc)
michael@0 477 * The "sock" is the connection descriptor.
michael@0 478 */
michael@0 479 plat_soc_connect_status_e platSecSockIsConnected (cpr_socket_t sock);
michael@0 480
michael@0 481 /**
michael@0 482 * platGenerateCryptoRand
michael@0 483 * @brief Generates a Random Number
michael@0 484 *
michael@0 485 * Generate crypto graphically random number for a desired length.
michael@0 486 * The function is expected to be much slower than the cpr_rand().
michael@0 487 * This function should be used when good random number is needed
michael@0 488 * such as random number that to be used for SRTP key for an example.
michael@0 489 *
michael@0 490 * @param[in] buf - pointer to the buffer to store the result of random
michael@0 491 * bytes requested.
michael@0 492 * @param[in] len - pointer to the length of the desired random bytes.
michael@0 493 * When calling the function, the integer's value
michael@0 494 * should be set to the desired number of random
michael@0 495 * bytes ('buf' should be of at least this size).
michael@0 496 * upon success, its value will be set to the
michael@0 497 * actual number of random bytes being returned.
michael@0 498 * (realistically, there is a maximum number of
michael@0 499 * random bytes that can be returned at a time.
michael@0 500 * if the caller request more than that, the
michael@0 501 * 'len' will indicate how many bytes are actually being
michael@0 502 * returned) on failure, its value will be set to 0.
michael@0 503 *
michael@0 504 * @return
michael@0 505 * 1 - success.
michael@0 506 * 0 - fail.
michael@0 507 *
michael@0 508 * @note The intent of this function is to generate a cryptographically strong
michael@0 509 * random number. Vendors can map this to HandyIron or OpenSSL random number
michael@0 510 * generation functions.
michael@0 511 *
michael@0 512 * @note This API maps to the following HandyIron API:
michael@0 513 * int secGetRandomData(uint8_t *buf, uint32_t size). Also note that a
michael@0 514 * "secAddEntropy(...)" may be required the first time to feed entropy data to
michael@0 515 * the random number generator.
michael@0 516 */
michael@0 517 int platGenerateCryptoRand(cc_uint8_t *buf, int *len);
michael@0 518
michael@0 519 /**
michael@0 520 * platSecSocSend
michael@0 521 *
michael@0 522 * @brief The platSecSocSend() function is used to send data over a secure
michael@0 523 * socket.
michael@0 524 *
michael@0 525 * The platSecSocSend() function shall transmit a message from the specified socket to
michael@0 526 * its peer. The platSecSocSend() function shall send a message only when the socket is
michael@0 527 * connected. The length of the message to be sent is specified by the length
michael@0 528 * argument. If the message is too long to pass through the underlying protocol,
michael@0 529 * platSecSocSend() shall fail and no data is transmitted. Delivery of the message is
michael@0 530 * not guaranteed.
michael@0 531 *
michael@0 532 * @param[in] soc Specifies the socket created with cprSocket() to send
michael@0 533 * @param[in] buf A pointer to the buffer of the message to send.
michael@0 534 * @param[in] len Specifies the length in bytes of the message pointed to by the buffer argument.
michael@0 535 *
michael@0 536 * @return Upon successful completion, platSecSocSend() shall return the number of
michael@0 537 * bytes sent. Otherwise, SOCKET_ERROR shall be returned and cpr_errno set to
michael@0 538 * indicate the error.
michael@0 539 *
michael@0 540 * @note The possible error values this function should return are
michael@0 541 * @li [CPR_EBADF] The socket argument is not a valid file descriptor
michael@0 542 * @li [CPR_ENOTSOCK] socket does not refer to a socket descriptor
michael@0 543 * @li [CPR_EAGAIN] The socket is marked non-blocking and no data can
michael@0 544 * be sent
michael@0 545 * @li [CPR_EWOULDBLOCK] Same as CPR_EAGAIN
michael@0 546 * @li [CPR_ENOTCONN] A connection-mode socket that is not connected
michael@0 547 * @li [CPR_ENOTSUPP] The specified flags are not supported for this
michael@0 548 * type of socket or protocol.
michael@0 549 * @li [CPR_EMSGSIZE] The message is too large to be sent all at once
michael@0 550 * @li [CPR_EDESTADDRREQ] The socket has no peer address set
michael@0 551 *
michael@0 552 */
michael@0 553 ssize_t
michael@0 554 platSecSocSend (cpr_socket_t soc,
michael@0 555 CONST void *buf,
michael@0 556 size_t len);
michael@0 557
michael@0 558 /**
michael@0 559 * platSecSocRecv
michael@0 560 *
michael@0 561 * @brief The platSecSocRecv() function shall receive a message from a secure socket.
michael@0 562 *
michael@0 563 * This function is normally used with connected sockets because it does not permit
michael@0 564 * the application to retrieve the source address of received data. The
michael@0 565 * platSecSocRecv() function shall return the length of the message written to
michael@0 566 * the buffer pointed to by the "buf" argument.
michael@0 567 *
michael@0 568 * @param[in] soc - Specifies the socket to receive data
michael@0 569 * @param[out] buf - Contains the data received
michael@0 570 * @param[out] len - The length of the data received
michael@0 571 *
michael@0 572 * @return On success the length of the message in bytes (including zero).
michael@0 573 * On failure SOCKET_ERROR shall be returned and cpr_errno set to
michael@0 574 * indicate the error.
michael@0 575 *
michael@0 576 * @note The possible error values this function should return are
michael@0 577 * @li [CPR_EBADF] The socket argument is not a valid file descriptor
michael@0 578 * @li [CPR_ENOTSOCK] The descriptor references a file, not a socket.
michael@0 579 * @li [CPR_EAGAIN] The socket is marked non-blocking and no data is
michael@0 580 * waiting to be received.
michael@0 581 * @li [CPR_EWOULDBLOCK] Same as CPR_EAGAIN
michael@0 582 * @li [CPR_ENOTCONN] A receive attempt is made on a connection-mode socket that is not connected
michael@0 583 * @li [CPR_ENOTSUPP] The specified flags are not supported for this type of socket or protocol
michael@0 584 *
michael@0 585 */
michael@0 586 ssize_t
michael@0 587 platSecSocRecv (cpr_socket_t soc,
michael@0 588 void * RESTRICT buf,
michael@0 589 size_t len);
michael@0 590
michael@0 591 /**
michael@0 592 * platSecSocClose
michael@0 593 *
michael@0 594 * @brief The platSecSocClose function shall close a secure socket
michael@0 595 *
michael@0 596 * The platSecSocClose() function shall destroy the socket descriptor indicated
michael@0 597 * by socket.
michael@0 598 *
michael@0 599 * @param[in] soc - The socket that needs to be destroyed
michael@0 600 *
michael@0 601 * @return CPR_SUCCESS on success otherwise, CPR_FAILURE. cpr_errno needs to be set in this case.
michael@0 602 *
michael@0 603 * @note The possible error values this function should return are
michael@0 604 * @li [CPR_EBADF] socket is not a valid socket descriptor.
michael@0 605 */
michael@0 606 cpr_status_e
michael@0 607 platSecSocClose (cpr_socket_t soc);
michael@0 608
michael@0 609 /**
michael@0 610 * Sets the SIS protocol version
michael@0 611 *
michael@0 612 * @param a - major version
michael@0 613 * @param b - minor version
michael@0 614 * @param c - additional version information
michael@0 615 * @param name - version name
michael@0 616 *
michael@0 617 * @return void
michael@0 618 * @note the platform should store this information and provide it when asked via the platGetSISProtocolVer()
michael@0 619 */
michael@0 620
michael@0 621 void platSetSISProtocolVer(cc_uint32_t a, cc_uint32_t b, cc_uint32_t c, char* name);
michael@0 622
michael@0 623 /**
michael@0 624 * Provides the SIS protocol version
michael@0 625 *
michael@0 626 * @param *a pointer to fill in the major version
michael@0 627 * @param *b pointer to fill in the minor version
michael@0 628 * @param *c pointer to fill in the additonal version
michael@0 629 * @param *name pointer to fill in the version name
michael@0 630 *
michael@0 631 * @return void
michael@0 632 */
michael@0 633 void
michael@0 634 platGetSISProtocolVer (cc_uint32_t *a, cc_uint32_t *b, cc_uint32_t *c, char* name);
michael@0 635
michael@0 636 /**
michael@0 637 * Provides the local IP address
michael@0 638 *
michael@0 639 * @return char * returns the local IP address
michael@0 640 */
michael@0 641 char *platGetIPAddr();
michael@0 642
michael@0 643 /**
michael@0 644 * Provides the local MAC address
michael@0 645 *
michael@0 646 * @param *maddr the pointer to the string holding MAC address
michael@0 647 * in the MAC address format after converting from string format.
michael@0 648 * @return void
michael@0 649 */
michael@0 650 void platGetMacAddr(char *addr);
michael@0 651
michael@0 652
michael@0 653 /**
michael@0 654 * platGetFeatureAllowed
michael@0 655 *
michael@0 656 * Get whether the feature is allowed
michael@0 657 *
michael@0 658 * @param featureId - sis feature id
michael@0 659 *
michael@0 660 * @return 1 - allowed, 0 - not allowed
michael@0 661 *
michael@0 662 */
michael@0 663 int platGetFeatureAllowed(cc_sis_feature_id_e featureId);
michael@0 664
michael@0 665
michael@0 666 /**
michael@0 667 * Set the Status message for failure reasons
michael@0 668 * @param char *msg
michael@0 669 * @return void
michael@0 670 */
michael@0 671 void platSetStatusMessage(char *msg);
michael@0 672
michael@0 673 /**
michael@0 674 * The equivalent of the printf function.
michael@0 675 *
michael@0 676 * This function MUST be implemented by the vendors. This is called by the core
michael@0 677 * library whenever some debugging information needs to be printed out.
michael@0 678 * call this function in order to clear the CPR Memory/Tracking statistics
michael@0 679 *
michael@0 680 * Please also be aware that cpr_stdio.h has other logging functions as well.
michael@0 681 * Vendors need to implement this function and the functions (err_msg,
michael@0 682 * buginf....etc) found in cpr_stdio.h
michael@0 683 *
michael@0 684 * @param[in] _format format string
michael@0 685 * @param[in] ... variable arg list
michael@0 686 *
michael@0 687 * @return Return code from printf
michael@0 688 */
michael@0 689 int debugif_printf(const char *_format, ...);
michael@0 690
michael@0 691 /**
michael@0 692 * Enable / disable speaker
michael@0 693 *
michael@0 694 * @param[in] state - true -> enable speaker, false -> disable speaker
michael@0 695 *
michael@0 696 * @return void
michael@0 697 */
michael@0 698
michael@0 699 void platSetSpeakerMode(cc_boolean state);
michael@0 700
michael@0 701 /**
michael@0 702 * Get the status (on/off) of the audio device
michael@0 703 *
michael@0 704 * @param[in] device_type - headset or speaker (see vcm_audio_device_t)
michael@0 705 *
michael@0 706 * @return 1 -> On, 0 -> off, ERROR -> unknown (error)
michael@0 707 */
michael@0 708
michael@0 709 int platGetAudioDeviceStatus(plat_audio_device_t device_type);
michael@0 710
michael@0 711 /*
michael@0 712 * Returns the default gateway
michael@0 713 *
michael@0 714 * @param void
michael@0 715 * @return u_long
michael@0 716 */
michael@0 717 cc_ulong_t platGetDefaultgw();
michael@0 718
michael@0 719
michael@0 720 #endif /* _PLATFORM_API_H_ */

mercurial