[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[hurd] 27/43: eth-multiplexer: Generalize function and improve error han
From: |
Samuel Thibault |
Subject: |
[hurd] 27/43: eth-multiplexer: Generalize function and improve error handling. |
Date: |
Mon, 11 Sep 2017 07:10:11 +0000 |
This is an automated email from the git hooks/post-receive script.
sthibault pushed a commit to branch upstream
in repository hurd.
commit 2d0d1fd043efd3457bc8bce04c884579d140b2b5
Author: Justus Winter <address@hidden>
Date: Wed Aug 23 16:05:23 2017 +0200
eth-multiplexer: Generalize function and improve error handling.
* eth-multiplexer/ethernet.c (set_promisc): Rename to
'eth_set_clear_flags' and generalize.
(ethernet_open): Adapt call site.
(ethernet_close): Likewise.
* eth-multiplexer/ethernet.h (eth_set_clear_flags): New declaration.
---
eth-multiplexer/ethernet.c | 42 +++++++++++++++++++++++++-----------------
eth-multiplexer/ethernet.h | 1 +
2 files changed, 26 insertions(+), 17 deletions(-)
diff --git a/eth-multiplexer/ethernet.c b/eth-multiplexer/ethernet.c
index c4ed3f4..c8849aa 100644
--- a/eth-multiplexer/ethernet.c
+++ b/eth-multiplexer/ethernet.c
@@ -75,31 +75,32 @@ int ethernet_demuxer (mach_msg_header_t *inp,
return 1;
}
-int set_promisc (char *dev_name, mach_port_t ether_port, int is_promisc)
+error_t
+eth_set_clear_flags (int set_flags, int clear_flags)
{
+ error_t err;
int flags;
- int ret;
size_t count;
- debug ("set_promisc is called, is_promisc: %d\n", is_promisc);
count = 1;
- ret = device_get_status (ether_port, NET_FLAGS, (dev_status_t) &flags,
+ err = device_get_status (ether_port, NET_FLAGS, (dev_status_t) &flags,
&count);
- if (ret)
+ if (err)
{
- error (0, ret, "device_get_status");
- return -1;
+ error (0, err, "device_get_status");
+ return err;
}
- if (is_promisc)
- flags |= IFF_PROMISC;
- else
- flags &= ~IFF_PROMISC;
- ret = device_set_status(ether_port, NET_FLAGS, (dev_status_t) &flags, 1);
- if (ret)
+
+ flags |= set_flags;
+ flags &= ~clear_flags;
+
+ err = device_set_status(ether_port, NET_FLAGS, (dev_status_t) &flags, 1);
+ if (err)
{
- error (0, ret, "device_set_status");
- return -1;
+ error (0, err, "device_set_status");
+ return err;
}
+
return 0;
}
@@ -150,7 +151,9 @@ int ethernet_open (char *dev_name, device_t master_device,
if (err)
error (2, err, "device_set_filter: %s", dev_name);
- set_promisc (dev_name, ether_port, 1);
+ err = eth_set_clear_flags (IFF_PROMISC, 0);
+ if (err)
+ error (2, err, "eth_set_clear_flags");
err = get_ethernet_address (ether_port, ether_address);
if (err)
@@ -161,7 +164,12 @@ int ethernet_open (char *dev_name, device_t master_device,
int ethernet_close (char *dev_name)
{
- set_promisc (dev_name, ether_port, 0);
+ error_t err;
+
+ err = eth_set_clear_flags (0, IFF_PROMISC);
+ if (err)
+ error (2, err, "eth_set_clear_flags");
+
return 0;
}
diff --git a/eth-multiplexer/ethernet.h b/eth-multiplexer/ethernet.h
index a2b2f5e..e8b766f 100644
--- a/eth-multiplexer/ethernet.h
+++ b/eth-multiplexer/ethernet.h
@@ -36,6 +36,7 @@ int ethernet_open (char *dev_name, device_t master_device,
int ethernet_close (char *dev_name);
int ethernet_demuxer (mach_msg_header_t *inp,
mach_msg_header_t *outp);
+error_t eth_set_clear_flags (int set_flags, int clear_flags);
#endif
--
Alioth's /usr/local/bin/git-commit-notice on
/srv/git.debian.org/git/pkg-hurd/hurd.git
- [hurd] 07/43: Fix taking into account prefix for xkb-data installation, (continued)
- [hurd] 07/43: Fix taking into account prefix for xkb-data installation, Samuel Thibault, 2017/09/11
- [hurd] 06/43: trans: Fix parallel build race around MIG-generated headers, Samuel Thibault, 2017/09/11
- [hurd] 09/43: libshouldbeinlibc: Add missing include., Samuel Thibault, 2017/09/11
- [hurd] 05/43: ext2fs: Reduce verbosity of missing xattr support on the FS, Samuel Thibault, 2017/09/11
- [hurd] 11/43: build: Drop unused/unsubstituted config variables, Samuel Thibault, 2017/09/11
- [hurd] 10/43: Revert "Fix taking into account prefix for xkb-data installation", Samuel Thibault, 2017/09/11
- [hurd] 19/43: libdiskfs: Make mapping the time device more robust., Samuel Thibault, 2017/09/11
- [hurd] 01/43: procfs: Remove superfluous calls., Samuel Thibault, 2017/09/11
- [hurd] 13/43: Fix harmless indentation errors tripping [-Wmisleading-indentation]., Samuel Thibault, 2017/09/11
- [hurd] 22/43: libshouldbeinlibc: Fix wiring code., Samuel Thibault, 2017/09/11
- [hurd] 27/43: eth-multiplexer: Generalize function and improve error handling.,
Samuel Thibault <=
- [hurd] 32/43: eth-multiplexer: Fix type check., Samuel Thibault, 2017/09/11
- [hurd] 38/43: trans/mtab: Fix warnings., Samuel Thibault, 2017/09/11
- [hurd] 41/43: exec: Avoid calling mmap with zero size, Samuel Thibault, 2017/09/11
- [hurd] 24/43: eth-multiplexer: Fix error handling., Samuel Thibault, 2017/09/11
- [hurd] 12/43: Fix typo., Samuel Thibault, 2017/09/11
- [hurd] 21/43: startup: Fix retrieving the privileged ports., Samuel Thibault, 2017/09/11
- [hurd] 25/43: eth-multiplexer: Implement getting the devices flags., Samuel Thibault, 2017/09/11
- [hurd] 20/43: ext2fs: Fix warning., Samuel Thibault, 2017/09/11
- [hurd] 18/43: Make build system more robust., Samuel Thibault, 2017/09/11
- [hurd] 14/43: procfs: Provide 'hostinfo'., Samuel Thibault, 2017/09/11