Philipp Maier | 87bd9be | 2017-08-22 16:35:41 +0200 | [diff] [blame] | 1 | /* 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 | |
| 26 | struct sockaddr_in; |
| 27 | struct mgcp_conn; |
Philipp Maier | edc00f4 | 2018-01-24 11:58:56 +0100 | [diff] [blame] | 28 | struct mgcp_endpoint; |
Philipp Maier | 87bd9be | 2017-08-22 16:35:41 +0200 | [diff] [blame] | 29 | |
| 30 | /* Callback type for RTP dispatcher functions |
| 31 | (e.g mgcp_dispatch_rtp_bridge_cb, see below) */ |
Philipp Maier | 36a8112 | 2018-01-24 11:52:34 +0100 | [diff] [blame] | 32 | typedef int (*mgcp_dispatch_rtp_cb) (int proto, struct sockaddr_in *addr, |
Philipp Maier | 87bd9be | 2017-08-22 16:35:41 +0200 | [diff] [blame] | 33 | char *buf, unsigned int buf_size, |
Philipp Maier | 36a8112 | 2018-01-24 11:52:34 +0100 | [diff] [blame] | 34 | struct mgcp_conn *conn); |
Philipp Maier | 87bd9be | 2017-08-22 16:35:41 +0200 | [diff] [blame] | 35 | |
Philipp Maier | df5d219 | 2018-01-24 11:39:32 +0100 | [diff] [blame] | 36 | /* Callback type for endpoint specific cleanup actions. This function |
| 37 | * is automatically executed when a connection is freed (see mgcp_conn_free() |
| 38 | * in mgcp_conn.c). Depending on the type of the endpoint there may be endpoint |
| 39 | * specific things to take care of once a connection has been removed. */ |
| 40 | typedef void (*mgcp_cleanup_cp) (struct mgcp_endpoint *endp, |
| 41 | struct mgcp_conn *conn); |
| 42 | |
Philipp Maier | 87bd9be | 2017-08-22 16:35:41 +0200 | [diff] [blame] | 43 | /*! MGCP endpoint properties */ |
| 44 | struct mgcp_endpoint_type { |
| 45 | /*!< maximum number of connections */ |
| 46 | int max_conns; |
| 47 | |
| 48 | /*!< callback that defines how to dispatch incoming RTP data */ |
| 49 | mgcp_dispatch_rtp_cb dispatch_rtp_cb; |
Philipp Maier | df5d219 | 2018-01-24 11:39:32 +0100 | [diff] [blame] | 50 | |
| 51 | /*!< callback that implements endpoint specific cleanup actions */ |
| 52 | mgcp_cleanup_cp cleanup_cb; |
Philipp Maier | 87bd9be | 2017-08-22 16:35:41 +0200 | [diff] [blame] | 53 | }; |
| 54 | |
| 55 | /*! MGCP endpoint typeset */ |
| 56 | struct mgcp_endpoint_typeset { |
| 57 | struct mgcp_endpoint_type rtp; |
| 58 | }; |
| 59 | |
| 60 | /*! static MGCP endpoint typeset (pre-initalized, read-only) */ |
| 61 | extern const struct mgcp_endpoint_typeset ep_typeset; |
Philipp Maier | edc00f4 | 2018-01-24 11:58:56 +0100 | [diff] [blame] | 62 | |
Philipp Maier | fdd603c | 2018-02-01 13:31:15 +0100 | [diff] [blame] | 63 | /*! MGCP endpoint model */ |
| 64 | struct mgcp_endpoint { |
| 65 | |
| 66 | /*!< Call identifier string (as supplied by the call agant) */ |
| 67 | char *callid; |
| 68 | |
| 69 | /*!< Local connection options (see mgcp_intermal.h) */ |
| 70 | struct mgcp_lco local_options; |
| 71 | |
| 72 | /*!< List with connections active on this endpoint */ |
| 73 | struct llist_head conns; |
| 74 | |
| 75 | /*!< Backpointer to the MGW configuration */ |
| 76 | struct mgcp_config *cfg; |
| 77 | |
| 78 | /*!< Backpointer to the Trunk specific configuration */ |
| 79 | struct mgcp_trunk_config *tcfg; |
| 80 | |
| 81 | /*!< Endpoint properties (see above) */ |
| 82 | const struct mgcp_endpoint_type *type; |
| 83 | |
| 84 | /*!< Last MGCP transmission (in case re-transmission is required) */ |
| 85 | char *last_trans; |
| 86 | |
| 87 | /*!< Last MGCP response (in case re-transmission is required) */ |
| 88 | char *last_response; |
| 89 | |
| 90 | /*!< Memorize if this endpoint was choosen by the MGW (wildcarded, true) |
| 91 | * or if the user has choosen the particular endpoint explicitly. */ |
Philipp Maier | 207ab51 | 2018-02-02 14:19:26 +0100 | [diff] [blame] | 92 | bool wildcarded_req; |
Philipp Maier | fdd603c | 2018-02-01 13:31:15 +0100 | [diff] [blame] | 93 | }; |
| 94 | |
| 95 | /*! Extract endpoint number for a given endpoint */ |
| 96 | #define ENDPOINT_NUMBER(endp) abs((int)(endp - endp->tcfg->endpoints)) |
| 97 | |
Philipp Maier | 1355d7e | 2018-02-01 14:30:06 +0100 | [diff] [blame] | 98 | void mgcp_endp_release(struct mgcp_endpoint *endp); |
| 99 | |