--- ansh/src/ansh.c 2011/10/04 22:37:46 1.1.1.1 +++ ansh/src/ansh.c 2011/10/10 13:56:30 1.1.1.1.2.3 @@ -3,14 +3,15 @@ * by Michael Pounov * * $Author: misho $ - * $Id: ansh.c,v 1.1.1.1 2011/10/04 22:37:46 misho Exp $ + * $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 Verbose, Kill, Crypted = 1; +int Timeout, Verbose, Kill; +u_int Crypted; extern char compiled[], compiledby[], compilehost[]; @@ -21,7 +22,7 @@ Usage() "=== %s === %s@%s ===\n\n" " Syntax: ansh [options] \n\n" "\t-d \tBind to host interface, like 'em0' (default is first host interface)\n" - "\t-i \tService ID (default is 42)\n" + "\t-t \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" @@ -33,19 +34,23 @@ main(int argc, char **argv) { char ch, szDev[STRSIZ] = { 0 }; int h, len; - u_short id = ANSH_ID; struct ether_addr ea; + srandomdev(); + do { + Crypted = (u_int) random() % UINT_MAX; + } while (!Crypted); + Get1stEth(szDev, STRSIZ); - while ((ch = getopt(argc, argv, "hvui:d:")) != -1) + 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 'i': - id = strtol(optarg, NULL, 0); - break; case 'u': Crypted ^= Crypted; break; @@ -74,7 +79,7 @@ main(int argc, char **argv) return 1; } - ConnectL2(h, id, &ea, len); + ConnectL2(h, &ea, len); VERB(1) printf("Finish client.\n"); close(h);