Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Partial Neighbor Scan Functionality #124

Merged
merged 2 commits into from
Jan 13, 2025
Merged
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
165 changes: 165 additions & 0 deletions diff.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
diff --git a/src/agent/em_agent.cpp b/src/agent/em_agent.cpp
index db545d0..665b441 100644
--- a/src/agent/em_agent.cpp
+++ b/src/agent/em_agent.cpp
@@ -635,6 +635,7 @@ em_t *em_agent_t::find_em_for_msg_type(unsigned char *data, unsigned int len, em
em = (em_t *)hash_map_get_next(m_em_map, em);
}
break;
+
case em_msg_type_channel_pref_query:
if (em_msg_t(data + (sizeof(em_raw_hdr_t) + sizeof(em_cmdu_t)),
len - (sizeof(em_raw_hdr_t) + sizeof(em_cmdu_t))).get_radio_id(&ruid) == false) {
@@ -738,6 +739,8 @@ em_t *em_agent_t::find_em_for_msg_type(unsigned char *data, unsigned int len, em
break;

case em_msg_type_1905_ack:
+ case em_msg_type_map_policy_config_req:
+ case em_msg_type_channel_scan_req:
break;

default:
diff --git a/src/cli/em_cli.cpp b/src/cli/em_cli.cpp
index 5f150e6..620b46a 100644
--- a/src/cli/em_cli.cpp
+++ b/src/cli/em_cli.cpp
@@ -71,12 +71,12 @@ em_network_node_t *em_cli_t::get_reset_tree(char *platform)
dm.init();
dm.decode_config(subdoc, "Reset");

- if (dm_easy_mesh_t::mac_address_from_name("ens160", al_mac) != 0) {
+ if (dm_easy_mesh_t::mac_address_from_name(interface, al_mac) != 0) {
return NULL;
}

dm.set_ctrl_al_interface_mac(al_mac);
- dm.set_ctrl_al_interface_name("ens160");
+ dm.set_ctrl_al_interface_name(interface);

//dm.print_config();

diff --git a/src/cli/main.go b/src/cli/main.go
index 67a5082..f078a93 100644
--- a/src/cli/main.go
+++ b/src/cli/main.go
@@ -556,7 +556,7 @@ func (m model) View() string {
end = start + m.viewHeight
}

- spew.Fprintf(m.dump, "start: %d end: %d\n", start, end)
+ //spew.Fprintf(m.dump, "start: %d end: %d\n", start, end)

styledContent := jsonStyle.Width(m.viewWidth).Height(m.viewHeight).Render(strings.Join(m.scrollContent[start:end], "\n"))
statusView = styledContent + m.currentOperatingInstructions
diff --git a/src/cmd/em_cmd_em_config.cpp b/src/cmd/em_cmd_em_config.cpp
index d23d74d..0de04bd 100644
--- a/src/cmd/em_cmd_em_config.cpp
+++ b/src/cmd/em_cmd_em_config.cpp
@@ -50,7 +50,7 @@ em_cmd_em_config_t::em_cmd_em_config_t(em_cmd_params_t param, dm_easy_mesh_t& dm
memset((unsigned char *)&m_orch_desc[0], 0, EM_MAX_CMD*sizeof(em_orch_desc_t));

m_orch_op_idx = 0;
- m_num_orch_desc = 4;
+ m_num_orch_desc = 6;
m_orch_desc[0].op = dm_orch_type_topo_sync;
m_orch_desc[0].submit = true;
m_orch_desc[1].op = dm_orch_type_channel_pref;
@@ -59,6 +59,11 @@ em_cmd_em_config_t::em_cmd_em_config_t(em_cmd_params_t param, dm_easy_mesh_t& dm
m_orch_desc[2].submit = true;
m_orch_desc[3].op = dm_orch_type_channel_cnf;
m_orch_desc[3].submit = true;
+ m_orch_desc[4].op = dm_orch_type_policy_cfg;
+ m_orch_desc[4].submit = true;
+ m_orch_desc[5].op = dm_orch_type_channel_scan_req;
+ m_orch_desc[5].submit = true;
+

strncpy(m_name, "em_config", strlen("em_config") + 1);
m_svc = em_service_type_ctrl;
diff --git a/src/em/channel/em_channel.cpp b/src/em/channel/em_channel.cpp
index 7fafddc..03c623d 100644
--- a/src/em/channel/em_channel.cpp
+++ b/src/em/channel/em_channel.cpp
@@ -111,13 +111,13 @@ short em_channel_t::create_channel_scan_req_tlv(unsigned char *buff)
memcpy(req->ruid, get_radio_interface_mac(), sizeof(mac_address_t));
len += sizeof(em_channel_scan_req_t);

+ req_op_class = req->op_class;
for (i = 0; i < dm->get_num_op_class(); i++) {
opclass = &dm->m_op_class[i];
if (opclass->m_op_class_info.id.type != em_op_class_type_scan_param) {
continue;
}

- req_op_class = &req->op_class[req->num_op_classes];
req_op_class->op_class = opclass->m_op_class_info.op_class;
req_op_class->num_channels = opclass->m_op_class_info.num_channels;

@@ -128,9 +128,9 @@ short em_channel_t::create_channel_scan_req_tlv(unsigned char *buff)
len += (sizeof(em_channel_scan_req_op_class_t) + req_op_class->num_channels*sizeof(unsigned char));

req->num_op_classes++;
+ req_op_class = (em_channel_scan_req_op_class_t *)((unsigned char *)req_op_class + sizeof(em_channel_scan_req_op_class_t) + req_op_class->num_channels*sizeof(unsigned char));
}

- printf("%s:%d: Length: %d\n", __func__, __LINE__, len);
return len;
}

diff --git a/src/em/em.cpp b/src/em/em.cpp
index f517dcb..a2e676b 100644
--- a/src/em/em.cpp
+++ b/src/em/em.cpp
@@ -106,6 +106,10 @@ void em_t::orch_execute(em_cmd_t *pcmd)
m_sm.set_state(em_state_ctrl_channel_select_pending);
} else if ((pcmd->get_orch_op() == dm_orch_type_channel_cnf) && (m_sm.get_state() == em_state_ctrl_channel_selected)) {
m_sm.set_state(em_state_ctrl_channel_cnf_pending);
+ } else if ((pcmd->get_orch_op() == dm_orch_type_policy_cfg) && (m_sm.get_state() == em_state_ctrl_configured)) {
+ m_sm.set_state(em_state_ctrl_set_policy_pending);
+ } else if ((pcmd->get_orch_op() == dm_orch_type_channel_scan_req) && (m_sm.get_state() == em_state_ctrl_configured)) {
+ m_sm.set_state(em_state_ctrl_channel_scan_pending);
}
break;

@@ -316,6 +320,7 @@ void em_t::handle_ctrl_state()
case em_cmd_type_set_channel:
em_configuration_t::process_ctrl_state();
em_channel_t::process_ctrl_state();
+ em_policy_cfg_t::process_ctrl_state();
break;

case em_cmd_type_scan_channel:
diff --git a/src/em/em_mgr.cpp b/src/em/em_mgr.cpp
index 23f1e02..7add496 100644
--- a/src/em/em_mgr.cpp
+++ b/src/em/em_mgr.cpp
@@ -283,14 +283,14 @@ void em_mgr_t::nodes_listener()
unsigned char buff[MAX_EM_BUFF_SZ];
em_raw_hdr_t *hdr;

- tm.tv_sec = m_timeout;
- tm.tv_usec = 0;
+ tm.tv_sec = 0;
+ tm.tv_usec = m_timeout * 1000;
highest_fd = reset_listeners();

while ((rc = select(highest_fd + 1, &m_rset, NULL, NULL, &tm)) >= 0) {
if (rc == 0) {
- tm.tv_sec = m_timeout;
- tm.tv_usec = 0;
+ tm.tv_sec = 0;
+ tm.tv_usec = m_timeout * 1000;
highest_fd = reset_listeners();

continue;
@@ -315,8 +315,8 @@ void em_mgr_t::nodes_listener()
em = (em_t *)hash_map_get_next(m_em_map, em);
}

- tm.tv_sec = m_timeout;
- tm.tv_usec = 0;
+ tm.tv_sec = 0;
+ tm.tv_usec = m_timeout * 1000;
highest_fd = reset_listeners();

}
46 changes: 46 additions & 0 deletions inc/dm_scan_result.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/**
* Copyright 2023 Comcast Cable Communications Management, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* SPDX-License-Identifier: Apache-2.0
*/

#ifndef DM_SCAN_RESULT_H
#define DM_SCAN_RESULT_H

#include "em_base.h"

class dm_scan_result_t {
public:
em_scan_result_t m_scan_result;

public:
int init() { memset(&m_scan_result, 0, sizeof(em_scan_result_t)); return 0; }
em_scan_result_t *get_scan_result() { return &m_scan_result; }
int decode(const cJSON *obj, void *parent_id);
void encode(cJSON *obj, em_scan_result_id_t id);

bool operator == (const dm_scan_result_t& obj);
void operator = (const dm_scan_result_t& obj);

static int parse_scan_result_id_from_key(const char *key, em_scan_result_id_t *id);

dm_scan_result_t(em_scan_result_t *scan_result);
dm_scan_result_t(const dm_scan_result_t& scan_result);
dm_scan_result_t(const em_scan_result_t& scan_result);
dm_scan_result_t();
~dm_scan_result_t();
};

#endif
53 changes: 53 additions & 0 deletions inc/dm_scan_result_list.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/**
* Copyright 2023 Comcast Cable Communications Management, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* SPDX-License-Identifier: Apache-2.0
*/

#ifndef DM_SCAN_RESULT_LIST_H
#define DM_SCAN_RESULT_LIST_H

#include "em_base.h"
#include "dm_scan_result.h"
#include "db_easy_mesh.h"

class dm_easy_mesh_t;
class dm_scan_result_list_t : public dm_scan_result_t, public db_easy_mesh_t {

public:
int init();

dm_orch_type_t get_dm_orch_type(db_client_t& db_client, const dm_scan_result_t& scan_result);
void update_list(const dm_scan_result_t& scan_result, dm_orch_type_t op);
void delete_list();

void init_table();
void init_columns();
int sync_db(db_client_t& db_client, void *ctx);
int update_db(db_client_t& db_client, dm_orch_type_t op, void *data = NULL);
bool search_db(db_client_t& db_client, void *ctx, void *key);
bool operator == (const db_easy_mesh_t& obj);
int set_config(db_client_t& db_client, const cJSON *obj, void *parent_id);
int set_config(db_client_t& db_client, dm_scan_result_t& scan_result, void *parent_id);
int get_config(cJSON *obj, void *parent_id, bool summary = false);

virtual dm_scan_result_t *get_first_scan_result() = 0;
virtual dm_scan_result_t *get_next_scan_result(dm_scan_result_t *scan_result) = 0;
virtual dm_scan_result_t *get_scan_result(const char *key) = 0;
virtual void remove_scan_result(const char *key) = 0;
virtual void put_scan_result(const char *key, const dm_scan_result_t *scan_result) = 0;
};

#endif
30 changes: 30 additions & 0 deletions inc/em_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -641,6 +641,36 @@ typedef struct {
unsigned char timestamp[0];
}__attribute__((__packed__)) em_timestamp_t;

typedef struct {
em_long_string_t net_id;
mac_address_t dev_mac;
em_radio_id_t ruid;
unsigned char op_class;
unsigned char channel;
bssid_t bssid;
} em_scan_result_id_t;

typedef struct {
bssid_t bssid;
ssid_t ssid;
signed char signal_strength;
wifi_channelBandwidth_t bandwidth;
unsigned char bss_color;
unsigned char channel_util;
unsigned short sta_count;
unsigned int aggr_scan_duration;
unsigned char scan_type;
} em_neighbor_t;

typedef struct {
em_scan_result_id_t id;
unsigned char scan_status;
em_long_string_t timestamp;
unsigned char util;
unsigned char noise;
em_neighbor_t neighbor;
} em_scan_result_t;

typedef struct {
em_radio_id_t ruid;
unsigned char op_class;
Expand Down
3 changes: 3 additions & 0 deletions src/agent/em_agent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -635,6 +635,7 @@ em_t *em_agent_t::find_em_for_msg_type(unsigned char *data, unsigned int len, em
em = (em_t *)hash_map_get_next(m_em_map, em);
}
break;

case em_msg_type_channel_pref_query:
if (em_msg_t(data + (sizeof(em_raw_hdr_t) + sizeof(em_cmdu_t)),
len - (sizeof(em_raw_hdr_t) + sizeof(em_cmdu_t))).get_radio_id(&ruid) == false) {
Expand Down Expand Up @@ -738,6 +739,8 @@ em_t *em_agent_t::find_em_for_msg_type(unsigned char *data, unsigned int len, em
break;

case em_msg_type_1905_ack:
case em_msg_type_map_policy_config_req:
case em_msg_type_channel_scan_req:
break;

default:
Expand Down
4 changes: 2 additions & 2 deletions src/cli/em_cli.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,12 @@ em_network_node_t *em_cli_t::get_reset_tree(char *platform)
dm.init();
dm.decode_config(subdoc, "Reset");

if (dm_easy_mesh_t::mac_address_from_name("ens160", al_mac) != 0) {
if (dm_easy_mesh_t::mac_address_from_name(interface, al_mac) != 0) {
return NULL;
}

dm.set_ctrl_al_interface_mac(al_mac);
dm.set_ctrl_al_interface_name("ens160");
dm.set_ctrl_al_interface_name(interface);

//dm.print_config();

Expand Down
2 changes: 1 addition & 1 deletion src/cli/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,7 @@ func (m model) View() string {
end = start + m.viewHeight
}

spew.Fprintf(m.dump, "start: %d end: %d\n", start, end)
//spew.Fprintf(m.dump, "start: %d end: %d\n", start, end)

styledContent := jsonStyle.Width(m.viewWidth).Height(m.viewHeight).Render(strings.Join(m.scrollContent[start:end], "\n"))
statusView = styledContent + m.currentOperatingInstructions
Expand Down
7 changes: 6 additions & 1 deletion src/cmd/em_cmd_em_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ em_cmd_em_config_t::em_cmd_em_config_t(em_cmd_params_t param, dm_easy_mesh_t& dm
memset((unsigned char *)&m_orch_desc[0], 0, EM_MAX_CMD*sizeof(em_orch_desc_t));

m_orch_op_idx = 0;
m_num_orch_desc = 4;
m_num_orch_desc = 6;
m_orch_desc[0].op = dm_orch_type_topo_sync;
m_orch_desc[0].submit = true;
m_orch_desc[1].op = dm_orch_type_channel_pref;
Expand All @@ -59,6 +59,11 @@ em_cmd_em_config_t::em_cmd_em_config_t(em_cmd_params_t param, dm_easy_mesh_t& dm
m_orch_desc[2].submit = true;
m_orch_desc[3].op = dm_orch_type_channel_cnf;
m_orch_desc[3].submit = true;
m_orch_desc[4].op = dm_orch_type_policy_cfg;
m_orch_desc[4].submit = true;
m_orch_desc[5].op = dm_orch_type_channel_scan_req;
m_orch_desc[5].submit = true;


strncpy(m_name, "em_config", strlen("em_config") + 1);
m_svc = em_service_type_ctrl;
Expand Down
Loading
Loading