1
0
mirror of https://github.com/mfontanini/libtins synced 2026-01-27 20:24:26 +01:00

65 Commits
v2.0 ... v3.1

Author SHA1 Message Date
Matias Fontanini
e7e66808a4 Updated files for release. 2014-08-24 21:40:22 -03:00
Matias Fontanini
2beebd6df3 Fix invalid lib name. 2014-08-24 20:07:30 -03:00
Matias Fontanini
0e967b4d30 Removed unnecessary check for CXX11_COMPILER_FLAGS. 2014-08-24 18:44:53 -03:00
Matias Fontanini
f5b0603799 CMake compilation now works on Windows. 2014-08-24 18:06:58 -03:00
Matias Fontanini
443974335a Added examples to CMake build system. 2014-08-23 23:12:19 -03:00
Matias Fontanini
2c2df752d0 Added tests to CMake build system. 2014-08-23 18:50:00 -03:00
Matias Fontanini
3a02bd0a3f Fix build system issues. 2014-08-23 13:05:51 -03:00
Santiago Alessandri
d0d4379b1b Added missing files. 2014-08-22 11:28:09 -07:00
Santiago Alessandri
fb7dbed58a First approach towards moving to CMake 2014-08-22 11:03:16 -07:00
Matias Fontanini
d2f0cd0686 Fixed issue #29: Added empty name check on DNS::encode_domain_name. 2014-08-20 22:44:03 -03:00
Matias Fontanini
2d6fcfb74a Fix ICMPv6 serialization (patch by einarjon). 2014-08-18 09:11:03 -03:00
Matias Fontanini
424e31bdd6 Updated configure files. 2014-08-09 14:42:11 -03:00
Matias Fontanini
5d8f3e6741 Updated README and CHANGES files. 2014-08-07 21:39:54 -03:00
Matias Fontanini
5d0ba22ac4 Fixed invalid parsing of unknown DNS records. 2014-08-07 21:22:31 -03:00
Matias Fontanini
8a44b29d92 Protocols now always set the next layer protocol flag. 2014-08-07 20:42:17 -03:00
Matias Fontanini
1b47623484 Timestamps can now be constructed from std::chrono::duration. 2014-08-07 20:12:19 -03:00
Matias Fontanini
282cd0913c Added Packet constructor. 2014-08-07 19:58:41 -03:00
Matias Fontanini
aed5ccdfca Updated configure files. 2014-08-07 19:56:29 -03:00
Matias Fontanini
8e6ddfd764 Fixed bug in EthernetII when changing its inner PDU. 2014-08-07 19:38:05 -03:00
Matias Fontanini
1c2bfd42ca Fixed invalid address passed to memcpy. 2014-08-07 19:37:06 -03:00
Matias Fontanini
b9db3ea1d3 Merge pull request #22 from mantiz/fix-armv5-alignment-issues
fix armv5 alignment issues
2014-07-31 13:47:17 -03:00
Christian Hammerl
52b0ee7ceb fix armv5 alignment issues 2014-07-31 15:49:52 +00:00
Matias Fontanini
3ef85aae38 Added BaseSniffer::set_extract_raw_pdus. 2014-07-30 23:01:03 -03:00
Matias Fontanini
3bb310dd6b Updated autotools files. 2014-07-30 22:59:14 -03:00
Matias Fontanini
a918229d4b Merge pull request #21 from jedahan/master
minimum automake version from 1.13 -> 1.11
2014-07-30 22:52:08 -03:00
Jonathan Dahan
95a9d18b6b minimum automake version from 1.13 -> 1.11 2014-07-30 11:44:24 -04:00
Matias Fontanini
7371b95ebc Merge pull request #19 from kylemcdonald/master
added Utils::to_string(PDU::PDUType). closes #12.
2014-07-29 08:57:44 -03:00
Kyle McDonald
416edc34f7 added Utils::to_string(PDU::PDUType). closes #12. 2014-07-27 00:24:16 -04:00
Matias Fontanini
2dff95700f Updated copyright notice. 2014-07-13 11:04:29 -03:00
Matias Fontanini
46b52ad26e Updated example. 2014-07-13 10:59:00 -03:00
Matias Fontanini
22e7c1d7c4 Fixed error compilations on windows. 2014-07-02 19:02:48 -03:00
Matias Fontanini
dd2ed5daa4 Added undef directive to avoid compilation error on windows. 2014-07-01 17:06:39 -03:00
Matias Fontanini
c25d4738b4 Added check for HAVE_DOT11 macro in RSNInformation header/source files. 2014-06-09 22:50:49 -03:00
Matias Fontanini
3d4f509a62 Added call to pcap_can_set_rfmon before calling pcap_set_rfmon. 2014-06-09 10:24:09 -03:00
Matias Fontanini
c9e955903e Fixed ICMPv6 checksum calculation. 2014-06-09 10:09:20 -03:00
Matias Fontanini
201ea885a1 Added method in TCP and IP that emplaces an option. 2014-06-01 12:55:36 -03:00
Matias Fontanini
356ea2a68a Added small option optimization to PDUOption. 2014-05-29 23:15:44 -03:00
Matias Fontanini
559c963d63 Fixed compilation errors on Windows. 2014-05-06 00:13:05 -03:00
Matias Fontanini
4bf5876adf Fixed compilation error in RSNInformation. 2014-05-05 08:34:16 -03:00
Matias Fontanini
b2788fad63 Simplified error string generation on Sniffer::pcap_open_live_extended. 2014-05-05 08:32:45 -03:00
Matias Fontanini
c249ff608c Merge pull request #11 from kylemcdonald/master
changed ICMP::check to ICMP::checksum
2014-05-03 18:52:29 -03:00
Kyle McDonald
bd55307b47 changed ICMP::check to ICMP::checksum for both the public getter and private setter. closes #10 2014-05-03 17:43:35 -04:00
Matias Fontanini
6b17dc78e5 Merge pull request #9 from kylemcdonald/master
Allow Sniffer to enable monitor mode on interface
2014-05-03 14:32:27 -03:00
Kyle McDonald
5fe4ab0de8 added pcap_open_live_extended() shim to sniffer.cpp and set rfmon to true in beacon capture example 2014-05-03 12:48:35 -04:00
Matias Fontanini
4ee89662f2 Fix bug on TCPStreamFollower. 2014-04-12 11:53:00 -03:00
Matias Fontanini
86e3f138f8 Added correct handling of the PDU::IPv6 flag in Internals::pdu_flag_to_ip_type. 2014-04-07 13:29:14 -03:00
Matias Fontanini
cd2b9aab98 TCPStreamFollower now doesn't clear its state each time follow_streams is called. 2014-04-07 11:29:09 -03:00
Matias Fontanini
f05840b9e9 Merge pull request #5 from lodagro/patch-1
Fix typo in test name
2014-04-03 13:38:43 -03:00
Wouter Overmeire
8c2abf9249 Fix typo in test name 2014-04-03 15:39:26 +02:00
Matias Fontanini
64d35b4903 TCPStreamFollower now handles overlapping fragments. 2014-04-02 11:10:44 -03:00
Matias Fontanini
10421fe945 Added DHCP::hostname. 2014-04-01 10:22:05 -03:00
Matias Fontanini
7c8aefccfe Merge pull request #4 from jacob-baines/patch-1
Remove Extra Qualification
2014-03-12 14:40:46 -02:00
Jacob Baines
60404296fb Remove Extra Qualification
The extra "SessionKeys::" prevents compilation on Windows.
2014-03-12 12:19:29 -04:00
Matias Fontanini
dbc3ab4c32 Updated the LICENSE file. 2014-03-05 18:23:16 -03:00
Matias Fontanini
f83521f778 Merge pull request #3 from JeanJoskin/master
PacketSender::send does not work properly
2014-02-27 11:25:54 -02:00
Jean Joskin
6fb8cbfc86 PacketSender::send matched PDU against most specific type, hence the PDU::DOT11 case would never be chosen. 2014-02-27 13:34:14 +01:00
Matias Fontanini
0acf388277 Removed 'no newline at end of file' warnings. 2014-02-10 18:21:46 -03:00
Matias F
4c4a5f6c03 Fixed bug when calling BIOCIMMEDIATE on *BSD. 2014-02-10 12:33:48 -03:00
Matias Fontanini
fbef2e765d Fixed bug on PacketSender::send_recv which didn't work under OSX and FreeBSD. 2014-02-06 15:10:23 -03:00
Matias F
ea927caa4b Added BSD notice to DNS stats example. 2014-02-03 10:57:30 -03:00
Matias F
60f9116af1 Added DNS stats example. 2014-02-03 10:55:37 -03:00
Matias Fontanini
75c6bb46dc Fixed compilation error in OSX caused by including pcap/bpf.h instead of pcap.h in src/ppi.cpp. 2014-01-25 18:45:55 -03:00
Matias Fontanini
0a2f3b477b Merge pull request #2 from itay-grudev/master
Fixed bug - not included std::string
2014-01-25 13:00:07 -08:00
Itay Grudev
e73ea43f7b Fixed bug - not included std::string
Error details:
implicit instantiation of undefined template std::basic_string
2014-01-25 22:55:59 +02:00
Matias F
17933765d3 dns_spoof example now uses DNS::Resource. 2014-01-24 09:54:03 -03:00
171 changed files with 3522 additions and 1148 deletions

71
CHANGES
View File

@@ -1,3 +1,74 @@
v3.1 - Sun Aug 24 21:39:43 ART 2014
- Fixed ICMPv6 checksum error on serialization.
- Fixed empty domain name encoding on DNS.
- Changed the build system to CMake.
v3.0 - Thu Aug 7 21:39:09 ART 2014
- Timestamps can now be constructed from std::chrono::duration.
- Packets can now be constructed from a PDU pointer and take ownership
of it.
- All protocols now set the next layer protocol flag, regardless if
it was already set. This was not done in some protocols,
like EthernetII, and as a consequence if the network layer protocol
was replaced by other, the packet would be serialized incorrectly.
- Fixed invalid parsing of some unknown DNS records.
- Fixed unaligned memory accesses that were not supported under
ARMv4 and ARMv5.
- Added BaseSniffer::set_extract_raw_pdus.
- Reduced minimum automake version to 1.11.
- Added Utils::to_string(PDU::PDUType).
- Fixed error compilations on Windows.
- Fixed ICMPv6 checksum calculation.
- Added method in IP and TCP to emplace an option (C++11 only).
- Added small option optimization to PDUOption.
- Fixed error compilation on RSNInformation.
- Renamed ICMP::check to ICMP::checksum.
- Added Sniffer support to set interface to promiscuous mode.
- TCPStreamFollower now handles overlapping fragments correctly.
- Fixed bugs in TCPStreamFollower which didn't allow it to follow
stream correctly.
- TCPStreamFollower now doesn't clear its state after every call to
TCPStreamFollower::follow_streams.
- Added IPv6 flag check to pdu_flag_to_ip_type.
- Added DHCP::hostname to extract the hostname options.
- Removed extra qualifier on SessionKeys::decrypt_unicast which
produced compilation errors on some platforms.
- PacketSender::send now uses PDU::matches_flag to match specific
PDU types.
- Removed 'no newline at end of file' warnings.
- Fixed bug when calling BIOCIMMEDIATE on *BSD.
- Fixed bug on PacketSender::send_recv which didn't work under *BSD.
- Fixed bug triggered by not including the string header.
v2.0 - Thu Jan 23 11:09:38 ART 2014 v2.0 - Thu Jan 23 11:09:38 ART 2014
- DNSResourceRecord was removed. Now DNS records are added using - DNSResourceRecord was removed. Now DNS records are added using

134
CMakeLists.txt Normal file
View File

@@ -0,0 +1,134 @@
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.1)
PROJECT(libtins)
# Compile in release mode by default
IF(NOT CMAKE_BUILD_TYPE)
MESSAGE(STATUS "Setting build type to 'RelWithDebInfo' as none was specified.")
SET(CMAKE_BUILD_TYPE RelWithDebInfo)
ELSE(NOT CMAKE_BUILD_TYPE)
MESSAGE(STATUS "Using specified '${CMAKE_BUILD_TYPE}' build type.")
ENDIF(NOT CMAKE_BUILD_TYPE)
# Default compilation settings
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
# Build output checks
OPTION(LIBTINS_BUILD_SHARED "Build libtins as a shared library." ON)
IF(LIBTINS_BUILD_SHARED)
MESSAGE(
STATUS
"Build will generate a shared library. "
"Use LIBTINS_BUILD_SHARED=0 to perform a static build"
)
SET(LIBTINS_TYPE SHARED)
ELSE(LIBTINS_BUILD_SHARED)
MESSAGE(STATUS "Build will generate a static library.")
SET(LIBTINS_TYPE STATIC)
ENDIF(LIBTINS_BUILD_SHARED)
# The version number.
SET(LIBTINS_VERSION_MAJOR 3)
SET(LIBTINS_VERSION_MINOR 1)
SET(LIBTINS_CPP_VERSION "${LIBTINS_VERSION_MAJOR}.${LIBTINS_VERSION_MINOR}")
# Required Packages
SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
# Look for libpcap
FIND_PACKAGE(PCAP REQUIRED)
# Set some Windows specific flags
IF(WIN32)
# We need to link against these libs
SET(LIBTINS_OS_LIBS Ws2_32.lib Iphlpapi.lib)
# Add the NOMINMAX macro to avoid Windows' min and max macros.
# While compiling on windows, for some reason, WIN32 is not defined,
# maybe we could fix this later, but it's OK for now.
ADD_DEFINITIONS(-DNOMINMAX -DWIN32)
ENDIF(WIN32)
# Compilation options
OPTION(LIBTINS_ENABLE_CXX11 "Compile libtins with c++11 features" OFF)
IF(LIBTINS_ENABLE_CXX11)
SET(HAVE_CXX11 ON)
INCLUDE(CheckCXX11Features)
IF(HAS_CXX11_NULLPTR AND HAS_CXX11_RVALUE_REFERENCES)
MESSAGE(STATUS "Enabling C++11 features")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CXX11_COMPILER_FLAGS}")
ELSE(HAS_CXX11_NULLPTR AND HAS_CXX11_RVALUE_REFERENCES)
MESSAGE(FATAL_ERROR "C++11 features requested but the compiler does not support them.")
ENDIF(HAS_CXX11_NULLPTR AND HAS_CXX11_RVALUE_REFERENCES)
ELSE(LIBTINS_ENABLE_CXX11)
MESSAGE(
WARNING
"Disabling C++11 features. Use LIBTINS_ENABLE_CXX11=1 to enable them. "
"Unless you are using an old compiler, you should enable this option, "
"as it increases the library's performance")
ENDIF(LIBTINS_ENABLE_CXX11)
OPTION(LIBTINS_ENABLE_DOT11 "Compile libtins with IEEE 802.11 support" ON)
OPTION(LIBTINS_ENABLE_WPA2 "Compile libtins with WPA2 decryption features (requires OpenSSL)" ON)
IF(LIBTINS_ENABLE_DOT11)
SET(HAVE_DOT11 ON)
MESSAGE(STATUS "Enabling IEEE 802.11 support.")
IF(LIBTINS_ENABLE_WPA2)
FIND_PACKAGE(OpenSSL REQUIRED)
SET(HAVE_WPA2_DECRYPTION ON)
MESSAGE(STATUS "Enabling WPA2 decryption support.")
ELSE(LIBTINS_ENABLE_WPA2)
MESSAGE(STATUS "Disabling WPA2 decryption support.")
ENDIF(LIBTINS_ENABLE_WPA2)
ENDIF(LIBTINS_ENABLE_DOT11)
SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib)
SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib)
# Congiguration file
CONFIGURE_FILE(
"${PROJECT_SOURCE_DIR}/include/config.h.in"
"${PROJECT_SOURCE_DIR}/include/config.h"
)
ENABLE_TESTING()
ADD_SUBDIRECTORY(include)
ADD_SUBDIRECTORY(src)
ADD_SUBDIRECTORY(tests)
ADD_SUBDIRECTORY(examples)
# Add all targets to the build-tree export set
EXPORT(
TARGETS tins
FILE "${PROJECT_BINARY_DIR}/libtinsTargets.cmake"
)
# Export the package for use from the build-tree
# (this registers the build-tree with a global CMake-registry)
EXPORT(PACKAGE libtins)
# Create the libtinsConfig.cmake and libtinsConfigVersion.cmake files
# for the build tree
SET(CONF_INCLUDE_DIRS "${PROJECT_SOURCE_DIR}/include")
CONFIGURE_FILE(
libtinsConfig.cmake.in
"${PROJECT_BINARY_DIR}/libtinsConfig.cmake" @ONLY
)
CONFIGURE_FILE(
libtinsConfigVersion.cmake.in
"${PROJECT_BINARY_DIR}/libtinsConfigVersion.cmake" @ONLY
)
# Install the libtinsConfig.cmake and libtinsConfigVersion.cmake
INSTALL(
FILES
"${PROJECT_BINARY_DIR}/libtinsConfig.cmake"
"${PROJECT_BINARY_DIR}/libtinsConfigVersion.cmake"
DESTINATION CMake
COMPONENT dev
)
# Install the export set for use with the install-tree
INSTALL(
EXPORT libtinsTargets
DESTINATION CMake
COMPONENT dev
)

View File

@@ -1,4 +1,4 @@
Copyright (c) 2012, Nasel Copyright (c) 2012-2014, Matias Fontanini
All rights reserved. All rights reserved.
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without

View File

@@ -1,4 +1,4 @@
AUTOMAKE_OPTIONS=subdir-objects AUTOMAKE_OPTIONS=subdir-objects 1.11
ACLOCAL_AMFLAGS=${ACLOCAL_FLAGS} -I m4 ACLOCAL_AMFLAGS=${ACLOCAL_FLAGS} -I m4
# pkg-config stuff # pkg-config stuff

