|
version 1.1, 2011/10/04 22:37:46
|
version 1.1.1.1.2.4, 2011/10/13 14:29:30
|
|
Line 10
|
Line 10
|
| #include "ansh.h" |
#include "ansh.h" |
| |
|
| |
|
| int Verbose, Kill, Crypted = 1; | int Timeout, Verbose, Kill; |
| | u_int Crypted; |
| |
|
| extern char compiled[], compiledby[], compilehost[]; |
extern char compiled[], compiledby[], compilehost[]; |
| |
|
|
Line 21 Usage()
|
Line 22 Usage()
|
| "=== %s === %s@%s ===\n\n" |
"=== %s === %s@%s ===\n\n" |
| " Syntax: ansh [options] <connect2host>\n\n" |
" Syntax: ansh [options] <connect2host>\n\n" |
| "\t-d <dev>\tBind to host interface, like 'em0' (default is first host interface)\n" |
"\t-d <dev>\tBind to host interface, like 'em0' (default is first host interface)\n" |
| "\t-i <id>\tService ID (default is 42)\n" | "\t-t <timeout>\tClient session timeout (default is 0 sec)\n" |
| "\t-u\t\tSwitch to unencrypted traffic between hosts\n" |
"\t-u\t\tSwitch to unencrypted traffic between hosts\n" |
| "\t-v\t\tVerbose (more -v, more verbosity ...)\n" |
"\t-v\t\tVerbose (more -v, more verbosity ...)\n" |
| "\t-h\t\tThis help screen!\n" |
"\t-h\t\tThis help screen!\n" |
|
Line 33 main(int argc, char **argv)
|
Line 34 main(int argc, char **argv)
|
| { |
{ |
| char ch, szDev[STRSIZ] = { 0 }; |
char ch, szDev[STRSIZ] = { 0 }; |
| int h, len; |
int h, len; |
| u_short id = ANSH_ID; |
|
| struct ether_addr ea; |
struct ether_addr ea; |
| |
|
| |
srandomdev(); |
| |
do { |
| |
Crypted = (u_int) random() % UINT_MAX; |
| |
} while (!Crypted); |
| |
|
| Get1stEth(szDev, STRSIZ); |
Get1stEth(szDev, STRSIZ); |
| |
|
| while ((ch = getopt(argc, argv, "hvui:d:")) != -1) | while ((ch = getopt(argc, argv, "hvut:d:")) != -1) |
| switch (ch) { |
switch (ch) { |
| |
case 't': |
| |
Timeout = abs(strtol(optarg, NULL, 0)); |
| |
break; |
| case 'd': |
case 'd': |
| strlcpy(szDev, optarg, sizeof szDev); |
strlcpy(szDev, optarg, sizeof szDev); |
| break; |
break; |
| case 'i': |
|
| id = strtol(optarg, NULL, 0); |
|
| break; |
|
| case 'u': |
case 'u': |
| Crypted ^= Crypted; |
Crypted ^= Crypted; |
| break; |
break; |
|
Line 74 main(int argc, char **argv)
|
Line 79 main(int argc, char **argv)
|
| return 1; |
return 1; |
| } |
} |
| |
|
| ConnectL2(h, id, &ea, len); | ConnectL2(h, &ea, len); |
| |
|
| VERB(1) printf("Finish client.\n"); | VERB(1) printf("\r\nFinish client.\r\n"); |
| close(h); |
close(h); |
| return 0; |
return 0; |
| } |
} |