Renaming libifc to libifconfig in response to feedback on initial commit of

this library. Sticking to 'libifconfig' (and 'ifconfig_' as function prefix)
should reduce chances of namespace collisions, make it more clear what the
library does, and be more in line with existing libraries.

Submitted by: Marie Helene Kvello-Aune <marieheleneka@gmail.com>
Differential Revision:	https://reviews.freebsd.org/D7742
Reviewed by:	cem, kp
This commit is contained in:
Kristof Provost
2016-09-02 18:33:08 +00:00
parent 2279a9a428
commit ec21434933
14 changed files with 128 additions and 129 deletions
-9
View File
@@ -1,9 +0,0 @@
# $FreeBSD$
default:
$(CC) -Wall -fPIC -lifc -g -o example_setdescription setdescription.c
$(CC) -Wall -fPIC -lifc -g -o example_setmtu setmtu.c
$(CC) -Wall -fPIC -lifc -g -o example_ifdestroy ifdestroy.c
$(CC) -Wall -fPIC -lifc -g -o example_ifcreate ifcreate.c
clean:
rm -f example_*
+8
View File
@@ -0,0 +1,8 @@
# $FreeBSD$
default:
$(CC) -Wall -fPIC -lifconfig -g -o example_setdescription setdescription.c
$(CC) -Wall -fPIC -lifconfig -g -o example_setmtu setmtu.c
$(CC) -Wall -fPIC -lifconfig -g -o example_ifdestroy ifdestroy.c
$(CC) -Wall -fPIC -lifconfig -g -o example_ifcreate ifcreate.c
clean:
rm -f example_*
@@ -37,7 +37,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <libifc.h>
#include <libifconfig.h>
int main(int argc, char *argv[])
@@ -55,21 +55,21 @@ int main(int argc, char *argv[])
printf("Requested interface name: %s\n", ifname);
libifc_handle_t *lifh = libifc_open();
if (libifc_create_interface(lifh, ifname, &ifactualname) == 0) {
ifconfig_handle_t *lifh = ifconfig_open();
if (ifconfig_create_interface(lifh, ifname, &ifactualname) == 0) {
printf("Successfully created interface '%s'\n", ifactualname);
libifc_close(lifh);
ifconfig_close(lifh);
lifh = NULL;
free(ifname);
free(ifactualname);
return (0);
} else {
switch (libifc_err_errtype(lifh)) {
switch (ifconfig_err_errtype(lifh)) {
case SOCKET:
warnx("couldn't create socket. This shouldn't happen.\n");
break;
case IOCTL:
if (libifc_err_ioctlreq(lifh) == SIOCIFCREATE2) {
if (ifconfig_err_ioctlreq(lifh) == SIOCIFCREATE2) {
warnx(
"Failed to create interface (SIOCIFCREATE2)\n");
}
@@ -79,12 +79,12 @@ int main(int argc, char *argv[])
"This is a thorough example accommodating for temporary"
" 'not implemented yet' errors. That's likely what happened"
" now. If not, your guess is as good as mine. ;)"
" Error code: %d\n", libifc_err_errno(
" Error code: %d\n", ifconfig_err_errno(
lifh));
break;
}
libifc_close(lifh);
ifconfig_close(lifh);
lifh = NULL;
free(ifname);
free(ifactualname);
@@ -37,7 +37,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <libifc.h>
#include <libifconfig.h>
int main(int argc, char *argv[])
@@ -55,20 +55,20 @@ int main(int argc, char *argv[])
printf("Interface name: %s\n", ifname);
libifc_handle_t *lifh = libifc_open();
if (libifc_destroy_interface(lifh, ifname) == 0) {
ifconfig_handle_t *lifh = ifconfig_open();
if (ifconfig_destroy_interface(lifh, ifname) == 0) {
printf("Successfully destroyed interface '%s'.", ifname);
libifc_close(lifh);
ifconfig_close(lifh);
lifh = NULL;
free(ifname);
return (0);
} else {
switch (libifc_err_errtype(lifh)) {
switch (ifconfig_err_errtype(lifh)) {
case SOCKET:
warnx("couldn't create socket. This shouldn't happen.\n");
break;
case IOCTL:
if (libifc_err_ioctlreq(lifh) == SIOCIFDESTROY) {
if (ifconfig_err_ioctlreq(lifh) == SIOCIFDESTROY) {
warnx(
"Failed to destroy interface (SIOCIFDESTROY)\n");
}
@@ -79,7 +79,7 @@ int main(int argc, char *argv[])
break;
}
libifc_close(lifh);
ifconfig_close(lifh);
lifh = NULL;
free(ifname);
return (-1);
@@ -35,7 +35,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <libifc.h>
#include <libifconfig.h>
int main(int argc, char *argv[])
@@ -54,27 +54,27 @@ int main(int argc, char *argv[])
printf("Interface name: %s\n", ifname);
libifc_handle_t *lifh = libifc_open();
if (libifc_get_description(lifh, ifname, &curdescr) == 0) {
ifconfig_handle_t *lifh = ifconfig_open();
if (ifconfig_get_description(lifh, ifname, &curdescr) == 0) {
printf("Old description: %s\n", curdescr);
}
printf("New description: %s\n\n", ifdescr);
if (libifc_set_description(lifh, ifname, ifdescr) == 0) {
if (ifconfig_set_description(lifh, ifname, ifdescr) == 0) {
printf("New description successfully set.\n");
} else {
switch (libifc_err_errtype(lifh)) {
switch (ifconfig_err_errtype(lifh)) {
case SOCKET:
err(libifc_err_errno(lifh), "Socket error");
err(ifconfig_err_errno(lifh), "Socket error");
break;
case IOCTL:
err(libifc_err_errno(
err(ifconfig_err_errno(
lifh), "IOCTL(%lu) error",
libifc_err_ioctlreq(lifh));
ifconfig_err_ioctlreq(lifh));
break;
case OTHER:
err(libifc_err_errno(lifh), "Other error");
err(ifconfig_err_errno(lifh), "Other error");
break;
}
}
@@ -86,6 +86,6 @@ int main(int argc, char *argv[])
ifdescr = NULL;
curdescr = NULL;
libifc_close(lifh);
ifconfig_close(lifh);
return (0);
}
@@ -37,7 +37,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <libifc.h>
#include <libifconfig.h>
int main(int argc, char *argv[])
@@ -58,26 +58,26 @@ int main(int argc, char *argv[])
printf("Interface name: %s\n", ifname);
printf("New MTU: %d", mtu);
libifc_handle_t *lifh = libifc_open();
if (libifc_set_mtu(lifh, ifname, mtu) == 0) {
ifconfig_handle_t *lifh = ifconfig_open();
if (ifconfig_set_mtu(lifh, ifname, mtu) == 0) {
printf("Successfully changed MTU of %s to %d\n", ifname, mtu);
libifc_close(lifh);
ifconfig_close(lifh);
lifh = NULL;
free(ifname);
return (0);
} else {
switch (libifc_err_errtype(lifh)) {
switch (ifconfig_err_errtype(lifh)) {
case SOCKET:
warnx("couldn't create socket. This shouldn't happen.\n");
break;
case IOCTL:
if (libifc_err_ioctlreq(lifh) == SIOCSIFMTU) {
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",
libifc_err_ioctlreq(lifh),
libifc_err_errno(lifh));
ifconfig_err_ioctlreq(lifh),
ifconfig_err_errno(lifh));
}
break;
default:
@@ -86,7 +86,7 @@ int main(int argc, char *argv[])
break;
}
libifc_close(lifh);
ifconfig_close(lifh);
lifh = NULL;
free(ifname);
return (-1);