[PATCH] CMake project lists for toplevel matahari
by Adam Stokes
---
CMakeLists.txt | 11 +++++++++++
config.h.in | 2 ++
2 files changed, 13 insertions(+), 0 deletions(-)
create mode 100644 CMakeLists.txt
create mode 100644 config.h.in
diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644
index 0000000..2a30360
--- /dev/null
+++ b/CMakeLists.txt
@@ -0,0 +1,11 @@
+cmake_minimum_required(VERSION 2.6)
+project (MATAHARI)
+
+# add sub-directories
+add_subdirectory(src)
+
+# check includes
+include (CheckIncludeFiles)
+check_include_files (string.h HAVE_STRING_H)
+check_include_files (sys/ioctl.h HAVE_SYS_IOCTL_H)
+configure_file (${CMAKE_CURRENT_SOURCE_DIR}/config.h.in ${CMAKE_CURRENT_BINARY_DIR}/config.h)
diff --git a/config.h.in b/config.h.in
new file mode 100644
index 0000000..e67866b
--- /dev/null
+++ b/config.h.in
@@ -0,0 +1,2 @@
+#cmakedefine HAVE_STRING_H 1
+#cmakedefine HAVE_SYS_IOCTL_H 1
--
1.7.2.2
13 years, 8 months
Matahari compilation on F13
by Arthur Clément
Hi,
I'm trying to compile matahari on F13 and I got errors
./autogen.sh
configure.ac:8: required directory ./build-aux does not exist
configure.ac: no proper invocation of AM_INIT_AUTOMAKE was found.
configure.ac: You should verify that configure.ac invokes AM_INIT_AUTOMAKE,
configure.ac: that aclocal.m4 is present in the top-level directory,
configure.ac: and that aclocal.m4 was recently regenerated (using aclocal).
src/Makefile.am:24: compiling `util.c' with per-target flags requires
`AM_PROG_CC_C_O' in `configure.ac'
cp: cannot create regular file `build-aux/depcomp': No such file or directory
src/Makefile.am: installing `build-aux/depcomp'
src/Makefile.am: error while copying
/usr/share/automake-1.11/am/depend2.am: am__fastdepCC does not appear in
AM_CONDITIONAL
/usr/share/automake-1.11/am/depend2.am: The usual way to define
`am__fastdepCC' is to add `AC_PROG_CC'
/usr/share/automake-1.11/am/depend2.am: to `configure.ac' and run `aclocal'
and `autoconf' again.
/usr/share/automake-1.11/am/depend2.am: AMDEP does not appear in
AM_CONDITIONAL
/usr/share/automake-1.11/am/depend2.am: The usual way to define `AMDEP' is to
add one of the compiler tests
/usr/share/automake-1.11/am/depend2.am: AC_PROG_CC, AC_PROG_CXX,
AC_PROG_CXX, AC_PROG_OBJC,
/usr/share/automake-1.11/am/depend2.am: AM_PROG_AS, AM_PROG_GCJ,
AM_PROG_UPC
/usr/share/automake-1.11/am/depend2.am: to `configure.ac' and run `aclocal'
and `autoconf' again.
/usr/share/automake-1.11/am/depend2.am: am__fastdepCXX does not appear in
AM_CONDITIONAL
/usr/share/automake-1.11/am/depend2.am: The usual way to define
`am__fastdepCXX' is to add `AC_PROG_CXX'
/usr/share/automake-1.11/am/depend2.am: to `configure.ac' and run `aclocal'
and `autoconf' again.
Makefile.am: installing `./INSTALL'
configure.ac:66: required file `lib/Makefile.in' not found
Makefile.am:3: required directory ./lib does not exist
configure.ac:12: error: possibly undefined macro: AM_INIT_AUTOMAKE
If this token and others are legitimate, please use m4_pattern_allow.
See the Autoconf documentation.
I created build-aux and lib folders, and restart autogen :
./autogen.sh
configure.ac: no proper invocation of AM_INIT_AUTOMAKE was found.
configure.ac: You should verify that configure.ac invokes AM_INIT_AUTOMAKE,
configure.ac: that aclocal.m4 is present in the top-level directory,
configure.ac: and that aclocal.m4 was recently regenerated (using aclocal).
src/Makefile.am:24: compiling `util.c' with per-target flags requires
`AM_PROG_CC_C_O' in `configure.ac'
src/Makefile.am: installing `build-aux/depcomp'
/usr/share/automake-1.11/am/depend2.am: am__fastdepCC does not appear in
AM_CONDITIONAL
/usr/share/automake-1.11/am/depend2.am: The usual way to define
`am__fastdepCC' is to add `AC_PROG_CC'
/usr/share/automake-1.11/am/depend2.am: to `configure.ac' and run `aclocal'
and `autoconf' again.
/usr/share/automake-1.11/am/depend2.am: AMDEP does not appear in
AM_CONDITIONAL
/usr/share/automake-1.11/am/depend2.am: The usual way to define `AMDEP' is to
add one of the compiler tests
/usr/share/automake-1.11/am/depend2.am: AC_PROG_CC, AC_PROG_CXX,
AC_PROG_CXX, AC_PROG_OBJC,
/usr/share/automake-1.11/am/depend2.am: AM_PROG_AS, AM_PROG_GCJ,
AM_PROG_UPC
/usr/share/automake-1.11/am/depend2.am: to `configure.ac' and run `aclocal'
and `autoconf' again.
/usr/share/automake-1.11/am/depend2.am: am__fastdepCXX does not appear in
AM_CONDITIONAL
/usr/share/automake-1.11/am/depend2.am: The usual way to define
`am__fastdepCXX' is to add `AC_PROG_CXX'
/usr/share/automake-1.11/am/depend2.am: to `configure.ac' and run `aclocal'
and `autoconf' again.
configure.ac:66: required file `lib/Makefile.in' not found
I also tried without success the spec from matahari-0.0.5-1.fc13.
--
Arthur CLEMENT
Linagora Paris
13 years, 8 months
[PATCH] start of mingw32-matahari spec
by Adam Stokes
---
mingw32-matahari.spec.in | 115 ++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 115 insertions(+), 0 deletions(-)
create mode 100644 mingw32-matahari.spec.in
diff --git a/mingw32-matahari.spec.in b/mingw32-matahari.spec.in
new file mode 100644
index 0000000..8113629
--- /dev/null
+++ b/mingw32-matahari.spec.in
@@ -0,0 +1,115 @@
+%global __strip %{_mingw32_strip}
+%global __objdump %{_mingw32_objdump}
+%global _use_internal_dependency_generator 0
+%global __find_requires %{_mingw32_findrequires}
+%global __find_provides %{_mingw32_findprovides}
+
+Name: mingw32-matahari
+Version: @VERSION@
+Release: 7%{?dist}
+Summary: Qpid QMF Agent for Ovirt Nodes
+
+Group: Applications/System
+License: GPLv2
+URL: http://fedorahosted.org/matahari
+Source0: http://astokes.fedorapeople.org/matahari/%{name}-%{version}.tar.gz
+BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%__id_u} -n)
+
+BuildRequires: mingw32-filesystem >= 56
+BuildRequires: mingw32-readline
+BuildRequires: mingw32-binutils
+BuildRequires: mingw32-libxml2
+BuildRequires: mingw32-libxslt
+BuildRequires: mingw32-gcc
+BuildRequires: mingw32-gettext
+BuildRequires: mingw32-w32api
+BuildRequires: mingw32-pcre
+BuildRequires: mingw32-qpid
+BuildArch: noarch
+
+%description
+
+matahari provides a QMF Agent that can be used to control and manage
+various pieces of functionality for an ovirt node, using the AMQP protocol.
+
+The Advanced Message Queuing Protocol (AMQP) is an open standard application
+layer protocol providing reliable transport of messages.
+
+QMF provides a modeling framework layer on top of qpid (which implements
+AMQP). This interface allows you to manage a host and its various components
+as a set of objects with properties and methods.
+
+MinGW cross-compiled Windows application.
+
+%prep
+%setup -q
+
+%build
+PATH=%{_mingw32_bindir}:$PATH \
+%{_mingw32-cmake}
+make %{?_smp_mflags}
+
+%install
+rm -rf $RPM_BUILD_ROOT
+make install DESTDIR=$RPM_BUILD_ROOT
+
+%post
+# win specific
+
+%preun
+# win specific
+
+%postun
+# win specific
+
+%files
+%defattr(-,root,root,-)
+%{_mingw32_bindir}/matahari-host.exe
+%{_mingw32_datadir}/matahari
+
+%config(noreplace) %{_sysconfdir}/sysconfig/matahari
+
+%doc AUTHORS COPYING
+
+%changelog
+* Fri Sep 03 2010 Adam Stokes <ajs(a)redhat.com - 0.0.4-8
+- MinGW cross compiled
+
+* Thu Oct 08 2009 Arjun Roy <arroy(a)redhat.com> - 0.0.4-7
+- Refactored for new version of qpidc.
+
+* Fri Oct 02 2009 Kevin Kofler <Kevin(a)tigcc.ticalc.org> - 0.0.4-6
+- Rebuild for new qpidc.
+
+* Sat Jul 25 2009 Fedora Release Engineering <rel-eng(a)lists.fedoraproject.org> - 0.0.4-5
+- Rebuilt for https://fedoraproject.org/wiki/Fedora_12_Mass_Rebuild
+
+* Thu Jul 16 2009 Arjun Roy <arroy(a)redhat.com> - 0.0.4-4
+- Changed buildroot value to meet fedora packaging guidelines
+- Updated project website
+
+* Mon Jul 13 2009 Arjun Roy <arroy(a)redhat.com> - 0.0.4-3
+- Quietened rpmlint errors and warnings.
+- Fixed most gcc warnings.
+- Changed init script so it doesn't run by default
+- Now rpm specfile makes it so service runs by default instead
+
+* Thu Jul 9 2009 Arjun Roy <arroy(a)redhat.com> - 0.0.4-2
+- Bumped qpidc and qmf version requirements to 0.5.790661.
+
+* Thu Jul 9 2009 Arjun Roy <arroy(a)redhat.com> - 0.0.4-1
+- Removed dependency on boost. Added dependency on pcre.
+
+* Thu Jul 2 2009 Arjun Roy <arroy(a)redhat.com> - 0.0.3-2
+- Fixed bug with not publishing host hypervisor and arch to broker
+- Updated aclocal.m4 to match new version of automake
+
+* Tue Jun 30 2009 Arjun Roy <arroy(a)redhat.com> - 0.0.3-1
+- Added getopt and daemonize support
+- Added sysV init script support
+
+* Mon Jun 29 2009 Arjun Roy <arroy(a)redhat.com> - 0.0.2-1
+- Now tracks hypervisor and arch using libvirt
+
+* Tue Jun 23 2009 Arjun Roy <arroy(a)redhat.com> - 0.0.1-1
+- Initial rpmspec packaging
--
1.7.2.2
13 years, 8 months
[PATCH 1/5] Set service vars Created matahar-host service
by Adam Stokes
---
src/CMakeLists.txt | 19 ++++++++++++-------
1 files changed, 12 insertions(+), 7 deletions(-)
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index fdcbbe4..b16668d 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -10,10 +10,15 @@ include_directories("${PROJECT_SOURCE_DIR}/qmf")
set(PCRE_PATH "D:/Users/mcpierce/Programming/pcre-7.0")
set(QPID_PATH "C:/Program Files/Apache/qpid-0.6")
+# set service name var's
+set(M_HOST "matahari-host")
+set(M_NET "matahari-net")
+set(M_PKG "matahari-package")
+
set(SCHEMAS
schema-host.xml)
-set(MAIN_SOURCES
+set(HOST_SOURCES
host.cpp
main.cpp
processor.cpp
@@ -31,7 +36,7 @@ set(GENERATED_SCHEMA_SOURCES
qmf/com/redhat/matahari/host/Processor.cpp
qmf/com/redhat/matahari/host/Processor.h)
-add_executable(matahari ${MAIN_SOURCES} ${GENERATED_SCHEMA_SOURCES})
+add_executable(${M_HOST} ${HOST_SOURCES} ${GENERATED_SCHEMA_SOURCES})
pkg_check_modules(pcre REQUIRED libpcre)
@@ -40,10 +45,10 @@ if(NOT PKG_CONFIG_FOUND)
endif(NOT PKG_CONFIG_FOUND)
if(WIN32)
- target_link_libraries(matahari wsock32)
+ target_link_libraries(${M_HOST} wsock32)
else(WIN32)
find_library(VIRT virt)
- target_link_libraries(matahari ${VIRT})
+ target_link_libraries(${M_HOST} ${VIRT})
endif(WIN32)
if(MSVC)
@@ -69,7 +74,7 @@ if(NOT QPIDCOMMON)
message(FATAL_ERROR "QPIDCOMMON library not found.")
endif(NOT QPIDCOMMON)
-target_link_libraries(matahari ${QPIDCOMMON} ${QPIDCLIENT} ${QMF})
+target_link_libraries(${M_HOST} ${QPIDCOMMON} ${QPIDCLIENT} ${QMF})
if(NOT pcre_FOUND)
IF(MSVC)
@@ -84,7 +89,7 @@ if(NOT pcre_FOUND)
endif(NOT pcre_FOUND)
if(pcre_FOUND)
- target_link_libraries(matahari ${pcre_LIBRARIES})
+ target_link_libraries(${M_HOST} ${pcre_LIBRARIES})
include_directories(${pcre_INCLUDE_DIRS})
else(pcre_FOUND)
message(FATAL_ERROR "PCRE header/library not found.")
@@ -94,7 +99,7 @@ set(simple_libs check libvirt udev_new)
foreach(lib ${simple_libs})
find_library(${lib}_LIBRARIES ${lib})
if(${lib}_LIBRARIES)
- target_link_libraries(matahari ${${lib}_LIBRARIES}})
+ target_link_libraries(${M_HOST} ${${lib}_LIBRARIES}})
else(${lib}_LIBRARIES)
message("Library ${lib} not found")
endif(${lib}_LIBRARIES)
--
1.7.2.2
13 years, 8 months
[PATCH] matahari win installer
by Adam Stokes
---
matahari-wininst.nsi | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 50 insertions(+), 0 deletions(-)
create mode 100755 matahari-wininst.nsi
diff --git a/matahari-wininst.nsi b/matahari-wininst.nsi
new file mode 100755
index 0000000..d8098a1
--- /dev/null
+++ b/matahari-wininst.nsi
@@ -0,0 +1,50 @@
+; matahari-wininst.nsi
+; prompt for dir; copy files
+;--------------------------------
+
+; The name of the installer
+Name "matahari installer"
+
+; The file to write
+OutFile "matahari-setup.exe"
+
+; The default installation directory
+InstallDir $PROGRAMFILES\matahari
+
+; Request application privileges for Windows Vista
+RequestExecutionLevel user
+
+;--------------------------------
+
+; Pages
+
+Page directory
+Page instfiles
+
+;--------------------------------
+
+; The stuff to install
+Section "" ;No components page, name is not important
+
+ ; Set output path to the installation directory.
+ SetOutPath $INSTDIR
+
+ ; install matahari service executables
+ ; -host, -net, -packages, etc
+ File src/matahari-*.exe
+ File /usr/i686-pc-mingw32/sys-root/mingw/bin/*.dll
+
+ ; Next part requires
+ ; http://nsis.sourceforge.net/NsSCM_plug-in
+ ; for service initialization
+
+ ; matahari-host
+ nsSCM::Install MatahariHost "Matahari Host" 16 2 \
+ "$INSTDIR\matahari-host.exe -d" "" "" "" ""
+ nsSCM::Start MatahariHost
+
+ ; matahari-net
+ nsSCM::Install MatahariNet "Matahari Net" 16 2 \
+ "$INSTDIR\matahari-net.exe -d" "" "" "" ""
+ nsSCM::Start MatahariNet
+SectionEnd ; end the section
--
1.7.2.2
13 years, 8 months
mingw32-qpid make issue
by Adam Stokes
Andrew or others,
How was https://fedorahosted.org/matahari/wiki/mingw32-qpid#Problem1Resolved fixed? I'm still getting a compiler error:
In file included from /home/akimbo/Documents/dev/qpidc-0.6/src/../include/qpid/framing/Array.h:22,
from /home/akimbo/Documents/dev/qpidc-0.6/src/../include/qpid/framing/amqp_types_full.h:33,
from /home/akimbo/Documents/dev/qpidc-0.6/src/../include/qpid/framing/Header.h:32,
from /home/akimbo/Documents/dev/qpidc-0.6/src/../include/qpid/framing/amqp_structs.h:30,
from /home/akimbo/Documents/dev/qpidc-0.6/src/qpid/framing/AMQP_ServerOperations.h:32,
from /home/akimbo/Documents/dev/qpidc-0.6/src/qpid/framing/ExchangeDeleteBody.h:31,
from /home/akimbo/Documents/dev/qpidc-0.6/src/qpid/framing/ExchangeDeleteBody.cpp:28:
/home/akimbo/Documents/dev/qpidc-0.6/src/../include/qpid/framing/FieldValue.h: In member function 'T qpid::framing::FieldValue::getFloatingPointValue() const':
/home/akimbo/Documents/dev/qpidc-0.6/src/../include/qpid/framing/FieldValue.h:205: error: 'uint' was not declared in this scope
/home/akimbo/Documents/dev/qpidc-0.6/src/../include/qpid/framing/FieldValue.h:205: error: expected ';' before 'i'
/home/akimbo/Documents/dev/qpidc-0.6/src/../include/qpid/framing/FieldValue.h:205: error: 'i' was not declared in this scope
make[2]: *** [src/CMakeFiles/qpidcommon.dir/qpid/framing/ExchangeDeleteBody.obj] Error 1
make[2]: Leaving directory `/home/akimbo/Documents/dev/qpidc-0.6'
make[1]: *** [src/CMakeFiles/qpidcommon.dir/all] Error 2
make[1]: Leaving directory `/home/akimbo/Documents/dev/qpidc-0.6'
make: *** [all] Error 2
Thanks
--
__ __
.-----.| |_.-----.| |--.-----.-----.
|__ --|| _| _ || <| -__|__ --|
|_____||____|_____||__|__|_____|_____|
.----------------------------------.
( ajs(a)redhat.com || 919.754.4187 )
`----------------------------------'
13 years, 8 months
[PATCH] netcf windows port
by Adam Stokes
---
bootstrap | 19 ++-
configure.ac | 44 +++-
mingw32-netcf.spec.in | 95 +++++++++
netcf-wininst.nsi | 37 ++++
src/Makefile.am | 15 +-
src/drv_initscripts.c | 2 +-
src/dutil.c | 1 -
src/internal.h | 3 +
src/ncftool.c | 7 +
src/netcf.c | 17 ++-
src/netcf_win.c | 565 +++++++++++++++++++++++++++++++++++++++++++++++++
src/netcf_win.h | 93 ++++++++
src/xslt_ext.c | 2 +-
13 files changed, 880 insertions(+), 20 deletions(-)
create mode 100644 mingw32-netcf.spec.in
create mode 100755 netcf-wininst.nsi
create mode 100644 src/netcf_win.c
create mode 100644 src/netcf_win.h
diff --git a/bootstrap b/bootstrap
index f0653ef..57ed2df 100755
--- a/bootstrap
+++ b/bootstrap
@@ -62,6 +62,24 @@ c-ctype
read-file
safe-alloc
warnings
+sys_wait
+sigaction
+pthread
+unistd
+getdtablesize
+signal
+arpa_inet
+sys_ioctl
+getopt-posix
+string
+sys_socket
+socket
+netinet_in
+vasprintf
+fcntl
+inet_ntop
+inet_pton
+close
'
# Tell gnulib to:
@@ -70,7 +88,6 @@ warnings
# put *.[ch] files in new gnulib/lib/ dir.
$gnulib_tool \
- --lgpl=2 \
--with-tests \
--m4-base=gnulib/m4 \
--source-base=gnulib/lib \
diff --git a/configure.ac b/configure.ac
index 1475875..cba128b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -16,7 +16,30 @@ AC_PROG_LIBTOOL
dnl The backend driver. Right now hardcoded to initscripts, but
dnl eventually needs to be configurable at buildtime
-AM_CONDITIONAL([NETCF_DRIVER_INITSCRIPTS], [true])
+dnl temporary, if win32 then dont build this.
+AC_CANONICAL_HOST
+
+dnl WIN32
+AC_MSG_CHECKING([for win32 platform])
+PLATFORM_WIN32="no"
+case "$host" in
+ *-*-mingw*)
+ PLATFORM_WIN32="yes"
+ MINGW_EXTRA_LDFLAGS="-no-undefined"
+ ;;
+ *-*-cygwin*)
+ MINGW_EXTRA_LDFLAGS="-no-undefined"
+ ;;
+ *-*-linux*)
+ MINGW_EXTRA_LDFLAGS="-no-undefined"
+ ;;
+ *)
+ ;;
+esac
+AC_MSG_RESULT([$PLATFORM_WIN32])
+AM_CONDITIONAL(PLATFORM_WIN32, test "${PLATFORM_WIN32}" = "yes")
+AC_SUBST([PLATFORM_WIN32])
+AC_SUBST(MINGW_EXTRA_LDFLAGS)
dnl Compiler flags to be used everywhere
AC_SUBST([NETCF_CFLAGS], ['--std=gnu99 -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fasynchronous-unwind-tables'])
@@ -27,23 +50,24 @@ NETCF_COMPILE_WARNINGS
dnl Need to test if pkg-config exists
PKG_PROG_PKG_CONFIG
-PKG_CHECK_MODULES([LIBAUGEAS], [augeas >= 0.5.0])
+PKG_CHECK_MODULES([LIBAUGEAS], [augeas >= 0.5.0], [], [AC_DEFINE([HAVE_LIBAUGEAS], [], [Use augeas])])
PKG_CHECK_MODULES([LIBXML], [libxml-2.0])
PKG_CHECK_MODULES([LIBXSLT], [libxslt])
PKG_CHECK_MODULES([LIBEXSLT], [libexslt])
-PKG_CHECK_MODULES([LIBNL], [libnl-1])
+PKG_CHECK_MODULES([LIBNL], [libnl-1], [], [AC_DEFINE([HAVE_LIBNL], [], [Use netlink])])
NETCF_CHECK_READLINE
NETCF_LIBDEPS=$(echo $LIBAUGEAS_LIBS $LIBEXSLT_LIBS $LIBXSLT_LIBS $LIBXML_LIBS $LIBNL_LIBS)
AC_SUBST([NETCF_LIBDEPS])
-AC_CHECK_HEADER([pthread.h],
- [AC_CHECK_LIB([pthread],[pthread_join],[
- AC_DEFINE([HAVE_LIBPTHREAD],[],[Define if pthread (-lpthread)])
- AC_DEFINE([HAVE_PTHREAD_H],[],[Define if <pthread.h>])
- LIBS="-lpthread $LIBS"
- ])])
+dnl check pthread functions
+dnl pulled from:
+dnl http://www.mail-archive.com/libvir-list@redhat.com/msg24187.html
+old_LIBS=$LIBS
+LIBS="$LIBS $LIB_PTHREAD"
+AC_CHECK_FUNCS([pthread_sigmask pthread_mutexattr_init])
+LIBS=$old_libs
AC_OUTPUT(Makefile \
gnulib/lib/Makefile \
@@ -51,4 +75,4 @@ AC_OUTPUT(Makefile \
src/Makefile \
tests/Makefile \
doc/Makefile \
- netcf.pc netcf.spec)
+ netcf.pc netcf.spec mingw32-netcf.spec)
diff --git a/mingw32-netcf.spec.in b/mingw32-netcf.spec.in
new file mode 100644
index 0000000..da56a41
--- /dev/null
+++ b/mingw32-netcf.spec.in
@@ -0,0 +1,95 @@
+%global __strip %{_mingw32_strip}
+%global __objdump %{_mingw32_objdump}
+%global _use_internal_dependency_generator 0
+%global __find_requires %{_mingw32_findrequires}
+%global __find_provides %{_mingw32_findprovides}
+
+Name: mingw32-netcf
+Version: @VERSION@
+Release: 2%{?dist}%{?extra_release}
+Summary: Cross-platform network configuration library
+
+Group: System Environment/Libraries
+License: LGPLv2+
+URL: https://fedorahosted.org/netcf/
+Source0: http://astokes.fedorapeople.org/%{name}/%{name}-%{version}.tar.gz
+BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
+
+BuildRequires: mingw32-filesystem >= 56
+BuildRequires: mingw32-readline
+BuildRequires: mingw32-binutils
+BuildRequires: mingw32-libxml2
+BuildRequires: mingw32-libxslt
+BuildRequires: mingw32-gcc
+BuildRequires: mingw32-gettext
+BuildRequires: mingw32-w32api
+Requires: pkgconfig
+
+%description
+A library for modifying the network configuration of a system. Network
+configurations are expresed in a platform-independent XML format, which
+netcf translates into changes to the system's 'native' network
+configuration files.
+
+MinGW cross-compiled Windows library.
+
+%prep
+%setup -q
+
+%build
+PATH=%{_mingw32_bindir}:$PATH \
+%{_mingw32_configure} --disable-static
+make %{?_smp_mflags}
+
+%install
+rm -rf $RPM_BUILD_ROOT
+make install DESTDIR=$RPM_BUILD_ROOT INSTALL="%{__install} -p"
+find $RPM_BUILD_ROOT -name '*.la' -exec rm -f {} ';'
+find $RPM_BUILD_ROOT -name '*dll.a' -exec rm -f {} ';'
+rm -rf $RPM_BUILD_ROOT%{_mingw32_datadir}/netcf
+
+%clean
+rm -rf $RPM_BUILD_ROOT
+
+%files
+%defattr(-,root,root,-)
+%{_mingw32_bindir}/ncftool.exe
+%{_mingw32_bindir}/libnetcf-1.dll
+%{_mingw32_includedir}/netcf.h
+%{_mingw32_libdir}/pkgconfig/netcf.pc
+%{_mingw32_datadir}
+
+%doc AUTHORS COPYING NEWS
+
+%changelog
+* Mon Sep 1 2010 Adam Stokes <ajs(a)redhat.com> - 0.1.6-2
+- Update spec to not require .dll.a or *.la
+- Fixed building of DLL
+
+* Thu Apr 16 2010 Laine Stump <laine(a)redhat.com> - 0.1.6-1
+- New version
+
+* Mon Nov 30 2009 David Lutterkort <lutter(a)redhat.com> - 0.1.5-1
+- New version
+
+* Thu Nov 5 2009 David Lutterkort <lutter(a)redhat.com> - 0.1.4-1
+- New version
+
+* Tue Oct 27 2009 David Lutterkort <lutter(a)redhat.com> - 0.1.3-1
+- New version
+
+* Fri Sep 25 2009 David Lutterkort <lutter(a)redhat.com> - 0.1.2-1
+- New Version
+
+* Wed Sep 16 2009 David Lutterkort <lutter(a)redhat.com> - 0.1.1-1
+- New Version
+
+* Mon Jul 13 2009 David Lutterkort <lutter(a)redhat.com> - 0.1.0-1
+- BR on augeas-0.5.2
+- Drop explicit requires for augeas-libs
+
+* Wed Apr 15 2009 David Lutterkort <lutter(a)redhat.com> - 0.0.2-1
+- Updates acording to Fedora review
+
+* Fri Feb 27 2009 David Lutterkort <lutter(a)redhat.com> - 0.0.1-1
+- Initial specfile
diff --git a/netcf-wininst.nsi b/netcf-wininst.nsi
new file mode 100755
index 0000000..d0d1687
--- /dev/null
+++ b/netcf-wininst.nsi
@@ -0,0 +1,37 @@
+; netcf-wininst.nsi
+; prompt for dir; copy files
+;--------------------------------
+
+; The name of the installer
+Name "netcf installer"
+
+; The file to write
+OutFile "netcf-setup.exe"
+
+; The default installation directory
+InstallDir $PROGRAMFILES\netcf
+
+; Request application privileges for Windows Vista
+RequestExecutionLevel user
+
+;--------------------------------
+
+; Pages
+
+Page directory
+Page instfiles
+
+;--------------------------------
+
+; The stuff to install
+Section "" ;No components page, name is not important
+
+ ; Set output path to the installation directory.
+ SetOutPath $INSTDIR
+
+ ; Put file there
+ File src/.libs/libnetcf-1.dll
+ File src/.libs/ncftool.exe
+ File /usr/i686-pc-mingw32/sys-root/mingw/bin/*.dll
+
+SectionEnd ; end the section
diff --git a/src/Makefile.am b/src/Makefile.am
index 9d8a3d7..16f8f1e 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -16,7 +16,10 @@ noinst_PROGRAMS = ncftransform
EXTRA_DIST = netcf_public.syms \
netcf_private.syms
-if NETCF_DRIVER_INITSCRIPTS
+if PLATFORM_WIN32
+WIN32LIB= -liphlpapi -ldnsapi
+DRIVER_SOURCES = netcf_win.h netcf_win.c
+else
DRIVER_SOURCES = drv_initscripts.c dutil.h dutil.c \
dutil_linux.h dutil_linux.c
endif
@@ -29,9 +32,13 @@ libnetcf_la_SOURCES = netcf.h netcf.c internal.h \
ref.h list.h \
xslt_ext.c $(DRIVER_SOURCES)
libnetcf_la_LDFLAGS = -Wl,--version-script=netcf.syms \
- -version-info $(LIBNETCF_VERSION_INFO)
+ -version-info $(LIBNETCF_VERSION_INFO) @MINGW_EXTRA_LDFLAGS@
libnetcf_la_LIBADD = $(NETCF_LIBDEPS) $(GNULIB)
-libnetcf_la_DEPENDENCIES = $(libnetcf_la_LIBADD) netcf.syms
+if PLATFORM_WIN32
+libnetcf_la_LIBADD += $(WIN32LIB)
+endif
+
+#libnetcf_la_DEPENDENCIES = $(libnetcf_la_LIBADD) netcf.syms
ncftool_SOURCES = ncftool.c
ncftool_LDADD = libnetcf.la $(READLINE_LIBS) $(GNULIB)
@@ -55,6 +62,6 @@ netcf.syms: netcf_public.syms netcf_private.syms
internal.h: datadir.h
datadir.h: $(top_builddir)/config.status
- echo '#define DATADIR "$(datadir)"' > datadir.h
+ echo '#define NETCF_DATADIR "$(datadir)"' > datadir.h
DISTCLEANFILES += $(BUILT_SOURCES)
diff --git a/src/drv_initscripts.c b/src/drv_initscripts.c
index c0bcfd5..2127d2a 100644
--- a/src/drv_initscripts.c
+++ b/src/drv_initscripts.c
@@ -100,7 +100,7 @@ static const struct augeas_xfm_table augeas_xfm_iptables =
static const char *const prog_lokkit = "/usr/sbin/lokkit";
static const char *const lokkit_custom_rules =
- "--custom-rules=ipv4:filter:" DATADIR "/netcf/iptables-forward-bridged";
+ "--custom-rules=ipv4:filter:" NETCF_DATADIR "/netcf/iptables-forward-bridged";
static const char *const prog_rc_d_iptables = "/etc/init.d/iptables";
diff --git a/src/dutil.c b/src/dutil.c
index 2a6eaa0..d736492 100644
--- a/src/dutil.c
+++ b/src/dutil.c
@@ -41,7 +41,6 @@
#include <netinet/in.h>
#include <arpa/inet.h>
-
#include "safe-alloc.h"
#include "ref.h"
#include "list.h"
diff --git a/src/internal.h b/src/internal.h
index d06665d..1b1726c 100644
--- a/src/internal.h
+++ b/src/internal.h
@@ -83,6 +83,9 @@
#define ATTRIBUTE_NOINLINE
#endif /* __GNUC__ */
+#ifndef WIN32
+#define DATADIR NETCF_DATADIR
+#endif
/* This needs ATTRIBUTE_RETURN_CHECK */
#include "ref.h"
diff --git a/src/ncftool.c b/src/ncftool.c
index 2cb139d..6cdbdef 100644
--- a/src/ncftool.c
+++ b/src/ncftool.c
@@ -677,7 +677,11 @@ static void parse_opts(int argc, char **argv) {
while ((opt = getopt_long(argc, argv, "+dhr:", options, &idx)) != -1) {
switch(opt) {
case 'd':
+#ifdef WIN32
+ _putenv("NETCF_DEBUG=1");
+#else
setenv("NETCF_DEBUG", "1", 1);
+#endif
break;
case 'h':
usage();
@@ -784,7 +788,10 @@ int main(int argc, char **argv) {
fprintf(stderr, "Failed to initialize netcf\n");
if (ncf != NULL)
print_netcf_error();
+#ifndef WIN32
+ // FIXME: Need to find out why ncf_init is croaking
exit(EXIT_FAILURE);
+#endif
}
readline_init();
if (optind < argc) {
diff --git a/src/netcf.c b/src/netcf.c
index 1a95332..f43d1c2 100644
--- a/src/netcf.c
+++ b/src/netcf.c
@@ -31,11 +31,15 @@
#include <sys/wait.h>
#include <signal.h>
#include <errno.h>
-#include "safe-alloc.h"
+#include "safe-alloc.h"
#include "internal.h"
#include "netcf.h"
+#ifdef WIN32
+#include "netcf_win.h"
+#else
#include "dutil.h"
+#endif
/* Clear error code and details */
#define API_ENTRY(ncf) \
@@ -88,7 +92,11 @@ int ncf_init(struct netcf **ncf, const char *root) {
if (make_ref(*ncf) < 0)
goto oom;
if (root == NULL)
+#ifdef WIN32
+ root = "c:\\";
+#else
root = "/";
+#endif
if (root[strlen(root)-1] == '/') {
(*ncf)->root = strdup(root);
} else {
@@ -99,7 +107,7 @@ int ncf_init(struct netcf **ncf, const char *root) {
goto oom;
(*ncf)->data_dir = getenv("NETCF_DATADIR");
if ((*ncf)->data_dir == NULL)
- (*ncf)->data_dir = DATADIR "/netcf";
+ (*ncf)->data_dir = NETCF_DATADIR "/netcf";
(*ncf)->debug = getenv("NETCF_DEBUG") != NULL;
return drv_init(*ncf);
oom:
@@ -262,6 +270,10 @@ int ncf_put_aug(struct netcf *ncf, const char *aug_xml, char **ncf_xml) {
return drv_put_aug(ncf, aug_xml, ncf_xml);
}
+#ifndef WIN32
+/* Do not see any other way around this as there is no
+ * portable option for strerror_r or pthread_sigmask
+ */
/*
* Internal helpers
*/
@@ -395,6 +407,7 @@ error:
return ret;
}
+#endif /* WIN32 */
/*
* argv_to_string() is borrowed from libvirt's
* src/util.c:virArgvToString()
diff --git a/src/netcf_win.c b/src/netcf_win.c
new file mode 100644
index 0000000..a1dbd5c
--- /dev/null
+++ b/src/netcf_win.c
@@ -0,0 +1,565 @@
+#include <config.h>
+#include <internal.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include "netcf_win.h"
+
+#define MAX_TRIES 3
+#define GAA_FLAGS ( GAA_FLAG_SKIP_DNS_SERVER | GAA_FLAG_SKIP_MULTICAST )
+#define BUFSIZE 8192
+
+PMIB_IPADDRTABLE _get_ip_addr_table(PMIB_IPADDRTABLE ipAddrTable) {
+ DWORD r = 0;
+ DWORD buf = 0;
+
+ ipAddrTable = (PMIB_IPADDRTABLE) malloc(sizeof (MIB_IPADDRTABLE));
+ if (GetIpAddrTable(ipAddrTable, &buf, 0) == ERROR_INSUFFICIENT_BUFFER) {
+ free(ipAddrTable);
+ ipAddrTable = (PMIB_IPADDRTABLE) malloc(buf);
+ if (ipAddrTable == NULL)
+ goto error;
+ }
+
+ if((r = GetIpAddrTable(ipAddrTable, &buf, 0)) == NO_ERROR)
+ return ipAddrTable;
+
+ error:
+ free(ipAddrTable);
+ return ipAddrTable;
+}
+
+PMIB_IFTABLE _get_if_table(PMIB_IFTABLE intfTable) {
+ DWORD bufferLength = 0;
+ DWORD r = 0;
+ intfTable = (PMIB_IFTABLE) malloc(sizeof(MIB_IFTABLE));
+ if (intfTable == NULL)
+ goto error;
+
+ bufferLength = sizeof(MIB_IFTABLE);
+ if (GetIfTable(intfTable, &bufferLength, FALSE) == ERROR_INSUFFICIENT_BUFFER) {
+ free(intfTable);
+ intfTable = (PMIB_IFTABLE) malloc(bufferLength);
+ if (intfTable == NULL)
+ goto error;
+ }
+
+ if ((r = GetIfTable(intfTable, &bufferLength, FALSE)) == NO_ERROR)
+ return intfTable;
+ error:
+ free(intfTable);
+}
+
+PIP_ADAPTER_ADDRESSES _get_ip_adapter_info(PIP_ADAPTER_ADDRESSES addrList) {
+ ULONG bufferLength = 0;
+ DWORD r;
+ int i;
+
+ for(i = 0; i < 5; i++) {
+ r = GetAdaptersAddresses(AF_INET, GAA_FLAGS, NULL, addrList, &bufferLength);
+ if (r != ERROR_BUFFER_OVERFLOW) {
+ break;
+ }
+ if (addrList != NULL) {
+ goto error;
+ }
+ addrList = (PIP_ADAPTER_ADDRESSES) malloc(bufferLength);
+ if (addrList == NULL)
+ goto error;
+ }
+ return addrList;
+ error:
+ free(addrList);
+}
+
+/* All undefined routines in windows */
+int drv_get_aug(struct netcf *ncf, const char *ncf_xml, char **aug_xml) {
+#ifdef WIN32
+ return -1;
+#endif
+}
+
+int drv_if_status(struct netcf_if *nif, unsigned int *flags) {
+#ifdef WIN32
+ return -1;
+#endif
+}
+
+int drv_init(struct netcf *ncf) {
+#ifdef WIN32
+ return -1;
+#endif
+}
+
+int drv_lookup_by_mac_string(struct netcf *ncf, const char *mac,
+ int maxifaces, struct netcf_if **ifaces) {
+#ifdef WIN32
+ return -1;
+#endif
+}
+
+int drv_put_aug(struct netcf *ncf, const char *aug_xml, char **ncf_xml) {
+#ifdef WIN32
+ return -1;
+#endif
+}
+
+int drv_undefine(struct netcf_if *nif) {
+#ifdef WIN32
+ return -1;
+#endif
+}
+
+char *drv_xml_desc(struct netcf_if *nif) {
+#ifdef WIN32
+ return -1;
+#endif
+}
+
+char *drv_xml_state(struct netcf_if *nif) {
+#ifdef WIN32
+ return -1;
+#endif
+}
+
+struct netcf_if *drv_define(struct netcf *ncf, const char *xml_str) {
+#ifdef WIN32
+ return ncf;
+#endif
+}
+
+static bool has_ifcfg_file(struct netcf *ncf, const char *name) {
+#ifdef WIN32
+ return FALSE;
+#endif
+}
+
+static bool is_bond(struct netcf *ncf, const char *name) {
+#ifdef WIN32
+ return FALSE;
+#endif
+}
+
+static bool is_bridge(struct netcf *ncf, const char *name) {
+#ifdef WIN32
+ return FALSE;
+#endif
+}
+
+static char *device_name_from_xml(struct netcf *ncf, xmlDocPtr ncf_xml) {
+#ifdef WIN32
+ char *ret = NULL;
+ return ret;
+#endif
+}
+
+static char *find_ifcfg_path_by_device(struct netcf *ncf, const char *name) {
+#ifdef WIN32
+ char *ret = NULL;
+ return ret;
+#endif
+}
+
+static char *find_ifcfg_path_by_hwaddr(struct netcf *ncf, const char *mac) {
+#ifdef WIN32
+ char *ret = NULL;
+ return ret;
+#endif
+}
+
+static char *find_ifcfg_path(struct netcf *ncf, const char *name) {
+#ifdef WIN32
+ char *ret = NULL;
+ return ret;
+#endif
+}
+
+static int aug_put_xml(struct netcf *ncf, xmlDocPtr xml) {
+#ifdef WIN32
+ return -1;
+#endif
+}
+static int bridge_slaves(struct netcf *ncf, const char *name, char ***slaves) {
+#ifdef WIN32
+ return -1;
+#endif
+}
+
+static int cmpstrp(const void *p1, const void *p2) {
+#ifdef WIN32
+ return -1;
+#endif
+}
+
+static int is_slave(struct netcf *ncf, const char *intf) {
+#ifdef WIN32
+ return -1;
+#endif
+}
+
+static int list_ifcfg_paths(struct netcf *ncf, char ***intf) {
+#ifdef WIN32
+ return -1;
+#endif
+}
+
+static int list_interfaces(struct netcf *ncf, char ***intf){
+#ifdef WIN32
+ return -1;
+#endif
+}
+
+static int uniq_ifcfg_paths(struct netcf *ncf, int ndevs, char **devs, char ***intf) {
+#ifdef WIN32
+ return -1;
+#endif
+}
+
+static void bond_setup(struct netcf *ncf, const char *name, bool alias) {
+#ifdef WIN32
+ return;
+#endif
+}
+
+static void bridge_physdevs(struct netcf *ncf) {
+#ifdef WIN32
+ return;
+#endif
+}
+
+static void rm_all_interfaces(struct netcf *ncf, xmlDocPtr ncf_xml) {
+#ifdef WIN32
+ return;
+#endif
+}
+
+static void rm_interface(struct netcf *ncf, const char *name) {
+#ifdef WIN32
+ return;
+#endif
+}
+
+static xmlDocPtr aug_get_xml_for_nif(struct netcf_if *nif) {
+#ifdef WIN32
+ xmlDocPtr result = NULL;
+ return result;
+#endif
+}
+
+static xmlDocPtr aug_get_xml(struct netcf *ncf, int nint, char **intf) {
+#ifdef WIN32
+ xmlDocPtr result = NULL;
+ return result;
+#endif
+}
+
+void drv_entry(struct netcf *ncf) {
+#ifdef WIN32
+ return;
+#endif
+}
+
+void drv_close(struct netcf *ncf) {
+#ifdef WIN32
+ return;
+#endif
+}
+
+int xasprintf(char **strp, const char *format, ...) {
+ va_list args;
+ int result;
+
+ va_start (args, format);
+ result = vasprintf (strp, format, args);
+ va_end (args);
+ if (result < 0)
+ *strp = NULL;
+ return result;
+}
+
+/* Create a new netcf if instance for interface NAME */
+struct netcf_if *make_netcf_if(struct netcf *ncf, char *name) {
+ int r;
+ struct netcf_if *result = NULL;
+
+ r = make_ref(result);
+ ERR_NOMEM(r < 0, ncf);
+ result->ncf = ref(ncf);
+ result->name = name;
+ return result;
+
+ error:
+ unref(result, netcf_if);
+ return result;
+}
+
+static int list_interface_ids(struct netcf *ncf ATTRIBUTE_UNUSED,
+ int maxnames ATTRIBUTE_UNUSED,
+ char **names, unsigned int flags ATTRIBUTE_UNUSED,
+ const char *id_attr ATTRIBUTE_UNUSED) {
+ unsigned int nint = 0;
+
+ PIP_ADAPTER_ADDRESSES addrList = NULL;
+ PIP_ADAPTER_ADDRESSES adapterp = NULL;
+ adapterp = _get_ip_adapter_info(addrList);
+ for (nint = 0; adapterp != NULL; nint++) {
+ if (names) {
+ char name[8192];
+ WideCharToMultiByte(CP_UTF8, 0, adapterp->FriendlyName,
+ -1, name, sizeof(name), NULL, NULL);
+ names[nint] = strdup(name);
+ }
+ adapterp = adapterp->Next;
+ }
+ return nint;
+ error:
+ free(addrList);
+ return -1;
+}
+
+int drv_list_interfaces(struct netcf *ncf,
+ int maxnames ATTRIBUTE_UNUSED, char **names,
+ unsigned int flags ATTRIBUTE_UNUSED) {
+ return list_interface_ids(ncf, 0, names, 0, NULL);
+}
+
+
+int drv_num_of_interfaces(struct netcf *ncf, unsigned int flags ATTRIBUTE_UNUSED) {
+ return list_interface_ids(ncf, 0, NULL, 0, NULL);
+}
+
+
+struct netcf_if *drv_lookup_by_name(struct netcf *ncf, const char *name) {
+ struct netcf_if *nif = NULL;
+ char *name_dup;
+ unsigned int nint = 0;
+ PIP_ADAPTER_ADDRESSES addrList = NULL;
+ PIP_ADAPTER_ADDRESSES adapterp = NULL;
+ adapterp = _get_ip_adapter_info(addrList);
+ for (nint = 0; adapterp != NULL; nint++) {
+ if (name) {
+ char wName[8192];
+ WideCharToMultiByte(CP_UTF8, 0, adapterp->FriendlyName,
+ -1, wName, sizeof(wName), NULL, NULL);
+ if (strcmp(wName, name) == 0) {
+ name_dup = strdup(wName);
+ nif = make_netcf_if(ncf, name_dup);
+ goto done;
+ }
+ }
+ adapterp = adapterp->Next;
+ }
+
+ done:
+ return nif;
+}
+
+
+const char *drv_mac_string(struct netcf_if *nif) {
+ // struct netcf *ncf = nif->ncf;
+ char mac[256];
+
+ PIP_ADAPTER_ADDRESSES addrList = NULL;
+ PIP_ADAPTER_ADDRESSES adapterp = NULL;
+ adapterp = _get_ip_adapter_info(addrList);
+ while(adapterp != NULL) {
+ char wName[8192];
+ WideCharToMultiByte(CP_UTF8, 0, adapterp->FriendlyName,
+ -1, wName, sizeof(wName), NULL, NULL);
+ if (strcmp(wName,nif->name) == 0) {
+ if ((int)adapterp->PhysicalAddressLength >= 6)
+ continue; /* just want ethernet for now */
+ sprintf(mac, "%02X:%02X:%02X:%02X:%02X:%02X",
+ adapterp->PhysicalAddress[0],
+ adapterp->PhysicalAddress[1],
+ adapterp->PhysicalAddress[2],
+ adapterp->PhysicalAddress[3],
+ adapterp->PhysicalAddress[4],
+ adapterp->PhysicalAddress[5]);
+ nif->mac = strdup(mac);
+ goto done;
+ }
+ adapterp = adapterp->Next;
+ }
+ done:
+ return nif->mac;
+}
+
+int drv_if_down(struct netcf_if *nif) {
+ PMIB_IFTABLE intfTable = NULL;
+ PMIB_IFTABLE intfTableDup = NULL;
+ PMIB_IFROW intRow;
+ int i;
+
+ intfTableDup = _get_if_table(intfTable);
+ if (intfTableDup != NULL) {
+ for (i = 0; i < (int) intfTableDup->dwNumEntries; i++) {
+ intRow = (PMIB_IFROW) & intfTableDup->table[i];
+ char wName[8192];
+ WideCharToMultiByte(CP_UTF8, 0, intRow->wszName,
+ -1, wName, sizeof(wName), NULL, NULL);
+ if (strcmp(wName,nif->name) == 0) {
+ intRow->dwAdminStatus = MIB_IF_ADMIN_STATUS_DOWN;
+ if (SetIfEntry(intRow) == NO_ERROR)
+ goto done;
+ }
+ }
+ /* Unable to shutdown interface */
+ return -1;
+ }
+ done:
+ return 0;
+}
+
+int drv_if_up(struct netcf_if *nif) {
+ PMIB_IFTABLE intfTable = NULL;
+ PMIB_IFTABLE intfTableDup = NULL;
+ PMIB_IFROW intRow;
+ int i;
+
+ intfTableDup = _get_if_table(intfTable);
+ if (intfTableDup != NULL) {
+ for (i = 0; i < (int) intfTableDup->dwNumEntries; i++) {
+ intRow = (PMIB_IFROW) & intfTableDup->table[i];
+ char wName[8192];
+ WideCharToMultiByte(CP_UTF8, 0, intRow->wszName,
+ -1, wName, sizeof(wName), NULL, NULL);
+ if (strcmp(wName,nif->name) == 0) {
+ intRow->dwAdminStatus = MIB_IF_ADMIN_STATUS_UP;
+ if (SetIfEntry(intRow) == NO_ERROR)
+ goto done;
+ }
+ }
+ /* Unable to shutdown interface */
+ return -1;
+ }
+ done:
+ return 0;
+}
+
+int drv_if_ipaddresses(struct netcf_if *nif, char *ipBuf) {
+ PIP_ADAPTER_ADDRESSES addrList = NULL;
+ PIP_ADAPTER_ADDRESSES adapterp = NULL;
+ PMIB_IPADDRTABLE ipAddrTable = NULL;
+ PMIB_IPADDRTABLE ipAddrTableDup = NULL;
+ IN_ADDR ipAddr;
+ DWORD r = 0;
+ int i;
+
+ if ((ipAddrTableDup = _get_ip_addr_table(ipAddrTable)) == NULL)
+ return -1;
+
+ adapterp = _get_ip_adapter_info(addrList);
+ if (adapterp != NULL) {
+ while(adapterp) {
+ if (adapterp->OperStatus != 1)
+ continue;
+
+ /* pull ip addresses from interface */
+ for (i = 0; i<ipAddrTableDup->dwNumEntries; i++) {
+ if (ipAddrTableDup->table[i].dwIndex == adapterp->IfIndex) {
+ char wName[8192];
+ WideCharToMultiByte(CP_UTF8, 0, adapterp->FriendlyName,
+ -1, wName, sizeof(wName), NULL, NULL);
+ if (strcmp(wName,nif->name) == 0) {
+ ipAddr.S_un.S_addr = (unsigned long) ipAddrTableDup->table[i].dwAddr;
+ sprintf(ipBuf,"%d",inet_ntoa(ipAddr));
+ return 0;
+ }
+ }
+ }
+ adapterp = adapterp->Next;
+ }
+
+ }
+ free(ipAddrTable);
+ free(addrList);
+ return -1;
+}
+
+int drv_add_ip_address(struct netcf_if *nif, char *ipAddr, char *netmask) {
+ IN_ADDR addr;
+ PIP_ADAPTER_ADDRESSES addrList = NULL;
+ PIP_ADAPTER_ADDRESSES adapterp = NULL;
+ PMIB_IPADDRTABLE ipAddrTable = NULL;
+ PMIB_IPADDRTABLE ipAddrTableDup = NULL;
+ ULONG bufferLength = 0;
+ DWORD r;
+ DWORD ifIndex;
+ int i;
+
+ /* ipv4 addr/subnetmask */
+ UINT IPAddress;
+ UINT IPNetMask;
+
+ /* handles to IP returned */
+ ULONG NTEContext = 0;
+ ULONG NTEInstance = 0;
+
+ if ((IPAddress = inet_addr(ipAddr)) == INADDR_NONE)
+ return -1;
+
+ if ((IPNetMask = inet_addr(netmask)) == INADDR_NONE)
+ return -1;
+
+
+ ipAddrTableDup = _get_ip_addr_table(ipAddrTable);
+ if (ipAddrTableDup != NULL) {
+ for(i=0;i<ipAddrTableDup->dwNumEntries;i++) {
+ ifIndex = ipAddrTableDup->table[i].dwIndex;
+ char wName[8192];
+ WideCharToMultiByte(CP_UTF8, 0, adapterp->FriendlyName,
+ -1, wName, sizeof(wName), NULL, NULL);
+ if (strcmp(wName,nif->name) == 0) {
+ if ((r = AddIPAddress(IPAddress, IPNetMask, ifIndex,
+ &NTEContext, &NTEInstance)) == NO_ERROR) {
+ return 0;
+ }
+ }
+ }
+ }
+ free(ipAddrTable);
+ return -1;
+}
+
+
+/* needs further testing
+int drv_rm_ip_address(struct netcf_if *nif, ULONG NTEContext) {
+ DWORD r = 0;
+ if ((r = DeleteIpAddress(NTEConext)) == NO_ERROR)
+ return 0;
+ return -1;
+}
+*/
+
+int drv_list_dns_server(struct netcf_if *nif, char *ip_str) {
+ char bufferLength[1024];
+ IP4_ARRAY *ips = (IP4_ARRAY*) bufferLength;
+ DWORD len = sizeof(bufferLength);
+ DNS_STATUS status;
+
+ status = DnsQueryConfig(DnsConfigDnsServerList, FALSE,
+ NULL, NULL, ips, &len);
+ if (status == 0) {
+ DWORD i;
+ for (i = 0; i < ips->AddrCount; i++) {
+ DWORD ip = ips->AddrArray[i];
+ snprintf(ip_str, sizeof(ip_str),
+ "%d.%d.%d.%d", (ip >> 0) & 255, (ip >> 8) & 255,
+ (ip >> 16) & 255, (ip >> 24) & 255);
+ }
+ } else {
+ return -1;
+ }
+ return 0;
+}
+
+/* NOT IMPLEMENTED
+int drv_add_dns_server(struct netcf_if *nif, const char *dnsAddr) {
+ return -1;
+}
+
+int drv_rm_dns_server(struct netcf_if *nif) {
+ return -1;
+}
+*/
diff --git a/src/netcf_win.h b/src/netcf_win.h
new file mode 100644
index 0000000..c1bb1d6
--- /dev/null
+++ b/src/netcf_win.h
@@ -0,0 +1,93 @@
+/*
+ * netcf-win.h: windows functions
+ *
+ * Copyright (C) 2009-2010 Red Hat Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * Author: Adam Stokes <ajs(a)redhat.com>
+ */
+
+#ifndef NETCF_WIN_H
+#define NETCF_WIN_H
+
+#ifndef WINVER
+#define WINVER 0x0501
+#endif
+
+#include <config.h>
+#include "internal.h"
+
+#include <stdbool.h>
+#include <string.h>
+#include <windows.h>
+#include <winsock.h>
+#include <winsock2.h>
+#include <ws2tcpip.h>
+#include <iphlpapi.h>
+#include <windns.h>
+#include "safe-alloc.h"
+#include "ref.h"
+#include "list.h"
+
+static int aug_put_xml(struct netcf *ncf, xmlDocPtr xml);
+static int bridge_slaves(struct netcf *ncf, const char *name, char ***slaves);
+static int cmpstrp(const void *p1, const void *p2);
+static int is_slave(struct netcf *ncf, const char *intf);
+static int list_ifcfg_paths(struct netcf *ncf, char ***intf);
+static int list_interface_ids(struct netcf *ncf, int maxnames, char **names,
+ unsigned int flags, const char *id_attr);
+static int list_interfaces(struct netcf *ncf, char ***intf);
+static int uniq_ifcfg_paths(struct netcf *ncf, int ndevs, char **devs, char ***intf);
+static bool has_ifcfg_file(struct netcf *ncf, const char *name);
+static bool is_bond(struct netcf *ncf, const char *name);
+static bool is_bridge(struct netcf *ncf, const char *name);
+static char *device_name_from_xml(struct netcf *ncf, xmlDocPtr ncf_xml);
+static char *find_ifcfg_path_by_device(struct netcf *ncf, const char *name);
+static char *find_ifcfg_path_by_hwaddr(struct netcf *ncf, const char *mac);
+static char *find_ifcfg_path(struct netcf *ncf, const char *name);
+static void bond_setup(struct netcf *ncf, const char *name, bool alias);
+static void bridge_physdevs(struct netcf *ncf);
+static void rm_all_interfaces(struct netcf *ncf, xmlDocPtr ncf_xml);
+static void rm_interface(struct netcf *ncf, const char *name);
+static xmlDocPtr aug_get_xml_for_nif(struct netcf_if *nif);
+static xmlDocPtr aug_get_xml(struct netcf *ncf, int nint, char **intf);
+struct netcf_if *make_netcf_if(struct netcf *ncf, char *name);
+int xasprintf(char **strp, const char *format, ...);
+
+/* structure return of interface table */
+PMIB_IFTABLE _get_if_table(PMIB_IFTABLE intfTable);
+
+/* structure return of adapter info */
+PIP_ADAPTER_ADDRESSES _get_ip_adapter_info(PIP_ADAPTER_ADDRESSES addrList);
+
+PMIB_IPADDRTABLE _get_ip_addr_table(PMIB_IPADDRTABLE ipAddrTable);
+
+/* Reports ip addresses */
+int drv_if_ipaddresses(struct netcf_if *nif, char *ipBuf);
+
+/* add ip address to device */
+int drv_add_ip_address(struct netcf_if *nif, char *ipAddr,
+ char *netmask);
+/* remove ip address from device */
+int drv_rm_ip_address(struct netcf_if *nif, ULONG NTEContext);
+/* add dns server to device */
+int drv_add_dns_server(struct netcf_if *nif, ULONG NTEContext);
+/* rm dns server from device */
+int drv_rm_dns_server(struct netcf_if *nif);
+/* list dns server */
+int drv_list_dns_server(struct netcf_if *ncf, char *ip_str);
+
+#endif /* NETCF_WIN_H */
diff --git a/src/xslt_ext.c b/src/xslt_ext.c
index 07e2b41..444889a 100644
--- a/src/xslt_ext.c
+++ b/src/xslt_ext.c
@@ -106,7 +106,7 @@ static void ipcalc_prefix(xmlXPathParserContextPtr ctxt, int nargs) {
goto error;
}
- r = inet_aton((char *) netmask_str, &netmask);
+ r = inet_pton(AF_INET, (char *) netmask_str, &netmask);
if (r < 0) {
xsltTransformError(xsltXPathGetTransformContext(ctxt), NULL, NULL,
"ipcalc:prefix: illegal netmask '%s'",
--
1.7.2.2
13 years, 8 months
[PATCH 01/10] Conditionalized building with win32 libraries.
by Adam Stokes
---
src/Makefile.am | 15 ++++++++++-----
1 files changed, 10 insertions(+), 5 deletions(-)
diff --git a/src/Makefile.am b/src/Makefile.am
index 34896f5..d2f9ff7 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -16,25 +16,30 @@ noinst_PROGRAMS = ncftransform
EXTRA_DIST = netcf_public.syms \
netcf_private.syms
-DRIVER_SOURCES = dutil.h dutil.c netcf.c drv_initscripts.c
+if NETCF_DRIVER_INITSCRIPTS
+DRIVER_SOURCES = drv_initscripts.c dutil.h dutil.c \
+ dutil_linux.h dutil_linux.c
+endif
if PLATFORM_WIN32
WIN32LIB= -liphlpapi -ldnsapi
DRIVER_SOURCES += netcf_win.h netcf_win.c
-else
-DRIVER_SOURCES += dutil_linux.c
endif
BUILT_SOURCES = datadir.h netcf.syms
DISTCLEANFILES = datadir.h
-libnetcf_la_SOURCES = netcf.h internal.h \
+libnetcf_la_SOURCES = netcf.h netcf.c internal.h \
ref.h list.h \
xslt_ext.c $(DRIVER_SOURCES)
libnetcf_la_LDFLAGS = -Wl,--version-script=netcf.syms \
-version-info $(LIBNETCF_VERSION_INFO) @MINGW_EXTRA_LDFLAGS@
-libnetcf_la_LIBADD = $(NETCF_LIBDEPS) $(GNULIB) $(WIN32LIB)
+libnetcf_la_LIBADD = $(NETCF_LIBDEPS) $(GNULIB)
+if PLATFORM_WIN32
+libnetcf_la_LIBADD += $(WIN32LIB)
+endif
+
#libnetcf_la_DEPENDENCIES = $(libnetcf_la_LIBADD) netcf.syms
ncftool_SOURCES = ncftool.c
--
1.7.2.2
13 years, 8 months
[PATCH] - review of win32 netcf port
by Adam Stokes
I know this is the matahari list but I was asked to post patch here for technical review.
Any suggestions highly appreciated
Thanks,
--
__ __
.-----.| |_.-----.| |--.-----.-----.
|__ --|| _| _ || <| -__|__ --|
|_____||____|_____||__|__|_____|_____|
.----------------------------------.
( ajs(a)redhat.com || 919.754.4187 )
`----------------------------------'
13 years, 8 months
Re: [Matahari] [PATCH] - review of win32 netcf port
by Adam Stokes
hey andrew,
thanks for the review i've implemented most of the suggestions but had some concern on the below.
thanks!
----- "Andrew Beekhof" <andrew(a)beekhof.net> wrote:
> > $gnulib_tool \
> > - --lgpl=2 \
>
> This is something you'll need to call out and explain exactly which
> modules cause this and what the status of getting them dual-licenced
> is.
>
Curious the approach to explain this? (code-wise)
>
> HAVE_READLINE?
>
> > add_history(line);
> > +#endif
> > ret = cmdret;
Win32 readline doesn't have add_history support IIRC
> > }
> > }
> > @@ -786,7 +793,9 @@
> > print_netcf_error();
> > exit(EXIT_FAILURE);
> > }
> > +#ifndef WIN32
>
> HAVE_READLINE?
>
> > readline_init();
> > +#endif
Same as above
> > +#ifdef WIN32
> > + return w32_lookup_by_name(ncf, name);
> > +#endif
> > return drv_lookup_by_name(ncf, name);
>
> Wouldn't it be preferrable to keep the same function name for these?
>
Yes it would, however, I think I was running into undefined references because we weren't using all the routines pre-defined.
> > +/* List ip addresses for each active interface
> > + * Returns 0 on success, -1 on failure
> > + */
> > +int ncf_if_ipaddresses(struct netcf_if *nif);
> > +
>
> Do we need this or is it just nice to have?
> Because effectively we're changing their API here.
>
> Probably best as a separate patch.
>
youre right i hadn't thought of it, ill keep it in the window specific file but take it out of the api
> > +#define MALLOC(x) HeapAlloc(GetProcessHeap(), 0, (x))
> > +#define FREE(x) HeapFree(GetProcessHeap(), 0, (x))
>
> We cant just use malloc?
>
I'll need to double check but I think malloc/free is fine as well
> > + error:
> > + FREE(intfTable);
> > + return intfTable;
>
> Um... you're returning a pointer to memory you just free'd
>
late night hacking :P
> > +#include "netcf.h"
> > +
> > +/* structure return of interface table */
> > +PMIB_IFTABLE _get_if_table(PMIB_IFTABLE intfTable);
> > +
> > +/* structure return of adapter info */
> > +PIP_ADAPTER_ADDRESSES _get_ip_adapter_info(PIP_ADAPTER_ADDRESSES
> addrList);
> > +
>
> See above.
> We probably dont want the following definitions.
I believe these are still needed for other routines
--
__ __
.-----.| |_.-----.| |--.-----.-----.
|__ --|| _| _ || <| -__|__ --|
|_____||____|_____||__|__|_____|_____|
.----------------------------------.
( ajs(a)redhat.com || 919.754.4187 )
`----------------------------------'
13 years, 8 months