1 /* 2 * libZRTP SDK library, implements the ZRTP secure VoIP protocol. 3 * Copyright (c) 2006-2009 Philip R. Zimmermann. All rights reserved. 4 * Contact: http://philzimmermann.com 5 * For licensing and other legal details, see the file zrtp_legal.c. 6 * 7 * Viktor Krykun <v.krikun at zfoneproject.com> 8 */ 9 10 11 12 /** 13 * \file zrtp_iface.h 14 * \brief libzrtp product-dependent functions 15 */ 16 17 #ifndef __ZRTP_IFACE_H__ 18 #define __ZRTP_IFACE_H__ 19 20 #include "zrtp_config.h" 21 #include "zrtp_base.h" 22 #include "zrtp_string.h" 23 #include "zrtp_error.h" 24 #include "zrtp_iface_system.h" 25 26 27 #if defined(__cplusplus) 28 extern "C" 29 { 30 #endif 31 32 /*======================================================================*/ 33 /* libzrtp interface: Cache */ 34 /*======================================================================*/ 35 36 /*! 37 * \defgroup zrtp_iface_cache ZRTP Cache 38 * \ingroup zrtp_iface 39 * 40 * The secret cache implementation should have a two-layer structure: each pair of ZIDs should have 41 * a relevant pair of secrets (current and previous). In addition to the value of the secret, the 42 * cache should contain: verification flag, last usage time-stamp and cache TTL value. 43 * 44 * The simplest secret cache scheme implementation is: 45 * \code 46 * [local_ZID][remote_ZID][curr_cache][prev_cache][verified][used at][cache ttl] 47 * \endcode 48 * \warning 49 * Libzrtp doen't provide synchronization for cache read/write operation. Cache is not thread safe 50 * by default. Implementor must take care of synchronization inside his implementation. 51 * 52 * For more information see corresponding section \ref XXX. Samples can be found at \ref XXX 53 * (\c zrtp_iface_builtin.h, \c zrtp_iface_cache.c) 54 * \{ 55 */ 56 57 /** 58 * @brief Data types and functions related to shared secrets. 59 */ 60 typedef struct zrtp_callback_cache_t 61 { 62 /** 63 * \brief Cache initialization. 64 * 65 * libzrtp calls this function before start using cache routine at zrtp_init(). 66 * 67 * \param zrtp - libzrtp global context; 68 * \sa zrtp_callback_cache_t#on_down() 69 */ 70 zrtp_status_t (*on_init)(zrtp_global_t* zrtp); 71 72 /** 73 * \brief Cache deinitialization. 74 * 75 * libzrtp calls this function when zrtp cache is no longer needed at zrtp_down(). 76 * \sa zrtp_callback_cache_t#on_init() 77 */ 78 void (*on_down)(); 79 80 /** 81 * \brief Add/Update cache value 82 * 83 * Interface function for entering the retained secret to the cache. This function should 84 * guarantee permanent storage in the cache. The implementation algorithm is the following: 85 * - if the entry associated with a given pair of ZIDs does not exist, the value should be 86 * stored in cache. 87 * - if the entry already exists, the current secret value becomes stored as the previous one. 88 * The new value becomes stored as the current one. Besides rss->value a timestamp 89 * (rss->lastused_at) and cache TTL(rss->ttl) should be updated. 90 * 91 * \param one_zid - ZID of one side; 92 * \param another_zid - ZID of the other side; 93 * \param rss - a structure storing the value of the secret that needs to be saved. 94 * \return 95 * - zrtp_status_ok if operation is successful; 96 * - some error code from \ref zrtp_status_t in case of error. 97 * \sa zrtp_callback_cache_t#on_get 98 */ 99 zrtp_status_t (*on_put)( const zrtp_stringn_t* one_zid, 100 const zrtp_stringn_t* another_zid, 101 zrtp_shared_secret_t *rss); 102 103 /** 104 * \brief Return secret cache associated with specified pair of ZIDs. 105 * 106 * This function should return the secret associated with the specified pair of ZIDs. In 107 * addition to the secret value, TTL (rss->ttl) and cache timestamp (rss->lastused_at) value 108 * should be also returned. 109 * 110 * \param one_zid - one side's ZID; 111 * \param another_zid - the other side's ZID; 112 * \param prev_requested - if this parameter value is 1, the function should return the previous 113 * secret's value. If this parameter value is 0, the function should return the current 114 * secret's value; 115 * \param rss - structure that needs to be filled in. 116 * \return 117 * - zrtp_status_ok - if operation is successful; 118 * - zrtp_status_fail - if the secret cannot be found; 119 * - some error code from zrtp_status_t if an error occurred. 120 * \sa zrtp_callback_cache_t#on_put 121 */ 122 zrtp_status_t (*on_get)( const zrtp_stringn_t* one_zid, 123 const zrtp_stringn_t* another_zid, 124 zrtp_shared_secret_t *rss, 125 int prev_requested); 126 127 /** 128 * \brief Set/clear cache verification flag 129 * 130 * This function should set the secret verification flag associated with a pair of ZIDs. 131 * \warning 132 * For internal use only. To change the verification flag from the user space use the 133 * zrtp_verified_set() function. 134 * 135 * \param one_zid - first ZID for cache identification; 136 * \param another_zid - second ZID for cache identification; 137 * \param verified - verification flag (value can be 0 or 1). 138 * \return 139 * - zrtp_status_ok if flag is successfully modified; 140 * - zrtp_status_fail if the secret cannot be found; 141 * - some other error code from \ref zrtp_status_t if another error occurred. 142 */ 143 zrtp_status_t (*on_set_verified)( const zrtp_stringn_t* one_zid, 144 const zrtp_stringn_t* another_zid, 145 uint32_t verified); 146 147 /** 148 * \brief Return cache verification flag 149 * 150 * This function return the secret verification flag associated with a pair of ZIDs. 151 * 152 * \param one_zid - first ZID for cache identification; 153 * \param another_zid - second ZID for cache identification; 154 * \param verified - verification flag to be filled in 155 * \return 156 * - zrtp_status_ok if flag is successfully returned; 157 * - zrtp_status_fail if the secret cannot be found; 158 * - some other error code from \ref zrtp_status_t if another error occurred. 159 */ 160 zrtp_status_t (*on_get_verified)( const zrtp_stringn_t* one_zid, 161 const zrtp_stringn_t* another_zid, 162 uint32_t* verified); 163 164 /** 165 * \brief Should set Secure Since cache aparemeter to current date and time 166 * 167 * This function is optional and may be ommited. 168 * 169 * \param one_zid - first ZID for cache identification; 170 * \param another_zid - second ZID for cache identification; 171 * \return 172 * - zrtp_status_ok if the oprtation finished sucessfully. 173 * - some other error code from \ref zrtp_status_t if another error occurred. 174 */ 175 zrtp_status_t (*on_reset_since)( const zrtp_stringn_t* one_zid, 176 const zrtp_stringn_t* another_zid); 177 178 /** 179 * \brief Add/Update cache value for MiTM endpoint 180 * 181 * This function is analogy to zrtp_callback_cache_t#on_put but for MiTM endpoint. 182 * \todo Add more detail description 183 * \sa zrtp_callback_cache_t#on_put zrtp_callback_cache_t#on_get_mitm 184 */ 185 zrtp_status_t (*on_put_mitm)( const zrtp_stringn_t* one_zid, 186 const zrtp_stringn_t* another_zid, 187 zrtp_shared_secret_t *rss); 188 189 /** 190 * \brief Return secret cache for MiTM endpoint 191 * 192 * This function is analogy to zrtp_callback_cache_t#on_get but for MiTM endpoint. 193 * \todo Add more detail description 194 * \sa zrtp_callback_cache_t#on_get zrtp_callback_cache_t#on_put_mitm 195 */ 196 zrtp_status_t (*on_get_mitm)( const zrtp_stringn_t* one_zid, 197 const zrtp_stringn_t* another_zid, 198 zrtp_shared_secret_t *rss); 199 200 /** 201 * \brief Return Preshared calls counter 202 * 203 * This function should return the preshared calls counter associated with a pair of ZIDs. 204 * 205 * \param one_zid - first ZID for cache identification; 206 * \param another_zid - second ZID for cache identification; 207 * \param counter - preshared calls counter to be filled in 208 * \return 209 * - zrtp_status_ok if counter is successfully returned; 210 * - zrtp_status_fail if the secret cannot be found; 211 * - some other error code from \ref zrtp_status_t if another error occurred. 212 */ 213 zrtp_status_t (*on_presh_counter_get)( const zrtp_stringn_t* one_zid, 214 const zrtp_stringn_t* another_zid, 215 uint32_t* counter); 216 217 /** 218 * \brief Increase/reset Preshared streams counter made between two endpoints (ZIDs) 219 * 220 * This function should set the preshared calls counter associated with a pair of ZIDs. 221 * Function is optional and should be implemented if your prodict uses Preshared keys exchange. 222 * 223 * \param one_zid - first ZID for; 224 * \param another_zid - second ZID; 225 * \param counter - Preshared calls counter. 226 * \return 227 * - zrtp_status_ok if the counter is successfully modified; 228 * - zrtp_status_fail if the secret cannot be found; 229 * - some other error code from \ref zrtp_status_t if another error occurred. 230 */ 231 zrtp_status_t (*on_presh_counter_set)( const zrtp_stringn_t* one_zid, 232 const zrtp_stringn_t* another_zid, 233 uint32_t counter); 234 } zrtp_callback_cache_t; 235 236 237 /** \} */ 238 239 /*======================================================================*/ 240 /* libzrtp interface: Scheduler */ 241 /*======================================================================*/ 242 243 /** 244 * \defgroup zrtp_iface_scheduler ZRTP Delay Calls 245 * \ingroup zrtp_iface 246 * 247 * Algorithm used in the scheduled call module is described in detail in section \ref XXX of the 248 * developer's guide documentation. Technical details of this function's implementation follows. 249 * 250 * For more information see corresponding section \ref XXX. Samples can be found at \ref XXX 251 * (\c zrtp_iface_builtin.h, \c zrtp_iface_scheduler.c) 252 * \{ 253 */ 254 255 /** \brief ZRTP Delays Calls signature. */ 256 typedef void (*zrtp_call_callback_t)(zrtp_stream_t*, zrtp_retry_task_t*); 257 258 /** 259 * @brief Delay Call wrapper 260 */ 261 struct zrtp_retry_task_t 262 { 263 /** \brief Task action callback */ 264 zrtp_call_callback_t callback; 265 266 /** \brief Timeout before call in milliseconds */ 267 zrtp_time_t timeout; 268 269 /** 270 * \brief User data pointer. 271 * 272 * Pointer to the user data. This pointer can be used for fast access to some additional data 273 * attached to this task by the user application. 274 */ 275 void* usr_data; 276 277 278 // TODO: hide these elements 279 /** 280 * \brief Task activity flag. 281 * 282 * Libzrtp unsets this flag on task canceling. It prevents the scheduler engine from re-adding 283 * an already canceled task. Callback handlers skip passive tasks. 284 * \note 285 * For internal use only. Don't' modify this field in implementation. 286 */ 287 uint8_t _is_enabled; 288 289 /** 290 * \brief Number of task retries. 291 * 292 * Every handler that attempts the task increases it by one. When the limit is reached the 293 * scheduler should stop retries and performs a specified action - generally raises an error. 294 * \note 295 * For internal use only. Don't' modify this field in implementation. 296 */ 297 uint32_t _retrys; 298 299 /** 300 * \brief Task Busy flag. 301 * 302 * Built-in cache implementation uses this flag to protect task from being removed during the 303 * callback. 304 * 305 * Default cache implementation "locks" this flag before call zrtp_retry_task#callback 306 * and "unlocks" when the call is performed. zrtp_callback_scheduler_t#on_wait_call_later exits 307 * when there are no callbacks in progress - no tasks with \c _is_busy enabled. 308 */ 309 uint8_t _is_busy; 310 }; 311 312 /** 313 * @brief Delay Calls callbacks 314 */ 315 typedef struct zrtp_callback_scheduler_t 316 { 317 /** 318 * \brief Delay Calls initialization. 319 * 320 * libzrtp calls this function before start using scheduler routine at zrtp_init(). 321 * 322 * \param zrtp - libzrtp global context; 323 * \sa zrtp_callback_scheduler_t#on_down() 324 */ 325 zrtp_status_t (*on_init)(zrtp_global_t* zrtp); 326 327 /** 328 * \brief Delay Calls deinitialization. 329 * 330 * libzrtp calls this function when zrtp scheduler is no longer needed at zrtp_down(). 331 * \sa zrtp_callback_scheduler_t#on_init() 332 */ 333 void (*on_down)(); 334 335 /** 336 * \brief Interface for performing delay call 337 * 338 * This function should add delay call request (\c task) to the processing queue. When the 339 * zrtp_retry_task_t#timeout is expired, scheduler should call zrtp_retry_task_t#callback and 340 * remove tasks from the processing queue. 341 * 342 * \param stream - stream context for processing the callback function; 343 * \param task - task structure that should be processed. 344 * \sa zrtp_callback_scheduler_t#on_cancel_call_later 345 */ 346 void (*on_call_later)(zrtp_stream_t *stream, zrtp_retry_task_t* task); 347 348 /** 349 * \brief Interface for canceling a delay calls 350 * 351 * This function cancels delay call if it still in the processing queue. The algorithm is the 352 * following: 353 * - If there is a specified task for a specified stream, this task should be deleted. 354 * - If the \c task parameter is equal to NULL - ALL tasks for the specified stream must be 355 * terminated and removed from the queue. 356 * 357 * \param ctx - stream context for the operation; 358 * \param task - delayed call wrapper structure. 359 * \sa zrtp_callback_scheduler_t#on_call_later 360 */ 361 void (*on_cancel_call_later)(zrtp_stream_t* ctx, zrtp_retry_task_t* task); 362 363 /** 364 * \brief Interface for waiting for scheduling tasks is finished 365 * 366 * This function is called by libzrtp when the state-mamchine is in a position to destroy ZRTP 367 * session and all incapsulated streams. Allocated for the stream memory may be cleared and 368 * released. If after this operation, scheduler perform time-out call it will bring system to 369 * crash. 370 * 371 * The scheduler implementation must guarantee that any delay call for the \c stream will not be 372 * performed after on_wait_call_later(). 373 * 374 * \param stream - stream context for the operation; 375 * \sa zrtp_callback_scheduler_t#on_call_later. 376 */ 377 void (*on_wait_call_later)(zrtp_stream_t* stream); 378 } zrtp_callback_scheduler_t; 379 380 /** \} */ 381 382 /*======================================================================*/ 383 /* libzrtp interface: Protocol */ 384 /*======================================================================*/ 385 386 /** 387 * \defgroup zrtp_iface_proto ZRTP Protocol Feedback 388 * \ingroup zrtp_iface 389 * 390 * This section defines ZRTP protcol events. Detail description of ZRTP state-machine is defined in 391 * \ref XXX. 392 * \{ 393 */ 394 395 /** 396 * \brief ZRTP Protocol events 397 * 398 * For additional information see \ref XXX 399 */ 400 typedef enum zrtp_protocol_event_t 401 { 402 /** \brief Just a stub for error detection. */ 403 ZRTP_EVENT_UNSUPPORTED = 0, 404 405 /** \brief Switching to CLEAR state */ 406 ZRTP_EVENT_IS_CLEAR, 407 408 /** \brief Switching to INITIATING_SECURE state */ 409 ZRTP_EVENT_IS_INITIATINGSECURE, 410 411 /** \brief Switching to PENDING_SECURE state */ 412 ZRTP_EVENT_IS_PENDINGSECURE, 413 414 /** \brief Switching to PENDING_CLEAR state */ 415 ZRTP_EVENT_IS_PENDINGCLEAR, 416 417 /** 418 * \brief Switching to NO_ZRTP state. 419 * 420 * Hello packet undelivered - no ZRTP endpoint and other end 421 */ 422 ZRTP_EVENT_NO_ZRTP, 423 424 /** 425 * \brief First N Hello packet undelivered - probably, no ZRTP endpoint and other end 426 * 427 * Libzrtp raises this event after few Hello have been send without receiving response from the 428 * remote endpoint. User application may use this event to stop Securing ritual if connection 429 * lag is important. 430 * 431 * Developer should take into account that delays in Hello receiving may be conditioned by 432 * interruptions in media channel 433 * 434 * \warning Don't handle this event unless necessary 435 */ 436 ZRTP_EVENT_NO_ZRTP_QUICK, 437 438 /** 439 * \brief MiTM Enrollment with MiTM endpoint 440 * 441 * Informs the Client-side endpoint of receiving a registration invitation from the MiTM. 442 * Libzrtp raises this event after switching to the Secure state (ZRTP_EVENT_IS_SECURE). The 443 * user may accept the invitation using a zrtp_register_with_trusted_mitm() call. 444 */ 445 ZRTP_EVENT_IS_CLIENT_ENROLLMENT, 446 447 /** 448 * \brief New user has registered to the MitM 449 * 450 * Informs MitM of the registration of a new user. Libzrtp raises this event when a user calls 451 * the special registration number and has switched to the secure state. 452 */ 453 ZRTP_EVENT_NEW_USER_ENROLLED, 454 455 /** 456 * \brief New user has already registered with the MiTM 457 * 458 * Notifies the MiTM of an attempt to register from a user that is already registered. In this 459 * case a new MiTM secret will not be generated and the user may be informed by voice prompt. 460 * Libzrtp raises this event from the SECURE state. 461 */ 462 ZRTP_EVENT_USER_ALREADY_ENROLLED, 463 464 /** 465 * \brief User has cancelled registration 466 * 467 * Libzrtp may raise this event during regular calls when it discovers that the user has removed 468 * its MiTM secret. This event informs the MiTM that the SAS can no longer be transferred to 469 * this user. 470 */ 471 ZRTP_EVENT_USER_UNENROLLED, 472 473 /** 474 * \brief SAS value and/or rendering scheme was updated 475 * 476 * LibZRTP raises this event when the SAS value is transferred from the trusted MiTM. The value 477 * is rendered automatically according to the rendering scheme specified by the trusted MiTM. 478 * (it may be different than that of the previous one). 479 * 480 * On receiving this event, the Client application should replace the old SAS with the new one 481 * and ask the user to verify it. This event is called from the Secure state only. 482 */ 483 ZRTP_EVENT_LOCAL_SAS_UPDATED, 484 485 /** 486 * \brief SAS transfer was accepted by the remote side 487 * 488 * Libzrtp raises this event to inform the Server-side about accepting the change of SAS value 489 * and/or rendering scheme by the remote client. This event is called from the Secure state 490 * only. 491 */ 492 ZRTP_EVENT_REMOTE_SAS_UPDATED, 493 494 /** 495 * \brief Swishing to SECURE state 496 * 497 * Duplicates zrtp_callback_event_t#on_zrtp_secure for more thin adjustments. 498 */ 499 ZRTP_EVENT_IS_SECURE, 500 501 /** 502 * \brief Swishing to SECURE state is finished. 503 * 504 * Equal to ZRTP_EVENT_IS_SECURE but called when the Securing process is completely finished: 505 * new RS secret is generate, cache flags updated and etc. Can be used in extended application 506 * for more thin adjustments. 507 */ 508 ZRTP_EVENT_IS_SECURE_DONE, 509 510 /** 511 * \brief Indicates DRM restriction. Stream can't go Secure. 512 * 513 * Libzrtp generate this event if DRM rules don't allow to switch to Secure mode: 514 * - A passive endpoint never sends a Commit message. Semi-active endpoint does not send a 515 * Commit to a passive endpoint 516 * - A passive phone, if acting as a SIP initiator r ejects all commit packets from everyone. 517 * - A passive phone rejects all commit messages from a PBX. 518 */ 519 ZRTP_EVENT_IS_PASSIVE_RESTRICTION, 520 521 ZRTP_EVENT_COUNT 522 523 } zrtp_protocol_event_t; 524 525 /** 526 * \brief ZRTP Protocol Errors and Warnings 527 * 528 * For additional information see \ref XXX 529 */ 530 typedef enum zrtp_security_event_t 531 { 532 /** 533 * \brief Switching to ERROR state 534 * 535 * The exact error code can be found at zrtp_stream_info_t#last_error. Use zrtp_log_error2str() 536 * to get error description in text mode. 537 */ 538 ZRTP_EVENT_PROTOCOL_ERROR = ZRTP_EVENT_COUNT, 539 540 /** 541 * \brief Hello Hash is different from that received in signaling. 542 * 543 * In accordance with sec. 8.1 of the ZRTP RFC, libzrtp provides the ability to prevent DOS 544 * attacks. libzrtp can detect an attack in which the hash of the remote Hello was received 545 * through signaling and added to the ZRTP context (zrtp_signaling_hash_set()). 546 * 547 * When the hash of the incoming Hello doesn't match the hash from signaling, the 548 * ZRTP_EVENT_WRONG_SIGNALING_HASH event is raised and the connection MAY be terminated 549 * manually. 550 */ 551 ZRTP_EVENT_WRONG_SIGNALING_HASH, 552 553 /** 554 * \brief Hmac of the received packet is different from the hmac value earlier received. 555 * 556 * If the Hello hash is sent through protected signaling, libzrtp provides the ability to 557 * prevent protocol packets from modification and even eliminates comparing the SAS. To do this, 558 * libzrtp compares the message Hmac with the Hmac received in the previous message. 559 * 560 * If the Hmacs don't match, the ZRTP_EVENT_WRONG_MESSAGE_HMAC event is raised and the 561 * connection MAY be terminated manually. 562 */ 563 ZRTP_EVENT_WRONG_MESSAGE_HMAC, 564 565 /** 566 * \brief Retain secret was found in the cache but it doesn't match with the remote one 567 * 568 * The library rises this event when non-expired secret have been found in the cache but 569 * value of the secret doesn't match with the remote side secret. Such situation may happen 570 * in case of MiTM attack or when remote side lost it's cache. 571 * 572 * Recommended behavior: the application should notify user about the situation and ask him to 573 * verify the SAS. If SAS is different - it indicates the attack. 574 */ 575 ZRTP_EVENT_MITM_WARNING 576 } zrtp_security_event_t; 577 578 /** 579 * \brief Callbacks definitions 580 * 581 * This section lists callback functions informing the user about the protocol status. These 582 * callbacks must be defined in the user application. 583 */ 584 typedef struct zrtp_callback_event_t 585 { 586 /** 587 * \brief ZRTP Protocol events notification. 588 * 589 * Informs about switching between the protocol states and other events. Provides more flexible 590 * control over the protocol then on_zrtp_secure and on_zrtp_not_secure. 591 * 592 * \param event - type of event; 593 * \param stream - ZRTP stream context. 594 */ 595 void (*on_zrtp_protocol_event)(zrtp_stream_t *stream, zrtp_protocol_event_t event); 596 597 /** 598 * \brief ZRTP Security events notification 599 * 600 * Informs about ZRTP security events: MiTM attacks, cache desynchronization and 601 * others. 602 * \warning MUST be handled in the target application to provide high security level. 603 * 604 * \param event - type of event; 605 * \param stream - ZRTP stream context. 606 */ 607 void (*on_zrtp_security_event)(zrtp_stream_t *stream, zrtp_security_event_t event); 608 609 /** 610 * \brief Indicates switching to SECURE state. 611 * 612 * Pair of events: \c on_zrtp_secure and \c on_zrtp_not_secure represent simplified event 613 * handling mechanism comparing to \c on_zrtp_protocol_event. libzrtp calls this event when the 614 * call is SECURE and media is encrypted. 615 * 616 * SAS Verification is required on this event. 617 * 618 * \param stream - ZRTP stream context. 619 */ 620 void (*on_zrtp_secure)(zrtp_stream_t *stream); 621 622 /** 623 * \brief Indicates switching to NOT SECURE state. 624 * 625 * This event duplicates some protocol and security events to simplify libzrtp usage. It may be 626 * used in applications which don't require detail information about ZRTP protocol. 627 * 628 * If Error appeared - the exact error code can be found at zrtp_stream_info_t#last_error. Use 629 * zrtp_log_error2str() to get error description in text mode. 630 * 631 * \param stream - ZRTP stream context. 632 */ 633 void (*on_zrtp_not_secure)(zrtp_stream_t *stream); 634 } zrtp_callback_event_t; 635 636 /** \} */ 637 638 /*======================================================================*/ 639 /* libzrtp interface: Misc */ 640 /*======================================================================*/ 641 642 /** 643 * \defgroup zrtp_iface_misc Miscellaneous functions 644 * \ingroup zrtp_iface 645 * \{ 646 */ 647 648 /** 649 * \brief Miscellaneous Functions 650 */ 651 typedef struct zrtp_callback_misc_t 652 { 653 /** 654 * \brief RTP packet sending function 655 * 656 * This function pushes an outgoing ZRTP packet to the network. Correct building of IP and UPD 657 * headers is the developer's responsibility. 658 * 659 * \param stream - ZRTP stream context; 660 * \param packet - buffer storing the ZRTP packet to send; 661 * \param length - size of the ZRTP packet. 662 * \return 663 * - number of bytes sent if successful; 664 * - -1 if error occurred. 665 */ 666 int (*on_send_packet)(const zrtp_stream_t* stream, char* packet, unsigned int length); 667 } zrtp_callback_misc_t; 668 669 /** \} */ 670 671 /** 672 * \brief ZRTP feedback interface and application dependent routine 673 * \ingroup zrtp_iface 674 */ 675 typedef struct zrtp_callback_t 676 { 677 /** \brief ZRTP Protocol Feedback */ 678 zrtp_callback_event_t event_cb; 679 /** \brief ZRTP Delay Calls routine */ 680 zrtp_callback_scheduler_t sched_cb; 681 /** \brief ZRTP Cache */ 682 zrtp_callback_cache_t cache_cb; 683 /** \brief Miscellaneous functions */ 684 zrtp_callback_misc_t misc_cb; 685 } zrtp_callback_t; 686 687 688 #if defined(__cplusplus) 689 } 690 #endif 691 692 #endif /*__ZRTP_IFACE_H__*/ 693