From 7a2ae6b7d5a5221d23020744c5fa2b251ec1e099 Mon Sep 17 00:00:00 2001 From: Matias Fontanini Date: Mon, 28 Dec 2015 06:28:52 -0800 Subject: [PATCH] Export classes on Windows shared lib builds Fixes #120 --- CMakeLists.txt | 1 + include/tins/arp.h | 2 +- include/tins/bootp.h | 3 +-- include/tins/config.h.in | 3 +++ include/tins/crypto.h | 9 +++++---- include/tins/dhcp.h | 4 ++-- include/tins/dhcpv6.h | 3 ++- include/tins/dns.h | 2 +- include/tins/dot11/dot11_assoc.h | 11 ++++++----- include/tins/dot11/dot11_auth.h | 5 +++-- include/tins/dot11/dot11_base.h | 2 +- include/tins/dot11/dot11_beacon.h | 3 ++- include/tins/dot11/dot11_control.h | 19 ++++++++++--------- include/tins/dot11/dot11_data.h | 6 ++++-- include/tins/dot11/dot11_mgmt.h | 3 ++- include/tins/dot11/dot11_probe.h | 5 +++-- include/tins/dot1q.h | 3 ++- include/tins/dot3.h | 2 +- include/tins/eapol.h | 7 +++---- include/tins/ethernetII.h | 2 +- include/tins/handshake_capturer.h | 5 +++-- include/tins/icmp.h | 4 ++-- include/tins/icmp_extension.h | 5 +++-- include/tins/icmpv6.h | 2 +- include/tins/ip.h | 2 +- include/tins/ip_address.h | 3 ++- include/tins/ip_reassembler.h | 5 +++-- include/tins/ipsec.h | 5 +++-- include/tins/ipv6.h | 2 +- include/tins/ipv6_address.h | 3 ++- include/tins/llc.h | 3 ++- include/tins/loopback.h | 2 +- include/tins/macros.h | 19 ++++++++++++++++++- include/tins/network_interface.h | 3 ++- include/tins/offline_packet_filter.h | 3 ++- include/tins/packet_sender.h | 2 +- include/tins/packet_writer.h | 3 ++- include/tins/pdu.h | 3 ++- include/tins/pktap.h | 3 ++- include/tins/ppi.h | 3 ++- include/tins/pppoe.h | 3 ++- include/tins/radiotap.h | 2 +- include/tins/rawpdu.h | 3 ++- include/tins/rsn_information.h | 3 ++- include/tins/sll.h | 3 ++- include/tins/snap.h | 2 +- include/tins/sniffer.h | 9 +++++---- include/tins/stp.h | 3 ++- include/tins/tcp.h | 2 +- include/tins/tcp_stream.h | 5 +++-- 50 files changed, 130 insertions(+), 80 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ac8f57d..13d8194 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -34,6 +34,7 @@ IF(LIBTINS_BUILD_SHARED) ELSE(LIBTINS_BUILD_SHARED) MESSAGE(STATUS "Build will generate a static library.") SET(LIBTINS_TYPE STATIC) + SET(TINS_STATIC_BUILD ON) ENDIF(LIBTINS_BUILD_SHARED) # The version number. diff --git a/include/tins/arp.h b/include/tins/arp.h index faf4644..1f7cf4c 100644 --- a/include/tins/arp.h +++ b/include/tins/arp.h @@ -46,7 +46,7 @@ namespace Tins { * \brief Represents an ARP PDU. * */ - class ARP : public PDU { + class TINS_API ARP : public PDU { public: /** * The type of the hardware address. diff --git a/include/tins/bootp.h b/include/tins/bootp.h index 603ce5d..fa28546 100644 --- a/include/tins/bootp.h +++ b/include/tins/bootp.h @@ -39,14 +39,13 @@ #include "ip_address.h" #include "hw_address.h" - namespace Tins { /** * \class BootP * \brief Class representing a BootP packet. */ - class BootP : public PDU { + class TINS_API BootP : public PDU { public: /** * The type of the IP addresses. diff --git a/include/tins/config.h.in b/include/tins/config.h.in index 88bc5f2..6a2b0ee 100644 --- a/include/tins/config.h.in +++ b/include/tins/config.h.in @@ -13,4 +13,7 @@ /* Use pcap_sendpacket to send l2 packets */ #cmakedefine HAVE_PACKET_SENDER_PCAP_SENDPACKET +/* Indicate whether libtins was built statically */ +#cmakedefine TINS_STATIC_BUILD + #endif // TINS_CONFIG_H diff --git a/include/tins/crypto.h b/include/tins/crypto.h index 7014059..8c538dc 100644 --- a/include/tins/crypto.h +++ b/include/tins/crypto.h @@ -39,6 +39,7 @@ #include "utils.h" #include "snap.h" #include "rawpdu.h" +#include "macros.h" #include "handshake_capturer.h" namespace Tins { @@ -53,7 +54,7 @@ namespace Crypto { /** * \brief Class that represents the keys used to decrypt a session. */ - class SessionKeys { + class TINS_API SessionKeys { public: /** * The size of the Pairwise Master Key. @@ -136,7 +137,7 @@ namespace Crypto { * of some access point, and this will generate the Pairwise Master Key * from those parameters. */ - class SupplicantData { + class TINS_API SupplicantData { public: /** * The type used to store the PMK. @@ -185,7 +186,7 @@ namespace Crypto { /** * \brief Decrypts WEP-encrypted traffic. */ - class WEPDecrypter { + class TINS_API WEPDecrypter { public: typedef HWAddress<6> address_type; @@ -241,7 +242,7 @@ namespace Crypto { * This class takes valid PSK and SSID tuples, captures client handshakes, * and decrypts their traffic afterwards. */ - class WPA2Decrypter { + class TINS_API WPA2Decrypter { public: /* * \brief The type used to store Dot11 addresses. diff --git a/include/tins/dhcp.h b/include/tins/dhcp.h index 6fb7b50..4b4c636 100644 --- a/include/tins/dhcp.h +++ b/include/tins/dhcp.h @@ -30,11 +30,11 @@ #ifndef TINS_DHCP_H #define TINS_DHCP_H - #include #include #include #include "bootp.h" +#include "macros.h" #include "pdu_option.h" #include "cxxstd.h" @@ -64,7 +64,7 @@ namespace Tins { * * \endcode */ - class DHCP : public BootP { + class TINS_API DHCP : public BootP { public: /** * This PDU's flag. diff --git a/include/tins/dhcpv6.h b/include/tins/dhcpv6.h index d30dbdc..327b8ab 100644 --- a/include/tins/dhcpv6.h +++ b/include/tins/dhcpv6.h @@ -33,6 +33,7 @@ #include #include #include "pdu.h" +#include "macros.h" #include "endianness.h" #include "small_uint.h" #include "ipv6_address.h" @@ -47,7 +48,7 @@ class OutputMemoryStream; * \class DHCPv6 * \brief Represents a DHCPv6 PDU. */ -class DHCPv6 : public PDU { +class TINS_API DHCPv6 : public PDU { public: /** * Represents a DHCPv6 option. diff --git a/include/tins/dns.h b/include/tins/dns.h index 21c10ea..0db2074 100644 --- a/include/tins/dns.h +++ b/include/tins/dns.h @@ -69,7 +69,7 @@ namespace Tins { * } * \endcode */ - class DNS : public PDU { + class TINS_API DNS : public PDU { public: /** * \brief This PDU's flag. diff --git a/include/tins/dot11/dot11_assoc.h b/include/tins/dot11/dot11_assoc.h index edc30c3..017d905 100644 --- a/include/tins/dot11/dot11_assoc.h +++ b/include/tins/dot11/dot11_assoc.h @@ -33,13 +33,14 @@ #define TINS_DOT11_DOT11_ASSOC_H #include "../dot11/dot11_mgmt.h" +#include "../macros.h" namespace Tins { /** * \brief Class representing a Disassociation frame in the IEEE 802.11 Protocol. * */ -class Dot11Disassoc : public Dot11ManagementFrame { +class TINS_API Dot11Disassoc : public Dot11ManagementFrame { public: /** * \brief This PDU's flag. @@ -133,7 +134,7 @@ private: * \brief Class representing an Association Request frame in the IEEE 802.11 Protocol. * */ -class Dot11AssocRequest : public Dot11ManagementFrame { +class TINS_API Dot11AssocRequest : public Dot11ManagementFrame { public: /** * \brief This PDU's flag. @@ -244,7 +245,7 @@ private: * \brief Class representing an Association Response frame in the IEEE 802.11 Protocol. * */ -class Dot11AssocResponse : public Dot11ManagementFrame { +class TINS_API Dot11AssocResponse : public Dot11ManagementFrame { public: /** * \brief This PDU's flag. @@ -370,7 +371,7 @@ private: * \brief Class representing an ReAssociation Request frame in the IEEE 802.11 Protocol. * */ -class Dot11ReAssocRequest : public Dot11ManagementFrame { +class TINS_API Dot11ReAssocRequest : public Dot11ManagementFrame { public: /** * \brief This PDU's flag. @@ -496,7 +497,7 @@ private: * \brief IEEE 802.11 ReAssociation Response frame. * */ -class Dot11ReAssocResponse : public Dot11ManagementFrame { +class TINS_API Dot11ReAssocResponse : public Dot11ManagementFrame { public: /** * \brief This PDU's flag. diff --git a/include/tins/dot11/dot11_auth.h b/include/tins/dot11/dot11_auth.h index 5f6dcb3..8d02a26 100644 --- a/include/tins/dot11/dot11_auth.h +++ b/include/tins/dot11/dot11_auth.h @@ -33,12 +33,13 @@ #define TINS_DOT11_DOT11_AUTH_H #include "../dot11/dot11_mgmt.h" +#include "../macros.h" namespace Tins { /** * \brief IEEE 802.11 Authentication Request frame. */ -class Dot11Authentication : public Dot11ManagementFrame { +class TINS_API Dot11Authentication : public Dot11ManagementFrame { public: /** * \brief This PDU's flag. @@ -165,7 +166,7 @@ private: * \brief IEEE 802.11 Deauthentication frame. * */ -class Dot11Deauthentication : public Dot11ManagementFrame { +class TINS_API Dot11Deauthentication : public Dot11ManagementFrame { public: /** * \brief This PDU's flag. diff --git a/include/tins/dot11/dot11_base.h b/include/tins/dot11/dot11_base.h index af6c050..7e4a970 100644 --- a/include/tins/dot11/dot11_base.h +++ b/include/tins/dot11/dot11_base.h @@ -52,7 +52,7 @@ class RSNInformation; /** * \brief Class representing an 802.11 frame. */ -class Dot11 : public PDU { +class TINS_API Dot11 : public PDU { public: /** * The type used to store hardware addresses. diff --git a/include/tins/dot11/dot11_beacon.h b/include/tins/dot11/dot11_beacon.h index bd44400..ae72ff6 100644 --- a/include/tins/dot11/dot11_beacon.h +++ b/include/tins/dot11/dot11_beacon.h @@ -33,13 +33,14 @@ #define TINS_DOT11_DOT11_BEACON_H #include "../dot11/dot11_mgmt.h" +#include "../macros.h" namespace Tins { /** * \brief Class representing an 802.11 Beacon. * */ - class Dot11Beacon : public Dot11ManagementFrame { + class TINS_API Dot11Beacon : public Dot11ManagementFrame { public: /** * \brief This PDU's flag. diff --git a/include/tins/dot11/dot11_control.h b/include/tins/dot11/dot11_control.h index 7528de6..4c23e03 100644 --- a/include/tins/dot11/dot11_control.h +++ b/include/tins/dot11/dot11_control.h @@ -34,12 +34,13 @@ #define TINS_DOT11_DOT11_CONTROL_H #include "../dot11/dot11_base.h" +#include "../macros.h" namespace Tins { /** * \brief Class that represents an 802.11 control frame. */ -class Dot11Control : public Dot11 { +class TINS_API Dot11Control : public Dot11 { public: /** * \brief This PDU's flag. @@ -92,7 +93,7 @@ public: * \brief Class that represents an abstraction of the 802.11 control frames * that contain a target address. */ -class Dot11ControlTA : public Dot11Control { +class TINS_API Dot11ControlTA : public Dot11Control { public: /** * \brief Getter for the target address field. @@ -157,7 +158,7 @@ private: /** * \brief IEEE 802.11 RTS frame. */ -class Dot11RTS : public Dot11ControlTA { +class TINS_API Dot11RTS : public Dot11ControlTA { public: /** * \brief This PDU's flag. @@ -216,7 +217,7 @@ public: } }; -class Dot11PSPoll : public Dot11ControlTA { +class TINS_API Dot11PSPoll : public Dot11ControlTA { public: /** * \brief This PDU's flag. @@ -276,7 +277,7 @@ public: } }; -class Dot11CFEnd : public Dot11ControlTA { +class TINS_API Dot11CFEnd : public Dot11ControlTA { public: /** * \brief This PDU's flag. @@ -336,7 +337,7 @@ public: } }; -class Dot11EndCFAck : public Dot11ControlTA { +class TINS_API Dot11EndCFAck : public Dot11ControlTA { public: /** * \brief This PDU's flag. @@ -396,7 +397,7 @@ public: } }; -class Dot11Ack : public Dot11Control { +class TINS_API Dot11Ack : public Dot11Control { public: /** * \brief This PDU's flag. @@ -457,7 +458,7 @@ public: /** * \brief Class that represents an 802.11 Block Ack Request PDU. */ -class Dot11BlockAckRequest : public Dot11ControlTA { +class TINS_API Dot11BlockAckRequest : public Dot11ControlTA { public: /** * \brief This PDU's flag. @@ -593,7 +594,7 @@ private: /** * \brief Class that represents an 802.11 block ack frame. */ -class Dot11BlockAck : public Dot11ControlTA { +class TINS_API Dot11BlockAck : public Dot11ControlTA { public: /** * \brief This PDU's flag. diff --git a/include/tins/dot11/dot11_data.h b/include/tins/dot11/dot11_data.h index 7482a1a..2680b00 100644 --- a/include/tins/dot11/dot11_data.h +++ b/include/tins/dot11/dot11_data.h @@ -33,9 +33,11 @@ #define TINS_DOT11_DOT11_DATA_H #include "../dot11/dot11_base.h" +#include "../macros.h" namespace Tins { -class Dot11Data : public Dot11 { + +class TINS_API Dot11Data : public Dot11 { public: /** * \brief This PDU's flag. @@ -256,7 +258,7 @@ private: address_type _addr4; }; -class Dot11QoSData : public Dot11Data { +class TINS_API Dot11QoSData : public Dot11Data { public: /** * \brief This PDU's flag. diff --git a/include/tins/dot11/dot11_mgmt.h b/include/tins/dot11/dot11_mgmt.h index ae0bcd6..f2b86d0 100644 --- a/include/tins/dot11/dot11_mgmt.h +++ b/include/tins/dot11/dot11_mgmt.h @@ -36,12 +36,13 @@ #include #include #include "../dot11/dot11_base.h" +#include "../macros.h" namespace Tins { /** * \brief Abstract class that englobes all Management frames in the 802.11 protocol. */ -class Dot11ManagementFrame : public Dot11 { +class TINS_API Dot11ManagementFrame : public Dot11 { public: /** * The supported rates container type. diff --git a/include/tins/dot11/dot11_probe.h b/include/tins/dot11/dot11_probe.h index 2cd0044..1337551 100644 --- a/include/tins/dot11/dot11_probe.h +++ b/include/tins/dot11/dot11_probe.h @@ -34,13 +34,14 @@ #define TINS_DOT11_DOT11_PROBE_H #include "../dot11/dot11_mgmt.h" +#include "../macros.h" namespace Tins { /** * \brief Class representing an Probe Request frame in the IEEE 802.11 Protocol. * */ -class Dot11ProbeRequest : public Dot11ManagementFrame { +class TINS_API Dot11ProbeRequest : public Dot11ManagementFrame { public: /** * \brief This PDU's flag. @@ -105,7 +106,7 @@ public: * \brief Class representing an Probe Response frame in the IEEE 802.11 Protocol. * */ -class Dot11ProbeResponse : public Dot11ManagementFrame { +class TINS_API Dot11ProbeResponse : public Dot11ManagementFrame { public: /** * \brief This PDU's flag. diff --git a/include/tins/dot1q.h b/include/tins/dot1q.h index beb3cda..c56b6be 100644 --- a/include/tins/dot1q.h +++ b/include/tins/dot1q.h @@ -31,6 +31,7 @@ #define TINS_DOT1Q_H #include "pdu.h" +#include "macros.h" #include "endianness.h" #include "small_uint.h" @@ -39,7 +40,7 @@ namespace Tins { * \class Dot1Q * Represents an IEEE 802.1q PDU. */ -class Dot1Q : public PDU { +class TINS_API Dot1Q : public PDU { public: /** * This PDU's flag. diff --git a/include/tins/dot3.h b/include/tins/dot3.h index 7f0493e..96e62b1 100644 --- a/include/tins/dot3.h +++ b/include/tins/dot3.h @@ -43,7 +43,7 @@ namespace Tins { * \class Dot3 * \brief Class representing an IEEE 802.3 PDU. */ - class Dot3 : public PDU { + class TINS_API Dot3 : public PDU { public: /** * \brief The address type. diff --git a/include/tins/eapol.h b/include/tins/eapol.h index a80a941..b6af617 100644 --- a/include/tins/eapol.h +++ b/include/tins/eapol.h @@ -36,7 +36,6 @@ #include "small_uint.h" #include "endianness.h" - namespace Tins { namespace Memory { class OutputMemoryStream; @@ -52,7 +51,7 @@ class OutputMemoryStream; * \class EAPOL * \brief Represents the EAP encapsulation over LAN. */ - class EAPOL : public PDU { + class TINS_API EAPOL : public PDU { public: /** * \brief This PDU's flag. @@ -184,7 +183,7 @@ class OutputMemoryStream; /** * \brief Class that represents the RC4 EAPOL PDU. */ - class RC4EAPOL : public EAPOL { + class TINS_API RC4EAPOL : public EAPOL { public: /** * The type used to store the key. @@ -367,7 +366,7 @@ class OutputMemoryStream; /** * \brief Class that represents the RSN EAPOL PDU. */ - class RSNEAPOL : public EAPOL { + class TINS_API RSNEAPOL : public EAPOL { public: /** * The type used to store the key. diff --git a/include/tins/ethernetII.h b/include/tins/ethernetII.h index 74855ec..63025fc 100644 --- a/include/tins/ethernetII.h +++ b/include/tins/ethernetII.h @@ -43,7 +43,7 @@ namespace Tins { * \class EthernetII * \brief Represents an Ethernet II PDU. */ - class EthernetII : public PDU { + class TINS_API EthernetII : public PDU { public: /** * \brief The hardware address type. diff --git a/include/tins/handshake_capturer.h b/include/tins/handshake_capturer.h index 49ef50f..767acd9 100644 --- a/include/tins/handshake_capturer.h +++ b/include/tins/handshake_capturer.h @@ -29,13 +29,14 @@ #include "config.h" -#if !defined(TINS_HANDSHAKE_CAPTURER_H) && defined(HAVE_DOT11) +#if !defined(TINS_HANDSHAKE_CAPTURER_H) && defined(HAVE_DOT11) #define TINS_HANDSHAKE_CAPTURER_H #include #include #include #include "hw_address.h" +#include "macros.h" #include "eapol.h" // .h @@ -106,7 +107,7 @@ namespace Tins { /** * Captures 802.1X RSN handshakes. */ - class RSNHandshakeCapturer { + class TINS_API RSNHandshakeCapturer { public: /** * The type of handshakes that will be captured. diff --git a/include/tins/icmp.h b/include/tins/icmp.h index 6c0f1ac..2e70758 100644 --- a/include/tins/icmp.h +++ b/include/tins/icmp.h @@ -51,7 +51,7 @@ namespace Tins { namespace Memory { class InputMemoryStream; -} // memory +} // Memory /** * \class ICMP @@ -60,7 +60,7 @@ class InputMemoryStream; * ICMP is the representation of the ICMP PDU. Instances of this class * must be sent over a level 3 PDU, this will otherwise fail. */ -class ICMP : public PDU { +class TINS_API ICMP : public PDU { public: /** * \brief This PDU's flag. diff --git a/include/tins/icmp_extension.h b/include/tins/icmp_extension.h index a3c8220..f12b494 100644 --- a/include/tins/icmp_extension.h +++ b/include/tins/icmp_extension.h @@ -4,6 +4,7 @@ #include #include #include +#include "macros.h" #include "small_uint.h" #include "endianness.h" @@ -12,7 +13,7 @@ namespace Tins { /** * \brief Class that represents an ICMP extension object */ -class ICMPExtension { +class TINS_API ICMPExtension { public: /** * The type used to store the payload @@ -121,7 +122,7 @@ private: /** * \brief Class that represents an ICMP extensions structure */ -class ICMPExtensionsStructure { +class TINS_API ICMPExtensionsStructure { public: /** * The minimum ICMP payload size that has to be present when the PDU diff --git a/include/tins/icmpv6.h b/include/tins/icmpv6.h index b2727bb..3b810e2 100644 --- a/include/tins/icmpv6.h +++ b/include/tins/icmpv6.h @@ -53,7 +53,7 @@ class OutputMemoryStream; * \class ICMPv6 * \brief Represents an ICMPv6 PDU. */ -class ICMPv6 : public PDU { +class TINS_API ICMPv6 : public PDU { public: /** * \brief This PDU's flag. diff --git a/include/tins/ip.h b/include/tins/ip.h index b249553..8a389e9 100644 --- a/include/tins/ip.h +++ b/include/tins/ip.h @@ -59,7 +59,7 @@ class OutputMemoryStream; * and set as the source address. If you don't want this behaviour, simply * set the source address to 0.0.0.0. */ - class IP : public PDU { + class TINS_API IP : public PDU { public: /** * This PDU's flag. diff --git a/include/tins/ip_address.h b/include/tins/ip_address.h index b2d3b52..9bfbf4b 100644 --- a/include/tins/ip_address.h +++ b/include/tins/ip_address.h @@ -34,13 +34,14 @@ #include #include #include "cxxstd.h" +#include "macros.h" namespace Tins { /** * \class IPv4Address * \brief Abstraction of an IPv4 address. */ -class IPv4Address { +class TINS_API IPv4Address { public: /** * The address size. diff --git a/include/tins/ip_reassembler.h b/include/tins/ip_reassembler.h index 1f62a06..7fd4a72 100644 --- a/include/tins/ip_reassembler.h +++ b/include/tins/ip_reassembler.h @@ -33,6 +33,7 @@ #include #include #include "pdu.h" +#include "macros.h" #include "ip_address.h" namespace Tins { @@ -66,7 +67,7 @@ private: uint16_t offset_; }; -class IPv4Stream { +class TINS_API IPv4Stream { public: IPv4Stream(); @@ -93,7 +94,7 @@ private: /** * \brief Reassembles fragmented IP packets. */ -class IPv4Reassembler { +class TINS_API IPv4Reassembler { public: /** * The status of each processed packet. diff --git a/include/tins/ipsec.h b/include/tins/ipsec.h index 426812e..5bacdab 100644 --- a/include/tins/ipsec.h +++ b/include/tins/ipsec.h @@ -31,6 +31,7 @@ #define TINS_IPSEC_H #include "pdu.h" +#include "macros.h" #include "endianness.h" #include "small_uint.h" @@ -39,7 +40,7 @@ namespace Tins { * \class IPSecAH * \brief Represents an IPSec Authentication Header. */ -class IPSecAH : public PDU { +class TINS_API IPSecAH : public PDU { public: /** * This PDU's flag. @@ -175,7 +176,7 @@ private: /** * \brief Represents an IPSec Authentication Header. */ -class IPSecESP : public PDU { +class TINS_API IPSecESP : public PDU { public: /** * This PDU's flag. diff --git a/include/tins/ipv6.h b/include/tins/ipv6.h index ca85aa1..35bc711 100644 --- a/include/tins/ipv6.h +++ b/include/tins/ipv6.h @@ -50,7 +50,7 @@ class PacketSender; * \class IPv6 * Represents an IPv6 PDU. */ -class IPv6 : public PDU { +class TINS_API IPv6 : public PDU { public: /** * This PDU's flag. diff --git a/include/tins/ipv6_address.h b/include/tins/ipv6_address.h index 3b72b6f..6727e9d 100644 --- a/include/tins/ipv6_address.h +++ b/include/tins/ipv6_address.h @@ -34,13 +34,14 @@ #include #include #include "cxxstd.h" +#include "macros.h" namespace Tins { /** * Represents an IPv6 address. */ -class IPv6Address { +class TINS_API IPv6Address { public: /** * The exception thrown when a malformed address is parsed. diff --git a/include/tins/llc.h b/include/tins/llc.h index 04def9e..9e9cd87 100644 --- a/include/tins/llc.h +++ b/include/tins/llc.h @@ -35,6 +35,7 @@ #include #include "macros.h" #include "pdu.h" +#include "macros.h" #include "endianness.h" namespace Tins { @@ -45,7 +46,7 @@ namespace Tins { * * This PDU follows the standard LLC frame described in the IEEE 802.2 specs. */ - class LLC : public PDU { + class TINS_API LLC : public PDU { public: /** * \brief This PDU's flag. diff --git a/include/tins/loopback.h b/include/tins/loopback.h index 8271bb4..9e50bee 100644 --- a/include/tins/loopback.h +++ b/include/tins/loopback.h @@ -34,7 +34,7 @@ #include "macros.h" namespace Tins { -class Loopback : public PDU { +class TINS_API Loopback : public PDU { public: /** * This PDU's type. diff --git a/include/tins/macros.h b/include/tins/macros.h index ac330a4..d35d3f1 100644 --- a/include/tins/macros.h +++ b/include/tins/macros.h @@ -34,6 +34,8 @@ #include #endif +#include "config.h" + // Check if this is Visual Studio #ifdef _MSC_VER // This is Visual Studio @@ -44,6 +46,18 @@ #define TINS_NOEXCEPT #define TINS_LIKELY(x) (x) #define TINS_UNLIKELY(x) (x) + // If libtins was built into a shared library + #if !defined(TINS_STATIC_BUILD) + // Export/import symbols, depending on whether we're compiling or consuming the lib + #ifdef tins_EXPORTS + #define TINS_API __declspec(dllexport) + #else + #define TINS_API __declspec(dllimport) + #endif // tins_EXPORTS + #else // TINS_STATIC_BUILD + // Otherwise, default this to an empty macro + #define TINS_API + #endif // TINS_STATIC_BUILD #else // Not Vistual Studio. Assume this is gcc compatible #define TINS_BEGIN_PACK @@ -53,6 +67,9 @@ #define TINS_NOEXCEPT noexcept #define TINS_LIKELY(x) __builtin_expect((x),1) #define TINS_UNLIKELY(x) __builtin_expect((x),0) -#endif // + #define TINS_API +#endif // _MSC_VER + + #endif // TINS_MACROS_H diff --git a/include/tins/network_interface.h b/include/tins/network_interface.h index 972c5af..e129f5d 100644 --- a/include/tins/network_interface.h +++ b/include/tins/network_interface.h @@ -33,6 +33,7 @@ #include #include #include +#include "macros.h" #include "hw_address.h" #include "ip_address.h" @@ -41,7 +42,7 @@ namespace Tins { * \class NetworkInterface * \brief Abstraction of a network interface */ -class NetworkInterface { +class TINS_API NetworkInterface { public: /** * \brief The type used to store the interface's identifier. diff --git a/include/tins/offline_packet_filter.h b/include/tins/offline_packet_filter.h index 4c1ce36..d7ebd84 100644 --- a/include/tins/offline_packet_filter.h +++ b/include/tins/offline_packet_filter.h @@ -33,6 +33,7 @@ #include #include #include "data_link_type.h" +#include "macros.h" namespace Tins { class PDU; @@ -74,7 +75,7 @@ class PDU; * } * \endcode */ -class OfflinePacketFilter { +class TINS_API OfflinePacketFilter { public: /** * Constructs an OfflinePacketFilter object. diff --git a/include/tins/packet_sender.h b/include/tins/packet_sender.h index d3d8ed0..cb203fa 100644 --- a/include/tins/packet_sender.h +++ b/include/tins/packet_sender.h @@ -113,7 +113,7 @@ namespace Tins { * \sa PacketSender::send * \sa PacketSender::send_recv */ - class PacketSender { + class TINS_API PacketSender { public: /** * The default timeout for receive actions. diff --git a/include/tins/packet_writer.h b/include/tins/packet_writer.h index 2664e6a..61a8c60 100644 --- a/include/tins/packet_writer.h +++ b/include/tins/packet_writer.h @@ -35,6 +35,7 @@ #include #include "data_link_type.h" #include "utils.h" +#include "macros.h" #include "cxxstd.h" struct timeval; @@ -75,7 +76,7 @@ class Packet; * writer.write(vt.begin(), vt.end()); * \endcode */ -class PacketWriter { +class TINS_API PacketWriter { public: /** * \brief The type of PDUs that will be written to this file (deprecated). diff --git a/include/tins/pdu.h b/include/tins/pdu.h index 8067d0b..df7f30f 100644 --- a/include/tins/pdu.h +++ b/include/tins/pdu.h @@ -36,6 +36,7 @@ #include "macros.h" #include "cxxstd.h" #include "exceptions.h" +#include "macros.h" /** \brief The Tins namespace. */ @@ -104,7 +105,7 @@ namespace Tins { * PDU::serialization_type buffer = packet.serialize(); * \endcode */ - class PDU { + class TINS_API PDU { public: /** * The type that will be returned when serializing PDUs. diff --git a/include/tins/pktap.h b/include/tins/pktap.h index 21b1e4a..2b4f93b 100644 --- a/include/tins/pktap.h +++ b/include/tins/pktap.h @@ -31,10 +31,11 @@ #define TINS_PKTAP_H #include "pdu.h" +#include "macros.h" namespace Tins { -class PKTAP : public PDU { +class TINS_API PKTAP : public PDU { public: /** * This PDU's flag. diff --git a/include/tins/ppi.h b/include/tins/ppi.h index fe9c961..cdcc695 100644 --- a/include/tins/ppi.h +++ b/include/tins/ppi.h @@ -31,6 +31,7 @@ #define TINS_PPI_H #include "pdu.h" +#include "macros.h" #include "endianness.h" #include "small_uint.h" @@ -43,7 +44,7 @@ namespace Tins { * cannot be serialized. Therefore, it is only useful while * sniffing packets. */ -class PPI : public PDU { +class TINS_API PPI : public PDU { public: /** * This PDU's flag. diff --git a/include/tins/pppoe.h b/include/tins/pppoe.h index 80a7a51..7d6e0c0 100644 --- a/include/tins/pppoe.h +++ b/include/tins/pppoe.h @@ -34,6 +34,7 @@ #include #include #include "pdu.h" +#include "macros.h" #include "endianness.h" #include "small_uint.h" #include "pdu_option.h" @@ -44,7 +45,7 @@ namespace Tins { * \class PPPoE * \brief Represents a Point-to-point protocol over Ethernet PDU. */ -class PPPoE : public PDU { +class TINS_API PPPoE : public PDU { public: /** * The tag types enum. diff --git a/include/tins/radiotap.h b/include/tins/radiotap.h index 805da11..55d2807 100644 --- a/include/tins/radiotap.h +++ b/include/tins/radiotap.h @@ -47,7 +47,7 @@ class PacketSender; * the FCS-at-end flag is on, the channel is set to 1, TSFT is set to 0, * dbm_signal is set to -50, and the rx_flag and antenna fields to 0. */ -class RadioTap : public PDU { +class TINS_API RadioTap : public PDU { public: /** * \brief This PDU's flag. diff --git a/include/tins/rawpdu.h b/include/tins/rawpdu.h index 77a05a9..ced0e1b 100644 --- a/include/tins/rawpdu.h +++ b/include/tins/rawpdu.h @@ -33,6 +33,7 @@ #include #include #include "pdu.h" +#include "macros.h" #include "cxxstd.h" namespace Tins { @@ -60,7 +61,7 @@ namespace Tins { * DNS dns = raw.to(); * \endcode */ - class RawPDU : public PDU { + class TINS_API RawPDU : public PDU { public: /** * The type used to store the payload. diff --git a/include/tins/rsn_information.h b/include/tins/rsn_information.h index 9094691..a2e1b2c 100644 --- a/include/tins/rsn_information.h +++ b/include/tins/rsn_information.h @@ -34,6 +34,7 @@ #include #include +#include "macros.h" #include "endianness.h" namespace Tins{ @@ -43,7 +44,7 @@ class PDUOption; /** * \brief Class that models the RSN information structure. */ -class RSNInformation { +class TINS_API RSNInformation { public: /** * \brief Enum that represents the different cypher suites. diff --git a/include/tins/sll.h b/include/tins/sll.h index f7855fd..4a9a81a 100644 --- a/include/tins/sll.h +++ b/include/tins/sll.h @@ -32,6 +32,7 @@ #include #include "pdu.h" +#include "macros.h" #include "endianness.h" #include "hw_address.h" @@ -40,7 +41,7 @@ namespace Tins { * \class SLL * \brief Represents a Linux cooked-mode capture (SLL) PDU. */ -class SLL : public PDU { +class TINS_API SLL : public PDU { public: /** * This PDU's flag. diff --git a/include/tins/snap.h b/include/tins/snap.h index b3981bb..6fdcf65 100644 --- a/include/tins/snap.h +++ b/include/tins/snap.h @@ -46,7 +46,7 @@ namespace Tins { * Note that this PDU contains the 802.3 LLC structure + SNAP frame. * So far only unnumbered information structure is supported. */ - class SNAP : public PDU { + class TINS_API SNAP : public PDU { public: /** * \brief This PDU's flag. diff --git a/include/tins/sniffer.h b/include/tins/sniffer.h index 8de0831..b87a403 100644 --- a/include/tins/sniffer.h +++ b/include/tins/sniffer.h @@ -40,6 +40,7 @@ #include "pdu.h" #include "packet.h" #include "cxxstd.h" +#include "macros.h" #include "exceptions.h" #include "internals.h" @@ -57,7 +58,7 @@ namespace Tins { * * Initialization must be done using the BaseSniffer::init method. */ - class BaseSniffer { + class TINS_API BaseSniffer { public: /** * The iterator type. @@ -279,7 +280,7 @@ namespace Tins { * \class Sniffer * \brief Sniffs packets from a network interface. */ - class Sniffer : public BaseSniffer { + class TINS_API Sniffer : public BaseSniffer { public: /** * \deprecated This enum is no longer necessary. You should use the @@ -359,7 +360,7 @@ namespace Tins { * This class acts exactly in the same way that Sniffer, but reads * packets from a pcap file instead of an interface. */ - class FileSniffer : public BaseSniffer { + class TINS_API FileSniffer : public BaseSniffer { public: /** * \brief Constructs an instance of FileSniffer. @@ -509,7 +510,7 @@ namespace Tins { * Sniffer sniffer("eth0", config); * \endcode */ - class SnifferConfiguration { + class TINS_API SnifferConfiguration { public: /** * \brief The default snapshot length. diff --git a/include/tins/stp.h b/include/tins/stp.h index 3a23751..514b087 100644 --- a/include/tins/stp.h +++ b/include/tins/stp.h @@ -31,6 +31,7 @@ #define TINS_STP_H #include "pdu.h" +#include "macros.h" #include "endianness.h" #include "hw_address.h" #include "small_uint.h" @@ -40,7 +41,7 @@ namespace Tins { * \class STP * \brief Represents a Spanning Tree Protocol PDU. */ -class STP : public PDU { +class TINS_API STP : public PDU { public: /** * This PDU's flag. diff --git a/include/tins/tcp.h b/include/tins/tcp.h index a2b4a4d..afb594d 100644 --- a/include/tins/tcp.h +++ b/include/tins/tcp.h @@ -76,7 +76,7 @@ class OutputMemoryStream; * \sa RawPDU */ - class TCP : public PDU { + class TINS_API TCP : public PDU { public: /** * This PDU's flag. diff --git a/include/tins/tcp_stream.h b/include/tins/tcp_stream.h index 9e58a33..9110ff3 100644 --- a/include/tins/tcp_stream.h +++ b/include/tins/tcp_stream.h @@ -37,6 +37,7 @@ #include #include #include "sniffer.h" +#include "macros.h" #include "tcp.h" #include "utils.h" #include "ip.h" @@ -50,7 +51,7 @@ class RawPDU; * \class TCPStream * \brief Represents a TCP stream. */ -class TCPStream { +class TINS_API TCPStream { public: /** * The stream information. @@ -203,7 +204,7 @@ private: * \class TCPStreamFollower * \brief Follows TCP streams and notifies the user when data is available. */ -class TCPStreamFollower { +class TINS_API TCPStreamFollower { public: /** * \brief Default constructor.