blob: 53b58b4b56d584a8cdb656fe2a376c26c4f1f637 [file] [log] [blame]
Harald Welteead7a7b2009-07-28 00:01:58 +02001#ifndef _RTP_PROXY_H
2#define _RTP_PROXY_H
3
4/* RTP proxy handling for ip.access nanoBTS */
5
6/* (C) 2009 by Harald Welte <laforge@gnumonks.org>
7 * All Rights Reserved
8 *
9 * This program is free software; you can redistribute it and/or modify
Harald Welte9af6ddf2011-01-01 15:25:50 +010010 * it under the terms of the GNU Affero General Public License as published by
11 * the Free Software Foundation; either version 3 of the License, or
Harald Welteead7a7b2009-07-28 00:01:58 +020012 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
Harald Welte9af6ddf2011-01-01 15:25:50 +010017 * GNU Affero General Public License for more details.
Harald Welteead7a7b2009-07-28 00:01:58 +020018 *
Harald Welte9af6ddf2011-01-01 15:25:50 +010019 * You should have received a copy of the GNU Affero General Public License
20 * along with this program. If not, see <http://www.gnu.org/licenses/>.
Harald Welteead7a7b2009-07-28 00:01:58 +020021 *
22 */
23
24
25#include <netinet/in.h>
26
Harald Weltedfe6c7d2010-02-20 16:24:02 +010027#include <osmocore/linuxlist.h>
28#include <osmocore/select.h>
Harald Welteead7a7b2009-07-28 00:01:58 +020029
Sylvain Munautb54dda42009-12-20 22:06:40 +010030#define RTP_PT_GSM_FULL 3
31#define RTP_PT_GSM_HALF 96
32#define RTP_PT_GSM_EFR 97
33#define RTP_PT_AMR_FULL 98
34#define RTP_PT_AMR_HALF 99
35
Harald Welteead7a7b2009-07-28 00:01:58 +020036enum rtp_rx_action {
37 RTP_NONE,
38 RTP_PROXY,
39 RTP_RECV_UPSTREAM,
40};
41
Harald Welteda7ab742009-12-19 22:23:05 +010042enum rtp_tx_action {
43 RTP_SEND_NONE,
44 RTP_SEND_DOWNSTREAM,
45};
46
Harald Welteead7a7b2009-07-28 00:01:58 +020047struct rtp_sub_socket {
48 struct sockaddr_in sin_local;
49 struct sockaddr_in sin_remote;
50
51 struct bsc_fd bfd;
52 /* linked list of to-be-transmitted msgb's */
53 struct llist_head tx_queue;
54};
55
56struct rtp_socket {
57 struct llist_head list;
58
59 struct rtp_sub_socket rtp;
60 struct rtp_sub_socket rtcp;
61
62 /* what should we do on receive? */
63 enum rtp_rx_action rx_action;
64 union {
65 struct {
66 struct rtp_socket *other_sock;
67 } proxy;
68 struct {
Harald Welteda7ab742009-12-19 22:23:05 +010069 struct gsm_network *net;
70 u_int32_t callref;
Harald Welteead7a7b2009-07-28 00:01:58 +020071 } receive;
72 };
Harald Welteda7ab742009-12-19 22:23:05 +010073 enum rtp_tx_action tx_action;
74 struct {
75 u_int16_t sequence;
76 u_int32_t timestamp;
77 u_int32_t ssrc;
Harald Welte392736d2009-12-20 13:16:14 +010078 struct timeval last_tv;
Harald Welteda7ab742009-12-19 22:23:05 +010079 } transmit;
Harald Welteead7a7b2009-07-28 00:01:58 +020080};
81
82struct rtp_socket *rtp_socket_create(void);
83int rtp_socket_bind(struct rtp_socket *rs, u_int32_t ip);
84int rtp_socket_connect(struct rtp_socket *rs, u_int32_t ip, u_int16_t port);
85int rtp_socket_proxy(struct rtp_socket *this, struct rtp_socket *other);
Harald Welteda7ab742009-12-19 22:23:05 +010086int rtp_socket_upstream(struct rtp_socket *this, struct gsm_network *net, u_int32_t callref);
Harald Welteead7a7b2009-07-28 00:01:58 +020087int rtp_socket_free(struct rtp_socket *rs);
Harald Welteda7ab742009-12-19 22:23:05 +010088int rtp_send_frame(struct rtp_socket *rs, struct gsm_data_frame *frame);
Harald Welteead7a7b2009-07-28 00:01:58 +020089
90#endif /* _RTP_PROXY_H */