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

Changed IEEE802_11::dst_addr, src_addr and filter_addr to addr1, addr2 and addr3.

This commit is contained in:
Matias Fontanini
2011-08-25 21:39:32 -03:00
parent fad0fe9c8b
commit 9e56c3681e
3 changed files with 45 additions and 46 deletions

View File

@@ -297,25 +297,25 @@ namespace Tins {
inline uint16_t duration_id() const { return Utils::net_to_host_s(this->_header.duration_id); }
/**
* \brief Getter for the destination's address.
* \brief Getter for the first address.
*
* \return The destination's address as a constant uint8_t pointer.
* \return The first address as a constant uint8_t pointer.
*/
inline const uint8_t* dst_addr() const { return this->_header.dst_addr; }
inline const uint8_t* addr1() const { return this->_header.addr1; }
/**
* \brief Getter for the source's address.
* \brief Getter for the second address.
*
* \return The source's address as a constant uint8_t pointer.
* \return The second address as a constant uint8_t pointer.
*/
inline const uint8_t* src_addr() const { return this->_header.src_addr; }
inline const uint8_t* addr2() const { return this->_header.addr2; }
/**
* \brief Getter for the filtering's address.
* \brief Getter for the third address.
*
* \return The filtering's address as a constant uint8_t pointer.
* \return The third address as a constant uint8_t pointer.
*/
inline const uint8_t* filter_addr() const { return this->_header.filter_addr; }
inline const uint8_t* addr3() const { return this->_header.addr3; }
/**
* \brief Getter for the fragment number.
@@ -332,11 +332,11 @@ namespace Tins {
inline uint16_t seq_num() const { return Utils::net_to_host_s(this->_header.seq_control.seq_number); }
/**
* \brief Getter for the optional address.
* \brief Getter for the fourth address.
*
* \return The optional address as a constant uint8_t pointer.
* \return The fourth address as a constant uint8_t pointer.
*/
inline const uint8_t* opt_addr() const { return this->_opt_addr; }
inline const uint8_t* addr4() const { return this->_addr4; }
/**
* \brief Getter for the interface.
@@ -423,25 +423,25 @@ namespace Tins {
void duration_id(uint16_t new_duration_id);
/**
* \brief Setter for the destination's address.
* \brief Setter for the first address.
*
* \param new_dst_addr const uint8_t array of 6 bytes containing the new destination's address.
* \param new_addr1 const uint8_t array of 6 bytes containing the new first's address.
*/
void dst_addr(const uint8_t* new_dst_addr);
void addr1(const uint8_t* new_addr1);
/**
* \brief Setter for the source's address.
* \brief Setter for the second address.
*
* \param new_src_addr const uint8_t array of 6 bytes containing the new source's address.
* \param new_addr2 const uint8_t array of 6 bytes containing the new second's address.
*/
void src_addr(const uint8_t* new_src_addr);
void addr2(const uint8_t* new_addr2);
/**
* \brief Setter for the filtering's address.
* \brief Setter for the third address.
*
* \param new_filter_addr const uint8_t array of 6 bytes containing the new filtering's address.
* \param new_addr3 const uint8_t array of 6 bytes containing the new third address.
*/
void filter_addr(const uint8_t* new_filter_addr);
void addr3(const uint8_t* new_addr3);
/**
* \brief Setter for the fragment number.
@@ -458,11 +458,11 @@ namespace Tins {
void seq_num(uint16_t new_seq_num);
/**
* \brief Setter for the optional address.
* \brief Setter for the fourth address.
*
* \param new_opt_addr const uint8_t array of 6 bytes containing the new optional address.
* \param new_addr4 const uint8_t array of 6 bytes containing the new fourth address.
*/
void opt_addr(const uint8_t* new_opt_addr);
void addr4(const uint8_t* new_addr4);
/**
* \brief Setter for the interface.
@@ -558,9 +558,9 @@ namespace Tins {
#endif
} __attribute__((__packed__)) control;
uint16_t duration_id;
uint8_t dst_addr[6];
uint8_t src_addr[6];
uint8_t filter_addr[6];
uint8_t addr1[6];
uint8_t addr2[6];
uint8_t addr3[6];
struct {
#if __BYTE_ORDER == __LITTLE_ENDIAN
unsigned int seq_number:12;
@@ -580,7 +580,7 @@ namespace Tins {
ieee80211_header _header;
uint8_t _opt_addr[6];
uint8_t _addr4[6];
uint32_t _iface_index, _options_size;
std::list<IEEE802_11_Option> _options;
};

View File

@@ -22,7 +22,6 @@
#include <cassert>
#include <cstring>
#include <stdexcept>
#include <iostream> //borrame
#ifndef WIN32
#include <net/ethernet.h>
#include <netpacket/packet.h>
@@ -41,17 +40,17 @@ const uint8_t *Tins::IEEE802_11::BROADCAST = (const uint8_t*)"\xff\xff\xff\xff\x
Tins::IEEE802_11::IEEE802_11(const uint8_t* dst_hw_addr, const uint8_t* src_hw_addr, PDU* child) : PDU(ETHERTYPE_IP, child), _options_size(0) {
memset(&this->_header, 0, sizeof(ieee80211_header));
if(dst_hw_addr)
this->dst_addr(dst_hw_addr);
this->addr1(dst_hw_addr);
if(src_hw_addr)
this->src_addr(src_hw_addr);
this->addr2(src_hw_addr);
}
Tins::IEEE802_11::IEEE802_11(const std::string& iface, const uint8_t* dst_hw_addr, const uint8_t* src_hw_addr, PDU* child) throw (std::runtime_error) : PDU(ETHERTYPE_IP, child), _options_size(0) {
memset(&this->_header, 0, sizeof(ieee80211_header));
if(dst_hw_addr)
this->dst_addr(dst_hw_addr);
this->addr1(dst_hw_addr);
if(src_hw_addr)
this->src_addr(src_hw_addr);
this->addr2(src_hw_addr);
this->iface(iface);
}
@@ -59,9 +58,9 @@ Tins::IEEE802_11::IEEE802_11(const std::string& iface, const uint8_t* dst_hw_add
Tins::IEEE802_11::IEEE802_11(uint32_t iface_index, const uint8_t* dst_hw_addr, const uint8_t* src_hw_addr, PDU* child) : PDU(ETHERTYPE_IP, child), _options_size(0) {
memset(&this->_header, 0, sizeof(ieee80211_header));
if(dst_hw_addr)
this->dst_addr(dst_hw_addr);
this->addr1(dst_hw_addr);
if(src_hw_addr)
this->src_addr(src_hw_addr);
this->addr2(src_hw_addr);
this->iface(iface_index);
}
@@ -163,16 +162,16 @@ void Tins::IEEE802_11::duration_id(uint16_t new_duration_id) {
this->_header.duration_id = Utils::net_to_host_s(new_duration_id);
}
void Tins::IEEE802_11::dst_addr(const uint8_t* new_dst_addr) {
memcpy(this->_header.dst_addr, new_dst_addr, 6);
void Tins::IEEE802_11::addr1(const uint8_t* new_addr1) {
memcpy(this->_header.addr1, new_addr1, 6);
}
void Tins::IEEE802_11::src_addr(const uint8_t* new_src_addr) {
memcpy(this->_header.src_addr, new_src_addr, 6);
void Tins::IEEE802_11::addr2(const uint8_t* new_addr2) {
memcpy(this->_header.addr2, new_addr2, 6);
}
void Tins::IEEE802_11::filter_addr(const uint8_t* new_filter_addr) {
memcpy(this->_header.filter_addr, new_filter_addr, 6);
void Tins::IEEE802_11::addr3(const uint8_t* new_addr3) {
memcpy(this->_header.addr3, new_addr3, 6);
}
void Tins::IEEE802_11::frag_num(uint8_t new_frag_num) {
@@ -183,8 +182,8 @@ void Tins::IEEE802_11::seq_num(uint16_t new_seq_num) {
this->_header.seq_control.seq_number = Utils::net_to_host_s(new_seq_num);
}
void Tins::IEEE802_11::opt_addr(const uint8_t* new_opt_addr) {
memcpy(this->_opt_addr, new_opt_addr, 6);
void Tins::IEEE802_11::addr4(const uint8_t* new_addr4) {
memcpy(this->_addr4, new_addr4, 6);
}
void Tins::IEEE802_11::iface(uint32_t new_iface_index) {
@@ -213,7 +212,7 @@ bool Tins::IEEE802_11::send(PacketSender* sender) {
addr.sll_protocol = Utils::net_to_host_s(ETH_P_ALL);
addr.sll_halen = 6;
addr.sll_ifindex = this->_iface_index;
memcpy(&(addr.sll_addr), this->_header.dst_addr, 6);
memcpy(&(addr.sll_addr), this->_header.addr1, 6);
return sender->send_l2(this, (struct sockaddr*)&addr, (uint32_t)sizeof(addr));
}
@@ -224,7 +223,7 @@ void Tins::IEEE802_11::write_serialization(uint8_t *buffer, uint32_t total_sz, c
memcpy(buffer, &this->_header, sizeof(ieee80211_header));
buffer += sizeof(ieee80211_header);
if (this->to_ds() && this->from_ds()) {
memcpy(buffer, this->_opt_addr, 6);
memcpy(buffer, this->_addr4, 6);
buffer += 6;
total_sz -= 6;
}

View File

@@ -197,7 +197,7 @@ bool Tins::RadioTap::send(PacketSender* sender) {
Tins::IEEE802_11 *wlan = dynamic_cast<Tins::IEEE802_11*>(inner_pdu());
if(wlan)
memcpy(&(addr.sll_addr), wlan->dst_addr(), 6);
memcpy(&(addr.sll_addr), wlan->addr1(), 6);
return sender->send_l2(this, (struct sockaddr*)&addr, (uint32_t)sizeof(addr));
}