blob: 9572d396f372351fb448ceb8b22145d6766d691a [file] [log] [blame]
Philipp Maier87bd9be2017-08-22 16:35:41 +02001/* 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>
Eric1e8d5fa2021-08-24 01:36:49 +020028#include <stdbool.h>
Philipp Maier87bd9be2017-08-22 16:35:41 +020029
30struct mgcp_conn;
31struct mgcp_parse_data;
32struct mgcp_endpoint;
Eric1e8d5fa2021-08-24 01:36:49 +020033struct mgcp_trunk;
Philipp Maier87bd9be2017-08-22 16:35:41 +020034
35void mgcp_disp_msg(unsigned char *message, unsigned int len, char *preamble);
36
37int mgcp_parse_conn_mode(const char *msg, struct mgcp_endpoint *endp,
38 struct mgcp_conn *conn);
39
40int mgcp_parse_header(struct mgcp_parse_data *pdata, char *data);
41
42int mgcp_parse_osmux_cid(const char *line);
43
Philipp Maier036612b2021-07-19 17:47:49 +020044bool mgcp_check_param(const struct mgcp_endpoint *endp, struct mgcp_trunk *trunk, const char *line);
Philipp Maier87bd9be2017-08-22 16:35:41 +020045
46int mgcp_verify_call_id(struct mgcp_endpoint *endp, const char *callid);
47
Philipp Maier01d24a32017-11-21 17:26:09 +010048int mgcp_verify_ci(struct mgcp_endpoint *endp, const char *conn_id);
Philipp Maier87bd9be2017-08-22 16:35:41 +020049
50char *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))