View File

@@ -1,9 +1,8 @@
# Makefile.in generated by automake 1.11.6 from Makefile.am. # Makefile.in generated by automake 1.14.1 from Makefile.am.
# @configure_input@ # @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # Copyright (C) 1994-2013 Free Software Foundation, Inc.
# 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software
# Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation # This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it, # gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved. # with or without modifications, as long as this notice is preserved.
@@ -18,23 +17,51 @@
VPATH = @srcdir@ VPATH = @srcdir@
am__make_dryrun = \ am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
{ \ am__make_running_with_option = \
am__dry=no; \ case $${target_option-} in \
?) ;; \
*) echo "am__make_running_with_option: internal error: invalid" \
"target option '$${target_option-}' specified" >&2; \
exit 1;; \
esac; \
has_opt=no; \
sane_makeflags=$$MAKEFLAGS; \
if $(am__is_gnu_make); then \
sane_makeflags=$$MFLAGS; \
else \
case $$MAKEFLAGS in \ case $$MAKEFLAGS in \
*\\[\ \ ]*) \ *\\[\ \ ]*) \
echo 'am--echo: ; @echo "AM" OK' | $(MAKE) -f - 2>/dev/null \ bs=\\; \
| grep '^AM OK$$' >/dev/null || am__dry=yes;; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
*) \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \
for am__flg in $$MAKEFLAGS; do \
case $$am__flg in \
*=*|--*) ;; \
*n*) am__dry=yes; break;; \
esac; \
done;; \
esac; \ esac; \
test $$am__dry = yes; \ fi; \
} skip_next=no; \
strip_trailopt () \
{ \
flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
}; \
for flg in $$sane_makeflags; do \
test $$skip_next = yes && { skip_next=no; continue; }; \
case $$flg in \
*=*|--*) continue;; \
-*I) strip_trailopt 'I'; skip_next=yes;; \
-*I?*) strip_trailopt 'I';; \
-*O) strip_trailopt 'O'; skip_next=yes;; \
-*O?*) strip_trailopt 'O';; \
-*l) strip_trailopt 'l'; skip_next=yes;; \
-*l?*) strip_trailopt 'l';; \
-[dEDm]) skip_next=yes;; \
-[JT]) skip_next=yes;; \
esac; \
case $$flg in \
*$$target_option*) has_opt=yes; break;; \
esac; \
done; \
test $$has_opt = yes
am__make_dryrun = (target_option=n; $(am__make_running_with_option))
am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
pkgdatadir = $(datadir)/@PACKAGE@ pkgdatadir = $(datadir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@
@@ -55,12 +82,12 @@ build_triplet = @build@
host_triplet = @host@ host_triplet = @host@
target_triplet = @target@ target_triplet = @target@
subdir = . subdir = .
DIST_COMMON = README $(am__configure_deps) $(libtins_HEADERS) \ DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
$(libtins_dot11_HEADERS) $(srcdir)/Makefile.am \ $(top_srcdir)/configure $(am__configure_deps) \
$(srcdir)/Makefile.in $(srcdir)/libtins.pc.in \ $(top_srcdir)/include/config.h.in $(srcdir)/libtins.pc.in \
$(top_srcdir)/configure $(top_srcdir)/include/config.h.in \ depcomp $(libtins_HEADERS) $(libtins_dot11_HEADERS) AUTHORS \
AUTHORS THANKS config.guess config.sub depcomp install-sh \ README THANKS compile config.guess config.sub install-sh \
ltmain.sh missing missing ltmain.sh
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/m4/ax_cxx_compile_stdcxx_11.m4 \ am__aclocal_m4_deps = $(top_srcdir)/m4/ax_cxx_compile_stdcxx_11.m4 \
$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \ $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
@@ -122,22 +149,47 @@ am_libtins_la_OBJECTS = src/arp.lo src/bootp.lo \
src/dot11/dot11_assoc.lo src/dot11/dot11_auth.lo \ src/dot11/dot11_assoc.lo src/dot11/dot11_auth.lo \
src/dot11/dot11_probe.lo src/dot11/dot11_control.lo src/dot11/dot11_probe.lo src/dot11/dot11_control.lo
libtins_la_OBJECTS = $(am_libtins_la_OBJECTS) libtins_la_OBJECTS = $(am_libtins_la_OBJECTS)
libtins_la_LINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) \ AM_V_lt = $(am__v_lt_@AM_V@)
am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
am__v_lt_0 = --silent
am__v_lt_1 =
libtins_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \
$(CXXFLAGS) $(libtins_la_LDFLAGS) $(LDFLAGS) -o $@ $(CXXFLAGS) $(libtins_la_LDFLAGS) $(LDFLAGS) -o $@
AM_V_P = $(am__v_P_@AM_V@)
am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
am__v_P_0 = false
am__v_P_1 = :
AM_V_GEN = $(am__v_GEN_@AM_V@)
am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
am__v_GEN_0 = @echo " GEN " $@;
am__v_GEN_1 =
AM_V_at = $(am__v_at_@AM_V@)
am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
am__v_at_0 = @
am__v_at_1 =
DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/include DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/include
depcomp = $(SHELL) $(top_srcdir)/depcomp depcomp = $(SHELL) $(top_srcdir)/depcomp
am__depfiles_maybe = depfiles am__depfiles_maybe = depfiles
am__mv = mv -f am__mv = mv -f
CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
LTCXXCOMPILE = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ LTCXXCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
--mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \
$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
$(AM_CXXFLAGS) $(CXXFLAGS)
AM_V_CXX = $(am__v_CXX_@AM_V@)
am__v_CXX_ = $(am__v_CXX_@AM_DEFAULT_V@)
am__v_CXX_0 = @echo " CXX " $@;
am__v_CXX_1 =
CXXLD = $(CXX) CXXLD = $(CXX)
CXXLINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
--mode=link $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \
$(LDFLAGS) -o $@ $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
AM_V_CXXLD = $(am__v_CXXLD_@AM_V@)
am__v_CXXLD_ = $(am__v_CXXLD_@AM_DEFAULT_V@)
am__v_CXXLD_0 = @echo " CXXLD " $@;
am__v_CXXLD_1 =
SOURCES = $(libtins_la_SOURCES) SOURCES = $(libtins_la_SOURCES)
DIST_SOURCES = $(libtins_la_SOURCES) DIST_SOURCES = $(libtins_la_SOURCES)
am__can_run_installinfo = \ am__can_run_installinfo = \
@@ -147,8 +199,27 @@ am__can_run_installinfo = \
esac esac
DATA = $(pkgconfig_DATA) DATA = $(pkgconfig_DATA)
HEADERS = $(libtins_HEADERS) $(libtins_dot11_HEADERS) HEADERS = $(libtins_HEADERS) $(libtins_dot11_HEADERS)
am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
# Read a list of newline-separated strings from the standard input,
# and print each of them once, without duplicates. Input order is
# *not* preserved.
am__uniquify_input = $(AWK) '\
BEGIN { nonempty = 0; } \
{ items[$$0] = 1; nonempty = 1; } \
END { if (nonempty) { for (i in items) print i; }; } \
'
# Make sure the list of sources is unique. This is necessary because,
# e.g., the same source file might be shared among _SOURCES variables
# for different programs/libraries.
am__define_uniq_tagged_files = \
list='$(am__tagged_files)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | $(am__uniquify_input)`
ETAGS = etags ETAGS = etags
CTAGS = ctags CTAGS = ctags
CSCOPE = cscope
AM_RECURSIVE_TARGETS = cscope
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
distdir = $(PACKAGE)-$(VERSION) distdir = $(PACKAGE)-$(VERSION)
top_distdir = $(distdir) top_distdir = $(distdir)
@@ -158,14 +229,17 @@ am__remove_distdir = \
&& rm -rf "$(distdir)" \ && rm -rf "$(distdir)" \
|| { sleep 5 && rm -rf "$(distdir)"; }; \ || { sleep 5 && rm -rf "$(distdir)"; }; \
else :; fi else :; fi
am__post_remove_distdir = $(am__remove_distdir)
DIST_ARCHIVES = $(distdir).tar.gz DIST_ARCHIVES = $(distdir).tar.gz
GZIP_ENV = --best GZIP_ENV = --best
DIST_TARGETS = dist-gzip
distuninstallcheck_listfiles = find . -type f -print distuninstallcheck_listfiles = find . -type f -print
am__distuninstallcheck_listfiles = $(distuninstallcheck_listfiles) \ am__distuninstallcheck_listfiles = $(distuninstallcheck_listfiles) \
| sed 's|^\./|$(prefix)/|' | grep -v '$(infodir)/dir$$' | sed 's|^\./|$(prefix)/|' | grep -v '$(infodir)/dir$$'
distcleancheck_listfiles = find . -type f -print distcleancheck_listfiles = find . -type f -print
ACLOCAL = @ACLOCAL@ ACLOCAL = @ACLOCAL@
AMTAR = @AMTAR@ AMTAR = @AMTAR@
AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
AR = @AR@ AR = @AR@
AUTOCONF = @AUTOCONF@ AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@ AUTOHEADER = @AUTOHEADER@
@@ -290,7 +364,7 @@ target_vendor = @target_vendor@
top_build_prefix = @top_build_prefix@ top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@ top_builddir = @top_builddir@
top_srcdir = @top_srcdir@ top_srcdir = @top_srcdir@
AUTOMAKE_OPTIONS = subdir-objects AUTOMAKE_OPTIONS = subdir-objects 1.11
ACLOCAL_AMFLAGS = ${ACLOCAL_FLAGS} -I m4 ACLOCAL_AMFLAGS = ${ACLOCAL_FLAGS} -I m4
# pkg-config stuff # pkg-config stuff
@@ -456,8 +530,8 @@ $(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
$(am__aclocal_m4_deps): $(am__aclocal_m4_deps):
include/config.h: include/stamp-h1 include/config.h: include/stamp-h1
@if test ! -f $@; then rm -f include/stamp-h1; else :; fi @test -f $@ || rm -f include/stamp-h1
@if test ! -f $@; then $(MAKE) $(AM_MAKEFLAGS) include/stamp-h1; else :; fi @test -f $@ || $(MAKE) $(AM_MAKEFLAGS) include/stamp-h1
include/stamp-h1: $(top_srcdir)/include/config.h.in $(top_builddir)/config.status include/stamp-h1: $(top_srcdir)/include/config.h.in $(top_builddir)/config.status
@rm -f include/stamp-h1 @rm -f include/stamp-h1
@@ -471,6 +545,7 @@ distclean-hdr:
-rm -f include/config.h include/stamp-h1 -rm -f include/config.h include/stamp-h1
libtins.pc: $(top_builddir)/config.status $(srcdir)/libtins.pc.in libtins.pc: $(top_builddir)/config.status $(srcdir)/libtins.pc.in
cd $(top_builddir) && $(SHELL) ./config.status $@ cd $(top_builddir) && $(SHELL) ./config.status $@
install-libLTLIBRARIES: $(lib_LTLIBRARIES) install-libLTLIBRARIES: $(lib_LTLIBRARIES)
@$(NORMAL_INSTALL) @$(NORMAL_INSTALL)
@list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \ @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \
@@ -497,12 +572,14 @@ uninstall-libLTLIBRARIES:
clean-libLTLIBRARIES: clean-libLTLIBRARIES:
-test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES) -test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES)
@list='$(lib_LTLIBRARIES)'; for p in $$list; do \ @list='$(lib_LTLIBRARIES)'; \
dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \ locs=`for p in $$list; do echo $$p; done | \
test "$$dir" != "$$p" || dir=.; \ sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \
echo "rm -f \"$${dir}/so_locations\""; \ sort -u`; \
rm -f "$${dir}/so_locations"; \ test -z "$$locs" || { \
done echo rm -f $${locs}; \
rm -f $${locs}; \
}
src/$(am__dirstamp): src/$(am__dirstamp):
@$(MKDIR_P) src @$(MKDIR_P) src
@: > src/$(am__dirstamp) @: > src/$(am__dirstamp)
@@ -578,107 +655,16 @@ src/dot11/dot11_probe.lo: src/dot11/$(am__dirstamp) \
src/dot11/$(DEPDIR)/$(am__dirstamp) src/dot11/$(DEPDIR)/$(am__dirstamp)
src/dot11/dot11_control.lo: src/dot11/$(am__dirstamp) \ src/dot11/dot11_control.lo: src/dot11/$(am__dirstamp) \
src/dot11/$(DEPDIR)/$(am__dirstamp) src/dot11/$(DEPDIR)/$(am__dirstamp)
libtins.la: $(libtins_la_OBJECTS) $(libtins_la_DEPENDENCIES) $(EXTRA_libtins_la_DEPENDENCIES) libtins.la: $(libtins_la_OBJECTS) $(libtins_la_DEPENDENCIES) $(EXTRA_libtins_la_DEPENDENCIES)
$(libtins_la_LINK) -rpath $(libdir) $(libtins_la_OBJECTS) $(libtins_la_LIBADD) $(LIBS) $(AM_V_CXXLD)$(libtins_la_LINK) -rpath $(libdir) $(libtins_la_OBJECTS) $(libtins_la_LIBADD) $(LIBS)
mostlyclean-compile: mostlyclean-compile:
-rm -f *.$(OBJEXT) -rm -f *.$(OBJEXT)
-rm -f src/address_range.$(OBJEXT) -rm -f src/*.$(OBJEXT)
-rm -f src/address_range.lo -rm -f src/*.lo
-rm -f src/arp.$(OBJEXT) -rm -f src/dot11/*.$(OBJEXT)
-rm -f src/arp.lo -rm -f src/dot11/*.lo
-rm -f src/bootp.$(OBJEXT)
-rm -f src/bootp.lo
-rm -f src/crypto.$(OBJEXT)
-rm -f src/crypto.lo
-rm -f src/dhcp.$(OBJEXT)
-rm -f src/dhcp.lo
-rm -f src/dhcpv6.$(OBJEXT)
-rm -f src/dhcpv6.lo
-rm -f src/dns.$(OBJEXT)
-rm -f src/dns.lo
-rm -f src/dot11/dot11_assoc.$(OBJEXT)
-rm -f src/dot11/dot11_assoc.lo
-rm -f src/dot11/dot11_auth.$(OBJEXT)
-rm -f src/dot11/dot11_auth.lo
-rm -f src/dot11/dot11_base.$(OBJEXT)
-rm -f src/dot11/dot11_base.lo
-rm -f src/dot11/dot11_beacon.$(OBJEXT)
-rm -f src/dot11/dot11_beacon.lo
-rm -f src/dot11/dot11_control.$(OBJEXT)
-rm -f src/dot11/dot11_control.lo
-rm -f src/dot11/dot11_data.$(OBJEXT)
-rm -f src/dot11/dot11_data.lo
-rm -f src/dot11/dot11_mgmt.$(OBJEXT)
-rm -f src/dot11/dot11_mgmt.lo
-rm -f src/dot11/dot11_probe.$(OBJEXT)
-rm -f src/dot11/dot11_probe.lo
-rm -f src/dot1q.$(OBJEXT)
-rm -f src/dot1q.lo
-rm -f src/dot3.$(OBJEXT)
-rm -f src/dot3.lo
-rm -f src/eapol.$(OBJEXT)
-rm -f src/eapol.lo
-rm -f src/ethernetII.$(OBJEXT)
-rm -f src/ethernetII.lo
-rm -f src/handshake_capturer.$(OBJEXT)
-rm -f src/handshake_capturer.lo
-rm -f src/icmp.$(OBJEXT)
-rm -f src/icmp.lo
-rm -f src/icmpv6.$(OBJEXT)
-rm -f src/icmpv6.lo
-rm -f src/internals.$(OBJEXT)
-rm -f src/internals.lo
-rm -f src/ip.$(OBJEXT)
-rm -f src/ip.lo
-rm -f src/ip_address.$(OBJEXT)
-rm -f src/ip_address.lo
-rm -f src/ip_reassembler.$(OBJEXT)
-rm -f src/ip_reassembler.lo
-rm -f src/ipsec.$(OBJEXT)
-rm -f src/ipsec.lo
-rm -f src/ipv6.$(OBJEXT)
-rm -f src/ipv6.lo
-rm -f src/ipv6_address.$(OBJEXT)
-rm -f src/ipv6_address.lo
-rm -f src/llc.$(OBJEXT)
-rm -f src/llc.lo
-rm -f src/loopback.$(OBJEXT)
-rm -f src/loopback.lo
-rm -f src/network_interface.$(OBJEXT)
-rm -f src/network_interface.lo
-rm -f src/packet_sender.$(OBJEXT)
-rm -f src/packet_sender.lo
-rm -f src/packet_writer.$(OBJEXT)
-rm -f src/packet_writer.lo
-rm -f src/pdu.$(OBJEXT)
-rm -f src/pdu.lo
-rm -f src/ppi.$(OBJEXT)
-rm -f src/ppi.lo
-rm -f src/pppoe.$(OBJEXT)
-rm -f src/pppoe.lo
-rm -f src/radiotap.$(OBJEXT)
-rm -f src/radiotap.lo
-rm -f src/rawpdu.$(OBJEXT)
-rm -f src/rawpdu.lo
-rm -f src/rsn_information.$(OBJEXT)
-rm -f src/rsn_information.lo
-rm -f src/sll.$(OBJEXT)
-rm -f src/sll.lo
-rm -f src/snap.$(OBJEXT)
-rm -f src/snap.lo
-rm -f src/sniffer.$(OBJEXT)
-rm -f src/sniffer.lo
-rm -f src/stp.$(OBJEXT)
-rm -f src/stp.lo
-rm -f src/tcp.$(OBJEXT)
-rm -f src/tcp.lo
-rm -f src/tcp_stream.$(OBJEXT)
-rm -f src/tcp_stream.lo
-rm -f src/udp.$(OBJEXT)
-rm -f src/udp.lo
-rm -f src/utils.$(OBJEXT)
-rm -f src/utils.lo
distclean-compile: distclean-compile:
-rm -f *.tab.c -rm -f *.tab.c
@@ -733,28 +719,28 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@src/dot11/$(DEPDIR)/dot11_probe.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/dot11/$(DEPDIR)/dot11_probe.Plo@am__quote@
.cpp.o: .cpp.o:
@am__fastdepCXX_TRUE@ depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\
@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\
@am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $< @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ $<
.cpp.obj: .cpp.obj:
@am__fastdepCXX_TRUE@ depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\
@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\
@am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
.cpp.lo: .cpp.lo:
@am__fastdepCXX_TRUE@ depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\
@am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\
@am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(LTCXXCOMPILE) -c -o $@ $< @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LTCXXCOMPILE) -c -o $@ $<
mostlyclean-libtool: mostlyclean-libtool:
-rm -f *.lo -rm -f *.lo
@@ -830,26 +816,15 @@ uninstall-libtins_dot11HEADERS:
files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
dir='$(DESTDIR)$(libtins_dot11dir)'; $(am__uninstall_files_from_dir) dir='$(DESTDIR)$(libtins_dot11dir)'; $(am__uninstall_files_from_dir)
ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) ID: $(am__tagged_files)
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ $(am__define_uniq_tagged_files); mkid -fID $$unique
unique=`for i in $$list; do \ tags: tags-am
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ TAGS: tags
done | \
$(AWK) '{ files[$$0] = 1; nonempty = 1; } \
END { if (nonempty) { for (i in files) print i; }; }'`; \
mkid -fID $$unique
tags: TAGS
TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
$(TAGS_FILES) $(LISP)
set x; \ set x; \
here=`pwd`; \ here=`pwd`; \
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ $(am__define_uniq_tagged_files); \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) '{ files[$$0] = 1; nonempty = 1; } \
END { if (nonempty) { for (i in files) print i; }; }'`; \
shift; \ shift; \
if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
test -n "$$unique" || unique=$$empty_fix; \ test -n "$$unique" || unique=$$empty_fix; \
@@ -861,15 +836,11 @@ TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
$$unique; \ $$unique; \
fi; \ fi; \
fi fi
ctags: CTAGS ctags: ctags-am
CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP) CTAGS: ctags
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
unique=`for i in $$list; do \ $(am__define_uniq_tagged_files); \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) '{ files[$$0] = 1; nonempty = 1; } \
END { if (nonempty) { for (i in files) print i; }; }'`; \
test -z "$(CTAGS_ARGS)$$unique" \ test -z "$(CTAGS_ARGS)$$unique" \
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
$$unique $$unique
@@ -878,9 +849,31 @@ GTAGS:
here=`$(am__cd) $(top_builddir) && pwd` \ here=`$(am__cd) $(top_builddir) && pwd` \
&& $(am__cd) $(top_srcdir) \ && $(am__cd) $(top_srcdir) \
&& gtags -i $(GTAGS_ARGS) "$$here" && gtags -i $(GTAGS_ARGS) "$$here"
cscope: cscope.files
test ! -s cscope.files \
|| $(CSCOPE) -b -q $(AM_CSCOPEFLAGS) $(CSCOPEFLAGS) -i cscope.files $(CSCOPE_ARGS)
clean-cscope:
-rm -f cscope.files
cscope.files: clean-cscope cscopelist
cscopelist: cscopelist-am
cscopelist-am: $(am__tagged_files)
list='$(am__tagged_files)'; \
case "$(srcdir)" in \
[\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
*) sdir=$(subdir)/$(srcdir) ;; \
esac; \
for i in $$list; do \
if test -f "$$i"; then \
echo "$(subdir)/$$i"; \
else \
echo "$$sdir/$$i"; \
fi; \
done >> $(top_builddir)/cscope.files
distclean-tags: distclean-tags:
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
-rm -f cscope.out cscope.in.out cscope.po.out cscope.files
distdir: $(DISTFILES) distdir: $(DISTFILES)
$(am__remove_distdir) $(am__remove_distdir)
@@ -923,40 +916,42 @@ distdir: $(DISTFILES)
|| chmod -R a+r "$(distdir)" || chmod -R a+r "$(distdir)"
dist-gzip: distdir dist-gzip: distdir
tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz
$(am__remove_distdir) $(am__post_remove_distdir)
dist-bzip2: distdir dist-bzip2: distdir
tardir=$(distdir) && $(am__tar) | BZIP2=$${BZIP2--9} bzip2 -c >$(distdir).tar.bz2 tardir=$(distdir) && $(am__tar) | BZIP2=$${BZIP2--9} bzip2 -c >$(distdir).tar.bz2
$(am__remove_distdir) $(am__post_remove_distdir)
dist-lzip: distdir dist-lzip: distdir
tardir=$(distdir) && $(am__tar) | lzip -c $${LZIP_OPT--9} >$(distdir).tar.lz tardir=$(distdir) && $(am__tar) | lzip -c $${LZIP_OPT--9} >$(distdir).tar.lz
$(am__remove_distdir) $(am__post_remove_distdir)
dist-lzma: distdir
tardir=$(distdir) && $(am__tar) | lzma -9 -c >$(distdir).tar.lzma
$(am__remove_distdir)
dist-xz: distdir dist-xz: distdir
tardir=$(distdir) && $(am__tar) | XZ_OPT=$${XZ_OPT--e} xz -c >$(distdir).tar.xz tardir=$(distdir) && $(am__tar) | XZ_OPT=$${XZ_OPT--e} xz -c >$(distdir).tar.xz
$(am__remove_distdir) $(am__post_remove_distdir)
dist-tarZ: distdir dist-tarZ: distdir
@echo WARNING: "Support for shar distribution archives is" \
"deprecated." >&2
@echo WARNING: "It will be removed altogether in Automake 2.0" >&2
tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z
$(am__remove_distdir) $(am__post_remove_distdir)
dist-shar: distdir dist-shar: distdir
@echo WARNING: "Support for distribution archives compressed with" \
"legacy program 'compress' is deprecated." >&2
@echo WARNING: "It will be removed altogether in Automake 2.0" >&2
shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz
$(am__remove_distdir) $(am__post_remove_distdir)
dist-zip: distdir dist-zip: distdir
-rm -f $(distdir).zip -rm -f $(distdir).zip
zip -rq $(distdir).zip $(distdir) zip -rq $(distdir).zip $(distdir)
$(am__remove_distdir) $(am__post_remove_distdir)
dist dist-all: distdir dist dist-all:
tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz $(MAKE) $(AM_MAKEFLAGS) $(DIST_TARGETS) am__post_remove_distdir='@:'
$(am__remove_distdir) $(am__post_remove_distdir)
# This target untars the dist file and tries a VPATH configuration. Then # This target untars the dist file and tries a VPATH configuration. Then
# it guarantees that the distribution is self-contained by making another # it guarantees that the distribution is self-contained by making another
@@ -967,8 +962,6 @@ distcheck: dist
GZIP=$(GZIP_ENV) gzip -dc $(distdir).tar.gz | $(am__untar) ;;\ GZIP=$(GZIP_ENV) gzip -dc $(distdir).tar.gz | $(am__untar) ;;\
*.tar.bz2*) \ *.tar.bz2*) \
bzip2 -dc $(distdir).tar.bz2 | $(am__untar) ;;\ bzip2 -dc $(distdir).tar.bz2 | $(am__untar) ;;\
*.tar.lzma*) \
lzma -dc $(distdir).tar.lzma | $(am__untar) ;;\
*.tar.lz*) \ *.tar.lz*) \
lzip -dc $(distdir).tar.lz | $(am__untar) ;;\ lzip -dc $(distdir).tar.lz | $(am__untar) ;;\
*.tar.xz*) \ *.tar.xz*) \
@@ -980,18 +973,19 @@ distcheck: dist
*.zip*) \ *.zip*) \
unzip $(distdir).zip ;;\ unzip $(distdir).zip ;;\
esac esac
chmod -R a-w $(distdir); chmod u+w $(distdir) chmod -R a-w $(distdir)
mkdir $(distdir)/_build chmod u+w $(distdir)
mkdir $(distdir)/_inst mkdir $(distdir)/_build $(distdir)/_inst
chmod a-w $(distdir) chmod a-w $(distdir)
test -d $(distdir)/_build || exit 0; \ test -d $(distdir)/_build || exit 0; \
dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \ dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \
&& dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \ && dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \
&& am__cwd=`pwd` \ && am__cwd=`pwd` \
&& $(am__cd) $(distdir)/_build \ && $(am__cd) $(distdir)/_build \
&& ../configure --srcdir=.. --prefix="$$dc_install_base" \ && ../configure \
$(AM_DISTCHECK_CONFIGURE_FLAGS) \ $(AM_DISTCHECK_CONFIGURE_FLAGS) \
$(DISTCHECK_CONFIGURE_FLAGS) \ $(DISTCHECK_CONFIGURE_FLAGS) \
--srcdir=.. --prefix="$$dc_install_base" \
&& $(MAKE) $(AM_MAKEFLAGS) \ && $(MAKE) $(AM_MAKEFLAGS) \
&& $(MAKE) $(AM_MAKEFLAGS) dvi \ && $(MAKE) $(AM_MAKEFLAGS) dvi \
&& $(MAKE) $(AM_MAKEFLAGS) check \ && $(MAKE) $(AM_MAKEFLAGS) check \
@@ -1014,7 +1008,7 @@ distcheck: dist
&& $(MAKE) $(AM_MAKEFLAGS) distcleancheck \ && $(MAKE) $(AM_MAKEFLAGS) distcleancheck \
&& cd "$$am__cwd" \ && cd "$$am__cwd" \
|| exit 1 || exit 1
$(am__remove_distdir) $(am__post_remove_distdir)
@(echo "$(distdir) archives ready for distribution: "; \ @(echo "$(distdir) archives ready for distribution: "; \
list='$(DIST_ARCHIVES)'; for i in $$list; do echo $$i; done) | \ list='$(DIST_ARCHIVES)'; for i in $$list; do echo $$i; done) | \
sed -e 1h -e 1s/./=/g -e 1p -e 1x -e '$$p' -e '$$x' sed -e 1h -e 1s/./=/g -e 1p -e 1x -e '$$p' -e '$$x'
@@ -1163,23 +1157,23 @@ uninstall-am: uninstall-libLTLIBRARIES uninstall-libtinsHEADERS \
.MAKE: install-am install-strip .MAKE: install-am install-strip
.PHONY: CTAGS GTAGS all all-am am--refresh check check-am clean \ .PHONY: CTAGS GTAGS TAGS all all-am am--refresh check check-am clean \
clean-generic clean-libLTLIBRARIES clean-libtool ctags dist \ clean-cscope clean-generic clean-libLTLIBRARIES clean-libtool \
dist-all dist-bzip2 dist-gzip dist-lzip dist-lzma dist-shar \ cscope cscopelist-am ctags ctags-am dist dist-all dist-bzip2 \
dist-tarZ dist-xz dist-zip distcheck distclean \ dist-gzip dist-lzip dist-shar dist-tarZ dist-xz dist-zip \
distclean-compile distclean-generic distclean-hdr \ distcheck distclean distclean-compile distclean-generic \
distclean-libtool distclean-tags distcleancheck distdir \ distclean-hdr distclean-libtool distclean-tags distcleancheck \
distuninstallcheck dvi dvi-am html html-am info info-am \ distdir distuninstallcheck dvi dvi-am html html-am info \
install install-am install-data install-data-am install-dvi \ info-am install install-am install-data install-data-am \
install-dvi-am install-exec install-exec-am install-html \ install-dvi install-dvi-am install-exec install-exec-am \
install-html-am install-info install-info-am \ install-html install-html-am install-info install-info-am \
install-libLTLIBRARIES install-libtinsHEADERS \ install-libLTLIBRARIES install-libtinsHEADERS \
install-libtins_dot11HEADERS install-man install-pdf \ install-libtins_dot11HEADERS install-man install-pdf \
install-pdf-am install-pkgconfigDATA install-ps install-ps-am \ install-pdf-am install-pkgconfigDATA install-ps install-ps-am \
install-strip installcheck installcheck-am installdirs \ install-strip installcheck installcheck-am installdirs \
maintainer-clean maintainer-clean-generic mostlyclean \ maintainer-clean maintainer-clean-generic mostlyclean \
mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ mostlyclean-compile mostlyclean-generic mostlyclean-libtool \
pdf pdf-am ps ps-am tags uninstall uninstall-am \ pdf pdf-am ps ps-am tags tags-am uninstall uninstall-am \
uninstall-libLTLIBRARIES uninstall-libtinsHEADERS \ uninstall-libLTLIBRARIES uninstall-libtinsHEADERS \
uninstall-libtins_dot11HEADERS uninstall-pkgconfigDATA uninstall-libtins_dot11HEADERS uninstall-pkgconfigDATA

2
README
View File

@@ -1,5 +1,5 @@
------------------------------------------------------------------------ ------------------------------------------------------------------------
libtins v2.0 libtins v3.0
------------------------------------------------------------------------ ------------------------------------------------------------------------

View File

@@ -23,41 +23,49 @@ if some features of the library are disabled.
In order to compile, execute: In order to compile, execute:
```Shell ```Shell
./configure # Create the build directory
mkdir build
cd build
# Configure the project. Add any relevant configuration flags
cmake ../
# Compile!
make make
``` ```
Note that by default, only the shared object is compiled. If you would Note that by default, only the shared object is compiled. If you would
like to generate a static library file as well, run: like to generate a static library file, run:
```Shell ```Shell
./configure --enable-static cmake ../ -DLIBTINS_BUILD_SHARED=0
``` ```
The generated static/shared library files will be located in the .libs The generated static/shared library files will be located in the
directory. _build/lib_ directory.
libtins is noticeable faster if you enable C++11 support. Therefore, if libtins is noticeable faster if you enable _C++11_ support. Therefore,
your compiler supports this standard, then you should enable it. In if your compiler supports this standard, then you should enable it.
order to do so, use the --enable-c++11 switch: In order to do so, use the _LIBTINS_ENABLE_CXX11_ switch:
```Shell ```Shell
./configure --enable-c++11 cmake ../ -DLIBTINS_ENABLE_CXX11=1
``` ```
If you want to disable WPA2 decryption support, which will remove If you want to disable _WPA2_ decryption support, which will remove
openssl as a dependency for compilation, use the --disable-wpa2 switch: openssl as a dependency for compilation, use the
_LIBTINS_ENABLE_WPA2_ switch:
```Shell ```Shell
./configure --disable-wpa2 cmake ../ -DLIBTINS_ENABLE_WPA2=0
``` ```
If you want to disable IEEE 802.11 support(this will also disable If you want to disable IEEE 802.11 support(this will also disable
RadioTap and WPA2 decryption), which will reduce the size of the RadioTap and WPA2 decryption), which will reduce the size of the
resulting library in around 20%, use the --disable-dot11 switch: resulting library in around 20%, use the _LIBTINS_ENABLE_DOT11_ switch:
```Shell ```Shell
./configure --disable-dot11 cmake ../ -DLIBTINS_ENABLE_DOT11=0
``` ```
## Installing ## ## Installing ##
@@ -69,7 +77,7 @@ shared object, execute as root:
make install make install
``` ```
This will install the shared object typically in /usr/local/lib. Note This will install the shared object typically in _/usr/local/lib_. Note
that you might have to update ldconfig's cache before using it, so that you might have to update ldconfig's cache before using it, so
in order to invalidate it, you should run(as root): in order to invalidate it, you should run(as root):

702
aclocal.m4 vendored

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,142 @@
# - Check which parts of the C++11 standard the compiler supports
#
# When found it will set the following variables
#
# CXX11_COMPILER_FLAGS - the compiler flags needed to get C++11 features
#
# HAS_CXX11_AUTO - auto keyword
# HAS_CXX11_AUTO_RET_TYPE - function declaration with deduced return types
# HAS_CXX11_CLASS_OVERRIDE - override and final keywords for classes and methods
# HAS_CXX11_CONSTEXPR - constexpr keyword
# HAS_CXX11_CSTDINT_H - cstdint header
# HAS_CXX11_DECLTYPE - decltype keyword
# HAS_CXX11_FUNC - __func__ preprocessor constant
# HAS_CXX11_INITIALIZER_LIST - initializer list
# HAS_CXX11_LAMBDA - lambdas
# HAS_CXX11_LIB_REGEX - regex library
# HAS_CXX11_LONG_LONG - long long signed & unsigned types
# HAS_CXX11_NULLPTR - nullptr
# HAS_CXX11_RVALUE_REFERENCES - rvalue references
# HAS_CXX11_SIZEOF_MEMBER - sizeof() non-static members
# HAS_CXX11_STATIC_ASSERT - static_assert()
# HAS_CXX11_VARIADIC_TEMPLATES - variadic templates
#=============================================================================
# Copyright 2011,2012 Rolf Eike Beer <eike@sf-mail.de>
# Copyright 2012 Andreas Weis
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
# (To distribute this file outside of CMake, substitute the full
# License text for the above reference.)
#
# Each feature may have up to 3 checks, every one of them in it's own file
# FEATURE.cpp - example that must build and return 0 when run
# FEATURE_fail.cpp - example that must build, but may not return 0 when run
# FEATURE_fail_compile.cpp - example that must fail compilation
#
# The first one is mandatory, the latter 2 are optional and do not depend on
# each other (i.e. only one may be present).
#
if (NOT CMAKE_CXX_COMPILER_LOADED)
message(FATAL_ERROR "CheckCXX11Features modules only works if language CXX is enabled")
endif ()
cmake_minimum_required(VERSION 2.8.3)
#
### Check for needed compiler flags
#
include(CheckCXXCompilerFlag)
check_cxx_compiler_flag("-std=c++11" _HAS_CXX11_FLAG)
if (NOT _HAS_CXX11_FLAG)
check_cxx_compiler_flag("-std=c++0x" _HAS_CXX0X_FLAG)
endif ()
if (_HAS_CXX11_FLAG)
set(CXX11_COMPILER_FLAGS "-std=c++11")
elseif (_HAS_CXX0X_FLAG)
set(CXX11_COMPILER_FLAGS "-std=c++0x")
endif ()
function(cxx11_check_feature FEATURE_NAME RESULT_VAR)
if (NOT DEFINED ${RESULT_VAR})
set(_bindir "${CMAKE_CURRENT_BINARY_DIR}/cxx11_${FEATURE_NAME}")
set(_SRCFILE_BASE ${CMAKE_CURRENT_LIST_DIR}/CheckCXX11Features/cxx11-test-${FEATURE_NAME})
set(_LOG_NAME "\"${FEATURE_NAME}\"")
message(STATUS "Checking C++11 support for ${_LOG_NAME}")
set(_SRCFILE "${_SRCFILE_BASE}.cpp")
set(_SRCFILE_FAIL "${_SRCFILE_BASE}_fail.cpp")
set(_SRCFILE_FAIL_COMPILE "${_SRCFILE_BASE}_fail_compile.cpp")
if (CROSS_COMPILING)
try_compile(${RESULT_VAR} "${_bindir}" "${_SRCFILE}"
COMPILE_DEFINITIONS "${CXX11_COMPILER_FLAGS}")
if (${RESULT_VAR} AND EXISTS ${_SRCFILE_FAIL})
try_compile(${RESULT_VAR} "${_bindir}_fail" "${_SRCFILE_FAIL}"
COMPILE_DEFINITIONS "${CXX11_COMPILER_FLAGS}")
endif (${RESULT_VAR} AND EXISTS ${_SRCFILE_FAIL})
else (CROSS_COMPILING)
try_run(_RUN_RESULT_VAR _COMPILE_RESULT_VAR
"${_bindir}" "${_SRCFILE}"
COMPILE_DEFINITIONS "${CXX11_COMPILER_FLAGS}")
if (_COMPILE_RESULT_VAR AND NOT _RUN_RESULT_VAR)
set(${RESULT_VAR} TRUE)
else (_COMPILE_RESULT_VAR AND NOT _RUN_RESULT_VAR)
set(${RESULT_VAR} FALSE)
endif (_COMPILE_RESULT_VAR AND NOT _RUN_RESULT_VAR)
if (${RESULT_VAR} AND EXISTS ${_SRCFILE_FAIL})
try_run(_RUN_RESULT_VAR _COMPILE_RESULT_VAR
"${_bindir}_fail" "${_SRCFILE_FAIL}"
COMPILE_DEFINITIONS "${CXX11_COMPILER_FLAGS}")
if (_COMPILE_RESULT_VAR AND _RUN_RESULT_VAR)
set(${RESULT_VAR} TRUE)
else (_COMPILE_RESULT_VAR AND _RUN_RESULT_VAR)
set(${RESULT_VAR} FALSE)
endif (_COMPILE_RESULT_VAR AND _RUN_RESULT_VAR)
endif (${RESULT_VAR} AND EXISTS ${_SRCFILE_FAIL})
endif (CROSS_COMPILING)
if (${RESULT_VAR} AND EXISTS ${_SRCFILE_FAIL_COMPILE})
try_compile(_TMP_RESULT "${_bindir}_fail_compile" "${_SRCFILE_FAIL_COMPILE}"
COMPILE_DEFINITIONS "${CXX11_COMPILER_FLAGS}")
if (_TMP_RESULT)
set(${RESULT_VAR} FALSE)
else (_TMP_RESULT)
set(${RESULT_VAR} TRUE)
endif (_TMP_RESULT)
endif (${RESULT_VAR} AND EXISTS ${_SRCFILE_FAIL_COMPILE})
if (${RESULT_VAR})
message(STATUS "Checking C++11 support for ${_LOG_NAME}: works")
else (${RESULT_VAR})
message(STATUS "Checking C++11 support for ${_LOG_NAME}: not supported")
endif (${RESULT_VAR})
set(${RESULT_VAR} ${${RESULT_VAR}} CACHE INTERNAL "C++11 support for ${_LOG_NAME}")
endif (NOT DEFINED ${RESULT_VAR})
endfunction(cxx11_check_feature)
cxx11_check_feature("__func__" HAS_CXX11_FUNC)
cxx11_check_feature("auto" HAS_CXX11_AUTO)
cxx11_check_feature("auto_ret_type" HAS_CXX11_AUTO_RET_TYPE)
cxx11_check_feature("class_override_final" HAS_CXX11_CLASS_OVERRIDE)
cxx11_check_feature("constexpr" HAS_CXX11_CONSTEXPR)
cxx11_check_feature("cstdint" HAS_CXX11_CSTDINT_H)
cxx11_check_feature("decltype" HAS_CXX11_DECLTYPE)
cxx11_check_feature("initializer_list" HAS_CXX11_INITIALIZER_LIST)
cxx11_check_feature("lambda" HAS_CXX11_LAMBDA)
cxx11_check_feature("long_long" HAS_CXX11_LONG_LONG)
cxx11_check_feature("nullptr" HAS_CXX11_NULLPTR)
cxx11_check_feature("regex" HAS_CXX11_LIB_REGEX)
cxx11_check_feature("rvalue-references" HAS_CXX11_RVALUE_REFERENCES)
cxx11_check_feature("sizeof_member" HAS_CXX11_SIZEOF_MEMBER)
cxx11_check_feature("static_assert" HAS_CXX11_STATIC_ASSERT)
cxx11_check_feature("variadic_templates" HAS_CXX11_VARIADIC_TEMPLATES)

View File

@@ -0,0 +1,8 @@
int main(void)
{
if (!__func__)
return 1;
if (!(*__func__))
return 1;
return 0;
}

View File

@@ -0,0 +1,12 @@
int main()
{
auto i = 5;
auto f = 3.14159f;
auto d = 3.14159;
bool ret = (
(sizeof(f) < sizeof(d)) &&
(sizeof(i) == sizeof(int))
);
return ret ? 0 : 1;
}

View File

@@ -0,0 +1,7 @@
int main(void)
{
// must fail because there is no initializer
auto i;
return 0;
}

View File

@@ -0,0 +1,8 @@
auto foo(int i) -> int {
return i - 1;
}
int main()
{
return foo(1);
}

View File

@@ -0,0 +1,21 @@
class base {
public:
virtual int foo(int a)
{ return 4 + a; }
int bar(int a) final
{ return a - 2; }
};
class sub final : public base {
public:
virtual int foo(int a) override
{ return 8 + 2 * a; };
};
int main(void)
{
base b;
sub s;
return (b.foo(2) * 2 == s.foo(2)) ? 0 : 1;
}

View File

@@ -0,0 +1,25 @@
class base {
public:
virtual int foo(int a)
{ return 4 + a; }
virtual int bar(int a) final
{ return a - 2; }
};
class sub final : public base {
public:
virtual int foo(int a) override
{ return 8 + 2 * a; };
virtual int bar(int a)
{ return a; }
};
class impossible : public sub { };
int main(void)
{
base b;
sub s;
return 1;
}

View File

@@ -0,0 +1,19 @@
constexpr int square(int x)
{
return x*x;
}
constexpr int the_answer()
{
return 42;
}
int main()
{
int test_arr[square(3)];
bool ret = (
(square(the_answer()) == 1764) &&
(sizeof(test_arr)/sizeof(test_arr[0]) == 9)
);
return ret ? 0 : 1;
}

View File

@@ -0,0 +1,11 @@
#include <cstdint>
int main()
{
bool test =
(sizeof(int8_t) == 1) &&
(sizeof(int16_t) == 2) &&
(sizeof(int32_t) == 4) &&
(sizeof(int64_t) == 8);
return test ? 0 : 1;
}

View File

@@ -0,0 +1,10 @@
bool check_size(int i)
{
return sizeof(int) == sizeof(decltype(i));
}
int main()
{
bool ret = check_size(42);
return ret ? 0 : 1;
}

View File

@@ -0,0 +1,27 @@
#include <vector>
class seq {
public:
seq(std::initializer_list<int> list);
int length() const;
private:
std::vector<int> m_v;
};
seq::seq(std::initializer_list<int> list)
: m_v(list)
{
}
int seq::length() const
{
return m_v.size();
}
int main(void)
{
seq a = {18, 20, 2, 0, 4, 7};
return (a.length() == 6) ? 0 : 1;
}

View File

@@ -0,0 +1,5 @@
int main()
{
int ret = 0;
return ([&ret]() -> int { return ret; })();
}

View File

@@ -0,0 +1,7 @@
int main(void)
{
long long l;
unsigned long long ul;
return ((sizeof(l) >= 8) && (sizeof(ul) >= 8)) ? 0 : 1;
}

View File

@@ -0,0 +1,6 @@
int main(void)
{
void *v = nullptr;
return v ? 1 : 0;
}

View File

@@ -0,0 +1,6 @@
int main(void)
{
int i = nullptr;
return 1;
}

View File

@@ -0,0 +1,26 @@
#include <algorithm>
#include <regex>
int parse_line(std::string const& line)
{
std::string tmp;
if(std::regex_search(line, std::regex("(\\s)+(-)?(\\d)+//(-)?(\\d)+(\\s)+"))) {
tmp = std::regex_replace(line, std::regex("(-)?(\\d)+//(-)?(\\d)+"), std::string("V"));
} else if(std::regex_search(line, std::regex("(\\s)+(-)?(\\d)+/(-)?(\\d)+(\\s)+"))) {
tmp = std::regex_replace(line, std::regex("(-)?(\\d)+/(-)?(\\d)+"), std::string("V"));
} else if(std::regex_search(line, std::regex("(\\s)+(-)?(\\d)+/(-)?(\\d)+/(-)?(\\d)+(\\s)+"))) {
tmp = std::regex_replace(line, std::regex("(-)?(\\d)+/(-)?(\\d)+/(-)?(\\d)+"), std::string("V"));
} else {
tmp = std::regex_replace(line, std::regex("(-)?(\\d)+"), std::string("V"));
}
return static_cast<int>(std::count(tmp.begin(), tmp.end(), 'V'));
}
int main()
{
bool test = (parse_line("f 7/7/7 -3/3/-3 2/-2/2") == 3) &&
(parse_line("f 7//7 3//-3 -2//2") == 3) &&
(parse_line("f 7/7 3/-3 -2/2") == 3) &&
(parse_line("f 7 3 -2") == 3);
return test ? 0 : 1;
}

View File

@@ -0,0 +1,57 @@
#include <cassert>
class rvmove {
public:
void *ptr;
char *array;
rvmove()
: ptr(0),
array(new char[10])
{
ptr = this;
}
rvmove(rvmove &&other)
: ptr(other.ptr),
array(other.array)
{
other.array = 0;
other.ptr = 0;
}
~rvmove()
{
assert(((ptr != 0) && (array != 0)) || ((ptr == 0) && (array == 0)));
delete[] array;
}
rvmove &operator=(rvmove &&other)
{
delete[] array;
ptr = other.ptr;
array = other.array;
other.array = 0;
other.ptr = 0;
return *this;
}
static rvmove create()
{
return rvmove();
}
private:
rvmove(const rvmove &);
rvmove &operator=(const rvmove &);
};
int main()
{
rvmove mine;
if (mine.ptr != &mine)
return 1;
mine = rvmove::create();
if (mine.ptr == &mine)
return 1;
return 0;
}

View File

@@ -0,0 +1,14 @@
struct foo {
char bar;
int baz;
};
int main(void)
{
bool ret = (
(sizeof(foo::bar) == 1) &&
(sizeof(foo::baz) >= sizeof(foo::bar)) &&
(sizeof(foo) >= sizeof(foo::bar) + sizeof(foo::baz))
);
return ret ? 0 : 1;
}

View File

@@ -0,0 +1,9 @@
struct foo {
int baz;
double bar;
};
int main(void)
{
return (sizeof(foo::bar) == 4) ? 0 : 1;
}

View File

@@ -0,0 +1,5 @@
int main(void)
{
static_assert(0 < 1, "your ordering of integers is screwed");
return 0;
}

View File

@@ -0,0 +1,5 @@
int main(void)
{
static_assert(1 < 0, "your ordering of integers is screwed");
return 0;
}

View File

@@ -0,0 +1,23 @@
int Accumulate()
{
return 0;
}
template<typename T, typename... Ts>
int Accumulate(T v, Ts... vs)
{
return v + Accumulate(vs...);
}
template<int... Is>
int CountElements()
{
return sizeof...(Is);
}
int main()
{
int acc = Accumulate(1, 2, 3, 4, -5);
int count = CountElements<1,2,3,4,5>();
return ((acc == 5) && (count == 5)) ? 0 : 1;
}

View File

@@ -0,0 +1,74 @@
# - Try to find libpcap include dirs and libraries
#
# Usage of this module as follows:
#
# find_package(PCAP)
#
# Variables used by this module, they can change the default behaviour and need
# to be set before calling find_package:
#
# PCAP_ROOT_DIR Set this variable to the root installation of
# libpcap if the module has problems finding the
# proper installation path.
#
# Variables defined by this module:
#
# PCAP_FOUND System has libpcap, include and library dirs found
# PCAP_INCLUDE_DIR The libpcap include directories.
# PCAP_LIBRARY The libpcap library (possibly includes a thread
# library e.g. required by pf_ring's libpcap)
# HAVE_PF_RING If a found version of libpcap supports PF_RING
find_path(PCAP_ROOT_DIR
NAMES include/pcap.h
)
find_path(PCAP_INCLUDE_DIR
NAMES pcap.h
HINTS ${PCAP_ROOT_DIR}/include
)
find_library(PCAP_LIBRARY
NAMES pcap wpcap
HINTS ${PCAP_ROOT_DIR}/lib
)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(PCAP DEFAULT_MSG
PCAP_LIBRARY
PCAP_INCLUDE_DIR
)
include(CheckCXXSourceCompiles)
set(CMAKE_REQUIRED_LIBRARIES ${PCAP_LIBRARY})
check_cxx_source_compiles("int main() { return 0; }" PCAP_LINKS_SOLO)
set(CMAKE_REQUIRED_LIBRARIES)
# check if linking against libpcap also needs to link against a thread library
if (NOT PCAP_LINKS_SOLO)
find_package(Threads)
if (THREADS_FOUND)
set(CMAKE_REQUIRED_LIBRARIES ${PCAP_LIBRARY} ${CMAKE_THREAD_LIBS_INIT})
check_cxx_source_compiles("int main() { return 0; }" PCAP_NEEDS_THREADS)
set(CMAKE_REQUIRED_LIBRARIES)
endif (THREADS_FOUND)
if (THREADS_FOUND AND PCAP_NEEDS_THREADS)
set(_tmp ${PCAP_LIBRARY} ${CMAKE_THREAD_LIBS_INIT})
list(REMOVE_DUPLICATES _tmp)
set(PCAP_LIBRARY ${_tmp}
CACHE STRING "Libraries needed to link against libpcap" FORCE)
else (THREADS_FOUND AND PCAP_NEEDS_THREADS)
message(FATAL_ERROR "Couldn't determine how to link against libpcap")
endif (THREADS_FOUND AND PCAP_NEEDS_THREADS)
endif (NOT PCAP_LINKS_SOLO)
include(CheckFunctionExists)
set(CMAKE_REQUIRED_LIBRARIES ${PCAP_LIBRARY})
check_function_exists(pcap_get_pfring_id HAVE_PF_RING)
set(CMAKE_REQUIRED_LIBRARIES)
mark_as_advanced(
PCAP_ROOT_DIR
PCAP_INCLUDE_DIR
PCAP_LIBRARY
)

1
compile Symbolic link
View File

@@ -0,0 +1 @@
/usr/share/automake-1.14/compile

337
configure vendored
View File

@@ -1,6 +1,6 @@
#! /bin/sh #! /bin/sh
# Guess values for system-dependent variables and create Makefiles. # Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.69 for libtins 2.0. # Generated by GNU Autoconf 2.69 for libtins 3.0.
# #
# Report bugs to <matias.fontanini@gmail.com>. # Report bugs to <matias.fontanini@gmail.com>.
# #
@@ -590,8 +590,8 @@ MAKEFLAGS=
# Identity of this package. # Identity of this package.
PACKAGE_NAME='libtins' PACKAGE_NAME='libtins'
PACKAGE_TARNAME='libtins' PACKAGE_TARNAME='libtins'
PACKAGE_VERSION='2.0' PACKAGE_VERSION='3.0'
PACKAGE_STRING='libtins 2.0' PACKAGE_STRING='libtins 3.0'
PACKAGE_BUGREPORT='matias.fontanini@gmail.com' PACKAGE_BUGREPORT='matias.fontanini@gmail.com'
PACKAGE_URL='http://libtins.sourceforge.net' PACKAGE_URL='http://libtins.sourceforge.net'
@@ -687,6 +687,10 @@ LDFLAGS
CFLAGS CFLAGS
CC CC
LIBTOOL LIBTOOL
AM_BACKSLASH
AM_DEFAULT_VERBOSITY
AM_DEFAULT_V
AM_V
am__untar am__untar
am__tar am__tar
AMTAR AMTAR
@@ -763,6 +767,7 @@ SHELL'
ac_subst_files='' ac_subst_files=''
ac_user_opts=' ac_user_opts='
enable_option_checking enable_option_checking
enable_silent_rules
enable_static enable_static
enable_shared enable_shared
with_pic with_pic
@@ -1331,7 +1336,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing. # Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh. # This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF cat <<_ACEOF
\`configure' configures libtins 2.0 to adapt to many kinds of systems. \`configure' configures libtins 3.0 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]... Usage: $0 [OPTION]... [VAR=VALUE]...
@@ -1402,7 +1407,7 @@ fi
if test -n "$ac_init_help"; then if test -n "$ac_init_help"; then
case $ac_init_help in case $ac_init_help in
short | recursive ) echo "Configuration of libtins 2.0:";; short | recursive ) echo "Configuration of libtins 3.0:";;
esac esac
cat <<\_ACEOF cat <<\_ACEOF
@@ -1410,15 +1415,20 @@ Optional Features:
--disable-option-checking ignore unrecognized --enable/--with options --disable-option-checking ignore unrecognized --enable/--with options
--disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no)
--enable-FEATURE[=ARG] include FEATURE [ARG=yes] --enable-FEATURE[=ARG] include FEATURE [ARG=yes]
--enable-silent-rules less verbose build output (undo: "make V=1")
--disable-silent-rules verbose build output (undo: "make V=0")
--enable-static[=PKGS] build static libraries [default=no] --enable-static[=PKGS] build static libraries [default=no]
--enable-shared[=PKGS] build shared libraries [default=yes] --enable-shared[=PKGS] build shared libraries [default=yes]
--enable-fast-install[=PKGS] --enable-fast-install[=PKGS]
optimize for fast installation [default=yes] optimize for fast installation [default=yes]
--disable-dependency-tracking speeds up one-time build --enable-dependency-tracking
--enable-dependency-tracking do not reject slow dependency extractors do not reject slow dependency extractors
--disable-dependency-tracking
speeds up one-time build
--disable-libtool-lock avoid locking (might break parallel builds) --disable-libtool-lock avoid locking (might break parallel builds)
--disable-maintainer-mode disable make rules and dependencies not useful --enable-maintainer-mode
(and sometimes confusing) to the casual installer enable make rules and dependencies not useful (and
sometimes confusing) to the casual installer
--enable-c++11 enable C++11 features --enable-c++11 enable C++11 features
--disable-dot11 disable IEEE 802.11 support --disable-dot11 disable IEEE 802.11 support
--disable-wpa2 disable WPA2 decryption features --disable-wpa2 disable WPA2 decryption features
@@ -1516,7 +1526,7 @@ fi
test -n "$ac_init_help" && exit $ac_status test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then if $ac_init_version; then
cat <<\_ACEOF cat <<\_ACEOF
libtins configure 2.0 libtins configure 3.0
generated by GNU Autoconf 2.69 generated by GNU Autoconf 2.69
Copyright (C) 2012 Free Software Foundation, Inc. Copyright (C) 2012 Free Software Foundation, Inc.
@@ -2006,7 +2016,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake. running configure, to aid debugging if configure makes a mistake.
It was created by libtins $as_me 2.0, which was It was created by libtins $as_me 3.0, which was
generated by GNU Autoconf 2.69. Invocation command line was generated by GNU Autoconf 2.69. Invocation command line was
$ $0 $@ $ $0 $@
@@ -2496,7 +2506,7 @@ test -n "$target_alias" &&
ac_config_headers="$ac_config_headers include/config.h" ac_config_headers="$ac_config_headers include/config.h"
am__api_version='1.11' am__api_version='1.14'
# Find a good install program. We prefer a C program (faster), # Find a good install program. We prefer a C program (faster),
# so one script is as good as another. But avoid the broken or # so one script is as good as another. But avoid the broken or
@@ -2593,9 +2603,6 @@ test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether build environment is sane" >&5 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether build environment is sane" >&5
$as_echo_n "checking whether build environment is sane... " >&6; } $as_echo_n "checking whether build environment is sane... " >&6; }
# Just in case
sleep 1
echo timestamp > conftest.file
# Reject unsafe characters in $srcdir or the absolute working directory # Reject unsafe characters in $srcdir or the absolute working directory
# name. Accept space and tab only in the latter. # name. Accept space and tab only in the latter.
am_lf=' am_lf='
@@ -2606,32 +2613,40 @@ case `pwd` in
esac esac
case $srcdir in case $srcdir in
*[\\\"\#\$\&\'\`$am_lf\ \ ]*) *[\\\"\#\$\&\'\`$am_lf\ \ ]*)
as_fn_error $? "unsafe srcdir value: \`$srcdir'" "$LINENO" 5;; as_fn_error $? "unsafe srcdir value: '$srcdir'" "$LINENO" 5;;
esac esac
# Do `set' in a subshell so we don't clobber the current shell's # Do 'set' in a subshell so we don't clobber the current shell's
# arguments. Must try -L first in case configure is actually a # arguments. Must try -L first in case configure is actually a
# symlink; some systems play weird games with the mod time of symlinks # symlink; some systems play weird games with the mod time of symlinks
# (eg FreeBSD returns the mod time of the symlink's containing # (eg FreeBSD returns the mod time of the symlink's containing
# directory). # directory).
if ( if (
set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null` am_has_slept=no
if test "$*" = "X"; then for am_try in 1 2; do
# -L didn't work. echo "timestamp, slept: $am_has_slept" > conftest.file
set X `ls -t "$srcdir/configure" conftest.file` set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null`
fi if test "$*" = "X"; then
rm -f conftest.file # -L didn't work.
if test "$*" != "X $srcdir/configure conftest.file" \ set X `ls -t "$srcdir/configure" conftest.file`
&& test "$*" != "X conftest.file $srcdir/configure"; then fi
if test "$*" != "X $srcdir/configure conftest.file" \
# If neither matched, then we have a broken ls. This can happen && test "$*" != "X conftest.file $srcdir/configure"; then
# if, for instance, CONFIG_SHELL is bash and it inherits a
# broken ls alias from the environment. This has actually
# happened. Such a system could not be considered "sane".
as_fn_error $? "ls -t appears to fail. Make sure there is not a broken
alias in your environment" "$LINENO" 5
fi
# If neither matched, then we have a broken ls. This can happen
# if, for instance, CONFIG_SHELL is bash and it inherits a
# broken ls alias from the environment. This has actually
# happened. Such a system could not be considered "sane".
as_fn_error $? "ls -t appears to fail. Make sure there is not a broken
alias in your environment" "$LINENO" 5
fi
if test "$2" = conftest.file || test $am_try -eq 2; then
break
fi
# Just in case.
sleep 1
am_has_slept=yes
done
test "$2" = conftest.file test "$2" = conftest.file
) )
then then
@@ -2643,6 +2658,16 @@ Check your system clock" "$LINENO" 5
fi fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; } $as_echo "yes" >&6; }
# If we didn't sleep, we still need to ensure time stamps of config.status and
# generated files are strictly newer.
am_sleep_pid=
if grep 'slept: no' conftest.file >/dev/null 2>&1; then
( sleep 1 ) &
am_sleep_pid=$!
fi
rm -f conftest.file
test "$program_prefix" != NONE && test "$program_prefix" != NONE &&
program_transform_name="s&^&$program_prefix&;$program_transform_name" program_transform_name="s&^&$program_prefix&;$program_transform_name"
# Use a double $ so make ignores it. # Use a double $ so make ignores it.
@@ -2665,12 +2690,12 @@ if test x"${MISSING+set}" != xset; then
esac esac
fi fi
# Use eval to expand $SHELL # Use eval to expand $SHELL
if eval "$MISSING --run true"; then if eval "$MISSING --is-lightweight"; then
am_missing_run="$MISSING --run " am_missing_run="$MISSING "
else else
am_missing_run= am_missing_run=
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: \`missing' script is too old or missing" >&5 { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: 'missing' script is too old or missing" >&5
$as_echo "$as_me: WARNING: \`missing' script is too old or missing" >&2;} $as_echo "$as_me: WARNING: 'missing' script is too old or missing" >&2;}
fi fi
if test x"${install_sh}" != xset; then if test x"${install_sh}" != xset; then
@@ -2682,10 +2707,10 @@ if test x"${install_sh}" != xset; then
esac esac
fi fi
# Installed binaries are usually stripped using `strip' when the user # Installed binaries are usually stripped using 'strip' when the user
# run `make install-strip'. However `strip' might not be the right # run "make install-strip". However 'strip' might not be the right
# tool to use in cross-compilation environments, therefore Automake # tool to use in cross-compilation environments, therefore Automake
# will honor the `STRIP' environment variable to overrule this program. # will honor the 'STRIP' environment variable to overrule this program.
if test "$cross_compiling" != no; then if test "$cross_compiling" != no; then
if test -n "$ac_tool_prefix"; then if test -n "$ac_tool_prefix"; then
# Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args. # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args.
@@ -2824,12 +2849,6 @@ fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $MKDIR_P" >&5 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MKDIR_P" >&5
$as_echo "$MKDIR_P" >&6; } $as_echo "$MKDIR_P" >&6; }
mkdir_p="$MKDIR_P"
case $mkdir_p in
[\\/$]* | ?:[\\/]*) ;;
*/*) mkdir_p="\$(top_builddir)/$mkdir_p" ;;
esac
for ac_prog in gawk mawk nawk awk for ac_prog in gawk mawk nawk awk
do do
# Extract the first word of "$ac_prog", so it can be a program name with args. # Extract the first word of "$ac_prog", so it can be a program name with args.
@@ -2912,6 +2931,45 @@ else
fi fi
rmdir .tst 2>/dev/null rmdir .tst 2>/dev/null
# Check whether --enable-silent-rules was given.
if test "${enable_silent_rules+set}" = set; then :
enableval=$enable_silent_rules;
fi
case $enable_silent_rules in # (((
yes) AM_DEFAULT_VERBOSITY=0;;
no) AM_DEFAULT_VERBOSITY=1;;
*) AM_DEFAULT_VERBOSITY=1;;
esac
am_make=${MAKE-make}
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $am_make supports nested variables" >&5
$as_echo_n "checking whether $am_make supports nested variables... " >&6; }
if ${am_cv_make_support_nested_variables+:} false; then :
$as_echo_n "(cached) " >&6
else
if $as_echo 'TRUE=$(BAR$(V))
BAR0=false
BAR1=true
V=1
am__doit:
@$(TRUE)
.PHONY: am__doit' | $am_make -f - >/dev/null 2>&1; then
am_cv_make_support_nested_variables=yes
else
am_cv_make_support_nested_variables=no
fi
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_make_support_nested_variables" >&5
$as_echo "$am_cv_make_support_nested_variables" >&6; }
if test $am_cv_make_support_nested_variables = yes; then
AM_V='$(V)'
AM_DEFAULT_V='$(AM_DEFAULT_VERBOSITY)'
else
AM_V=$AM_DEFAULT_VERBOSITY
AM_DEFAULT_V=$AM_DEFAULT_VERBOSITY
fi
AM_BACKSLASH='\'
if test "`cd $srcdir && pwd`" != "`pwd`"; then if test "`cd $srcdir && pwd`" != "`pwd`"; then
# Use -I$(srcdir) only when $(srcdir) != ., so that make's output # Use -I$(srcdir) only when $(srcdir) != ., so that make's output
# is not polluted with repeated "-I." # is not polluted with repeated "-I."
@@ -2934,7 +2992,7 @@ fi
# Define the identity of the package. # Define the identity of the package.
PACKAGE='libtins' PACKAGE='libtins'
VERSION='2.0' VERSION='3.0'
cat >>confdefs.h <<_ACEOF cat >>confdefs.h <<_ACEOF
@@ -2962,18 +3020,70 @@ AUTOHEADER=${AUTOHEADER-"${am_missing_run}autoheader"}
MAKEINFO=${MAKEINFO-"${am_missing_run}makeinfo"} MAKEINFO=${MAKEINFO-"${am_missing_run}makeinfo"}
# For better backward compatibility. To be removed once Automake 1.9.x
# dies out for good. For more background, see:
# <http://lists.gnu.org/archive/html/automake/2012-07/msg00001.html>
# <http://lists.gnu.org/archive/html/automake/2012-07/msg00014.html>
mkdir_p='$(MKDIR_P)'
# We need awk for the "check" target. The system "awk" is bad on # We need awk for the "check" target. The system "awk" is bad on
# some platforms. # some platforms.
# Always define AMTAR for backward compatibility. Yes, it's still used # Always define AMTAR for backward compatibility. Yes, it's still used
# in the wild :-( We should find a proper way to deprecate it ... # in the wild :-( We should find a proper way to deprecate it ...
AMTAR='$${TAR-tar}' AMTAR='$${TAR-tar}'
# We'll loop over all known methods to create a tar archive until one works.
_am_tools='gnutar pax cpio none'
am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -' am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -'
# POSIX will say in a future version that running "rm -f" with no argument
# is OK; and we want to be able to make that assumption in our Makefile
# recipes. So use an aggressive probe to check that the usage we want is
# actually supported "in the wild" to an acceptable degree.
# See automake bug#10828.
# To make any issue more visible, cause the running configure to be aborted
# by default if the 'rm' program in use doesn't match our expectations; the
# user can still override this though.
if rm -f && rm -fr && rm -rf; then : OK; else
cat >&2 <<'END'
Oops!
Your 'rm' program seems unable to run without file operands specified
on the command line, even when the '-f' option is present. This is contrary
to the behaviour of most rm programs out there, and not conforming with
the upcoming POSIX standard: <http://austingroupbugs.net/view.php?id=542>
Please tell bug-automake@gnu.org about your system, including the value
of your $PATH and any error possibly output before this message. This
can help us improve future automake versions.
END
if test x"$ACCEPT_INFERIOR_RM_PROGRAM" = x"yes"; then
echo 'Configuration will proceed anyway, since you have set the' >&2
echo 'ACCEPT_INFERIOR_RM_PROGRAM variable to "yes"' >&2
echo >&2
else
cat >&2 <<'END'
Aborting the configuration process, to ensure you take notice of the issue.
You can download and install GNU coreutils to get an 'rm' implementation
that behaves properly: <http://www.gnu.org/software/coreutils/>.
If you want to complete the configuration process using your problematic
'rm' anyway, export the environment variable ACCEPT_INFERIOR_RM_PROGRAM
to "yes", and re-run configure.
END
as_fn_error $? "Your 'rm' program is bad, sorry." "$LINENO" 5
fi
fi
case `pwd` in case `pwd` in
*\ * | *\ *) *\ * | *\ *)
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Libtool does not cope well with whitespace in \`pwd\`" >&5 { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Libtool does not cope well with whitespace in \`pwd\`" >&5
@@ -3087,7 +3197,7 @@ am__quote=
_am_result=none _am_result=none
# First try GNU make style include. # First try GNU make style include.
echo "include confinc" > confmf echo "include confinc" > confmf
# Ignore all kinds of additional output from `make'. # Ignore all kinds of additional output from 'make'.
case `$am_make -s -f confmf 2> /dev/null` in #( case `$am_make -s -f confmf 2> /dev/null` in #(
*the\ am__doit\ target*) *the\ am__doit\ target*)
am__include=include am__include=include
@@ -3920,6 +4030,65 @@ ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_c_compiler_gnu ac_compiler_gnu=$ac_cv_c_compiler_gnu
ac_ext=c
ac_cpp='$CPP $CPPFLAGS'
ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_c_compiler_gnu
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC understands -c and -o together" >&5
$as_echo_n "checking whether $CC understands -c and -o together... " >&6; }
if ${am_cv_prog_cc_c_o+:} false; then :
$as_echo_n "(cached) " >&6
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
int
main ()
{
;
return 0;
}
_ACEOF
# Make sure it works both with $CC and with simple cc.
# Following AC_PROG_CC_C_O, we do the test twice because some
# compilers refuse to overwrite an existing .o file with -o,
# though they will create one.
am_cv_prog_cc_c_o=yes
for am_i in 1 2; do
if { echo "$as_me:$LINENO: $CC -c conftest.$ac_ext -o conftest2.$ac_objext" >&5
($CC -c conftest.$ac_ext -o conftest2.$ac_objext) >&5 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } \
&& test -f conftest2.$ac_objext; then
: OK
else
am_cv_prog_cc_c_o=no
break
fi
done
rm -f core conftest*
unset am_i
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_prog_cc_c_o" >&5
$as_echo "$am_cv_prog_cc_c_o" >&6; }
if test "$am_cv_prog_cc_c_o" != yes; then
# Losing compiler, so override with the script.
# FIXME: It is wrong to rewrite CC.
# But if we don't then we get into trouble of one sort or another.
# A longer-term fix would be to have automake use am__CC in this case,
# and then we could set am__CC="\$(top_srcdir)/compile \$(CC)"
CC="$am_aux_dir/compile $CC"
fi
ac_ext=c
ac_cpp='$CPP $CPPFLAGS'
ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_c_compiler_gnu
depcc="$CC" am_compiler_list= depcc="$CC" am_compiler_list=
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc" >&5 { $as_echo "$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc" >&5
@@ -3931,8 +4100,8 @@ else
# We make a subdir and do the tests there. Otherwise we can end up # We make a subdir and do the tests there. Otherwise we can end up
# making bogus files that we don't know about and never remove. For # making bogus files that we don't know about and never remove. For
# instance it was reported that on HP-UX the gcc test will end up # instance it was reported that on HP-UX the gcc test will end up
# making a dummy file named `D' -- because `-MD' means `put the output # making a dummy file named 'D' -- because '-MD' means "put the output
# in D'. # in D".
rm -rf conftest.dir rm -rf conftest.dir
mkdir conftest.dir mkdir conftest.dir
# Copy depcomp to subdir because otherwise we won't find it if we're # Copy depcomp to subdir because otherwise we won't find it if we're
@@ -3967,16 +4136,16 @@ else
: > sub/conftest.c : > sub/conftest.c
for i in 1 2 3 4 5 6; do for i in 1 2 3 4 5 6; do
echo '#include "conftst'$i'.h"' >> sub/conftest.c echo '#include "conftst'$i'.h"' >> sub/conftest.c
# Using `: > sub/conftst$i.h' creates only sub/conftst1.h with # Using ": > sub/conftst$i.h" creates only sub/conftst1.h with
# Solaris 8's {/usr,}/bin/sh. # Solaris 10 /bin/sh.
touch sub/conftst$i.h echo '/* dummy */' > sub/conftst$i.h
done done
echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf
# We check with `-c' and `-o' for the sake of the "dashmstdout" # We check with '-c' and '-o' for the sake of the "dashmstdout"
# mode. It turns out that the SunPro C++ compiler does not properly # mode. It turns out that the SunPro C++ compiler does not properly
# handle `-M -o', and we need to detect this. Also, some Intel # handle '-M -o', and we need to detect this. Also, some Intel
# versions had trouble with output in subdirs # versions had trouble with output in subdirs.
am__obj=sub/conftest.${OBJEXT-o} am__obj=sub/conftest.${OBJEXT-o}
am__minus_obj="-o $am__obj" am__minus_obj="-o $am__obj"
case $depmode in case $depmode in
@@ -3985,8 +4154,8 @@ else
test "$am__universal" = false || continue test "$am__universal" = false || continue
;; ;;
nosideeffect) nosideeffect)
# after this tag, mechanisms are not by side-effect, so they'll # After this tag, mechanisms are not by side-effect, so they'll
# only be used when explicitly requested # only be used when explicitly requested.
if test "x$enable_dependency_tracking" = xyes; then if test "x$enable_dependency_tracking" = xyes; then
continue continue
else else
@@ -3994,7 +4163,7 @@ else
fi fi
;; ;;
msvc7 | msvc7msys | msvisualcpp | msvcmsys) msvc7 | msvc7msys | msvisualcpp | msvcmsys)
# This compiler won't grok `-c -o', but also, the minuso test has # This compiler won't grok '-c -o', but also, the minuso test has
# not run yet. These depmodes are late enough in the game, and # not run yet. These depmodes are late enough in the game, and
# so weak that their functioning should not be impacted. # so weak that their functioning should not be impacted.
am__obj=conftest.${OBJEXT-o} am__obj=conftest.${OBJEXT-o}
@@ -11488,7 +11657,7 @@ $as_echo_n "checking whether to enable maintainer-specific portions of Makefiles
if test "${enable_maintainer_mode+set}" = set; then : if test "${enable_maintainer_mode+set}" = set; then :
enableval=$enable_maintainer_mode; USE_MAINTAINER_MODE=$enableval enableval=$enable_maintainer_mode; USE_MAINTAINER_MODE=$enableval
else else
USE_MAINTAINER_MODE=yes USE_MAINTAINER_MODE=no
fi fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $USE_MAINTAINER_MODE" >&5 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $USE_MAINTAINER_MODE" >&5
@@ -11773,8 +11942,8 @@ else
# We make a subdir and do the tests there. Otherwise we can end up # We make a subdir and do the tests there. Otherwise we can end up
# making bogus files that we don't know about and never remove. For # making bogus files that we don't know about and never remove. For
# instance it was reported that on HP-UX the gcc test will end up # instance it was reported that on HP-UX the gcc test will end up
# making a dummy file named `D' -- because `-MD' means `put the output # making a dummy file named 'D' -- because '-MD' means "put the output
# in D'. # in D".
rm -rf conftest.dir rm -rf conftest.dir
mkdir conftest.dir mkdir conftest.dir
# Copy depcomp to subdir because otherwise we won't find it if we're # Copy depcomp to subdir because otherwise we won't find it if we're
@@ -11809,16 +11978,16 @@ else
: > sub/conftest.c : > sub/conftest.c
for i in 1 2 3 4 5 6; do for i in 1 2 3 4 5 6; do
echo '#include "conftst'$i'.h"' >> sub/conftest.c echo '#include "conftst'$i'.h"' >> sub/conftest.c
# Using `: > sub/conftst$i.h' creates only sub/conftst1.h with # Using ": > sub/conftst$i.h" creates only sub/conftst1.h with
# Solaris 8's {/usr,}/bin/sh. # Solaris 10 /bin/sh.
touch sub/conftst$i.h echo '/* dummy */' > sub/conftst$i.h
done done
echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf
# We check with `-c' and `-o' for the sake of the "dashmstdout" # We check with '-c' and '-o' for the sake of the "dashmstdout"
# mode. It turns out that the SunPro C++ compiler does not properly # mode. It turns out that the SunPro C++ compiler does not properly
# handle `-M -o', and we need to detect this. Also, some Intel # handle '-M -o', and we need to detect this. Also, some Intel
# versions had trouble with output in subdirs # versions had trouble with output in subdirs.
am__obj=sub/conftest.${OBJEXT-o} am__obj=sub/conftest.${OBJEXT-o}
am__minus_obj="-o $am__obj" am__minus_obj="-o $am__obj"
case $depmode in case $depmode in
@@ -11827,8 +11996,8 @@ else
test "$am__universal" = false || continue test "$am__universal" = false || continue
;; ;;
nosideeffect) nosideeffect)
# after this tag, mechanisms are not by side-effect, so they'll # After this tag, mechanisms are not by side-effect, so they'll
# only be used when explicitly requested # only be used when explicitly requested.
if test "x$enable_dependency_tracking" = xyes; then if test "x$enable_dependency_tracking" = xyes; then
continue continue
else else
@@ -11836,7 +12005,7 @@ else
fi fi
;; ;;
msvc7 | msvc7msys | msvisualcpp | msvcmsys) msvc7 | msvc7msys | msvisualcpp | msvcmsys)
# This compiler won't grok `-c -o', but also, the minuso test has # This compiler won't grok '-c -o', but also, the minuso test has
# not run yet. These depmodes are late enough in the game, and # not run yet. These depmodes are late enough in the game, and
# so weak that their functioning should not be impacted. # so weak that their functioning should not be impacted.
am__obj=conftest.${OBJEXT-o} am__obj=conftest.${OBJEXT-o}
@@ -15432,7 +15601,7 @@ fi
LIBTINS_VERSION=2:0:0 LIBTINS_VERSION=3:0:0
ac_config_files="$ac_config_files Makefile libtins.pc" ac_config_files="$ac_config_files Makefile libtins.pc"
@@ -15545,6 +15714,14 @@ LIBOBJS=$ac_libobjs
LTLIBOBJS=$ac_ltlibobjs LTLIBOBJS=$ac_ltlibobjs
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking that generated files are newer than configure" >&5
$as_echo_n "checking that generated files are newer than configure... " >&6; }
if test -n "$am_sleep_pid"; then
# Hide warnings about reused PIDs.
wait $am_sleep_pid 2>/dev/null
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: done" >&5
$as_echo "done" >&6; }
if test -n "$EXEEXT"; then if test -n "$EXEEXT"; then
am__EXEEXT_TRUE= am__EXEEXT_TRUE=
am__EXEEXT_FALSE='#' am__EXEEXT_FALSE='#'
@@ -15966,7 +16143,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# report actual input values of CONFIG_FILES etc. instead of their # report actual input values of CONFIG_FILES etc. instead of their
# values after options handling. # values after options handling.
ac_log=" ac_log="
This file was extended by libtins $as_me 2.0, which was This file was extended by libtins $as_me 3.0, which was
generated by GNU Autoconf 2.69. Invocation command line was generated by GNU Autoconf 2.69. Invocation command line was
CONFIG_FILES = $CONFIG_FILES CONFIG_FILES = $CONFIG_FILES
@@ -16033,7 +16210,7 @@ _ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
ac_cs_version="\\ ac_cs_version="\\
libtins config.status 2.0 libtins config.status 3.0
configured by $0, generated by GNU Autoconf 2.69, configured by $0, generated by GNU Autoconf 2.69,
with options \\"\$ac_cs_config\\" with options \\"\$ac_cs_config\\"
@@ -17138,7 +17315,7 @@ $as_echo "$as_me: executing $ac_file commands" >&6;}
case $ac_file$ac_mode in case $ac_file$ac_mode in
"depfiles":C) test x"$AMDEP_TRUE" != x"" || { "depfiles":C) test x"$AMDEP_TRUE" != x"" || {
# Autoconf 2.62 quotes --file arguments for eval, but not when files # Older Autoconf quotes --file arguments for eval, but not when files
# are listed without --file. Let's play safe and only enable the eval # are listed without --file. Let's play safe and only enable the eval
# if we detect the quoting. # if we detect the quoting.
case $CONFIG_FILES in case $CONFIG_FILES in
@@ -17151,7 +17328,7 @@ $as_echo "$as_me: executing $ac_file commands" >&6;}
# Strip MF so we end up with the name of the file. # Strip MF so we end up with the name of the file.
mf=`echo "$mf" | sed -e 's/:.*$//'` mf=`echo "$mf" | sed -e 's/:.*$//'`
# Check whether this is an Automake generated Makefile or not. # Check whether this is an Automake generated Makefile or not.
# We used to match only the files named `Makefile.in', but # We used to match only the files named 'Makefile.in', but
# some people rename them; so instead we look at the file content. # some people rename them; so instead we look at the file content.
# Grep'ing the first line is not enough: some people post-process # Grep'ing the first line is not enough: some people post-process
# each Makefile.in and add a new line on top of each file to say so. # each Makefile.in and add a new line on top of each file to say so.
@@ -17185,21 +17362,19 @@ $as_echo X"$mf" |
continue continue
fi fi
# Extract the definition of DEPDIR, am__include, and am__quote # Extract the definition of DEPDIR, am__include, and am__quote
# from the Makefile without running `make'. # from the Makefile without running 'make'.
DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"` DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"`
test -z "$DEPDIR" && continue test -z "$DEPDIR" && continue
am__include=`sed -n 's/^am__include = //p' < "$mf"` am__include=`sed -n 's/^am__include = //p' < "$mf"`
test -z "am__include" && continue test -z "$am__include" && continue
am__quote=`sed -n 's/^am__quote = //p' < "$mf"` am__quote=`sed -n 's/^am__quote = //p' < "$mf"`
# When using ansi2knr, U may be empty or an underscore; expand it
U=`sed -n 's/^U = //p' < "$mf"`
# Find all dependency output files, they are included files with # Find all dependency output files, they are included files with
# $(DEPDIR) in their names. We invoke sed twice because it is the # $(DEPDIR) in their names. We invoke sed twice because it is the
# simplest approach to changing $(DEPDIR) to its actual value in the # simplest approach to changing $(DEPDIR) to its actual value in the
# expansion. # expansion.
for file in `sed -n " for file in `sed -n "
s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \ s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \
sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g'`; do
# Make sure the directory exists. # Make sure the directory exists.
test -f "$dirpart/$file" && continue test -f "$dirpart/$file" && continue
fdir=`$as_dirname -- "$file" || fdir=`$as_dirname -- "$file" ||

