From 02ee4275f7feb88a8544cf48ce496d2c0e22423b Mon Sep 17 00:00:00 2001 From: Petr Písař Date: Jan 19 2018 15:17:05 +0000 Subject: Fix warnings --- diff --git a/.rpmlint b/.rpmlint new file mode 100644 index 0000000..b7e59b1 --- /dev/null +++ b/.rpmlint @@ -0,0 +1,2 @@ +from Config import * +addFilter("spelling-error .* libpcap"); diff --git a/Net-RawIP-0.25-Decalare-used-function.patch b/Net-RawIP-0.25-Decalare-used-function.patch new file mode 100644 index 0000000..b1781f8 --- /dev/null +++ b/Net-RawIP-0.25-Decalare-used-function.patch @@ -0,0 +1,55 @@ +From ebb883cb2e2f0031fd947bf36c0f089e5a5352ea Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= +Date: Fri, 19 Jan 2018 15:47:40 +0100 +Subject: [PATCH] Decalare used function +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +GCC warns about implicit declarations of functions used in RawIP.xs +but defined in eth.c. This patch adds their declarations into eth.h. + +Signed-off-by: Petr Písař +--- + MANIFEST | 1 + + RawIP.xs | 1 + + eth.h | 3 +++ + 3 files changed, 5 insertions(+) + create mode 100644 eth.h + +diff --git a/MANIFEST b/MANIFEST +index 9bfa0ee..1211b02 100644 +--- a/MANIFEST ++++ b/MANIFEST +@@ -18,6 +18,7 @@ lib/Net/RawIP/udphdr.pm + RawIP.xs + RawIP/libpcap.pod + eth.c ++eth.h + ifaddrlist.c + ifaddrlist.h + ip.h +diff --git a/RawIP.xs b/RawIP.xs +index cddc523..234ea5d 100644 +--- a/RawIP.xs ++++ b/RawIP.xs +@@ -31,6 +31,7 @@ extern "C" { + #include + #endif + #include "ifaddrlist.h" ++#include "eth.h" + #include + #include + #include +diff --git a/eth.h b/eth.h +new file mode 100644 +index 0000000..ab28b45 +--- /dev/null ++++ b/eth.h +@@ -0,0 +1,3 @@ ++int tap(char *dev,unsigned int *my_eth_ip,unsigned char *my_eth_mac); ++int mac_disc(unsigned int addr,unsigned char * eth_mac); ++void send_eth_packet(int fd, char* eth_device, u_char *pkt, int len, int flag); +-- +2.13.6 + diff --git a/Net-RawIP-0.25-Silent-compiler-warnings.patch b/Net-RawIP-0.25-Silent-compiler-warnings.patch new file mode 100644 index 0000000..19e9672 --- /dev/null +++ b/Net-RawIP-0.25-Silent-compiler-warnings.patch @@ -0,0 +1,92 @@ +From ee4e010724ea0106f0ebdf572c6b55573122f12b Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= +Date: Fri, 19 Jan 2018 15:56:05 +0100 +Subject: [PATCH] Silent compiler warnings +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Signed-off-by: Petr Písař +--- + RawIP.xs | 12 +++--------- + eth.c | 5 ++++- + ifaddrlist.c | 3 +-- + 3 files changed, 8 insertions(+), 12 deletions(-) + +diff --git a/RawIP.xs b/RawIP.xs +index 234ea5d..143c65f 100644 +--- a/RawIP.xs ++++ b/RawIP.xs +@@ -166,14 +166,6 @@ u_long host_to_ip (char *host_name); + void pkt_send(int fd, unsigned char *sock, u_char *pkt, int size); + int linkoffset(int); + +-static int +-not_here(s) +- char *s; +-{ +- croak("%s not implemented on this architecture", s); +- return -1; +-} +- + static double + constant(name, arg) + char *name; +@@ -592,6 +584,8 @@ CODE: + memset(dev,0,16); + len = ip_rt_dev(addr,dev); + RETVAL = newSVpv(dev,len); ++#else ++ PERL_UNUSED_ARG(addr); + #endif + #if !defined(_LINUX_) && !defined(_BPF_) + croak("rdev() is not implemented on this system"); +@@ -689,7 +683,7 @@ send_eth_packet(fd,eth_device,pkt,flag) + SV* pkt + int flag + CODE: +- send_eth_packet(fd, eth_device, (char*)SvPV(pkt,PL_na), SvCUR(pkt),flag); ++ send_eth_packet(fd, eth_device, (unsigned char*)SvPV(pkt,PL_na), SvCUR(pkt),flag); + + AV * + eth_parse(pkt) +diff --git a/eth.c b/eth.c +index 48aeed2..a36a9ab 100644 +--- a/eth.c ++++ b/eth.c +@@ -235,7 +235,10 @@ int + tap(char *dev,unsigned int *my_eth_ip,unsigned char *my_eth_mac) + { + +- int fd,v,s; ++ int fd; ++#ifdef _BPF_ ++ int v,s; ++#endif + struct ifreq ifr; + (void)strcpy(ifr.ifr_name, dev); + #ifndef _BPF_ +diff --git a/ifaddrlist.c b/ifaddrlist.c +index 0729b2b..b60ef3c 100644 +--- a/ifaddrlist.c ++++ b/ifaddrlist.c +@@ -41,7 +41,7 @@ ifaddrlist(register struct ifaddrlist **ipaddrp, register char *errbuf) + #ifdef HAVE_SOCKADDR_SA_LEN + register int n; + #endif +- register struct ifreq *ifrp, *ifend, *ifnext, *mp; ++ register struct ifreq *ifrp, *ifend, *ifnext; + register struct sockaddr_in *sin; + register struct ifaddrlist *al; + struct ifconf ifc; +@@ -71,7 +71,6 @@ ifaddrlist(register struct ifaddrlist **ipaddrp, register char *errbuf) + ifend = (struct ifreq *)((char *)ibuf + ifc.ifc_len); + + al = ifaddrlist; +- mp = NULL; + nipaddr = 0; + for (; ifrp < ifend; ifrp = ifnext) + { +-- +2.13.6 + diff --git a/Net-RawIP-0.25-Use-_DEFAULT_SOURCE-instead-of-_BSD_SOURCE.patch b/Net-RawIP-0.25-Use-_DEFAULT_SOURCE-instead-of-_BSD_SOURCE.patch new file mode 100644 index 0000000..ffdad9f --- /dev/null +++ b/Net-RawIP-0.25-Use-_DEFAULT_SOURCE-instead-of-_BSD_SOURCE.patch @@ -0,0 +1,29 @@ +From 32cfda724ce867d1b4a3e581b4b305b300ddfed2 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= +Date: Fri, 19 Jan 2018 15:39:16 +0100 +Subject: [PATCH] Use _DEFAULT_SOURCE instead of _BSD_SOURCE +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +_BSD_SOURCE is deprecated in glibc since 2.20 version. + +Signed-off-by: Petr Písař +--- + ifaddrlist.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/ifaddrlist.c b/ifaddrlist.c +index 41183d3..0729b2b 100644 +--- a/ifaddrlist.c ++++ b/ifaddrlist.c +@@ -1,5 +1,5 @@ + #ifdef _LINUX_ +-#define _BSD_SOURCE 1 ++#define _DEFAULT_SOURCE 1 + #define __FAVOR_BSD 1 + #endif + +-- +2.13.6 + diff --git a/perl-Net-RawIP.spec b/perl-Net-RawIP.spec index 164832b..b0015e9 100644 --- a/perl-Net-RawIP.spec +++ b/perl-Net-RawIP.spec @@ -1,60 +1,100 @@ +# Execute tests that requires working network +%bcond_with perl_Net_RawIP_enables_network_test +# Execute optional test +%bcond_without perl_Net_RawIP_enables_optional_test + Name: perl-Net-RawIP Version: 0.25 -Release: 27%{?dist} -Summary: Perl extension for manipulating raw ip packets using libpcap +Release: 28%{?dist} +Summary: Perl extension for manipulating raw IP packets using libpcap License: GPL+ or Artistic -Group: Development/Libraries URL: http://search.cpan.org/dist/Net-RawIP/ Source0: http://www.cpan.org/modules/by-module/Net/Net-RawIP-%{version}.tar.gz Patch0: Net-RawIP-0.23-format.patch +# Adapt to changes in glibc-2.20, CPAN RT#124134 +Patch1: Net-RawIP-0.25-Use-_DEFAULT_SOURCE-instead-of-_BSD_SOURCE.patch +# Fix missing function prototypes, CPAN RT#124134 +Patch2: Net-RawIP-0.25-Decalare-used-function.patch +# Fix compiler warnings, CPAN RT#124134 +Patch3: Net-RawIP-0.25-Silent-compiler-warnings.patch +BuildRequires: findutils +BuildRequires: gcc +BuildRequires: libpcap-devel BuildRequires: perl-devel BuildRequires: perl-generators -BuildRequires: perl(ExtUtils::MakeMaker), libpcap-devel, -BuildRequires: perl(Proc::ProcessTable), perl(Test::Perl::Critic) -BuildRequires: perl(Test::Pod), perl(Test::Pod::Coverage) -Requires: perl(:MODULE_COMPAT_%(eval "`%{__perl} -V:version`"; echo $version)) +BuildRequires: perl-interpreter +BuildRequires: perl(Config) +BuildRequires: perl(DynaLoader) +BuildRequires: perl(ExtUtils::MakeMaker) >= 6.76 +BuildRequires: perl(strict) +BuildRequires: perl(warnings) +%if %{without perl_Net_RawIP_enables_network_test} +BuildRequires: sed +%endif +# Run-time: +BuildRequires: perl(AutoLoader) +BuildRequires: perl(Carp) +BuildRequires: perl(Class::Struct) +BuildRequires: perl(English) +BuildRequires: perl(Exporter) +BuildRequires: perl(subs) +BuildRequires: perl(vars) +# Prefer XSLoader over DynaLoader +BuildRequires: perl(XSLoader) +# Tests: +BuildRequires: perl(Data::Dumper) +BuildRequires: perl(Test::More) +%if %{with perl_Net_RawIP_enables_optional_test} +# Optional tests: +BuildRequires: perl(Proc::ProcessTable) +%endif +Requires: perl(:MODULE_COMPAT_%(eval "`perl -V:version`"; echo $version)) +# Prefer XSLoader over DynaLoader +Requires: perl(XSLoader) %{?perl_default_filter} %description -This package provides a class object which can be used for creating, -manipulating and sending raw ip packets with optional features for +This package provides a Perl class which can be used for creating, +manipulating and sending raw IP packets with optional features for manipulating Ethernet headers. %prep %setup -q -n Net-RawIP-%{version} -%patch0 -p1 -b .format +%patch0 -p1 +%patch1 -p1 +%patch2 -p1 +%patch3 -p1 +chmod a-x examples/* +%if %{without perl_Net_RawIP_enables_network_test} +rm t/iflist.t +sed -i -e '/^t\/iflist\.t/d' MANIFEST +%endif %build -%{__perl} Makefile.PL INSTALLDIRS=vendor OPTIMIZE="$RPM_OPT_FLAGS" +perl Makefile.PL INSTALLDIRS=vendor NO_PACKLIST=1 OPTIMIZE="$RPM_OPT_FLAGS" make %{?_smp_mflags} %install -make pure_install PERL_INSTALL_ROOT=$RPM_BUILD_ROOT - -find $RPM_BUILD_ROOT -type f -name .packlist -exec rm -f {} \; -find $RPM_BUILD_ROOT -type f -name '*.bs' -size 0 -exec rm -f {} \; -find $RPM_BUILD_ROOT -depth -type d -exec rmdir {} 2>/dev/null \; - +make pure_install DESTDIR=$RPM_BUILD_ROOT +find $RPM_BUILD_ROOT -type f -name '*.bs' -size 0 -delete %{_fixperms} $RPM_BUILD_ROOT/* -chmod a-x examples/* - %check -%{?!_with_network_tests: rm t/iflist.t } +unset AUTHOR_MODE make test -%clean -rm -rf $RPM_BUILD_ROOT - %files -%defattr(-,root,root,-) -%doc Changes README README.Devel TODO examples +%doc Changes examples README README.Devel TODO %{perl_vendorarch}/auto/* %{perl_vendorarch}/Net* %{_mandir}/man3/* %changelog +* Fri Jan 19 2018 Petr Pisar - 0.25-28 +- Modernize spec file +- Fix compiler warnings (CPAN RT#124134) + * Thu Aug 03 2017 Fedora Release Engineering - 0.25-27 - Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Binutils_Mass_Rebuild