blob: 58d9ab200b4106a926bf59f43d4294466740990c [file] [log] [blame]
Cullen Jennings235513a2005-09-21 22:51:36 +00001/*
2 * rtp.h
3 *
4 * rtp interface for srtp reference implementation
5 *
6 * David A. McGrew
7 * Cisco Systems, Inc.
8 *
9 * data types:
10 *
11 * rtp_msg_t an rtp message (the data that goes on the wire)
12 * rtp_sender_t sender side socket and rtp info
13 * rtp_receiver_t receiver side socket and rtp info
14 *
15 */
16
17/*
18 *
David McGrew7629bf22006-06-08 17:00:25 +000019 * Copyright (c) 2001-2006, Cisco Systems, Inc.
Cullen Jennings235513a2005-09-21 22:51:36 +000020 * All rights reserved.
21 *
22 * Redistribution and use in source and binary forms, with or without
23 * modification, are permitted provided that the following conditions
24 * are met:
25 *
26 * Redistributions of source code must retain the above copyright
27 * notice, this list of conditions and the following disclaimer.
28 *
29 * Redistributions in binary form must reproduce the above
30 * copyright notice, this list of conditions and the following
31 * disclaimer in the documentation and/or other materials provided
32 * with the distribution.
33 *
34 * Neither the name of the Cisco Systems, Inc. nor the names of its
35 * contributors may be used to endorse or promote products derived
36 * from this software without specific prior written permission.
37 *
38 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
39 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
40 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
41 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
42 * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
43 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
44 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
45 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
46 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
47 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49 * OF THE POSSIBILITY OF SUCH DAMAGE.
50 *
51 */
52
53
54#ifndef RTP_H
55#define RTP_H
56
Marcus Sundberg4254d0a2005-10-02 20:16:47 +000057#ifdef HAVE_NETINET_IN_H
58# include <netinet/in.h>
59#elif defined HAVE_WINSOCK2_H
60# include <winsock2.h>
61#endif
Cullen Jennings235513a2005-09-21 22:51:36 +000062
jfigusa9ac8982014-10-31 14:49:31 -040063//#include "srtp_priv.h"
David McGrew1a2ab2c2006-07-12 22:48:44 +000064#include "srtp.h"
jfigusa9ac8982014-10-31 14:49:31 -040065/*
66 * RTP_HEADER_LEN indicates the size of an RTP header
67 */
68#define RTP_HEADER_LEN 12
69
70/*
71 * RTP_MAX_BUF_LEN defines the largest RTP packet in the rtp.c implementation
72 */
73#define RTP_MAX_BUF_LEN 16384
74
75
76typedef srtp_hdr_t rtp_hdr_t;
77
78typedef struct {
79 srtp_hdr_t header;
80 char body[RTP_MAX_BUF_LEN];
81} rtp_msg_t;
82
83typedef struct rtp_sender_ctx_t {
84 rtp_msg_t message;
85 int socket;
86 srtp_ctx_t *srtp_ctx;
87 struct sockaddr_in addr; /* reciever's address */
88} rtp_sender_ctx_t;
89
90typedef struct rtp_receiver_ctx_t {
91 rtp_msg_t message;
92 int socket;
93 srtp_ctx_t *srtp_ctx;
94 struct sockaddr_in addr; /* receiver's address */
95} rtp_receiver_ctx_t;
96
Cullen Jennings235513a2005-09-21 22:51:36 +000097
David McGrew1a2ab2c2006-07-12 22:48:44 +000098typedef struct rtp_sender_ctx_t *rtp_sender_t;
Cullen Jennings235513a2005-09-21 22:51:36 +000099
David McGrew1a2ab2c2006-07-12 22:48:44 +0000100typedef struct rtp_receiver_ctx_t *rtp_receiver_t;
Cullen Jennings235513a2005-09-21 22:51:36 +0000101
Jonathan Lennox986f6d02010-05-17 19:28:39 +0000102int
David McGrew1a2ab2c2006-07-12 22:48:44 +0000103rtp_sendto(rtp_sender_t sender, const void* msg, int len);
Cullen Jennings235513a2005-09-21 22:51:36 +0000104
Jonathan Lennox986f6d02010-05-17 19:28:39 +0000105int
David McGrew1a2ab2c2006-07-12 22:48:44 +0000106rtp_recvfrom(rtp_receiver_t receiver, void *msg, int *len);
Cullen Jennings235513a2005-09-21 22:51:36 +0000107
108int
Jonathan Lennox75b36872010-05-21 00:30:21 +0000109rtp_receiver_init(rtp_receiver_t rcvr, int sock,
David McGrew1a2ab2c2006-07-12 22:48:44 +0000110 struct sockaddr_in addr, unsigned int ssrc);
Cullen Jennings235513a2005-09-21 22:51:36 +0000111
112int
Jonathan Lennox75b36872010-05-21 00:30:21 +0000113rtp_sender_init(rtp_sender_t sender, int sock,
David McGrew1a2ab2c2006-07-12 22:48:44 +0000114 struct sockaddr_in addr, unsigned int ssrc);
Cullen Jennings235513a2005-09-21 22:51:36 +0000115
116/*
117 * srtp_sender_init(...) initializes an rtp_sender_t
Cullen Jennings235513a2005-09-21 22:51:36 +0000118 */
119
120int
David McGrew1a2ab2c2006-07-12 22:48:44 +0000121srtp_sender_init(rtp_sender_t rtp_ctx, /* structure to be init'ed */
Cullen Jennings235513a2005-09-21 22:51:36 +0000122 struct sockaddr_in name, /* socket name */
jfigus857009c2014-11-05 11:17:43 -0500123 srtp_sec_serv_t security_services, /* sec. servs. to be used */
Cullen Jennings235513a2005-09-21 22:51:36 +0000124 unsigned char *input_key /* master key/salt in hex */
125 );
126
127int
David McGrew1a2ab2c2006-07-12 22:48:44 +0000128srtp_receiver_init(rtp_receiver_t rtp_ctx, /* structure to be init'ed */
Cullen Jennings235513a2005-09-21 22:51:36 +0000129 struct sockaddr_in name, /* socket name */
jfigus857009c2014-11-05 11:17:43 -0500130 srtp_sec_serv_t security_services, /* sec. servs. to be used */
Cullen Jennings235513a2005-09-21 22:51:36 +0000131 unsigned char *input_key /* master key/salt in hex */
132 );
133
134
David McGrew1a2ab2c2006-07-12 22:48:44 +0000135int
136rtp_sender_init_srtp(rtp_sender_t sender, const srtp_policy_t *policy);
137
138int
Jonathan Lennox8cae72f2010-05-17 19:19:10 +0000139rtp_sender_deinit_srtp(rtp_sender_t sender);
140
141int
David McGrew1a2ab2c2006-07-12 22:48:44 +0000142rtp_receiver_init_srtp(rtp_receiver_t sender, const srtp_policy_t *policy);
143
Jonathan Lennox8cae72f2010-05-17 19:19:10 +0000144int
145rtp_receiver_deinit_srtp(rtp_receiver_t sender);
146
David McGrewd0832052006-07-13 19:04:53 +0000147
148rtp_sender_t
Jonathan Lennoxed3ab2b2010-05-17 19:42:26 +0000149rtp_sender_alloc(void);
David McGrewd0832052006-07-13 19:04:53 +0000150
Jonathan Lennox8cae72f2010-05-17 19:19:10 +0000151void
152rtp_sender_dealloc(rtp_sender_t rtp_ctx);
153
David McGrewd0832052006-07-13 19:04:53 +0000154rtp_receiver_t
Jonathan Lennoxed3ab2b2010-05-17 19:42:26 +0000155rtp_receiver_alloc(void);
David McGrewd0832052006-07-13 19:04:53 +0000156
Jonathan Lennox8cae72f2010-05-17 19:19:10 +0000157void
158rtp_receiver_dealloc(rtp_receiver_t rtp_ctx);
159
David McGrewd0832052006-07-13 19:04:53 +0000160
David McGrew1a2ab2c2006-07-12 22:48:44 +0000161
Cullen Jennings235513a2005-09-21 22:51:36 +0000162#endif /* RTP_H */