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];
static struct t_preconf *tcp;
static int auth_type = EAD_AUTH_DEFAULT;
static int timeout = EAD_TIMEOUT;
+static uint16_t sid = 0;
static void
set_nonblock(int enable)
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);
auth_type = ntohs(pong->auth_type);
if (nid == 0xffff)
printf("%04x: %s\n", ntohs(msg->nid), pong->name);
+ sid = msg->sid;
return true;
}
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"
int ch;
msg->magic = htonl(EAD_MAGIC);
- msg->tid = 0;
+ msg->sid = 0;
memset(&local, 0, sizeof(local));
memset(&remote, 0, sizeof(remote));
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;
fprintf(stderr, "Device did not accept user name\n");
return 1;
}
+ timeout = EAD_TIMEOUT_LONG;
if (!get_prime()) {
fprintf(stderr, "Failed to get user password info\n");
return 1;
}
-
- timeout = EAD_TIMEOUT_LONG;
if (!send_a()) {
fprintf(stderr, "Failed to send local authentication data\n");
return 1;