mirror of
https://github.com/mfontanini/libtins
synced 2026-01-23 02:35:57 +01:00
Fixed compilation error in OSX. Fixed bug when sending IP PDUs in BSD.
This commit is contained in:
@@ -33,16 +33,14 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include "macros.h"
|
#include "macros.h"
|
||||||
|
|
||||||
#if defined(BSD)
|
#if defined(__APPLE__)
|
||||||
#if defined(__APPLE__)
|
#include <sys/types.h>
|
||||||
#include <sys/types.h>
|
#define TINS_IS_LITTLE_ENDIAN (BYTE_ORDER == LITTLE_ENDIAN)
|
||||||
#define TINS_IS_LITTLE_ENDIAN (BYTE_ORDER == LITTLE_ENDIAN)
|
#define TINS_IS_BIG_ENDIAN (BYTE_ORDER == BIG_ENDIAN)
|
||||||
#define TINS_IS_BIG_ENDIAN (BYTE_ORDER == BIG_ENDIAN)
|
#elif defined(BSD)
|
||||||
#else
|
#include <sys/endian.h>
|
||||||
#include <sys/endian.h>
|
#define TINS_IS_LITTLE_ENDIAN (_BYTE_ORDER == _LITTLE_ENDIAN)
|
||||||
#define TINS_IS_LITTLE_ENDIAN (_BYTE_ORDER == _LITTLE_ENDIAN)
|
#define TINS_IS_BIG_ENDIAN (_BYTE_ORDER == _BIG_ENDIAN)
|
||||||
#define TINS_IS_BIG_ENDIAN (_BYTE_ORDER == _BIG_ENDIAN)
|
|
||||||
#endif
|
|
||||||
#elif defined(WIN32)
|
#elif defined(WIN32)
|
||||||
// Assume windows == little endian. fixme later
|
// Assume windows == little endian. fixme later
|
||||||
#define TINS_IS_LITTLE_ENDIAN 1
|
#define TINS_IS_LITTLE_ENDIAN 1
|
||||||
|
|||||||
@@ -260,12 +260,7 @@ namespace Tins {
|
|||||||
* \return The total length of this IP PDU.
|
* \return The total length of this IP PDU.
|
||||||
*/
|
*/
|
||||||
uint16_t tot_len() const {
|
uint16_t tot_len() const {
|
||||||
// FreeBSD wants this in host byte order............
|
|
||||||
#ifdef __FreeBSD__
|
|
||||||
return _ip.tot_len;
|
|
||||||
#else
|
|
||||||
return Endian::be_to_host(_ip.tot_len);
|
return Endian::be_to_host(_ip.tot_len);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -32,9 +32,11 @@
|
|||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
#include "macros.h"
|
||||||
|
|
||||||
#ifndef WIN32
|
#ifndef WIN32
|
||||||
#ifdef BSD
|
#if defined(BSD) || defined(__APPLE__)
|
||||||
|
#include <sys/types.h>
|
||||||
#include <net/if_dl.h>
|
#include <net/if_dl.h>
|
||||||
#else
|
#else
|
||||||
#include <netpacket/packet.h>
|
#include <netpacket/packet.h>
|
||||||
|
|||||||
10
src/ip.cpp
10
src/ip.cpp
@@ -170,12 +170,7 @@ void IP::tos(uint8_t new_tos) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void IP::tot_len(uint16_t new_tot_len) {
|
void IP::tot_len(uint16_t new_tot_len) {
|
||||||
// FreeBSD wants this in host byte order............
|
|
||||||
#ifdef __FreeBSD__
|
|
||||||
_ip.tot_len = new_tot_len;
|
|
||||||
#else
|
|
||||||
_ip.tot_len = Endian::host_to_be(new_tot_len);
|
_ip.tot_len = Endian::host_to_be(new_tot_len);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void IP::id(uint16_t new_id) {
|
void IP::id(uint16_t new_id) {
|
||||||
@@ -394,6 +389,11 @@ void IP::write_serialization(uint8_t *buffer, uint32_t total_sz, const PDU* pare
|
|||||||
protocol(new_flag);
|
protocol(new_flag);
|
||||||
//flag(new_flag);
|
//flag(new_flag);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef __FreeBSD__
|
||||||
|
if(!parent)
|
||||||
|
total_sz = Endian::host_to_be<uint16_t>(total_sz);
|
||||||
|
#endif
|
||||||
tot_len(total_sz);
|
tot_len(total_sz);
|
||||||
head_len(my_sz / sizeof(uint32_t));
|
head_len(my_sz / sizeof(uint32_t));
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user