summaryrefslogtreecommitdiff
path: root/eth-filter
diff options
context:
space:
mode:
authorJustus Winter <4winter@informatik.uni-hamburg.de>2014-04-08 16:22:42 +0200
committerJustus Winter <4winter@informatik.uni-hamburg.de>2014-04-11 12:52:27 +0200
commitbbca7914d49aef1e83686a66a122f69ed704a848 (patch)
tree085e311c9a7b887e654c29193fe1b4079f66fd50 /eth-filter
parentb3f03a48cab64cdc8a4cdf25d82ad1882913ae6d (diff)
eth-filter: fix receiver lookups
Previously, the device definitions were filtered using sed to replace the device_t type with mach_port_send_t to make the device argument of device_open polymorphic. Rather than doing that, which makes it impossible to use translation functions, the definition of device_open has been amended. * eth-filter/Makefile: Remove the ourdevice hack that changes device_t to mach_port_send_t. * eth-filter/filter.c: Fix all device_t receiver lookups. * eth-filter/mig-decls.h: New file. * eth-filter/mig-mutate.h: Add mutators.
Diffstat (limited to 'eth-filter')
-rw-r--r--eth-filter/Makefile7
-rw-r--r--eth-filter/filter.c50
-rw-r--r--eth-filter/mig-decls.h45
-rw-r--r--eth-filter/mig-mutate.h7
4 files changed, 67 insertions, 42 deletions
diff --git a/eth-filter/Makefile b/eth-filter/Makefile
index 0b22222c..deee1e57 100644
--- a/eth-filter/Makefile
+++ b/eth-filter/Makefile
@@ -20,10 +20,10 @@ makemode := server
SRCS = bpf_impl.c filter.c queue.c pcap_filter.c
LCLHDRS = bpf_impl.h queue.h util.h
-DIST_FILES = ourdevice.defs notify.defs
+DIST_FILES = device.defs notify.defs
HURDLIBS = ports trivfs fshelp ihash shouldbeinlibc
target = eth-filter
-MIGSTUBS = ourdeviceServer.o notifyServer.o
+MIGSTUBS = deviceServer.o notifyServer.o
MIGSFLAGS = -imacros $(srcdir)/mig-mutate.h
OBJS = $(SRCS:.c=.o) $(MIGSTUBS)
@@ -31,6 +31,3 @@ include ../Makeconf
#CFLAGS += -I../pfinet/linux-src/include -I../pfinet/glue-include
LDFLAGS += -lpcap
-
-ourdevice.defs: device.defs
- $(CPP) $(CPPFLAGS) -x c $< | sed -e '/out[ ]*device[ ]*:[ ]*device_t/s/device_t/mach_port_send_t/' > $@
diff --git a/eth-filter/filter.c b/eth-filter/filter.c
index 04bf7b10..8c76c7b1 100644
--- a/eth-filter/filter.c
+++ b/eth-filter/filter.c
@@ -40,7 +40,7 @@
#include <hurd/ihash.h>
#include <hurd/fshelp.h>
-#include "ourdevice_S.h"
+#include "device_S.h"
#include "notify_S.h"
#include "bpf_impl.h"
#include "util.h"
@@ -287,21 +287,21 @@ do_mach_notify_dead_name (struct port_info *pi,
/* Implementation of device interface */
kern_return_t
-ds_xxx_device_set_status (device_t device, dev_flavor_t flavor,
+ds_xxx_device_set_status (struct proxy_user *device, dev_flavor_t flavor,
dev_status_t status, size_t statu_cnt)
{
return D_INVALID_OPERATION;
}
kern_return_t
-ds_xxx_device_get_status (device_t device, dev_flavor_t flavor,
+ds_xxx_device_get_status (struct proxy_user *device, dev_flavor_t flavor,
dev_status_t status, size_t *statuscnt)
{
return D_INVALID_OPERATION;
}
kern_return_t
-ds_xxx_device_set_filter (device_t device, mach_port_t rec,
+ds_xxx_device_set_filter (struct proxy_user *device, mach_port_t rec,
int pri, filter_array_t filt, size_t len)
{
return D_INVALID_OPERATION;
@@ -359,13 +359,13 @@ ds_device_open (mach_port_t master_port, mach_port_t reply_port,
}
kern_return_t
-ds_device_close (device_t device)
+ds_device_close (struct proxy_user *device)
{
return 0;
}
kern_return_t
-ds_device_write (device_t device, mach_port_t reply_port,
+ds_device_write (struct proxy_user *user, mach_port_t reply_port,
mach_msg_type_name_t reply_type, dev_mode_t mode,
recnum_t recnum, io_buf_ptr_t data, size_t datalen,
int *bytes_written)
@@ -374,17 +374,14 @@ ds_device_write (device_t device, mach_port_t reply_port,
int has_filter = 0;
net_hash_entry_t entp, *hash_headp;
net_rcv_port_t infp, nextfp;
- struct proxy_user *user;
struct proxy *proxy;
- user = ports_lookup_port (port_bucket, device, user_portclass);
if (user == NULL)
{
vm_deallocate (mach_task_self (), (vm_address_t) data, datalen);
return D_INVALID_OPERATION;
}
proxy = user->proxy;
- ports_port_deref (user);
/* The packet can be sent as long as it passes one filter,
* even thought there is usually only one filter in the list. */
@@ -420,20 +417,17 @@ ds_device_write (device_t device, mach_port_t reply_port,
}
kern_return_t
-ds_device_write_inband (device_t device, mach_port_t reply_port,
+ds_device_write_inband (struct proxy_user *user, mach_port_t reply_port,
mach_msg_type_name_t reply_type, dev_mode_t mode,
recnum_t recnum, io_buf_ptr_inband_t data,
size_t datalen, int *bytes_written)
{
kern_return_t ret;
- struct proxy_user *user;
struct proxy *proxy;
- user = ports_lookup_port (port_bucket, device, user_portclass);
if (user == NULL)
return D_INVALID_OPERATION;
proxy = user->proxy;
- ports_port_deref (user);
ret = device_write_inband (proxy->device_port, mode, recnum, data,
datalen, bytes_written);
@@ -441,20 +435,17 @@ ds_device_write_inband (device_t device, mach_port_t reply_port,
}
kern_return_t
-ds_device_read (device_t device, mach_port_t reply_port,
+ds_device_read (struct proxy_user *user, mach_port_t reply_port,
mach_msg_type_name_t reply_type, dev_mode_t mode,
recnum_t recnum, int bytes_wanted,
io_buf_ptr_t *data, size_t *datalen)
{
kern_return_t ret;
- struct proxy_user *user;
struct proxy *proxy;
- user = ports_lookup_port (port_bucket, device, user_portclass);
if (user == NULL)
return D_INVALID_OPERATION;
proxy = user->proxy;
- ports_port_deref (user);
ret = device_read (proxy->device_port, mode, recnum,
bytes_wanted, data, datalen);
@@ -462,20 +453,17 @@ ds_device_read (device_t device, mach_port_t reply_port,
}
kern_return_t
-ds_device_read_inband (device_t device, mach_port_t reply_port,
+ds_device_read_inband (struct proxy_user *user, mach_port_t reply_port,
mach_msg_type_name_t reply_type, dev_mode_t mode,
recnum_t recnum, int bytes_wanted,
io_buf_ptr_inband_t data, size_t *datalen)
{
kern_return_t ret;
- struct proxy_user *user;
struct proxy *proxy;
- user = ports_lookup_port (port_bucket, device, user_portclass);
if (user == NULL)
return D_INVALID_OPERATION;
proxy = user->proxy;
- ports_port_deref (user);
ret = device_read_inband (proxy->device_port, mode, recnum,
bytes_wanted, data, datalen);
@@ -483,18 +471,15 @@ ds_device_read_inband (device_t device, mach_port_t reply_port,
}
kern_return_t
-ds_device_map (device_t device, vm_prot_t prot, vm_offset_t offset,
+ds_device_map (struct proxy_user *user, vm_prot_t prot, vm_offset_t offset,
vm_size_t size, memory_object_t *pager, int unmap)
{
kern_return_t ret;
- struct proxy_user *user;
struct proxy *proxy;
- user = ports_lookup_port (port_bucket, device, user_portclass);
if (user == NULL)
return D_INVALID_OPERATION;
proxy = user->proxy;
- ports_port_deref (user);
ret = device_map (proxy->device_port, prot, offset,
size, pager, unmap);
@@ -502,18 +487,15 @@ ds_device_map (device_t device, vm_prot_t prot, vm_offset_t offset,
}
kern_return_t
-ds_device_set_status (device_t device, dev_flavor_t flavor,
+ds_device_set_status (struct proxy_user *user, dev_flavor_t flavor,
dev_status_t status, size_t statuslen)
{
kern_return_t ret;
- struct proxy_user *user;
struct proxy *proxy;
- user = ports_lookup_port (port_bucket, device, user_portclass);
if (user == NULL)
return D_INVALID_OPERATION;
proxy = user->proxy;
- ports_port_deref (user);
ret = device_set_status (proxy->device_port, flavor,
status, statuslen);
@@ -521,38 +503,32 @@ ds_device_set_status (device_t device, dev_flavor_t flavor,
}
kern_return_t
-ds_device_get_status (device_t device, dev_flavor_t flavor,
+ds_device_get_status (struct proxy_user *user, dev_flavor_t flavor,
dev_status_t status, size_t *statuslen)
{
kern_return_t ret;
- struct proxy_user *user;
struct proxy *proxy;
- user = ports_lookup_port (port_bucket, device, user_portclass);
if (user == NULL)
return D_INVALID_OPERATION;
proxy = user->proxy;
- ports_port_deref (user);
ret = device_get_status (proxy->device_port, flavor, status, statuslen);
return ret;
}
kern_return_t
-ds_device_set_filter (device_t device, mach_port_t receive_port,
+ds_device_set_filter (struct proxy_user *user, mach_port_t receive_port,
int priority, filter_array_t filter, size_t filterlen)
{
mach_port_t tmp;
kern_return_t err;
mach_port_t device_receive_port;
- struct proxy_user *user;
struct proxy *proxy;
- user = ports_lookup_port (port_bucket, device, user_portclass);
if (user == NULL)
return D_INVALID_OPERATION;
proxy = user->proxy;
- ports_port_deref (user);
if (proxy->device == NULL)
{
diff --git a/eth-filter/mig-decls.h b/eth-filter/mig-decls.h
new file mode 100644
index 00000000..0bb29a64
--- /dev/null
+++ b/eth-filter/mig-decls.h
@@ -0,0 +1,45 @@
+/*
+ Copyright (C) 2014 Free Software Foundation, Inc.
+ Written by Justus Winter.
+
+ 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 the GNU Hurd. If not, see <http://www.gnu.org/licenses/>. */
+
+#ifndef __ETH_FILTER_MIG_DECLS_H__
+#define __ETH_FILTER_MIG_DECLS_H__
+
+#include <hurd/ports.h>
+
+typedef struct proxy_user *proxy_user_t;
+
+extern struct port_bucket *port_bucket;
+extern struct port_class *user_portclass;
+
+/* Called by server stub functions. */
+
+static inline struct proxy_user * __attribute__ ((unused))
+begin_using_device_port (mach_port_t port)
+{
+ return ports_lookup_port (port_bucket, port, user_portclass);
+}
+
+static inline void __attribute__ ((unused))
+end_using_device (struct proxy_user *p)
+{
+ if (p)
+ ports_port_deref (p);
+}
+
+#endif /* __ETH_FILTER_MIG_DECLS_H__ */
diff --git a/eth-filter/mig-mutate.h b/eth-filter/mig-mutate.h
index f692236e..388ce090 100644
--- a/eth-filter/mig-mutate.h
+++ b/eth-filter/mig-mutate.h
@@ -23,3 +23,10 @@
end_using_port_info (port_info_t)
#define NOTIFY_IMPORTS \
import "libports/mig-decls.h";
+
+#define DEVICE_INTRAN \
+ proxy_user_t begin_using_device_port (mach_port_t)
+#define DEVICE_DESTRUCTOR \
+ end_using_device (proxy_user_t)
+#define DEVICE_IMPORTS \
+ import "eth-filter/mig-decls.h";