blob: 65b1a5fac9068e9c930a6ede35c1c0dccdd20a45 [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
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (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
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 *
23 */
24
25
26#include <netinet/in.h>
27
Harald Weltedfe6c7d2010-02-20 16:24:02 +010028#include <osmocore/linuxlist.h>
29#include <osmocore/select.h>
Harald Welteead7a7b2009-07-28 00:01:58 +020030
Sylvain Munautb54dda42009-12-20 22:06:40 +010031#define RTP_PT_GSM_FULL 3
32#define RTP_PT_GSM_HALF 96
33#define RTP_PT_GSM_EFR 97
34#define RTP_PT_AMR_FULL 98
35#define RTP_PT_AMR_HALF 99
36
Harald Welteead7a7b2009-07-28 00:01:58 +020037enum rtp_rx_action {
38 RTP_NONE,
39 RTP_PROXY,
40 RTP_RECV_UPSTREAM,
41};
42
Harald Welteda7ab742009-12-19 22:23:05 +010043enum rtp_tx_action {
44 RTP_SEND_NONE,
45 RTP_SEND_DOWNSTREAM,
46};
47
Harald Welteead7a7b2009-07-28 00:01:58 +020048struct rtp_sub_socket {
49 struct sockaddr_in sin_local;
50 struct sockaddr_in sin_remote;
51
52 struct bsc_fd bfd;
53 /* linked list of to-be-transmitted msgb's */
54 struct llist_head tx_queue;
55};
56
57struct rtp_socket {
58 struct llist_head list;
59
60 struct rtp_sub_socket rtp;
61 struct rtp_sub_socket rtcp;
62
63 /* what should we do on receive? */
64 enum rtp_rx_action rx_action;
65 union {
66 struct {
67 struct rtp_socket *other_sock;
68 } proxy;
69 struct {
Harald Welteda7ab742009-12-19 22:23:05 +010070 struct gsm_network *net;
71 u_int32_t callref;
Harald Welteead7a7b2009-07-28 00:01:58 +020072 } receive;
73 };
Harald Welteda7ab742009-12-19 22:23:05 +010074 enum rtp_tx_action tx_action;
75 struct {
76 u_int16_t sequence;
77 u_int32_t timestamp;
78 u_int32_t ssrc;
Harald Welte392736d2009-12-20 13:16:14 +010079 struct timeval last_tv;
Harald Welteda7ab742009-12-19 22:23:05 +010080 } transmit;
Harald Welteead7a7b2009-07-28 00:01:58 +020081};
82
83struct rtp_socket *rtp_socket_create(void);
84int rtp_socket_bind(struct rtp_socket *rs, u_int32_t ip);
85int rtp_socket_connect(struct rtp_socket *rs, u_int32_t ip, u_int16_t port);
86int rtp_socket_proxy(struct rtp_socket *this, struct rtp_socket *other);
Harald Welteda7ab742009-12-19 22:23:05 +010087int rtp_socket_upstream(struct rtp_socket *this, struct gsm_network *net, u_int32_t callref);
Harald Welteead7a7b2009-07-28 00:01:58 +020088int rtp_socket_free(struct rtp_socket *rs);
Harald Welteda7ab742009-12-19 22:23:05 +010089int rtp_send_frame(struct rtp_socket *rs, struct gsm_data_frame *frame);
Harald Welteead7a7b2009-07-28 00:01:58 +020090
91#endif /* _RTP_PROXY_H */