aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc/src
diff options
context:
space:
mode:
authorNeels Hofmeyr <nhofmeyr@sysmocom.de>2016-03-31 16:14:13 +0200
committerNeels Hofmeyr <nhofmeyr@sysmocom.de>2016-03-31 16:14:13 +0200
commitb70dfa610d89786aa72a4adb4ffc1ba27a5f8af4 (patch)
tree46b8ad0e9463c83b3a36344dc0ae050adc6ed358 /openbsc/src
parent4b940126a3132ac6d6da4194229f2b8cb642c2ec (diff)
parentcf1302e4cb4875816615a23e5d7e2e9f7bcb5bca (diff)
Merge branch 'master' into sysmocom/iu
Conflicts: openbsc/src/libmsc/auth.c openbsc/src/libmsc/gsm_04_08.c openbsc/src/osmo-bsc/osmo_bsc_vty.c openbsc/tests/Makefile.am
Diffstat (limited to 'openbsc/src')
-rw-r--r--openbsc/src/gprs/gprs_gmm.c2
-rw-r--r--openbsc/src/libmgcp/mgcp_transcode.c8
-rw-r--r--openbsc/src/libmsc/auth.c33
-rw-r--r--openbsc/src/osmo-bsc/osmo_bsc_vty.c4
-rw-r--r--openbsc/src/utils/meas_db.c13
5 files changed, 35 insertions, 25 deletions
diff --git a/openbsc/src/gprs/gprs_gmm.c b/openbsc/src/gprs/gprs_gmm.c
index 630810aaa..6ece0e9ab 100644
--- a/openbsc/src/gprs/gprs_gmm.c
+++ b/openbsc/src/gprs/gprs_gmm.c
@@ -2400,7 +2400,7 @@ int gsm0408_gprs_rcvmsg_iu(struct msgb *msg, struct gprs_ra_id *ra_id,
uint16_t *sai)
{
struct gsm48_hdr *gh = (struct gsm48_hdr *) msgb_gmmh(msg);
- uint8_t pdisc = gh->proto_discr & 0x0f;
+ uint8_t pdisc = gsm48_hdr_pdisc(gh);
struct sgsn_mm_ctx *mmctx;
int rc = -EINVAL;
diff --git a/openbsc/src/libmgcp/mgcp_transcode.c b/openbsc/src/libmgcp/mgcp_transcode.c
index c994d3291..f31e7aefb 100644
--- a/openbsc/src/libmgcp/mgcp_transcode.c
+++ b/openbsc/src/libmgcp/mgcp_transcode.c
@@ -330,7 +330,7 @@ static int decode_audio(struct mgcp_process_rtp_state *state,
while (*nbytes >= state->src_frame_size) {
if (state->sample_cnt + state->src_samples_per_frame > ARRAY_SIZE(state->samples)) {
LOGP(DMGCP, LOGL_ERROR,
- "Sample buffer too small: %d > %d.\n",
+ "Sample buffer too small: %zu > %zu.\n",
state->sample_cnt + state->src_samples_per_frame,
ARRAY_SIZE(state->samples));
return -ENOSPC;
@@ -388,7 +388,7 @@ static int encode_audio(struct mgcp_process_rtp_state *state,
/* Not even one frame fits into the buffer */
LOGP(DMGCP, LOGL_INFO,
- "Encoding (RTP) buffer too small: %d > %d.\n",
+ "Encoding (RTP) buffer too small: %zu > %zu.\n",
nbytes + state->dst_frame_size, buf_size);
return -ENOSPC;
}
@@ -540,7 +540,7 @@ int mgcp_transcoding_process_rtp(struct mgcp_endpoint *endp,
* instead if the delta is small enough.
*/
LOGP(DMGCP, LOGL_NOTICE,
- "0x%x dropping sample buffer due delta=%d sample_cnt=%d\n",
+ "0x%x dropping sample buffer due delta=%d sample_cnt=%zu\n",
ENDPOINT_NUMBER(endp), delta, state->sample_cnt);
state->sample_cnt = 0;
state->next_time = ts_no;
@@ -569,7 +569,7 @@ int mgcp_transcoding_process_rtp(struct mgcp_endpoint *endp,
if (nbytes > 0)
LOGP(DMGCP, LOGL_NOTICE,
- "Skipped audio frame in RTP packet: %d octets\n",
+ "Skipped audio frame in RTP packet: %zu octets\n",
nbytes);
} else
ts_no = state->next_time;
diff --git a/openbsc/src/libmsc/auth.c b/openbsc/src/libmsc/auth.c
index 3d036950f..2d42c2dfe 100644
--- a/openbsc/src/libmsc/auth.c
+++ b/openbsc/src/libmsc/auth.c
@@ -31,6 +31,15 @@
#include <stdlib.h>
+const struct value_string auth_action_names[] = {
+#define AUTH_ACTION_STR(X) { X, #X }
+ AUTH_ACTION_STR(AUTH_ERROR),
+ AUTH_ACTION_STR(AUTH_NOT_AVAIL),
+ AUTH_ACTION_STR(AUTH_DO_AUTH_THEN_CIPH),
+ AUTH_ACTION_STR(AUTH_DO_CIPH),
+ AUTH_ACTION_STR(AUTH_DO_AUTH),
+#undef AUTH_ACTION_STR
+};
static int
_use_xor(struct gsm_auth_info *ainfo, struct gsm_auth_tuple *atuple)
@@ -82,13 +91,14 @@ int auth_get_tuple_for_subscr(struct gsm_auth_tuple *atuple,
/* Get subscriber info (if any) */
rc = db_get_authinfo_for_subscr(&ainfo, subscr);
if (rc < 0) {
- return rc == -ENOENT ? AUTH_NOT_AVAIL : -1;
+ return rc == -ENOENT ? AUTH_NOT_AVAIL : AUTH_ERROR;
}
/* If possible, re-use the last tuple and skip auth */
rc = db_get_lastauthtuple_for_subscr(atuple, subscr);
if ((rc == 0) &&
(key_seq != GSM_KEY_SEQ_INVAL) &&
+ (key_seq == atuple->key_seq) &&
(atuple->use_count < 3))
{
atuple->use_count++;
@@ -98,35 +108,44 @@ int auth_get_tuple_for_subscr(struct gsm_auth_tuple *atuple,
}
/* Generate a new one */
+ if (rc != 0) {
+ /* If db_get_lastauthtuple_for_subscr() returned nothing, make
+ * sure the atuple memory is initialized to zero and thus start
+ * off with key_seq = 0. */
+ memset(atuple, 0, sizeof(*atuple));
+ } else {
+ /* If db_get_lastauthtuple_for_subscr() returned a previous
+ * tuple, use the next key_seq. */
+ atuple->key_seq = (atuple->key_seq + 1) % 7;
+ }
atuple->use_count = 1;
- atuple->key_seq = (atuple->key_seq + 1) % 7;
if (RAND_bytes(atuple->rand, sizeof(atuple->rand)) != 1) {
LOGP(DMM, LOGL_NOTICE, "RAND_bytes failed, can't generate new auth tuple\n");
- return -1;
+ return AUTH_ERROR;
}
switch (ainfo.auth_algo) {
case AUTH_ALGO_NONE:
DEBUGP(DMM, "No authentication for subscriber\n");
- return 0;
+ return AUTH_NOT_AVAIL;
case AUTH_ALGO_XOR:
if (_use_xor(&ainfo, atuple))
/* non-zero return value means failure */
- return 0;
+ return AUTH_NOT_AVAIL;
break;
case AUTH_ALGO_COMP128v1:
if (_use_comp128_v1(&ainfo, atuple))
/* non-zero return value means failure */
- return 0;
+ return AUTH_NOT_AVAIL;
break;
default:
DEBUGP(DMM, "Unsupported auth type algo_id=%d\n",
ainfo.auth_algo);
- return 0;
+ return AUTH_NOT_AVAIL;
}
db_sync_lastauthtuple_for_subscr(atuple, subscr);
diff --git a/openbsc/src/osmo-bsc/osmo_bsc_vty.c b/openbsc/src/osmo-bsc/osmo_bsc_vty.c
index c8f0621dc..e623c9c10 100644
--- a/openbsc/src/osmo-bsc/osmo_bsc_vty.c
+++ b/openbsc/src/osmo-bsc/osmo_bsc_vty.c
@@ -43,7 +43,7 @@ static struct osmo_bsc_data *osmo_bsc_data(struct vty *vty)
static struct osmo_msc_data *osmo_msc_data(struct vty *vty)
{
- return osmo_msc_data_find(bsc_gsmnet, (long int) vty->index);
+ return vty->index;
}
static struct cmd_node bsc_node = {
@@ -70,7 +70,7 @@ DEFUN(cfg_net_msc, cfg_net_msc_cmd,
return CMD_WARNING;
}
- vty->index = (void *)(long int)index;
+ vty->index = msc;
vty->node = MSC_NODE;
return CMD_SUCCESS;
}
diff --git a/openbsc/src/utils/meas_db.c b/openbsc/src/utils/meas_db.c
index 6c7e7ae6e..a3b694e6b 100644
--- a/openbsc/src/utils/meas_db.c
+++ b/openbsc/src/utils/meas_db.c
@@ -314,7 +314,6 @@ err_io:
void meas_db_close(struct meas_db_state *st)
{
- int retries;
if (sqlite3_finalize(st->stmt_ins_mr) != SQLITE_OK)
fprintf(stderr, "DB insert measurement report finalize error: %s\n",
sqlite3_errmsg(st->db));
@@ -324,16 +323,8 @@ void meas_db_close(struct meas_db_state *st)
if (sqlite3_finalize(st->stmt_upd_mr) != SQLITE_OK)
fprintf(stderr, "DB update measurement report finalize error: %s\n",
sqlite3_errmsg(st->db));
- retries = 0;
- while (1) {
- if (sqlite3_close(st->db) == SQLITE_OK)
- break;
- if ((++retries) >= 3) {
- fprintf(stderr, "Unable to close DB, abandoning.\n");
- break;
- }
- sleep(1);
- }
+ if (sqlite3_close(st->db) != SQLITE_OK)
+ fprintf(stderr, "Unable to close DB, abandoning.\n");
talloc_free(st);