Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
map-agent
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
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Multi-AP
map-agent
Commits
d07d51ef
Commit
d07d51ef
authored
Mar 8, 2021
by
Jakob Olsson
Browse files
Options
Downloads
Patches
Plain Diff
map-agent: some memory cleanup
parent
4590c35e
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/core/agent.c
+29
-0
29 additions, 0 deletions
src/core/agent.c
src/core/config.c
+39
-6
39 additions, 6 deletions
src/core/config.c
src/utils/debug.c
+24
-0
24 additions, 0 deletions
src/utils/debug.c
with
92 additions
and
6 deletions
src/core/agent.c
+
29
−
0
View file @
d07d51ef
...
...
@@ -2868,6 +2868,7 @@ static void parse_radio(struct ubus_request *req, int type,
if
(
tb
[
5
])
{
struct
blob_attr
*
cur
,
*
cur1
;
re
->
num_supp_opclass
=
blobmsg_check_array
(
tb
[
5
],
BLOBMSG_TYPE_TABLE
);
re
->
supp_opclass
=
calloc
(
re
->
num_supp_opclass
,
sizeof
(
*
re
->
supp_opclass
));
if
(
!
re
->
supp_opclass
)
{
...
...
@@ -2997,6 +2998,30 @@ static struct wifi_scanres_channel_element *wifi_get_scanres_ch_element(struct w
return
0
;
}
static
void
free_scanresults
(
struct
wifi_radio_element
*
re
)
{
int
i
;
struct
wifi_scanres_element
*
scanres_el
;
int
j
;
scanres_el
=
re
->
scanlist
;
for
(
j
=
0
;
j
<
scanres_el
->
num_opclass_scanned
;
j
++
)
{
int
k
;
struct
wifi_scanres_opclass_element
*
opclass
=
&
scanres_el
->
opclass_scanlist
[
j
];
for
(
k
=
0
;
k
<
opclass
->
num_channels_scanned
;
k
++
)
{
struct
wifi_scanres_channel_element
*
ch_el
=
&
opclass
->
channel_scanlist
[
k
];
free
(
ch_el
->
nbrlist
);
}
free
(
opclass
->
channel_scanlist
);
}
free
(
scanres_el
->
opclass_scanlist
);
free
(
scanres_el
);
}
static
void
parse_scanresults
(
struct
ubus_request
*
req
,
int
type
,
struct
blob_attr
*
msg
)
{
fprintf
(
stdout
,
"%s --->
\n
"
,
__func__
);
...
...
@@ -3987,11 +4012,15 @@ void agent_free_radios(struct agent *a)
re
=
&
a
->
radios
[
i
];
free_scanresults
(
re
);
for
(
j
=
0
;
j
<
re
->
num_supp_opclass
;
j
++
)
{
free
(
re
->
supp_opclass
[
j
].
supp_chanlist
);
free
(
re
->
supp_opclass
[
j
].
exclude_chanlist
);
}
free
(
re
->
bsslist
);
free
(
re
->
supp_opclass
);
agent_free_wsc_data
(
&
re
->
autconfig
);
re
->
autconfig
.
key
=
NULL
;
...
...
...
...
This diff is collapsed.
Click to expand it.
src/core/config.c
+
39
−
6
View file @
d07d51ef
...
...
@@ -875,6 +875,19 @@ static struct steer_policy *get_steer_policy_by_name(struct netif_fhcfg *c,
return
NULL
;
}
static
struct
agent_config_radio
*
get_agent_config_radio
(
struct
agent_config
*
c
,
const
char
*
ifname
)
{
struct
agent_config_radio
*
p
;
list_for_each_entry
(
p
,
&
c
->
radiolist
,
list
)
{
if
(
!
strcmp
(
ifname
,
p
->
name
))
return
p
;
}
return
NULL
;
}
void
stax_add_entry
(
struct
list_head
*
h
,
char
*
sta_macstr
)
{
struct
stax
*
n
;
...
...
@@ -1406,11 +1419,17 @@ static int agent_config_get_wifi_radio(struct agent_config *a,
}
if
(
ifname
&&
band
)
{
n
=
get_agent_config_radio
(
a
,
ifname
);
if
(
!
n
)
{
n
=
calloc
(
1
,
sizeof
(
*
n
));
if
(
!
n
)
{
warn
(
"-ENOMEM!
\n
"
);
return
-
1
;
}
list_add_tail
(
&
n
->
list
,
&
a
->
radiolist
);
}
strncpy
(
n
->
name
,
ifname
,
16
);
n
->
name
[
15
]
=
'\0'
;
n
->
band
=
band
;
...
...
@@ -1426,8 +1445,6 @@ static int agent_config_get_wifi_radio(struct agent_config *a,
true
:
false
;
}
list_add_tail
(
&
n
->
list
,
&
a
->
radiolist
);
return
0
;
}
...
...
@@ -2213,13 +2230,29 @@ int clean_all_fh(struct agent_config *cfg)
return
0
;
}
void
clean_radio_cfg
(
struct
agent_config_radio
*
p
)
{
list_del
(
&
p
->
list
);
free
(
p
);
}
int
clean_all_radios
(
struct
agent_config
*
cfg
)
{
struct
agent_config_radio
*
p
,
*
tmp
;
list_for_each_entry_safe
(
p
,
tmp
,
&
cfg
->
radiolist
,
list
)
clean_radio_cfg
(
p
);
return
0
;
}
int
agent_config_clean
(
struct
agent_config
*
cfg
)
{
clean_all_fh
(
cfg
);
clean_all_bk
(
cfg
);
clean_steer_btm_excl
(
cfg
);
clean_steer_excl
(
cfg
);
clean_all_radios
(
cfg
);
if
(
cfg
->
pcfg
)
free
(
cfg
->
pcfg
);
...
...
...
...
This diff is collapsed.
Click to expand it.
src/utils/debug.c
+
24
−
0
View file @
d07d51ef
...
...
@@ -220,4 +220,28 @@ void log_cmdu(int level, void *var)
log_test
(
level
,
btlv
,
len
);
free
(
btlv
);
}
<<<<<<<
HEAD
}
=======
msgversion
=
json_object_new_int
(
cmdu
->
message_version
);
msgtype
=
json_object_new_int
(
cmdu
->
message_type
);
direction
=
json_object_new_boolean
(
flag
);
msgid
=
json_object_new_int
(
cmdu
->
message_id
);
intfname
=
json_object_new_string
(
cmdu
->
intf_name
);
msg
=
json_object_new_string
(
map_stringify_cmdu_type
(
cmdu
->
message_type
));
json_object_object_add
(
main_object
,
"message_version"
,
msgversion
);
json_object_object_add
(
main_object
,
"message_type"
,
msgtype
);
json_object_object_add
(
main_object
,
"message_id"
,
msgid
);
json_object_object_add
(
main_object
,
"interface_name"
,
intfname
);
json_object_object_add
(
main_object
,
"message"
,
msg
);
json_object_object_add
(
main_object
,
"direction"
,
direction
);
json_object_object_add
(
main_object
,
"tlvs"
,
tlvarray
);
fprintf
(
testfile
,
"%s
\n
"
,
json_object_to_json_string
(
main_object
));
fflush
(
testfile
);
json_object_put
(
main_object
);
}
>>>>>>>
77
d3f2a
...
map
-
agent
:
some
memory
cleanup
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
sign in
to comment