Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
map-controller
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Automate
Agent sessions
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-controller
Commits
b4336173
Commit
b4336173
authored
Jun 9, 2023
by
Jakob Olsson
Browse files
Options
Downloads
Patches
Plain Diff
make a generic buildcmdu func and use it for link metric resp
parent
febeae7b
Branches
Branches containing commit
No related tags found
1 merge request
!246
Jo fixme
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/cntlr.c
+28
-10
28 additions, 10 deletions
src/cntlr.c
src/cntlr_ubus.c
+80
-47
80 additions, 47 deletions
src/cntlr_ubus.c
src/cntlr_ubus.h
+2
-1
2 additions, 1 deletion
src/cntlr_ubus.h
with
110 additions
and
58 deletions
src/cntlr.c
+
28
−
10
View file @
b4336173
...
@@ -1636,24 +1636,27 @@ static void cntlr_signal_periodic_run(atimer_t *t)
...
@@ -1636,24 +1636,27 @@ static void cntlr_signal_periodic_run(atimer_t *t)
static
void
combined_link_metric_periodic_collection
(
struct
controller
*
c
)
static
void
combined_link_metric_periodic_collection
(
struct
controller
*
c
)
{
{
trace
(
"%s: --->
\n
"
,
__func__
);
trace
(
"%s: --->
\n
"
,
__func__
);
struct
cmdu_buff
*
cmdu
;
struct
node
*
p
;
struct
node
*
p
;
struct
netif_radio
*
r
;
uint8_t
*
radiolist
=
NULL
,
*
bsslist
=
NULL
;
struct
netif_iface
*
bss
;
uint8_t
*
bsslist
=
NULL
,
*
new_bsslist
=
NULL
;
uint8_t
*
radiolist
=
NULL
,
*
new_radiolist
=
NULL
;
int
num_bss
,
num_radio
;
int
radio_index
,
bss_index
;
uint8_t
hwaddr
[
6
];
/* AP metrics query for each agent */
/* AP metrics query for each agent */
/* For each agent */
/* For each agent */
list_for_each_entry
(
p
,
&
c
->
nodelist
,
list
)
{
list_for_each_entry
(
p
,
&
c
->
nodelist
,
list
)
{
uint8_t
*
new_radiolist
;
struct
node
*
n
;
struct
cmdu_buff
*
cmdu
;
struct
netif_radio
*
r
;
int
num_bss
=
0
,
num_radio
=
0
;
uint8_t
hwaddr
[
6
];
num_radio
=
0
;
num_radio
=
0
;
num_bss
=
0
;
num_bss
=
0
;
memcpy
(
hwaddr
,
p
->
alid
,
6
);
memcpy
(
hwaddr
,
p
->
alid
,
6
);
/* For each radio */
/* For each radio */
list_for_each_entry
(
r
,
&
p
->
radiolist
,
list
)
{
list_for_each_entry
(
r
,
&
p
->
radiolist
,
list
)
{
struct
netif_iface
*
bss
;
int
radio_index
;
/* Building a radiolist of all radios */
/* Building a radiolist of all radios */
new_radiolist
=
(
uint8_t
*
)
realloc
(
radiolist
,
new_radiolist
=
(
uint8_t
*
)
realloc
(
radiolist
,
6
*
(
num_radio
+
1
)
*
sizeof
(
uint8_t
));
6
*
(
num_radio
+
1
)
*
sizeof
(
uint8_t
));
...
@@ -1670,6 +1673,9 @@ static void combined_link_metric_periodic_collection(struct controller *c)
...
@@ -1670,6 +1673,9 @@ static void combined_link_metric_periodic_collection(struct controller *c)
/* For each bss in radio */
/* For each bss in radio */
list_for_each_entry
(
bss
,
&
r
->
iflist
,
list
)
{
list_for_each_entry
(
bss
,
&
r
->
iflist
,
list
)
{
int
bss_index
;
uint8_t
*
new_bsslist
;
if
(
!
bss
->
bss
->
is_fbss
&&
!
bss
->
bss
->
is_bbss
)
if
(
!
bss
->
bss
->
is_fbss
&&
!
bss
->
bss
->
is_bbss
)
/* if bss is a bsta */
/* if bss is a bsta */
continue
;
continue
;
...
@@ -1696,9 +1702,21 @@ static void combined_link_metric_periodic_collection(struct controller *c)
...
@@ -1696,9 +1702,21 @@ static void combined_link_metric_periodic_collection(struct controller *c)
}
}
send_cmdu
(
c
,
cmdu
);
send_cmdu
(
c
,
cmdu
);
cmdu_free
(
cmdu
);
/* query i1905d base CMDU */
cmdu
=
ieee1905_ubus_buildcmdu
(
c
->
ubus_ctx
,
CMDU_TYPE_LINK_METRIC_RESPONSE
);
if
(
!
cmdu
)
dbg
(
"No response from stack when generating 0x%04x
\n
"
,
CMDU_TYPE_LINK_METRIC_RESPONSE
);
n
=
cntlr_find_node
(
c
,
c
->
almac
);
if
(
!
n
)
{
cmdu_free
(
cmdu
);
goto
error
;
}
/* 1905 Link metric query */
handle_link_metrics_response
(
c
,
cmdu
,
n
);
ieee1905_buildcmdu_linkmetric_resp
(
c
,
CMDU_TYPE_LINK_METRIC_RESPONSE
);
//FIXME: why here?
cmdu_free
(
cmdu
);
cmdu_free
(
cmdu
);
}
}
error:
error:
...
...
This diff is collapsed.
Click to expand it.
src/cntlr_ubus.c
+
80
−
47
View file @
b4336173
...
@@ -3676,91 +3676,124 @@ int ubus_call_object(struct controller *c, uint32_t obj,
...
@@ -3676,91 +3676,124 @@ int ubus_call_object(struct controller *c, uint32_t obj,
return
0
;
return
0
;
}
}
static
void
ieee1905_buildcmdu_lm_cb
(
struct
ubus_request
*
req
,
int
type
,
struct
blob_attr
*
msg
)
struct
buildcmdu_ctx
{
struct
cmdu_buff
*
buff
;
int
status
;
};
static
void
ieee1905_ubus_buildcmdu_cb
(
struct
ubus_request
*
req
,
int
type
,
struct
blob_attr
*
msg
)
{
{
char
tlv_str
[
500
]
=
{
0
};
int
len
,
b_len
;
uint16_t
msg_type
;
uint8_t
*
tlv
=
NULL
;
struct
cmdu_buff
*
cmdu
=
NULL
;
struct
controller
*
c
;
uint16_t
mid
=
0
;
struct
blob_attr
*
tb
[
2
];
struct
blob_attr
*
tb
[
2
];
static
const
struct
blobmsg_policy
cb
_attr
[
2
]
=
{
static
const
struct
blobmsg_policy
ev
_attr
[
2
]
=
{
[
0
]
=
{
.
name
=
"type"
,
.
type
=
BLOBMSG_TYPE_INT32
},
[
0
]
=
{
.
name
=
"type"
,
.
type
=
BLOBMSG_TYPE_INT32
},
[
1
]
=
{
.
name
=
"data"
,
.
type
=
BLOBMSG_TYPE_STRING
},
[
1
]
=
{
.
name
=
"data"
,
.
type
=
BLOBMSG_TYPE_STRING
}
};
};
uint16_t
cmdu_type
=
0
,
mid
=
0
;
char
*
data
;
uint8_t
origin
[
6
]
=
{
0
};
uint8_t
*
tlv
;
uint32_t
b_len
;
struct
buildcmdu_ctx
*
ctx
=
req
->
priv
;
struct
cmdu_buff
**
buff
=
NULL
;
if
(
!
ctx
)
{
err
(
"%s: No priv
\n
"
,
__func__
);
return
;
}
b
lobmsg_parse
(
cb_attr
,
2
,
tb
,
blob_data
(
msg
),
blob_len
(
msg
))
;
b
uff
=
&
ctx
->
buff
;
if
(
!
tb
[
1
]
||
!
tb
[
0
])
if
(
!
msg
)
{
err
(
"%s: Message NULL
\n
"
,
__func__
);
ctx
->
status
=
-
1
;
return
;
}
blobmsg_parse
(
ev_attr
,
2
,
tb
,
blob_data
(
msg
),
blob_len
(
msg
));
if
(
!
tb
[
0
]
||
!
tb
[
1
])
return
;
return
;
c
=
(
struct
controller
*
)
req
->
priv
;
cmdu_type
=
blobmsg_get_u32
(
tb
[
0
]);
msg_type
=
(
uint16_t
)
blobmsg_get_u32
(
tb
[
0
]);
data
=
blobmsg_get_string
(
tb
[
1
]);
strncpy
(
tlv_str
,
blobmsg_data
(
tb
[
1
]),
sizeof
(
tlv_str
)
-
1
);
if
(
!
data
)
{
len
=
strlen
(
tlv_str
);
err
(
"%s: No data
\n
"
,
__func__
);
b_len
=
(
len
/
2
);
ctx
->
status
=
-
1
;
tlv
=
(
uint8_t
*
)
malloc
((
b_len
)
*
sizeof
(
uint8_t
));
if
(
tlv
==
NULL
)
{
err
(
"No Memory
\n
"
);
return
;
return
;
}
}
strtob
(
tlv_str
,
b_len
,
tlv
);
if
(
msg_type
==
CMDU_TYPE_LINK_METRIC_RESPONSE
)
{
dbg
(
"|%s:%d| type = %u data = %s
\n
"
,
__func__
,
__LINE__
,
struct
node
*
n
;
cmdu_type
,
data
)
;
cmdu
=
cmdu_alloc_custom
(
msg_type
,
&
mid
,
NULL
,
c
->
almac
,
tlv
,
b_len
);
b_len
=
(
strlen
(
data
)
/
2
)
-
3
;
if
(
!
cmdu
)
goto
out
;
n
=
cntlr_find_node
(
c
,
c
->
almac
);
if
(
!
n
)
goto
out
;
handle_link_metrics_response
(
c
,
cmdu
,
n
);
tlv
=
(
uint8_t
*
)
calloc
(
1
,
b_len
);
cmdu_free
(
cmdu
);
if
(
!
tlv
)
{
err
(
"%s: No memory
\n
"
,
__func__
);
ctx
->
status
=
-
1
;
return
;
}
}
out:
strtob
(
data
,
b_len
,
tlv
);
*
buff
=
cmdu_alloc_custom
(
cmdu_type
,
&
mid
,
NULL
,
origin
,
tlv
,
b_len
);
free
(
tlv
);
free
(
tlv
);
if
(
!*
buff
)
{
err
(
"%s: Couldn't allocate cmdu buff
\n
"
,
__func__
);
ctx
->
status
=
-
1
;
return
;
return
;
}
}
int
ieee1905_buildcmdu_linkmetric_resp
(
struct
controller
*
c
,
uint16_t
msg_type
)
ctx
->
status
=
0
;
}
struct
cmdu_buff
*
ieee1905_ubus_buildcmdu
(
struct
ubus_context
*
ubus_ctx
,
uint16_t
msg_type
)
{
{
struct
blob_buf
b
=
{
0
};
struct
blob_buf
b
=
{
0
};
int
ret
=
0
;
int
ret
=
0
;
uint32_t
id
;
uint32_t
id
;
struct
buildcmdu_ctx
ctx
=
{
.
buff
=
NULL
,
.
status
=
-
1
,
};
dbg
(
"|%s:%d| Entry
\n
"
,
__func__
,
__LINE__
);
memset
(
&
b
,
0
,
sizeof
(
struct
blob_buf
));
blob_buf_init
(
&
b
,
0
);
blob_buf_init
(
&
b
,
0
);
blobmsg_add_u32
(
&
b
,
"type"
,
(
uint32_t
)
msg_type
);
blobmsg_add_u32
(
&
b
,
"type"
,
(
uint32_t
)
msg_type
);
if
(
!
c
->
ubus_ctx
)
if
(
ubus_lookup_id
(
ubus_ctx
,
"ieee1905"
,
&
id
))
{
trace
(
"I think that the ubus_ctx is NULL
\n
"
);
dbg
(
"|%s:%d| not present ieee1905"
,
__func__
,
__LINE__
);
if
(
ubus_lookup_id
(
c
->
ubus_ctx
,
"ieee1905"
,
&
id
))
{
dbg
(
"[%s:%d] not present i1905"
,
__func__
,
__LINE__
);
goto
out
;
goto
out
;
}
}
trace
(
"
\t\t
%s: %d
\n
"
,
__func__
,
__LINE__
);
ret
=
ubus_invoke
(
ubus_ctx
,
id
,
"buildcmdu"
,
b
.
head
,
ieee1905_ubus_buildcmdu_cb
,
&
ctx
,
2000
);
if
(
ctx
.
status
)
ret
=
ctx
.
status
;
ret
=
ubus_invoke
(
c
->
ubus_ctx
,
id
,
"buildcmdu"
,
b
.
head
,
ieee1905_buildcmdu_lm_cb
,
c
,
5000
);
if
(
ret
)
{
if
(
ret
)
{
dbg
(
"
[
%s:%d
]
ubus call failed for |i1905 buildcmdu|"
,
dbg
(
"
|
%s:%d
|
ubus call failed for |i
eee
1905 buildcmdu|"
,
__func__
,
__LINE__
);
__func__
,
__LINE__
);
goto
out
;
goto
out
;
}
}
out:
out:
blob_buf_free
(
&
b
);
blob_buf_free
(
&
b
);
return
ret
;
return
ctx
.
buff
;
}
}
int
cntlr_wait_for_object_timeout
(
struct
controller
*
c
,
void
*
object
,
int
cntlr_wait_for_object_timeout
(
struct
controller
*
c
,
void
*
object
,
uint32_t
tmo_msecs
,
void
*
res
)
uint32_t
tmo_msecs
,
void
*
res
)
{
{
...
...
This diff is collapsed.
Click to expand it.
src/cntlr_ubus.h
+
2
−
1
View file @
b4336173
...
@@ -29,7 +29,8 @@ int ubus_call_object(struct controller *c, uint32_t obj,
...
@@ -29,7 +29,8 @@ int ubus_call_object(struct controller *c, uint32_t obj,
int
cntlr_wait_for_object_timeout
(
struct
controller
*
c
,
void
*
object
,
int
cntlr_wait_for_object_timeout
(
struct
controller
*
c
,
void
*
object
,
uint32_t
tmo_msecs
,
void
*
res
);
uint32_t
tmo_msecs
,
void
*
res
);
int
ieee1905_buildcmdu_linkmetric_resp
(
struct
controller
*
c
,
uint16_t
msg_type
);
struct
cmdu_buff
*
ieee1905_ubus_buildcmdu
(
struct
ubus_context
*
ubus_ctx
,
uint16_t
msg_type
);
int
cntlr_get_ieee1905_almac
(
struct
controller
*
c
,
uint8_t
*
almac
);
int
cntlr_get_ieee1905_almac
(
struct
controller
*
c
,
uint8_t
*
almac
);
void
cntlr_status_add_opclass
(
struct
blob_buf
*
bb
,
struct
wifi_radio_opclass
*
opclass
,
void
cntlr_status_add_opclass
(
struct
blob_buf
*
bb
,
struct
wifi_radio_opclass
*
opclass
,
...
...
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