blob: a3e45964cbb42c78ab9b21bec9265b42fe237f43 [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
28#include <openbsc/linuxlist.h>
29#include <openbsc/select.h>
30
31enum rtp_rx_action {
32 RTP_NONE,
33 RTP_PROXY,
34 RTP_RECV_UPSTREAM,
35};
36
Harald Welteda7ab742009-12-19 22:23:05 +010037enum rtp_tx_action {
38 RTP_SEND_NONE,
39 RTP_SEND_DOWNSTREAM,
40};
41
Harald Welteead7a7b2009-07-28 00:01:58 +020042struct rtp_sub_socket {
43 struct sockaddr_in sin_local;
44 struct sockaddr_in sin_remote;
45
46 struct bsc_fd bfd;
47 /* linked list of to-be-transmitted msgb's */
48 struct llist_head tx_queue;
49};
50
51struct rtp_socket {
52 struct llist_head list;
53
54 struct rtp_sub_socket rtp;
55 struct rtp_sub_socket rtcp;
56
57 /* what should we do on receive? */
58 enum rtp_rx_action rx_action;
59 union {
60 struct {
61 struct rtp_socket *other_sock;
62 } proxy;
63 struct {
Harald Welteda7ab742009-12-19 22:23:05 +010064 struct gsm_network *net;
65 u_int32_t callref;
Harald Welteead7a7b2009-07-28 00:01:58 +020066 } receive;
67 };
Harald Welteda7ab742009-12-19 22:23:05 +010068 enum rtp_tx_action tx_action;
69 struct {
70 u_int16_t sequence;
71 u_int32_t timestamp;
72 u_int32_t ssrc;
73 } transmit;
Harald Welteead7a7b2009-07-28 00:01:58 +020074};
75
76struct rtp_socket *rtp_socket_create(void);
77int rtp_socket_bind(struct rtp_socket *rs, u_int32_t ip);
78int rtp_socket_connect(struct rtp_socket *rs, u_int32_t ip, u_int16_t port);
79int rtp_socket_proxy(struct rtp_socket *this, struct rtp_socket *other);
Harald Welteda7ab742009-12-19 22:23:05 +010080int rtp_socket_upstream(struct rtp_socket *this, struct gsm_network *net, u_int32_t callref);
Harald Welteead7a7b2009-07-28 00:01:58 +020081int rtp_socket_free(struct rtp_socket *rs);
Harald Welteda7ab742009-12-19 22:23:05 +010082int rtp_send_frame(struct rtp_socket *rs, struct gsm_data_frame *frame);
Harald Welteead7a7b2009-07-28 00:01:58 +020083
84#endif /* _RTP_PROXY_H */