diff --git a/Doxyfile b/Doxyfile index 4923aaa..1b47dfe 100644 --- a/Doxyfile +++ b/Doxyfile @@ -31,7 +31,7 @@ PROJECT_NAME = libtins # This could be handy for archiving the generated documentation or # if some version control system is used. -PROJECT_NUMBER = 0.1 +PROJECT_NUMBER = 0.3 # The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) # base path where the generated documentation will be put. diff --git a/include/eapol.h b/include/eapol.h index 06fc52f..a12e95f 100644 --- a/include/eapol.h +++ b/include/eapol.h @@ -135,11 +135,6 @@ namespace Tins { */ EAPOL(uint8_t packet_type, EAPOLTYPE type); - /** - * \brief Copy constructor. - */ - EAPOL(const EAPOL &other); - /** * \brief Constructor which creates an EAPOL object from a buffer. * \param buffer The buffer from which this PDU will be constructed. @@ -147,8 +142,6 @@ namespace Tins { */ EAPOL(const uint8_t *buffer, uint32_t total_sz); - void copy_eapol_fields(const EAPOL *other); - TINS_BEGIN_PACK struct eapolhdr { uint8_t version, packet_type; diff --git a/include/packet.h b/include/packet.h index a52ee52..5ca8127 100644 --- a/include/packet.h +++ b/include/packet.h @@ -35,11 +35,22 @@ #include "pdu.h" #include "timestamp.h" +/** + * \namespace Tins + */ namespace Tins { template class PacketWrapper; - + + +/** + * \brief Thin wrapper over a PDU and Timestamp reference. + */ typedef PacketWrapper RefPacket; + +/** + * \brief Thin wrapper over a PDU pointer and a Timestamp. + */ typedef PacketWrapper PtrPacket; /** @@ -109,7 +120,7 @@ private: }; /** - * \brief Represents a sniffed packet. + * \class Represents a sniffed packet. * * A Packet contains a PDU pointer and a Timestamp object. Packets * will delete the stored PDU* unless you call release_pdu at diff --git a/include/sniffer.h b/include/sniffer.h index 1083916..f822da0 100644 --- a/include/sniffer.h +++ b/include/sniffer.h @@ -89,18 +89,25 @@ namespace Tins { * object. This wrapper can be both implicitly converted to a * PDU* and a Packet object. So doing this: * + * \code * Sniffer s(...); - * // smart pointer? :D - * PDU *pdu = s.next_packet(); - * // Packet takes care of the PDU*. \sa Packet::release_pdu + * std::unique_ptr pdu(s.next_packet()); + * // Packet takes care of the PDU*. * Packet packet(s.next_packet()); + * \endcode * * Is fine, but this: * + * \code + * // bad!! * PtrPacket p = s.next_packet(); * + * \endcode + * * Is not, since PtrPacket can't be copy constructed. * + * \sa Packet::release_pdu + * * \return The captured packet, matching the given filter. * If an error occured(probably compiling the filter), PtrPacket::pdu * will return 0. Caller takes ownership of the PDU * stored in @@ -115,8 +122,10 @@ namespace Tins { * The callback object must implement an operator with some of * the following(or compatible) signatures: * + * \code * bool operator()(PDU&); * bool operator()(RefPacket&); + * \endcode * * This operator will be called using the sniffed packets * as arguments. You can modify the parameter argument as you wish. @@ -125,12 +134,14 @@ namespace Tins { * * The callback taking a RefPacket will contain a timestamp * indicating the moment in which the packet was taken out of - * the wire/pcap file. \sa RefPacket + * the wire/pcap file. * * Note that the Functor object will be copied using its copy * constructor, so that object should be some kind of proxy to * another object which will process the packets(e.g. std::bind). * + * \sa RefPacket + * * \param cback_handler The callback handler object which should process packets. * \param max_packets The maximum amount of packets to sniff. 0 == infinite. */ diff --git a/src/eapol.cpp b/src/eapol.cpp index 90541a8..aad283c 100644 --- a/src/eapol.cpp +++ b/src/eapol.cpp @@ -51,10 +51,6 @@ EAPOL::EAPOL(const uint8_t *buffer, uint32_t total_sz) std::memcpy(&_header, buffer, sizeof(_header)); } -EAPOL::EAPOL(const EAPOL &other) : PDU(other) { - copy_eapol_fields(&other); -} - EAPOL *EAPOL::from_bytes(const uint8_t *buffer, uint32_t total_sz) { if(total_sz < sizeof(eapolhdr)) throw std::runtime_error("Not enough size for an EAPOL header in the buffer."); @@ -96,11 +92,6 @@ void EAPOL::write_serialization(uint8_t *buffer, uint32_t total_sz, const PDU *) write_body(buffer + sizeof(_header), total_sz - sizeof(_header)); } -void EAPOL::copy_eapol_fields(const EAPOL *other) { - std::memcpy(&_header, &other->_header, sizeof(_header)); - -} - /* RC4EAPOL */ RC4EAPOL::RC4EAPOL()