flag new subscriber structs in memory and send a signal
diff --git a/openbsc/include/openbsc/gsm_subscriber.h b/openbsc/include/openbsc/gsm_subscriber.h
index 3efb20c..0abf17a 100644
--- a/openbsc/include/openbsc/gsm_subscriber.h
+++ b/openbsc/include/openbsc/gsm_subscriber.h
@@ -11,6 +11,8 @@
#define GSM_NAME_LENGTH 128
#define GSM_EXTENSION_LENGTH 128
+#define GSM_SUBSCRIBER_FIRST_CONTACT 0x00000001
+
struct gsm_equipment {
long long unsigned int id;
char imei[GSM_IMEI_LENGTH];
@@ -33,6 +35,9 @@
char extension[GSM_EXTENSION_LENGTH];
int authorized;
+ /* Temporary field which is not stored in the DB/HLR */
+ u_int32_t flags;
+
/* Every user can only have one equipment in use at any given
* point in time */
struct gsm_equipment equipment;
diff --git a/openbsc/include/openbsc/signal.h b/openbsc/include/openbsc/signal.h
index 1af8496..0dc1772 100644
--- a/openbsc/include/openbsc/signal.h
+++ b/openbsc/include/openbsc/signal.h
@@ -83,6 +83,7 @@
enum signal_subscr {
S_SUBSCR_ATTACHED,
S_SUBSCR_DETACHED,
+ S_SUBSCR_FIRST_CONTACT,
};
typedef int signal_cbfn(unsigned int subsys, unsigned int signal,
diff --git a/openbsc/src/db.c b/openbsc/src/db.c
index 9ad39d3..e24b619 100644
--- a/openbsc/src/db.c
+++ b/openbsc/src/db.c
@@ -224,6 +224,7 @@
}
subscr = subscr_alloc();
+ subscr->flags |= GSM_SUBSCRIBER_FIRST_CONTACT;
if (!subscr)
return NULL;
result = dbi_conn_queryf(conn,
diff --git a/openbsc/src/gsm_04_08.c b/openbsc/src/gsm_04_08.c
index ec7b4d3..5c4465e 100644
--- a/openbsc/src/gsm_04_08.c
+++ b/openbsc/src/gsm_04_08.c
@@ -1151,8 +1151,12 @@
switch (mi_type) {
case GSM_MI_TYPE_IMSI:
- if (!lchan->subscr)
+ if (!lchan->subscr) {
lchan->subscr = db_create_subscriber(net, mi_string);
+ if (lchan->subscr->flags & GSM_SUBSCRIBER_FIRST_CONTACT) {
+ dispatch_signal(SS_SUBSCR, S_SUBSCR_FIRST_CONTACT, &lchan->subscr);
+ }
+ }
if (lchan->loc_operation)
lchan->loc_operation->waiting_for_imsi = 0;
break;
@@ -1245,6 +1249,9 @@
/* look up subscriber based on IMSI */
subscr = db_create_subscriber(bts->network, mi_string);
+ if (subscr->flags & GSM_SUBSCRIBER_FIRST_CONTACT) {
+ dispatch_signal(SS_SUBSCR, S_SUBSCR_FIRST_CONTACT, &subscr);
+ }
break;
case GSM_MI_TYPE_TMSI:
DEBUGPC(DMM, "\n");