aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/Makefile.am2
-rw-r--r--include/mtp_level3.h180
-rw-r--r--src/isup.c2
-rw-r--r--src/links.c2
-rw-r--r--src/main.c2
-rw-r--r--src/main_stp.c2
-rw-r--r--src/mtp_layer3.c6
-rw-r--r--src/mtp_link.c2
-rw-r--r--src/sccp_state.c2
-rw-r--r--src/sctp_m3ua_client.c1
-rw-r--r--tests/mtp/Makefile.am2
-rw-r--r--tests/mtp/mtp_parse_test.c10
12 files changed, 16 insertions, 197 deletions
diff --git a/include/Makefile.am b/include/Makefile.am
index aff4e37..db4f76d 100644
--- a/include/Makefile.am
+++ b/include/Makefile.am
@@ -1,4 +1,4 @@
-noinst_HEADERS = mtp_level3.h mtp_data.h ipaccess.h thread.h mtp_pcap.h \
+noinst_HEADERS = mtp_data.h ipaccess.h thread.h mtp_pcap.h \
mgcp_ss7.h bss_patch.h bssap_sccp.h bsc_data.h udp_input.h \
snmp_mtp.h cellmgr_debug.h bsc_sccp.h bsc_ussd.h sctp_m2ua.h \
isup_types.h counter.h msc_connection.h ss7_application.h \
diff --git a/include/mtp_level3.h b/include/mtp_level3.h
deleted file mode 100644
index f311ad5..0000000
--- a/include/mtp_level3.h
+++ /dev/null
@@ -1,180 +0,0 @@
-/* Q.701-Q.704, Q.706, Q.707 handling code */
-/*
- * (C) 2010 by Holger Hans Peter Freyther <zecke@selfish.org>
- * (C) 2010 by On-Waves
- * All Rights Reserved
- *
- * 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 mtp_level3_h
-#define mtp_level3_h
-
-#include <stdint.h>
-#include <endian.h>
-#include <sys/types.h>
-
-
-/*
- * pssible service information octets..
- */
-#define MTP_NI_NATION_NET 0x02
-
-#define MTP_SI_MNT_SNM_MSG 0x00
-#define MTP_SI_MNT_REG_MSG 0x01
-#define MTP_SI_MNT_SCCP 0x03
-#define MTP_SI_MNT_ISUP 0x05
-
-/*
- * h0 contains the group, h1 the semantic of it
- */
-
-#define MTP_TST_MSG_GRP 0x01
-#define MTP_PROHIBIT_MSG_GRP 0x04
-#define MTP_SROUTE_MSG_GRP 0x05
-#define MTP_TRF_RESTR_MSG_GRP 0x07
-
-/* h1 values for different groups */
-#define MTP_TST_MSG_SLTM 0x01
-#define MTP_TST_MSG_SLTA 0x02
-
-#define MTP_RESTR_MSG_ALLWED 0x01
-
-/* For the prohibit group */
-#define MTP_PROHIBIT_MSG_SIG 0x01
-#define MTP_PROHIBIT_MSG_TFA 0x05
-
-/* For the Signalling-route-set-test */
-#define MTP_SROUTE_MSG_TEST 0x01
-
-
-#define SCCP_SST 0x03
-#define SCCP_SSP 0x02
-#define SCCP_SSA 0x01
-
-#define MTP_LINK_MASK 0x0F
-#define MTP_ADDR_MASK 0x3FFF
-#define MTP_APOC_MASK 0x3f
-
-
-#if __BYTE_ORDER == __LITTLE_ENDIAN
-#define MTP_LINK_SLS(addr) ((addr >>28) & MTP_LINK_MASK)
-#define MTP_ADDR(link, dpc, opc) \
- (((dpc) & MTP_ADDR_MASK) << 0 | \
- ((opc) & MTP_ADDR_MASK) << 14| \
- ((link) & MTP_LINK_MASK) << 28)
-#define MTP_MAKE_APOC(apoc) \
- (apoc & 0x3fff)
-#define MTP_ADDR_DPC(addr) \
- (addr & MTP_ADDR_MASK)
-#define MTP_ADDR_OPC(addr) \
- ((addr >> 14) & MTP_ADDR_MASK)
-#elif __BYTE_ORDER == __BIG_ENDIAN
-static inline uint32_t c_swap_32(uint32_t in)
-{
- return (((in & 0x000000ff) << 24) |
- ((in & 0x0000ff00) << 8) |
- ((in & 0x00ff0000) >> 8) |
- ((in & 0xff000000) >> 24));
-}
-static inline uint16_t c_swap_16(uint16_t in)
-{
- return (((in & 0x00ff) << 8) |
- (in & 0xff00) >> 8);
-}
-#define MTP_LINK_SLS(addr) ((c_swap_32(addr)>>28) & MTP_LINK_MASK)
-#define MTP_ADDR(link, dpc, opc) \
- c_swap_32(((dpc) & MTP_ADDR_MASK) << 0 | \
- ((opc) & MTP_ADDR_MASK) << 14| \
- ((link) & MTP_LINK_MASK) << 28)
-#define MTP_MAKE_APOC(apoc) \
- c_swap_16((apoc & 0x3fff))
-#define MTP_ADDR_DPC(addr) \
- (c_swap_32(addr) & MTP_ADDR_MASK)
-#define MTP_ADDR_OPC(addr) \
- ((c_swap_32(addr) >> 14) & MTP_ADDR_MASK)
-#endif
-
-
-
-/*
- * not the on wire address...
- */
-struct mtp_addr {
- uint16_t dpc;
- uint16_t opc;
- uint8_t link;
-} __attribute__((packed));
-
-/*
- * the struct is defined in Q.704 and can be seen in the
- * wireshark dissectors too
- */
-struct mtp_level_3_hdr {
-#if __BYTE_ORDER == __LITTLE_ENDIAN
- uint8_t ser_ind : 4,
- spare : 2,
- ni : 2;
-#elif __BYTE_ORDER == __BIG_ENDIAN
- uint8_t ni : 2,
- spare : 2,
- ser_ind : 4;
-#endif
- uint32_t addr;
- uint8_t data[0];
-} __attribute__((packed));
-
-struct mtp_level_3_cmn {
-#if __BYTE_ORDER == __LITTLE_ENDIAN
- uint8_t h0 : 4,
- h1 : 4;
-#elif __BYTE_ORDER == __BIG_ENDIAN
- uint8_t h1 : 4,
- h0 : 4;
-#endif
-} __attribute__((packed));
-
-struct mtp_level_3_mng {
- struct mtp_level_3_cmn cmn;
-#if __BYTE_ORDER == __LITTLE_ENDIAN
- uint8_t spare : 4,
- length : 4;
-#elif __BYTE_ORDER == __BIG_ENDIAN
- uint8_t length : 4,
- spare : 4;
-#endif
- uint8_t data[0];
-} __attribute__((packed));
-
-struct mtp_level_3_prohib {
- struct mtp_level_3_cmn cmn;
-
- uint16_t apoc;
-} __attribute__((packed));
-
-struct sccp_con_ctrl_prt_mgt {
- uint8_t sst;
- uint8_t assn; /* affected sub system number */
- uint16_t apoc;
-#if __BYTE_ORDER == __LITTLE_ENDIAN
- uint8_t mul_ind : 2,
- spare : 6;
-#elif __BYTE_ORDER == __BIG_ENDIAN
- uint8_t spare : 6,
- mul_ind : 2;
-#endif
-} __attribute__((packed));
-
-#endif
diff --git a/src/isup.c b/src/isup.c
index 2827f21..7fe9e23 100644
--- a/src/isup.c
+++ b/src/isup.c
@@ -21,7 +21,7 @@
#include <isup_types.h>
#include <cellmgr_debug.h>
#include <mtp_data.h>
-#include <mtp_level3.h>
+#include <osmocom/mtp/mtp_level3.h>
#include <osmocom/core/msgb.h>
#include <osmocom/gsm/tlv.h>
diff --git a/src/links.c b/src/links.c
index 1b97e58..febfa56 100644
--- a/src/links.c
+++ b/src/links.c
@@ -24,7 +24,7 @@
#include <cellmgr_debug.h>
#include <msc_connection.h>
#include <mtp_data.h>
-#include <mtp_level3.h>
+#include <osmocom/mtp/mtp_level3.h>
#include <mtp_pcap.h>
#include <snmp_mtp.h>
diff --git a/src/main.c b/src/main.c
index 5f5611b..bafdc39 100644
--- a/src/main.c
+++ b/src/main.c
@@ -21,7 +21,7 @@
#include <mtp_data.h>
#include <msc_connection.h>
-#include <mtp_level3.h>
+#include <osmocom/mtp/mtp_level3.h>
#include <thread.h>
#include <bss_patch.h>
#include <bssap_sccp.h>
diff --git a/src/main_stp.c b/src/main_stp.c
index 0cd7824..8a9e10e 100644
--- a/src/main_stp.c
+++ b/src/main_stp.c
@@ -21,7 +21,7 @@
*/
#include <mtp_data.h>
-#include <mtp_level3.h>
+#include <osmocom/mtp/mtp_level3.h>
#include <mtp_pcap.h>
#include <thread.h>
#include <bsc_data.h>
diff --git a/src/mtp_layer3.c b/src/mtp_layer3.c
index 238a3f1..c4bbab4 100644
--- a/src/mtp_layer3.c
+++ b/src/mtp_layer3.c
@@ -19,7 +19,7 @@
*
*/
#include <mtp_data.h>
-#include <mtp_level3.h>
+#include <osmocom/mtp/mtp_level3.h>
#include <bsc_data.h>
#include <cellmgr_debug.h>
#include <isup_types.h>
@@ -368,9 +368,9 @@ static int mtp_link_regular_msg(struct mtp_link *link, struct mtp_level_3_hdr *h
return -1;
}
- if (MTP_ADDR_DPC(hdr->addr) != link->set->opc) {
+ if (MTP_READ_DPC(hdr->addr) != link->set->opc) {
LOGP(DINP, LOGL_ERROR, "MSG for OPC %d not handled on %d/%s\n",
- MTP_ADDR_DPC(hdr->addr), link->set->nr, link->set->name);
+ MTP_READ_DPC(hdr->addr), link->set->nr, link->set->name);
return -1;
}
diff --git a/src/mtp_link.c b/src/mtp_link.c
index 9b84e63..858bf4a 100644
--- a/src/mtp_link.c
+++ b/src/mtp_link.c
@@ -20,7 +20,7 @@
*/
#include <mtp_data.h>
-#include <mtp_level3.h>
+#include <osmocom/mtp/mtp_level3.h>
#include <cellmgr_debug.h>
#include <counter.h>
diff --git a/src/sccp_state.c b/src/sccp_state.c
index a788580..49cf49a 100644
--- a/src/sccp_state.c
+++ b/src/sccp_state.c
@@ -21,7 +21,7 @@
#include <mtp_data.h>
#include <msc_connection.h>
-#include <mtp_level3.h>
+#include <osmocom/mtp/mtp_level3.h>
#include <bss_patch.h>
#include <bssap_sccp.h>
#include <bsc_data.h>
diff --git a/src/sctp_m3ua_client.c b/src/sctp_m3ua_client.c
index cb9fab3..972738c 100644
--- a/src/sctp_m3ua_client.c
+++ b/src/sctp_m3ua_client.c
@@ -19,7 +19,6 @@
#include <cellmgr_debug.h>
#include <string.h>
#include <bsc_data.h>
-#include <mtp_level3.h>
#include <osmocom/sigtran/xua_msg.h>
#include <osmocom/sigtran/m3ua_types.h>
diff --git a/tests/mtp/Makefile.am b/tests/mtp/Makefile.am
index 3490641..21cc2c0 100644
--- a/tests/mtp/Makefile.am
+++ b/tests/mtp/Makefile.am
@@ -1,4 +1,4 @@
-AM_CPPFLAGS = $(all_includes) -I$(top_srcdir)/include -Wall
+AM_CPPFLAGS = $(all_includes) -I$(top_srcdir)/include $(LIBOSMOCORE_CFLAGS) -Wall
noinst_PROGRAMS = mtp_parse_test
EXTRA_DIST = mtp_parse_test.ok
diff --git a/tests/mtp/mtp_parse_test.c b/tests/mtp/mtp_parse_test.c
index e21baed..c13d295 100644
--- a/tests/mtp/mtp_parse_test.c
+++ b/tests/mtp/mtp_parse_test.c
@@ -1,5 +1,5 @@
/* MTP Layer3 parsing tests */
-#include <mtp_level3.h>
+#include <osmocom/mtp/mtp_level3.h>
#include <arpa/inet.h>
@@ -590,14 +590,14 @@ int main(int argc, char **argv)
tests[2].prohib.apoc = MTP_MAKE_APOC(86);
addr = MTP_ADDR(0x00, 0x2AAA, 0x1555);
- if (MTP_ADDR_OPC(addr) != 0x1555) {
+ if (MTP_READ_OPC(addr) != 0x1555) {
fprintf(stderr, "Failed to extract OPC: %d\n",
- MTP_ADDR_OPC(addr));
+ MTP_READ_OPC(addr));
abort();
}
- if (MTP_ADDR_DPC(addr) != 0x2AAA) {
+ if (MTP_READ_DPC(addr) != 0x2AAA) {
fprintf(stderr, "Failed to extract DPC: %d\n",
- MTP_ADDR_DPC(addr));
+ MTP_READ_DPC(addr));
abort();
}