diff options
author | Neels Hofmeyr <nhofmeyr@sysmocom.de> | 2016-05-08 23:25:31 +0200 |
---|---|---|
committer | Neels Hofmeyr <nhofmeyr@sysmocom.de> | 2016-05-09 00:26:01 +0200 |
commit | 6950d14c5bf301fbb3061f5a4fe67f5f57b76040 (patch) | |
tree | 1ae01412e3f15a6a7358ea5ad2a63cd6862a45f8 /openbsc/src/libmsc/db.c | |
parent | cf2ca648e9f8b9ed753b4ffb588305b0a3430208 (diff) | |
parent | cd5e52605cdb77bdc6f36fce81a6a1bac7fbda48 (diff) |
Merge branch 'master' into sysmocom/iu, with tweakssysmocom/iu_orig_history
Numerous manual adjustments are included to make sense on the sysmocom/iu branch:
* gsm_04_08_gprs.h has moved to libosmocore on the master branch, but
sysmocom/iu has added some entries. Until it is clear whether to move the
additions to libosmocore as well, keep gsm_04_08_gprs.h on sysmocom/iu with
merely the additions.
* Thus, keep using the old gsm_04_08_gprs.[hc] from openbsc in the Makefiles,
but only where the sysmocom/iu additions are needed.
* In openbsc's gsm_04_08_gprs.h,
* include the libosmocore gsm_04_08_gprs.h,
* use '#pragma once' instead of #ifndef and
* add a TODO comment about moving the rest to libosmocore.
* Apply the addition of an osmo_auth_vector to gsm_auth_tuple: in the Iu auth
vector hacks, use the gsm_auth_tuple.vec instead of a local struct.
See iu_hack__get_hardcoded_auth_tuple() and gsm48_rx_gmm_att_req().
* In the si2q tests, pass NULL as ctx to gsm_network_init().
* In cscn_main.c, add a debug log that was originally added to osmo-nitb.
* openbsc/.gitignore: keep only one addition of 'writtenconfig'
Conflicts:
openbsc/include/openbsc/gprs_sgsn.h
openbsc/include/openbsc/gsm_04_08_gprs.h
openbsc/src/gprs/gsm_04_08_gprs.c
openbsc/src/libmsc/gsm_04_08.c
openbsc/src/osmo-cscn/cscn_main.c
openbsc/tests/gsm0408/Makefile.am
Diffstat (limited to 'openbsc/src/libmsc/db.c')
-rw-r--r-- | openbsc/src/libmsc/db.c | 40 |
1 files changed, 19 insertions, 21 deletions
diff --git a/openbsc/src/libmsc/db.c b/openbsc/src/libmsc/db.c index 8d7d7dc19..b555905ed 100644 --- a/openbsc/src/libmsc/db.c +++ b/openbsc/src/libmsc/db.c @@ -34,6 +34,7 @@ #include <openbsc/db.h> #include <openbsc/debug.h> +#include <osmocom/gsm/protocol/gsm_23_003.h> #include <osmocom/core/talloc.h> #include <osmocom/core/statistics.h> #include <osmocom/core/rate_ctr.h> @@ -508,14 +509,8 @@ struct gsm_subscriber *db_create_subscriber(const char *imsi) /* Is this subscriber known in the db? */ subscr = db_get_subscriber(GSM_SUBSCRIBER_IMSI, imsi); if (subscr) { - result = dbi_conn_queryf(conn, - "UPDATE Subscriber set updated = datetime('now') " - "WHERE imsi = %s " , imsi); - if (!result) - LOGP(DDB, LOGL_ERROR, "failed to update timestamp\n"); - else - dbi_result_free(result); - return subscr; + subscr_put(subscr); + return NULL; } subscr = subscr_alloc(); @@ -529,10 +524,13 @@ struct gsm_subscriber *db_create_subscriber(const char *imsi) "(%s, datetime('now'), datetime('now')) ", imsi ); - if (!result) + if (!result) { LOGP(DDB, LOGL_ERROR, "Failed to create Subscriber by IMSI.\n"); + subscr_put(subscr); + return NULL; + } subscr->id = dbi_conn_sequence_last(conn, NULL); - strncpy(subscr->imsi, imsi, GSM_IMSI_LENGTH-1); + strncpy(subscr->imsi, imsi, sizeof(subscr->imsi)-1); dbi_result_free(result); LOGP(DDB, LOGL_INFO, "New Subscriber: ID %llu, IMSI %s\n", subscr->id, subscr->imsi); db_subscriber_alloc_exten(subscr); @@ -703,25 +701,25 @@ int db_get_lastauthtuple_for_subscr(struct gsm_auth_tuple *atuple, atuple->key_seq = dbi_result_get_ulonglong(result, "key_seq"); len = dbi_result_get_field_length(result, "rand"); - if (len != sizeof(atuple->rand)) + if (len != sizeof(atuple->vec.rand)) goto err_size; blob = dbi_result_get_binary(result, "rand"); - memcpy(atuple->rand, blob, len); + memcpy(atuple->vec.rand, blob, len); len = dbi_result_get_field_length(result, "sres"); - if (len != sizeof(atuple->sres)) + if (len != sizeof(atuple->vec.sres)) goto err_size; blob = dbi_result_get_binary(result, "sres"); - memcpy(atuple->sres, blob, len); + memcpy(atuple->vec.sres, blob, len); len = dbi_result_get_field_length(result, "kc"); - if (len != sizeof(atuple->kc)) + if (len != sizeof(atuple->vec.kc)) goto err_size; blob = dbi_result_get_binary(result, "kc"); - memcpy(atuple->kc, blob, len); + memcpy(atuple->vec.kc, blob, len); dbi_result_free(result); @@ -762,11 +760,11 @@ int db_sync_lastauthtuple_for_subscr(struct gsm_auth_tuple *atuple, /* Update / Insert */ dbi_conn_quote_binary_copy(conn, - atuple->rand, sizeof(atuple->rand), &rand_str); + atuple->vec.rand, sizeof(atuple->vec.rand), &rand_str); dbi_conn_quote_binary_copy(conn, - atuple->sres, sizeof(atuple->sres), &sres_str); + atuple->vec.sres, sizeof(atuple->vec.sres), &sres_str); dbi_conn_quote_binary_copy(conn, - atuple->kc, sizeof(atuple->kc), &kc_str); + atuple->vec.kc, sizeof(atuple->vec.kc), &kc_str); if (!upd) { result = dbi_conn_queryf(conn, @@ -806,7 +804,7 @@ static void db_set_from_query(struct gsm_subscriber *subscr, dbi_conn result) const char *string; string = dbi_result_get_string(result, "imsi"); if (string) - strncpy(subscr->imsi, string, GSM_IMSI_LENGTH-1); + strncpy(subscr->imsi, string, sizeof(subscr->imsi)-1); string = dbi_result_get_string(result, "tmsi"); if (string) @@ -1320,7 +1318,7 @@ int db_subscriber_alloc_token(struct gsm_subscriber *subscriber, uint32_t *token return 0; } -int db_subscriber_assoc_imei(struct gsm_subscriber *subscriber, char imei[GSM_IMEI_LENGTH]) +int db_subscriber_assoc_imei(struct gsm_subscriber *subscriber, char imei[GSM23003_IMEISV_NUM_DIGITS]) { unsigned long long equipment_id, watch_id; dbi_result result; |