Move if_nameindex to libinetutils.

Build if_nametoindex() and if_nameindex() in libinetutils.a
if they are missing in the system library.
This commit is contained in:
Mats Erik Andersson
2012-11-28 18:32:53 +01:00
parent e9a6037fb1
commit 0dc3545ca8
10 changed files with 46 additions and 42 deletions

View File

@@ -1,3 +1,30 @@
2012-11-28 Mats Erik Andersson <gnu@gisladisker.se>
libinetutils.a: Build if_nametoindex(), if_nameindex(),
and if_freenameindex() into library, if they are missing
in the system library.
* libinetutils/Makefile.am (libinetutils_a_SOURCES):
Add if_index.c.
* libinetutils/if_index.c: Moved from old location at
`ifconfig/if_index.c'. Do not include <ifconfig.h>.
* libinetutils/libinetutils.h (if_nameindex)
[!HAVE_STRUCT_IF_NAMEINDEX): New structure declaration.
(if_nametoindex, if_nameindex, if_freenameindex)
[!HAVE_STRUCT_IF_NAMEINDEX): New function declarations.
* ifconfig/Makefile.am (ifconfig_SOURCES): Remove if_index.c.
(noinst_HEADERS): Remove if_index.h.
* ifconfig/if_index.c, ifconfig/if_index.h: Deleted files.
* ifconfig/ifconfig.h: Do not include "if_index.h".
* ifconfig/system.h: Do not include <if_index.h>.
Test script for ifconfig utility.
* tests/ifconfig.sh: New file.
* tests/Makefile.am (dist_check_SCRIPTS) [ENABLE_ifconfig]:
Add ifconfig.sh.
2012-11-23 Mats Erik Andersson <gnu@gisladisker.se>
syslogd: Reusable IP sockets.

1
TODO
View File

@@ -129,7 +129,6 @@ Ability to ping multiple host in one go.
* ifconfig
** Implement flags support in changeif.c and options.c
** Fix and move if_index.c to libinetutils.
** Port to BSD.
** Make sure it is a drop in replacement at least for the most
common options on Linux and BSD.

View File

@@ -23,9 +23,9 @@ bin_PROGRAMS = $(ifconfig_BUILD)
EXTRA_PROGRAMS = ifconfig
ifconfig_SOURCES = ifconfig.c flags.c changeif.c options.c printif.c system.c if_index.c
ifconfig_SOURCES = ifconfig.c flags.c changeif.c options.c printif.c system.c
noinst_HEADERS = ifconfig.h if_index.h flags.h options.h printif.h system.h
noinst_HEADERS = ifconfig.h flags.h options.h printif.h system.h
@PATHDEFS_MAKE@
AM_CPPFLAGS = $(PATHDEF_PROCNET_DEV)

View File

@@ -1,34 +0,0 @@
/*
Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
2010, 2011, 2012 Free Software Foundation, Inc.
This file is part of GNU Inetutils.
GNU Inetutils is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or (at
your option) any later version.
GNU Inetutils 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
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see `http://www.gnu.org/licenses/'. */
#ifndef IF_INDEX_H
# define IF_INDEX_H
# ifndef HAVE_STRUCT_IF_NAMEINDEX
struct if_nameindex
{
char *if_name;
int if_index;
};
extern unsigned int if_nametoindex (const char *ifname);
extern struct if_nameindex *if_nameindex (void);
extern void if_freenameindex (struct if_nameindex *ptr);
# endif
#endif

View File

@@ -23,7 +23,6 @@
# define IFCONFIG_IFCONFIG_H
# include "flags.h"
# include "if_index.h"
# include "options.h"
# include "printif.h"
# include "system.h"

View File

@@ -23,8 +23,6 @@
# define IFCONFIG_SYSTEM_H
# include <if_index.h>
/* Option parsing. */
extern struct argp_child system_argp_child;

View File

@@ -30,6 +30,7 @@ libinetutils_a_SOURCES = \
daemon.c\
defauthors.c\
des_rw.c\
if_index.c \
kcmd.c\
krcmd.c\
localhost.c\

View File

@@ -36,8 +36,6 @@
#include <sys/ioctl.h>
#include <net/if.h>
#include <ifconfig.h>
#ifndef HAVE_STRUCT_IF_NAMEINDEX
unsigned int
if_nametoindex (const char *ifname)

View File

@@ -33,6 +33,18 @@ void logwtmp (const char *, const char *, const char *);
void cleanup_session (char *tty, int pty_fd);
void logwtmp_keep_open (char *line, char *name, char *host);
#ifndef HAVE_STRUCT_IF_NAMEINDEX
struct if_nameindex
{
char *if_name;
int if_index;
};
unsigned int if_nametoindex (const char *ifname);
struct if_nameindex *if_nameindex (void);
void if_freenameindex (struct if_nameindex *ptr);
#endif
extern const char *default_program_authors[];
#define iu_argp_init(name, authors) \

View File

@@ -68,6 +68,10 @@ if ENABLE_dnsdomainname
dist_check_SCRIPTS += dnsdomainname.sh
endif
if ENABLE_ifconfig
dist_check_SCRIPTS += ifconfig.sh
endif
TESTS = localhost waitdaemon $(dist_check_SCRIPTS)
TESTS_ENVIRONMENT = EXEEXT=$(EXEEXT)