blob: ad5e28d1e619246aa75331cd0b7704d2962df449 [file] [log] [blame]
Philipp Maier87bd9be2017-08-22 16:35:41 +02001/* Endpoint types */
2
3/*
4 * (C) 2017 by sysmocom s.f.m.c. GmbH <info@sysmocom.de>
5 * All Rights Reserved
6 *
7 * Author: Philipp Maier
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * 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
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 Affero General Public License for more details.
18 *
19 * 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/>.
21 *
22 */
23
24#pragma once
25
26struct sockaddr_in;
27struct mgcp_conn;
Philipp Maieredc00f42018-01-24 11:58:56 +010028struct mgcp_endpoint;
Philipp Maier87bd9be2017-08-22 16:35:41 +020029
30/* Callback type for RTP dispatcher functions
31 (e.g mgcp_dispatch_rtp_bridge_cb, see below) */
Philipp Maier36a81122018-01-24 11:52:34 +010032typedef int (*mgcp_dispatch_rtp_cb) (int proto, struct sockaddr_in *addr,
Philipp Maier87bd9be2017-08-22 16:35:41 +020033 char *buf, unsigned int buf_size,
Philipp Maier36a81122018-01-24 11:52:34 +010034 struct mgcp_conn *conn);
Philipp Maier87bd9be2017-08-22 16:35:41 +020035
36/*! MGCP endpoint properties */
37struct mgcp_endpoint_type {
38 /*!< maximum number of connections */
39 int max_conns;
40
41 /*!< callback that defines how to dispatch incoming RTP data */
42 mgcp_dispatch_rtp_cb dispatch_rtp_cb;
43};
44
45/*! MGCP endpoint typeset */
46struct mgcp_endpoint_typeset {
47 struct mgcp_endpoint_type rtp;
48};
49
50/*! static MGCP endpoint typeset (pre-initalized, read-only) */
51extern const struct mgcp_endpoint_typeset ep_typeset;
Philipp Maieredc00f42018-01-24 11:58:56 +010052
Philipp Maierfdd603c2018-02-01 13:31:15 +010053/*! MGCP endpoint model */
54struct mgcp_endpoint {
55
56 /*!< Call identifier string (as supplied by the call agant) */
57 char *callid;
58
59 /*!< Local connection options (see mgcp_intermal.h) */
60 struct mgcp_lco local_options;
61
62 /*!< List with connections active on this endpoint */
63 struct llist_head conns;
64
65 /*!< Backpointer to the MGW configuration */
66 struct mgcp_config *cfg;
67
68 /*!< Backpointer to the Trunk specific configuration */
69 struct mgcp_trunk_config *tcfg;
70
71 /*!< Endpoint properties (see above) */
72 const struct mgcp_endpoint_type *type;
73
74 /*!< Last MGCP transmission (in case re-transmission is required) */
75 char *last_trans;
76
77 /*!< Last MGCP response (in case re-transmission is required) */
78 char *last_response;
79
80 /*!< Memorize if this endpoint was choosen by the MGW (wildcarded, true)
81 * or if the user has choosen the particular endpoint explicitly. */
82 bool wildcarded_crcx;
83};
84
85/*! Extract endpoint number for a given endpoint */
86#define ENDPOINT_NUMBER(endp) abs((int)(endp - endp->tcfg->endpoints))
87
Philipp Maier1355d7e2018-02-01 14:30:06 +010088void mgcp_endp_release(struct mgcp_endpoint *endp);
89