Skip to content
This repository was archived by the owner on Mar 24, 2025. It is now read-only.

Commit 4ae4619

Browse files
piotrkoziarkderda
andauthored
[link metrics] implement link metrics properties (#484)
Co-authored-by: Konrad Derda <konrad.derda@nordicsemi.no>
1 parent d5b95c1 commit 4ae4619

17 files changed

+1576
-1
lines changed

src/ipc-dbus/DBusIPCAPI_v1.cpp

+172
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,11 @@ DBusIPCAPI_v1::init_callback_tables()
119119
INTERFACE_CALLBACK_CONNECT(WPANTUND_IF_CMD_PEEK, interface_peek_handler);
120120
INTERFACE_CALLBACK_CONNECT(WPANTUND_IF_CMD_POKE, interface_poke_handler);
121121

122+
INTERFACE_CALLBACK_CONNECT(WPANTUND_IF_CMD_LINK_METRICS_QUERY, interface_link_metrics_query_handler);
123+
INTERFACE_CALLBACK_CONNECT(WPANTUND_IF_CMD_LINK_METRICS_PROBE, interface_link_metrics_probe_handler);
124+
INTERFACE_CALLBACK_CONNECT(WPANTUND_IF_CMD_LINK_METRICS_MGMT_FORWARD, interface_link_metrics_mgmt_forward_handler);
125+
INTERFACE_CALLBACK_CONNECT(WPANTUND_IF_CMD_LINK_METRICS_MGMT_ENH_ACK, interface_link_metrics_mgmt_enh_ack_handler);
126+
122127
INTERFACE_CALLBACK_CONNECT(WPANTUND_IF_CMD_MLR_REQUEST, interface_mlr_request_handler);
123128

124129
INTERFACE_CALLBACK_CONNECT(WPANTUND_IF_CMD_BACKBONE_ROUTER_CONFIG, interface_backbone_router_config_handler);
@@ -2120,6 +2125,173 @@ DBusIPCAPI_v1::interface_poke_handler(
21202125
return ret;
21212126
}
21222127

2128+
DBusHandlerResult
2129+
DBusIPCAPI_v1::interface_link_metrics_query_handler(
2130+
NCPControlInterface* interface,
2131+
DBusMessage * message
2132+
) {
2133+
DBusHandlerResult ret = DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
2134+
const uint8_t *dest_addr = NULL;
2135+
int dest_addr_len;
2136+
struct in6_addr dest;
2137+
uint8_t series;
2138+
uint8_t metrics = 0;
2139+
bool did_succeed = false;
2140+
2141+
did_succeed = dbus_message_get_args(
2142+
message, NULL,
2143+
DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE, &dest_addr, &dest_addr_len,
2144+
DBUS_TYPE_BYTE, &series,
2145+
DBUS_TYPE_BYTE, &metrics,
2146+
DBUS_TYPE_INVALID
2147+
);
2148+
2149+
require(did_succeed, bail);
2150+
require(dest_addr_len == sizeof(dest), bail);
2151+
2152+
dbus_message_ref(message);
2153+
2154+
memcpy(dest.s6_addr, dest_addr, sizeof(dest));
2155+
2156+
interface->link_metrics_query(
2157+
dest,
2158+
series,
2159+
metrics,
2160+
boost::bind(&DBusIPCAPI_v1::CallbackWithStatus_Helper, this, _1, message)
2161+
);
2162+
2163+
ret = DBUS_HANDLER_RESULT_HANDLED;
2164+
2165+
bail:
2166+
return ret;
2167+
}
2168+
2169+
DBusHandlerResult
2170+
DBusIPCAPI_v1::interface_link_metrics_probe_handler(
2171+
NCPControlInterface* interface,
2172+
DBusMessage * message
2173+
) {
2174+
DBusHandlerResult ret = DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
2175+
const uint8_t *dest_addr = NULL;
2176+
int dest_addr_len;
2177+
struct in6_addr dest;
2178+
uint8_t series;
2179+
uint8_t length;
2180+
bool did_succeed = false;
2181+
2182+
did_succeed = dbus_message_get_args(
2183+
message, NULL,
2184+
DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE, &dest_addr, &dest_addr_len,
2185+
DBUS_TYPE_BYTE, &series,
2186+
DBUS_TYPE_BYTE, &length,
2187+
DBUS_TYPE_INVALID
2188+
);
2189+
2190+
require(did_succeed, bail);
2191+
require(dest_addr_len == sizeof(dest), bail);
2192+
2193+
dbus_message_ref(message);
2194+
2195+
memcpy(dest.s6_addr, dest_addr, sizeof(dest));
2196+
2197+
interface->link_metrics_probe(
2198+
dest,
2199+
series,
2200+
length,
2201+
boost::bind(&DBusIPCAPI_v1::CallbackWithStatus_Helper, this, _1, message)
2202+
);
2203+
2204+
ret = DBUS_HANDLER_RESULT_HANDLED;
2205+
2206+
bail:
2207+
return ret;
2208+
}
2209+
2210+
DBusHandlerResult
2211+
DBusIPCAPI_v1::interface_link_metrics_mgmt_forward_handler(
2212+
NCPControlInterface* interface,
2213+
DBusMessage * message
2214+
) {
2215+
DBusHandlerResult ret = DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
2216+
const uint8_t *dest_addr = NULL;
2217+
int dest_addr_len;
2218+
struct in6_addr dest;
2219+
uint8_t series_id = 0;
2220+
uint8_t metrics = 0;
2221+
uint8_t frame_types = 0;
2222+
bool did_succeed = false;
2223+
2224+
did_succeed = dbus_message_get_args(
2225+
message, NULL,
2226+
DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE, &dest_addr, &dest_addr_len,
2227+
DBUS_TYPE_BYTE, &series_id,
2228+
DBUS_TYPE_BYTE, &frame_types,
2229+
DBUS_TYPE_BYTE, &metrics,
2230+
DBUS_TYPE_INVALID
2231+
);
2232+
2233+
require(did_succeed, bail);
2234+
require(dest_addr_len == sizeof(dest), bail);
2235+
2236+
dbus_message_ref(message);
2237+
2238+
memcpy(dest.s6_addr, dest_addr, sizeof(dest));
2239+
2240+
interface->link_metrics_mgmt_forward(
2241+
dest,
2242+
series_id,
2243+
frame_types,
2244+
metrics,
2245+
boost::bind(&DBusIPCAPI_v1::CallbackWithStatus_Helper, this, _1, message)
2246+
);
2247+
2248+
ret = DBUS_HANDLER_RESULT_HANDLED;
2249+
2250+
bail:
2251+
return ret;
2252+
}
2253+
2254+
DBusHandlerResult
2255+
DBusIPCAPI_v1::interface_link_metrics_mgmt_enh_ack_handler(
2256+
NCPControlInterface* interface,
2257+
DBusMessage * message
2258+
) {
2259+
DBusHandlerResult ret = DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
2260+
const uint8_t *dest_addr = NULL;
2261+
int dest_addr_len;
2262+
struct in6_addr dest;
2263+
uint8_t metrics = 0;
2264+
uint8_t flags = 0;
2265+
bool did_succeed = false;
2266+
2267+
did_succeed = dbus_message_get_args(
2268+
message, NULL,
2269+
DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE, &dest_addr, &dest_addr_len,
2270+
DBUS_TYPE_BYTE, &flags,
2271+
DBUS_TYPE_BYTE, &metrics,
2272+
DBUS_TYPE_INVALID
2273+
);
2274+
2275+
require(did_succeed, bail);
2276+
require(dest_addr_len == sizeof(dest), bail);
2277+
2278+
dbus_message_ref(message);
2279+
2280+
memcpy(dest.s6_addr, dest_addr, sizeof(dest));
2281+
2282+
interface->link_metrics_mgmt_enh_ack(
2283+
dest,
2284+
flags,
2285+
metrics,
2286+
boost::bind(&DBusIPCAPI_v1::CallbackWithStatus_Helper, this, _1, message)
2287+
);
2288+
2289+
ret = DBUS_HANDLER_RESULT_HANDLED;
2290+
2291+
bail:
2292+
return ret;
2293+
}
2294+
21232295
DBusHandlerResult
21242296
DBusIPCAPI_v1::interface_mlr_request_handler(
21252297
NCPControlInterface* interface,

src/ipc-dbus/DBusIPCAPI_v1.h

+20
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,26 @@ class DBusIPCAPI_v1 {
281281
DBusMessage * message
282282
);
283283

284+
DBusHandlerResult interface_link_metrics_query_handler(
285+
NCPControlInterface* interface,
286+
DBusMessage * message
287+
);
288+
289+
DBusHandlerResult interface_link_metrics_probe_handler(
290+
NCPControlInterface* interface,
291+
DBusMessage * message
292+
);
293+
294+
DBusHandlerResult interface_link_metrics_mgmt_forward_handler(
295+
NCPControlInterface* interface,
296+
DBusMessage * message
297+
);
298+
299+
DBusHandlerResult interface_link_metrics_mgmt_enh_ack_handler(
300+
NCPControlInterface* interface,
301+
DBusMessage * message
302+
);
303+
284304
DBusHandlerResult interface_mlr_request_handler(
285305
NCPControlInterface* interface,
286306
DBusMessage * message

src/ipc-dbus/wpan-dbus-v1.h

+5
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,11 @@
9999

100100
#define WPANTUND_IF_SIGNAL_NETWORK_TIME_UPDATE "NetworkTimeUpdate"
101101

102+
#define WPANTUND_IF_CMD_LINK_METRICS_QUERY "LinkMetricsQuery"
103+
#define WPANTUND_IF_CMD_LINK_METRICS_PROBE "LinkMetricsProbe"
104+
#define WPANTUND_IF_CMD_LINK_METRICS_MGMT_FORWARD "LinkMetricsMgmtForward"
105+
#define WPANTUND_IF_CMD_LINK_METRICS_MGMT_ENH_ACK "LinkMetricsMgmtEnhAck"
106+
102107
#define WPANTUND_IF_CMD_MLR_REQUEST "MlrRequest"
103108

104109
#define WPANTUND_IF_CMD_BACKBONE_ROUTER_CONFIG "BackboneRouterConfig"

src/ncp-dummy/DummyNCPControlInterface.cpp

+41
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,47 @@ DummyNCPControlInterface::property_remove_value(
396396
mNCPInstance->property_remove_value(key, value, cb);
397397
}
398398

399+
void
400+
DummyNCPControlInterface::link_metrics_query(
401+
const struct in6_addr &address,
402+
uint8_t seriesId,
403+
const uint8_t metrics,
404+
CallbackWithStatus cb
405+
) {
406+
cb(kWPANTUNDStatus_FeatureNotImplemented);
407+
}
408+
409+
void
410+
DummyNCPControlInterface::link_metrics_probe(
411+
const struct in6_addr &address,
412+
uint8_t seriesId,
413+
uint8_t length,
414+
CallbackWithStatus cb
415+
) {
416+
cb(kWPANTUNDStatus_FeatureNotImplemented);
417+
}
418+
419+
void
420+
DummyNCPControlInterface::link_metrics_mgmt_forward(
421+
const struct in6_addr &address,
422+
uint8_t seriesId,
423+
const uint8_t frame_types,
424+
const uint8_t metrics,
425+
CallbackWithStatus cb
426+
) {
427+
cb(kWPANTUNDStatus_FeatureNotImplemented);
428+
}
429+
430+
void
431+
DummyNCPControlInterface::link_metrics_mgmt_enh_ack(
432+
const struct in6_addr &address,
433+
uint8_t seriesId,
434+
const uint8_t metrics,
435+
CallbackWithStatus cb
436+
) {
437+
cb(kWPANTUNDStatus_FeatureNotImplemented);
438+
}
439+
399440
void
400441
DummyNCPControlInterface::mlr_request(
401442
const std::vector<struct in6_addr> &addresses,

src/ncp-dummy/DummyNCPControlInterface.h

+29
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,35 @@ class DummyNCPControlInterface : public NCPControlInterface {
245245

246246
virtual NCPInstance& get_ncp_instance(void);
247247

248+
virtual void link_metrics_query(
249+
const struct in6_addr &address,
250+
uint8_t seriesId,
251+
const uint8_t metrics,
252+
CallbackWithStatus cb = NilReturn()
253+
);
254+
255+
virtual void link_metrics_probe(
256+
const struct in6_addr &address,
257+
uint8_t seriesId,
258+
uint8_t length,
259+
CallbackWithStatus cb = NilReturn()
260+
);
261+
262+
virtual void link_metrics_mgmt_forward(
263+
const struct in6_addr &address,
264+
uint8_t seriesId,
265+
const uint8_t frame_types,
266+
const uint8_t metrics,
267+
CallbackWithStatus cb = NilReturn()
268+
);
269+
270+
virtual void link_metrics_mgmt_enh_ack(
271+
const struct in6_addr &address,
272+
uint8_t flags,
273+
const uint8_t metrics,
274+
CallbackWithStatus cb = NilReturn()
275+
);
276+
248277
virtual void mlr_request(
249278
const std::vector<struct in6_addr> &addresses,
250279
bool mlr_timeout_present,

0 commit comments

Comments
 (0)