Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,8 @@ enum eActionOp_BML: uint8_t {
ACTION_BML_NW_MAP_UPDATE = 0x1e,
ACTION_BML_STATS_UPDATE = 0x1f,
ACTION_BML_EVENTS_UPDATE = 0x20,
ACTION_BML_OREN_REVERSE_STR_REQUEST = 0x29,
ACTION_BML_OREN_REVERSE_STR_RESPONSE = 0x2a,
ACTION_BML_SET_LEGACY_CLIENT_ROAMING_REQUEST = 0x38,
ACTION_BML_SET_LEGACY_CLIENT_ROAMING_RESPONSE = 0x39,
ACTION_BML_GET_LEGACY_CLIENT_ROAMING_REQUEST = 0x3a,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1798,6 +1798,64 @@ class cACTION_BML_UNREGISTER_TOPOLOGY_QUERY : public BaseClass
eActionOp_BML* m_action_op = nullptr;
};

class cACTION_BML_OREN_REVERSE_STR_REQUEST : public BaseClass
{
public:
cACTION_BML_OREN_REVERSE_STR_REQUEST(uint8_t* buff, size_t buff_len, bool parse = false);
explicit cACTION_BML_OREN_REVERSE_STR_REQUEST(std::shared_ptr<BaseClass> base, bool parse = false);
~cACTION_BML_OREN_REVERSE_STR_REQUEST();

static eActionOp_BML get_action_op(){
return (eActionOp_BML)(ACTION_BML_OREN_REVERSE_STR_REQUEST);
}
uint32_t& buffer_size();
std::string buffer_str();
char* buffer(size_t length = 0);
bool set_buffer(const std::string& str);
bool set_buffer(const char buffer[], size_t size);
bool alloc_buffer(size_t count = 1);
void class_swap() override;
bool finalize() override;
static size_t get_initial_size();

private:
bool init();
eActionOp_BML* m_action_op = nullptr;
uint32_t* m_buffer_size = nullptr;
char* m_buffer = nullptr;
size_t m_buffer_idx__ = 0;
int m_lock_order_counter__ = 0;
};

class cACTION_BML_OREN_REVERSE_STR_RESPONSE : public BaseClass
{
public:
cACTION_BML_OREN_REVERSE_STR_RESPONSE(uint8_t* buff, size_t buff_len, bool parse = false);
explicit cACTION_BML_OREN_REVERSE_STR_RESPONSE(std::shared_ptr<BaseClass> base, bool parse = false);
~cACTION_BML_OREN_REVERSE_STR_RESPONSE();

static eActionOp_BML get_action_op(){
return (eActionOp_BML)(ACTION_BML_OREN_REVERSE_STR_RESPONSE);
}
uint32_t& buffer_size();
std::string buffer_str();
char* buffer(size_t length = 0);
bool set_buffer(const std::string& str);
bool set_buffer(const char buffer[], size_t size);
bool alloc_buffer(size_t count = 1);
void class_swap() override;
bool finalize() override;
static size_t get_initial_size();

private:
bool init();
eActionOp_BML* m_action_op = nullptr;
uint32_t* m_buffer_size = nullptr;
char* m_buffer = nullptr;
size_t m_buffer_idx__ = 0;
int m_lock_order_counter__ = 0;
};

class cACTION_BML_TRIGGER_CHANNEL_SELECTION_REQUEST : public BaseClass
{
public:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6117,6 +6117,262 @@ bool cACTION_BML_UNREGISTER_TOPOLOGY_QUERY::init()
return true;
}

cACTION_BML_OREN_REVERSE_STR_REQUEST::cACTION_BML_OREN_REVERSE_STR_REQUEST(uint8_t* buff, size_t buff_len, bool parse) :
BaseClass(buff, buff_len, parse) {
m_init_succeeded = init();
}
cACTION_BML_OREN_REVERSE_STR_REQUEST::cACTION_BML_OREN_REVERSE_STR_REQUEST(std::shared_ptr<BaseClass> base, bool parse) :
BaseClass(base->getBuffPtr(), base->getBuffRemainingBytes(), parse){
m_init_succeeded = init();
}
cACTION_BML_OREN_REVERSE_STR_REQUEST::~cACTION_BML_OREN_REVERSE_STR_REQUEST() {
}
uint32_t& cACTION_BML_OREN_REVERSE_STR_REQUEST::buffer_size() {
return (uint32_t&)(*m_buffer_size);
}

