summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlaforge <laforge@99fdad57-331a-0410-800a-d7fa5415bdb3>2007-06-03 06:21:35 +0000
committerlaforge <laforge@99fdad57-331a-0410-800a-d7fa5415bdb3>2007-06-03 06:21:35 +0000
commitafdbbbc6242433463cd0f18920aacbbf579306f5 (patch)
treee9766e47f9b04c9c6af51744c41711504a312d29
parent8ea4f8cf9ca5ff9bf03512e04ff578365316ea02 (diff)
first implementation (ugly) of operator name query
git-svn-id: http://svn.openmoko.org/trunk/src/target/gsm@2135 99fdad57-331a-0410-800a-d7fa5415bdb3
-rw-r--r--src/gsmd/usock.c27
1 files changed, 23 insertions, 4 deletions
diff --git a/src/gsmd/usock.c b/src/gsmd/usock.c
index 696867d..0a29e86 100644
--- a/src/gsmd/usock.c
+++ b/src/gsmd/usock.c
@@ -361,23 +361,42 @@ static int network_sigq_cb(struct gsmd_atcmd *cmd, void *ctx, char *resp)
return 0;
}
+#define GSMD_OPER_MAXLEN 16
static int network_oper_cb(struct gsmd_atcmd *cmd, void *ctx, char *resp)
{
struct gsmd_user *gu = ctx;
- struct gsmd_signal_quality *gsq;
struct gsmd_ucmd *ucmd;
- char *comma;
+ char *comma, *opname;
- ucmd = gsmd_ucmd_fill(sizeof(*gsq), GSMD_MSG_NETWORK,
+ ucmd = gsmd_ucmd_fill(GSMD_OPER_MAXLEN+1, GSMD_MSG_NETWORK,
GSMD_NETWORK_OPER_GET, 0);
if (!ucmd)
return -ENOMEM;
- /* FIXME: implementation */
+ /* Format: <mode>[, <format>, <oper>] */
+ comma = strchr(resp, ',');
+ if (!comma)
+ goto out_err;
+
+ if (atoi(comma+1) != 0) {
+ gsmd_log(GSMD_NOTICE, "COPS format !=0 not supported yet!\n");
+ goto out_err;
+ }
+ comma = strchr(resp, ',');
+ if (!comma || *(comma+1) != '"')
+ goto out_err;
+ opname = comma+2;
+
+ memcpy(ucmd->buf, opname, strlen(opname-1));
+ ucmd->buf[strlen(opname)] = '\0';
usock_cmd_enqueue(ucmd, gu);
return 0;
+
+out_err:
+ talloc_free(ucmd);
+ return -EIO;
}
static int usock_rcv_network(struct gsmd_user *gu, struct gsmd_msg_hdr *gph,
personal git repositories of Harald Welte. Your mileage may vary