aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Jonas Gunz <himself@jonasgunz.de> 2019-06-28 00:50:19 +0200
committerGravatar Jonas Gunz <himself@jonasgunz.de> 2019-06-28 00:50:19 +0200
commitf6ac29dceebb32afc27c2e93294b3c7bb8b2f66f (patch)
treef17ac7e1550490c7b20dd5f045de7dda6b72a3ba /src
parent3ede7cb5691ad52a289ac7c6b19d8ef77744ba1f (diff)
downloadbbs-f6ac29dceebb32afc27c2e93294b3c7bb8b2f66f.tar.gz
minor fixes
Diffstat (limited to 'src')
-rw-r--r--src/main.c2
-rw-r--r--src/modem.c31
-rw-r--r--src/modem.h2
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 <poll.h>
#include <string.h>
#include <signal.h>
+#include <errno.h>
#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);