Annotation of ansh/src/ansh.c, revision 1.1.1.1.2.1
1.1 misho 1: /*************************************************************************
2: * (C) 2011 AITNET - Sofia/Bulgaria - <office@aitnet.org>
3: * by Michael Pounov <misho@elwix.org>
4: *
5: * $Author: misho $
1.1.1.1.2.1! misho 6: * $Id: ansh.c,v 1.1.1.1 2011/10/04 22:37:46 misho Exp $
1.1 misho 7: *
8: *************************************************************************/
9: #include "global.h"
10: #include "ansh.h"
11:
12:
1.1.1.1.2.1! misho 13: int Verbose, Kill;
! 14: u_int Crypted;
1.1 misho 15:
16: extern char compiled[], compiledby[], compilehost[];
17:
18: static void
19: Usage()
20: {
21: printf( " -= ansh =- ELWIX Layer2 remote management client\n"
22: "=== %s === %s@%s ===\n\n"
23: " Syntax: ansh [options] <connect2host>\n\n"
24: "\t-d <dev>\tBind to host interface, like 'em0' (default is first host interface)\n"
25: "\t-i <id>\tService ID (default is 42)\n"
26: "\t-u\t\tSwitch to unencrypted traffic between hosts\n"
27: "\t-v\t\tVerbose (more -v, more verbosity ...)\n"
28: "\t-h\t\tThis help screen!\n"
29: "\n", compiled, compiledby, compilehost);
30: }
31:
32: int
33: main(int argc, char **argv)
34: {
35: char ch, szDev[STRSIZ] = { 0 };
36: int h, len;
37: u_short id = ANSH_ID;
38: struct ether_addr ea;
39:
40: Get1stEth(szDev, STRSIZ);
41:
42: while ((ch = getopt(argc, argv, "hvui:d:")) != -1)
43: switch (ch) {
44: case 'd':
45: strlcpy(szDev, optarg, sizeof szDev);
46: break;
47: case 'i':
48: id = strtol(optarg, NULL, 0);
49: break;
50: case 'u':
51: Crypted ^= Crypted;
52: break;
53: case 'v':
54: Verbose++;
55: break;
56: case 'h':
57: default:
58: Usage();
59: return 1;
60: }
61: argc -= optind;
62: argv += optind;
63: if (!argc) {
64: printf("Error:: not specified mac for connect ...\n");
65: return 1;
66: }
67: if (!ether_aton_r(argv[0], &ea)) {
68: printf("Error:: invalid mac ...\n");
69: return 1;
70: }
71:
72: h = PrepareL2(szDev, &len);
73: if (h == -1) {
74: printf("Error:: Descriptor not opened ... \n");
75: return 1;
76: }
77:
78: ConnectL2(h, id, &ea, len);
79:
80: VERB(1) printf("Finish client.\n");
81: close(h);
82: return 0;
83: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>