@@ -5,6 +5,7 @@ struct gsm_auth_tuple;
struct gsm_subscriber;
enum auth_action {
+ AUTH_ERROR = -1, /* Internal error */
AUTH_NOT_AVAIL = 0, /* No auth tuple available */
AUTH_DO_AUTH_THEN_CIPH = 1, /* Firsth authenticate, then cipher */
AUTH_DO_CIPH = 2, /* Only ciphering */
@@ -17,12 +18,11 @@ static inline const char *auth_action_str(enum auth_action a)
case X: return #X
switch (a) {
+ AUTH_CASE(AUTH_ERROR);
AUTH_CASE(AUTH_NOT_AVAIL);
AUTH_CASE(AUTH_DO_AUTH_THEN_CIPH);
AUTH_CASE(AUTH_DO_CIPH);
AUTH_CASE(AUTH_DO_AUTH);
- case -1:
- return "(internal error)";
default:
return "(unknown auth_action)";
}
@@ -84,7 +84,7 @@ int auth_get_tuple_for_subscr(struct gsm_auth_tuple *atuple,
if (rc < 0) {
LOGP(DMM, LOGL_NOTICE,
"No retrievable Ki for subscriber, skipping auth\n");
- 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 */
@@ -105,7 +105,7 @@ int auth_get_tuple_for_subscr(struct gsm_auth_tuple *atuple,
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) {
@@ -141,7 +141,7 @@ static void test_error()
test_get_authinfo_rc = -EIO;
auth_action = auth_get_tuple_for_subscr_verbose(&atuple, &subscr,
key_seq);
- OSMO_ASSERT(auth_action == -1);
+ OSMO_ASSERT(auth_action == AUTH_ERROR);
}
static void test_auth_not_avail()
@@ -1,7 +1,7 @@
* test_error()
wrapped: db_get_authinfo_for_subscr(): rc = -5
-auth_get_tuple_for_subscr(key_seq=0) --> auth_action == (internal error)
+auth_get_tuple_for_subscr(key_seq=0) --> auth_action == AUTH_ERROR
* test_auth_not_avail()
wrapped: db_get_authinfo_for_subscr(): rc = -2