summaryrefslogtreecommitdiff
path: root/src/util
diff options
context:
space:
mode:
authorlaforge <laforge@99fdad57-331a-0410-800a-d7fa5415bdb3>2007-03-10 02:22:04 +0000
committerlaforge <laforge@99fdad57-331a-0410-800a-d7fa5415bdb3>2007-03-10 02:22:04 +0000
commit2797211645d452446cb7b329ee9d3d3a923f8520 (patch)
tree5f8dc89cc720f7ea3ce0d6c2b31489addb37c3b8 /src/util
parenta831d70619f614254692b75c1aca39f21c15fb55 (diff)
* properly implement PIN/PUK handling throughout gsmd/libgsmd/util
git-svn-id: http://svn.openmoko.org/trunk/src/target/gsm@1314 99fdad57-331a-0410-800a-d7fa5415bdb3
Diffstat (limited to 'src/util')
-rw-r--r--src/util/pin.c31
1 files changed, 24 insertions, 7 deletions
diff --git a/src/util/pin.c b/src/util/pin.c
index 7bfd8da..fdd0099 100644
--- a/src/util/pin.c
+++ b/src/util/pin.c
@@ -25,29 +25,46 @@
#include <libgsmd/libgsmd.h>
#include <libgsmd/event.h>
+#include <libgsmd/pin.h>
-#define PIN_SIZE 32
+#define PIN_SIZE 8
static char *pin;
static char pinbuf[PIN_SIZE+1];
+static char pinbuf2[PIN_SIZE+1];
static int pin_handler(struct lgsm_handle *lh, int evt, struct gsmd_evt_auxdata *aux)
{
int rc;
+ int type = aux->u.pin.type;
+ char *newpin = NULL;
- printf("EVENT: PIN request (type=%u) ", aux->u.pin.type);
+ printf("EVENT: PIN request (type='%s') ", lgsm_pin_name(aux->u.pin.type));
/* FIXME: read pin from STDIN and send it back via lgsm_pin */
- if (aux->u.pin.type == 1 && pin) {
+ if (type == 1 && pin) {
printf("Auto-responding with pin `%s'\n", pin);
- lgsm_pin(lh, pin);
+ lgsm_pin(lh, type, pin, NULL);
} else {
do {
- printf("Please enter PIN: ");
- rc = fscanf(stdin, "%32s", &pinbuf);
+ printf("Please enter %s: ", lgsm_pin_name(type));
+ rc = fscanf(stdin, "%8s", &pinbuf);
} while (rc < 1);
- return lgsm_pin(lh, pinbuf);
+ switch (type) {
+ case GSMD_PIN_SIM_PUK:
+ case GSMD_PIN_SIM_PUK2:
+ do {
+ printf("Please enter new PIN: ");
+ rc = fscanf(stdin, "%8s", &pinbuf2);
+ newpin = pinbuf2;
+ } while (rc < 1);
+ break;
+ default:
+ break;
+ }
+
+ return lgsm_pin(lh, type, pinbuf, newpin);
}
return 0;
personal git repositories of Harald Welte. Your mileage may vary