1
0
mirror of https://github.com/mfontanini/libtins synced 2026-01-28 12:44:25 +01:00

Documented many header files. Done some minor code refactoring over PDU::clone_packet.

This commit is contained in:
Matias Fontanini
2011-08-16 20:53:55 -03:00
parent 9b897db21f
commit e587d18796
12 changed files with 125 additions and 66 deletions

View File

@@ -157,10 +157,24 @@ namespace Tins {
*/
virtual PDU *clone_packet(uint8_t *ptr, uint32_t total_sz) { return 0; }
protected:
/* Serialize this PDU storing the result in buffer. */
/** \brief Serializes this PDU and propagates this action to child PDUs.
*
* \param buffer The buffer in which to store this PDU's serialization.
* \param total_sz The total size of the buffer.
* \param parent The parent PDU. Will be 0 if there's the parent does not exist.
*/
void serialize(uint8_t *buffer, uint32_t total_sz, const PDU *parent);
/** \brief Clones the inner pdu(if any).
*
* This method clones the inner pdu using data from a buffer.
* \param ptr The pointer from which the child PDU must be cloned.
* \param total_sz The total size of the buffer.
* \return Returns the cloned PDU. Will be 0 if cloning failed.
*/
PDU *clone_inner_pdu(uint8_t *ptr, uint32_t total_sz);
/** \brief Serialices this TCP PDU.
/** \brief Serializes this TCP PDU.
*
* Each PDU must override this method and implement it's own
* serialization.
@@ -170,7 +184,25 @@ namespace Tins {
*/
virtual void write_serialization(uint8_t *buffer, uint32_t total_sz, const PDU *parent) = 0;
/** \brief Does the 16 bits sum of all 2 bytes elements between start and end.
*
* This is the checksum used by IP, UDP and TCP. If there's and odd number of
* bytes, the last one is padded and added to the checksum. The checksum is performed
* using network endiannes.
* \param start The pointer to the start of the buffer.
* \param end The pointer to the end of the buffer(excluding the last element).
* \return Returns the checksum between start and end(non inclusive).
*/
static uint32_t do_checksum(uint8_t *start, uint8_t *end);
/** \brief Performs the pseudo header checksum used in TCP and UDP PDUs.
*
* \param source_ip The source ip address.
* \param dest_ip The destination ip address.
* \param len The length to be included in the pseudo header.
* \param flag The flag to use in the protocol field of the pseudo header.
* \return The pseudo header checksum.
*/
static uint32_t pseudoheader_checksum(uint32_t source_ip, uint32_t dest_ip, uint32_t len, uint32_t flag);
private:
uint32_t _flag;