mirror of
https://github.com/mfontanini/libtins
synced 2026-01-23 02:35:57 +01:00
Add Exception for fields that are not present in RadioTap frames.
This commit is contained in:
@@ -5,14 +5,14 @@
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following disclaimer
|
||||
* in the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
@@ -55,7 +55,7 @@ class malformed_packet : public std::runtime_error {
|
||||
public:
|
||||
malformed_packet()
|
||||
: std::runtime_error(std::string()) { }
|
||||
|
||||
|
||||
const char* what() const throw() {
|
||||
return "Malformed packet";
|
||||
}
|
||||
@@ -68,7 +68,7 @@ class pdu_not_found : public std::runtime_error {
|
||||
public:
|
||||
pdu_not_found()
|
||||
: std::runtime_error(std::string()) { }
|
||||
|
||||
|
||||
const char* what() const throw() {
|
||||
return "PDU not found";
|
||||
}
|
||||
@@ -82,18 +82,30 @@ class invalid_interface : public std::runtime_error {
|
||||
public:
|
||||
invalid_interface()
|
||||
: std::runtime_error(std::string()) { }
|
||||
|
||||
|
||||
const char* what() const throw() {
|
||||
return "Invalid interface";
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* \brief Exception thrown when a field is not present in frame.
|
||||
*/
|
||||
class field_not_present : public std::runtime_error {
|
||||
public:
|
||||
field_not_present()
|
||||
: std::runtime_error(std::string()) { }
|
||||
const char* what() const throw() {
|
||||
return "Field not present";
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* \brief Exception thrown when PacketSender fails to open a socket.
|
||||
*/
|
||||
class socket_open_error : public std::runtime_error {
|
||||
public:
|
||||
socket_open_error(const std::string &msg)
|
||||
socket_open_error(const std::string &msg)
|
||||
: std::runtime_error(msg) { }
|
||||
};
|
||||
|
||||
@@ -102,7 +114,7 @@ public:
|
||||
*/
|
||||
class socket_close_error : public std::runtime_error {
|
||||
public:
|
||||
socket_close_error(const std::string &msg)
|
||||
socket_close_error(const std::string &msg)
|
||||
: std::runtime_error(msg) { }
|
||||
};
|
||||
|
||||
@@ -111,7 +123,7 @@ public:
|
||||
*/
|
||||
class socket_write_error : public std::runtime_error {
|
||||
public:
|
||||
socket_write_error(const std::string &msg)
|
||||
socket_write_error(const std::string &msg)
|
||||
: std::runtime_error(msg) { }
|
||||
};
|
||||
|
||||
@@ -127,7 +139,7 @@ public:
|
||||
};
|
||||
|
||||
/**
|
||||
* \brief Exception thrown when an unkown link layer PDU type is
|
||||
* \brief Exception thrown when an unkown link layer PDU type is
|
||||
* found while sniffing.
|
||||
*/
|
||||
class unknown_link_type : public std::exception {
|
||||
|
||||
@@ -220,91 +220,91 @@ namespace Tins {
|
||||
* \brief Getter for the version field.
|
||||
* \return The version field.
|
||||
*/
|
||||
uint8_t version() const { return _radio.it_version; }
|
||||
uint8_t version() const;
|
||||
|
||||
/**
|
||||
* \brief Getter for the padding field.
|
||||
* \return The padding field.
|
||||
*/
|
||||
uint8_t padding() const { return _radio.it_pad; }
|
||||
uint8_t padding() const;
|
||||
|
||||
/**
|
||||
* \brief Getter for the length field.
|
||||
* \return The length field.
|
||||
*/
|
||||
uint16_t length() const { return Endian::le_to_host(_radio.it_len); }
|
||||
uint16_t length() const;
|
||||
|
||||
/**
|
||||
* \brief Getter for the tsft field.
|
||||
* \return The tsft field.
|
||||
*/
|
||||
uint64_t tsft() const { return Endian::le_to_host(_tsft); }
|
||||
uint64_t tsft() const;
|
||||
|
||||
/**
|
||||
* \brief Getter for the flags field.
|
||||
* \return The flags field.
|
||||
*/
|
||||
FrameFlags flags() const { return (FrameFlags)_flags; }
|
||||
FrameFlags flags() const;
|
||||
|
||||
/**
|
||||
* \brief Getter for the rate field.
|
||||
* \return The rate field.
|
||||
*/
|
||||
uint8_t rate() const { return _rate; }
|
||||
uint8_t rate() const;
|
||||
|
||||
/**
|
||||
* \brief Getter for the channel frequency field.
|
||||
* \return The channel frequency field.
|
||||
*/
|
||||
uint16_t channel_freq() const { return Endian::le_to_host(_channel_freq); }
|
||||
uint16_t channel_freq() const;
|
||||
|
||||
/**
|
||||
* \brief Getter for the channel type field.
|
||||
* \return The channel type field.
|
||||
*/
|
||||
uint16_t channel_type() const { return Endian::le_to_host(_channel_type); }
|
||||
uint16_t channel_type() const;
|
||||
|
||||
/**
|
||||
* \brief Getter for the dbm signal field.
|
||||
* \return The dbm signal field.
|
||||
*/
|
||||
uint8_t dbm_signal() const { return _dbm_signal; }
|
||||
uint8_t dbm_signal() const;
|
||||
|
||||
/**
|
||||
* \brief Getter for the dbm noise field.
|
||||
* \return The dbm noise field.
|
||||
*/
|
||||
uint8_t dbm_noise() const { return _dbm_noise; }
|
||||
uint8_t dbm_noise() const;
|
||||
|
||||
/**
|
||||
* \brief Getter for the signal quality field.
|
||||
* \return The signal quality field.
|
||||
*/
|
||||
uint16_t signal_quality() const { return _signal_quality; }
|
||||
uint16_t signal_quality() const;
|
||||
|
||||
/**
|
||||
* \brief Getter for the antenna field.
|
||||
* \return The antenna field.
|
||||
*/
|
||||
uint8_t antenna() const { return _antenna; }
|
||||
uint8_t antenna() const;
|
||||
|
||||
/**
|
||||
* \brief Getter for the db signal field.
|
||||
* \return The db signal field.
|
||||
*/
|
||||
uint8_t db_signal() const { return _db_signal; }
|
||||
uint8_t db_signal() const;
|
||||
|
||||
/**
|
||||
* \brief Getter for the channel+ field.
|
||||
* \return The channel+ field.
|
||||
*/
|
||||
uint32_t channel_plus() const { return Endian::le_to_host<uint32_t>(_channel_type); }
|
||||
uint32_t channel_plus() const;
|
||||
|
||||
/**
|
||||
* \brief Getter for the rx flags field.
|
||||
* \return The rx flags field.
|
||||
*/
|
||||
uint16_t rx_flags() const { return Endian::le_to_host(_rx_flags); }
|
||||
uint16_t rx_flags() const;
|
||||
|
||||
/**
|
||||
* \brief Getter for the present bit fields.
|
||||
|
||||
Reference in New Issue
Block a user