/***
This file is part of systemd.
Copyright (C) 2013 Tom Gundersen <teg@jklm.no>
under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
systemd 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
#include "conf-parser.h"
#include "ethtool-util.h"
#include "log.h"
#include "string-table.h"
#include "strxcpyx.h"
#include "util.h"
[DUP_FULL] = "full",
[DUP_HALF] = "half"
};
[WOL_PHY] = "phy",
[WOL_MAGIC] = "magic",
[WOL_OFF] = "off"
};
int fd;
if (fd < 0)
return -errno;
return 0;
}
};
};
char *d;
int r;
if (*fd < 0) {
r = ethtool_connect(fd);
if (r < 0)
return log_warning_errno(r, "link_config: could not connect to ethtool: %m");
}
if (r < 0)
return -errno;
if (!d)
return -ENOMEM;
*ret = d;
return 0;
}
.cmd = ETHTOOL_GSET
};
};
bool need_update = false;
int r;
return 0;
if (*fd < 0) {
r = ethtool_connect(fd);
if (r < 0)
return log_warning_errno(r, "link_config: could not connect to ethtool: %m");
}
if (r < 0)
return -errno;
need_update = true;
}
switch (duplex) {
case DUP_HALF:
need_update = true;
}
break;
case DUP_FULL:
need_update = true;
}
break;
default:
break;
}
if (need_update) {
if (r < 0)
return -errno;
}
return 0;
}
.cmd = ETHTOOL_GWOL
};
};
bool need_update = false;
int r;
if (wol == _WOL_INVALID)
return 0;
if (*fd < 0) {
r = ethtool_connect(fd);
if (r < 0)
return log_warning_errno(r, "link_config: could not connect to ethtool: %m");
}
if (r < 0)
return -errno;
switch (wol) {
case WOL_PHY:
need_update = true;
}
break;
case WOL_MAGIC:
need_update = true;
}
break;
case WOL_OFF:
need_update = true;
}
break;
default:
break;
}
if (need_update) {
if (r < 0)
return -errno;
}
return 0;
}