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