[sms] Send a notification on incoming SMS
Further tests of the signal class. Send a notification
on incoming SMS.
diff --git a/include/openbsc/signal.h b/include/openbsc/signal.h
index eb4fc8d..e53c194 100644
--- a/include/openbsc/signal.h
+++ b/include/openbsc/signal.h
@@ -28,7 +28,8 @@
/*
* Signalling areas
*/
-#define S_PAGING 0x0001
+#define S_PAGING 0x0001
+#define S_SMS 0x0002
struct signal_data {
@@ -46,6 +47,12 @@
struct gsm_lchan *lchan;
};
+struct sms_signal_data {
+ struct signal_data data;
+
+ struct sms_submit *sms;
+};
+
/* Management */
void register_signal_handler(int areas, int (*sig)(struct signal_data *, void *data), void *data);
diff --git a/src/gsm_04_11.c b/src/gsm_04_11.c
index b0d3a01..d354663 100644
--- a/src/gsm_04_11.c
+++ b/src/gsm_04_11.c
@@ -36,6 +36,7 @@
#include <openbsc/gsm_04_11.h>
#include <openbsc/gsm_04_08.h>
#include <openbsc/abis_rsl.h>
+#include <openbsc/signal.h>
#define GSM411_ALLOC_SIZE 1024
#define GSM411_ALLOC_HEADROOM 128
@@ -118,6 +119,15 @@
"UserData: \"%s\"\n", sms->mti, sms->vpf, sms->msg_ref,
sms->pid, sms->dcs, sms->ud_len, sms->user_data);
+ struct sms_signal_data sig = {
+ .data = {
+ .area = S_SMS,
+ },
+
+ .sms = sms,
+ };
+ dispatch_signal(&sig.data);
+
free(sms);
return 0;
diff --git a/src/telnet_interface.c b/src/telnet_interface.c
index e3f56c2..b9ef139 100644
--- a/src/telnet_interface.c
+++ b/src/telnet_interface.c
@@ -29,6 +29,7 @@
#include <openbsc/gsm_subscriber.h>
#include <openbsc/chan_alloc.h>
#include <openbsc/gsm_04_08.h>
+#include <openbsc/gsm_04_11.h>
#include <openbsc/msgb.h>
#include <openbsc/abis_rsl.h>
#include <openbsc/paging.h>
@@ -49,6 +50,7 @@
/* per network data */
static int telnet_new_connection(struct bsc_fd *fd, unsigned int what);
static int telnet_paging_callback(struct signal_data *signal, void *data);
+static int telnet_sms_callback(struct signal_data *signal, void *data);
static struct bsc_fd server_socket = {
.when = BSC_FD_READ,
@@ -88,8 +90,9 @@
server_socket.fd = fd;
bsc_register_fd(&server_socket);
- /* register paging callbacks */
+ /* register callbacks */
register_signal_handler(S_PAGING, telnet_paging_callback, network);
+ register_signal_handler(S_SMS, telnet_sms_callback, network);
}
void telnet_write_help(int fd) {
@@ -381,3 +384,16 @@
return 0;
}
+
+static int telnet_sms_callback(struct signal_data *signal, void *data)
+{
+ struct sms_signal_data *sms =
+ (struct sms_signal_data *) signal;
+ struct telnet_connection *con;
+
+ llist_for_each_entry(con, &active_connections, entry) {
+ WRITE_CONNECTION(con->fd.fd, "Incoming SMS: %s\n", sms->sms->user_data);
+ }
+
+ return 0;
+}