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
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 @@
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 @@
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;
}