std::string cACTION_BML_OREN_REVERSE_STR_REQUEST::buffer_str() {
char *buffer_ = buffer();
if (!buffer_) { return std::string(); }
return std::string(buffer_, m_buffer_idx__);
}

char* cACTION_BML_OREN_REVERSE_STR_REQUEST::buffer(size_t length) {
if( (m_buffer_idx__ == 0) || (m_buffer_idx__ < length) ) {
TLVF_LOG(ERROR) << "buffer length is smaller than requested length";
return nullptr;
}
return ((char*)m_buffer);
}

bool cACTION_BML_OREN_REVERSE_STR_REQUEST::set_buffer(const std::string& str) { return set_buffer(str.c_str(), str.size()); }
bool cACTION_BML_OREN_REVERSE_STR_REQUEST::set_buffer(const char str[], size_t size) {
if (str == nullptr) {
TLVF_LOG(WARNING) << "set_buffer received a null pointer.";
return false;
}
if (!alloc_buffer(size)) { return false; }
std::copy(str, str + size, m_buffer);
return true;
}
bool cACTION_BML_OREN_REVERSE_STR_REQUEST::alloc_buffer(size_t count) {
if (m_lock_order_counter__ > 0) {;
TLVF_LOG(ERROR) << "Out of order allocation for variable length list buffer, abort!";
return false;
}
size_t len = sizeof(char) * count;
if(getBuffRemainingBytes() < len ) {
TLVF_LOG(ERROR) << "Not enough available space on buffer - can't allocate";
return false;
}
m_lock_order_counter__ = 0;
uint8_t *src = (uint8_t *)&m_buffer[*m_buffer_size];
uint8_t *dst = src + len;
if (!m_parse__) {
size_t move_length = getBuffRemainingBytes(src) - len;
std::copy_n(src, move_length, dst);
}
m_buffer_idx__ += count;
*m_buffer_size += count;
if (!buffPtrIncrementSafe(len)) {
LOG(ERROR) << "buffPtrIncrementSafe(" << std::dec << len << ") Failed!";
return false;
}
return true;
}

void cACTION_BML_OREN_REVERSE_STR_REQUEST::class_swap()
{
tlvf_swap(8*sizeof(eActionOp_BML), reinterpret_cast<uint8_t*>(m_action_op));
tlvf_swap(32, reinterpret_cast<uint8_t*>(m_buffer_size));
}

bool cACTION_BML_OREN_REVERSE_STR_REQUEST::finalize()
{
if (m_parse__) {
TLVF_LOG(DEBUG) << "finalize() called but m_parse__ is set";
return true;
}
if (m_finalized__) {
TLVF_LOG(DEBUG) << "finalize() called for already finalized class";
return true;
}
if (!isPostInitSucceeded()) {
TLVF_LOG(ERROR) << "post init check failed";
return false;
}
if (m_inner__) {
if (!m_inner__->finalize()) {
TLVF_LOG(ERROR) << "m_inner__->finalize() failed";
return false;
}
auto tailroom = m_inner__->getMessageBuffLength() - m_inner__->getMessageLength();
m_buff_ptr__ -= tailroom;
}
class_swap();
m_finalized__ = true;
return true;
}

size_t cACTION_BML_OREN_REVERSE_STR_REQUEST::get_initial_size()
{
size_t class_size = 0;
class_size += sizeof(uint32_t); // buffer_size
return class_size;
}

