summaryrefslogtreecommitdiffstats
path: root/src/auc_core.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/auc_core.c')
-rw-r--r--src/auc_core.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/src/auc_core.c b/src/auc_core.c
index 0fd09f8..e137061 100644
--- a/src/auc_core.c
+++ b/src/auc_core.c
@@ -21,18 +21,25 @@
#include <string.h>
#include <osmocom/core/linuxlist.h>
+#include <osmocom/core/talloc.h>
#include <osmocom/crypt/auth.h>
#include "auc.h"
-#define NBUCKETS 1024
-static struct llist_head auc_buckets[NBUCKETS];
+static struct llist_head *auc_buckets;
+static unsigned int g_nbuckets;
-int auc_core_init(void *ctx)
+int auc_core_init(void *ctx, unsigned int nbuckets)
{
int i;
- for (i = 0; i < NBUCKETS; i++)
+ auc_buckets = talloc_array(ctx, struct llist_head, nbuckets);
+ if (!auc_buckets)
+ return -ENOMEM;
+
+ g_nbuckets = nbuckets;
+
+ for (i = 0; i < nbuckets; i++)
INIT_LLIST_HEAD(&auc_buckets[i]);
return 0;
@@ -45,7 +52,7 @@ static unsigned int osmo_auc_hashfn(const char *imsi)
res = atoi(imsi + len - 6);
- return res % NBUCKETS;
+ return res % g_nbuckets;
}
int auc_add_rec(struct auc_rec *rec)