media/webrtc/signaling/src/sipcc/plat/darwin/plat_api_stub.c

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
-rwxr-xr-x

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.

     1 /* This Source Code Form is subject to the terms of the Mozilla Public
     2  * License, v. 2.0. If a copy of the MPL was not distributed with this
     3  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     5 #include <string.h>
     7 #include "cpr_types.h"
     8 #include "cc_constants.h"
     9 #include "cpr_socket.h"
    10 #include "plat_api.h"
    12 /**
    13  * Initialize the platform threa.
    14  * @todo add more explanation here.
    15  */
    16 int platThreadInit(char * tname)
    17 {
    18     return 0;
    19 }
    21 /**
    22  * The initial initialization function for any platform related
    23  * modules
    24  *
    25  *
    26  * @return 0 - SUCCESS
    27  *        -1 - FAILURE
    28  */
    29 int platInit()
    30 {
    31     return 0;
    32 }
    34 /**
    35  * The initial initialization function for the debugging/logging
    36  * modules
    37  *
    38  *
    39  * @return 0 - SUCCESS
    40  *        -1 - FAILURE
    41  */
    42 void debugInit()
    43 {
    44     return ;
    45 }
    47 /**
    48  * Add cc control classifier
    49  */
    50 void platAddCallControlClassifiers(unsigned long myIPAddr, unsigned short myPort,
    51 	unsigned long cucm1IPAddr, unsigned short cucm1Port,
    52 	unsigned long cucm2IPAddr, unsigned short cucm2Port,
    53 	unsigned long cucm3IPAddr, unsigned short cucm3Port,
    54 	unsigned char  protocol)
    55 {
    56     return;
    57 }
    59 /**
    60  * Set ip address mode
    61  * e.g.
    62  *
    63  */
    64 cpr_ip_mode_e platGetIpAddressMode()
    65 {
    66     return CPR_IP_MODE_IPV4;
    67 }
    69 /**
    70  * Remove cc control classifier.
    71  */
    72 void platRemoveCallControlClassifiers()
    73 {
    74     return;
    75 }
    77 /**
    78  * Tell whether wifi is supported and active
    79  */
    80 cc_boolean	platWlanISActive()
    81 {
    82     return FALSE;
    83 }
    85 /**
    86  * Check if the netowrk interface changed.
    87  */
    88 boolean	platIsNetworkInterfaceChanged()// (NOOP)
    89 {
    90     return TRUE;
    91 }
    93 /**
    94  * Set active phone load name
    95  * @return FAILURE or true length. "-1" means no active load found.
    96  *
    97  */
    98 int platGetActiveInactivePhoneLoadName(char * image_a, char * image_b, int len)
    99 {
   100     memset(image_a, 0, len);
   101     memset(image_b, 0, len);
   103     return 0;
   104 }
   106 /**
   107  * Get or Set user defined phrases
   108  * @param index  the phrase index, see
   109  * @param phrase the return phrase holder
   110  * @param len the input length to cap the maximum value
   111  * @return SUCCESS or FAILURE
   112  */
   113 int platGetPhraseText(int index, char* phrase, unsigned int len)
   114 {
   115     return 0;
   116 }
   118 /**
   119  * Set the unregistration reason
   120  * @param reason see the unregister reason definitions.
   121  * @return void
   122  */
   123 void platSetUnregReason(int reason)
   124 {
   125     return;
   126 }
   128 /**
   129  * Get the unregistration reason code.
   130  * @return reason code for unregistration, see the definition.
   131  */
   132 int platGetUnregReason()
   133 {
   134     return 0;
   135 }
   137 /**
   138  * Set the kpml value for application.
   139  * @param kpml_config the kpml value
   140  * @return void
   141  */
   142 void platSetKPMLConfig(cc_kpml_config_t kpml_config)
   143 {
   144     return ;
   145 }
   147 /**
   148  * Check if a line has active MWI status
   149  * @param line
   150  * @return boolean
   151  */
   152 boolean platGetMWIStatus(cc_lineid_t line)
   153 {
   154     return TRUE;
   155 }
   158 /**
   159  * Secure Socket API's.
   160  * The pSIPCC expects the following Secure Socket APIs to be implemented in the
   161  * vendor porting layer.
   162  */
   164 /**
   165  * platSecIsServerSecure
   166  *
   167  * @brief Lookup the secure status of the server
   168  *
   169  * This function looks at the the CCM server type by using the security library
   170  * and returns appropriate indication to the pSIPCC.
   171  *
   172  *
   173  * @return   Server is security enabled or not
   174  *           PLAT_SOCK_SECURE or PLAT_SOCK_NONSECURE
   175  *
   176  * @note This API maps to the following HandyIron API:
   177  *  int secIsServerSecure(SecServerType type) where type should be SRVR_TYPE_CCM
   178  */
   179 plat_soc_status_e platSecIsServerSecure(void)
   180 {
   181     return PLAT_SOCK_NONSECURE;
   182 }
   185 /**
   186  * platSecSocConnect
   187  * @brief  Securely connect to a remote server
   188  *
   189  * This function uses the security library APIs to connect to a remote server.
   190  * @param[in]  host         server addr
   191  * @param[in]  port         port number
   192  * @param[in]  ipMode       IP mode to indicate v6, v4 or both
   193  * @param[in]  mode         blocking connect or not
   194  *                          FALSE: non-blocking; TRUE: blocking
   195  * @param[in]  tos          TOS value
   196  * @param[in]  connectionType Are we talking to Call-Agent
   197  * @param[in]  connectionMode The mode of the connection
   198  *                            (Authenticated/Encrypted)
   199  * @param[out] localPort    local port used for the connection
   200  *
   201  * @return     client socket descriptor
   202  *             >=0: connected or in progress
   203  *             INVALID SOCKET: failed
   204  *
   205  * @pre        (hostAndPort not_eq NULL)
   206  * @pre        (localPort   not_eq NULL)
   207  *
   208  * @note localPort is undefined when the return value is INVALID_SOCKET
   209  *
   210  * @note This API maps to the HandyIron APIs as follows:
   211  * If mode == TRUE (blocking):
   212  *    int secEstablishSecureConnection(const char* serverAddr, *uint32_t port, secConnectionType type)
   213  *    @li ipMode is UNUSED
   214  *    @li "host" maps to "serverAddr", "connectionType" maps to "type"
   215  *    @li localPort is passed in as 0
   216  * If mode == FALSE (non-blocking):
   217  *     int secConnect(const char* serverAddr, uint32_t port, *secConnectionType type, uint32_t localPort)
   218  *    @li ipMode is UNUSED
   219  *    @li "host" maps to "serverAddr", "connectionType" maps to "type"
   220  *
   221  * @note The implementation should use the "setsockopt" to set the "tos" value passed
   222  * in this API on the created socket.
   223  *
   224  */
   225 cpr_socket_t
   226 platSecSocConnect (char *host,
   227                   int     port,
   228                   int     ipMode,
   229                   boolean mode,
   230                   unsigned int tos,
   231                   plat_soc_connect_mode_e connectionMode,
   232                   uint16_t *localPort)
   233 {
   234     return 0;
   235 }
   237 /**
   238  * platSecSockIsConnected
   239  * Determine the status of a secure connection that was initiated
   240  * in non-blocking mode
   241  *
   242  * @param[in]    sock   socket descriptor
   243  *
   244  * @return   connection status
   245  *           @li connection complete: PLAT_SOCK_CONN_OK
   246  *           @li connection waiting:  PLAT_SOCK_CONN_WAITING
   247  *           @li connection failed:   PLAT_SOCK_CONN_FAILED
   248  *
   249  * @note This API maps to the following HandyIron API:
   250  * int secIsConnectionReady (int connDesc)
   251  * The "sock" is the connection descriptor.
   252  */
   253 plat_soc_connect_status_e platSecSockIsConnected (cpr_socket_t sock)
   254 {
   255     return PLAT_SOCK_CONN_OK;
   256 }
   258 /**
   259  * platSecSocSend
   260  *
   261  * @brief The platSecSocSend() function is used to send data over a secure
   262  * socket.
   263  *
   264  * The platSecSocSend() function shall transmit a message from the specified socket to
   265  * its peer. The platSecSocSend() function shall send a message only when the socket is
   266  * connected. The length of the message to be sent is specified by the length
   267  * argument. If the message is too long to pass through the underlying protocol,
   268  * platSecSocSend() shall fail and no data is transmitted.  Delivery of the message is
   269  * not guaranteed.
   270  *
   271  * @param[in] soc  Specifies the socket created with cprSocket() to send
   272  * @param[in] buf  A pointer to the buffer of the message to send.
   273  * @param[in] len  Specifies the length in bytes of the message pointed to by the buffer argument.
   274  *
   275  * @return Upon successful completion, platSecSocSend() shall return the number of
   276  *     bytes sent. Otherwise, SOCKET_ERROR shall be returned and cpr_errno set to
   277  *     indicate the error.
   278  *
   279  * @note The possible error values this function should return are
   280  *        @li [CPR_EBADF]  The socket argument is not a valid file descriptor
   281  *        @li [CPR_ENOTSOCK]  socket does not refer to a socket descriptor
   282  *        @li [CPR_EAGAIN]    The socket is marked non-blocking and no data can
   283  *                          be sent
   284  *        @li [CPR_EWOULDBLOCK]   Same as CPR_EAGAIN
   285  *        @li [CPR_ENOTCONN]  A connection-mode socket that is not connected
   286  *        @li [CPR_ENOTSUPP]  The specified flags are not supported for this
   287  *                            type of socket or protocol.
   288  *        @li [CPR_EMSGSIZE]  The message is too large to be sent all at once
   289  *        @li [CPR_EDESTADDRREQ]  The socket has no peer address set
   290  *
   291  */
   292 ssize_t
   293 platSecSocSend (cpr_socket_t soc,
   294          CONST void *buf,
   295          size_t len)
   296 {
   297     return 0;
   298 }
   300 /**
   301  * platSecSocRecv
   302  *
   303  * @brief The platSecSocRecv() function shall receive a message from a secure socket.
   304  *
   305  * This function is normally used with connected sockets because it does not permit
   306  * the application to retrieve the source address of received data.  The
   307  * platSecSocRecv() function shall return the length of the message written to
   308  * the buffer pointed to by the "buf" argument.
   309  *
   310  * @param[in] soc  - Specifies the socket to receive data
   311  * @param[out] buf  - Contains the data received
   312  * @param[out] len  - The length of the data received
   313  *
   314  * @return On success the length of the message in bytes (including zero).
   315  *         On failure SOCKET_ERROR shall be returned and cpr_errno set to
   316  *         indicate the error.
   317  *
   318  * @note The possible error values this function should return are
   319  *        @li [CPR_EBADF]  The socket argument is not a valid file descriptor
   320  *        @li [CPR_ENOTSOCK]  The descriptor references a file, not a socket.
   321  *        @li [CPR_EAGAIN]    The socket is marked non-blocking and no data is
   322  *                        waiting to be received.
   323  *        @li [CPR_EWOULDBLOCK]   Same as CPR_EAGAIN
   324  *        @li [CPR_ENOTCONN]  A receive attempt is made on a connection-mode socket that is not connected
   325  *        @li [CPR_ENOTSUPP]  The specified flags are not supported for this type of socket or protocol
   326  *
   327  */
   328 ssize_t
   329 platSecSocRecv (cpr_socket_t soc,
   330          void * RESTRICT buf,
   331          size_t len)
   332 {
   333     return 0;
   334 }
   336 /**
   337  * platSecSocClose
   338  *
   339  * @brief The platSecSocClose function shall close a secure socket
   340  *
   341  * The platSecSocClose() function shall destroy the socket descriptor indicated
   342  * by socket.
   343  *
   344  * @param[in] soc  - The socket that needs to be destroyed
   345  *
   346  * @return CPR_SUCCESS on success otherwise, CPR_FAILURE. cpr_errno needs to be set in this case.
   347  *
   348  * @note The possible error values this function should return are
   349  *         @li [CPR_EBADF]      socket is not a valid socket descriptor.
   350  */
   351 cpr_status_e
   352 platSecSocClose (cpr_socket_t soc)
   353 {
   354     return CPR_SUCCESS;
   355 }
   357 /**
   358  * Sets the SIS protocol version
   359  *
   360  * @param a - major version
   361  * @param b - minor version
   362  * @param c - additional version information
   363  *
   364  * @return void
   365  * @note the platform should store this information and provide it when asked via the platGetSISProtocolVer()
   366  */
   367 void platSetSISProtocolVer(uint32_t a, uint32_t b, uint32_t c, char* name)
   368 {
   369     return;
   370 }
   372 /**
   373  * Provides the SIS protocol version
   374  *
   375  * @param *a pointer to fill in the major version
   376  * @param *b pointer to fill in the minor version
   377  * @param *c pointer to fill in the additonal version
   378  *
   379  * @return void
   380  */
   381 void
   382 platGetSISProtocolVer (uint32_t *a, uint32_t *b, uint32_t *c, char* name)
   383 {
   384     return;
   385 }
   388 void debug_bind_keyword(const char *cmd, int32_t *flag_ptr)
   389 {
   390     return;
   391 }
   393 void debugif_add_keyword(const char *x, const char *y)
   394 {
   395     return;
   396 }
   398 void platSetSpeakerMode(cc_boolean state)
   399 {
   400     return;
   401 }
   403 boolean platGetSpeakerHeadsetMode()
   404 {
   405     return TRUE;
   406 }
   408 /**
   409  *  platGetFeatureAllowed
   410  *
   411  *      Get whether the feature is allowed
   412  *
   413  *  @param featureId - sis feature id
   414  *
   415  *  @return  1 - allowed, 0 - not allowed
   416  *
   417  */
   418 int platGetFeatureAllowed(cc_sis_feature_id_e featureId)
   419 {
   420     return TRUE;
   421 }
   424 int platGetAudioDeviceStatus(plat_audio_device_t device_type)
   425 {
   426     return 0;
   427 }
   430 /*
   431  * Returns the default gateway
   432  *
   433  * @param void
   434  * @return u_long
   435  */
   436 cc_ulong_t platGetDefaultgw(){
   437 	return 0;
   438 }
   440 /**
   441  * Sets the time based on Date header in 200 OK from REGISTER request
   442  * @param void
   443  * @return void
   444  */
   445 void platSetCucmRegTime (void) {
   446     //Noop
   447 }

mercurial