summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mactelnet.c2
-rw-r--r--mndp.c17
-rw-r--r--mndp.h4
3 files changed, 19 insertions, 4 deletions
diff --git a/mactelnet.c b/mactelnet.c
index ad2c985..e48e4db 100644
--- a/mactelnet.c
+++ b/mactelnet.c
@@ -483,7 +483,7 @@ int main (int argc, char **argv) {
break;
case 'l':
- return mndp();
+ return mndp(connect_timeout);
break;
case 'h':
diff --git a/mndp.c b/mndp.c
index e8ba8e3..986476e 100644
--- a/mndp.c
+++ b/mndp.c
@@ -20,6 +20,8 @@
#include <locale.h>
#include <stdlib.h>
#include <stdio.h>
+#include <signal.h>
+#include <unistd.h>
#include <arpa/inet.h>
#include <netinet/ether.h>
#include <string.h>
@@ -36,7 +38,13 @@ unsigned char mt_direction_fromserver = 0;
int main(int argc, char **argv) {
#else
-int mndp(void) {
+
+void sig_alarm(int signo)
+{
+ exit(0);
+}
+
+int mndp(int timeout) {
#endif
int sock,result;
int optval = 1;
@@ -46,6 +54,7 @@ int mndp(void) {
#ifdef FROM_MACTELNET
/* mactelnet.c has this set to 1 */
mt_direction_fromserver = 0;
+ signal(SIGALRM, sig_alarm);
#endif
setlocale(LC_ALL, "");
@@ -90,6 +99,12 @@ int mndp(void) {
printf("\n\E[1m%-17s %s\E[m\n", _("MAC-Address"), _("Identity (platform version hardware) uptime"));
+#ifdef FROM_MACTELNET
+ if (timeout > 0) {
+ alarm(timeout);
+ }
+#endif
+
while(1) {
struct mt_mndp_info *packet;
/* Wait for a UDP packet */
diff --git a/mndp.h b/mndp.h
index 77c489f..65c3a51 100644
--- a/mndp.h
+++ b/mndp.h
@@ -1,6 +1,6 @@
#ifndef _MNDP_H
#define _MNDP_H
-int mndp(void);
+int mndp(int timeout);
-#endif \ No newline at end of file
+#endif