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

All tests now run successfully on big endian architectures.

This commit is contained in:
Matias Fontanini
2013-04-21 15:40:28 -03:00
parent 077b54bbed
commit 6f04329fbe
3 changed files with 39 additions and 23 deletions

View File

@@ -3399,19 +3399,37 @@ namespace Tins {
* \brief Getter for the bar control field.
* \return The stored bar control field.
*/
uint16_t bar_control() const { return Endian::le_to_host(_bar_control.tid); }
uint16_t bar_control() const {
#if TINS_IS_LITTLE_ENDIAN
return _bar_control & 0xf;
#else
return (_bar_control >> 8) & 0xf;
#endif
}
/**
* \brief Getter for the start sequence field.
* \return The stored start sequence.
*/
uint16_t start_sequence() const { return Endian::le_to_host(_start_sequence.seq); }
uint16_t start_sequence() const {
#if TINS_IS_LITTLE_ENDIAN
return (_start_sequence >> 4) & 0xfff;
#else
return (Endian::le_to_host<uint16_t>(_start_sequence) >> 4) & 0xfff;
#endif
}
/**
* \brief Getter for the fragment number field.
* \return The stored fragment number field.
*/
uint8_t fragment_number() const { return _start_sequence.frag; }
uint8_t fragment_number() const {
#if TINS_IS_LITTLE_ENDIAN
return _start_sequence & 0xf;
#else
return (_start_sequence >> 8) & 0xf;
#endif
}
/**
* \brief Returns the 802.11 frame's header length.
@@ -3467,22 +3485,10 @@ namespace Tins {
protected:
uint32_t write_ext_header(uint8_t *buffer, uint32_t total_sz);
private:
TINS_BEGIN_PACK
struct BarControl {
uint16_t tid:4,
reserved:12;
} TINS_END_PACK;
TINS_BEGIN_PACK
struct StartSequence {
uint16_t frag:4,
seq:12;
} TINS_END_PACK;
void init_block_ack();
BarControl _bar_control;
StartSequence _start_sequence;
uint16_t _bar_control;
uint16_t _start_sequence;
};
/**

View File

@@ -187,7 +187,7 @@ private:
struct dot1q_hdr {
#if TINS_IS_BIG_ENDIAN
uint16_t priority:3,
cfi:1
cfi:1,
id:12;
uint16_t type;
#else

View File

@@ -1540,17 +1540,27 @@ uint32_t Dot11BlockAckRequest::write_ext_header(uint8_t *buffer, uint32_t total_
}
void Dot11BlockAckRequest::bar_control(uint16_t bar) {
//std::memcpy(&_bar_control, &bar, sizeof(bar));
_bar_control.tid = Endian::host_to_le(bar);
#if TINS_IS_LITTLE_ENDIAN
_bar_control = bar | (_bar_control & 0xfff0);
#else
_bar_control = (bar << 8) | (_bar_control & 0xf0ff);
#endif
}
void Dot11BlockAckRequest::start_sequence(uint16_t seq) {
//std::memcpy(&_start_sequence, &seq, sizeof(seq));
_start_sequence.seq = Endian::host_to_le(seq);
#if TINS_IS_LITTLE_ENDIAN
_start_sequence = (seq << 4) | (_start_sequence & 0xf);
#else
_start_sequence = Endian::host_to_le<uint16_t>(seq << 4) | (_start_sequence & 0xf00);
#endif
}
void Dot11BlockAckRequest::fragment_number(uint8_t frag) {
_start_sequence.frag = frag;
#if TINS_IS_LITTLE_ENDIAN
_start_sequence = frag | (_start_sequence & 0xfff0);
#else
_start_sequence = (frag << 8) | (_start_sequence & 0xf0ff);
#endif
}
uint32_t Dot11BlockAckRequest::header_size() const {