diff --git a/src/auc.h b/src/auc.h index eba9843..6560dde 100644 --- a/src/auc.h +++ b/src/auc.h @@ -28,6 +28,7 @@ struct auc_rec { struct llist_head list; struct llist_head hash_list; uint8_t imsi[15+1]; + long offset_sqn; struct osmo_sub_auth_data auth; }; diff --git a/src/auc_rec_csv.c b/src/auc_rec_csv.c index 21a87a8..c5e257b 100644 --- a/src/auc_rec_csv.c +++ b/src/auc_rec_csv.c @@ -32,8 +32,8 @@ 2620301,1,000102030405060708090a0b0c0d0e0f,0f0e0d0c0b0a09080706050403020100,0001,32,0 */ -static struct auc_rec *auc_rec_from_csv(void *ctx, - const char *line_orig) +static struct auc_rec * +auc_rec_from_csv(void *ctx, const char *line_orig, long offset_nextline) { char *line = talloc_strdup(ctx, line_orig); char *tok; @@ -99,6 +99,13 @@ static struct auc_rec *auc_rec_from_csv(void *ctx, if (!tok) goto ret_free; rec->auth.u.umts.sqn = strtoull(tok, NULL, 10); + if (strlen(tok) != 8) + printf("SQN must be 8 digits wide in order to support updates\n"); + else { + /* save file offfset for SQN so we can update it */ + rec->offset_sqn = offset_nextline - (strlen(line_orig) - (tok - line)); + } + /* IS_OP */ tok = strtok(NULL, ","); if (!tok) @@ -191,11 +198,14 @@ int auc_storage_read(void *ctx, const char *fname) while ((line = fgets(line, 256, file))) { struct auc_rec *rec; + long offset_nextline; if (line[0] == '#') continue; - rec = auc_rec_from_csv(ctx, line); + offset_nextline = ftell(file); + + rec = auc_rec_from_csv(ctx, line, offset_nextline); if (!rec) continue; diff --git a/src/gen_auc_txt.pl b/src/gen_auc_txt.pl index 14cae39..62b259a 100755 --- a/src/gen_auc_txt.pl +++ b/src/gen_auc_txt.pl @@ -9,5 +9,5 @@ my $COUNT = $ARGV[0]; my $i; for ($i = 0; $i < $COUNT; $i++) { - printf("90170%010u,5,%032u,%032u,0000,%u,0\n", $i, $i, $i, $i); + printf("90170%010u,5,%032u,%032u,0000,%08u,0\n", $i, $i, $i, $i); }