From af7fa11347c8c3dc6b3fbd33a0c34e3e08fc0d12 Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Sun, 4 Jan 2009 01:24:00 +0000 Subject: [PATCH] allow the ead client to override the broadcast address SVN-Revision: 13849 --- package/ead/src/ead-client.c | 40 ++++++++++++++++++++++++------------ package/ead/src/ead.h | 2 +- package/ead/src/filter.c | 16 ++++++++------- 3 files changed, 37 insertions(+), 21 deletions(-) diff --git a/package/ead/src/ead-client.c b/package/ead/src/ead-client.c index 14e04c40ba..74b0b4361a 100644 --- a/package/ead/src/ead-client.c +++ b/package/ead/src/ead-client.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -293,12 +294,13 @@ send_command(const char *command) static int usage(const char *prog) { - fprintf(stderr, "Usage: %s [:]\n" + fprintf(stderr, "Usage: %s [-b ] [:] \n" "\n" - "\n: Node ID (4 digits hex)\n" - "\n: Username to authenticate with\n" + "\t-b : Set the broadcast address to \n" + "\t: Node ID (4 digits hex)\n" + "\t: Username to authenticate with\n" "\n" - "\nPassing no arguments shows a list of active nodes on the network\n" + "\tPassing no arguments shows a list of active nodes on the network\n" "\n", prog); return -1; } @@ -309,6 +311,8 @@ int main(int argc, char **argv) int val = 1; char *st = NULL; const char *command = NULL; + const char *prog = argv[0]; + int ch; msg->magic = htonl(EAD_MAGIC); msg->tid = 0; @@ -324,12 +328,22 @@ int main(int argc, char **argv) local.sin_addr.s_addr = INADDR_ANY; local.sin_port = 0; + while ((ch = getopt(argc, argv, "b:")) != -1) { + switch(ch) { + case 'b': + inet_aton(optarg, &remote.sin_addr); + break; + } + } + argv += optind; + argc -= optind; + switch(argc) { - case 4: - command = argv[3]; - /* fall through */ case 3: - username = argv[2]; + command = argv[2]; + /* fall through */ + case 2: + username = argv[1]; st = strchr(username, ':'); if (st) { *st = 0; @@ -340,15 +354,15 @@ int main(int argc, char **argv) memset(st, 0, strlen(st)); } /* fall through */ - case 2: - nid = strtoul(argv[1], &st, 16); + case 1: + nid = strtoul(argv[0], &st, 16); if (st && st[0] != 0) - return usage(argv[0]); + return usage(prog); /* fall through */ - case 1: + case 0: break; default: - return usage(argv[0]); + return usage(prog); } msg->nid = htons(nid); diff --git a/package/ead/src/ead.h b/package/ead/src/ead.h index 3bd64f9d57..3cc12c8a4d 100644 --- a/package/ead/src/ead.h +++ b/package/ead/src/ead.h @@ -14,7 +14,7 @@ #ifndef __EAD_H #define __EAD_H -#define EAD_DEBUGLEVEL 1 +#define EAD_DEBUGLEVEL 2 #include #include diff --git a/package/ead/src/filter.c b/package/ead/src/filter.c index ffa69f18bf..0759dc330f 100644 --- a/package/ead/src/filter.c +++ b/package/ead/src/filter.c @@ -1,13 +1,15 @@ -/* precompiled expression: udp and dst host 255.255.255.255 and dst port 56026 */ +/* precompiled expression: udp and dst port 56026 */ static struct bpf_insn pktfilter_insns[] = { { .code = 0x0028, .jt = 0x00, .jf = 0x00, .k = 0x0000000c }, - { .code = 0x0015, .jt = 0x0b, .jf = 0x00, .k = 0x000086dd }, - { .code = 0x0015, .jt = 0x00, .jf = 0x0a, .k = 0x00000800 }, + { .code = 0x0015, .jt = 0x00, .jf = 0x04, .k = 0x000086dd }, + { .code = 0x0030, .jt = 0x00, .jf = 0x00, .k = 0x00000014 }, + { .code = 0x0015, .jt = 0x00, .jf = 0x0b, .k = 0x00000011 }, + { .code = 0x0028, .jt = 0x00, .jf = 0x00, .k = 0x00000038 }, + { .code = 0x0015, .jt = 0x08, .jf = 0x09, .k = 0x0000dada }, + { .code = 0x0015, .jt = 0x00, .jf = 0x08, .k = 0x00000800 }, { .code = 0x0030, .jt = 0x00, .jf = 0x00, .k = 0x00000017 }, - { .code = 0x0015, .jt = 0x00, .jf = 0x08, .k = 0x00000011 }, - { .code = 0x0020, .jt = 0x00, .jf = 0x00, .k = 0x0000001e }, - { .code = 0x0015, .jt = 0x00, .jf = 0x06, .k = 0xffffffff }, + { .code = 0x0015, .jt = 0x00, .jf = 0x06, .k = 0x00000011 }, { .code = 0x0028, .jt = 0x00, .jf = 0x00, .k = 0x00000014 }, { .code = 0x0045, .jt = 0x04, .jf = 0x00, .k = 0x00001fff }, { .code = 0x00b1, .jt = 0x00, .jf = 0x00, .k = 0x0000000e }, @@ -18,6 +20,6 @@ static struct bpf_insn pktfilter_insns[] = { }; static struct bpf_program pktfilter = { - .bf_len = 14, + .bf_len = 16, .bf_insns = pktfilter_insns, }; -- 2.25.1