From d88e15979081740b86f48a78c81df56f5122a2c4 Mon Sep 17 00:00:00 2001 From: tick Date: Sat, 1 Dec 2007 01:55:39 +0000 Subject: gsmd: Submitting a PIN for authentication needs to respond with status too.(Andrzej Zaborowski) git-svn-id: http://svn.openmoko.org/trunk/src/target/gsm@3545 99fdad57-331a-0410-800a-d7fa5415bdb3 --- src/util/shell.c | 36 ++++++++++++++++++++++++++++++------ 1 file changed, 30 insertions(+), 6 deletions(-) (limited to 'src/util/shell.c') diff --git a/src/util/shell.c b/src/util/shell.c index 031ed34..373ce33 100644 --- a/src/util/shell.c +++ b/src/util/shell.c @@ -44,7 +44,7 @@ static int nFIND = 0; static int nREADRG = 0; -static int pending_responses = 0; +int pending_responses = 0; /* this is the handler for receiving passthrough responses */ static int pt_msghandler(struct lgsm_handle *lh, struct gsmd_msg_hdr *gmh) @@ -373,6 +373,32 @@ static int phone_msghandler(struct lgsm_handle *lh, struct gsmd_msg_hdr *gmh) return 0; } +static int pin_msghandler(struct lgsm_handle *lh, struct gsmd_msg_hdr *gmh) +{ + int result = *(int *) gmh->data; + + if (result) + printf("PIN error %i\n", result); + else + printf("PIN accepted!\n"); + pending_responses --; + return 0; +} + +static const struct msghandler_s { + int type; + lgsm_msg_handler *fn; +} msghandlers[] = { + { GSMD_MSG_PASSTHROUGH, pt_msghandler }, + { GSMD_MSG_PHONEBOOK, pb_msghandler }, + { GSMD_MSG_SMS, sms_msghandler }, + { GSMD_MSG_NETWORK, net_msghandler }, + { GSMD_MSG_PHONE, phone_msghandler }, + { GSMD_MSG_PIN, pin_msghandler }, + + { 0, 0 } +}; + static int shell_help(void) { printf( "\tA\tAnswer incoming call\n" @@ -424,12 +450,10 @@ int shell_main(struct lgsm_handle *lgsmh, int sync) fd_set readset; char *ptr, *fcomma, *lcomma; int gsm_fd = lgsm_fd(lgsmh); + const struct msghandler_s *hndl; - lgsm_register_handler(lgsmh, GSMD_MSG_PASSTHROUGH, &pt_msghandler); - lgsm_register_handler(lgsmh, GSMD_MSG_PHONEBOOK, &pb_msghandler); - lgsm_register_handler(lgsmh, GSMD_MSG_SMS, &sms_msghandler); - lgsm_register_handler(lgsmh, GSMD_MSG_NETWORK, &net_msghandler); - lgsm_register_handler(lgsmh, GSMD_MSG_PHONE, &phone_msghandler); + for (hndl = msghandlers; hndl->fn; hndl ++) + lgsm_register_handler(lgsmh, hndl->type, hndl->fn); fcntl(0, F_SETFD, O_NONBLOCK); fcntl(gsm_fd, F_SETFD, O_NONBLOCK); -- cgit v1.2.3