diff --git a/network/netmanager/include/net_connection.h b/network/netmanager/include/net_connection.h index 8430ec9c287f3cf1e3950e82f042474fec4e7a8c..0ab63a063080a619c9d6d44964064b819a5e8a44 100644 --- a/network/netmanager/include/net_connection.h +++ b/network/netmanager/include/net_connection.h @@ -387,6 +387,20 @@ NetConn_ErrorCode OH_NetConn_GetPacUrl(char *pacUrl); */ int32_t OH_NetConn_QueryProbeResult(char *destination, int32_t duration, NetConn_ProbeResultInfo *probeResultInfo); +/** + * @brief Query a network trace route. + * + * @param destination Pointer to the destination. + * @param option Pointer to the trace route option + * @param traceRouteInfo Pointer to trace route result. + * @return 0 - Success. + * 201 - Missing permissions. + * @permission ohos.permission.INTERNET and ohos.permission.LOCATION and ohos.permission.ACCESS_TRACE_ROUTE_INFO + * @since 20 + */ +int32_t OH_NetConn_QueryTraceRoute(char *destination, NetConn_TraceRouteOption *option, + NetConn_TraceRouteInfo *traceRouteInfo); + #ifdef __cplusplus } #endif diff --git a/network/netmanager/include/net_connection_type.h b/network/netmanager/include/net_connection_type.h index 4691534472f797b7fdece33eacd85f0c69606823..2fa5511905387b611e2d3a4b40c604a69b720440 100644 --- a/network/netmanager/include/net_connection_type.h +++ b/network/netmanager/include/net_connection_type.h @@ -131,6 +131,18 @@ typedef enum NetConn_ErrorCode { NETCONN_INTERNAL_ERROR = 2100003 } NetConn_ErrorCode; +/** + * @brief Enumerates packets type of trace route. + * + * @since 20 + */ +typedef enum NetConn_PacketsType { + /** ICMP */ + NETCONN_PACKETS_ICMP = 0, + /** UDP */ + NETCONN_PACKETS_UDP = 1 +} NetConn_PacketsType; + /** * @brief Defines the network handle. * @@ -393,6 +405,32 @@ typedef struct NetConn_ProbeResultInfo { uint32_t rtt[NETCONN_MAX_RTT_NUM]; } NetConn_ProbeResultInfo; +/** + * @brief Defines the network trace route option. + * + * @since 20 + */ +typedef struct NetConn_TraceRouteOption { + /** Maximum number of jumps, default is 30 */ + uint8_t maxJumpNumber; + /** Packets type */ + NetConn_PacketsType packetsType; +} NetConn_TraceRouteOption; + +/** + * @brief Defines the trace route information. + * + * @since 20 + */ +typedef struct NetConn_TraceRouteInfo { + /** Number of jumps */ + uint8_t jumpNo; + /** host name or address */ + char address[NETCONN_MAX_STR_LEN]; + /** RTT in micro seconds */ + uint32_t rtt[NETCONN_MAX_RTT_NUM]; +} NetConn_TraceRouteInfo; + #ifdef __cplusplus } #endif diff --git a/network/netmanager/libnet_connection.ndk.json b/network/netmanager/libnet_connection.ndk.json index 7d32accef8a78312c487bee1a622bfadfd7b06ee..ed2a16131598098e136c2718e19eecb1c6c753e1 100644 --- a/network/netmanager/libnet_connection.ndk.json +++ b/network/netmanager/libnet_connection.ndk.json @@ -90,5 +90,9 @@ { "first_introduced": "20", "name": "OH_NetConn_QueryProbeResult" + }, + { + "first_introduced": "20", + "name": "OH_NetConn_QueryTraceRoute" } ] \ No newline at end of file