Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
AC_CHECK_HEADERS_ONCE([
ctype.h
errno.h
+ net/if.h
stdarg.h
stdio.h
stdlib.h
#############################################################################*/
#include <errno.h>
+#include <net/if.h>
#include <stdlib.h>
#include <string.h>
struct network_ctx* ctx;
int refcount;
+ unsigned int index;
char* name;
};
if (!name)
return -EINVAL;
+ unsigned int index = if_nametoindex(name);
+ if (!index) {
+ ERROR(ctx, "Could not find interface %s\n", name);
+ return -ENODEV;
+ }
+
struct network_interface* i = calloc(1, sizeof(*i));
if (!i)
return -ENOMEM;
// Initialise object
i->ctx = network_ref(ctx);
i->refcount = 1;
+ i->index = index;
i->name = strdup(name);
DEBUG(i->ctx, "Allocated network interface at %p\n", i);