This graph shows which files directly or indirectly include this file:
Go to the source code of this file.
Data Structures | |
| struct | switch_rtp_crypto_key |
Defines | |
| #define | SWITCH_RTP_MAX_BUF_LEN 16384 |
| #define | SWITCH_RTCP_MAX_BUF_LEN 16384 |
| #define | SWITCH_RTP_MAX_CRYPTO_LEN 64 |
| #define | SWITCH_RTP_KEY_LEN 30 |
| #define | SWITCH_RTP_CRYPTO_KEY_32 "AES_CM_128_HMAC_SHA1_32" |
| #define | SWITCH_RTP_CRYPTO_KEY_80 "AES_CM_128_HMAC_SHA1_80" |
Typedefs | |
| typedef switch_rtp_crypto_key | switch_rtp_crypto_key_t |
| typedef void(*) | switch_rtp_invalid_handler_t (switch_rtp_t *rtp_session, switch_socket_t *sock, void *data, switch_size_t datalen, switch_sockaddr_t *from_addr) |
Enumerations | |
| enum | switch_rtp_crypto_direction_t { SWITCH_RTP_CRYPTO_SEND, SWITCH_RTP_CRYPTO_RECV, SWITCH_RTP_CRYPTO_MAX } |
| enum | switch_rtp_crypto_key_type_t { NO_CRYPTO, AES_CM_128_HMAC_SHA1_80, AES_CM_128_HMAC_SHA1_32, AES_CM_128_NULL_AUTH } |
Functions | |
| switch_status_t | switch_rtp_add_crypto_key (switch_rtp_t *rtp_session, switch_rtp_crypto_direction_t direction, uint32_t index, switch_rtp_crypto_key_type_t type, unsigned char *key, switch_size_t keylen) |
| void | switch_rtp_get_random (void *buf, uint32_t len) |
| void | switch_rtp_init (switch_memory_pool_t *pool) |
| Initilize the RTP System. | |
| void | switch_rtp_shutdown (void) |
| switch_port_t | switch_rtp_set_start_port (switch_port_t port) |
| Set/Get RTP start port. | |
| switch_status_t | switch_rtp_set_ssrc (switch_rtp_t *rtp_session, uint32_t ssrc) |
| switch_port_t | switch_rtp_set_end_port (switch_port_t port) |
| Set/Get RTP end port. | |
| switch_port_t | switch_rtp_request_port (const char *ip) |
| Request a new port to be used for media. | |
| void | switch_rtp_release_port (const char *ip, switch_port_t port) |
| switch_status_t | switch_rtp_set_interval (switch_rtp_t *rtp_session, uint32_t ms_per_packet, uint32_t samples_per_interval) |
| switch_status_t | switch_rtp_change_interval (switch_rtp_t *rtp_session, uint32_t ms_per_packet, uint32_t samples_per_interval) |
| switch_status_t | switch_rtp_create (switch_rtp_t **new_rtp_session, switch_payload_t payload, uint32_t samples_per_interval, uint32_t ms_per_packet, switch_rtp_flag_t flags, char *timer_name, const char **err, switch_memory_pool_t *pool) |
| create a new RTP session handle | |
| switch_rtp_t * | switch_rtp_new (const char *rx_host, switch_port_t rx_port, const char *tx_host, switch_port_t tx_port, switch_payload_t payload, uint32_t samples_per_interval, uint32_t ms_per_packet, switch_rtp_flag_t flags, char *timer_name, const char **err, switch_memory_pool_t *pool) |
| prepare a new RTP session handle and fully initilize it | |
| switch_status_t | switch_rtp_set_remote_address (switch_rtp_t *rtp_session, const char *host, switch_port_t port, switch_port_t remote_rtcp_port, switch_bool_t change_adv_addr, const char **err) |
| Assign a remote address to the RTP session. | |
| char * | switch_rtp_get_remote_host (switch_rtp_t *rtp_session) |
| switch_port_t | switch_rtp_get_remote_port (switch_rtp_t *rtp_session) |
| void | switch_rtp_reset_media_timer (switch_rtp_t *rtp_session) |
| void | switch_rtp_set_max_missed_packets (switch_rtp_t *rtp_session, uint32_t max) |
| switch_status_t | switch_rtp_udptl_mode (switch_rtp_t *rtp_session) |
| switch_status_t | switch_rtp_set_local_address (switch_rtp_t *rtp_session, const char *host, switch_port_t port, const char **err) |
| Assign a local address to the RTP session. | |
| void | switch_rtp_kill_socket (switch_rtp_t *rtp_session) |
| Kill the socket on an existing RTP session. | |
| void | switch_rtp_break (switch_rtp_t *rtp_session) |
| void | switch_rtp_flush (switch_rtp_t *rtp_session) |
| uint8_t | switch_rtp_ready (switch_rtp_t *rtp_session) |
| Test if an RTP session is ready. | |
| void | switch_rtp_destroy (switch_rtp_t **rtp_session) |
| Destroy an RTP session. | |
| switch_status_t | switch_rtp_activate_ice (switch_rtp_t *rtp_session, char *login, char *rlogin) |
| Acvite ICE on an RTP session. | |
| switch_status_t | switch_rtp_activate_rtcp (switch_rtp_t *rtp_session, int send_rate, switch_port_t remote_port) |
| Activate sending RTCP Sender Reports (SR's). | |
| switch_status_t | switch_rtp_activate_jitter_buffer (switch_rtp_t *rtp_session, uint32_t queue_frames, uint32_t max_queue_frames, uint32_t samples_per_packet, uint32_t samples_per_second, uint32_t max_drift) |
| Acvite a jitter buffer on an RTP session. | |
| switch_status_t | switch_rtp_debug_jitter_buffer (switch_rtp_t *rtp_session, const char *name) |
| switch_status_t | switch_rtp_deactivate_jitter_buffer (switch_rtp_t *rtp_session) |
| switch_status_t | switch_rtp_pause_jitter_buffer (switch_rtp_t *rtp_session, switch_bool_t pause) |
| void | switch_rtp_set_flag (switch_rtp_t *rtp_session, switch_rtp_flag_t flags) |
| Set an RTP Flag. | |
| uint32_t | switch_rtp_test_flag (switch_rtp_t *rtp_session, switch_rtp_flag_t flags) |
| Test an RTP Flag. | |
| void | switch_rtp_clear_flag (switch_rtp_t *rtp_session, switch_rtp_flag_t flags) |
| Clear an RTP Flag. | |
| switch_socket_t * | switch_rtp_get_rtp_socket (switch_rtp_t *rtp_session) |
| Retrieve the socket from an existing RTP session. | |
| uint32_t | switch_rtp_get_default_samples_per_interval (switch_rtp_t *rtp_session) |
| Get the default samples per interval for a given RTP session. | |
| void | switch_rtp_set_default_payload (switch_rtp_t *rtp_session, switch_payload_t payload) |
| Set the default payload number for a given RTP session. | |
| uint32_t | switch_rtp_get_default_payload (switch_rtp_t *rtp_session) |
| Get the default payload number for a given RTP session. | |
| void | switch_rtp_set_invald_handler (switch_rtp_t *rtp_session, switch_rtp_invalid_handler_t on_invalid) |
| Set a callback function to execute when an invalid RTP packet is encountered. | |
| switch_status_t | switch_rtp_read (switch_rtp_t *rtp_session, void *data, uint32_t *datalen, switch_payload_t *payload_type, switch_frame_flag_t *flags, switch_io_flag_t io_flags) |
| Read data from a given RTP session. | |
| switch_status_t | switch_rtp_queue_rfc2833 (switch_rtp_t *rtp_session, const switch_dtmf_t *dtmf) |
| Queue RFC2833 DTMF data into an RTP Session. | |
| switch_status_t | switch_rtp_queue_rfc2833_in (switch_rtp_t *rtp_session, const switch_dtmf_t *dtmf) |
| Queue RFC2833 DTMF data into an RTP Session. | |
| switch_size_t | switch_rtp_has_dtmf (switch_rtp_t *rtp_session) |
| Test for presence of DTMF on a given RTP session. | |
| switch_size_t | switch_rtp_dequeue_dtmf (switch_rtp_t *rtp_session, switch_dtmf_t *dtmf) |
| Retrieve DTMF digits from a given RTP session. | |
| switch_status_t | switch_rtp_zerocopy_read (switch_rtp_t *rtp_session, void **data, uint32_t *datalen, switch_payload_t *payload_type, switch_frame_flag_t *flags, switch_io_flag_t io_flags) |
| Read data from a given RTP session without copying. | |
| switch_status_t | switch_rtp_zerocopy_read_frame (switch_rtp_t *rtp_session, switch_frame_t *frame, switch_io_flag_t io_flags) |
| Read data from a given RTP session without copying. | |
| switch_status_t | switch_rtcp_zerocopy_read_frame (switch_rtp_t *rtp_session, switch_rtcp_frame_t *frame) |
| Read RTCP data from a given RTP session without copying. | |
| void | rtp_flush_read_buffer (switch_rtp_t *rtp_session, switch_rtp_flush_t flush) |
| switch_status_t | switch_rtp_enable_vad (switch_rtp_t *rtp_session, switch_core_session_t *session, switch_codec_t *codec, switch_vad_flag_t flags) |
| Enable VAD on an RTP Session. | |
| switch_status_t | switch_rtp_disable_vad (switch_rtp_t *rtp_session) |
| Disable VAD on an RTP Session. | |
| int | switch_rtp_write_frame (switch_rtp_t *rtp_session, switch_frame_t *frame) |
| Write data to a given RTP session. | |
| int | switch_rtp_write_manual (switch_rtp_t *rtp_session, void *data, uint32_t datalen, uint8_t m, switch_payload_t payload, uint32_t ts, switch_frame_flag_t *flags) |
| Write data with a specified payload and sequence number to a given RTP session. | |
| uint32_t | switch_rtp_get_ssrc (switch_rtp_t *rtp_session) |
| Retrieve the SSRC from a given RTP session. | |
| void | switch_rtp_set_private (switch_rtp_t *rtp_session, void *private_data) |
| Associate an arbitrary data pointer with and RTP session. | |
| void | switch_rtp_set_telephony_event (switch_rtp_t *rtp_session, switch_payload_t te) |
| Set the payload type to consider RFC2833 DTMF. | |
| void | switch_rtp_set_telephony_recv_event (switch_rtp_t *rtp_session, switch_payload_t te) |
| void | switch_rtp_set_recv_pt (switch_rtp_t *rtp_session, switch_payload_t pt) |
| void | switch_rtp_set_cng_pt (switch_rtp_t *rtp_session, switch_payload_t pt) |
| Set the payload type for comfort noise. | |
| void * | switch_rtp_get_private (switch_rtp_t *rtp_session) |
| Retrieve the private data from a given RTP session. | |
| switch_status_t | switch_rtp_activate_stun_ping (switch_rtp_t *rtp_session, const char *stun_ip, switch_port_t stun_port, uint32_t packet_count, switch_bool_t funny) |
| void | switch_rtp_intentional_bugs (switch_rtp_t *rtp_session, switch_rtp_bug_flag_t bugs) |
| switch_rtp_stats_t * | switch_rtp_get_stats (switch_rtp_t *rtp_session, switch_memory_pool_t *pool) |
| switch_byte_t | switch_rtp_check_auto_adj (switch_rtp_t *rtp_session) |
| void | switch_rtp_set_interdigit_delay (switch_rtp_t *rtp_session, uint32_t delay) |
Definition in file switch_rtp.h.
| #define SWITCH_RTCP_MAX_BUF_LEN 16384 |
Definition at line 44 of file switch_rtp.h.
| #define SWITCH_RTP_CRYPTO_KEY_32 "AES_CM_128_HMAC_SHA1_32" |
Definition at line 47 of file switch_rtp.h.
| #define SWITCH_RTP_CRYPTO_KEY_80 "AES_CM_128_HMAC_SHA1_80" |
Definition at line 48 of file switch_rtp.h.
| #define SWITCH_RTP_KEY_LEN 30 |
Definition at line 46 of file switch_rtp.h.
| #define SWITCH_RTP_MAX_BUF_LEN 16384 |
Definition at line 43 of file switch_rtp.h.
Referenced by switch_rtp_create(), and switch_rtp_write_manual().
| #define SWITCH_RTP_MAX_CRYPTO_LEN 64 |
| typedef struct switch_rtp_crypto_key switch_rtp_crypto_key_t |
Definition at line 69 of file switch_rtp.h.
Definition at line 49 of file switch_rtp.h.
00049 { 00050 SWITCH_RTP_CRYPTO_SEND, 00051 SWITCH_RTP_CRYPTO_RECV, 00052 SWITCH_RTP_CRYPTO_MAX 00053 } switch_rtp_crypto_direction_t;
Definition at line 55 of file switch_rtp.h.
00055 { 00056 NO_CRYPTO, 00057 AES_CM_128_HMAC_SHA1_80, 00058 AES_CM_128_HMAC_SHA1_32, 00059 AES_CM_128_NULL_AUTH 00060 } switch_rtp_crypto_key_type_t;
| switch_status_t switch_rtp_add_crypto_key | ( | switch_rtp_t * | rtp_session, | |
| switch_rtp_crypto_direction_t | direction, | |||
| uint32_t | index, | |||
| switch_rtp_crypto_key_type_t | type, | |||
| unsigned char * | key, | |||
| switch_size_t | keylen | |||
| ) |
Definition at line 1406 of file switch_rtp.c.
References AES_CM_128_HMAC_SHA1_32, AES_CM_128_HMAC_SHA1_80, AES_CM_128_NULL_AUTH, SWITCH_CALL_DIRECTION_OUTBOUND, switch_channel_direction(), switch_channel_get_uuid(), switch_channel_get_variable, SWITCH_CHANNEL_SESSION_LOG, switch_channel_set_variable, switch_core_alloc, switch_core_memory_pool_get_data(), switch_core_session_get_channel(), switch_event_add_header(), switch_event_add_header_string(), SWITCH_EVENT_CALL_SECURE, switch_event_create, switch_event_fire, SWITCH_LOG_CRIT, SWITCH_LOG_ERROR, SWITCH_LOG_INFO, switch_log_printf(), SWITCH_RTP_CRYPTO_MAX, SWITCH_RTP_CRYPTO_RECV, SWITCH_RTP_CRYPTO_SEND, SWITCH_RTP_FLAG_ENABLE_RTCP, SWITCH_RTP_FLAG_SECURE_RECV, SWITCH_RTP_FLAG_SECURE_RECV_RESET, SWITCH_RTP_FLAG_SECURE_SEND, SWITCH_RTP_FLAG_SECURE_SEND_RESET, SWITCH_RTP_MAX_CRYPTO_LEN, switch_set_flag, SWITCH_STACK_BOTTOM, SWITCH_STATUS_FALSE, SWITCH_STATUS_SUCCESS, and switch_test_flag.
01409 { 01410 #ifndef ENABLE_SRTP 01411 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_CRIT, "SRTP NOT SUPPORTED IN THIS BUILD!\n"); 01412 return SWITCH_STATUS_FALSE; 01413 #else 01414 switch_rtp_crypto_key_t *crypto_key; 01415 srtp_policy_t *policy; 01416 err_status_t stat; 01417 switch_status_t status = SWITCH_STATUS_SUCCESS; 01418 switch_core_session_t *session = switch_core_memory_pool_get_data(rtp_session->pool, "__session"); 01419 switch_channel_t *channel = switch_core_session_get_channel(session); 01420 switch_event_t *fsevent = NULL; 01421 01422 if (direction >= SWITCH_RTP_CRYPTO_MAX || keylen > SWITCH_RTP_MAX_CRYPTO_LEN) { 01423 return SWITCH_STATUS_FALSE; 01424 } 01425 01426 crypto_key = switch_core_alloc(rtp_session->pool, sizeof(*crypto_key)); 01427 01428 if (direction == SWITCH_RTP_CRYPTO_RECV) { 01429 policy = &rtp_session->recv_policy; 01430 } else { 01431 policy = &rtp_session->send_policy; 01432 } 01433 01434 crypto_key->type = type; 01435 crypto_key->index = index; 01436 memcpy(crypto_key->key, key, keylen); 01437 crypto_key->next = rtp_session->crypto_keys[direction]; 01438 rtp_session->crypto_keys[direction] = crypto_key; 01439 01440 memset(policy, 0, sizeof(*policy)); 01441 01442 switch (crypto_key->type) { 01443 case AES_CM_128_HMAC_SHA1_80: 01444 crypto_policy_set_aes_cm_128_hmac_sha1_80(&policy->rtp); 01445 if (switch_channel_direction(channel) == SWITCH_CALL_DIRECTION_OUTBOUND) { 01446 switch_channel_set_variable(channel, "sip_has_crypto", "AES_CM_128_HMAC_SHA1_80"); 01447 } 01448 break; 01449 case AES_CM_128_HMAC_SHA1_32: 01450 crypto_policy_set_aes_cm_128_hmac_sha1_32(&policy->rtp); 01451 if (switch_channel_direction(channel) == SWITCH_CALL_DIRECTION_OUTBOUND) { 01452 switch_channel_set_variable(channel, "sip_has_crypto", "AES_CM_128_HMAC_SHA1_32"); 01453 } 01454 break; 01455 case AES_CM_128_NULL_AUTH: 01456 crypto_policy_set_aes_cm_128_null_auth(&policy->rtp); 01457 if (switch_channel_direction(channel) == SWITCH_CALL_DIRECTION_OUTBOUND) { 01458 switch_channel_set_variable(channel, "sip_has_crypto", "AES_CM_128_NULL_AUTH"); 01459 } 01460 break; 01461 default: 01462 break; 01463 } 01464 01465 policy->next = NULL; 01466 policy->key = (uint8_t *) crypto_key->key; 01467 01468 if (switch_test_flag(rtp_session, SWITCH_RTP_FLAG_ENABLE_RTCP)) { 01469 crypto_policy_set_rtcp_default(&policy->rtcp); 01470 policy->rtcp.sec_serv = sec_serv_none; 01471 } 01472 01473 policy->rtp.sec_serv = sec_serv_conf_and_auth; 01474 switch (direction) { 01475 case SWITCH_RTP_CRYPTO_RECV: 01476 policy->ssrc.type = ssrc_any_inbound; 01477 01478 if (switch_test_flag(rtp_session, SWITCH_RTP_FLAG_SECURE_RECV)) { 01479 switch_set_flag(rtp_session, SWITCH_RTP_FLAG_SECURE_RECV_RESET); 01480 } else { 01481 if ((stat = srtp_create(&rtp_session->recv_ctx, policy))) { 01482 status = SWITCH_STATUS_FALSE; 01483 } 01484 01485 if (status == SWITCH_STATUS_SUCCESS) { 01486 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "Activating Secure RTP RECV\n"); 01487 switch_set_flag(rtp_session, SWITCH_RTP_FLAG_SECURE_RECV); 01488 } else { 01489 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Error allocating srtp [%d]\n", stat); 01490 return status; 01491 } 01492 } 01493 break; 01494 case SWITCH_RTP_CRYPTO_SEND: 01495 policy->ssrc.type = ssrc_specific; 01496 policy->ssrc.value = rtp_session->ssrc; 01497 01498 if (switch_test_flag(rtp_session, SWITCH_RTP_FLAG_SECURE_SEND)) { 01499 switch_set_flag(rtp_session, SWITCH_RTP_FLAG_SECURE_SEND_RESET); 01500 } else { 01501 if ((stat = srtp_create(&rtp_session->send_ctx, policy))) { 01502 status = SWITCH_STATUS_FALSE; 01503 } 01504 01505 if (status == SWITCH_STATUS_SUCCESS) { 01506 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "Activating Secure RTP SEND\n"); 01507 switch_set_flag(rtp_session, SWITCH_RTP_FLAG_SECURE_SEND); 01508 } else { 01509 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Error allocating SRTP [%d]\n", stat); 01510 return status; 01511 } 01512 } 01513 01514 break; 01515 default: 01516 abort(); 01517 break; 01518 } 01519 01520 if (switch_event_create(&fsevent, SWITCH_EVENT_CALL_SECURE) == SWITCH_STATUS_SUCCESS) { 01521 switch_event_add_header(fsevent, SWITCH_STACK_BOTTOM, "secure_type", "srtp:%s", switch_channel_get_variable(channel, "sip_has_crypto")); 01522 switch_event_add_header_string(fsevent, SWITCH_STACK_BOTTOM, "caller-unique-id", switch_channel_get_uuid(channel)); 01523 switch_event_fire(&fsevent); 01524 } 01525 01526 01527 return SWITCH_STATUS_SUCCESS; 01528 #endif 01529 }
1.4.7