aboutsummaryrefslogtreecommitdiffstats
path: root/src/ctrl.c
diff options
context:
space:
mode:
authorNeels Hofmeyr <neels@hofmeyr.de>2017-11-23 15:25:30 +0100
committerNeels Hofmeyr <nhofmeyr@sysmocom.de>2017-11-29 16:22:29 +0000
commitbd1dca0859dc9e3653c75af13501e59a587975ef (patch)
tree996c817c9f1dbcb94fe0919d6362ed67a7b6ed88 /src/ctrl.c
parent33eeeef9dcfb3103ddbbac756088825d38ce5f53 (diff)
db_get_auth_data / db_get_auc: clarify return values
Differentiate between "IMSI unknown" and "IMSI has no auth data": in case of known IMSI lacking auth data, return -ENOKEY instead of -ENOENT. Fix API doc comments to reflect what the functions actually return, on top of adding the -ENOKEY detail. Adjust db_test expectations from -ENOENT to -ENOKEY where appropriate. Adjust VTY and CTRL command rc evaluation. A subsequent patch will use these return values to log details on each of these situations. Change-Id: Icf6304d23585f2ed45e050fa27c787f2d66fd3f7
Diffstat (limited to 'src/ctrl.c')
-rw-r--r--src/ctrl.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/ctrl.c b/src/ctrl.c
index 3e81661..8ae9d7c 100644
--- a/src/ctrl.c
+++ b/src/ctrl.c
@@ -228,11 +228,16 @@ static int get_subscr_info_aud(struct ctrl_cmd *cmd, void *data)
rc = db_get_auth_data(hlr->dbc, imsi, &aud2g, &aud3g, NULL);
- if (rc == -ENOENT) {
+ switch (rc) {
+ case 0:
+ break;
+ case -ENOENT:
+ case -ENOKEY:
/* No auth data found, tell the print*() functions about it. */
aud2g.algo = OSMO_AUTH_ALG_NONE;
aud3g.algo = OSMO_AUTH_ALG_NONE;
- } else if (rc) {
+ break;
+ default:
cmd->reply = "Error retrieving authentication data.";
return CTRL_CMD_ERROR;
}
@@ -258,11 +263,16 @@ static int get_subscr_info_all(struct ctrl_cmd *cmd, void *data)
rc = db_get_auth_data(hlr->dbc, subscr.imsi, &aud2g, &aud3g, NULL);
- if (rc == -ENOENT) {
+ switch (rc) {
+ case 0:
+ break;
+ case -ENOENT:
+ case -ENOKEY:
/* No auth data found, tell the print*() functions about it. */
aud2g.algo = OSMO_AUTH_ALG_NONE;
aud3g.algo = OSMO_AUTH_ALG_NONE;
- } else if (rc) {
+ break;
+ default:
cmd->reply = "Error retrieving authentication data.";
return CTRL_CMD_ERROR;
}