summaryrefslogtreecommitdiff
path: root/src/libgsmd
diff options
context:
space:
mode:
authorlaforge <laforge@99fdad57-331a-0410-800a-d7fa5415bdb3>2007-08-16 05:48:59 +0000
committerlaforge <laforge@99fdad57-331a-0410-800a-d7fa5415bdb3>2007-08-16 05:48:59 +0000
commit1c4526b52edc7c245cb76ba801bbbe9da1a3b5ae (patch)
treec6cc10078666dd145694d72ec497420593b09889 /src/libgsmd
parent929473af86307cb76dcb75183094c56c9fce2939 (diff)
Operator Selection (Andrzej Zaborowski)
This adds gsmd/libgsmd/libgmsd-tool commands to: * query available operators, * register to given operator, * register automatically (like gsmd did until now), * deregister, * get current operator name, * query signal quality, * query current connection state (a bit hacky, but it's the only way I found to satisfy the synchronous prototype in misc.h). The operator cache is not used as it wouldn't give any benefit here. Retrieving the list of present operators takes very long but there doesn't seem to exist any way around it and all other phones I used also take that long. The libgmsd call for registration to an automatically chosen operator now takes a parameter of a different type so all libgsmd clients need to be updated (this patch updates libgsmd-tool already, but not libmokogsmd which is not a part of gsmd project). git-svn-id: http://svn.openmoko.org/trunk/src/target/gsm@2713 99fdad57-331a-0410-800a-d7fa5415bdb3
Diffstat (limited to 'src/libgsmd')
-rw-r--r--src/libgsmd/lgsm_internals.h2
-rw-r--r--src/libgsmd/libgsmd_event.c7
-rw-r--r--src/libgsmd/libgsmd_network.c45
3 files changed, 47 insertions, 7 deletions
diff --git a/src/libgsmd/lgsm_internals.h b/src/libgsmd/lgsm_internals.h
index bf1f4a2..94421fa 100644
--- a/src/libgsmd/lgsm_internals.h
+++ b/src/libgsmd/lgsm_internals.h
@@ -2,10 +2,12 @@
#define _LGSM_INTERNALS_H
#include <gsmd/usock.h>
+#include <libgsmd/misc.h>
struct lgsm_handle {
int fd;
lgsm_msg_handler *handler[__NUM_GSMD_MSGS];
+ enum lgsm_netreg_state netreg_state;
};
int lgsm_send(struct lgsm_handle *lh, struct gsmd_msg_hdr *gmh);
diff --git a/src/libgsmd/libgsmd_event.c b/src/libgsmd/libgsmd_event.c
index c751cad..777edd8 100644
--- a/src/libgsmd/libgsmd_event.c
+++ b/src/libgsmd/libgsmd_event.c
@@ -63,6 +63,12 @@ static int evt_demux_msghandler(struct lgsm_handle *lh, struct gsmd_msg_hdr *gmh
gmh->msg_subtype >= __NUM_GSMD_EVT)
return -EINVAL;
+ switch (gmh->msg_subtype) {
+ case GSMD_EVT_NETREG:
+ lh->netreg_state = aux->u.netreg.state;
+ break;
+ }
+
if (evt_handlers[gmh->msg_subtype])
return evt_handlers[gmh->msg_subtype](lh, gmh->msg_subtype, aux);
else
@@ -71,6 +77,7 @@ static int evt_demux_msghandler(struct lgsm_handle *lh, struct gsmd_msg_hdr *gmh
int lgsm_evt_init(struct lgsm_handle *lh)
{
+ lh->netreg_state = LGSM_NETREG_ST_NOTREG;
return lgsm_register_handler(lh, GSMD_MSG_EVENT, &evt_demux_msghandler);
}
diff --git a/src/libgsmd/libgsmd_network.c b/src/libgsmd/libgsmd_network.c
index 800b58c..9a21fb5 100644
--- a/src/libgsmd/libgsmd_network.c
+++ b/src/libgsmd/libgsmd_network.c
@@ -32,18 +32,49 @@
#include "lgsm_internals.h"
-int lgsm_netreg_register(struct lgsm_handle *lh, int oper)
+/* Get the current network registration status */
+int lgsm_get_netreg_state(struct lgsm_handle *lh,
+ enum lgsm_netreg_state *state)
{
- /* FIXME: implement oper selection */
- return lgsm_send_simple(lh, GSMD_MSG_NETWORK, GSMD_NETWORK_REGISTER);
+ *state = lh->netreg_state;
}
-int lgsm_signal_quality(struct lgsm_handle *lh)
+int lgsm_oper_get(struct lgsm_handle *lh)
{
- return lgsm_send_simple(lh, GSMD_MSG_NETWORK, GSMD_NETWORK_SIGQ_GET);
+ return lgsm_send_simple(lh, GSMD_MSG_NETWORK, GSMD_NETWORK_OPER_GET);
}
-int lgsmd_operator_name(struct lgsm_handle *lh)
+int lgsm_opers_get(struct lgsm_handle *lh)
{
- return lgsm_send_simple(lh, GSMD_MSG_NETWORK, GSMD_NETWORK_OPER_GET);
+ return lgsm_send_simple(lh, GSMD_MSG_NETWORK, GSMD_NETWORK_OPER_LIST);
+}
+
+int lgsm_netreg_register(struct lgsm_handle *lh, gsmd_oper_numeric oper)
+{
+ struct gsmd_msg_hdr *gmh;
+
+ gmh = lgsm_gmh_fill(GSMD_MSG_NETWORK, GSMD_NETWORK_REGISTER,
+ sizeof(gsmd_oper_numeric));
+ if (!gmh)
+ return -ENOMEM;
+
+ memcpy(gmh->data, oper, sizeof(gsmd_oper_numeric));
+
+ if (lgsm_send(lh, gmh) < gmh->len + sizeof(*gmh)) {
+ lgsm_gmh_free(gmh);
+ return -EIO;
+ }
+
+ lgsm_gmh_free(gmh);
+ return 0;
+}
+
+int lgsm_netreg_deregister(struct lgsm_handle *lh)
+{
+ return lgsm_send_simple(lh, GSMD_MSG_NETWORK, GSMD_NETWORK_DEREGISTER);
+}
+
+int lgsm_signal_quality(struct lgsm_handle *lh)
+{
+ return lgsm_send_simple(lh, GSMD_MSG_NETWORK, GSMD_NETWORK_SIGQ_GET);
}
personal git repositories of Harald Welte. Your mileage may vary