libosmo-sigtran 2.0.0.52-6412
Osmocom SIGTRAN library
xua_msg.h
Go to the documentation of this file.
1/* Routines for generating and parsing messages */
2/* (C) 2011 by Holger Hans Peter Freyther <zecke@selfish.org>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 *
17 */
18#pragma once
19
20#include "xua_types.h"
21
22#include <osmocom/core/linuxlist.h>
24
25#define XUA_HDR(class, type) ((struct xua_common_hdr) { .spare = 0, .msg_class = (class), .msg_type = (type) })
26
27struct msgb;
28struct osmo_sccp_addr;
29struct osmo_sccp_gt;
30
31struct xua_msg {
34
35 struct llist_head headers;
36};
37
39 struct llist_head entry;
40
41 uint16_t tag;
42 uint16_t len;
43 uint8_t *dat;
44
45 /* TODO: keep small data in the struct for perf reasons */
46};
47
49 const char *name;
50 const struct value_string *msgt_names;
51 const struct value_string *iei_names;
52 const uint16_t *mand_ies[256];
53};
54
56 const char *name;
57 uint16_t port;
58 uint16_t ppid;
60 const struct xua_msg_class *class[256];
61};
62
64 uint8_t msg_class;
65 uint8_t msg_type;
66 int event;
67};
68
69extern const struct xua_dialect xua_dialect_sua;
70extern const struct xua_dialect xua_dialect_m3ua;
71
72void osmo_xua_msg_tall_ctx_init(void *ctx);
73
74struct xua_msg *xua_msg_alloc(void);
75void xua_msg_free(struct xua_msg *msg);
76
77int xua_msg_add_data(struct xua_msg *msg, uint16_t tag, uint16_t len, const uint8_t *dat);
78
79struct xua_msg_part *xua_msg_find_tag(const struct xua_msg *msg, uint16_t tag);
80int xua_msg_free_tag(struct xua_msg *xua, uint16_t tag);
81int xua_msg_copy_part(struct xua_msg *xua_out, uint16_t tag_out,
82 const struct xua_msg *xua_in, uint16_t tag_in);
83
84struct xua_msg *xua_from_msg(const int version, uint16_t len, uint8_t *data);
85struct msgb *xua_to_msg(const int version, struct xua_msg *msg);
86
87struct xua_msg *xua_from_nested(struct xua_msg_part *outer);
88
89int msgb_t16l16vp_put(struct msgb *msg, uint16_t tag, uint16_t len, const uint8_t *data);
90int msgb_t16l16vp_put_u32(struct msgb *msg, uint16_t tag, uint32_t val);
91int xua_msg_add_u32(struct xua_msg *xua, uint16_t iei, uint32_t val);
92uint32_t xua_msg_part_get_u32(const struct xua_msg_part *part);
93uint32_t xua_msg_get_u32(const struct xua_msg *xua, uint16_t iei);
94const uint32_t *xua_msg_get_u32p(const struct xua_msg *xua, uint16_t iei, uint32_t *out);
95const char *xua_msg_part_get_str(const struct xua_msg_part *part);
96const char *xua_msg_get_str(const struct xua_msg *xua, uint16_t iei);
97int xua_msg_get_len(const struct xua_msg *xua, uint16_t iei);
98void xua_part_add_gt(struct msgb *msg, const struct osmo_sccp_gt *gt);
99int xua_msg_add_sccp_addr(struct xua_msg *xua, uint16_t iei, const struct osmo_sccp_addr *addr);
100
101const char *xua_class_msg_name(const struct xua_msg_class *xmc, uint16_t msg_type);
102const char *xua_class_iei_name(const struct xua_msg_class *xmc, uint16_t iei);
103char *xua_hdr_dump(struct xua_msg *xua, const struct xua_dialect *dialect);
104char *xua_msg_dump(struct xua_msg *xua, const struct xua_dialect *dialect);
105int xua_dialect_check_all_mand_ies(const struct xua_dialect *dialect, struct xua_msg *xua);
106
107int xua_msg_event_map(const struct xua_msg *xua,
108 const struct xua_msg_event_map *maps,
109 unsigned int num_maps);
void osmo_xua_msg_tall_ctx_init(void *ctx)
Definition: xua_msg.c:39
uint8_t msg_type
Definition: sccp_scmg.h:0
char * xua_msg_dump(struct xua_msg *xua, const struct xua_dialect *dialect)
Definition: xua_msg.c:522
const char * xua_class_iei_name(const struct xua_msg_class *xmc, uint16_t iei)
Definition: xua_msg.c:463
void xua_msg_free(struct xua_msg *msg)
Definition: xua_msg.c:56
const uint32_t * xua_msg_get_u32p(const struct xua_msg *xua, uint16_t iei, uint32_t *out)
Definition: xua_msg.c:301
const struct xua_dialect xua_dialect_m3ua
Definition: m3ua.c:275
int xua_msg_free_tag(struct xua_msg *xua, uint16_t tag)
Definition: xua_msg.c:97
const char * xua_msg_get_str(const struct xua_msg *xua, uint16_t iei)
Definition: xua_msg.c:325
int xua_msg_get_len(const struct xua_msg *xua, uint16_t iei)
Definition: xua_msg.c:333
struct msgb * xua_to_msg(const int version, struct xua_msg *msg)
Definition: xua_msg.c:203
int xua_msg_add_data(struct xua_msg *msg, uint16_t tag, uint16_t len, const uint8_t *dat)
Definition: xua_msg.c:61
struct xua_msg * xua_from_msg(const int version, uint16_t len, uint8_t *data)
Definition: xua_msg.c:151
void xua_part_add_gt(struct msgb *msg, const struct osmo_sccp_gt *gt)
Definition: xua_msg.c:341
int msgb_t16l16vp_put(struct msgb *msg, uint16_t tag, uint16_t len, const uint8_t *data)
Definition: xua_msg.c:247
char * xua_hdr_dump(struct xua_msg *xua, const struct xua_dialect *dialect)
Definition: xua_msg.c:475
int msgb_t16l16vp_put_u32(struct msgb *msg, uint16_t tag, uint32_t val)
Definition: xua_msg.c:273
int xua_msg_add_u32(struct xua_msg *xua, uint16_t iei, uint32_t val)
Definition: xua_msg.c:280
uint32_t xua_msg_part_get_u32(const struct xua_msg_part *part)
Definition: xua_msg.c:286
struct xua_msg * xua_from_nested(struct xua_msg_part *outer)
Definition: xua_msg.c:186
struct xua_msg_part * xua_msg_find_tag(const struct xua_msg *msg, uint16_t tag)
Definition: xua_msg.c:86
int xua_msg_copy_part(struct xua_msg *xua_out, uint16_t tag_out, const struct xua_msg *xua_in, uint16_t tag_in)
Definition: xua_msg.c:111
int xua_msg_add_sccp_addr(struct xua_msg *xua, uint16_t iei, const struct osmo_sccp_addr *addr)
Definition: xua_msg.c:379
const struct xua_dialect xua_dialect_sua
Definition: sua.c:221
uint32_t xua_msg_get_u32(const struct xua_msg *xua, uint16_t iei)
Definition: xua_msg.c:292
const char * xua_msg_part_get_str(const struct xua_msg_part *part)
Definition: xua_msg.c:310
struct xua_msg * xua_msg_alloc(void)
Definition: xua_msg.c:44
int xua_msg_event_map(const struct xua_msg *xua, const struct xua_msg_event_map *maps, unsigned int num_maps)
Map from a xua_msg (class+type) to an event.
Definition: xua_msg.c:435
const char * xua_class_msg_name(const struct xua_msg_class *xmc, uint16_t msg_type)
Definition: xua_msg.c:451
int xua_dialect_check_all_mand_ies(const struct xua_dialect *dialect, struct xua_msg *xua)
Definition: xua_msg.c:490
Definition: mtp_sap.h:36
Definition: sccp_sap.h:183
Definition: sccp_sap.h:175
Definition: xua_types.h:31
Definition: xua_msg.h:55
uint16_t port
Definition: xua_msg.h:57
uint16_t ppid
Definition: xua_msg.h:58
int log_subsys
Definition: xua_msg.h:59
const char * name
Definition: xua_msg.h:56
Definition: xua_msg.h:48
const uint16_t * mand_ies[256]
Definition: xua_msg.h:52
const char * name
Definition: xua_msg.h:49
const struct value_string * iei_names
Definition: xua_msg.h:51
const struct value_string * msgt_names
Definition: xua_msg.h:50
Definition: xua_msg.h:63
uint8_t msg_type
Definition: xua_msg.h:65
uint8_t msg_class
Definition: xua_msg.h:64
int event
Definition: xua_msg.h:66
Definition: xua_msg.h:38
struct llist_head entry
Definition: xua_msg.h:39
uint8_t * dat
Definition: xua_msg.h:43
uint16_t tag
Definition: xua_msg.h:41
uint16_t len
Definition: xua_msg.h:42
Definition: xua_msg.h:31
struct osmo_mtp_transfer_param mtp
Definition: xua_msg.h:33
struct xua_common_hdr hdr
Definition: xua_msg.h:32
struct llist_head headers
Definition: xua_msg.h:35
uint16_t tag
Definition: xua_types.h:0
uint16_t len
Definition: xua_types.h:1
uint8_t data[0]
Definition: xua_types.h:5
uint8_t version
Definition: xua_types.h:0