Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/rump/net/lib/libnetinet Autoconfigure 127.0.0.1 for lo0.
details: https://anonhg.NetBSD.org/src/rev/68b4eb8d9688
branches: trunk
changeset: 760614:68b4eb8d9688
user: pooka <pooka%NetBSD.org@localhost>
date: Sun Jan 09 12:22:34 2011 +0000
description:
Autoconfigure 127.0.0.1 for lo0.
(testing bind/connect/etc. is now possible on a virgin rump kernel
without the need to ifconfig anything)
diffstat:
sys/rump/net/lib/libnetinet/component.c | 41 +++++++++++++++++++++++++++++++-
1 files changed, 39 insertions(+), 2 deletions(-)
diffs (63 lines):
diff -r fb84340d7b8e -r 68b4eb8d9688 sys/rump/net/lib/libnetinet/component.c
--- a/sys/rump/net/lib/libnetinet/component.c Sun Jan 09 12:20:53 2011 +0000
+++ b/sys/rump/net/lib/libnetinet/component.c Sun Jan 09 12:22:34 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: component.c,v 1.3 2010/08/10 21:50:10 pooka Exp $ */
+/* $NetBSD: component.c,v 1.4 2011/01/09 12:22:34 pooka Exp $ */
/*
* Copyright (c) 2009 Antti Kantee. All Rights Reserved.
@@ -28,11 +28,16 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: component.c,v 1.3 2010/08/10 21:50:10 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: component.c,v 1.4 2011/01/09 12:22:34 pooka Exp $");
#include <sys/param.h>
#include <sys/domain.h>
#include <sys/protosw.h>
+#include <sys/socketvar.h>
+
+#include <net/if.h>
+#include <netinet/in.h>
+#include <netinet/in_var.h>
#include "rump_private.h"
#include "rump_net_private.h"
@@ -49,3 +54,35 @@
carpattach(1);
}
+
+RUMP_COMPONENT(RUMP_COMPONENT_NET_IF)
+{
+ struct ifaliasreq ia;
+ struct sockaddr_in *sin;
+ struct socket *so;
+ int error;
+
+ if ((error = socreate(AF_INET, &so, SOCK_DGRAM, 0, curlwp, NULL)) != 0)
+ panic("lo0 config: cannot create socket");
+
+ /* configure 127.0.0.1 for lo0 */
+ memset(&ia, 0, sizeof(ia));
+ strcpy(ia.ifra_name, "lo0");
+ 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("127.0.0.1");
+
+ 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("255.0.0.0");
+
+ 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("127.255.255.255");
+
+ in_control(so, SIOCAIFADDR, &ia, lo0ifp, curlwp);
+ soclose(so);
+}
Home |
Main Index |
Thread Index |
Old Index