From ff21304852e30a4ce823a258b525c3fcc60e66cc Mon Sep 17 00:00:00 2001 From: Matias Fontanini Date: Thu, 15 Sep 2011 10:21:23 -0300 Subject: [PATCH] Fixed endianness bug in UDP's getters. --- include/udp.h | 7 ++++--- src/udp.cpp | 1 - 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/udp.h b/include/udp.h index ae7fbc9..ad38be8 100644 --- a/include/udp.h +++ b/include/udp.h @@ -24,6 +24,7 @@ #include "pdu.h" +#include "utils.h" namespace Tins { @@ -67,19 +68,19 @@ namespace Tins { * \brief Getter for the destination port. * \return The datagram's destination port. */ - inline uint16_t dport() const { return _udp.dport; } + inline uint16_t dport() const { return Utils::net_to_host_s(_udp.dport); } /** * \brief Getter for the source port. * \return The datagram's source port. */ - inline uint16_t sport() const { return _udp.sport; } + inline uint16_t sport() const { return Utils::net_to_host_s(_udp.sport); } /** * \brief Getter for the length of the datagram. * \return The length of the datagram. */ - inline uint16_t length() const { return _udp.len; } + inline uint16_t length() const { return Utils::net_to_host_s(_udp.len); } /** * \brief Set the destination port. diff --git a/src/udp.cpp b/src/udp.cpp index 0fa8d2d..227d127 100644 --- a/src/udp.cpp +++ b/src/udp.cpp @@ -22,7 +22,6 @@ #include #include #include -#include "utils.h" #include "udp.h" #include "constants.h" #include "ip.h"