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

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/media/webrtc/signaling/src/sipcc/include/plat_api.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,720 @@
     1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.7 +
     1.8 +#ifndef _PLAT_API_H_
     1.9 +#define _PLAT_API_H_
    1.10 +
    1.11 +#include "cc_constants.h"
    1.12 +#include "cpr_socket.h"
    1.13 +#include "cc_types.h"
    1.14 +
    1.15 +/**
    1.16 + * Define unregister reason
    1.17 + */
    1.18 +#define CC_UNREG_REASON_UNSPECIFIED                       0
    1.19 +//Common with what SCCP uses...need to match with J-Side
    1.20 +#define CC_UNREG_REASON_TCP_TIMEOUT                       10
    1.21 +#define CC_UNREG_REASON_CM_RESET_TCP                      12
    1.22 +#define CC_UNREG_REASON_CM_ABORTED_TCP                    13
    1.23 +#define CC_UNREG_REASON_CM_CLOSED_TCP                     14
    1.24 +#define CC_UNREG_REASON_REG_TIMEOUT                       17
    1.25 +#define CC_UNREG_REASON_FALLBACK                          18
    1.26 +#define CC_UNREG_REASON_PHONE_KEYPAD                      20
    1.27 +#define CC_UNREG_REASON_RESET_RESET                       22
    1.28 +#define CC_UNREG_REASON_RESET_RESTART                     23
    1.29 +#define CC_UNREG_REASON_PHONE_REG_REJ                     24
    1.30 +#define CC_UNREG_REASON_PHONE_INITIALIZED                 25
    1.31 +#define CC_UNREG_REASON_VOICE_VLAN_CHANGED                26
    1.32 +#define CC_UNREG_REASON_POWER_SAVE_PLUS                   32
    1.33 +//sip specific ones...need to match with J-Side
    1.34 +#define CC_UNREG_REASON_VERSION_STAMP_MISMATCH            100
    1.35 +#define CC_UNREG_REASON_VERSION_STAMP_MISMATCH_CONFIG     101
    1.36 +#define CC_UNREG_REASON_VERSION_STAMP_MISMATCH_SOFTKEY    102
    1.37 +#define CC_UNREG_REASON_VERSION_STAMP_MISMATCH_DIALPLAN   103
    1.38 +#define CC_UNREG_REASON_APPLY_CONFIG_RESTART              104
    1.39 +#define CC_UNREG_REASON_CONFIG_RETRY_RESTART              105
    1.40 +#define CC_UNREG_REASON_TLS_ERROR                         106
    1.41 +#define CC_UNREG_REASON_RESET_TO_INACTIVE_PARTITION       107
    1.42 +#define CC_UNREG_REASON_VPN_CONNECTIVITY_LOST             108
    1.43 +
    1.44 +#define CC_IPPROTO_UDP 17
    1.45 +#define CC_IPPROTO_TCP 6
    1.46 +
    1.47 +
    1.48 +/**
    1.49 + * socket security status
    1.50 + */
    1.51 +typedef enum
    1.52 +{
    1.53 +    PLAT_SOCK_SECURE,
    1.54 +    PLAT_SOCK_NONSECURE
    1.55 +} plat_soc_status_e;
    1.56 +
    1.57 +/**
    1.58 + * socket connection status
    1.59 + */
    1.60 +typedef enum
    1.61 +{
    1.62 +    PLAT_SOCK_CONN_OK,
    1.63 +    PLAT_SOCK_CONN_WAITING,
    1.64 +    PLAT_SOCK_CONN_FAILED
    1.65 +} plat_soc_connect_status_e;
    1.66 +
    1.67 +/**
    1.68 + * socket connection type
    1.69 + */
    1.70 +typedef enum
    1.71 +{
    1.72 +    PLAT_SOCK_CUCM
    1.73 +} plat_soc_connect_type_e;
    1.74 +
    1.75 +/**
    1.76 + * socket connection mode
    1.77 + */
    1.78 +typedef enum
    1.79 +{
    1.80 +    PLAT_SOCK_AUTHENTICATED,
    1.81 +    PLAT_SOCK_ENCRYPTED,
    1.82 +    PLAT_SOCK_NON_SECURE
    1.83 +} plat_soc_connect_mode_e;
    1.84 +
    1.85 +/**
    1.86 + * psipcc core debug categories
    1.87 + */
    1.88 +typedef enum
    1.89 +{
    1.90 +    CC_DEBUG_CCAPP,
    1.91 +    CC_DEBUG_CONFIG_CACHE,
    1.92 +    CC_DEBUG_SIP_ADAPTER,
    1.93 +    CC_DEBUG_CCAPI,
    1.94 +    CC_DEBUG_CC_MSG,
    1.95 +    CC_DEBUG_FIM,
    1.96 +    CC_DEBUG_FSM,
    1.97 +    CC_DEBUG_AUTH,
    1.98 +    CC_DEBUG_GSM,
    1.99 +    CC_DEBUG_LSM,
   1.100 +    CC_DEBUG_FSM_CAC,
   1.101 +    CC_DEBUG_DCSM,
   1.102 +    CC_DEBUG_SIP_TASK,
   1.103 +    CC_DEBUG_SIP_STATE,
   1.104 +    CC_DEBUG_SIP_MSG,
   1.105 +    CC_DEBUG_SIP_REG_STATE,
   1.106 +    CC_DEBUG_SIP_TRX,
   1.107 +    CC_DEBUG_TIMERS,
   1.108 +    CC_DEBUG_SIP_DM,
   1.109 +    CC_DEBUG_CCDEFAULT, /* Always ON by default */
   1.110 +    CC_DEBUG_DIALPLAN,
   1.111 +    CC_DEBUG_KPML,
   1.112 +    CC_DEBUG_REMOTE_CC,
   1.113 +    CC_DEBUG_SIP_PRESENCE,
   1.114 +    CC_DEBUG_CONFIG_APP,
   1.115 +    CC_DEBUG_CALL_EVENT,
   1.116 +    CC_DEBUG_PLAT,
   1.117 +    CC_DEBUG_NOTIFY,
   1.118 +    CC_DEBUG_CPR_MEMORY, /* Has additional parameters - Tracking/poison */
   1.119 +    CC_DEBUG_MAX        /* NOT USED */
   1.120 +} cc_debug_category_e;
   1.121 +
   1.122 +
   1.123 +/**
   1.124 + * debug show categories
   1.125 + */
   1.126 +typedef enum
   1.127 +{
   1.128 +    CC_DEBUG_SHOW_FSMCNF,
   1.129 +    CC_DEBUG_SHOW_FSMDEF,
   1.130 +    CC_DEBUG_SHOW_FSMXFR,
   1.131 +    CC_DEBUG_SHOW_FSMB2BCNF,
   1.132 +    CC_DEBUG_SHOW_DCSM,
   1.133 +    CC_DEBUG_SHOW_FIM,
   1.134 +    CC_DEBUG_SHOW_FSM,
   1.135 +    CC_DEBUG_SHOW_LSM,
   1.136 +    CC_DEBUG_SHOW_BULK_REGISTER,
   1.137 +    CC_DEBUG_SHOW_KPML,
   1.138 +    CC_DEBUG_SHOW_REMOTE_CC,
   1.139 +    CC_DEBUG_SHOW_CONFIG_CACHE,
   1.140 +    CC_DEBUG_SHOW_SUBS_STATS,
   1.141 +    CC_DEBUG_SHOW_PUBLISH_STATS,
   1.142 +    CC_DEBUG_SHOW_REGISTER,
   1.143 +    CC_DEBUG_SHOW_DIALPLAN,
   1.144 +    CC_DEBUG_SHOW_CPR_MEMORY, /* Has additional parameters -
   1.145 +                                 config/heap-gaurd/stat/tracking. */
   1.146 +    CC_DEBUG_SHOW_MAX
   1.147 +} cc_debug_show_options_e;
   1.148 +
   1.149 +/**
   1.150 + * debug clear categories
   1.151 + */
   1.152 +typedef enum
   1.153 +{
   1.154 +    CC_DEBUG_CLEAR_CPR_MEMORY,
   1.155 +    CC_DEBUG_CLEAR_MAX
   1.156 +} cc_debug_clear_options_e;
   1.157 +
   1.158 +/**
   1.159 + * cpr memory debug sub-categories
   1.160 + */
   1.161 +typedef enum
   1.162 +{
   1.163 +    CC_DEBUG_CPR_MEM_TRACKING,
   1.164 +    CC_DEBUG_CPR_MEM_POISON
   1.165 +} cc_debug_cpr_mem_options_e;
   1.166 +
   1.167 +/**
   1.168 + * cpr memory clear sub-commands
   1.169 + */
   1.170 +typedef enum
   1.171 +{
   1.172 +    CC_DEBUG_CLEAR_CPR_TRACKING,
   1.173 +    CC_DEBUG_CLEAR_CPR_STATISTICS
   1.174 +} cc_debug_clear_cpr_options_e;
   1.175 +
   1.176 +/**
   1.177 +  * cpr memory show sub-commands
   1.178 +  */
   1.179 +typedef enum
   1.180 +{
   1.181 +    CC_DEBUG_SHOW_CPR_CONFIG,
   1.182 +    CC_DEBUG_SHOW_CPR_HEAP_GUARD,
   1.183 +    CC_DEBUG_SHOW_CPR_STATISTICS,
   1.184 +    CC_DEBUG_SHOW_CPR_TRACKING
   1.185 +} cc_debug_show_cpr_options_e;
   1.186 +
   1.187 +/**
   1.188 + * Enabling/disabling debugs
   1.189 + */
   1.190 +typedef enum
   1.191 +{
   1.192 +    CC_DEBUG_DISABLE,
   1.193 +    CC_DEBUG_ENABLE
   1.194 +} cc_debug_flag_e;
   1.195 +
   1.196 +// Corresponds to the values for XML tags DHCPv4Status and DHCPv6Status
   1.197 +typedef enum {
   1.198 +       DHCP_STATUS_GOOD = 1,
   1.199 +       DHCP_STATUS_TIMEOUT,
   1.200 +       DHCP_STATUS_DISABLED
   1.201 + } dhcp_status_e;
   1.202 +
   1.203 +
   1.204 +// Corresponds to the value for XML tag for DNSStatusUnifiedCMX
   1.205 +typedef enum {
   1.206 +   DNS_STATUS_GOOD = 1,
   1.207 +   DNS_STATUS_TIMEOUT,
   1.208 +   DNS_STATUS_DID_NOT_RESOLVE,
   1.209 +   DNS_STATUS_NA_IP_CONFIGURED
   1.210 +} ucm_dns_resolution_status_e;
   1.211 +
   1.212 +#define LEN32   32
   1.213 +#define IP_ADDR_MAX_LEN       32
   1.214 +#define PORT_MAX_LEN          20
   1.215 +#define STATUS_MAX_LEN        4
   1.216 +#define LEN80   80
   1.217 +#define WIRED_PROP_PREFIX     "dhcp.eth0"
   1.218 +#define WIRELESS_PROP_PREFIX  "dhcp.mlan0"
   1.219 +#define WIRED_INT 1
   1.220 +#define WIFI_INT  2
   1.221 +
   1.222 +
   1.223 +/**
   1.224 + * Called by the thread to initialize any thread specific data
   1.225 + * once the thread is created.
   1.226 + *
   1.227 + * @param[in] tname       thread name
   1.228 + *
   1.229 + * @return 0 - SUCCESS
   1.230 + *        -1 - FAILURE
   1.231 + */
   1.232 +int platThreadInit(char * tname);
   1.233 +
   1.234 +/**
   1.235 + * The initial initialization function for any platform related
   1.236 + * modules
   1.237 + *
   1.238 + *
   1.239 + * @return 0 - SUCCESS
   1.240 + *        -1 - FAILURE
   1.241 + */
   1.242 +int platInit();
   1.243 +
   1.244 +/**
   1.245 + * The initial initialization function for the debugging/logging
   1.246 + * modules
   1.247 + *
   1.248 + */
   1.249 +void debugInit();
   1.250 +
   1.251 +/**
   1.252 + * Get device model that will be sent to cucm in the UserAgent header
   1.253 + *
   1.254 + * @return char * Pointer to the string containing the model number of the phone.
   1.255 + */
   1.256 +char *platGetModel();
   1.257 +
   1.258 +/**
   1.259 + * plat_audio_device_t
   1.260 + * Enums for indicating audio device
   1.261 + */
   1.262 +typedef enum vcm_audio_device_type {
   1.263 +    VCM_AUDIO_DEVICE_NONE,
   1.264 +    VCM_AUDIO_DEVICE_HEADSET,
   1.265 +    VCM_AUDIO_DEVICE_SPEAKER
   1.266 +} plat_audio_device_t;
   1.267 +
   1.268 +
   1.269 +/**
   1.270 + * Add cc control classifier
   1.271 + *
   1.272 + * Called by SIP stack to specify addresses and ports that will be used for call control
   1.273 + *
   1.274 + * @param[in] myIPAddr - phone local interface IP Address
   1.275 + * @param[in] myPort - phone local interface Port
   1.276 + * @param[in] cucm1IPAddr - CUCM 1 IP Address
   1.277 + * @param[in] cucm1Port - CUCM 1 Port
   1.278 + * @param[in] cucm2IPAddr - CUCM 2 IP Address
   1.279 + * @param[in] cucm2Port - CUCM 2 Port
   1.280 + * @param[in] cucm3IPAddr - CUCM 3 IP Address
   1.281 + * @param[in] cucm3Port - CUCM 3 Port
   1.282 + * @param[in] protocol - CC_IPPROTO_UDP or CC_IP_PROTO_TCP
   1.283 + *
   1.284 + * @note : Needed only if using WiFi. If not using Wifi please provide a stub
   1.285 + */
   1.286 +void platAddCallControlClassifiers(unsigned long myIPAddr, unsigned short myPort,
   1.287 +	unsigned long cucm1IPAddr, unsigned short cucm1Port,
   1.288 +	unsigned long cucm2IPAddr, unsigned short cucm2Port,
   1.289 +	unsigned long cucm3IPAddr, unsigned short cucm3Port,
   1.290 +	unsigned char  protocol);
   1.291 +
   1.292 +/**
   1.293 + * Remove cc control classifier.
   1.294 + *
   1.295 + * Undo platAddCallControlClassifiers
   1.296 + */
   1.297 +void platRemoveCallControlClassifiers();
   1.298 +
   1.299 +/**
   1.300 + * Tell whether wifi is supported and active
   1.301 + *
   1.302 + * @return boolean wether WLAN is active or not
   1.303 + */
   1.304 +cc_boolean	platWlanISActive();
   1.305 +
   1.306 +/**
   1.307 + * Check if the netowrk interface changed.
   1.308 + *
   1.309 + * @return boolean returns TRUE if the network interface has changed
   1.310 + *
   1.311 + * @note Most common case is for softphone clients where if a PC is
   1.312 + * undocked the network interface changes from wired to wireless.
   1.313 + */
   1.314 +boolean	platIsNetworkInterfaceChanged();
   1.315 +
   1.316 +/**
   1.317 + * Get active phone load name
   1.318 + *
   1.319 + * Returns the phone images in the active and inactive partitions
   1.320 + * The phone reports these phone loads to CUCM for display on the Admin page
   1.321 + *
   1.322 + * @param[in] image_a : Populate the image name from partition a
   1.323 + * @param[in] image_b : Populate the image name from partition b
   1.324 + * @param[in] len : Length of the pointers for image_a and image_b
   1.325 + * @return 1 - image_a is active
   1.326 + *         2 - image_b is active
   1.327 + *        -1 - Failure
   1.328 + */
   1.329 +int platGetActiveInactivePhoneLoadName(char * image_a, char * image_b, int len);
   1.330 +
   1.331 +/**
   1.332 + * Get localized phrase for the specified index
   1.333 + *
   1.334 + * @param[in] index  the phrase index, see
   1.335 + * @param[in] phrase the return phrase holder
   1.336 + * @param[in] len the input length to cap the maximum value
   1.337 + *
   1.338 + * @return SUCCESS or FAILURE
   1.339 + */
   1.340 +int platGetPhraseText(int index, char* phrase, unsigned int len);
   1.341 +
   1.342 +/**
   1.343 + * Set the unregistration reason
   1.344 + *
   1.345 + * @param[in] reason see the unregister reason definitions.
   1.346 + *
   1.347 + * @note we expect the platform to save this value in Non Volatile memory
   1.348 + * This will be retrieved later by using platGetUnregReason. This reason is reported to CUCM
   1.349 + */
   1.350 +void platSetUnregReason(int reason);
   1.351 +
   1.352 +
   1.353 +/**
   1.354 + * Get the unregistration reason code.
   1.355 + *
   1.356 + * @return reason code for unregistration
   1.357 + */
   1.358 +int platGetUnregReason();
   1.359 +
   1.360 +/**
   1.361 + * Sets the time based on Date header in 200 OK from REGISTER request
   1.362 + * @param void
   1.363 + * @return void
   1.364 + */
   1.365 +void platSetCucmRegTime (void);
   1.366 +
   1.367 +/**
   1.368 + * Set the kpml value for application.
   1.369 + *
   1.370 + * @param kpml_config the kpml value
   1.371 + */
   1.372 +void platSetKPMLConfig(cc_kpml_config_t kpml_config);
   1.373 +
   1.374 +/**
   1.375 + * Check if a line has active MWI status
   1.376 + *
   1.377 + * @param line
   1.378 + *
   1.379 + * @return boolean
   1.380 + *
   1.381 + * @note The stack doesn't store the MWI status and expects
   1.382 + * the application to store that information. The stack
   1.383 + * queries the mwi status from the application using this method.
   1.384 + */
   1.385 +boolean platGetMWIStatus(cc_lineid_t line);
   1.386 +
   1.387 +/**
   1.388 + * Check if the speaker or headset is enabled.
   1.389 + *
   1.390 + * @return boolean if the speaker or headset is enabled, returns true.
   1.391 + */
   1.392 +boolean platGetSpeakerHeadsetMode();
   1.393 +
   1.394 +/**
   1.395 + * Secure Socket API's.
   1.396 + * The pSIPCC expects the following Secure Socket APIs to be implemented in the
   1.397 + * vendor porting layer.
   1.398 + */
   1.399 +
   1.400 +/**
   1.401 + * platSecIsServerSecure
   1.402 + *
   1.403 + * @brief Lookup the secure status of the server
   1.404 + *
   1.405 + * This function looks at the the CCM server type by using the security library
   1.406 + * and returns appropriate indication to the pSIPCC.
   1.407 + *
   1.408 + *
   1.409 + * @return   Server is security enabled or not
   1.410 + *           PLAT_SOCK_SECURE or PLAT_SOCK_NONSECURE
   1.411 + *
   1.412 + * @note This API maps to the following HandyIron API:
   1.413 + *  int secIsServerSecure(SecServerType type) where type should be SRVR_TYPE_CCM
   1.414 + */
   1.415 +plat_soc_status_e platSecIsServerSecure(void);
   1.416 +
   1.417 +
   1.418 +/**
   1.419 + * platSecSocConnect
   1.420 + * @brief  Securely connect to a remote server
   1.421 + *
   1.422 + * This function uses the security library APIs to connect to a remote server.
   1.423 + * @param[in]  host         server addr
   1.424 + * @param[in]  port         port number
   1.425 + * @param[in]  ipMode       IP mode to indicate v6, v4 or both
   1.426 + * @param[in]  mode         blocking connect or not
   1.427 + *                          FALSE: non-blocking; TRUE: blocking
   1.428 + * @param[in]  tos          TOS value
   1.429 + * @param[in]  connectionMode The mode of the connection
   1.430 + *                            (Authenticated/Encrypted)
   1.431 + * @param[out] localPort    local port used for the connection
   1.432 + *
   1.433 + * @return     client socket descriptor
   1.434 + *             >=0: connected or in progress
   1.435 + *             INVALID SOCKET: failed
   1.436 + *
   1.437 + * @pre        (hostAndPort not_eq NULL)
   1.438 + * @pre        (localPort   not_eq NULL)
   1.439 + *
   1.440 + * @note localPort is undefined when the return value is INVALID_SOCKET
   1.441 + *
   1.442 + * @note This API maps to the HandyIron APIs as follows:
   1.443 + * If mode == TRUE (blocking):
   1.444 + *    int secEstablishSecureConnection(const char* serverAddr, *uint32_t port, secConnectionType type)
   1.445 + *    @li ipMode is UNUSED
   1.446 + *    @li "host" maps to "serverAddr", "type" should be determined by an application and use the value from SecServerType.
   1.447 + *    @li localPort is passed in as 0
   1.448 + * If mode == FALSE (non-blocking):
   1.449 + *     int secConnect(const char* serverAddr, uint32_t port, *secConnectionType type, uint32_t localPort)
   1.450 + *    @li ipMode is UNUSED
   1.451 + *    @li "host" maps to "serverAddr", "type" should be determined by an application and use the value from SecServerType.
   1.452 + *
   1.453 + * @note The implementation should use the "setsockopt" to set the "tos" value passed
   1.454 + * in this API on the created socket.
   1.455 + *
   1.456 + */
   1.457 +cpr_socket_t
   1.458 +platSecSocConnect (char *host,
   1.459 +                  int     port,
   1.460 +                  int     ipMode,
   1.461 +                  boolean mode,
   1.462 +                  unsigned int tos,
   1.463 +                  plat_soc_connect_mode_e connectionMode,
   1.464 +                  cc_uint16_t *localPort);
   1.465 +
   1.466 +/**
   1.467 + * platSecSockIsConnected
   1.468 + * Determine the status of a secure connection that was initiated
   1.469 + * in non-blocking mode
   1.470 + *
   1.471 + * @param[in]    sock   socket descriptor
   1.472 + *
   1.473 + * @return   connection status
   1.474 + *           @li connection complete: PLAT_SOCK_CONN_OK
   1.475 + *           @li connection waiting:  PLAT_SOCK_CONN_WAITING
   1.476 + *           @li connection failed:   PLAT_SOCK_CONN_FAILED
   1.477 + *
   1.478 + * @note This API maps to the following HandyIron API:
   1.479 + * int secIsConnectionReady (int connDesc)
   1.480 + * The "sock" is the connection descriptor.
   1.481 + */
   1.482 +plat_soc_connect_status_e platSecSockIsConnected (cpr_socket_t sock);
   1.483 +
   1.484 +/**
   1.485 + * platGenerateCryptoRand
   1.486 + * @brief Generates a Random Number
   1.487 + *
   1.488 + * Generate crypto graphically random number for a desired length.
   1.489 + * The function is expected to be much slower than the cpr_rand().
   1.490 + * This function should be used when good random number is needed
   1.491 + * such as random number that to be used for SRTP key for an example.
   1.492 + *
   1.493 + * @param[in] buf  - pointer to the buffer to store the result of random
   1.494 + *                   bytes requested.
   1.495 + * @param[in] len  - pointer to the length of the desired random bytes.
   1.496 + *             When calling the function, the integer's value
   1.497 + *             should be set to the desired number of random
   1.498 + *             bytes ('buf' should be of at least this size).
   1.499 + *             upon success, its value will be set to the
   1.500 + *             actual number of random bytes being returned.
   1.501 + *             (realistically, there is a maximum number of
   1.502 + *             random bytes that can be returned at a time.
   1.503 + *             if the caller request more than that, the
   1.504 + *             'len' will indicate how many bytes are actually being
   1.505 + *             returned) on failure, its value will be set to 0.
   1.506 + *
   1.507 + * @return
   1.508 + *     1 - success.
   1.509 + *     0 - fail.
   1.510 + *
   1.511 + * @note The intent of this function is to generate a cryptographically strong
   1.512 + * random number. Vendors can map this to HandyIron or OpenSSL random number
   1.513 + * generation functions.
   1.514 + *
   1.515 + * @note This API maps to the following HandyIron API:
   1.516 + * int secGetRandomData(uint8_t *buf, uint32_t size). Also note that a
   1.517 + * "secAddEntropy(...)" may be required the first time to feed entropy data to
   1.518 + * the random number generator.
   1.519 + */
   1.520 +int platGenerateCryptoRand(cc_uint8_t *buf, int *len);
   1.521 +
   1.522 +/**
   1.523 + * platSecSocSend
   1.524 + *
   1.525 + * @brief The platSecSocSend() function is used to send data over a secure
   1.526 + * socket.
   1.527 + *
   1.528 + * The platSecSocSend() function shall transmit a message from the specified socket to
   1.529 + * its peer. The platSecSocSend() function shall send a message only when the socket is
   1.530 + * connected. The length of the message to be sent is specified by the length
   1.531 + * argument. If the message is too long to pass through the underlying protocol,
   1.532 + * platSecSocSend() shall fail and no data is transmitted.  Delivery of the message is
   1.533 + * not guaranteed.
   1.534 + *
   1.535 + * @param[in] soc  Specifies the socket created with cprSocket() to send
   1.536 + * @param[in] buf  A pointer to the buffer of the message to send.
   1.537 + * @param[in] len  Specifies the length in bytes of the message pointed to by the buffer argument.
   1.538 + *
   1.539 + * @return Upon successful completion, platSecSocSend() shall return the number of
   1.540 + *     bytes sent. Otherwise, SOCKET_ERROR shall be returned and cpr_errno set to
   1.541 + *     indicate the error.
   1.542 + *
   1.543 + * @note The possible error values this function should return are
   1.544 + *        @li [CPR_EBADF]  The socket argument is not a valid file descriptor
   1.545 + *        @li [CPR_ENOTSOCK]  socket does not refer to a socket descriptor
   1.546 + *        @li [CPR_EAGAIN]    The socket is marked non-blocking and no data can
   1.547 + *                          be sent
   1.548 + *        @li [CPR_EWOULDBLOCK]   Same as CPR_EAGAIN
   1.549 + *        @li [CPR_ENOTCONN]  A connection-mode socket that is not connected
   1.550 + *        @li [CPR_ENOTSUPP]  The specified flags are not supported for this
   1.551 + *                            type of socket or protocol.
   1.552 + *        @li [CPR_EMSGSIZE]  The message is too large to be sent all at once
   1.553 + *        @li [CPR_EDESTADDRREQ]  The socket has no peer address set
   1.554 + *
   1.555 + */
   1.556 +ssize_t
   1.557 +platSecSocSend (cpr_socket_t soc,
   1.558 +         CONST void *buf,
   1.559 +         size_t len);
   1.560 +
   1.561 +/**
   1.562 + * platSecSocRecv
   1.563 + *
   1.564 + * @brief The platSecSocRecv() function shall receive a message from a secure socket.
   1.565 + *
   1.566 + * This function is normally used with connected sockets because it does not permit
   1.567 + * the application to retrieve the source address of received data.  The
   1.568 + * platSecSocRecv() function shall return the length of the message written to
   1.569 + * the buffer pointed to by the "buf" argument.
   1.570 + *
   1.571 + * @param[in] soc  - Specifies the socket to receive data
   1.572 + * @param[out] buf  - Contains the data received
   1.573 + * @param[out] len  - The length of the data received
   1.574 + *
   1.575 + * @return On success the length of the message in bytes (including zero).
   1.576 + *         On failure SOCKET_ERROR shall be returned and cpr_errno set to
   1.577 + *         indicate the error.
   1.578 + *
   1.579 + * @note The possible error values this function should return are
   1.580 + *        @li [CPR_EBADF]  The socket argument is not a valid file descriptor
   1.581 + *        @li [CPR_ENOTSOCK]  The descriptor references a file, not a socket.
   1.582 + *        @li [CPR_EAGAIN]    The socket is marked non-blocking and no data is
   1.583 + *                        waiting to be received.
   1.584 + *        @li [CPR_EWOULDBLOCK]   Same as CPR_EAGAIN
   1.585 + *        @li [CPR_ENOTCONN]  A receive attempt is made on a connection-mode socket that is not connected
   1.586 + *        @li [CPR_ENOTSUPP]  The specified flags are not supported for this type of socket or protocol
   1.587 + *
   1.588 + */
   1.589 +ssize_t
   1.590 +platSecSocRecv (cpr_socket_t soc,
   1.591 +         void * RESTRICT buf,
   1.592 +         size_t len);
   1.593 +
   1.594 +/**
   1.595 + * platSecSocClose
   1.596 + *
   1.597 + * @brief The platSecSocClose function shall close a secure socket
   1.598 + *
   1.599 + * The platSecSocClose() function shall destroy the socket descriptor indicated
   1.600 + * by socket.
   1.601 + *
   1.602 + * @param[in] soc  - The socket that needs to be destroyed
   1.603 + *
   1.604 + * @return CPR_SUCCESS on success otherwise, CPR_FAILURE. cpr_errno needs to be set in this case.
   1.605 + *
   1.606 + * @note The possible error values this function should return are
   1.607 + *         @li [CPR_EBADF]      socket is not a valid socket descriptor.
   1.608 + */
   1.609 +cpr_status_e
   1.610 +platSecSocClose (cpr_socket_t soc);
   1.611 +
   1.612 +/**
   1.613 + * Sets the SIS protocol version
   1.614 + *
   1.615 + * @param a - major version
   1.616 + * @param b - minor version
   1.617 + * @param c - additional version information
   1.618 + * @param name - version name
   1.619 + *
   1.620 + * @return void
   1.621 + * @note the platform should store this information and provide it when asked via the platGetSISProtocolVer()
   1.622 + */
   1.623 +
   1.624 +void platSetSISProtocolVer(cc_uint32_t a, cc_uint32_t b, cc_uint32_t c, char* name);
   1.625 +
   1.626 +/**
   1.627 + * Provides the SIS protocol version
   1.628 + *
   1.629 + * @param *a pointer to fill in the major version
   1.630 + * @param *b pointer to fill in the minor version
   1.631 + * @param *c pointer to fill in the additonal version
   1.632 + * @param *name pointer to fill in the version name
   1.633 + *
   1.634 + * @return void
   1.635 + */
   1.636 +void
   1.637 +platGetSISProtocolVer (cc_uint32_t *a, cc_uint32_t *b, cc_uint32_t *c, char* name);
   1.638 +
   1.639 +/**
   1.640 + * Provides the local IP address
   1.641 + *
   1.642 + * @return char *  returns the local IP address
   1.643 + */
   1.644 +char *platGetIPAddr();
   1.645 +
   1.646 +/**
   1.647 + * Provides the local MAC address
   1.648 + *
   1.649 + * @param *maddr the pointer to the string holding MAC address
   1.650 + *             in the MAC address format after converting from string format.
   1.651 + * @return void
   1.652 + */
   1.653 +void platGetMacAddr(char *addr);
   1.654 +
   1.655 +
   1.656 +/**
   1.657 + *  platGetFeatureAllowed
   1.658 + *
   1.659 + *      Get whether the feature is allowed
   1.660 + *
   1.661 + *  @param featureId - sis feature id
   1.662 + *
   1.663 + *  @return  1 - allowed, 0 - not allowed
   1.664 + *
   1.665 + */
   1.666 +int platGetFeatureAllowed(cc_sis_feature_id_e featureId);
   1.667 +
   1.668 +
   1.669 +/**
   1.670 + * Set the Status message for failure reasons
   1.671 + * @param char *msg
   1.672 + * @return void
   1.673 + */
   1.674 +void platSetStatusMessage(char *msg);
   1.675 +
   1.676 +/**
   1.677 + * The equivalent of the printf function.
   1.678 + *
   1.679 + * This function MUST be implemented by the vendors. This is called by the core
   1.680 + * library whenever some debugging information needs to be printed out.
   1.681 + * call this function in order to clear the CPR Memory/Tracking statistics
   1.682 + *
   1.683 + * Please also be aware that cpr_stdio.h has other logging functions as well.
   1.684 + * Vendors need to implement this function and the functions (err_msg,
   1.685 + * buginf....etc) found in cpr_stdio.h
   1.686 + *
   1.687 + * @param[in] _format  format string
   1.688 + * @param[in] ...     variable arg list
   1.689 + *
   1.690 + * @return  Return code from printf
   1.691 + */
   1.692 +int debugif_printf(const char *_format, ...);
   1.693 +
   1.694 +/**
   1.695 + * Enable / disable speaker
   1.696 + *
   1.697 + * @param[in] state - true -> enable speaker, false -> disable speaker
   1.698 + *
   1.699 + * @return void
   1.700 + */
   1.701 +
   1.702 +void platSetSpeakerMode(cc_boolean state);
   1.703 +
   1.704 +/**
   1.705 + * Get the status (on/off) of the audio device
   1.706 + *
   1.707 + * @param[in]  device_type - headset or speaker (see vcm_audio_device_t)
   1.708 + *
   1.709 + * @return 1 -> On, 0 -> off, ERROR -> unknown (error)
   1.710 + */
   1.711 +
   1.712 +int platGetAudioDeviceStatus(plat_audio_device_t device_type);
   1.713 +
   1.714 +/*
   1.715 + * Returns the default gateway
   1.716 + *
   1.717 + * @param void
   1.718 + * @return u_long
   1.719 + */
   1.720 +cc_ulong_t platGetDefaultgw();
   1.721 +
   1.722 +
   1.723 +#endif /* _PLATFORM_API_H_ */

mercurial