diff options
author | Ruben Undheim <ruben.undheim@gmail.com> | 2018-07-20 22:28:06 +0200 |
---|---|---|
committer | Ruben Undheim <ruben.undheim@gmail.com> | 2018-07-20 22:30:32 +0200 |
commit | 616f07068ce1d53ec1dda14b3ac25c9799f4cecc (patch) | |
tree | 94d84ee18abfd3a76940a4acc219b053f0832d5a /contrib |
Imported 1.2.1
Diffstat (limited to 'contrib')
-rw-r--r-- | contrib/a-link/sccp-split-by-con.lua | 170 | ||||
-rwxr-xr-x | contrib/jenkins.sh | 52 | ||||
-rw-r--r-- | contrib/systemd/osmo-bsc.service | 12 |
3 files changed, 234 insertions, 0 deletions
diff --git a/contrib/a-link/sccp-split-by-con.lua b/contrib/a-link/sccp-split-by-con.lua new file mode 100644 index 0000000..f5d5502 --- /dev/null +++ b/contrib/a-link/sccp-split-by-con.lua @@ -0,0 +1,170 @@ +-- Split trace based on SCCP Source +-- There are still bugs to find... bugs bugs bugs... hmm +do + local function init_listener() + print("CREATED LISTENER") + local tap = Listener.new("ip", "sccp && (ip.src == 172.16.1.81 || ip.dst == 172.16.1.81)") + local sccp_type_field = Field.new("sccp.message_type") + local sccp_src_field = Field.new("sccp.slr") + local sccp_dst_field = Field.new("sccp.dlr") + local msg_type_field = Field.new("gsm_a.dtap_msg_mm_type") + local lu_rej_field = Field.new("gsm_a.dtap.rej_cause") + local ip_src_field = Field.new("ip.src") + local ip_dst_field = Field.new("ip.dst") + + -- + local bssmap_msgtype_field = Field.new("gsm_a.bssmap_msgtype") + -- assignment failure 0x03 + -- + + -- + local dtap_cause_field = Field.new("gsm_a_dtap.cause") + local dtap_cc_field = Field.new("gsm_a.dtap_msg_cc_type") + + local connections = {} + + function check_failure(con) + check_lu_reject(con) + check_disconnect(con) + check_failures(con) + end + + -- cipher mode reject + function check_failures(con) + local msgtype = bssmap_msgtype_field() + if not msgtype then + return + end + + msgtype = tonumber(msgtype) + if msgtype == 89 then + print("Cipher mode reject") + con[4] = true + elseif msgtype == 0x03 then + print("Assignment failure") + con[4] = true + elseif msgtype == 0x22 then + print("Clear Request... RF failure?") + con[4] = true + end + end + + -- check if a DISCONNECT is normal + function check_disconnect(con) + local msg_type = dtap_cc_field() + if not msg_type then + return + end + + if tonumber(msg_type) ~= 0x25 then + return + end + + local cause = dtap_cause_field() + if not cause then + return + end + + cause = tonumber(cause) + if cause ~= 0x10 then + print("DISCONNECT != Normal") + con[4] = true + end + end + + -- check if we have a LU Reject + function check_lu_reject(con) + local msg_type = msg_type_field() + if not msg_type then + return + end + + msg_type = tonumber(tostring(msg_type)) + if msg_type == 0x04 then + print("LU REJECT with " .. tostring(lu_rej_field())) + con[4] = true + end + end + + function tap.packet(pinfo,tvb,ip) + local ip_src = tostring(ip_src_field()) + local ip_dst = tostring(ip_dst_field()) + local sccp_type = tonumber(tostring(sccp_type_field())) + local sccp_src = sccp_src_field() + local sccp_dst = sccp_dst_field() + + local con + + if sccp_type == 0x01 then + elseif sccp_type == 0x2 then + local src = string.format("%s-%s", ip_src, tostring(sccp_src)) + local dst = string.format("%s-%s", ip_dst, tostring(sccp_dst)) + local datestring = os.date("%Y%m%d%H%M%S") + local pcap_name = string.format("alink_trace_%s-%s_%s.pcap", src, dst, datestring) + local dumper = Dumper.new_for_current(pcap_name) + + local con = { ip_src, tostring(sccp_src), tostring(sccp_dst), false, dumper, pcap_name } + + dumper:dump_current() + connections[src] = con + connections[dst] = con + elseif sccp_type == 0x4 then + -- close a connection... remove it from the list + local src = string.format("%s-%s", ip_src, tostring(sccp_src)) + local dst = string.format("%s-%s", ip_dst, tostring(sccp_dst)) + + local con = connections[src] + if not con then + return + end + + con[5]:dump_current() + con[5]:flush() + + -- this causes a crash on unpacted wireshark + con[5]:close() + + -- the connection had a failure + if con[4] == true then + local datestring = os.date("%Y%m%d%H%M%S") + local new_name = string.format("alink_failure_%s_%s-%s.pcap", datestring, con[2], con[3]) + os.rename(con[6], new_name) + else + os.remove(con[6]) + end + + + -- clear the old connection + connections[src] = nil + connections[dst] = nil + + elseif sccp_type == 0x5 then + -- not handled yet... we should verify stuff here... + local dst = string.format("%s-%s", ip_dst, tostring(sccp_dst)) + local con = connections[dst] + if not con then + return + end + con[5]:dump_current() + elseif sccp_type == 0x6 then + local dst = string.format("%s-%s", ip_dst, tostring(sccp_dst)) + local con = connections[dst] + if not con then + print("DON'T KNOW THIS CONNECTION for " .. ip_dst) + return + end + con[5]:dump_current() + check_failure(con) + end + + end + function tap.draw() + print("DRAW") + end + function tap.reset() + print("RESET") + end + end + + init_listener() +end diff --git a/contrib/jenkins.sh b/contrib/jenkins.sh new file mode 100755 index 0000000..0be4fe0 --- /dev/null +++ b/contrib/jenkins.sh @@ -0,0 +1,52 @@ +#!/usr/bin/env bash +# jenkins build helper script for openbsc. This is how we build on jenkins.osmocom.org + +if ! [ -x "$(command -v osmo-build-dep.sh)" ]; then + echo "Error: We need to have scripts/osmo-deps.sh from http://git.osmocom.org/osmo-ci/ in PATH !" + exit 2 +fi + + +set -ex + +base="$PWD" +deps="$base/deps" +inst="$deps/install" +export deps inst + +osmo-clean-workspace.sh + +mkdir "$deps" || true + +osmo-build-dep.sh libosmocore "" '--disable-doxygen --enable-gnutls' + +verify_value_string_arrays_are_terminated.py $(find . -name "*.[hc]") + +export PKG_CONFIG_PATH="$inst/lib/pkgconfig:$PKG_CONFIG_PATH" +export LD_LIBRARY_PATH="$inst/lib" + +osmo-build-dep.sh libosmo-abis +osmo-build-dep.sh libosmo-netif +osmo-build-dep.sh libosmo-sccp +osmo-build-dep.sh osmo-mgw + +set +x +echo +echo +echo +echo " =============================== osmo-bsc ===============================" +echo +set -x + +cd "$base" +autoreconf --install --force +./configure --enable-sanitize --enable-external-tests --enable-werror +$MAKE $PARALLEL_MAKE +LD_LIBRARY_PATH="$inst/lib" $MAKE check \ + || cat-testlogs.sh +LD_LIBRARY_PATH="$inst/lib" \ + DISTCHECK_CONFIGURE_FLAGS="--enable-vty-tests --enable-external-tests --enable-werror" \ + $MAKE distcheck \ + || cat-testlogs.sh + +osmo-clean-workspace.sh diff --git a/contrib/systemd/osmo-bsc.service b/contrib/systemd/osmo-bsc.service new file mode 100644 index 0000000..67dcd7e --- /dev/null +++ b/contrib/systemd/osmo-bsc.service @@ -0,0 +1,12 @@ +[Unit] +Description=Osmocom Base Station Controller (BSC) +Wants=osmo-mgw.service + +[Service] +Type=simple +Restart=always +ExecStart=/usr/bin/osmo-bsc -c /etc/osmocom/osmo-bsc.cfg -s +RestartSec=2 + +[Install] +WantedBy=multi-user.target |