chiark / gitweb /
udev: net_setup_link - open ethtool and rtnl connections lazily
[elogind.git] / src / udev / net / ethtool-util.h
1 /*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
2
3 /***
4  This file is part of systemd.
5
6  Copyright (C) 2013 Tom Gundersen <teg@jklm.no>
7
8   systemd is free software; you can redistribute it and/or modify it
9   under the terms of the GNU Lesser General Public License as published by
10   the Free Software Foundation; either version 2.1 of the License, or
11   (at your option) any later version.
12
13   systemd is distributed in the hope that it will be useful, but
14   WITHOUT ANY WARRANTY; without even the implied warranty of
15   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16   Lesser General Public License for more details.
17
18   You should have received a copy of the GNU Lesser General Public License
19   along with systemd; If not, see <http://www.gnu.org/licenses/>.
20 ***/
21
22 #pragma once
23
24 #include <macro.h>
25
26 /* we can't use DUPLEX_ prefix, as it
27  * clashes with <linux/ethtool.h> */
28 typedef enum Duplex {
29         DUP_FULL,
30         DUP_HALF,
31         _DUP_MAX,
32         _DUP_INVALID = -1
33 } Duplex;
34
35 typedef enum WakeOnLan {
36         WOL_PHY,
37         WOL_MAGIC,
38         WOL_OFF,
39         _WOL_MAX,
40         _WOL_INVALID = -1
41 } WakeOnLan;
42
43 int ethtool_connect(int *ret);
44
45 int ethtool_get_driver(int *fd, const char *ifname, char **ret);
46 int ethtool_set_speed(int *fd, const char *ifname, unsigned int speed, Duplex duplex);
47 int ethtool_set_wol(int *fd, const char *ifname, WakeOnLan wol);
48
49 const char *duplex_to_string(Duplex d) _const_;
50 Duplex duplex_from_string(const char *d) _pure_;
51
52 const char *wol_to_string(WakeOnLan wol) _const_;
53 WakeOnLan wol_from_string(const char *wol) _pure_;
54
55 int config_parse_duplex(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
56 int config_parse_wol(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);