From 8d0343872ecd53e9a9e31984d6588c06e076cb8e Mon Sep 17 00:00:00 2001 From: Max Date: Fri, 9 Nov 2018 15:41:35 +0100 Subject: Make pointcode width function public That's useful for external programs veryfying pointcode validity. For example if used as part of BSS-related identity in GCR construction by LCLS code we should be able to double.check that no significant bits off pointcode are lost/ignored. Change-Id: I5a9981dd2c1d78966c61a3f6b50c7c0d9b542caf --- include/osmocom/sigtran/osmo_ss7.h | 2 ++ src/osmo_ss7.c | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/include/osmocom/sigtran/osmo_ss7.h b/include/osmocom/sigtran/osmo_ss7.h index 414606a..a97e236 100644 --- a/include/osmocom/sigtran/osmo_ss7.h +++ b/include/osmocom/sigtran/osmo_ss7.h @@ -113,6 +113,8 @@ int osmo_ss7_bind_all_instances(); struct osmo_sccp_instance *osmo_ss7_ensure_sccp(struct osmo_ss7_instance *inst); +uint8_t osmo_ss7_pc_width(const struct osmo_ss7_pc_fmt *pc_fmt); + /*********************************************************************** * MTP Users (Users of MTP, such as SCCP or ISUP) ***********************************************************************/ diff --git a/src/osmo_ss7.c b/src/osmo_ss7.c index f97876c..73f8127 100644 --- a/src/osmo_ss7.c +++ b/src/osmo_ss7.c @@ -179,7 +179,7 @@ static unsigned int num_pc_comp_exp(const struct osmo_ss7_pc_fmt *pc_fmt) } /* get the total width (in bits) of the point-codes in this ss7_instance */ -static unsigned int get_pc_width(const struct osmo_ss7_pc_fmt *pc_fmt) +uint8_t osmo_ss7_pc_width(const struct osmo_ss7_pc_fmt *pc_fmt) { return pc_fmt->component_len[0] + pc_fmt->component_len[1] + pc_fmt->component_len[2]; } @@ -189,7 +189,7 @@ static unsigned int get_pc_width(const struct osmo_ss7_pc_fmt *pc_fmt) static unsigned int get_pc_comp_shift(const struct osmo_ss7_pc_fmt *pc_fmt, unsigned int comp_num) { - uint32_t pc_width = get_pc_width(pc_fmt); + uint32_t pc_width = osmo_ss7_pc_width(pc_fmt); switch (comp_num) { case 0: return pc_width - pc_fmt->component_len[0]; @@ -287,7 +287,7 @@ const char *osmo_ss7_pointcode_print2(const struct osmo_ss7_instance *inst, uint int osmo_ss7_pointcode_parse_mask_or_len(struct osmo_ss7_instance *inst, const char *in) { - unsigned int width = get_pc_width(inst ? &inst->cfg.pc_fmt : &default_pc_fmt); + unsigned int width = osmo_ss7_pc_width(inst ? &inst->cfg.pc_fmt : &default_pc_fmt); if (in[0] == '/') { /* parse mask by length */ -- cgit v1.2.3