|
version 1.2, 2011/10/17 20:14:02
|
version 1.4, 2015/05/19 23:25:30
|
|
Line 12 terms:
|
Line 12 terms:
|
| All of the documentation and software included in the ELWIX and AITNET |
All of the documentation and software included in the ELWIX and AITNET |
| Releases is copyrighted by ELWIX - Sofia/Bulgaria <info@elwix.org> |
Releases is copyrighted by ELWIX - Sofia/Bulgaria <info@elwix.org> |
| |
|
| Copyright 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 | Copyright 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2013 |
| by Michael Pounov <misho@elwix.org>. All rights reserved. |
by Michael Pounov <misho@elwix.org>. All rights reserved. |
| |
|
| Redistribution and use in source and binary forms, with or without |
Redistribution and use in source and binary forms, with or without |
|
Line 57 extern char compiled[], compiledby[], compilehost[];
|
Line 57 extern char compiled[], compiledby[], compilehost[];
|
| static void |
static void |
| Usage() |
Usage() |
| { |
{ |
| printf( " -= ansh =- ELWIX Layer3 remote management client over ICMP\n" | printf( " -= ansh3 =- ELWIX Layer3 remote management client over ICMP\n" |
| "=== %s === %s@%s ===\n\n" |
"=== %s === %s@%s ===\n\n" |
| " Syntax: ansh [options] <connect2host>\n\n" |
" Syntax: ansh [options] <connect2host>\n\n" |
| |
"\t-a <address>\tBind to address\n" |
| "\t-i <id>\tService ID (default is 42)\n" |
"\t-i <id>\tService ID (default is 42)\n" |
| "\t-t <timeout>\tClient session timeout (default is 0 sec)\n" |
"\t-t <timeout>\tClient session timeout (default is 0 sec)\n" |
| "\t-k <key>\tService cipher key\n" |
"\t-k <key>\tService cipher key\n" |
|
Line 72 Usage()
|
Line 73 Usage()
|
| int |
int |
| main(int argc, char **argv) |
main(int argc, char **argv) |
| { |
{ |
| struct sockaddr sa = { 0 }; | sockaddr_t sa, ba; |
| struct sockaddr_in *sin4 = (struct sockaddr_in*) &sa; | |
| struct sockaddr_in6 *sin6 = (struct sockaddr_in6*) &sa; | |
| struct hostent *host; |
struct hostent *host; |
| char ch; |
char ch; |
| int h, len; |
int h, len; |
| u_short id = ANSH_ID; |
u_short id = ANSH_ID; |
| |
|
| |
memset(&sa, 0, sizeof sa); |
| |
memset(&ba, 0, sizeof ba); |
| |
|
| srandomdev(); |
srandomdev(); |
| do { |
do { |
| Crypted = (u_int) random() % UINT_MAX; |
Crypted = (u_int) random() % UINT_MAX; |
|
Line 87 main(int argc, char **argv)
|
Line 89 main(int argc, char **argv)
|
| |
|
| strlcpy(Key, DEFAULT_KEY, sizeof Key); |
strlcpy(Key, DEFAULT_KEY, sizeof Key); |
| |
|
| while ((ch = getopt(argc, argv, "hvui:t:k:")) != -1) | while ((ch = getopt(argc, argv, "hvui:t:k:a:")) != -1) |
| switch (ch) { |
switch (ch) { |
| |
case 'a': |
| |
host = gethostbyname(optarg); |
| |
if (!host) { |
| |
printf("Error:: in bind address '%s' #%d - %s\n", |
| |
optarg, h_errno, hstrerror(h_errno)); |
| |
return 1; |
| |
} |
| |
switch (host->h_addrtype) { |
| |
case AF_INET: |
| |
ba.sin.sin_len = sizeof(struct sockaddr_in); |
| |
ba.sin.sin_family = AF_INET; |
| |
memcpy(&ba.sin.sin_addr.s_addr, host->h_addr, host->h_length); |
| |
break; |
| |
case AF_INET6: |
| |
ba.sin6.sin6_len = sizeof(struct sockaddr_in6); |
| |
ba.sin6.sin6_family = AF_INET6; |
| |
memcpy(&ba.sin6.sin6_addr.s6_addr, host->h_addr, host->h_length); |
| |
break; |
| |
default: |
| |
printf("Error:: Unknown address type %d !!!\n", host->h_addrtype); |
| |
return 1; |
| |
} |
| |
break; |
| case 't': |
case 't': |
| Timeout = abs(strtol(optarg, NULL, 0)); |
Timeout = abs(strtol(optarg, NULL, 0)); |
| break; |
break; |
|
Line 124 main(int argc, char **argv)
|
Line 149 main(int argc, char **argv)
|
| } |
} |
| switch (host->h_addrtype) { |
switch (host->h_addrtype) { |
| case AF_INET: |
case AF_INET: |
| sin4->sin_len = sizeof(struct sockaddr_in); | sa.sin.sin_len = sizeof(struct sockaddr_in); |
| sin4->sin_family = AF_INET; | sa.sin.sin_family = AF_INET; |
| memcpy(&sin4->sin_addr.s_addr, host->h_addr, host->h_length); | memcpy(&sa.sin.sin_addr.s_addr, host->h_addr, host->h_length); |
| break; |
break; |
| case AF_INET6: |
case AF_INET6: |
| sin6->sin6_len = sizeof(struct sockaddr_in6); | sa.sin6.sin6_len = sizeof(struct sockaddr_in6); |
| sin6->sin6_family = AF_INET6; | sa.sin6.sin6_family = AF_INET6; |
| memcpy(&sin6->sin6_addr.s6_addr, host->h_addr, host->h_length); | memcpy(&sa.sin6.sin6_addr.s6_addr, host->h_addr, host->h_length); |
| break; |
break; |
| default: |
default: |
| printf("Error:: Unknown address type %d !!!\n", host->h_addrtype); |
printf("Error:: Unknown address type %d !!!\n", host->h_addrtype); |
| return 1; |
return 1; |
| } |
} |
| |
|
| h = PrepareL3(&sa, &len); | h = PrepareL3(&ba, &len); |
| if (h == -1) { |
if (h == -1) { |
| printf("Error:: Descriptor not opened ... \n"); |
printf("Error:: Descriptor not opened ... \n"); |
| return 1; |
return 1; |