diff options
-rw-r--r-- | mactelnet.c | 2 | ||||
-rw-r--r-- | mndp.c | 17 | ||||
-rw-r--r-- | mndp.h | 4 |
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': @@ -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 */ @@ -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 |