aboutsummaryrefslogtreecommitdiff
path: root/libqcdm/src
diff options
context:
space:
mode:
authorDan Williams <dcbw@redhat.com>2010-02-22 12:17:27 -0800
committerDan Williams <dcbw@redhat.com>2010-02-22 12:17:27 -0800
commit3d617b7bf62bd35811cd7be6cbd7848e1835ec5e (patch)
tree592a77c32a784d93e1ba58cd4e872ce9e6f5fede /libqcdm/src
parent7d151e6ae005cdac451b3e24697c7dc1e2c1e462 (diff)
qcdm: add command to get MDN (ie, phone number)
Diffstat (limited to 'libqcdm/src')
-rw-r--r--libqcdm/src/Makefile.am1
-rw-r--r--libqcdm/src/commands.c53
-rw-r--r--libqcdm/src/commands.h14
-rw-r--r--libqcdm/src/nv-items.h35
4 files changed, 103 insertions, 0 deletions
diff --git a/libqcdm/src/Makefile.am b/libqcdm/src/Makefile.am
index 18edc707..5cc05682 100644
--- a/libqcdm/src/Makefile.am
+++ b/libqcdm/src/Makefile.am
@@ -6,6 +6,7 @@ libqcdm_la_CPPFLAGS = \
libqcdm_la_SOURCES = \
dm-commands.h \
+ nv-items.h \
com.c \
com.h \
commands.c \
diff --git a/libqcdm/src/commands.c b/libqcdm/src/commands.c
index 9f2f9a79..41356935 100644
--- a/libqcdm/src/commands.c
+++ b/libqcdm/src/commands.c
@@ -20,6 +20,7 @@
#include "commands.h"
#include "error.h"
#include "dm-commands.h"
+#include "nv-items.h"
#include "result-private.h"
#include "utils.h"
@@ -215,3 +216,55 @@ qcdm_cmd_esn_result (const char *buf, gsize len, GError **error)
return result;
}
+/**********************************************************************/
+
+gsize
+qcdm_cmd_nv_get_mdn_new (char *buf, gsize len, guint8 profile, GError **error)
+{
+ char cmdbuf[sizeof (DMCmdNVReadWrite) + DIAG_TRAILER_LEN];
+ DMCmdNVReadWrite *cmd = (DMCmdNVReadWrite *) &cmdbuf[0];
+ DMNVItemMdn *req;
+
+ g_return_val_if_fail (buf != NULL, 0);
+ g_return_val_if_fail (len >= sizeof (*cmd) + DIAG_TRAILER_LEN, 0);
+
+ memset (cmd, 0, sizeof (*cmd));
+ cmd->code = DIAG_CMD_NV_READ;
+ cmd->nv_item = GUINT16_TO_LE (DIAG_NV_DIR_NUMBER);
+
+ req = (DMNVItemMdn *) &cmd->data[0];
+ req->profile = profile;
+
+ return dm_encapsulate_buffer (cmdbuf, sizeof (*cmd), sizeof (cmdbuf), buf, len);
+}
+
+QCDMResult *
+qcdm_cmd_nv_get_mdn_result (const char *buf, gsize len, GError **error)
+{
+ QCDMResult *result = NULL;
+ DMCmdNVReadWrite *rsp = (DMCmdNVReadWrite *) buf;
+ DMNVItemMdn *mdn;
+ char tmp[11];
+
+ g_return_val_if_fail (buf != NULL, NULL);
+
+ if (!check_command (buf, len, DIAG_CMD_NV_READ, sizeof (DMCmdNVReadWrite), error))
+ return NULL;
+
+ mdn = (DMNVItemMdn *) &rsp->data[0];
+
+ result = qcdm_result_new ();
+
+ qcdm_result_add_uint8 (result, QCDM_CMD_NV_GET_MDN_ITEM_PROFILE, mdn->profile);
+
+ memset (tmp, 0, sizeof (tmp));
+ g_assert (sizeof (mdn->mdn) <= sizeof (tmp));
+ memcpy (tmp, mdn->mdn, sizeof (mdn->mdn));
+ qcdm_result_add_string (result, QCDM_CMD_NV_GET_MDN_ITEM_MDN, tmp);
+
+ return result;
+}
+
+/**********************************************************************/
+
+
diff --git a/libqcdm/src/commands.h b/libqcdm/src/commands.h
index 67d7fbb1..8e62b7ef 100644
--- a/libqcdm/src/commands.h
+++ b/libqcdm/src/commands.h
@@ -52,4 +52,18 @@ QCDMResult *qcdm_cmd_esn_result (const char *buf,
/**********************************************************************/
+#define QCDM_CMD_NV_GET_MDN_ITEM_PROFILE "profile"
+#define QCDM_CMD_NV_GET_MDN_ITEM_MDN "mdn"
+
+gsize qcdm_cmd_nv_get_mdn_new (char *buf,
+ gsize len,
+ guint8 profile,
+ GError **error);
+
+QCDMResult *qcdm_cmd_nv_get_mdn_result (const char *buf,
+ gsize len,
+ GError **error);
+
+/**********************************************************************/
+
#endif /* LIBQCDM_COMMANDS_H */
diff --git a/libqcdm/src/nv-items.h b/libqcdm/src/nv-items.h
new file mode 100644
index 00000000..6f058121
--- /dev/null
+++ b/libqcdm/src/nv-items.h
@@ -0,0 +1,35 @@
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Copyright (C) 2010 Red Hat, Inc.
+ *
+ * This program is free software: you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU General Public
+ * License as published by the Free Software Foundation
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef LIBQCDM_NV_ITEMS_H
+#define LIBQCDM_NV_ITEMS_H
+
+enum {
+ DIAG_NV_DIR_NUMBER = 178, /* Mobile Directory Number (MDN) */
+};
+
+
+/* DIAG_NV_DIR_NUMBER */
+struct DMNVItemMdn {
+ guint8 profile;
+ guint8 mdn[10];
+} __attribute__ ((packed));
+typedef struct DMNVItemMdn DMNVItemMdn;
+
+
+#endif /* LIBQCDM_NV_ITEMS_H */
+