Philipp Maier | 87bd9be | 2017-08-22 16:35:41 +0200 | [diff] [blame] | 1 | /* A Media Gateway Control Protocol Media Gateway: RFC 3435 */ |
| 2 | /* Message parser/generator utilities */ |
| 3 | |
| 4 | /* |
| 5 | * (C) 2009-2012 by Holger Hans Peter Freyther <zecke@selfish.org> |
| 6 | * (C) 2009-2012 by On-Waves |
| 7 | * (C) 2017 by sysmocom s.f.m.c. GmbH <info@sysmocom.de> |
| 8 | * All Rights Reserved |
| 9 | * |
| 10 | * This program is free software; you can redistribute it and/or modify |
| 11 | * it under the terms of the GNU Affero General Public License as published by |
| 12 | * the Free Software Foundation; either version 3 of the License, or |
| 13 | * (at your option) any later version. |
| 14 | * |
| 15 | * This program is distributed in the hope that it will be useful, |
| 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 18 | * GNU Affero General Public License for more details. |
| 19 | * |
| 20 | * You should have received a copy of the GNU Affero General Public License |
| 21 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 22 | * |
| 23 | */ |
| 24 | |
| 25 | #pragma once |
| 26 | |
| 27 | #include <stdint.h> |
Eric | 1e8d5fa | 2021-08-24 01:36:49 +0200 | [diff] [blame] | 28 | #include <stdbool.h> |
Philipp Maier | 87bd9be | 2017-08-22 16:35:41 +0200 | [diff] [blame] | 29 | |
| 30 | struct mgcp_conn; |
| 31 | struct mgcp_parse_data; |
| 32 | struct mgcp_endpoint; |
Eric | 1e8d5fa | 2021-08-24 01:36:49 +0200 | [diff] [blame] | 33 | struct mgcp_trunk; |
Philipp Maier | 87bd9be | 2017-08-22 16:35:41 +0200 | [diff] [blame] | 34 | |
| 35 | void mgcp_disp_msg(unsigned char *message, unsigned int len, char *preamble); |
| 36 | |
| 37 | int mgcp_parse_conn_mode(const char *msg, struct mgcp_endpoint *endp, |
| 38 | struct mgcp_conn *conn); |
| 39 | |
| 40 | int mgcp_parse_header(struct mgcp_parse_data *pdata, char *data); |
| 41 | |
| 42 | int mgcp_parse_osmux_cid(const char *line); |
| 43 | |
Philipp Maier | 036612b | 2021-07-19 17:47:49 +0200 | [diff] [blame] | 44 | bool mgcp_check_param(const struct mgcp_endpoint *endp, struct mgcp_trunk *trunk, const char *line); |
Philipp Maier | 87bd9be | 2017-08-22 16:35:41 +0200 | [diff] [blame] | 45 | |
| 46 | int mgcp_verify_call_id(struct mgcp_endpoint *endp, const char *callid); |
| 47 | |
Philipp Maier | 01d24a3 | 2017-11-21 17:26:09 +0100 | [diff] [blame] | 48 | int mgcp_verify_ci(struct mgcp_endpoint *endp, const char *conn_id); |
Philipp Maier | 87bd9be | 2017-08-22 16:35:41 +0200 | [diff] [blame] | 49 | |
| 50 | char *mgcp_strline(char *str, char **saveptr); |
| 51 | |
| 52 | #define for_each_line(line, save)\ |
| 53 | for (line = mgcp_strline(NULL, &save); line;\ |
| 54 | line = mgcp_strline(NULL, &save)) |
| 55 | |
| 56 | #define for_each_non_empty_line(line, save)\ |
| 57 | for (line = strtok_r(NULL, "\r\n", &save); line;\ |
| 58 | line = strtok_r(NULL, "\r\n", &save)) |