summaryrefslogtreecommitdiff
path: root/mactelnet.c
diff options
context:
space:
mode:
authorHåkon Nessjøen <haakon.nessjoen@gmail.com>2010-11-01 22:46:34 +0100
committerHåkon Nessjøen <haakon.nessjoen@gmail.com>2010-11-01 22:46:34 +0100
commitf241a46d9901f6c6c679838b35c90cc3619167be (patch)
tree02212b48b78cb672f520ca2b9bfe9f175b079ae7 /mactelnet.c
parent1b94292a0fb5cfeb42aaf0039e7865a07aa1ef3f (diff)
downloadMAC-Telnet-f241a46d9901f6c6c679838b35c90cc3619167be.tar.gz
MAC-Telnet-f241a46d9901f6c6c679838b35c90cc3619167be.zip
Added support for connecting to your router via the router identity name. (using MNDP)
Diffstat (limited to 'mactelnet.c')
-rw-r--r--mactelnet.c32
1 files changed, 29 insertions, 3 deletions
diff --git a/mactelnet.c b/mactelnet.c
index 411413a..03233b4 100644
--- a/mactelnet.c
+++ b/mactelnet.c
@@ -283,12 +283,13 @@ int main (int argc, char **argv) {
}
}
if (argc - optind < 2 || printHelp) {
- fprintf(stderr, "Usage: %s <ifname> <MAC> [-h] [-n] [-u <username>] [-p <password>]\n", argv[0]);
+ fprintf(stderr, "Usage: %s <ifname> <MAC|identity> [-h] [-n] [-u <username>] [-p <password>]\n", argv[0]);
if (printHelp) {
fprintf(stderr, "\nParameters:\n");
fprintf(stderr, " ifname Network interface that the RouterOS resides on. (example: eth0)\n");
fprintf(stderr, " MAC MAC-Address of the RouterOS device. Use mndp to discover them.\n");
+ fprintf(stderr, " identity The identity/name of your RouterOS device. Uses MNDP protocol to find it.\n");
fprintf(stderr, " -n Do not use broadcast packets. Less insecure but requires root privileges.\n");
fprintf(stderr, " -u Specify username on command line.\n");
fprintf(stderr, " -p Specify password on command line.\n");
@@ -302,8 +303,33 @@ int main (int argc, char **argv) {
strncpy(devicename, argv[optind++], sizeof(devicename) - 1);
devicename[sizeof(devicename) - 1] = '\0';
- /* Convert mac address string to ether_addr struct */
- ether_aton_r(argv[optind], (struct ether_addr *)dstmac);
+ /* Check for identity name or mac address */
+ {
+ unsigned char *p = argv[optind];
+ int colons = 0;
+ while (*p++) {
+ if (*p == ':') {
+ colons++;
+ }
+ }
+
+ if (colons != 5) {
+ fprintf(stderr, "Searching for '%s'...", argv[optind]);
+
+ /* Search for Router by identity name, using MNDP */
+ if (!queryMNDP(argv[optind], dstmac)) {
+ fprintf(stderr, "not found.\n");
+ return 1;
+ }
+
+ /* Router found, display mac and continue */
+ fprintf(stderr, "%s\n", ether_ntoa((struct ether_addr *)dstmac));
+
+ } else {
+ /* Convert mac address string to ether_addr struct */
+ ether_aton_r(argv[optind], (struct ether_addr *)dstmac);
+ }
+ }
/* Seed randomizer */
srand(time(NULL));