From f6ac29dceebb32afc27c2e93294b3c7bb8b2f66f Mon Sep 17 00:00:00 2001 From: Jonas Gunz Date: Fri, 28 Jun 2019 00:50:19 +0200 Subject: minor fixes --- src/main.c | 2 +- src/modem.c | 31 ++++++++++--------------------- src/modem.h | 2 ++ 3 files changed, 13 insertions(+), 22 deletions(-) diff --git a/src/main.c b/src/main.c index 75b37a3..988055e 100644 --- a/src/main.c +++ b/src/main.c @@ -166,7 +166,7 @@ void dialup_server(struct prog_params params) printf("Connection!\n"); - modem_run(fd, 0, NULL); + modem_run(fd, params.run_argc, params.run_argv); } void telnet_server(struct prog_params params) diff --git a/src/modem.c b/src/modem.c index 82572b8..be5c9d6 100644 --- a/src/modem.c +++ b/src/modem.c @@ -20,29 +20,10 @@ int modem_accept_wait(int fd) fds.fd = fd; fds.events = POLLIN; - /*write(fd, _AT_ECHO_OFF, strlen(_AT_ECHO_OFF) ); - - int ok = 0; - while(1) { - ret = poll(&fds, 1, 1000); - if (ret) - cnt = read(fd, buff, 128); //Dummy read from _AT_ECHO_OFF, should say OK - else - break; - - - if( strstr(buff, "OK") ) - ok = 1; - } - - if(! ok ) - return 3; -*/ - modem_command(fd, _AT_ECHO_OFF, 1000); modem_command(fd, _AT_MUTE, 1000); + modem_command(fd, _AT_RESET_ON_DTR, 1000); - //printf("Modem OK\n"); /* //DONT wait for ring while ( 1 ) { //wait for RING ret = poll(&fds, 1, 2000); //poll in 2s interval @@ -141,7 +122,15 @@ int modem_run(int fd, int argc, char* argv[]) dup2 (in[0], STDIN_FILENO); dup2 (out[1], STDOUT_FILENO); - printf("EXEC ERROR\r\n"); + + char *arv = malloc(sizeof(char) * (argc + 1)); + memset(arv, 0, sizeof(char) * (argc + 1)); + memcpy (arv, argv, argc); + + //execv(argv[0], arv); + execl("/bin/bash", "/bin/bash", NULL); + + printf("EXEC ERROR %i: %s\r\n", errno, strerror(errno)); exit(0); } else if (pid < 0) {//error diff --git a/src/modem.h b/src/modem.h index 09823a5..2598273 100644 --- a/src/modem.h +++ b/src/modem.h @@ -9,6 +9,7 @@ #include #include #include +#include #define _AT "AT\r\n" #define _AT_ANSWER "ATA\r\n" @@ -17,6 +18,7 @@ #define _AT_HANGUP "ATH\r\n" #define _AT_CMD_MODE "+++\r\n" #define _AT_MUTE "ATM0\r\n" +#define _AT_RESET_ON_DTR "AT&D3\r\n" int modem_accept_wait(int fd); -- cgit v1.2.3