1
0
mirror of https://github.com/mfontanini/libtins synced 2026-01-23 02:35:57 +01:00

Done minor modification, mostly on documentation.

This commit is contained in:
Matias Fontanini
2013-01-29 16:18:08 -03:00
parent 2a1a28c3fb
commit 931a86eff9
5 changed files with 29 additions and 23 deletions

View File

@@ -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.

View File

@@ -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;

View File

@@ -35,11 +35,22 @@
#include "pdu.h"
#include "timestamp.h"
/**
* \namespace Tins
*/
namespace Tins {
template<typename WrappedType, typename TimestampType>
class PacketWrapper;
/**
* \brief Thin wrapper over a PDU and Timestamp reference.
*/
typedef PacketWrapper<PDU&, const Timestamp&> RefPacket;
/**
* \brief Thin wrapper over a PDU pointer and a Timestamp.
*/
typedef PacketWrapper<PDU*, Timestamp> 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
* <b>will delete</b> the stored PDU* unless you call release_pdu at

View File

@@ -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> 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.
*/

View File

@@ -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()