aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <zecke@selfish.org>2010-08-04 18:51:16 +0800
committerHolger Hans Peter Freyther <zecke@selfish.org>2010-08-04 18:51:16 +0800
commite66c7c10ea1c34590992af4ac96455e4214b9eae (patch)
treec2e1e7d3e8d353f60e98ed70ba1818a28529189d /src
parentcf381e244726348d8a792f1bba3f09fb91908cb8 (diff)
cleanup: Remove code that is provided by libosmocore now.
libosmocore contains the GSM08.08 definition, no need to copy that anymore.
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am3
-rw-r--r--src/bss_patch.c5
-rw-r--r--src/bssap_sccp.c3
-rw-r--r--src/main.c3
-rw-r--r--src/openbsc_nat/bssap.c65
-rw-r--r--src/openbsc_nat/tlv_parser.c160
6 files changed, 6 insertions, 233 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index bf92f05..2657809 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -10,8 +10,7 @@ mgcp_mgw_LDADD = $(LAFORGE_LIBS) $(NEXUSWARE_C7_LIBS) $(NEXUSWARE_UNIPORTE_LIBS)
$(LIBOSMOVTY_LIBS) $(LIBOSMOCORE_LIBS) -lpthread
cellmgr_ng_SOURCES = main.c mtp_layer3.c thread.c input/ipaccess.c pcap.c \
- bss_patch.c \
- openbsc_nat/bssap.c openbsc_nat/tlv_parser.c bssap_sccp.c \
+ bss_patch.c bssap_sccp.c \
msc_conn.c link_udp.c snmp_mtp.c debug.c
cellmgr_ng_LDADD = $(LIBOSMOCORE_LIBS) $(LIBOSMOSCCP_LIBS) $(LIBOSMOVTY_LIBS) $(NEXUSWARE_C7_LIBS) \
-lpthread -lnetsnmp -lcrypto
diff --git a/src/bss_patch.c b/src/bss_patch.c
index 5994b9e..88280e2 100644
--- a/src/bss_patch.c
+++ b/src/bss_patch.c
@@ -25,8 +25,9 @@
#include <string.h>
-#include <openbsc_nat/bssap.h>
-#include <openbsc_nat/tlv.h>
+#include <osmocore/gsm0808.h>
+#include <osmocore/protocol/gsm_08_08.h>
+
#include <osmocom/sccp/sccp.h>
#include <arpa/inet.h>
diff --git a/src/bssap_sccp.c b/src/bssap_sccp.c
index 3f4a8dd..3ae80a5 100644
--- a/src/bssap_sccp.c
+++ b/src/bssap_sccp.c
@@ -24,8 +24,7 @@
#include <cellmgr_debug.h>
#include <osmocore/msgb.h>
-
-#include <openbsc_nat/bssap.h>
+#include <osmocore/protocol/gsm_08_08.h>
#include <string.h>
diff --git a/src/main.c b/src/main.c
index 0df22a1..8ce1330 100644
--- a/src/main.c
+++ b/src/main.c
@@ -30,12 +30,11 @@
#include <cellmgr_debug.h>
#include <osmocore/talloc.h>
+#include <osmocore/protocol/gsm_08_08.h>
#include <osmocom/vty/command.h>
#include <osmocom/vty/vty.h>
-#include <openbsc_nat/bssap.h>
-
#include <sys/stat.h>
#include <sys/types.h>
diff --git a/src/openbsc_nat/bssap.c b/src/openbsc_nat/bssap.c
deleted file mode 100644
index 2d23a9f..0000000
--- a/src/openbsc_nat/bssap.c
+++ /dev/null
@@ -1,65 +0,0 @@
-/* GSM 08.08 BSSMAP handling */
-/* (C) 2009 by Holger Hans Peter Freyther <zecke@selfish.org>
- * (C) 2009 by on-waves.com
- * All Rights Reserved
- *
- * 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, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- */
-
-#include <openbsc_nat/bssap.h>
-#include <openbsc_nat/tlv.h>
-
-#include <osmocom/sccp/sccp.h>
-
-#include <arpa/inet.h>
-#include <assert.h>
-
-
-#define BSSMAP_MSG_SIZE 512
-#define BSSMAP_MSG_HEADROOM 128
-
-
-static const struct tlv_definition bss_att_tlvdef = {
- .def = {
- [GSM0808_IE_IMSI] = { TLV_TYPE_TLV },
- [GSM0808_IE_TMSI] = { TLV_TYPE_TLV },
- [GSM0808_IE_CELL_IDENTIFIER_LIST] = { TLV_TYPE_TLV },
- [GSM0808_IE_CHANNEL_NEEDED] = { TLV_TYPE_TV },
- [GSM0808_IE_EMLPP_PRIORITY] = { TLV_TYPE_TV },
- [GSM0808_IE_CHANNEL_TYPE] = { TLV_TYPE_TLV },
- [GSM0808_IE_PRIORITY] = { TLV_TYPE_TLV },
- [GSM0808_IE_CIRCUIT_IDENTITY_CODE] = { TLV_TYPE_TV },
- [GSM0808_IE_DOWNLINK_DTX_FLAG] = { TLV_TYPE_TV },
- [GSM0808_IE_INTERFERENCE_BAND_TO_USE] = { TLV_TYPE_TV },
- [GSM0808_IE_CLASSMARK_INFORMATION_T2] = { TLV_TYPE_TLV },
- [GSM0808_IE_GROUP_CALL_REFERENCE] = { TLV_TYPE_TLV },
- [GSM0808_IE_TALKER_FLAG] = { TLV_TYPE_T },
- [GSM0808_IE_CONFIG_EVO_INDI] = { TLV_TYPE_TV },
- [GSM0808_IE_LSA_ACCESS_CTRL_SUPPR] = { TLV_TYPE_TV },
- [GSM0808_IE_SERVICE_HANDOVER] = { TLV_TYPE_TV},
- [GSM0808_IE_ENCRYPTION_INFORMATION] = { TLV_TYPE_TLV },
- [GSM0808_IE_CIPHER_RESPONSE_MODE] = { TLV_TYPE_TV },
- [GSM0808_IE_SPEECH_VERSION] = { TLV_TYPE_TV },
- [GSM0808_IE_CHOSEN_ENCR_ALG] = { TLV_TYPE_TV },
- [GSM0808_IE_CHOSEN_CHANNEL] = { TLV_TYPE_TV },
- },
-};
-
-const struct tlv_definition *gsm0808_att_tlvdef()
-{
- return &bss_att_tlvdef;
-}
-
diff --git a/src/openbsc_nat/tlv_parser.c b/src/openbsc_nat/tlv_parser.c
deleted file mode 100644
index 9b38b9f..0000000
--- a/src/openbsc_nat/tlv_parser.c
+++ /dev/null
@@ -1,160 +0,0 @@
-#include <stdio.h>
-#include <openbsc_nat/tlv.h>
-
-#ifndef ARRAY_SIZE
-#define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0]))
-#endif
-
-struct tlv_definition tvlv_att_def;
-
-int tlv_dump(struct tlv_parsed *dec)
-{
- int i;
-
- for (i = 0; i <= 0xff; i++) {
- if (!dec->lv[i].val)
- continue;
- printf("T=%02x L=%d\n", i, dec->lv[i].len);
- }
- return 0;
-}
-
-/* o_tag: output: tag found
- * o_len: output: length of the data
- * o_val: output: pointer to the data
- * def: input: a structure defining the valid TLV tags / configurations
- * buf: input: the input data buffer to be parsed
- * buf_len: input: the length of the input data buffer
- *
- * Also, returns the number of bytes consumed by the TLV entry
- */
-int tlv_parse_one(uint8_t *o_tag, uint16_t *o_len, const uint8_t **o_val,
- const struct tlv_definition *def,
- const uint8_t *buf, int buf_len)
-{
- uint8_t tag;
- int len;
-
- tag = *buf;
- *o_tag = tag;
-
- /* FIXME: use tables for knwon IEI */
- switch (def->def[tag].type) {
- case TLV_TYPE_T:
- /* GSM TS 04.07 11.2.4: Type 1 TV or Type 2 T */
- *o_val = buf;
- *o_len = 0;
- len = 1;
- break;
- case TLV_TYPE_TV:
- *o_val = buf+1;
- *o_len = 1;
- len = 2;
- break;
- case TLV_TYPE_FIXED:
- *o_val = buf+1;
- *o_len = def->def[tag].fixed_len;
- len = def->def[tag].fixed_len + 1;
- break;
- case TLV_TYPE_TLV:
- /* GSM TS 04.07 11.2.4: Type 4 TLV */
- if (buf + 1 > buf + buf_len)
- return -1;
- *o_val = buf+2;
- *o_len = *(buf+1);
- len = *o_len + 2;
- if (len > buf_len)
- return -2;
- break;
- case TLV_TYPE_TvLV:
- if (*(buf+1) & 0x80) {
- /* like TLV, but without highest bit of len */
- if (buf + 1 > buf + buf_len)
- return -1;
- *o_val = buf+2;
- *o_len = *(buf+1) & 0x7f;
- len = *o_len + 2;
- if (len > buf_len)
- return -2;
- break;
- }
- /* like TL16V, fallthrough */
- case TLV_TYPE_TL16V:
- if (2 > buf_len)
- return -1;
- *o_val = buf+3;
- *o_len = *(buf+1) << 8 | *(buf+2);
- len = *o_len + 3;
- if (len > buf_len)
- return -2;
- break;
- default:
- return -3;
- }
-
- return len;
-}
-
-/* dec: output: a caller-allocated pointer to a struct tlv_parsed,
- * def: input: a structure defining the valid TLV tags / configurations
- * buf: input: the input data buffer to be parsed
- * buf_len: input: the length of the input data buffer
- * lv_tag: input: an initial LV tag at the start of the buffer
- * lv_tag2: input: a second initial LV tag following lv_tag
- */
-int tlv_parse(struct tlv_parsed *dec, const struct tlv_definition *def,
- const uint8_t *buf, int buf_len, uint8_t lv_tag,
- uint8_t lv_tag2)
-{
- int ofs = 0, num_parsed = 0;
- uint16_t len;
-
- memset(dec, 0, sizeof(*dec));
-
- if (lv_tag) {
- if (ofs > buf_len)
- return -1;
- dec->lv[lv_tag].val = &buf[ofs+1];
- dec->lv[lv_tag].len = buf[ofs];
- len = dec->lv[lv_tag].len + 1;
- if (ofs + len > buf_len)
- return -2;
- num_parsed++;
- ofs += len;
- }
- if (lv_tag2) {
- if (ofs > buf_len)
- return -1;
- dec->lv[lv_tag2].val = &buf[ofs+1];
- dec->lv[lv_tag2].len = buf[ofs];
- len = dec->lv[lv_tag2].len + 1;
- if (ofs + len > buf_len)
- return -2;
- num_parsed++;
- ofs += len;
- }
-
- while (ofs < buf_len) {
- int rv;
- uint8_t tag;
- const uint8_t *val;
-
- rv = tlv_parse_one(&tag, &len, &val, def,
- &buf[ofs], buf_len-ofs);
- if (rv < 0)
- return rv;
- dec->lv[tag].val = val;
- dec->lv[tag].len = len;
- ofs += rv;
- num_parsed++;
- }
- //tlv_dump(dec);
- return num_parsed;
-}
-
-static __attribute__((constructor)) void on_dso_load_tlv(void)
-{
- int i;
- for (i = 0; i < ARRAY_SIZE(tvlv_att_def.def); i++)
- tvlv_att_def.def[i].type = TLV_TYPE_TvLV;
-}