aboutsummaryrefslogtreecommitdiffstats
path: root/package/ead
diff options
context:
space:
mode:
authorFelix Fietkau <nbd@openwrt.org>2009-01-06 14:08:07 +0000
committerFelix Fietkau <nbd@openwrt.org>2009-01-06 14:08:07 +0000
commitda951bad66813a97971be00847b052e750f6b6a5 (patch)
tree2d76859136dfbcaa4ef2303e5b75fc55e8258446 /package/ead
parent8c634001bbb558ad877da765205a825ff8015900 (diff)
downloadupstream-da951bad66813a97971be00847b052e750f6b6a5.tar.gz
upstream-da951bad66813a97971be00847b052e750f6b6a5.tar.bz2
upstream-da951bad66813a97971be00847b052e750f6b6a5.zip
ead: allow the client to override the source ip of the server, so that it can work with route filtering properly
SVN-Revision: 13883
Diffstat (limited to 'package/ead')
-rw-r--r--package/ead/src/ead-client.c14
-rw-r--r--package/ead/src/ead.c2
-rw-r--r--package/ead/src/ead.h3
3 files changed, 15 insertions, 4 deletions
diff --git a/package/ead/src/ead-client.c b/package/ead/src/ead-client.c
index 74b0b4361a..2592c8f15e 100644
--- a/package/ead/src/ead-client.c
+++ b/package/ead/src/ead-client.c
@@ -44,6 +44,9 @@ static uint16_t nid = 0xffff;
struct sockaddr_in local, remote;
static int s = 0;
static int sockflags;
+static struct in_addr serverip = {
+ .s_addr = 0x01010101 /* dummy */
+};
static unsigned char *skey = NULL;
static unsigned char bbuf[MAXPARAMLEN];
@@ -80,6 +83,7 @@ send_packet(int type, bool (*handler)(void), unsigned int max)
int res = 0;
type = htonl(type);
+ memcpy(&msg->ip, &serverip.s_addr, sizeof(msg->ip));
set_nonblock(0);
sendto(s, msgbuf, sizeof(struct ead_msg) + ntohl(msg->len), 0, (struct sockaddr *) &remote, sizeof(remote));
set_nonblock(1);
@@ -294,8 +298,9 @@ send_command(const char *command)
static int
usage(const char *prog)
{
- fprintf(stderr, "Usage: %s [-b <addr>] <node> <username>[:<password>] <command>\n"
+ fprintf(stderr, "Usage: %s [-s <addr>] [-b <addr>] <node> <username>[:<password>] <command>\n"
"\n"
+ "\t-s <addr>: Set the server's source address to <addr>\n"
"\t-b <addr>: Set the broadcast address to <addr>\n"
"\t<node>: Node ID (4 digits hex)\n"
"\t<username>: Username to authenticate with\n"
@@ -328,11 +333,16 @@ int main(int argc, char **argv)
local.sin_addr.s_addr = INADDR_ANY;
local.sin_port = 0;
- while ((ch = getopt(argc, argv, "b:")) != -1) {
+ while ((ch = getopt(argc, argv, "b:s:h")) != -1) {
switch(ch) {
+ case 's':
+ inet_aton(optarg, &serverip);
+ break;
case 'b':
inet_aton(optarg, &remote.sin_addr);
break;
+ case 'h':
+ return usage(prog);
}
}
argv += optind;
diff --git a/package/ead/src/ead.c b/package/ead/src/ead.c
index b6a9310f0f..91f6fbaf70 100644
--- a/package/ead/src/ead.c
+++ b/package/ead/src/ead.c
@@ -250,7 +250,7 @@ ead_send_packet_clone(struct ead_packet *pkt)
len = sizeof(struct ead_packet) - sizeof(struct ether_header) + ntohl(pktbuf->msg.len);
pktbuf->len[0] = len >> 8;
pktbuf->len[1] = len & 0xff;
- memcpy(pktbuf->srcipaddr, pkt->destipaddr, 4);
+ memcpy(pktbuf->srcipaddr, &pkt->msg.ip, 4);
memcpy(pktbuf->destipaddr, pkt->srcipaddr, 4);
/* ip checksum */
diff --git a/package/ead/src/ead.h b/package/ead/src/ead.h
index 3cc12c8a4d..36db0f5529 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 2
+#define EAD_DEBUGLEVEL 1
#include <stdint.h>
#include <stddef.h>
@@ -120,6 +120,7 @@ struct ead_msg {
uint32_t type;
uint16_t nid; /* node id */
uint16_t tid; /* transaction id */
+ uint32_t ip; /* source ip for responses from the server */
union {
struct ead_msg_pong pong;
struct ead_msg_user user;