summaryrefslogtreecommitdiff
path: root/src/util
diff options
context:
space:
mode:
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