mirror of
https://github.com/mfontanini/libtins
synced 2026-01-28 12:44:25 +01:00
Code cleanup and use same syntax on the entire project
Initial code cleanup More code cleanup Cleanup more code Cleanup Dot11 code Fix OSX build issue Cleanup examples Fix ref and pointer declaration syntax Fix braces
This commit is contained in:
@@ -37,168 +37,159 @@ using Tins::Memory::InputMemoryStream;
|
||||
using Tins::Memory::OutputMemoryStream;
|
||||
|
||||
namespace Tins {
|
||||
/* Diassoc */
|
||||
|
||||
Dot11Disassoc::Dot11Disassoc(const address_type &dst_hw_addr,
|
||||
const address_type &src_hw_addr)
|
||||
: Dot11ManagementFrame(dst_hw_addr, src_hw_addr), _body()
|
||||
{
|
||||
this->subtype(Dot11::DISASSOC);
|
||||
// Disassoc
|
||||
|
||||
Dot11Disassoc::Dot11Disassoc(const address_type& dst_hw_addr,
|
||||
const address_type& src_hw_addr)
|
||||
: Dot11ManagementFrame(dst_hw_addr, src_hw_addr), body_() {
|
||||
this->subtype(Dot11::DISASSOC);
|
||||
}
|
||||
|
||||
Dot11Disassoc::Dot11Disassoc(const uint8_t *buffer, uint32_t total_sz)
|
||||
Dot11Disassoc::Dot11Disassoc(const uint8_t* buffer, uint32_t total_sz)
|
||||
: Dot11ManagementFrame(buffer, total_sz) {
|
||||
InputMemoryStream stream(buffer, total_sz);
|
||||
stream.skip(management_frame_size());
|
||||
stream.read(_body);
|
||||
stream.read(body_);
|
||||
parse_tagged_parameters(stream);
|
||||
}
|
||||
|
||||
void Dot11Disassoc::reason_code(uint16_t new_reason_code) {
|
||||
this->_body.reason_code = Endian::host_to_le(new_reason_code);
|
||||
body_.reason_code = Endian::host_to_le(new_reason_code);
|
||||
}
|
||||
|
||||
uint32_t Dot11Disassoc::header_size() const {
|
||||
return Dot11ManagementFrame::header_size() + sizeof(DisassocBody);
|
||||
return Dot11ManagementFrame::header_size() + sizeof(body_);
|
||||
}
|
||||
|
||||
void Dot11Disassoc::write_fixed_parameters(OutputMemoryStream& stream) {
|
||||
stream.write(_body);
|
||||
stream.write(body_);
|
||||
}
|
||||
|
||||
/* Assoc request. */
|
||||
// Assoc request
|
||||
|
||||
Dot11AssocRequest::Dot11AssocRequest(const address_type &dst_hw_addr,
|
||||
const address_type &src_hw_addr)
|
||||
: Dot11ManagementFrame(dst_hw_addr, src_hw_addr), _body()
|
||||
{
|
||||
Dot11AssocRequest::Dot11AssocRequest(const address_type& dst_hw_addr,
|
||||
const address_type& src_hw_addr)
|
||||
: Dot11ManagementFrame(dst_hw_addr, src_hw_addr), body_() {
|
||||
subtype(Dot11::ASSOC_REQ);
|
||||
}
|
||||
|
||||
Dot11AssocRequest::Dot11AssocRequest(const uint8_t *buffer, uint32_t total_sz)
|
||||
: Dot11ManagementFrame(buffer, total_sz)
|
||||
{
|
||||
Dot11AssocRequest::Dot11AssocRequest(const uint8_t* buffer, uint32_t total_sz)
|
||||
: Dot11ManagementFrame(buffer, total_sz) {
|
||||
InputMemoryStream stream(buffer, total_sz);
|
||||
stream.skip(management_frame_size());
|
||||
stream.read(_body);
|
||||
stream.read(body_);
|
||||
parse_tagged_parameters(stream);
|
||||
}
|
||||
|
||||
void Dot11AssocRequest::listen_interval(uint16_t new_listen_interval) {
|
||||
this->_body.listen_interval = Endian::host_to_le(new_listen_interval);
|
||||
body_.listen_interval = Endian::host_to_le(new_listen_interval);
|
||||
}
|
||||
|
||||
uint32_t Dot11AssocRequest::header_size() const {
|
||||
return Dot11ManagementFrame::header_size() + sizeof(AssocReqBody);
|
||||
return Dot11ManagementFrame::header_size() + sizeof(body_);
|
||||
}
|
||||
|
||||
void Dot11AssocRequest::write_fixed_parameters(OutputMemoryStream& stream) {
|
||||
stream.write(_body);
|
||||
stream.write(body_);
|
||||
}
|
||||
|
||||
/* Assoc response. */
|
||||
// Assoc response
|
||||
|
||||
Dot11AssocResponse::Dot11AssocResponse(const address_type &dst_hw_addr,
|
||||
const address_type &src_hw_addr)
|
||||
: Dot11ManagementFrame(dst_hw_addr, src_hw_addr)
|
||||
{
|
||||
Dot11AssocResponse::Dot11AssocResponse(const address_type& dst_hw_addr,
|
||||
const address_type& src_hw_addr)
|
||||
: Dot11ManagementFrame(dst_hw_addr, src_hw_addr), body_() {
|
||||
subtype(Dot11::ASSOC_RESP);
|
||||
memset(&_body, 0, sizeof(_body));
|
||||
}
|
||||
|
||||
Dot11AssocResponse::Dot11AssocResponse(const uint8_t *buffer, uint32_t total_sz)
|
||||
: Dot11ManagementFrame(buffer, total_sz)
|
||||
{
|
||||
Dot11AssocResponse::Dot11AssocResponse(const uint8_t* buffer, uint32_t total_sz)
|
||||
: Dot11ManagementFrame(buffer, total_sz) {
|
||||
InputMemoryStream stream(buffer, total_sz);
|
||||
stream.skip(management_frame_size());
|
||||
stream.read(_body);
|
||||
stream.read(body_);
|
||||
parse_tagged_parameters(stream);
|
||||
}
|
||||
|
||||
void Dot11AssocResponse::status_code(uint16_t new_status_code) {
|
||||
this->_body.status_code = Endian::host_to_le(new_status_code);
|
||||
body_.status_code = Endian::host_to_le(new_status_code);
|
||||
}
|
||||
|
||||
void Dot11AssocResponse::aid(uint16_t new_aid) {
|
||||
this->_body.aid = Endian::host_to_le(new_aid);
|
||||
body_.aid = Endian::host_to_le(new_aid);
|
||||
}
|
||||
|
||||
uint32_t Dot11AssocResponse::header_size() const {
|
||||
return Dot11ManagementFrame::header_size() + sizeof(AssocRespBody);
|
||||
return Dot11ManagementFrame::header_size() + sizeof(body_);
|
||||
}
|
||||
|
||||
void Dot11AssocResponse::write_fixed_parameters(OutputMemoryStream& stream) {
|
||||
stream.write(_body);
|
||||
stream.write(body_);
|
||||
}
|
||||
|
||||
/* ReAssoc request. */
|
||||
// ReAssoc request
|
||||
|
||||
Dot11ReAssocRequest::Dot11ReAssocRequest(const address_type &dst_hw_addr,
|
||||
const address_type &src_hw_addr)
|
||||
: Dot11ManagementFrame(dst_hw_addr, src_hw_addr)
|
||||
{
|
||||
this->subtype(Dot11::REASSOC_REQ);
|
||||
memset(&_body, 0, sizeof(_body));
|
||||
Dot11ReAssocRequest::Dot11ReAssocRequest(const address_type& dst_hw_addr,
|
||||
const address_type& src_hw_addr)
|
||||
: Dot11ManagementFrame(dst_hw_addr, src_hw_addr), body_() {
|
||||
subtype(Dot11::REASSOC_REQ);
|
||||
}
|
||||
|
||||
Dot11ReAssocRequest::Dot11ReAssocRequest(const uint8_t *buffer, uint32_t total_sz)
|
||||
: Dot11ManagementFrame(buffer, total_sz)
|
||||
{
|
||||
Dot11ReAssocRequest::Dot11ReAssocRequest(const uint8_t* buffer, uint32_t total_sz)
|
||||
: Dot11ManagementFrame(buffer, total_sz) {
|
||||
InputMemoryStream stream(buffer, total_sz);
|
||||
stream.skip(management_frame_size());
|
||||
stream.read(_body);
|
||||
stream.read(body_);
|
||||
parse_tagged_parameters(stream);
|
||||
}
|
||||
|
||||
void Dot11ReAssocRequest::listen_interval(uint16_t new_listen_interval) {
|
||||
this->_body.listen_interval = Endian::host_to_le(new_listen_interval);
|
||||
body_.listen_interval = Endian::host_to_le(new_listen_interval);
|
||||
}
|
||||
|
||||
void Dot11ReAssocRequest::current_ap(const address_type &new_current_ap) {
|
||||
new_current_ap.copy(_body.current_ap);
|
||||
void Dot11ReAssocRequest::current_ap(const address_type& new_current_ap) {
|
||||
new_current_ap.copy(body_.current_ap);
|
||||
}
|
||||
|
||||
uint32_t Dot11ReAssocRequest::header_size() const {
|
||||
return Dot11ManagementFrame::header_size() + sizeof(this->_body);
|
||||
return Dot11ManagementFrame::header_size() + sizeof(body_);
|
||||
}
|
||||
|
||||
void Dot11ReAssocRequest::write_fixed_parameters(OutputMemoryStream& stream) {
|
||||
stream.write(_body);
|
||||
stream.write(body_);
|
||||
}
|
||||
|
||||
/* ReAssoc response. */
|
||||
// ReAssoc response
|
||||
|
||||
Dot11ReAssocResponse::Dot11ReAssocResponse(const address_type &dst_hw_addr,
|
||||
const address_type &src_hw_addr)
|
||||
: Dot11ManagementFrame(dst_hw_addr, src_hw_addr)
|
||||
{
|
||||
this->subtype(Dot11::REASSOC_RESP);
|
||||
memset(&_body, 0, sizeof(_body));
|
||||
Dot11ReAssocResponse::Dot11ReAssocResponse(const address_type& dst_hw_addr,
|
||||
const address_type& src_hw_addr)
|
||||
: Dot11ManagementFrame(dst_hw_addr, src_hw_addr), body_() {
|
||||
subtype(Dot11::REASSOC_RESP);
|
||||
}
|
||||
|
||||
Dot11ReAssocResponse::Dot11ReAssocResponse(const uint8_t *buffer, uint32_t total_sz)
|
||||
Dot11ReAssocResponse::Dot11ReAssocResponse(const uint8_t* buffer, uint32_t total_sz)
|
||||
: Dot11ManagementFrame(buffer, total_sz) {
|
||||
InputMemoryStream stream(buffer, total_sz);
|
||||
stream.skip(management_frame_size());
|
||||
stream.read(_body);
|
||||
stream.read(body_);
|
||||
parse_tagged_parameters(stream);
|
||||
}
|
||||
|
||||
void Dot11ReAssocResponse::status_code(uint16_t new_status_code) {
|
||||
this->_body.status_code = Endian::host_to_le(new_status_code);
|
||||
body_.status_code = Endian::host_to_le(new_status_code);
|
||||
}
|
||||
|
||||
void Dot11ReAssocResponse::aid(uint16_t new_aid) {
|
||||
this->_body.aid = Endian::host_to_le(new_aid);
|
||||
body_.aid = Endian::host_to_le(new_aid);
|
||||
}
|
||||
|
||||
uint32_t Dot11ReAssocResponse::header_size() const {
|
||||
return Dot11ManagementFrame::header_size() + sizeof(this->_body);
|
||||
return Dot11ManagementFrame::header_size() + sizeof(body_);
|
||||
}
|
||||
|
||||
void Dot11ReAssocResponse::write_fixed_parameters(OutputMemoryStream& stream) {
|
||||
stream.write(_body);
|
||||
stream.write(body_);
|
||||
}
|
||||
} // namespace Tins
|
||||
|
||||
} // Tins
|
||||
|
||||
#endif // HAVE_DOT11
|
||||
|
||||
Reference in New Issue
Block a user