Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/tests/net Calculate broadcast IP instead of requiring it as ...
details: https://anonhg.NetBSD.org/src/rev/0b66167f6d63
branches: trunk
changeset: 756614:0b66167f6d63
user: pooka <pooka%NetBSD.org@localhost>
date: Mon Jul 26 14:07:04 2010 +0000
description:
Calculate broadcast IP instead of requiring it as a config parameter.
diffstat:
tests/net/config/netconfig.c | 17 ++++++++++-------
tests/net/icmp/t_forward.c | 6 +++---
tests/net/if_loop/t_pr.c | 6 +++---
3 files changed, 16 insertions(+), 13 deletions(-)
diffs (118 lines):
diff -r 687c0a01ac74 -r 0b66167f6d63 tests/net/config/netconfig.c
--- a/tests/net/config/netconfig.c Mon Jul 26 13:43:26 2010 +0000
+++ b/tests/net/config/netconfig.c Mon Jul 26 14:07:04 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: netconfig.c,v 1.2 2010/07/25 22:28:48 pooka Exp $ */
+/* $NetBSD: netconfig.c,v 1.3 2010/07/26 14:07:04 pooka Exp $ */
/*-
* Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: netconfig.c,v 1.2 2010/07/25 22:28:48 pooka Exp $");
+__RCSID("$NetBSD: netconfig.c,v 1.3 2010/07/26 14:07:04 pooka Exp $");
#endif /* not lint */
#include <sys/types.h>
@@ -62,11 +62,11 @@
}
static void
-netcfg_rump_if(const char *ifname,
- const char *addr, const char *mask, const char *bcast)
+netcfg_rump_if(const char *ifname, const char *addr, const char *mask)
{
struct ifaliasreq ia;
struct sockaddr_in *sin;
+ in_addr_t inaddr, inmask;
int s, rv;
s = -1;
@@ -74,25 +74,28 @@
atf_tc_fail_errno("if config socket");
}
+ inaddr = inet_addr(addr);
+ inmask = inet_addr(mask);
+
/* Address */
memset(&ia, 0, sizeof(ia));
strcpy(ia.ifra_name, ifname);
sin = (struct sockaddr_in *)&ia.ifra_addr;
sin->sin_family = AF_INET;
sin->sin_len = sizeof(struct sockaddr_in);
- sin->sin_addr.s_addr = inet_addr(addr);
+ sin->sin_addr.s_addr = inaddr;
/* Netmask */
sin = (struct sockaddr_in *)&ia.ifra_mask;
sin->sin_family = AF_INET;
sin->sin_len = sizeof(struct sockaddr_in);
- sin->sin_addr.s_addr = inet_addr(mask);
+ sin->sin_addr.s_addr = inmask;
/* Broadcast address */
sin = (struct sockaddr_in *)&ia.ifra_broadaddr;
sin->sin_family = AF_INET;
sin->sin_len = sizeof(struct sockaddr_in);
- sin->sin_addr.s_addr = inet_addr(bcast);
+ sin->sin_addr.s_addr = inaddr | ~inmask;
rv = rump_sys_ioctl(s, SIOCAIFADDR, &ia);
if (rv) {
diff -r 687c0a01ac74 -r 0b66167f6d63 tests/net/icmp/t_forward.c
--- a/tests/net/icmp/t_forward.c Mon Jul 26 13:43:26 2010 +0000
+++ b/tests/net/icmp/t_forward.c Mon Jul 26 14:07:04 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: t_forward.c,v 1.3 2010/07/25 21:39:21 pooka Exp $ */
+/* $NetBSD: t_forward.c,v 1.4 2010/07/26 14:07:04 pooka Exp $ */
/*-
* Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: t_forward.c,v 1.3 2010/07/25 21:39:21 pooka Exp $");
+__RCSID("$NetBSD: t_forward.c,v 1.4 2010/07/26 14:07:04 pooka Exp $");
#endif /* not lint */
#include <sys/types.h>
@@ -180,7 +180,7 @@
int s;
netcfg_rump_makeshmif("bus1", ifname);
- netcfg_rump_if(ifname, "1.0.0.1", "255.255.255.0", "1.0.0.255");
+ netcfg_rump_if(ifname, "1.0.0.1", "255.255.255.0");
netcfg_rump_route("0.0.0.0", "0.0.0.0", "1.0.0.2"); /* default router */
/* set global ttl to 1 */
diff -r 687c0a01ac74 -r 0b66167f6d63 tests/net/if_loop/t_pr.c
--- a/tests/net/if_loop/t_pr.c Mon Jul 26 13:43:26 2010 +0000
+++ b/tests/net/if_loop/t_pr.c Mon Jul 26 14:07:04 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: t_pr.c,v 1.1 2010/07/25 21:42:08 pooka Exp $ */
+/* $NetBSD: t_pr.c,v 1.2 2010/07/26 14:07:04 pooka Exp $ */
/*-
* Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: t_pr.c,v 1.1 2010/07/25 21:42:08 pooka Exp $");
+__RCSID("$NetBSD: t_pr.c,v 1.2 2010/07/26 14:07:04 pooka Exp $");
#endif /* not lint */
#include <sys/types.h>
@@ -78,7 +78,7 @@
rump_init();
/* first, config lo0 & route */
- netcfg_rump_if(ifname, "127.0.0.1", "255.0.0.0", "127.255.255.255");
+ netcfg_rump_if(ifname, "127.0.0.1", "255.0.0.0");
netcfg_rump_route("127.0.0.1", "255.0.0.0", "127.0.0.1");
if ((s = rump_sys_socket(PF_ROUTE, SOCK_RAW, 0)) == -1)
Home |
Main Index |
Thread Index |
Old Index