bool cACTION_BML_OREN_REVERSE_STR_REQUEST::init()
{
if (getBuffRemainingBytes() < get_initial_size()) {
TLVF_LOG(ERROR) << "Not enough available space on buffer. Class init failed";
return false;
}
m_buffer_size = reinterpret_cast<uint32_t*>(m_buff_ptr__);
if (!m_parse__) *m_buffer_size = 0;
if (!buffPtrIncrementSafe(sizeof(uint32_t))) {
LOG(ERROR) << "buffPtrIncrementSafe(" << std::dec << sizeof(uint32_t) << ") Failed!";
return false;
}
m_buffer = (char*)m_buff_ptr__;
uint32_t buffer_size = *m_buffer_size;
if (m_parse__) { tlvf_swap(32, reinterpret_cast<uint8_t*>(&buffer_size)); }
m_buffer_idx__ = buffer_size;
if (!buffPtrIncrementSafe(sizeof(char) * (buffer_size))) {
LOG(ERROR) << "buffPtrIncrementSafe(" << std::dec << sizeof(char) * (buffer_size) << ") Failed!";
return false;
}
if (m_parse__) { class_swap(); }
return true;
}

cACTION_BML_OREN_REVERSE_STR_RESPONSE::cACTION_BML_OREN_REVERSE_STR_RESPONSE(uint8_t* buff, size_t buff_len, bool parse) :
BaseClass(buff, buff_len, parse) {
m_init_succeeded = init();
}
cACTION_BML_OREN_REVERSE_STR_RESPONSE::cACTION_BML_OREN_REVERSE_STR_RESPONSE(std::shared_ptr<BaseClass> base, bool parse) :
BaseClass(base->getBuffPtr(), base->getBuffRemainingBytes(), parse){
m_init_succeeded = init();
}
cACTION_BML_OREN_REVERSE_STR_RESPONSE::~cACTION_BML_OREN_REVERSE_STR_RESPONSE() {
}
uint32_t& cACTION_BML_OREN_REVERSE_STR_RESPONSE::buffer_size() {
return (uint32_t&)(*m_buffer_size);
}

std::string cACTION_BML_OREN_REVERSE_STR_RESPONSE::buffer_str() {
char *buffer_ = buffer();
if (!buffer_) { return std::string(); }
return std::string(buffer_, m_buffer_idx__);
}

char* cACTION_BML_OREN_REVERSE_STR_RESPONSE::buffer(size_t length) {
if( (m_buffer_idx__ == 0) || (m_buffer_idx__ < length) ) {
TLVF_LOG(ERROR) << "buffer length is smaller than requested length";
return nullptr;
}
return ((char*)m_buffer);
}

bool cACTION_BML_OREN_REVERSE_STR_RESPONSE::set_buffer(const std::string& str) { return set_buffer(str.c_str(), str.size()); }
bool cACTION_BML_OREN_REVERSE_STR_RESPONSE::set_buffer(const char str[], size_t size) {
if (str == nullptr) {
TLVF_LOG(WARNING) << "set_buffer received a null pointer.";
return false;
}
if (!alloc_buffer(size)) { return false; }
std::copy(str, str + size, m_buffer);
return true;
}
bool cACTION_BML_OREN_REVERSE_STR_RESPONSE::alloc_buffer(size_t count) {
if (m_lock_order_counter__ > 0) {;
TLVF_LOG(ERROR) << "Out of order allocation for variable length list buffer, abort!";
return false;
}
size_t len = sizeof(char) * count;
if(getBuffRemainingBytes() < len ) {
TLVF_LOG(ERROR) << "Not enough available space on buffer - can't allocate";
return false;
}
m_lock_order_counter__ = 0;
uint8_t *src = (uint8_t *)&m_buffer[*m_buffer_size];
uint8_t *dst = src + len;
if (!m_parse__) {
size_t move_length = getBuffRemainingBytes(src) - len;
std::copy_n(src, move_length, dst);
}
m_buffer_idx__ += count;
*m_buffer_size += count;
if (!buffPtrIncrementSafe(len)) {
LOG(ERROR) << "buffPtrIncrementSafe(" << std::dec << len << ") Failed!";
return false;
}
return true;
}

void cACTION_BML_OREN_REVERSE_STR_RESPONSE::class_swap()
{
tlvf_swap(8*sizeof(eActionOp_BML), reinterpret_cast<uint8_t*>(m_action_op));
tlvf_swap(32, reinterpret_cast<uint8_t*>(m_buffer_size));
}

