pub struct MgmtClient { /* private fields */ }Expand description
Management client for a running ndn-fwd forwarder.
Sends NFD management Interests over an IpcFace and decodes the
ControlResponse from the returned Data packet.
On Unix the transport is a Unix domain socket; on Windows it is a
Named Pipe. Both are accessed through the same MgmtClient API.
Implementations§
Source§impl MgmtClient
impl MgmtClient
Sourcepub async fn connect(
face_socket: impl AsRef<str>,
) -> Result<Self, ForwarderError>
pub async fn connect( face_socket: impl AsRef<str>, ) -> Result<Self, ForwarderError>
Connect to the forwarder’s IPC socket.
face_socket is a Unix domain socket path on Unix (e.g.
/run/nfd/nfd.sock) or a Named Pipe path on Windows (e.g.
\\.\pipe\ndn).
Sourcepub fn from_face(face: Arc<IpcFace>) -> Self
pub fn from_face(face: Arc<IpcFace>) -> Self
Wrap an existing IpcFace (e.g. from a ForwarderClient).
Sourcepub async fn route_add(
&self,
prefix: &Name,
face_id: Option<u64>,
cost: u64,
) -> Result<ControlParameters, ForwarderError>
pub async fn route_add( &self, prefix: &Name, face_id: Option<u64>, cost: u64, ) -> Result<ControlParameters, ForwarderError>
Add (or update) a route: rib/register.
Pass face_id: None to let the router use the requesting face (the
default NFD behaviour when no FaceId is supplied). This is the correct
value to use when connecting over a Unix socket without SHM, because
there is no separate SHM face ID to reference.
Sourcepub async fn route_remove(
&self,
prefix: &Name,
face_id: Option<u64>,
) -> Result<ControlParameters, ForwarderError>
pub async fn route_remove( &self, prefix: &Name, face_id: Option<u64>, ) -> Result<ControlParameters, ForwarderError>
Remove a route: rib/unregister.
Pass face_id: None to remove the route on the requesting face.
Sourcepub async fn route_list(&self) -> Result<Vec<FibEntry>, ForwarderError>
pub async fn route_list(&self) -> Result<Vec<FibEntry>, ForwarderError>
List all FIB routes: fib/list.
Returns NFD TLV FibEntry dataset entries (per-spec wire format).
Sourcepub async fn rib_list(&self) -> Result<Vec<RibEntry>, ForwarderError>
pub async fn rib_list(&self) -> Result<Vec<RibEntry>, ForwarderError>
List all RIB routes: rib/list.
Returns NFD TLV RibEntry dataset entries (per-spec wire format).
Sourcepub async fn face_create(
&self,
uri: &str,
) -> Result<ControlParameters, ForwarderError>
pub async fn face_create( &self, uri: &str, ) -> Result<ControlParameters, ForwarderError>
Create a face: faces/create.
Sourcepub async fn face_create_with_mtu(
&self,
uri: &str,
mtu: Option<u64>,
) -> Result<ControlParameters, ForwarderError>
pub async fn face_create_with_mtu( &self, uri: &str, mtu: Option<u64>, ) -> Result<ControlParameters, ForwarderError>
Create a face with an optional mtu hint: faces/create.
For SHM faces the router uses mtu to size the ring slot so
it can carry Data packets whose content body is up to mtu
bytes. For Unix and network faces mtu is currently ignored.
Sourcepub async fn face_destroy(
&self,
face_id: u64,
) -> Result<ControlParameters, ForwarderError>
pub async fn face_destroy( &self, face_id: u64, ) -> Result<ControlParameters, ForwarderError>
Destroy a face: faces/destroy.
Sourcepub async fn face_list(&self) -> Result<Vec<FaceStatus>, ForwarderError>
pub async fn face_list(&self) -> Result<Vec<FaceStatus>, ForwarderError>
List all faces: faces/list.
Returns NFD TLV FaceStatus dataset entries (per-spec wire format).
Sourcepub async fn strategy_set(
&self,
prefix: &Name,
strategy: &Name,
) -> Result<ControlParameters, ForwarderError>
pub async fn strategy_set( &self, prefix: &Name, strategy: &Name, ) -> Result<ControlParameters, ForwarderError>
Set forwarding strategy for a prefix: strategy-choice/set.
Sourcepub async fn strategy_unset(
&self,
prefix: &Name,
) -> Result<ControlParameters, ForwarderError>
pub async fn strategy_unset( &self, prefix: &Name, ) -> Result<ControlParameters, ForwarderError>
Unset forwarding strategy for a prefix: strategy-choice/unset.
Sourcepub async fn strategy_list(&self) -> Result<Vec<StrategyChoice>, ForwarderError>
pub async fn strategy_list(&self) -> Result<Vec<StrategyChoice>, ForwarderError>
List all strategy choices: strategy-choice/list.
Returns NFD TLV StrategyChoice dataset entries (per-spec wire format).
Sourcepub async fn cs_info(&self) -> Result<ControlResponse, ForwarderError>
pub async fn cs_info(&self) -> Result<ControlResponse, ForwarderError>
Content store info: cs/info.
Sourcepub async fn cs_config(
&self,
capacity: Option<u64>,
) -> Result<ControlParameters, ForwarderError>
pub async fn cs_config( &self, capacity: Option<u64>, ) -> Result<ControlParameters, ForwarderError>
Configure CS capacity: cs/config.
If capacity is Some, sets the new max capacity in bytes.
Always returns the current capacity.
Sourcepub async fn cs_erase(
&self,
prefix: &Name,
count: Option<u64>,
) -> Result<ControlParameters, ForwarderError>
pub async fn cs_erase( &self, prefix: &Name, count: Option<u64>, ) -> Result<ControlParameters, ForwarderError>
Erase CS entries by prefix: cs/erase.
Returns the number of entries erased (in the count field of the
response ControlParameters).
Sourcepub async fn neighbors_list(&self) -> Result<ControlResponse, ForwarderError>
pub async fn neighbors_list(&self) -> Result<ControlResponse, ForwarderError>
List discovered neighbors: neighbors/list.
Sourcepub async fn service_list(&self) -> Result<ControlResponse, ForwarderError>
pub async fn service_list(&self) -> Result<ControlResponse, ForwarderError>
List locally announced services: service/list.
Sourcepub async fn service_announce(
&self,
prefix: &Name,
) -> Result<ControlParameters, ForwarderError>
pub async fn service_announce( &self, prefix: &Name, ) -> Result<ControlParameters, ForwarderError>
Announce a service prefix at runtime: service/announce.
Sourcepub async fn service_withdraw(
&self,
prefix: &Name,
) -> Result<ControlParameters, ForwarderError>
pub async fn service_withdraw( &self, prefix: &Name, ) -> Result<ControlParameters, ForwarderError>
Withdraw a previously announced service prefix: service/withdraw.
Sourcepub async fn service_browse(
&self,
prefix: Option<&Name>,
) -> Result<ControlResponse, ForwarderError>
pub async fn service_browse( &self, prefix: Option<&Name>, ) -> Result<ControlResponse, ForwarderError>
Browse all known service records (local + received from peers): service/browse.
When prefix is Some, the router returns only records whose
announced_prefix has prefix as a prefix (server-side filter).
Sourcepub async fn status(&self) -> Result<ControlResponse, ForwarderError>
pub async fn status(&self) -> Result<ControlResponse, ForwarderError>
General forwarder status: status/general.
Sourcepub async fn shutdown(&self) -> Result<ControlResponse, ForwarderError>
pub async fn shutdown(&self) -> Result<ControlResponse, ForwarderError>
Request graceful shutdown: status/shutdown.
Sourcepub async fn config_get(&self) -> Result<ControlResponse, ForwarderError>
pub async fn config_get(&self) -> Result<ControlResponse, ForwarderError>
Retrieve the running router configuration as TOML: config/get.
Sourcepub async fn face_counters(&self) -> Result<ControlResponse, ForwarderError>
pub async fn face_counters(&self) -> Result<ControlResponse, ForwarderError>
Per-face packet/byte counters: faces/counters.
Sourcepub async fn measurements_list(&self) -> Result<ControlResponse, ForwarderError>
pub async fn measurements_list(&self) -> Result<ControlResponse, ForwarderError>
Per-prefix measurements (satisfaction rate, RTTs): measurements/list.
Sourcepub async fn security_identity_list(
&self,
) -> Result<ControlResponse, ForwarderError>
pub async fn security_identity_list( &self, ) -> Result<ControlResponse, ForwarderError>
List all identity keys in the PIB: security/identity-list.
Sourcepub async fn security_identity_status(
&self,
) -> Result<ControlResponse, ForwarderError>
pub async fn security_identity_status( &self, ) -> Result<ControlResponse, ForwarderError>
Query the active identity status: security/identity-status.
Returns a ControlResponse whose status_text is a space-separated
key=value line: identity=<name> is_ephemeral=<bool> pib_path=<path>.
Works whether or not a PIB is configured (unlike identity-list).
Sourcepub async fn security_identity_generate(
&self,
name: &Name,
) -> Result<ControlParameters, ForwarderError>
pub async fn security_identity_generate( &self, name: &Name, ) -> Result<ControlParameters, ForwarderError>
Generate a new Ed25519 identity key: security/identity-generate.
Sourcepub async fn security_anchor_list(
&self,
) -> Result<ControlResponse, ForwarderError>
pub async fn security_anchor_list( &self, ) -> Result<ControlResponse, ForwarderError>
List all trust anchors in the PIB: security/anchor-list.
Sourcepub async fn security_key_delete(
&self,
name: &Name,
) -> Result<ControlParameters, ForwarderError>
pub async fn security_key_delete( &self, name: &Name, ) -> Result<ControlParameters, ForwarderError>
Delete a key from the PIB: security/key-delete.
Sourcepub async fn security_identity_did(
&self,
name: &Name,
) -> Result<ControlResponse, ForwarderError>
pub async fn security_identity_did( &self, name: &Name, ) -> Result<ControlResponse, ForwarderError>
Get the did:ndn: DID for a named identity: security/identity-did.
The response status_text contains the DID string.
Sourcepub async fn security_ca_info(&self) -> Result<ControlResponse, ForwarderError>
pub async fn security_ca_info(&self) -> Result<ControlResponse, ForwarderError>
Retrieve the router’s NDNCERT CA profile: security/ca-info.
Returns NOT_FOUND if no ca_prefix is configured.
Sourcepub async fn security_ca_enroll(
&self,
ca_prefix: &Name,
challenge_type: &str,
challenge_param: &str,
) -> Result<ControlParameters, ForwarderError>
pub async fn security_ca_enroll( &self, ca_prefix: &Name, challenge_type: &str, challenge_param: &str, ) -> Result<ControlParameters, ForwarderError>
Initiate NDNCERT enrollment with a CA: security/ca-enroll.
Parameters:
ca_prefix— NDN name of the CA (e.g./ndn/edu/example/CA)challenge_type—"token","pin","possession", or"yubikey-hotp"challenge_param— the challenge secret/code
The router starts a background enrollment session and returns immediately
with status_text = "started". Poll security/identity-list to detect
when the certificate has been installed.
Sourcepub async fn security_ca_token_add(
&self,
description: &str,
) -> Result<ControlParameters, ForwarderError>
pub async fn security_ca_token_add( &self, description: &str, ) -> Result<ControlParameters, ForwarderError>
Add a Zero-Touch-Provisioning token to the CA: security/ca-token-add.
Returns the generated token in ControlParameters::uri.
Sourcepub async fn security_ca_requests(
&self,
) -> Result<ControlResponse, ForwarderError>
pub async fn security_ca_requests( &self, ) -> Result<ControlResponse, ForwarderError>
List pending NDNCERT CA enrollment requests: security/ca-requests.
Sourcepub async fn security_yubikey_detect(
&self,
) -> Result<ControlResponse, ForwarderError>
pub async fn security_yubikey_detect( &self, ) -> Result<ControlResponse, ForwarderError>
Detect whether a YubiKey is connected: security/yubikey-detect.
Returns Ok with status_text = "present" if a YubiKey is found,
or an error if not present or the yubikey-piv feature is not compiled in.
Sourcepub async fn security_yubikey_generate(
&self,
name: &Name,
) -> Result<ControlParameters, ForwarderError>
pub async fn security_yubikey_generate( &self, name: &Name, ) -> Result<ControlParameters, ForwarderError>
Generate a P-256 key in YubiKey PIV slot 9a: security/yubikey-generate.
On success the response body.uri contains the base64url-encoded 65-byte
uncompressed public key.
Sourcepub async fn security_schema_list(
&self,
) -> Result<ControlResponse, ForwarderError>
pub async fn security_schema_list( &self, ) -> Result<ControlResponse, ForwarderError>
List all active trust schema rules: security/schema-list.
Returns a human-readable list of rules; one per line in the status_text:
[0] /data_pattern => /key_pattern
Sourcepub async fn security_schema_rule_add(
&self,
rule: &str,
) -> Result<ControlResponse, ForwarderError>
pub async fn security_schema_rule_add( &self, rule: &str, ) -> Result<ControlResponse, ForwarderError>
Add a trust schema rule: security/schema-rule-add.
rule must be in the form "<data_pattern> => <key_pattern>", e.g.:
"/sensor/<node>/<type> => /sensor/<node>/KEY/<id>".
Sourcepub async fn security_schema_rule_remove(
&self,
index: u64,
) -> Result<ControlResponse, ForwarderError>
pub async fn security_schema_rule_remove( &self, index: u64, ) -> Result<ControlResponse, ForwarderError>
Remove a trust schema rule by index: security/schema-rule-remove.
index is the 0-based position from security_schema_list().
Sourcepub async fn security_schema_set(
&self,
rules: &str,
) -> Result<ControlResponse, ForwarderError>
pub async fn security_schema_set( &self, rules: &str, ) -> Result<ControlResponse, ForwarderError>
Replace the entire trust schema: security/schema-set.
rules is a newline-separated list of rule strings. Each line must be in
the form "<data_pattern> => <key_pattern>". Pass an empty string to
clear all rules (schema rejects everything).
Sourcepub async fn discovery_status(&self) -> Result<ControlResponse, ForwarderError>
pub async fn discovery_status(&self) -> Result<ControlResponse, ForwarderError>
Get discovery protocol status and current config: discovery/status.
Sourcepub async fn discovery_config_set(
&self,
params: &str,
) -> Result<ControlResponse, ForwarderError>
pub async fn discovery_config_set( &self, params: &str, ) -> Result<ControlResponse, ForwarderError>
Update runtime-mutable discovery parameters: discovery/config.
Pass parameters as a URL query string:
"hello_interval_base_ms=5000&liveness_miss_count=3".
Supported keys: hello_interval_base_ms, hello_interval_max_ms,
hello_jitter, liveness_timeout_ms, liveness_miss_count,
probe_timeout_ms, swim_indirect_fanout, gossip_fanout,
auto_create_faces.
Sourcepub async fn routing_dvr_status(
&self,
) -> Result<ControlResponse, ForwarderError>
pub async fn routing_dvr_status( &self, ) -> Result<ControlResponse, ForwarderError>
Get DVR routing protocol status: routing/dvr-status.
Sourcepub async fn routing_dvr_config_set(
&self,
params: &str,
) -> Result<ControlResponse, ForwarderError>
pub async fn routing_dvr_config_set( &self, params: &str, ) -> Result<ControlResponse, ForwarderError>
Update runtime-mutable DVR parameters: routing/dvr-config.
Pass parameters as a URL query string:
"update_interval_ms=30000&route_ttl_ms=90000".
Sourcepub async fn log_get_filter(&self) -> Result<ControlResponse, ForwarderError>
pub async fn log_get_filter(&self) -> Result<ControlResponse, ForwarderError>
Get the current runtime log filter string: log/get-filter.
Sourcepub async fn log_get_recent(
&self,
after_seq: u64,
) -> Result<ControlResponse, ForwarderError>
pub async fn log_get_recent( &self, after_seq: u64, ) -> Result<ControlResponse, ForwarderError>
Get new log lines from the router’s in-memory ring buffer: log/get-recent.
Pass the last sequence number received (0 on first call) in after_seq.
The router returns only entries with a higher sequence number, so repeated
polls never replay old lines.
Response format: first line is the new max sequence number, followed by zero or more log lines.
Sourcepub async fn log_set_filter(
&self,
filter: &str,
) -> Result<ControlResponse, ForwarderError>
pub async fn log_set_filter( &self, filter: &str, ) -> Result<ControlResponse, ForwarderError>
Set the runtime log filter: log/set-filter.
The filter string is an EnvFilter-compatible directive
(e.g. "info", "debug,ndn_engine=trace").