summaryrefslogtreecommitdiff
path: root/share/examples/libifconfig/setmtu.c
diff options
context:
space:
mode:
authorKristof Provost <kp@FreeBSD.org>2016-09-04 20:55:27 +0000
committerKristof Provost <kp@FreeBSD.org>2016-09-04 20:55:27 +0000
commit9a2ff3154b811a8210a7eca5531e233c69ed5924 (patch)
tree12d81ea7d75d0d61a9df62021c064a4ed9bdcecc /share/examples/libifconfig/setmtu.c
parent4e8a91fb6c8ce47a96e80efa93e79d8f55df8310 (diff)
downloadsrc-test2-9a2ff3154b811a8210a7eca5531e233c69ed5924.tar.gz
src-test2-9a2ff3154b811a8210a7eca5531e233c69ed5924.zip
Notes
Diffstat (limited to 'share/examples/libifconfig/setmtu.c')
-rw-r--r--share/examples/libifconfig/setmtu.c58
1 files changed, 28 insertions, 30 deletions
diff --git a/share/examples/libifconfig/setmtu.c b/share/examples/libifconfig/setmtu.c
index 4d5a0f8d5f92..1f8f33873ecf 100644
--- a/share/examples/libifconfig/setmtu.c
+++ b/share/examples/libifconfig/setmtu.c
@@ -12,9 +12,6 @@
* this list of conditions and the following disclaimer in the documentation and/or
* other materials provided with the distribution.
*
- * 3. Neither the name of the copyright holder nor the names of its contributors
- * may be used to endorse or promote products derived from this software without
- * specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
@@ -40,17 +37,18 @@
#include <libifconfig.h>
-int main(int argc, char *argv[])
+int
+main(int argc, char *argv[])
{
+ char *ifname, *ptr;
+ int mtu;
+
if (argc != 3) {
errx(EINVAL, "Invalid number of arguments."
" First argument should be interface name, second argument"
" should be the MTU to set.");
}
- char *ifname, *ptr;
- int mtu;
-
/* We have a static number of arguments. Therefore we can do it simple. */
ifname = strdup(argv[1]);
mtu = (int)strtol(argv[2], &ptr, 10);
@@ -65,30 +63,30 @@ int main(int argc, char *argv[])
lifh = NULL;
free(ifname);
return (0);
- } else {
- switch (ifconfig_err_errtype(lifh)) {
- case SOCKET:
- warnx("couldn't create socket. This shouldn't happen.\n");
- break;
- case IOCTL:
- if (ifconfig_err_ioctlreq(lifh) == SIOCSIFMTU) {
- warnx("Failed to set MTU (SIOCSIFMTU)\n");
- } else {
- warnx(
- "Failed to set MTU due to error in unexpected ioctl() call %lu. Error code: %i.\n",
- ifconfig_err_ioctlreq(lifh),
- ifconfig_err_errno(lifh));
- }
- break;
- default:
+ }
+
+ switch (ifconfig_err_errtype(lifh)) {
+ case SOCKET:
+ warnx("couldn't create socket. This shouldn't happen.\n");
+ break;
+ case IOCTL:
+ if (ifconfig_err_ioctlreq(lifh) == SIOCSIFMTU) {
+ warnx("Failed to set MTU (SIOCSIFMTU)\n");
+ } else {
warnx(
- "Should basically never end up here in this example.\n");
- break;
+ "Failed to set MTU due to error in unexpected ioctl() call %lu. Error code: %i.\n",
+ ifconfig_err_ioctlreq(lifh),
+ ifconfig_err_errno(lifh));
}
-
- ifconfig_close(lifh);
- lifh = NULL;
- free(ifname);
- return (-1);
+ break;
+ default:
+ warnx(
+ "Should basically never end up here in this example.\n");
+ break;
}
+
+ ifconfig_close(lifh);
+ lifh = NULL;
+ free(ifname);
+ return (-1);
}