bool cACTION_BML_OREN_REVERSE_STR_RESPONSE::finalize()
{
if (m_parse__) {
TLVF_LOG(DEBUG) << "finalize() called but m_parse__ is set";
return true;
}
if (m_finalized__) {
TLVF_LOG(DEBUG) << "finalize() called for already finalized class";
return true;
}
if (!isPostInitSucceeded()) {
TLVF_LOG(ERROR) << "post init check failed";
return false;
}
if (m_inner__) {
if (!m_inner__->finalize()) {
TLVF_LOG(ERROR) << "m_inner__->finalize() failed";
return false;
}
auto tailroom = m_inner__->getMessageBuffLength() - m_inner__->getMessageLength();
m_buff_ptr__ -= tailroom;
}
class_swap();
m_finalized__ = true;
return true;
}

size_t cACTION_BML_OREN_REVERSE_STR_RESPONSE::get_initial_size()
{
size_t class_size = 0;
class_size += sizeof(uint32_t); // buffer_size
return class_size;
}

bool cACTION_BML_OREN_REVERSE_STR_RESPONSE::init()
{
if (getBuffRemainingBytes() < get_initial_size()) {
TLVF_LOG(ERROR) << "Not enough available space on buffer. Class init failed";
return false;
}
m_buffer_size = reinterpret_cast<uint32_t*>(m_buff_ptr__);
if (!m_parse__) *m_buffer_size = 0;
if (!buffPtrIncrementSafe(sizeof(uint32_t))) {
LOG(ERROR) << "buffPtrIncrementSafe(" << std::dec << sizeof(uint32_t) << ") Failed!";
return false;
}
m_buffer = (char*)m_buff_ptr__;
uint32_t buffer_size = *m_buffer_size;
if (m_parse__) { tlvf_swap(32, reinterpret_cast<uint8_t*>(&buffer_size)); }
m_buffer_idx__ = buffer_size;
if (!buffPtrIncrementSafe(sizeof(char) * (buffer_size))) {
LOG(ERROR) << "buffPtrIncrementSafe(" << std::dec << sizeof(char) * (buffer_size) << ") Failed!";
return false;
}
if (m_parse__) { class_swap(); }
return true;
}

cACTION_BML_TRIGGER_CHANNEL_SELECTION_REQUEST::cACTION_BML_TRIGGER_CHANNEL_SELECTION_REQUEST(uint8_t* buff, size_t buff_len, bool parse) :
BaseClass(buff, buff_len, parse) {
m_init_succeeded = init();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,10 @@ eActionOp_BML:
ACTION_BML_NW_MAP_UPDATE: 30
ACTION_BML_STATS_UPDATE: 31
ACTION_BML_EVENTS_UPDATE: 32
#================================================
ACTION_BML_OREN_REVERSE_STR_REQUEST: 41
ACTION_BML_OREN_REVERSE_STR_RESPONSE: 42
#================================================

ACTION_BML_SET_LEGACY_CLIENT_ROAMING_REQUEST: 56
ACTION_BML_SET_LEGACY_CLIENT_ROAMING_RESPONSE: 57
Expand Down
22 changes: 22 additions & 0 deletions common/beerocks/tlvf/yaml/beerocks/tlvf/beerocks_message_bml.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,28 @@ cACTION_BML_REGISTER_TOPOLOGY_QUERY:
cACTION_BML_UNREGISTER_TOPOLOGY_QUERY:
_type: class

#================================================
cACTION_BML_OREN_REVERSE_STR_REQUEST:
_type: class
buffer_size:
_type: uint32_t
_length_var: True
buffer:
_type: char
_length: [buffer_size]
#================================================

#================================================
cACTION_BML_OREN_REVERSE_STR_RESPONSE:
_type: class
buffer_size:
_type: uint32_t
_length_var: True
buffer:
_type: char
_length: [buffer_size]
#================================================

cACTION_BML_TRIGGER_CHANNEL_SELECTION_REQUEST:
_type: class
al_mac: sMacAddr
Expand Down
Loading