summaryrefslogtreecommitdiffstats
path: root/include/m2ua/m2ua_msg.h
blob: e251a380a2c14d0bee1229992356ccb9c8263885 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/* Routines for generating and parsing messages */
/* (C) 2011 by Holger Hans Peter Freyther <zecke@selfish.org>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation; either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 */


#ifndef m2ua_msg_h
#define m2ua_msg_h

#include "m2ua_types.h"

#include <osmocore/linuxlist.h>

struct msgb;

struct m2ua_msg {
	struct m2ua_common_hdr hdr;

	struct llist_head headers;
};

struct m2ua_msg_part {
	struct llist_head entry;

	uint16_t tag;
	uint16_t len;
	uint8_t  *dat;

	/* TODO: keep small data in the struct for perf reasons */
};


struct m2ua_msg *m2ua_msg_alloc(void);
void m2ua_msg_free(struct m2ua_msg *msg);

int m2ua_msg_add_data(struct m2ua_msg *msg, uint16_t tag, uint16_t len, uint8_t *dat);

struct m2ua_msg_part *m2ua_msg_find_tag(struct m2ua_msg *msg, uint16_t tag);

struct m2ua_msg *m2ua_from_msg(uint16_t len, uint8_t *data);
struct msgb *m2ua_to_msg(struct m2ua_msg *msg);

void m2ua_set_log_area(int log_area);

#endif