From 555b1af398c2b808d93a2e93699bce8dcd2b917a Mon Sep 17 00:00:00 2001 From: nbd Date: Tue, 6 Jan 2009 14:08:07 +0000 Subject: ead: allow the client to override the source ip of the server, so that it can work with route filtering properly git-svn-id: svn://svn.openwrt.org/openwrt/trunk@13883 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- package/ead/src/ead-client.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'package/ead/src/ead-client.c') diff --git a/package/ead/src/ead-client.c b/package/ead/src/ead-client.c index 74b0b4361..2592c8f15 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 ] [:] \n" + fprintf(stderr, "Usage: %s [-s ] [-b ] [:] \n" "\n" + "\t-s : Set the server's source address to \n" "\t-b : Set the broadcast address to \n" "\t: Node ID (4 digits hex)\n" "\t: 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; -- cgit v1.2.3