]> git.ipfire.org Git - people/ms/network.git/commitdiff
Add new libnetwork
authorMichael Tremer <michael.tremer@ipfire.org>
Sun, 20 Aug 2017 12:03:13 +0000 (12:03 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Sun, 20 Aug 2017 12:03:13 +0000 (12:03 +0000)
This is going to be a central place to all things that needed
to be implemented in C here.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
.gitignore
Makefile.am
configure.ac
src/inetcalc.c
src/libnetwork/libnetwork-private.h [new file with mode: 0644]
src/libnetwork/libnetwork.c [new file with mode: 0644]
src/libnetwork/libnetwork.sym [new file with mode: 0644]
src/libnetwork/network/libnetwork.h [new file with mode: 0644]
src/network.pc.in

index ad5e18f0fe34162a1eacd6b7d9bce7d19d6585a1..4795273034a190d49dda1e76caaf50da4b33667b 100644 (file)
@@ -1,8 +1,11 @@
 /Makefile
 /build-aux
+/config.*
+/libtool
 /missing
 /src/functions/functions
 /src/inetcalc
+/src/libnetwork/libnetwork.pc
 /src/network.pc
 /src/ppp/ip-updown
 /src/systemd/*.service
 /*.tar.xz
 *.log
 *.cache
+*.la
+*.lo
 *.o
 *.stamp
 *.trs
 *~
 .deps
 .dirstamp
+.libs
 Makefile.in
 aclocal.m4
 config.status
index c18c460a04cfdaab52b69acb9bec8296c71f6af1..40026aa693683560b0dd2fe0d85cbbc0f2e6a7c0 100644 (file)
@@ -30,7 +30,7 @@ AUTOMAKE_OPTIONS = color-tests
 
 bashcompletiondir= $(datadir)/bash-completion/completions
 libexecdir       = $(prefix)/lib
-pkgconfigdatadir = $(datadir)/pkgconfig
+pkgconfigdir     = $(libdir)/pkgconfig
 pppdir           = $(sysconfdir)/ppp
 systemconfigdir  = $(datadir)/network
 sysctldir        = $(prefix)/lib/sysctl.d
@@ -59,9 +59,21 @@ INSTALL_EXEC_HOOKS =
 UNINSTALL_EXEC_HOOKS =
 noinst_DATA =
 
-AM_CFLAGS       = $(OUR_CFLAGS)
-AM_CPPFLAGS     = $(OUR_CPPFLAGS)
-AM_LDFLAGS      = $(OUR_LDFLAGS)
+AM_CPPFLAGS = \
+       $(OUR_CPPFLAGS) \
+       -include $(top_builddir)/config.h \
+       -I${top_srcdir}/src/libnetwork
+
+AM_CFLAGS = \
+       $(OUR_CFLAGS) \
+       -fvisibility=hidden \
+       -ffunction-sections \
+       -fdata-sections
+
+AM_LDFLAGS = \
+       $(OUR_LDFLAGS) \
+       -Wl,--gc-sections \
+       -Wl,--as-needed
 
 DISTCHECK_CONFIGURE_FLAGS = \
        --with-systemdsystemunitdir=$$dc_install_base/$(systemdsystemunitdir) \
@@ -190,6 +202,9 @@ bin_PROGRAMS = \
 src_inetcalc_SOURCES = \
        src/inetcalc.c
 
+src_inetcalc_LDADD = \
+       src/libnetwork.la
+
 dist_hooks_configs_SCRIPTS = \
        src/hooks/configs/dhcp \
        src/hooks/configs/ipv4-static \
@@ -214,6 +229,33 @@ dist_hooks_zones_SCRIPTS = \
 
 # ------------------------------------------------------------------------------
 
+LIBNETWORK_CURRENT=0
+LIBNETWORK_REVISION=0
+LIBNETWORK_AGE=0
+
+pkginclude_HEADERS = \
+       src/libnetwork/network/libnetwork.h
+
+lib_LTLIBRARIES = \
+       src/libnetwork.la
+
+src_libnetwork_la_SOURCES = \
+       src/libnetwork/libnetwork-private.h \
+       src/libnetwork/libnetwork.c
+
+src_libnetwork_la_LDFLAGS = \
+       $(AM_LDFLAGS) \
+       -version-info $(LIBNETWORK_CURRENT):$(LIBNETWORK_REVISION):$(LIBNETWORK_AGE) \
+       -Wl,--version-script=$(top_srcdir)/src/libnetwork/libnetwork.sym
+
+src_libnetwork_la_DEPENDENCIES = \
+       src/libnetwork/libnetwork.sym
+
+EXTRA_DIST += \
+       src/libnetwork/libnetwork.sym
+
+# ------------------------------------------------------------------------------
+
 ppp_SCRIPTS = \
        src/ppp/ip-updown
 
@@ -309,11 +351,11 @@ endif
 
 # ------------------------------------------------------------------------------
 
-pkgconfigdata_DATA = \
+pkgconfig_DATA = \
        src/network.pc
 
 CLEANFILES += \
-       $(pkgconfigdata_DATA)
+       $(pkgconfig_DATA)
 
 EXTRA_DIST += \
        src/network.pc.in
index df6d64993027ea5450508fb638dd4f0b8cc48e54..b2c06d0f0acfc549c1529170a36f8bfbf16b1a4d 100644 (file)
@@ -41,6 +41,11 @@ AM_INIT_AUTOMAKE([
 ])
 AM_SILENT_RULES([yes])
 
+LT_INIT([
+       disable-static
+       pic-only
+])
+
 AC_PROG_LN_S
 AC_PROG_MKDIR_P
 AC_PROG_SED
@@ -103,6 +108,7 @@ AC_SUBST([udevdir], [$with_udevdir])
 AM_CONDITIONAL(HAVE_UDEV, [test -n "$with_udevdir"])
 
 # ------------------------------------------------------------------------------
+AC_CONFIG_HEADERS(config.h)
 AC_CONFIG_FILES([
        Makefile
 ])
index da3444e00c5d283f405368d24676f67f20af66d7..1841c84065975b7e9beff194f8a67bc81118d12a 100644 (file)
@@ -28,6 +28,8 @@
 #include <string.h>
 #include <sys/socket.h>
 
+#include <network/libnetwork.h>
+
 typedef struct ip_address {
        int family;
        struct in6_addr addr;
@@ -513,7 +515,7 @@ int main(int argc, char** argv) {
        int family = AF_UNSPEC;
 
        while (1) {
-               int c = getopt_long(argc, argv, "46bcefgnpsv", long_options, &option_index);
+               int c = getopt_long(argc, argv, "46bcefgnpsviV", long_options, &option_index);
                if (c == -1)
                        break;
 
@@ -580,6 +582,11 @@ int main(int argc, char** argv) {
                                verbose = 1;
                                break;
 
+                       case 'V':
+                               printf("%s\n", network_version());
+                               exit(0);
+                               break;
+
                        case '?':
                                break;
 
diff --git a/src/libnetwork/libnetwork-private.h b/src/libnetwork/libnetwork-private.h
new file mode 100644 (file)
index 0000000..d94f395
--- /dev/null
@@ -0,0 +1,26 @@
+/*#############################################################################
+#                                                                             #
+# IPFire.org - A linux based firewall                                         #
+# Copyright (C) 2017 IPFire Network Development Team                          #
+#                                                                             #
+# This program 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.                                         #
+#                                                                             #
+# This program 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 LIBNETWORK_PRIVATE_H
+#define LIBNETWORK_PRIVATE_H
+
+#define NETWORK_EXPORT __attribute__ ((visibility("default")))
+
+#endif
diff --git a/src/libnetwork/libnetwork.c b/src/libnetwork/libnetwork.c
new file mode 100644 (file)
index 0000000..629a6b1
--- /dev/null
@@ -0,0 +1,26 @@
+/*#############################################################################
+#                                                                             #
+# IPFire.org - A linux based firewall                                         #
+# Copyright (C) 2017 IPFire Network Development Team                          #
+#                                                                             #
+# This program 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.                                         #
+#                                                                             #
+# This program 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/>.       #
+#                                                                             #
+#############################################################################*/
+
+#include <network/libnetwork.h>
+#include "libnetwork-private.h"
+
+NETWORK_EXPORT const char* network_version() {
+       return "network " VERSION;
+}
diff --git a/src/libnetwork/libnetwork.sym b/src/libnetwork/libnetwork.sym
new file mode 100644 (file)
index 0000000..5a5a464
--- /dev/null
@@ -0,0 +1,6 @@
+LIBNETWORK_0 {
+global:
+        network_version;
+local:
+        *;
+};
diff --git a/src/libnetwork/network/libnetwork.h b/src/libnetwork/network/libnetwork.h
new file mode 100644 (file)
index 0000000..615a628
--- /dev/null
@@ -0,0 +1,26 @@
+/*#############################################################################
+#                                                                             #
+# IPFire.org - A linux based firewall                                         #
+# Copyright (C) 2017 IPFire Network Development Team                          #
+#                                                                             #
+# This program 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.                                         #
+#                                                                             #
+# This program 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 LIBNETWORK_H
+#define LIBNETWORK_H
+
+const char* network_version();
+
+#endif
index fd3af83313eee3e217c8cfeacff26d17c6de718f..8df548cc382499b12c412f96aafce963aeb303a8 100644 (file)
 
 prefix=@prefix@
 exec_prefix=@exec_prefix@
+includedir=@includedir@
+libdir=@libdir@
 networkdir=@networkdir@
 
 Name: network
 Description: Network configuration tools for IPFire
 URL: @PACKAGE_URL@
 Version: @PACKAGE_VERSION@
+Libs: -L${libdir} -lnetwork
+Libs.private:
+Cflags: -I${includedir}