summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Bushnell <thomas@gnu.org>1996-10-25 03:14:46 +0000
committerThomas Bushnell <thomas@gnu.org>1996-10-25 03:14:46 +0000
commit96d494ad261e1635b1168bf53b613b866d06f086 (patch)
tree89a7b759de1ac3122acb0207dec2d63c88c6b59d
parent0ffdd2c1c4bb58c395ee8a283c94fb0cc9034201 (diff)
Thu Oct 24 22:38:55 1996 Thomas Bushnell, n/BSG <thomas@gnu.ai.mit.edu>
* main.c (main): Call setup_loopback_device before parsing args (and thus before the ethernet device shows up). * loopback.c: New file. * Makefile (SRCS): Add loopback.c. * pfinet.h (loopback_dev): New variable. * pfinet.h (ip_rt_del): New prototype.
-rw-r--r--pfinet/ChangeLog10
-rw-r--r--pfinet/Makefile2
-rw-r--r--pfinet/loopback.c93
-rw-r--r--pfinet/main.c2
-rw-r--r--pfinet/pfinet.h4
5 files changed, 110 insertions, 1 deletions
diff --git a/pfinet/ChangeLog b/pfinet/ChangeLog
index ae4d44fd..f2b16762 100644
--- a/pfinet/ChangeLog
+++ b/pfinet/ChangeLog
@@ -1,3 +1,13 @@
+Thu Oct 24 22:38:55 1996 Thomas Bushnell, n/BSG <thomas@gnu.ai.mit.edu>
+
+ * main.c (main): Call setup_loopback_device before parsing args
+ (and thus before the ethernet device shows up).
+ * loopback.c: New file.
+ * Makefile (SRCS): Add loopback.c.
+ * pfinet.h (loopback_dev): New variable.
+
+ * pfinet.h (ip_rt_del): New prototype.
+
Thu Sep 12 16:47:24 1996 Thomas Bushnell, n/BSG <thomas@gnu.ai.mit.edu>
* Makefile (HURDLIBS): New variable.
diff --git a/pfinet/Makefile b/pfinet/Makefile
index b4023be9..6c4a8c8b 100644
--- a/pfinet/Makefile
+++ b/pfinet/Makefile
@@ -26,7 +26,7 @@ LINUXSRCS= af_inet.c arp.c datagram.c dev.c dev_mcast.c devinet.c eth.c \
tcp.c timer.c udp.c utils.c
UNUSEDSRC = packet.c ipx.c ip_fw.c p8022.c p8023.c pe2.c psnap.c rarp.c
SRCS = sched.c timer-emul.c devices.c socket.c main.c ethernet.c \
- io-ops.c socket-ops.c misc.c time.c options.c
+ io-ops.c socket-ops.c misc.c time.c options.c loopback.c
MIGSRCS = ioServer.c socketServer.c startup_notifyServer.c
OBJS= $(subst .c,.o,$(LINUXSRCS) $(SRCS) $(MIGSRCS))
LCLHDRS= config.h mapped-time.h mutations.h pfinet.h
diff --git a/pfinet/loopback.c b/pfinet/loopback.c
new file mode 100644
index 00000000..78cdfdf3
--- /dev/null
+++ b/pfinet/loopback.c
@@ -0,0 +1,93 @@
+/* Loopback "device" for pfinet
+ Copyright (C) 1996 Free Software Foundation, Inc.
+ Written by Thomas Bushnell, n/BSG.
+
+ This file is part of the GNU Hurd.
+
+ The GNU Hurd is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2, or (at
+ your option) any later version.
+
+ The GNU Hurd is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. */
+
+#include <linux/netdevice.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+
+#include "pfinet.h"
+
+struct device loopback_dev;
+
+int
+loopback_xmit (struct sk_buff *skb, struct device *dev)
+{
+ int done;
+
+ if (!skb || !dev)
+ return 0;
+
+ if (dev->tbusy)
+ return 1;
+
+ dev->tbusy;
+
+ done = dev_rint (skb->data, skb->len, 0, dev);
+ dev_kfree_skb (skb, FREE_WRITE);
+
+ while (done != 1)
+ done = dev_rint (0, 0, 0, dev);
+
+ dev->tbusy = 0;
+ return 0;
+}
+
+
+void
+setup_loopback_device (char *name)
+{
+ int i;
+
+ loopback_dev.name = name;
+ for (i = 0; i < DEV_NUMBUFFS; i++)
+ skb_queue_head_init (&loopback_dev.buffs[i]);
+
+ loopback_dev.open = 0;
+ loopback_dev.stop = 0;
+ loopback_dev.hard_start_xmit = loopback_xmit;
+ loopback_dev.hard_header = 0;
+ loopback_dev.rebuild_header = 0;
+ loopback_dev.type_trans = 0;
+ loopback_dev.get_stats = 0;
+ loopback_dev.set_multicast_list = 0;
+
+ loopback_dev.type = 0;
+ loopback_dev.addr_len = 0;
+ loopback_dev.flags = IFF_LOOPBACK | IFF_BROADCAST;
+ loopback_dev.family = AF_INET;
+
+ loopback_dev.mtu = 2000;
+
+ /* Defaults */
+ loopback_dev.pa_addr = inet_addr ("127.0.0.1");
+ loopback_dev.pa_brdaddr = inet_addr ("127.255.255.255");
+ loopback_dev.pa_mask = inet_addr ("255.0.0.0");
+ loopback_dev.pa_alen = sizeof (unsigned long);
+
+ loopback_dev.next = dev_base;
+ dev_base = &loopback_dev;
+
+ /* Add the route */
+ ip_rt_add (RTF_HOST, loopback_dev.pa_addr, 0xffffffff, 0, &loopback_dev,
+ loopback_dev.mtu, 0);
+}
+
+
+
diff --git a/pfinet/main.c b/pfinet/main.c
index 0df713e4..64c8a664 100644
--- a/pfinet/main.c
+++ b/pfinet/main.c
@@ -210,6 +210,8 @@ main (int argc,
arrange_shutdown_notification ();
+ setup_loopback_device ("loopback");
+
/* Parse options. */
argp_parse (&pfinet_argp, argc, argv, 0,0,0);
diff --git a/pfinet/pfinet.h b/pfinet/pfinet.h
index 966a4e8d..b4ed61ec 100644
--- a/pfinet/pfinet.h
+++ b/pfinet/pfinet.h
@@ -42,6 +42,7 @@ struct port_class *socketport_class;
mach_port_t fsys_identity;
extern struct device ether_dev;
+extern struct device loopback_dev;
/* A port on SOCK. Multiple sock_user's can point to the same socket. */
struct sock_user
@@ -59,6 +60,8 @@ struct sock_addr
struct sockaddr address[0];
};
+void setup_loopback_device (char *);
+
int ethernet_demuxer (mach_msg_header_t *, mach_msg_header_t *);
void setup_ethernet_device (char *);
void become_task_protid (struct trivfs_protid *);
@@ -71,6 +74,7 @@ void init_time (void);
void inet_proto_init (struct net_proto *);
void ip_rt_add (short, u_long, u_long, u_long, struct device *,
u_short, u_long);
+void ip_rt_del (u_long, struct device *);
int tcp_readable (struct sock *);