/*************************************************************************
* (C) 2011 AITNET - Sofia/Bulgaria - <office@aitnet.org>
* by Michael Pounov <misho@elwix.org>
*
* $Author: misho $
* $Id: ansh.c,v 1.1.1.1.2.3 2011/10/10 13:56:30 misho Exp $
*
*************************************************************************/
#include "global.h"
#include "ansh.h"
int Timeout, Verbose, Kill;
u_int Crypted;
extern char compiled[], compiledby[], compilehost[];
static void
Usage()
{
printf( " -= ansh =- ELWIX Layer2 remote management client\n"
"=== %s === %s@%s ===\n\n"
" Syntax: ansh [options] <connect2host>\n\n"
"\t-d <dev>\tBind to host interface, like 'em0' (default is first host interface)\n"
"\t-t <timeout>\tClient session timeout (default is 0 sec)\n"
"\t-u\t\tSwitch to unencrypted traffic between hosts\n"
"\t-v\t\tVerbose (more -v, more verbosity ...)\n"
"\t-h\t\tThis help screen!\n"
"\n", compiled, compiledby, compilehost);
}
int
main(int argc, char **argv)
{
char ch, szDev[STRSIZ] = { 0 };
int h, len;
struct ether_addr ea;
srandomdev();
do {
Crypted = (u_int) random() % UINT_MAX;
} while (!Crypted);
Get1stEth(szDev, STRSIZ);
while ((ch = getopt(argc, argv, "hvut:d:")) != -1)
switch (ch) {
case 't':
Timeout = abs(strtol(optarg, NULL, 0));
break;
case 'd':
strlcpy(szDev, optarg, sizeof szDev);
break;
case 'u':
Crypted ^= Crypted;
break;
case 'v':
Verbose++;
break;
case 'h':
default:
Usage();
return 1;
}
argc -= optind;
argv += optind;
if (!argc) {
printf("Error:: not specified mac for connect ...\n");
return 1;
}
if (!ether_aton_r(argv[0], &ea)) {
printf("Error:: invalid mac ...\n");
return 1;
}
h = PrepareL2(szDev, &len);
if (h == -1) {
printf("Error:: Descriptor not opened ... \n");
return 1;
}
ConnectL2(h, &ea, len);
VERB(1) printf("Finish client.\n");
close(h);
return 0;
}
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>