summaryrefslogtreecommitdiff
path: root/protocol.c
diff options
context:
space:
mode:
authorHåkon Nessjøen <haakon.nessjoen@gmail.com>2011-11-02 19:28:05 +0100
committerHåkon Nessjøen <haakon.nessjoen@gmail.com>2011-11-02 19:28:05 +0100
commit2df57f592c0760b15707e87537e29aebaa83ee87 (patch)
tree7a0b9e73e99a83426cff3f1035449c369ae50d44 /protocol.c
parent0df0f028bb355547ac50ea5756edb14e3d12f562 (diff)
downloadMAC-Telnet-2df57f592c0760b15707e87537e29aebaa83ee87.tar.gz
MAC-Telnet-2df57f592c0760b15707e87537e29aebaa83ee87.zip
Quiet mode and no terminal setup when not talking to a tty
Diffstat (limited to 'protocol.c')
-rw-r--r--protocol.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/protocol.c b/protocol.c
index f75bd1d..5800a7e 100644
--- a/protocol.c
+++ b/protocol.c
@@ -477,7 +477,7 @@ done:
* This function accepts either a full MAC address using : or - as seperators.
* Or a router hostname. The hostname will be searched for via MNDP broadcast packets.
*/
-int query_mndp_verbose(char *address, unsigned char *dstmac) {
+int query_mndp_or_mac(char *address, unsigned char *dstmac, int verbose) {
char *p = address;
int colons = 0;
int dashs = 0;
@@ -510,14 +510,20 @@ int query_mndp_verbose(char *address, unsigned char *dstmac) {
* Not a valid mac-address.
* Search for Router by identity name, using MNDP
*/
- fprintf(stderr, "Searching for '%s'...", address);
+ if (verbose) {
+ fprintf(stderr, "Searching for '%s'...", address);
+ }
if (!query_mndp(address, dstmac)) {
- fprintf(stderr, "not found\n");
+ if (verbose) {
+ fprintf(stderr, "not found\n");
+ }
return 0;
}
/* Router found, display mac and continue */
- fprintf(stderr, "found\n");
+ if (verbose) {
+ fprintf(stderr, "found\n");
+ }
} else {
/* Convert mac address string to ether_addr struct */
ether_aton_r(address, (struct ether_addr *)dstmac);