View File

@@ -1,10 +1,10 @@
AC_INIT([libtins], [2.0], [matias.fontanini@gmail.com], [libtins], [http://libtins.sourceforge.net]) AC_INIT([libtins], [3.0], [matias.fontanini@gmail.com], [libtins], [http://libtins.sourceforge.net])
AC_CANONICAL_SYSTEM AC_CANONICAL_SYSTEM
AC_CONFIG_HEADER(include/config.h) AC_CONFIG_HEADER(include/config.h)
AM_INIT_AUTOMAKE([-Wall -Werror -Wno-extra-portability foreign]) AM_INIT_AUTOMAKE([-Wall -Werror -Wno-extra-portability foreign])
LT_INIT([disable-static]) LT_INIT([disable-static])
AC_CONFIG_MACRO_DIR([m4]) AC_CONFIG_MACRO_DIR([m4])
AM_MAINTAINER_MODE([enable]) AM_MAINTAINER_MODE([disable])
AC_PROG_CXX AC_PROG_CXX
AC_LANG(C++) AC_LANG(C++)
@@ -80,6 +80,6 @@ AC_ARG_ENABLE(
AC_SUBST(CXXFLAGS) AC_SUBST(CXXFLAGS)
AC_SUBST(LIBS) AC_SUBST(LIBS)
AC_SUBST(LIBTINS_INCLUDE_DIR) AC_SUBST(LIBTINS_INCLUDE_DIR)
AC_SUBST([LIBTINS_VERSION], [2:0:0]) AC_SUBST([LIBTINS_VERSION], [3:0:0])
AC_CONFIG_FILES([Makefile libtins.pc]) AC_CONFIG_FILES([Makefile libtins.pc])
AC_OUTPUT AC_OUTPUT

56
examples/CMakeLists.txt Normal file
View File

@@ -0,0 +1,56 @@
FIND_PACKAGE(libtins QUIET)
FIND_PACKAGE(Threads QUIET)
IF(libtins_FOUND)
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/examples)
INCLUDE_DIRECTORIES(${LIBTINS_INCLUDE_DIRS})
LINK_LIBRARIES(${LIBTINS_LIBRARIES})
IF(HAVE_CXX11)
SET(LIBTINS_CXX11_EXAMPLES
arpmonitor
dns_queries
dns_spoof
dns_stats
wps_detect
)
ELSE(HAVE_CXX11)
MESSAGE(WARNING "Disabling some examples since C++11 support is disabled.")
ENDIF(HAVE_CXX11)
ADD_CUSTOM_TARGET(
examples DEPENDS
arpspoofing
${LIBTINS_CXX11_EXAMPLES}
beacon_display
portscan
traceroute
)
ADD_EXECUTABLE(arpspoofing EXCLUDE_FROM_ALL arpspoofing.cpp)
IF(HAVE_CXX11)
ADD_EXECUTABLE(arpmonitor EXCLUDE_FROM_ALL arpmonitor.cpp)
ADD_EXECUTABLE(dns_queries EXCLUDE_FROM_ALL dns_queries.cpp)
ADD_EXECUTABLE(dns_spoof EXCLUDE_FROM_ALL dns_spoof.cpp)
ADD_EXECUTABLE(dns_stats EXCLUDE_FROM_ALL dns_stats.cpp)
ADD_EXECUTABLE(wps_detect EXCLUDE_FROM_ALL wps_detect.cpp)
ENDIF(HAVE_CXX11)
ADD_EXECUTABLE(beacon_display EXCLUDE_FROM_ALL beacon_display.cpp)
if(THREADS_FOUND)
ADD_EXECUTABLE(portscan EXCLUDE_FROM_ALL portscan.cpp)
ADD_EXECUTABLE(traceroute EXCLUDE_FROM_ALL traceroute.cpp)
TARGET_LINK_LIBRARIES(portscan ${CMAKE_THREAD_LIBS_INIT})
TARGET_LINK_LIBRARIES(traceroute ${CMAKE_THREAD_LIBS_INIT})
ELSE(THREADS_FOUND)
MESSAGE(WARNING "Disabling portscan and traceroute examples since pthreads library was not found.")
ENDIF(THREADS_FOUND)
ELSE(libtins_FOUND)
MESSAGE(
WARNING
"Disabling examples since libtins is not installed. "
"Run cmake again once it is installed in order to compile them."
)
ENDIF(libtins_FOUND)

View File

@@ -1,7 +1,7 @@
CXX=@CXX@ CXX=@CXX@
CXXFLAGS=-Wall @CXXFLAGS@ CXXFLAGS=-Wall @CXXFLAGS@
LDFLAGS=-ltins LDFLAGS=-ltins
EXECUTABLES=arpspoofing arpmonitor portscan traceroute beacon_display dns_queries dns_spoof wps_detect EXECUTABLES=arpspoofing arpmonitor portscan traceroute beacon_display dns_queries dns_spoof dns_stats wps_detect
all: $(EXECUTABLES) all: $(EXECUTABLES)
@@ -21,6 +21,9 @@ dns_queries:
dns_spoof: dns_spoof:
$(CXX) dns_spoof.cpp -o dns_spoof -std=c++0x $(CXXFLAGS) $(LDFLAGS) $(CXX) dns_spoof.cpp -o dns_spoof -std=c++0x $(CXXFLAGS) $(LDFLAGS)
dns_stats:
$(CXX) dns_stats.cpp -o dns_stats -std=c++0x $(CXXFLAGS) $(LDFLAGS) -lpthread
beacon_display: beacon_display:
$(CXX) beacon_display.cpp -o beacon_display $(CXXFLAGS) $(LDFLAGS) $(CXX) beacon_display.cpp -o beacon_display $(CXXFLAGS) $(LDFLAGS)

View File

@@ -1,3 +1,32 @@
/*
* Copyright (c) 2014, Matias Fontanini
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#include <tins/tins.h> #include <tins/tins.h>
#include <map> #include <map>
#include <iostream> #include <iostream>
@@ -58,6 +87,10 @@ int main(int argc, char *argv[])
return 1; return 1;
} }
arp_monitor monitor; arp_monitor monitor;
Sniffer sniffer(argv[1], 2000, true, "arp"); // Sniff on the provided interface in promiscuous mode
Sniffer sniffer(argv[1], Sniffer::PROMISC);
// Only capture arp packets
sniffer.set_filter("arp");
monitor.run(sniffer); monitor.run(sniffer);
} }

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2012, Matias Fontanini * Copyright (c) 2014, Matias Fontanini
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2012, Matias Fontanini * Copyright (c) 2014, Matias Fontanini
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@@ -47,7 +47,7 @@ private:
}; };
void BeaconSniffer::run(const std::string &iface) { void BeaconSniffer::run(const std::string &iface) {
Sniffer sniffer(iface, 1500, true, "type mgt subtype beacon"); Sniffer sniffer(iface, Sniffer::PROMISC, "type mgt subtype beacon", true);
sniffer.sniff_loop(make_sniffer_handler(this, &BeaconSniffer::callback)); sniffer.sniff_loop(make_sniffer_handler(this, &BeaconSniffer::callback));
} }

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2012, Matias Fontanini * Copyright (c) 2014, Matias Fontanini
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@@ -54,8 +54,12 @@ int main(int argc, char *argv[])
std::cout << "Usage: " << *argv << " <interface>" << std::endl; std::cout << "Usage: " << *argv << " <interface>" << std::endl;
return 1; return 1;
} }
// Sniff on the provided interface, maximum packet size 2000 // Sniff on the provided interface in promiscuos mode
// in promiscuos mode and only udp packets sent to port 53 Sniffer sniffer(argv[1], Sniffer::PROMISC);
Sniffer sniffer(argv[1], 2000, true, "udp and dst port 53");
// Only capture udp packets sent to port 53
sniffer.set_filter("udp and dst port 53");
// Start the capture
sniffer.sniff_loop(callback); sniffer.sniff_loop(callback);
} }

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2012, Matias Fontanini * Copyright (c) 2014, Matias Fontanini
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@@ -54,10 +54,14 @@ bool callback(const PDU &pdu)
if(query.type() == DNS::A) { if(query.type() == DNS::A) {
// Here's one! Let's add an answer. // Here's one! Let's add an answer.
dns.add_answer( dns.add_answer(
query.dname(), DNS::Resource(
// 777 is just a random TTL query.dname(),
DNS::make_info(DNS::A, query.query_class(), 777), "127.0.0.1",
IPv4Address("127.0.0.1") DNS::A,
query.query_class(),
// 777 is just a random TTL
777
)
); );
} }
} }
@@ -85,10 +89,15 @@ int main(int argc, char *argv[])
std::cout << "Usage: " << *argv << " <interface>" << std::endl; std::cout << "Usage: " << *argv << " <interface>" << std::endl;
return 1; return 1;
} }
// Sniff on the provided interface, maximum packet size 2000 // Sniff on the provided interface in promiscuos mode
// in promiscuos mode and only udp packets sent to port 53 Sniffer sniffer(argv[1], Sniffer::PROMISC);
Sniffer sniffer(argv[1], 2000, true, "udp and dst port 53");
// Only capture udp packets sent to port 53
sniffer.set_filter("udp and dst port 53");
// All packets will be sent through the provided interface // All packets will be sent through the provided interface
sender.default_interface(argv[1]); sender.default_interface(argv[1]);
// Start the capture
sniffer.sniff_loop(callback); sniffer.sniff_loop(callback);
} }

189
examples/dns_stats.cpp Normal file
View File

@@ -0,0 +1,189 @@
/*
* Copyright (c) 2014, Matias Fontanini
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#include <iostream>
#include <mutex>
#include <chrono>
#include <map>
#include <thread>
#include <algorithm>
#include <tins/tins.h>
using namespace Tins;
// Holds the DNS response time statistics. The response time is
// represented using the Duration template parameter.
template<typename Duration>
class statistics {
public:
using duration_type = Duration;
using locker_type = std::lock_guard<std::mutex>;
struct information {
duration_type average, worst;
size_t count;
};
statistics()
: m_duration(), m_worst(duration_type::min()), m_count()
{
}
void add_response_time(const duration_type& duration)
{
locker_type _(m_lock);
m_duration += duration;
m_count++;
m_worst = std::max(m_worst, duration);
}
information get_information() const
{
locker_type _(m_lock);
if(m_count == 0)
return { };
else
return { m_duration / m_count, m_worst, m_count };
};
private:
duration_type m_duration, m_worst;
size_t m_count;
mutable std::mutex m_lock;
};
// Sniffs and tracks DNS queries. When a matching DNS response is found,
// the response time is added to a statistics object.
//
// This class performs *no cleanup* on data associated with queries that
// weren't answered.
class dns_monitor {
public:
// The response times are measured in milliseconds
using duration_type = std::chrono::milliseconds;
// The statistics type used.
using statistics_type = statistics<duration_type>;
void run(BaseSniffer& sniffer);
const statistics_type& stats() const {
return m_stats;
}
private:
using packet_info = std::tuple<IPv4Address, IPv4Address, uint16_t>;
using clock_type = std::chrono::steady_clock;
using time_point_type = std::chrono::time_point<clock_type>;
bool callback(const PDU& pdu);
static packet_info make_packet_info(const PDU& pdu, const DNS& dns);
statistics_type m_stats;
std::map<packet_info, time_point_type> m_packet_info;
};
void dns_monitor::run(BaseSniffer& sniffer)
{
sniffer.sniff_loop(
std::bind(
&dns_monitor::callback,
this,
std::placeholders::_1
)
);
}
bool dns_monitor::callback(const PDU& pdu)
{
auto now = clock_type::now();
auto dns = pdu.rfind_pdu<RawPDU>().to<DNS>();
auto info = make_packet_info(pdu, dns);
// If it's a query, add the sniff time to our map.
if(dns.type() == DNS::QUERY) {
m_packet_info.insert(
std::make_pair(info, now)
);
}
else {
// It's a response, we need to find the query in our map.
auto iter = m_packet_info.find(info);
if(iter != m_packet_info.end()) {
// We found the query, let's add the response time to the
// statistics object.
m_stats.add_response_time(
std::chrono::duration_cast<duration_type>(now - iter->second)
);
// Forget about the query.
m_packet_info.erase(iter);
}
}
return true;
}
// It is required that we can identify packets sent and received that
// hold the same DNS id as belonging to the same query.
//
// This function retrieves a tuple (addr, addr, id) that will achieve it.
auto dns_monitor::make_packet_info(const PDU& pdu, const DNS& dns) -> packet_info
{
const auto& ip = pdu.rfind_pdu<IP>();
return std::make_tuple(
// smallest address first
std::min(ip.src_addr(), ip.dst_addr()),
// largest address second
std::max(ip.src_addr(), ip.dst_addr()),
dns.id()
);
}
int main(int argc, char *argv[]) {
if(argc != 2) {
std::cout << "Usage: " << *argv << " <interface>\n";
return 1;
}
try {
Sniffer sniffer(argv[1], Sniffer::PROMISC);
sniffer.set_filter("udp and port 53");
dns_monitor monitor;
std::thread thread(
[&]() {
monitor.run(sniffer);
}
);
while(true) {
auto info = monitor.stats().get_information();
std::cout << "\rAverage " << info.average.count()
<< "ms. Worst: " << info.worst.count() << "ms. Count: "
<< info.count;
std::cout.flush();
std::this_thread::sleep_for(std::chrono::seconds(1));
}
}
catch(std::exception& ex) {
std::cout << "[-] Error: " << ex.what() << std::endl;
}
}

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2012, Matias Fontanini * Copyright (c) 2014, Matias Fontanini
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2012, Matias Fontanini * Copyright (c) 2014, Matias Fontanini
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2012, Matias Fontanini * Copyright (c) 2014, Matias Fontanini
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

7
include/CMakeLists.txt Normal file
View File

@@ -0,0 +1,7 @@
FILE(GLOB INCLUDE_FILES "*.h")
INSTALL(
FILES ${INCLUDE_FILES}
DESTINATION include/tins
COMPONENT Headers
)
ADD_SUBDIRECTORY(dot11)

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2012, Matias Fontanini * Copyright (c) 2014, Matias Fontanini
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2012, Matias Fontanini * Copyright (c) 2014, Matias Fontanini
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2012, Matias Fontanini * Copyright (c) 2014, Matias Fontanini
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View File

@@ -1,89 +1,9 @@
/* include/config.h.in. Generated from configure.ac by autoheader. */
/* define if the compiler supports basic C++11 syntax */ /* Define if the compiler supports basic C++11 syntax */
#undef HAVE_CXX11 #cmakedefine HAVE_CXX11
/* Define to 1 if you have the <dlfcn.h> header file. */
#undef HAVE_DLFCN_H
/* Have IEEE 802.11 support */ /* Have IEEE 802.11 support */
#undef HAVE_DOT11 #cmakedefine HAVE_DOT11
/* Define to 1 if you have the <inttypes.h> header file. */
#undef HAVE_INTTYPES_H
/* Define to 1 if you have the `crypto' library (-lcrypto). */
#undef HAVE_LIBCRYPTO
/* Define to 1 if you have the `pcap' library (-lpcap). */
#undef HAVE_LIBPCAP
/* Define to 1 if you have the <memory.h> header file. */
#undef HAVE_MEMORY_H
/* Define to 1 if you have the <openssl/aes.h> header file. */
#undef HAVE_OPENSSL_AES_H
/* Define to 1 if you have the <openssl/evp.h> header file. */
#undef HAVE_OPENSSL_EVP_H
/* Define to 1 if you have the <openssl/hmac.h> header file. */
#undef HAVE_OPENSSL_HMAC_H
/* Define to 1 if you have the <pcap.h> header file. */
#undef HAVE_PCAP_H
/* Define to 1 if you have the <stdint.h> header file. */
#undef HAVE_STDINT_H
/* Define to 1 if you have the <stdlib.h> header file. */
#undef HAVE_STDLIB_H
/* Define to 1 if you have the <strings.h> header file. */
#undef HAVE_STRINGS_H
/* Define to 1 if you have the <string.h> header file. */
#undef HAVE_STRING_H
/* Define to 1 if you have the <sys/stat.h> header file. */
#undef HAVE_SYS_STAT_H
/* Define to 1 if you have the <sys/types.h> header file. */
#undef HAVE_SYS_TYPES_H
/* Define to 1 if you have the <unistd.h> header file. */
#undef HAVE_UNISTD_H
/* Have WPA2 decryption library */ /* Have WPA2 decryption library */
#undef HAVE_WPA2_DECRYPTION #cmakedefine HAVE_WPA2_DECRYPTION
/* Define to the sub-directory in which libtool stores uninstalled libraries.
*/
#undef LT_OBJDIR
/* Name of package */
#undef PACKAGE
/* Define to the address where bug reports for this package should be sent. */
#undef PACKAGE_BUGREPORT
/* Define to the full name of this package. */
#undef PACKAGE_NAME
/* Define to the full name and version of this package. */
#undef PACKAGE_STRING
/* Define to the one symbol short name of this package. */
#undef PACKAGE_TARNAME
/* Define to the home page for this package. */
#undef PACKAGE_URL
/* Define to the version of this package. */
#undef PACKAGE_VERSION
/* Define to 1 if you have the ANSI C header files. */
#undef STDC_HEADERS
/* Version number of package */
#undef VERSION

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2012, Matias Fontanini * Copyright (c) 2014, Matias Fontanini
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2012, Matias Fontanini * Copyright (c) 2014, Matias Fontanini
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2012, Matias Fontanini * Copyright (c) 2014, Matias Fontanini
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@@ -38,7 +38,9 @@
#define TINS_CXXSTD_GCC_FIX 0 #define TINS_CXXSTD_GCC_FIX 0
#endif // __GXX_EXPERIMENTAL_CXX0X__ #endif // __GXX_EXPERIMENTAL_CXX0X__
#define TINS_IS_CXX11 (__cplusplus > 199711L || TINS_CXXSTD_GCC_FIX == 1) #ifndef TINS_IS_CXX11
#define TINS_IS_CXX11 (__cplusplus > 199711L || TINS_CXXSTD_GCC_FIX == 1 || _MSC_VER >= 1800)
#endif // TINS_IS_CXX11
namespace Tins{ namespace Tins{
namespace Internals { namespace Internals {

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2012, Matias Fontanini * Copyright (c) 2014, Matias Fontanini
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@@ -309,6 +309,15 @@ namespace Tins {
* \param name The domain name. * \param name The domain name.
*/ */
void domain_name(const std::string &name); void domain_name(const std::string &name);
/**
* \brief Adds a hostname option.
*
* The new option is appended at the end of the list.
*
* \param name The hostname.
*/
void hostname(const std::string &name);
// Option getters // Option getters
@@ -423,6 +432,16 @@ namespace Tins {
* \return std::string Containing the domain name. * \return std::string Containing the domain name.
*/ */
std::string domain_name() const; std::string domain_name() const;
/**
* \brief Searchs for a hostname option.
*
* If the option is not found, an option_not_found exception
* is thrown.
*
* \return std::string Containing the hostname.
*/
std::string hostname() const;
/** /**
* \brief Getter for the options list. * \brief Getter for the options list.

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2012, Matias Fontanini * Copyright (c) 2014, Matias Fontanini
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@@ -30,6 +30,7 @@
#ifndef TINS_DHCPV6_H #ifndef TINS_DHCPV6_H
#define TINS_DHCPV6_H #define TINS_DHCPV6_H
#include <cstring>
#include <list> #include <list>
#include "pdu.h" #include "pdu.h"
#include "endianness.h" #include "endianness.h"
@@ -886,9 +887,11 @@ void class_option_data2option(InputIterator start, InputIterator end,
std::vector<uint8_t>& buffer, size_t start_index = 0) std::vector<uint8_t>& buffer, size_t start_index = 0)
{ {
size_t index = start_index; size_t index = start_index;
uint16_t uint16_t_buffer;
while(start != end) { while(start != end) {
buffer.resize(buffer.size() + sizeof(uint16_t) + start->size()); buffer.resize(buffer.size() + sizeof(uint16_t) + start->size());
*(uint16_t*)&buffer[index] = Endian::host_to_be<uint16_t>(start->size()); uint16_t_buffer = Endian::host_to_be<uint16_t>(start->size());
std::memcpy(&buffer[index], &uint16_t_buffer, sizeof(uint16_t));
index += sizeof(uint16_t); index += sizeof(uint16_t);
std::copy(start->begin(), start->end(), buffer.begin() + index); std::copy(start->begin(), start->end(), buffer.begin() + index);
index += start->size(); index += start->size();
@@ -904,9 +907,9 @@ OutputType option2class_option_data(const uint8_t *ptr, uint32_t total_sz)
OutputType output; OutputType output;
size_t index = 0; size_t index = 0;
while(index + 2 < total_sz) { while(index + 2 < total_sz) {
uint16_t size = Endian::be_to_host( uint16_t size;
*(const uint16_t*)(ptr + index) std::memcpy(&size, ptr + index, sizeof(uint16_t));
); size = Endian::be_to_host(size);
index += sizeof(uint16_t); index += sizeof(uint16_t);
if(index + size > total_sz) if(index + size > total_sz)
throw option_not_found(); throw option_not_found();

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2012, Matias Fontanini * Copyright (c) 2014, Matias Fontanini
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2012, Matias Fontanini * Copyright (c) 2014, Matias Fontanini
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View File

@@ -0,0 +1,6 @@
FILE(GLOB INCLUDE_FILES "*.h")
INSTALL(
FILES ${INCLUDE_FILES}
DESTINATION include/tins/dot11
COMPONENT Headers
)

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2012, Matias Fontanini * Copyright (c) 2014, Matias Fontanini
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@@ -619,4 +619,4 @@ private:
}; };
} // namespace Tins } // namespace Tins
#endif // TINS_DOT11_DOT11_ASSOC_H #endif // TINS_DOT11_DOT11_ASSOC_H

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2012, Matias Fontanini * Copyright (c) 2014, Matias Fontanini
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@@ -257,4 +257,4 @@ private:
} // namespace Tins } // namespace Tins
#endif // TINS_DOT11_DOT11_AUTH_H #endif // TINS_DOT11_DOT11_AUTH_H

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2012, Matias Fontanini * Copyright (c) 2014, Matias Fontanini
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2012, Matias Fontanini * Copyright (c) 2014, Matias Fontanini
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@@ -163,4 +163,4 @@ namespace Tins {
}; };
} // namespace Tins } // namespace Tins
#endif // TINS_DOT11_DOT11_BEACON_H #endif // TINS_DOT11_DOT11_BEACON_H

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2012, Matias Fontanini * Copyright (c) 2014, Matias Fontanini
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2012, Matias Fontanini * Copyright (c) 2014, Matias Fontanini
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2012, Matias Fontanini * Copyright (c) 2014, Matias Fontanini
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2012, Matias Fontanini * Copyright (c) 2014, Matias Fontanini
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@@ -230,4 +230,4 @@ private:
uint32_t write_fixed_parameters(uint8_t *buffer, uint32_t total_sz); uint32_t write_fixed_parameters(uint8_t *buffer, uint32_t total_sz);
}; };
} // namespace Tins } // namespace Tins
#endif // TINS_DOT11_DOT11_PROBE_H #endif // TINS_DOT11_DOT11_PROBE_H

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2012, Matias Fontanini * Copyright (c) 2014, Matias Fontanini
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2012, Matias Fontanini * Copyright (c) 2014, Matias Fontanini
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2012, Matias Fontanini * Copyright (c) 2014, Matias Fontanini
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2012, Matias Fontanini * Copyright (c) 2014, Matias Fontanini
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2012, Matias Fontanini * Copyright (c) 2014, Matias Fontanini
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2012, Matias Fontanini * Copyright (c) 2014, Matias Fontanini
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@@ -30,6 +30,7 @@
#ifndef TINS_EXCEPTIONS_H #ifndef TINS_EXCEPTIONS_H
#define TINS_EXCEPTIONS_H #define TINS_EXCEPTIONS_H
#include <string>
#include <stdexcept> #include <stdexcept>
namespace Tins { namespace Tins {

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2012, Matias Fontanini * Copyright (c) 2014, Matias Fontanini
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@@ -166,4 +166,4 @@ namespace Tins {
}; };
} }
#endif // TINS_HANDSHAKE_CAPTURER_H #endif // TINS_HANDSHAKE_CAPTURER_H

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2012, Matias Fontanini * Copyright (c) 2014, Matias Fontanini
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2012, Matias Fontanini * Copyright (c) 2014, Matias Fontanini
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@@ -30,6 +30,18 @@
#ifndef TINS_ICMP_H #ifndef TINS_ICMP_H
#define TINS_ICMP_H #define TINS_ICMP_H
// Windows likes to define macros with not-so-common-names, which break
// this code
#ifdef WIN32
#ifdef TIMESTAMP_REQUEST
#undef TIMESTAMP_REQUEST
#endif // TIMESTAMP_REQUEST
#ifdef TIMESTAMP_REPLY
#undef TIMESTAMP_REPLY
#endif // TIMESTAMP_REPLY
#endif // WIN32
#include "macros.h" #include "macros.h"
#include "pdu.h" #include "pdu.h"
#include "endianness.h" #include "endianness.h"
@@ -258,7 +270,7 @@ namespace Tins {
* *
* \return Returns the checksum as an unit16_t. * \return Returns the checksum as an unit16_t.
*/ */
uint16_t check() const { return Endian::be_to_host(_icmp.check); } uint16_t checksum() const { return Endian::be_to_host(_icmp.check); }
/** /**
* \brief Getter for the echo id. * \brief Getter for the echo id.
@@ -377,7 +389,7 @@ namespace Tins {
} un; } un;
} TINS_END_PACK; } TINS_END_PACK;
void check(uint16_t new_check); void checksum(uint16_t new_check);
/** \brief Serialices this ICMP PDU. /** \brief Serialices this ICMP PDU.
* \param buffer The buffer in which the PDU will be serialized. * \param buffer The buffer in which the PDU will be serialized.

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2012, Matias Fontanini * Copyright (c) 2014, Matias Fontanini
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2012, Matias Fontanini * Copyright (c) 2014, Matias Fontanini
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2012, Matias Fontanini * Copyright (c) 2014, Matias Fontanini
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2012, Matias Fontanini * Copyright (c) 2014, Matias Fontanini
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@@ -426,6 +426,20 @@ namespace Tins {
internal_add_option(opt); internal_add_option(opt);
_ip_options.push_back(std::move(opt)); _ip_options.push_back(std::move(opt));
} }
/**
* \brief Adds an IP option.
*
* The option is constructed from the provided parameters.
*
* \param args The arguments to be used in the option's
* constructor.
*/
template<typename... Args>
void add_option(Args&&... args) {
_ip_options.emplace_back(std::forward<Args>(args)...);
internal_add_option(_ip_options.back());
}
#endif #endif
/** /**

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2012, Matias Fontanini * Copyright (c) 2014, Matias Fontanini
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2012, Matias Fontanini * Copyright (c) 2014, Matias Fontanini
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@@ -213,4 +213,4 @@ IPv4ReassemblerProxy<Functor> make_ipv4_reassembler_proxy(Functor func) {
} }
#endif // TINS_IP_REASSEMBLER_H #endif // TINS_IP_REASSEMBLER_H

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2012, Matias Fontanini * Copyright (c) 2014, Matias Fontanini
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2012, Matias Fontanini * Copyright (c) 2014, Matias Fontanini
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2012, Matias Fontanini * Copyright (c) 2014, Matias Fontanini
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2012, Matias Fontanini * Copyright (c) 2014, Matias Fontanini
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2012, Matias Fontanini * Copyright (c) 2014, Matias Fontanini
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2012, Matias Fontanini * Copyright (c) 2014, Matias Fontanini
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@@ -40,11 +40,13 @@
#define TINS_END_PACK __pragma( pack(pop) ) #define TINS_END_PACK __pragma( pack(pop) )
#define TINS_PACKED(DECLARATION) __pragma( pack(push, 1) ) DECLARATION __pragma( pack(pop) ) #define TINS_PACKED(DECLARATION) __pragma( pack(push, 1) ) DECLARATION __pragma( pack(pop) )
#define TINS_DEPRECATED(func) __declspec(deprecated) func #define TINS_DEPRECATED(func) __declspec(deprecated) func
#define NOEXCEPT
#else #else
#define TINS_BEGIN_PACK #define TINS_BEGIN_PACK
#define TINS_END_PACK __attribute__((packed)) #define TINS_END_PACK __attribute__((packed))
#define TINS_PACKED(DECLARATION) DECLARATION __attribute__((packed)) #define TINS_PACKED(DECLARATION) DECLARATION __attribute__((packed))
#define TINS_DEPRECATED(func) func __attribute__ ((deprecated)) #define TINS_DEPRECATED(func) func __attribute__ ((deprecated))
#define NOEXCEPT noexcept
#endif #endif
#endif #endif

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2012, Matias Fontanini * Copyright (c) 2014, Matias Fontanini
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2012, Matias Fontanini * Copyright (c) 2014, Matias Fontanini
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@@ -128,6 +128,13 @@ private:
*/ */
class Packet { class Packet {
public: public:
/**
* Tag used to specify that a Packet should own a PDU pointer.
*/
struct own_pdu {
};
/** /**
* \brief Default constructs a Packet. * \brief Default constructs a Packet.
* *
@@ -143,6 +150,17 @@ public:
*/ */
Packet(const PDU *apdu, const Timestamp &tstamp) Packet(const PDU *apdu, const Timestamp &tstamp)
: pdu_(apdu->clone()), ts(tstamp) { } : pdu_(apdu->clone()), ts(tstamp) { }
/**
* \brief Constructs a Packet from a PDU* and a Timestamp.
*
* The PDU* will be owned by the Packet. This means you
* <b>do not</b> have to explicitly delete the pointer, that
* will be done automatically by the Packet when it goes out
* of scope.
*/
Packet(PDU *apdu, const Timestamp &tstamp, own_pdu)
: pdu_(apdu), ts(tstamp) { }
/** /**
* \brief Constructs a Packet from a const PDU&. * \brief Constructs a Packet from a const PDU&.
@@ -197,14 +215,14 @@ public:
/** /**
* Move constructor. * Move constructor.
*/ */
Packet(Packet &&rhs) noexcept : pdu_(rhs.pdu()), ts(rhs.timestamp()) { Packet(Packet &&rhs) NOEXCEPT : pdu_(rhs.pdu()), ts(rhs.timestamp()) {
rhs.pdu_ = nullptr; rhs.pdu_ = nullptr;
} }
/** /**
* Move assignment operator. * Move assignment operator.
*/ */
Packet& operator=(Packet &&rhs) noexcept { Packet& operator=(Packet &&rhs) NOEXCEPT {
if(this != &rhs) { if(this != &rhs) {
std::swap(pdu_, rhs.pdu_); std::swap(pdu_, rhs.pdu_);
ts = rhs.timestamp(); ts = rhs.timestamp();
@@ -268,7 +286,7 @@ public:
* \return true if pdu() == nullptr, false otherwise. * \return true if pdu() == nullptr, false otherwise.
*/ */
operator bool() const { operator bool() const {
return bool(pdu_); return pdu_ ? true : false;
} }
/** /**

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2012, Matias Fontanini * Copyright (c) 2014, Matias Fontanini
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@@ -87,7 +87,7 @@ namespace Tins {
* \brief Move constructor. * \brief Move constructor.
* \param rhs The sender to be moved. * \param rhs The sender to be moved.
*/ */
PacketSender(PacketSender &&rhs) noexcept { PacketSender(PacketSender &&rhs) NOEXCEPT {
*this = std::move(rhs); *this = std::move(rhs);
} }
@@ -95,7 +95,7 @@ namespace Tins {
* \brief Move assignment operator. * \brief Move assignment operator.
* \param rhs The sender to be moved. * \param rhs The sender to be moved.
*/ */
PacketSender& operator=(PacketSender &&rhs) noexcept { PacketSender& operator=(PacketSender &&rhs) NOEXCEPT {
_sockets = std::move(rhs._sockets); _sockets = std::move(rhs._sockets);
rhs._sockets = std::vector<int>(SOCKETS_END, INVALID_RAW_SOCKET); rhs._sockets = std::vector<int>(SOCKETS_END, INVALID_RAW_SOCKET);
#ifndef WIN32 #ifndef WIN32
@@ -325,6 +325,10 @@ namespace Tins {
SocketTypeMap _types; SocketTypeMap _types;
uint32_t _timeout, _timeout_usec; uint32_t _timeout, _timeout_usec;
NetworkInterface default_iface; NetworkInterface default_iface;
// In BSD we need to store the buffer size, retrieved using BIOCGBLEN
#if defined(BSD) || defined(__FreeBSD_kernel__)
int buffer_size;
#endif
}; };
} }

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2012, Matias Fontanini * Copyright (c) 2014, Matias Fontanini
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@@ -76,7 +76,7 @@ public:
* *
* \param rhs The PacketWriter to be moved. * \param rhs The PacketWriter to be moved.
*/ */
PacketWriter(PacketWriter &&rhs) noexcept { PacketWriter(PacketWriter &&rhs) NOEXCEPT {
*this = std::move(rhs); *this = std::move(rhs);
} }
@@ -88,7 +88,7 @@ public:
* *
* \param rhs The PacketWriter to be moved. * \param rhs The PacketWriter to be moved.
*/ */
PacketWriter& operator=(PacketWriter &&rhs) noexcept { PacketWriter& operator=(PacketWriter &&rhs) NOEXCEPT {
handle = 0; handle = 0;
dumper = 0; dumper = 0;
std::swap(handle, rhs.handle); std::swap(handle, rhs.handle);

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2012, Matias Fontanini * Copyright (c) 2014, Matias Fontanini
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@@ -149,7 +149,7 @@ namespace Tins {
* *
* \param rhs The PDU to be moved. * \param rhs The PDU to be moved.
*/ */
PDU(PDU &&rhs) noexcept PDU(PDU &&rhs) NOEXCEPT
: _inner_pdu(0) : _inner_pdu(0)
{ {
std::swap(_inner_pdu, rhs._inner_pdu); std::swap(_inner_pdu, rhs._inner_pdu);
@@ -160,7 +160,7 @@ namespace Tins {
* *
* \param rhs The PDU to be moved. * \param rhs The PDU to be moved.
*/ */
PDU& operator=(PDU &&rhs) noexcept { PDU& operator=(PDU &&rhs) NOEXCEPT {
std::swap(_inner_pdu, rhs._inner_pdu); std::swap(_inner_pdu, rhs._inner_pdu);
return *this; return *this;
} }

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2012, Matias Fontanini * Copyright (c) 2014, Matias Fontanini
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2012, Matias Fontanini * Copyright (c) 2014, Matias Fontanini
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2012, Matias Fontanini * Copyright (c) 2014, Matias Fontanini
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@@ -32,6 +32,7 @@
#include <vector> #include <vector>
#include <iterator> #include <iterator>
#include <cstring>
#include <algorithm> #include <algorithm>
#include <string> #include <string>
#include <stdint.h> #include <stdint.h>
@@ -266,8 +267,8 @@ namespace Internals {
if(opt.data_size() != sizeof(T) + sizeof(U)) if(opt.data_size() != sizeof(T) + sizeof(U))
throw malformed_option(); throw malformed_option();
std::pair<T, U> output; std::pair<T, U> output;
output.first = *(const T*)opt.data_ptr(); std::memcpy(&output.first, opt.data_ptr(), sizeof(T));
output.second = *(const U*)(opt.data_ptr() + sizeof(T)); std::memcpy(&output.second, opt.data_ptr() + sizeof(T), sizeof(U));
if(PDUType::endianness == PDUType::BE) { if(PDUType::endianness == PDUType::BE) {
output.first = Endian::be_to_host(output.first); output.first = Endian::be_to_host(output.first);
output.second = Endian::be_to_host(output.second); output.second = Endian::be_to_host(output.second);
@@ -298,9 +299,10 @@ namespace Internals {
*/ */
template<typename OptionType, class PDUType> template<typename OptionType, class PDUType>
class PDUOption { class PDUOption {
private:
static const int small_buffer_size = 8;
public: public:
typedef std::vector<uint8_t> container_type; typedef uint8_t data_type;
typedef typename container_type::value_type data_type;
typedef OptionType option_type; typedef OptionType option_type;
/** /**
@@ -310,8 +312,79 @@ public:
* \param data The option's data(if any). * \param data The option's data(if any).
*/ */
PDUOption(option_type opt = option_type(), size_t length = 0, const data_type *data = 0) PDUOption(option_type opt = option_type(), size_t length = 0, const data_type *data = 0)
: option_(opt), size_(length), value_(data, data + (data ? length : 0)) { : option_(opt), size_(length) {
set_payload_contents(data, data + (data ? length : 0));
}
/**
* \brief Copy constructor.
* \param rhs The PDUOption to be copied.
*/
PDUOption(const PDUOption& rhs) {
real_size_ = 0;
*this = rhs;
}
#if TINS_IS_CXX11
/**
* \brief Move constructor.
* \param rhs The PDUOption to be moved.
*/
PDUOption(PDUOption&& rhs) {
real_size_ = 0;
*this = std::move(rhs);
}
/**
* \brief Move assignment operator.
* \param rhs The PDUOption to be moved.
*/
PDUOption& operator=(PDUOption&& rhs) {
option_ = rhs.option_;
size_ = rhs.size_;
if(real_size_ > small_buffer_size) {
delete[] payload_.big_buffer_ptr;
}
real_size_ = rhs.real_size_;
if(real_size_ > small_buffer_size) {
payload_.big_buffer_ptr = nullptr;
std::swap(payload_.big_buffer_ptr, rhs.payload_.big_buffer_ptr);
rhs.real_size_ = 0;
}
else {
std::copy(
rhs.data_ptr(),
rhs.data_ptr() + rhs.data_size(),
payload_.small_buffer
);
}
return *this;
}
#endif // TINS_IS_CXX11
/**
* \brief Copy assignment operator.
* \param rhs The PDUOption to be copied.
*/
PDUOption& operator=(const PDUOption& rhs) {
option_ = rhs.option_;
size_ = rhs.size_;
if(real_size_ > small_buffer_size) {
delete[] payload_.big_buffer_ptr;
}
real_size_ = rhs.real_size_;
set_payload_contents(rhs.data_ptr(), rhs.data_ptr() + rhs.data_size());
return *this;
}
/**
* \brief Destructor.
*/
~PDUOption() {
if(real_size_ > small_buffer_size) {
delete[] payload_.big_buffer_ptr;
}
} }
/** /**
@@ -324,8 +397,8 @@ public:
*/ */
template<typename ForwardIterator> template<typename ForwardIterator>
PDUOption(option_type opt, ForwardIterator start, ForwardIterator end) PDUOption(option_type opt, ForwardIterator start, ForwardIterator end)
: option_(opt), size_(std::distance(start, end)), value_(start, end) { : option_(opt), size_(std::distance(start, end)) {
set_payload_contents(start, end);
} }
/** /**
@@ -345,8 +418,8 @@ public:
*/ */
template<typename ForwardIterator> template<typename ForwardIterator>
PDUOption(option_type opt, size_t length, ForwardIterator start, ForwardIterator end) PDUOption(option_type opt, size_t length, ForwardIterator start, ForwardIterator end)
: option_(opt), size_(length), value_(start, end) { : option_(opt), size_(length) {
set_payload_contents(start, end);
} }
/** /**
@@ -375,7 +448,9 @@ public:
* \return const data_type& containing this option's value. * \return const data_type& containing this option's value.
*/ */
const data_type *data_ptr() const { const data_type *data_ptr() const {
return &*value_.begin(); return real_size_ <= small_buffer_size ?
payload_.small_buffer :
payload_.big_buffer_ptr;
} }
/** /**
@@ -384,7 +459,7 @@ public:
* This is the actual size of the data. * This is the actual size of the data.
*/ */
size_t data_size() const { size_t data_size() const {
return value_.size(); return real_size_;
} }
/** /**
@@ -415,9 +490,32 @@ public:
return Internals::converter<T>::convert(*this); return Internals::converter<T>::convert(*this);
} }
private: private:
template<typename ForwardIterator>
void set_payload_contents(ForwardIterator start, ForwardIterator end) {
real_size_ = std::distance(start, end);
if(real_size_ <= small_buffer_size) {
std::copy(
start,
end,
payload_.small_buffer
);
}
else {
payload_.big_buffer_ptr = new data_type[real_size_];
std::copy(
start,
end,
payload_.big_buffer_ptr
);
}
}
option_type option_; option_type option_;
uint16_t size_; uint16_t size_, real_size_;
container_type value_; union {
data_type small_buffer[small_buffer_size];
data_type* big_buffer_ptr;
} payload_;
}; };
} // namespace Tins } // namespace Tins
#endif // TINS_PDU_OPTION_H #endif // TINS_PDU_OPTION_H

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2012, Matias Fontanini * Copyright (c) 2014, Matias Fontanini
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2012, Matias Fontanini * Copyright (c) 2014, Matias Fontanini
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2012, Matias Fontanini * Copyright (c) 2014, Matias Fontanini
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2012, Matias Fontanini * Copyright (c) 2014, Matias Fontanini
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2012, Matias Fontanini * Copyright (c) 2014, Matias Fontanini
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@@ -27,7 +27,9 @@
* *
*/ */
#ifndef TINS_RSN_INFORMATION #include "config.h"
#if !defined(TINS_RSN_INFORMATION) && defined(HAVE_DOT11)
#define TINS_RSN_INFORMATION #define TINS_RSN_INFORMATION
#include <stdint.h> #include <stdint.h>

Some files were not shown because too many files have changed in this diff Show More