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

Created UDP PDU. Done some documentation on TCP.

This commit is contained in:
Matias F
2011-08-12 20:22:45 -03:00
parent d59cec94b6
commit 35c1a6e65d
5 changed files with 65 additions and 4 deletions

View File

@@ -117,7 +117,7 @@ namespace Tins {
void dport(uint16_t new_dport);
/** \brief Set the source port.
* \param new_dport New source port.
* \param new_sport New source port.
*/
void sport(uint16_t new_sport);
@@ -151,6 +151,7 @@ namespace Tins {
* Payload is NOT copied. Therefore, pointers provided as
* payloads must be freed manually by the user.
* \param new_payload New payload.
* \param new_payload_size New payload's size
*/
void payload(uint8_t *new_payload, uint32_t new_payload_size);

46
include/udp.h Normal file
View File

@@ -0,0 +1,46 @@
#ifndef __UDP_H
#define __UDP_H
#include "pdu.h"
namespace Tins {
/** \brief UDP represents the UDP PDU.
*
* UDP is the representation of the UDP PDU. Instances of this class
* must be sent over a level 3 PDU, this will otherwise fail.
*/
class UDP : public PDU {
public:
/** \brief UDP constructor.
*
* Creates an instance of UDP. Destination and source port can
* be provided, otherwise both will be 0.
* \param dport Destination port.
* \param sport Source port.
* */
UDP(uint16_t sport = 0, uint16_t dport = 0);
/** \brief Set the payload.
*
* Payload is NOT copied. Therefore, pointers provided as
* payloads must be freed manually by the user.
* \param new_payload New payload.
* \param new_payload_size New payload's size
*/
void payload(uint8_t *new_payload, uint32_t new_payload_size);
private:
struct udphdr {
uint16_t sport;
uint16_t dport;
uint16_t len;
uint16_t check;
} __attribute__((packed));
udphdr _udp;
uint8_t *payload;
};
};
#endif