Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
M
map-controller
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Multi-AP
map-controller
Commits
e6dbe8a6
Commit
e6dbe8a6
authored
2 years ago
by
Filip Matusiak
Browse files
Options
Downloads
Patches
Plain Diff
Utilize mac-addresses hashtable for object lookup
Signed-off-by:
Filip Matusiak
<
filip.matusiak@iopsys.eu
>
parent
f5709fd5
No related branches found
No related tags found
No related merge requests found
Pipeline
#99373
passed
2 years ago
Stage: static_code_analysis
Stage: compile_test
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/cntlr.c
+99
-49
99 additions, 49 deletions
src/cntlr.c
src/cntlr.h
+0
-2
0 additions, 2 deletions
src/cntlr.h
with
99 additions
and
51 deletions
src/cntlr.c
+
99
−
49
View file @
e6dbe8a6
...
...
@@ -57,21 +57,15 @@
extern
bool
waitext
;
/*
find interface by macaddress - no radio argument
*/
struct
netif_iface
*
find_interface_by_mac
_nor
(
struct
controller
*
c
,
uint8_t
*
hwaddr
)
/*
deprecated
*/
struct
netif_iface
*
_
find_interface_by_mac
(
struct
controller
*
c
,
struct
netif_radio
*
r
,
uint8_t
*
hwaddr
)
{
struct
netif_iface
*
p
=
NULL
;
/* fh anf bk iface */
struct
netif_radio
*
r
=
NULL
;
struct
node
*
n
=
NULL
;
struct
netif_iface
*
p
=
NULL
;
list_for_each_entry
(
n
,
&
c
->
nodelist
,
list
)
{
list_for_each_entry
(
r
,
&
n
->
radiolist
,
list
)
{
list_for_each_entry
(
p
,
&
r
->
iflist
,
list
)
{
if
(
!
memcmp
(
p
->
bss
->
bssid
,
hwaddr
,
6
))
return
p
;
}
}
list_for_each_entry
(
p
,
&
r
->
iflist
,
list
)
{
if
(
!
memcmp
(
p
->
bss
->
bssid
,
hwaddr
,
6
))
return
p
;
}
return
NULL
;
...
...
@@ -81,14 +75,15 @@ struct netif_iface *find_interface_by_mac_nor(struct controller *c,
struct
netif_iface
*
find_interface_by_mac
(
struct
controller
*
c
,
struct
netif_radio
*
r
,
uint8_t
*
hwaddr
)
{
struct
netif_iface
*
p
=
NULL
;
struct
map_macaddr_entry
*
entry
=
NULL
;
list_for_each_entry
(
p
,
&
r
->
iflist
,
list
)
{
if
(
!
memcmp
(
p
->
bss
->
bssid
,
hwaddr
,
6
))
return
p
;
}
entry
=
allmac_lookup
(
&
c
->
mac_table
,
hwaddr
,
MAC_ENTRY_FBSS
);
return
NULL
;
if
(
WARN_ON
(
!
entry
))
/* fall back to old find - TODO: deprecate */
return
_find_interface_by_mac
(
c
,
r
,
hwaddr
);
return
(
struct
netif_iface
*
)
entry
->
data
;
}
/* find radio by ssid, node known */
...
...
@@ -144,8 +139,8 @@ struct netif_iface *find_interface_by_ssid(struct controller *c,
return
NULL
;
}
/*
find radio by node
*/
struct
netif_radio
*
find_radio_by_node
(
struct
controller
*
c
,
struct
node
*
n
,
/*
deprecated
*/
struct
netif_radio
*
_
find_radio_by_node
(
struct
controller
*
c
,
struct
node
*
n
,
uint8_t
*
radio_mac
)
{
struct
netif_radio
*
p
=
NULL
;
...
...
@@ -158,8 +153,23 @@ struct netif_radio *find_radio_by_node(struct controller *c, struct node *n,
return
NULL
;
}
/* find radio by macaddress, search all nodes */
struct
netif_radio
*
find_radio_by_mac
(
struct
controller
*
c
,
uint8_t
*
mac
)
/* find radio by node */
struct
netif_radio
*
find_radio_by_node
(
struct
controller
*
c
,
struct
node
*
n
,
uint8_t
*
radio_mac
)
{
struct
map_macaddr_entry
*
entry
=
NULL
;
entry
=
allmac_lookup
(
&
c
->
mac_table
,
radio_mac
,
MAC_ENTRY_RADIO
);
if
(
WARN_ON
(
!
entry
))
/* fall back to old find - TODO: deprecate */
return
_find_radio_by_node
(
c
,
n
,
radio_mac
);
return
(
struct
netif_radio
*
)
entry
->
data
;
}
/* deprecated */
struct
netif_radio
*
_find_radio_by_mac
(
struct
controller
*
c
,
uint8_t
*
mac
)
{
struct
node
*
n
=
NULL
;
struct
netif_radio
*
r
=
NULL
;
...
...
@@ -173,6 +183,20 @@ struct netif_radio *find_radio_by_mac(struct controller *c, uint8_t *mac)
return
NULL
;
}
/* find radio by macaddress, search all nodes */
struct
netif_radio
*
find_radio_by_mac
(
struct
controller
*
c
,
uint8_t
*
mac
)
{
struct
map_macaddr_entry
*
entry
=
NULL
;
entry
=
allmac_lookup
(
&
c
->
mac_table
,
mac
,
MAC_ENTRY_RADIO
);
if
(
WARN_ON
(
!
entry
))
/* fall back to old find - TODO: deprecate */
return
_find_radio_by_mac
(
c
,
mac
);
return
(
struct
netif_radio
*
)
entry
->
data
;
}
/* finds radio struct from interface macaddr */
struct
netif_radio
*
find_radio_by_bssid
(
struct
controller
*
c
,
uint8_t
*
bssid
)
{
...
...
@@ -206,8 +230,8 @@ struct netif_link *find_link_by_mac(struct controller *c, uint8_t *upstream, uin
return
NULL
;
}
/*
find node by macaddress
*/
struct
node
*
cntlr_find_node
(
struct
controller
*
c
,
uint8_t
*
almac
)
/*
deprecated
*/
struct
node
*
_
cntlr_find_node
(
struct
controller
*
c
,
uint8_t
*
almac
)
{
struct
node
*
n
=
NULL
;
...
...
@@ -219,8 +243,22 @@ struct node *cntlr_find_node(struct controller *c, uint8_t *almac)
return
NULL
;
}
/* find sta by macaddress */
struct
sta
*
cntlr_find_sta
(
struct
controller
*
c
,
uint8_t
*
mac
)
/* find node by macaddress */
struct
node
*
cntlr_find_node
(
struct
controller
*
c
,
uint8_t
*
mac
)
{
struct
map_macaddr_entry
*
entry
=
NULL
;
entry
=
allmac_lookup
(
&
c
->
mac_table
,
mac
,
MAC_ENTRY_ALID
);
if
(
WARN_ON
(
!
entry
))
/* fall back to old find - TODO: deprecate */
return
_cntlr_find_node
(
c
,
mac
);
return
(
struct
node
*
)
entry
->
data
;
}
/* deprecated */
struct
sta
*
_cntlr_find_sta
(
struct
controller
*
c
,
uint8_t
*
mac
)
{
struct
sta
*
s
=
NULL
;
...
...
@@ -232,6 +270,20 @@ struct sta *cntlr_find_sta(struct controller *c, uint8_t *mac)
return
NULL
;
}
/* find sta by macaddress */
struct
sta
*
cntlr_find_sta
(
struct
controller
*
c
,
uint8_t
*
mac
)
{
struct
map_macaddr_entry
*
entry
=
NULL
;
entry
=
allmac_lookup
(
&
c
->
mac_table
,
mac
,
MAC_ENTRY_ALID
);
if
(
WARN_ON
(
!
entry
))
/* fall back to old find - TODO: deprecate */
return
_cntlr_find_sta
(
c
,
mac
);
return
(
struct
sta
*
)
entry
->
data
;
}
struct
bcnreq
*
cntlr_find_bcnreq
(
struct
controller
*
c
,
uint8_t
*
sta
,
uint8_t
*
alid
)
{
struct
bcnreq
*
br
=
NULL
;
...
...
@@ -246,23 +298,8 @@ struct bcnreq *cntlr_find_bcnreq(struct controller *c, uint8_t *sta, uint8_t *al
return
NULL
;
}
#if 0
/* find node by macaddress */
struct netif_iface *cntlr_get_fbss_by_mac(struct controller *c, struct node *n,
uint8_t *mac)
{
struct netif_iface *p;
list_for_each_entry(p, &n->iflist, list) {
if (!memcmp(p->bss->bssid, mac, 6))
return p;
}
return NULL;
}
#endif
/* find fbss based on macaddr */
struct
netif_iface
*
cntlr_iterate_fbss
(
struct
controller
*
c
,
uint8_t
*
mac
)
/* deprecated */
struct
netif_iface
*
_cntlr_iterate_fbss
(
struct
controller
*
c
,
uint8_t
*
mac
)
{
struct
node
*
n
=
NULL
;
struct
netif_radio
*
r
=
NULL
;
...
...
@@ -280,6 +317,20 @@ struct netif_iface *cntlr_iterate_fbss(struct controller *c, uint8_t *mac)
return
NULL
;
}
/* find fbss based on macaddr */
struct
netif_iface
*
cntlr_iterate_fbss
(
struct
controller
*
c
,
uint8_t
*
mac
)
{
struct
map_macaddr_entry
*
entry
=
NULL
;
entry
=
allmac_lookup
(
&
c
->
mac_table
,
mac
,
MAC_ENTRY_FBSS
);
if
(
WARN_ON
(
!
entry
))
/* fall back to old find - TODO: deprecate */
return
_cntlr_iterate_fbss
(
c
,
mac
);
return
(
struct
netif_iface
*
)
entry
->
data
;
}
/* find node based on bssid */
struct
node
*
cntlr_find_node_by_iface
(
struct
controller
*
c
,
uint8_t
*
bssid
)
{
...
...
@@ -1200,8 +1251,7 @@ void cntlr_clean_bcnreqlist(struct controller *c)
free
(
b
);
}
}
void
cntlr_clean_linklist
(
struct
controller
*
c
)
void
node_clean_linklist
(
struct
controller
*
c
)
{
struct
netif_link
*
l
=
NULL
,
*
tmp
;
...
...
@@ -1327,11 +1377,11 @@ struct netif_link *alloc_link_init(struct controller *c,
if
(
!
l
->
metrics
)
goto
out
;
l
->
upstream
=
find
_i
n
ter
face_by_mac_nor
(
c
,
upstream
);
l
->
upstream
=
cntlr
_iter
ate_fbss
(
c
,
upstream
);
if
(
!
l
->
upstream
)
goto
out_metrics
;
l
->
downstream
=
find
_i
n
ter
face_by_mac_nor
(
c
,
downstream
);
l
->
downstream
=
cntlr
_iter
ate_fbss
(
c
,
downstream
);
if
(
!
l
->
downstream
)
goto
out_metrics
;
...
...
@@ -2093,7 +2143,7 @@ out_exit:
cntlr_clean_mac_hashtable
(
c
);
cntlr_clean_stalist
(
c
);
cntlr_clean_bcnreqlist
(
c
);
cntlr
_clean_linklist
(
c
);
node
_clean_linklist
(
c
);
cntlr_clean_nodelist
(
c
);
ubus_unregister_event_handler
(
ctx
,
&
c
->
evh
);
cntlr_remove_object
(
c
);
...
...
This diff is collapsed.
Click to expand it.
src/cntlr.h
+
0
−
2
View file @
e6dbe8a6
...
...
@@ -397,8 +397,6 @@ struct steer_control_config *get_steer_control_config(struct controller *c);
struct
sta
*
cntlr_add_sta
(
struct
controller
*
c
,
uint8_t
*
macaddr
);
struct
sta
*
cntlr_find_sta
(
struct
controller
*
c
,
uint8_t
*
mac
);
struct
bcnreq
*
cntlr_find_bcnreq
(
struct
controller
*
c
,
uint8_t
*
sta
,
uint8_t
*
alid
);
struct
netif_iface
*
cntlr_get_fbss_by_mac
(
struct
controller
*
c
,
struct
node
*
n
,
uint8_t
*
mac
);
bool
cntlr_resync_config
(
struct
controller
*
c
,
bool
reload
);
int
cntlr_radio_clean_scanlist_el
(
struct
wifi_scanres_element
*
el
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment