summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <holger@moiji-mobile.com>2013-09-16 23:49:13 +0200
committerHarald Welte <laforge@gnumonks.org>2013-09-24 01:36:42 +0200
commit32bf396bb5d0c76e2f8b12ac1e4fdddb42d540e1 (patch)
tree36462bf6f984ed039d2f59d98ba46a05e236dfe6
parenta1f259323ff8d85741a07cce2c821cbd9974b658 (diff)
lgsm: Allow to set any user data for the gsm handle
-rw-r--r--include/libgsmd/libgsmd.h3
-rw-r--r--src/libgsmd/lgsm_internals.h3
-rw-r--r--src/libgsmd/libgsmd.c10
3 files changed, 16 insertions, 0 deletions
diff --git a/include/libgsmd/libgsmd.h b/include/libgsmd/libgsmd.h
index f260ae2..a6a4252 100644
--- a/include/libgsmd/libgsmd.h
+++ b/include/libgsmd/libgsmd.h
@@ -69,4 +69,7 @@ extern int lgsm_handle_packet(struct lgsm_handle *lh, char *buf, int len);
extern int lgsm_blocking_wait_packet(struct lgsm_handle *lh, u_int16_t id,
struct gsmd_msg_hdr *gmh, int rlen);
+extern void *lgsm_get_user_data(struct lgsm_handle *lh);
+extern void lgsm_set_user_data(struct lgsm_handle *lh, void *data);
+
#endif
diff --git a/src/libgsmd/lgsm_internals.h b/src/libgsmd/lgsm_internals.h
index c826723..76c08b4 100644
--- a/src/libgsmd/lgsm_internals.h
+++ b/src/libgsmd/lgsm_internals.h
@@ -8,6 +8,9 @@ struct lgsm_handle {
int fd;
lgsm_msg_handler *handler[__NUM_GSMD_MSGS];
enum lgsm_netreg_state netreg_state;
+
+ /* any data set by the user */
+ void *user_data;
};
int lgsm_send(struct lgsm_handle *lh, struct gsmd_msg_hdr *gmh);
diff --git a/src/libgsmd/libgsmd.c b/src/libgsmd/libgsmd.c
index 50bd719..1626b04 100644
--- a/src/libgsmd/libgsmd.c
+++ b/src/libgsmd/libgsmd.c
@@ -229,3 +229,13 @@ int lgsm_send_simple(struct lgsm_handle *lh, int type, int sub_type)
lgsm_gmh_free(gmh);
return rc;
}
+
+void *lgsm_get_user_data(struct lgsm_handle *lh)
+{
+ return lh->user_data;
+}
+
+void lgsm_set_user_data(struct lgsm_handle *lh, void *data)
+{
+ lh->user_data = data;
+}
personal git repositories of Harald Welte. Your mileage may vary