xua_msg.h
Go to the documentation of this file.
/* 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 General Public License as published by
* the Free Software Foundation; either version 2 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#pragma once
#include "xua_types.h"
#include <osmocom/core/linuxlist.h>
#include <osmocom/sigtran/mtp_sap.h>
#define XUA_HDR(class, type) ((struct xua_common_hdr) { .spare = 0, .msg_class = (class), .msg_type = (type) })
struct msgb;
struct osmo_sccp_addr;
struct osmo_sccp_gt;
struct xua_msg {
struct xua_common_hdr hdr;
struct osmo_mtp_transfer_param mtp;
struct llist_head headers;
};
struct xua_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 xua_msg_class {
const char *name;
const struct value_string *msgt_names;
const struct value_string *iei_names;
const uint16_t *mand_ies[256];
};
struct xua_dialect {
const char *name;
uint16_t port;
uint16_t ppid;
int log_subsys;
const struct xua_msg_class *class[256];
};
struct xua_msg_event_map {
uint8_t msg_class;
uint8_t msg_type;
int event;
};
extern const struct xua_dialect xua_dialect_sua;
extern const struct xua_dialect xua_dialect_m3ua;
void osmo_xua_msg_tall_ctx_init(void *ctx);
struct xua_msg *xua_msg_alloc(void);
void xua_msg_free(struct xua_msg *msg);
int xua_msg_add_data(struct xua_msg *msg, uint16_t tag, uint16_t len, uint8_t *dat);
struct xua_msg_part *xua_msg_find_tag(const struct xua_msg *msg, uint16_t tag);
int xua_msg_free_tag(struct xua_msg *xua, uint16_t tag);
int xua_msg_copy_part(struct xua_msg *xua_out, uint16_t tag_out,
const struct xua_msg *xua_in, uint16_t tag_in);
struct xua_msg *xua_from_msg(const int version, uint16_t len, uint8_t *data);
struct msgb *xua_to_msg(const int version, struct xua_msg *msg);
struct xua_msg *xua_from_nested(struct xua_msg_part *outer);
int msgb_t16l16vp_put(struct msgb *msg, uint16_t tag, uint16_t len, const uint8_t *data);
int msgb_t16l16vp_put_u32(struct msgb *msg, uint16_t tag, uint32_t val);
int xua_msg_add_u32(struct xua_msg *xua, uint16_t iei, uint32_t val);
uint32_t xua_msg_part_get_u32(struct xua_msg_part *part);
uint32_t xua_msg_get_u32(struct xua_msg *xua, uint16_t iei);
void xua_part_add_gt(struct msgb *msg, const struct osmo_sccp_gt *gt);
int xua_msg_add_sccp_addr(struct xua_msg *xua, uint16_t iei, const struct osmo_sccp_addr *addr);
const char *xua_class_msg_name(const struct xua_msg_class *xmc, uint16_t msg_type);
const char *xua_class_iei_name(const struct xua_msg_class *xmc, uint16_t iei);
char *xua_hdr_dump(struct xua_msg *xua, const struct xua_dialect *dialect);
char *xua_msg_dump(struct xua_msg *xua, const struct xua_dialect *dialect);
int xua_dialect_check_all_mand_ies(const struct xua_dialect *dialect, struct xua_msg *xua);
int xua_msg_event_map(const struct xua_msg *xua,
const struct xua_msg_event_map *maps,
unsigned int num_maps);
xua_dialect::log_subsys
int log_subsys
Definition: xua_msg.h:59
version
uint8_t version
Definition: xua_types.h:67
msgb_t16l16vp_put_u32
int msgb_t16l16vp_put_u32(struct msgb *msg, uint16_t tag, uint32_t val)
Definition: xua_msg.c:273
xua_from_nested
struct xua_msg * xua_from_nested(struct xua_msg_part *outer)
Definition: xua_msg.c:186
xua_dialect::port
uint16_t port
Definition: xua_msg.h:57
xua_dialect
Definition: xua_msg.h:55
xua_msg_part::dat
uint8_t * dat
Definition: xua_msg.h:43
msgb_t16l16vp_put
int msgb_t16l16vp_put(struct msgb *msg, uint16_t tag, uint16_t len, const uint8_t *data)
Definition: xua_msg.c:247
xua_msg_part::len
uint16_t len
Definition: xua_msg.h:42
xua_msg_dump
char * xua_msg_dump(struct xua_msg *xua, const struct xua_dialect *dialect)
Definition: xua_msg.c:494
xua_types.h
xua_msg_class::msgt_names
const struct value_string * msgt_names
Definition: xua_msg.h:50
xua_msg_alloc
struct xua_msg * xua_msg_alloc(void)
Definition: xua_msg.c:44
xua_msg_add_data
int xua_msg_add_data(struct xua_msg *msg, uint16_t tag, uint16_t len, uint8_t *dat)
Definition: xua_msg.c:61
xua_msg_get_u32
uint32_t xua_msg_get_u32(struct xua_msg *xua, uint16_t iei)
Definition: xua_msg.c:292
xua_msg_add_u32
int xua_msg_add_u32(struct xua_msg *xua, uint16_t iei, uint32_t val)
Definition: xua_msg.c:280
xua_msg_class::name
const char * name
Definition: xua_msg.h:49
xua_msg_part
Definition: xua_msg.h:38
xua_msg_event_map::msg_type
uint8_t msg_type
Definition: xua_msg.h:65
xua_msg_event_map::msg_class
uint8_t msg_class
Definition: xua_msg.h:64
msg_type
uint8_t msg_type
Definition: xua_types.h:70
xua_msg_event_map
Definition: xua_msg.h:63
xua_from_msg
struct xua_msg * xua_from_msg(const int version, uint16_t len, uint8_t *data)
Definition: xua_msg.c:151
osmo_xua_msg_tall_ctx_init
void osmo_xua_msg_tall_ctx_init(void *ctx)
Definition: xua_msg.c:39
xua_msg_free_tag
int xua_msg_free_tag(struct xua_msg *xua, uint16_t tag)
Definition: xua_msg.c:97
xua_msg_part::tag
uint16_t tag
Definition: xua_msg.h:41
xua_msg_copy_part
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
tag
uint16_t tag
Definition: xua_types.h:67
xua_class_msg_name
const char * xua_class_msg_name(const struct xua_msg_class *xmc, uint16_t msg_type)
Definition: xua_msg.c:410
xua_msg_add_sccp_addr
int xua_msg_add_sccp_addr(struct xua_msg *xua, uint16_t iei, const struct osmo_sccp_addr *addr)
Definition: xua_msg.c:338
xua_dialect_sua
const struct xua_dialect xua_dialect_sua
Definition: sua.c:215
xua_msg_class
Definition: xua_msg.h:48
xua_msg_free
void xua_msg_free(struct xua_msg *msg)
Definition: xua_msg.c:56
xua_to_msg
struct msgb * xua_to_msg(const int version, struct xua_msg *msg)
Definition: xua_msg.c:203
xua_class_iei_name
const char * xua_class_iei_name(const struct xua_msg_class *xmc, uint16_t iei)
Definition: xua_msg.c:422
xua_msg_part_get_u32
uint32_t xua_msg_part_get_u32(struct xua_msg_part *part)
Definition: xua_msg.c:286
xua_msg_event_map::event
int event
Definition: xua_msg.h:66
osmo_mtp_transfer_param
Definition: mtp_sap.h:36
xua_common_hdr
Definition: xua_types.h:31
xua_dialect::name
const char * name
Definition: xua_msg.h:56
osmo_sccp_addr
Definition: sccp_sap.h:151
xua_msg_event_map
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:394
osmo_sccp_gt
Definition: sccp_sap.h:143
xua_msg::hdr
struct xua_common_hdr hdr
Definition: xua_msg.h:32
xua_hdr_dump
char * xua_hdr_dump(struct xua_msg *xua, const struct xua_dialect *dialect)
Definition: xua_msg.c:434
xua_msg
Definition: xua_msg.h:31
data
uint8_t data[0]
Definition: xua_types.h:72
xua_dialect::ppid
uint16_t ppid
Definition: xua_msg.h:58
xua_msg::headers
struct llist_head headers
Definition: xua_msg.h:35
xua_msg_find_tag
struct xua_msg_part * xua_msg_find_tag(const struct xua_msg *msg, uint16_t tag)
Definition: xua_msg.c:86
mtp_sap.h
xua_dialect_check_all_mand_ies
int xua_dialect_check_all_mand_ies(const struct xua_dialect *dialect, struct xua_msg *xua)
Definition: xua_msg.c:449
xua_msg_class::iei_names
const struct value_string * iei_names
Definition: xua_msg.h:51
xua_dialect_m3ua
const struct xua_dialect xua_dialect_m3ua
Definition: m3ua.c:272
len
uint16_t len
Definition: xua_types.h:68
xua_part_add_gt
void xua_part_add_gt(struct msgb *msg, const struct osmo_sccp_gt *gt)
Definition: xua_msg.c:300
xua_msg::mtp
struct osmo_mtp_transfer_param mtp
Definition: xua_msg.h:33