OPT_FLAG("hdr-digest", 'g', &c.hdr_digest, nvmf_hdr_digest), \
OPT_FLAG("data-digest", 'G', &c.data_digest, nvmf_data_digest) \
+struct tr_config {
+ char *transport;
+ char *traddr;
+ char *host_traddr;
+ char *host_iface;
+ char *trsvcid;
+};
+
static void space_strip_len(int max, char *str)
{
int i;
return strcasecmp(s1, s2);
}
-static bool ctrl_config_match(nvme_ctrl_t c, char *transport,
- char *traddr, char *host_traddr,
- char *host_iface, char *trsvcid)
+static bool ctrl_config_match(nvme_ctrl_t c, struct tr_config *trcfg)
{
- if (!strcmp0(nvme_ctrl_get_transport(c), transport) &&
- !strcasecmp0(nvme_ctrl_get_traddr(c), traddr) &&
- !strcmp0(nvme_ctrl_get_trsvcid(c), trsvcid) &&
- !strcmp0(nvme_ctrl_get_host_traddr(c), host_traddr) &&
- !strcmp0(nvme_ctrl_get_host_iface(c), host_iface))
+ if (!strcmp0(nvme_ctrl_get_transport(c), trcfg->transport) &&
+ !strcasecmp0(nvme_ctrl_get_traddr(c), trcfg->traddr) &&
+ !strcmp0(nvme_ctrl_get_trsvcid(c), trcfg->trsvcid) &&
+ !strcmp0(nvme_ctrl_get_host_traddr(c), trcfg->host_traddr) &&
+ !strcmp0(nvme_ctrl_get_host_iface(c), trcfg->host_iface))
return true;
return false;
}
-static nvme_ctrl_t lookup_discover_ctrl(nvme_root_t r, char *transport,
- char *traddr, char *host_traddr,
- char *host_iface, char *trsvcid)
+static nvme_ctrl_t lookup_discover_ctrl(nvme_root_t r, struct tr_config *trcfg)
{
nvme_host_t h;
nvme_subsystem_t s;
nvme_subsystem_for_each_ctrl(s, c) {
if (!nvme_ctrl_is_discovery_ctrl(c))
continue;
- if (ctrl_config_match(c, transport, traddr,
- host_traddr, host_iface,
- trsvcid))
+ if (ctrl_config_match(c, trcfg))
return c;
}
}
if (!trsvcid)
trsvcid = get_default_trsvcid(transport, true);
+ struct tr_config trcfg = {
+ .transport = transport,
+ .traddr = traddr,
+ .host_traddr = cfg.host_traddr,
+ .host_iface = cfg.host_iface,
+ .trsvcid = trsvcid,
+ };
+
if (!force) {
- c = lookup_discover_ctrl(r, transport, traddr,
- cfg.host_traddr, cfg.host_iface,
- trsvcid);
+ c = lookup_discover_ctrl(r, &trcfg);
if (c) {
__discover(c, &cfg, raw, connect,
true, flags);
if (!trsvcid)
trsvcid = get_default_trsvcid(transport, true);
+ struct tr_config trcfg = {
+ .transport = transport,
+ .traddr = traddr,
+ .host_traddr = cfg.host_traddr,
+ .host_iface = cfg.host_iface,
+ .trsvcid = trsvcid,
+ };
+
if (device && !force) {
c = nvme_scan_ctrl(r, device);
if (c) {
/* Check if device matches command-line options */
- if (!ctrl_config_match(c, transport, traddr,
- cfg.host_traddr, cfg.host_iface,
- trsvcid)) {
+ if (!ctrl_config_match(c, &trcfg)) {
fprintf(stderr,
"ctrl device %s found, ignoring "
"non matching command-line options\n",
}
}
if (!c && !force) {
- c = lookup_discover_ctrl(r, transport, traddr,
- cfg.host_traddr, cfg.host_iface,
- trsvcid);
+ c = lookup_discover_ctrl(r, &trcfg);
if (c)
persistent = true;
}