[PATCH 1/3] auto-t: return None with get_ordered_network(s)
by James Prestwood
If no networks are found, return None rather than an empty
array. This is easier to check by the caller (and was assumed
in some cases). Also add an exception to get_ordered_network
if no network is found.
---
autotests/util/iwd.py | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/autotests/util/iwd.py b/autotests/util/iwd.py
index 3ba5112c..35e5a693 100755
--- a/autotests/util/iwd.py
+++ b/autotests/util/iwd.py
@@ -376,6 +376,10 @@ class Device(IWDDBusAbstract):
for bus_obj in self._station.GetOrderedNetworks():
ordered_network = OrderedNetwork(bus_obj)
ordered_networks.append(ordered_network)
+
+ if len(ordered_networks) == 0:
+ return None
+
return ordered_networks
def get_ordered_network(self, network):
@@ -385,6 +389,9 @@ class Device(IWDDBusAbstract):
'''
ordered_networks = self.get_ordered_networks()
+ if not ordered_networks:
+ raise Exception('Network %s not found' % network)
+
for n in ordered_networks:
if n.name == network:
return n
--
2.17.1
1 year, 4 months
[PATCH] Don't pass NULL as src to memcpy, even when zero len.
by Will Dietz
Skip the memcpy when len = 0, definitely don't ignore attempt
to copy X bytes from NULL where X != 0 :).
---
monitor/main.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/monitor/main.c b/monitor/main.c
index 020dba86..41692cd1 100644
--- a/monitor/main.c
+++ b/monitor/main.c
@@ -176,7 +176,8 @@ static size_t rta_add(void *rta_buf, unsigned short type, uint16_t len,
rta->rta_len = rta_len;
rta->rta_type = type;
- memcpy(RTA_DATA(rta), data, len);
+ if (len)
+ memcpy(RTA_DATA(rta), data, len);
return RTA_SPACE(len);
}
--
2.24.0-rc1
1 year, 4 months
[PATCH] client: Cancel agent prompt with CTRL+D
by Tim Kourt
Previously, CTRL+D used to cause termination of the client. Now, the
command will cancel the agent’s prompts in agent mod. In regular mode
the behavior is unchanged.
---
client/agent.c | 28 +++++++++++++++++++---------
client/display.c | 8 ++++----
2 files changed, 23 insertions(+), 13 deletions(-)
diff --git a/client/agent.c b/client/agent.c
index 78499419..16bc3c4f 100644
--- a/client/agent.c
+++ b/client/agent.c
@@ -366,14 +366,17 @@ static void process_input_username_password(const char *prompt)
struct l_dbus_message *reply;
char *username;
- if (l_queue_isempty(pending_op.saved_input)) {
- /* received username */
- if (!strlen(prompt)) {
- reply = agent_reply_canceled(pending_message,
+ if (!prompt || !strlen(prompt)) {
+ reply = agent_reply_canceled(pending_message,
"Canceled by user");
- goto send_reply;
- }
+ l_queue_clear(pending_op.saved_input, l_free);
+
+ goto send_reply;
+ }
+
+ if (l_queue_isempty(pending_op.saved_input)) {
+ /* received username */
l_queue_push_tail(pending_op.saved_input, l_strdup(prompt));
display_agent_prompt(PROMPT_PASSWORD, true);
@@ -397,7 +400,7 @@ static void process_input_passphrase(const char *prompt)
{
struct l_dbus_message *reply;
- if (!strlen(prompt)) {
+ if (!prompt || !strlen(prompt)) {
reply = agent_reply_canceled(pending_message,
"Canceled by user");
goto send_reply;
@@ -412,11 +415,18 @@ send_reply:
static void process_input_password(const char *prompt)
{
- struct l_dbus_message *reply =
- l_dbus_message_new_method_return(pending_message);
+ struct l_dbus_message *reply;
+
+ if (!prompt || !strlen(prompt)) {
+ reply = agent_reply_canceled(pending_message,
+ "Canceled by user");
+ goto send_reply;
+ }
+ reply = l_dbus_message_new_method_return(pending_message);
l_dbus_message_set_arguments(reply, "s", prompt);
+send_reply:
agent_send_reply(reply);
}
diff --git a/client/display.c b/client/display.c
index c08183da..cd17ad84 100644
--- a/client/display.c
+++ b/client/display.c
@@ -465,6 +465,10 @@ static void readline_callback(char *prompt)
HIST_ENTRY *previous_prompt;
+ if (agent_prompt(masked_input.use_mask ?
+ masked_input.passphrase : prompt))
+ goto done;
+
if (!prompt) {
display_quit();
@@ -473,10 +477,6 @@ static void readline_callback(char *prompt)
return;
}
- if (agent_prompt(masked_input.use_mask ?
- masked_input.passphrase : prompt))
- goto done;
-
if (!strlen(prompt))
goto done;
--
2.13.6
1 year, 4 months
[PATCH 1/5] client: Consolidate cancelation replies
by Tim Kourt
---
client/agent.c | 19 +++++++++++++------
1 file changed, 13 insertions(+), 6 deletions(-)
diff --git a/client/agent.c b/client/agent.c
index 8af714a2..b80e5727 100644
--- a/client/agent.c
+++ b/client/agent.c
@@ -50,6 +50,15 @@ static struct pending_op {
struct l_queue *saved_input;
} pending_op;
+static struct l_dbus_message *agent_reply_canceled(
+ struct l_dbus_message *message,
+ const char *text)
+{
+ return l_dbus_message_new_error(message,
+ IWD_AGENT_INTERFACE ".Error.Canceled",
+ "Error: %s", text);
+}
+
static struct l_dbus_message *agent_error(const char *text)
{
display_error(text);
@@ -342,9 +351,8 @@ static void process_input_username_password(const char *prompt)
if (l_queue_isempty(pending_op.saved_input)) {
/* received username */
if (!strlen(prompt)) {
- reply = l_dbus_message_new_error(pending_message,
- IWD_AGENT_INTERFACE ".Error.Canceled",
- "Canceled by user");
+ reply = agent_reply_canceled(pending_message,
+ "Canceled by user");
goto send_reply;
}
@@ -372,9 +380,8 @@ static void process_input_passphrase(const char *prompt)
struct l_dbus_message *reply;
if (!strlen(prompt)) {
- reply = l_dbus_message_new_error(pending_message,
- IWD_AGENT_INTERFACE ".Error.Canceled",
- "Canceled by user");
+ reply = agent_reply_canceled(pending_message,
+ "Canceled by user");
goto send_reply;
}
--
2.13.6
1 year, 4 months
[PATCH] manpages: replace shorthand words
by James Prestwood
Replaces cases of 'certs' with 'certificates', and 8021x with IEEE 802.1x
---
src/iwd.network.rst | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/src/iwd.network.rst b/src/iwd.network.rst
index 33efd3f4..4a843b7e 100644
--- a/src/iwd.network.rst
+++ b/src/iwd.network.rst
@@ -234,10 +234,10 @@ authentication configuration.
Embedded PEMs
-------------
-Rather than including an absolute path to a PEM file (for certs or keys), the
-PEM itself can be included inside the settings file and referenced directly.
-This allows 8021x network provisioning using a single file without any
-references to certificates/keys on the system.
+Rather than including an absolute path to a PEM file (for certificates and
+keys), the PEM itself can be included inside the settings file and referenced
+directly. This allows IEEE 802.1x network provisioning using a single file
+without any references to certificates or keys on the system.
An embedded PEM can appear anywhere in the settings file using the following
format (this example the PEM is named 'my_ca_cert'):
@@ -255,8 +255,8 @@ elsewhere in the settings file by prefixing the value with 'embed:'
EAP-TLS-CACert=embed:my_ca_cert
-This is not limited to CA Certs either. Client certs, client keys (encrypted
-or not), and certificate chains can be included.
+This is not limited to CA Certificates either. Client certificates, client keys
+(encrypted or not), and certificate chains can be included.
SEE ALSO
========
--
2.17.1
1 year, 4 months
[PATCH 1/8] wiphy: Add wiphy_get_supported_rates
by Andrew Zaborowski
Add code to parse the supported data rates info from the wiphy dumps and
expose it for P2P's use with a getter function.
---
src/wiphy.c | 78 ++++++++++++++++++++++++++++++++++++++++++++++++++---
src/wiphy.h | 2 ++
2 files changed, 76 insertions(+), 4 deletions(-)
diff --git a/src/wiphy.c b/src/wiphy.c
index 9cb9ae66..12ec5d17 100644
--- a/src/wiphy.c
+++ b/src/wiphy.c
@@ -76,6 +76,7 @@ struct wiphy {
struct watchlist state_watches;
uint8_t extended_capabilities[EXT_CAP_LEN + 2]; /* max bitmap size + IE header */
uint8_t *iftype_extended_capabilities[NUM_NL80211_IFTYPES];
+ uint8_t *supported_rates[NUM_NL80211_BANDS];
uint8_t rm_enabled_capabilities[7]; /* 5 size max + header */
bool support_scheduled_scan:1;
@@ -212,6 +213,9 @@ static void wiphy_free(void *data)
for (i = 0; i < NUM_NL80211_IFTYPES; i++)
l_free(wiphy->iftype_extended_capabilities[i]);
+ for (i = 0; i < NUM_NL80211_BANDS; i++)
+ l_free(wiphy->supported_rates[i]);
+
scan_freq_set_free(wiphy->supported_freqs);
watchlist_destroy(&wiphy->state_watches);
l_free(wiphy->model_str);
@@ -478,6 +482,14 @@ bool wiphy_supports_iftype(struct wiphy *wiphy, uint32_t iftype)
return wiphy->supported_iftypes & (1 << (iftype - 1));
}
+const uint8_t *wiphy_get_supported_rates(struct wiphy *wiphy, unsigned int band)
+{
+ if (band >= L_ARRAY_SIZE(wiphy->supported_rates))
+ return NULL;
+
+ return wiphy->supported_rates[band];
+}
+
uint32_t wiphy_state_watch_add(struct wiphy *wiphy,
wiphy_state_watch_func_t func,
void *user_data, wiphy_destroy_func_t destroy)
@@ -622,20 +634,70 @@ static void parse_supported_frequencies(struct wiphy *wiphy,
}
}
+static uint8_t *parse_supported_rates(struct l_genl_attr *attr)
+{
+ uint16_t type;
+ uint16_t len;
+ const void *data;
+ struct l_genl_attr nested;
+ int count = 0;
+ uint8_t *ret;
+
+ if (!l_genl_attr_recurse(attr, &nested))
+ return NULL;
+
+ while (l_genl_attr_next(&nested, NULL, NULL, NULL))
+ count++;
+
+ if (!l_genl_attr_recurse(attr, &nested))
+ return NULL;
+
+ ret = l_malloc(count + 1);
+ ret[count] = 0;
+
+ count = 0;
+
+ while (l_genl_attr_next(&nested, NULL, NULL, NULL)) {
+ struct l_genl_attr nested2;
+
+ if (!l_genl_attr_recurse(&nested, &nested2)) {
+ l_free(ret);
+ return NULL;
+ }
+
+ while (l_genl_attr_next(&nested2, &type, &len, &data)) {
+ if (type != NL80211_BITRATE_ATTR_RATE || len != 4)
+ continue;
+
+ /*
+ * Convert from the 100kb/s units reported by the
+ * kernel to the 500kb/s used in 802.11 IEs.
+ */
+ ret[count++] = *(const uint32_t *) data / 5;
+ }
+ }
+
+ return ret;
+}
+
static void parse_supported_bands(struct wiphy *wiphy,
struct l_genl_attr *bands)
{
- uint16_t type, len;
- const void *data;
+ uint16_t type;
struct l_genl_attr attr;
l_debug("");
- while (l_genl_attr_next(bands, NULL, NULL, NULL)) {
+ while (l_genl_attr_next(bands, &type, NULL, NULL)) {
+ enum nl80211_band band = type;
+
+ if (band != NL80211_BAND_2GHZ && band != NL80211_BAND_5GHZ)
+ continue;
+
if (!l_genl_attr_recurse(bands, &attr))
continue;
- while (l_genl_attr_next(&attr, &type, &len, &data)) {
+ while (l_genl_attr_next(&attr, &type, NULL, NULL)) {
struct l_genl_attr freqs;
switch (type) {
@@ -645,6 +707,14 @@ static void parse_supported_bands(struct wiphy *wiphy,
parse_supported_frequencies(wiphy, &freqs);
break;
+
+ case NL80211_BAND_ATTR_RATES:
+ if (wiphy->supported_rates[band])
+ continue;
+
+ wiphy->supported_rates[band] =
+ parse_supported_rates(&attr);
+ break;
}
}
}
diff --git a/src/wiphy.h b/src/wiphy.h
index c109f0a8..a5133972 100644
--- a/src/wiphy.h
+++ b/src/wiphy.h
@@ -66,6 +66,8 @@ bool wiphy_has_ext_feature(struct wiphy *wiphy, uint32_t feature);
uint8_t wiphy_get_max_num_ssids_per_scan(struct wiphy *wiphy);
uint32_t wiphy_get_max_roc_duration(struct wiphy *wiphy);
bool wiphy_supports_iftype(struct wiphy *wiphy, uint32_t iftype);
+const uint8_t *wiphy_get_supported_rates(struct wiphy *wiphy,
+ unsigned int band);
bool wiphy_supports_adhoc_rsn(struct wiphy *wiphy);
bool wiphy_can_offchannel_tx(struct wiphy *wiphy);
bool wiphy_supports_qos_set_map(struct wiphy *wiphy);
--
2.20.1
1 year, 4 months
[PATCH] client: Fix network name completion
by Tim Kourt
Exclude the network names that are shorter then the query text
from the autocompletion network name list.
---
client/network.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/client/network.c b/client/network.c
index 023a505c..b4ce3235 100644
--- a/client/network.c
+++ b/client/network.c
@@ -228,6 +228,9 @@ static bool match_by_partial_name(const void *a, const void *b)
return false;
}
+ if (*text)
+ return false;
+
return true;
}
--
2.13.6
1 year, 4 months
[PATCH] network: add L_WARN for known network lookup failure
by James Prestwood
When updating the network ranking there was a potential out of bounds
array access. The condition was if known_network_offset returned a
negative value, indicating the known network was not found. Since
network->info is only set for known networks this should not ever
happen as network->info is checked prior.
Though this is likely impossible, knownnetworks is complex enough that
its better to just be paranoid and put an L_WARN_ON to check the
return.
---
src/network.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/src/network.c b/src/network.c
index 3270b57c..0f29022b 100644
--- a/src/network.c
+++ b/src/network.c
@@ -1376,6 +1376,8 @@ void network_rank_update(struct network *network, bool connected)
if (network->info->connected_time != 0) {
int n = known_network_offset(network->info);
+ L_WARN_ON(n < 0);
+
if (n >= (int) L_ARRAY_SIZE(rankmod_table))
n = L_ARRAY_SIZE(rankmod_table) - 1;
--
2.21.0
1 year, 4 months
[PATCH] manpage: add section on embedding PEMs in settings
by James Prestwood
---
src/iwd.network.rst | 27 +++++++++++++++++++++++++++
1 file changed, 27 insertions(+)
diff --git a/src/iwd.network.rst b/src/iwd.network.rst
index 75b8297a..2410aa57 100644
--- a/src/iwd.network.rst
+++ b/src/iwd.network.rst
@@ -235,6 +235,33 @@ authentication configuration.
method's negotiation is encrypted, a secure identity string can be
provided.
+Embedded PEMs
+-------------
+
+Rather than including an absolute path to a PEM file (for certs or keys), the
+PEM itself can be included inside the settings file and referenced directly.
+This allows 8021x network provisioning using a single file without any
+references to certificates/keys on the system.
+
+An embedded PEM can appear anywhere in the settings file using the following
+format (this example the PEM is named 'my_ca_cert'):
+
+.. code-block::
+
+ [@pem@my_ca_cert]
+ ----- BEGIN CERTIFICATE -----
+ <PEM data>
+ ----- END CERTIFICATE -----
+
+After this special group tag its as simple as pasting in a PEM file including
+the BEGIN/END tags. Now 'my_ca_cert' can be used to reference the certificate
+elsewhere in the settings file by prefixing the value with 'embed:'
+
+EAP-TLS-CACert=embed:my_ca_cert
+
+This is not limited to CA Certs either. Client certs, client keys (encrypted
+or not), and certificate chains can be included.
+
SEE ALSO
========
--
2.21.0
1 year, 4 months
[PATCH 01/11] netdev: Add a wdev_id based frame watch API
by Andrew Zaborowski
From: Andrew Zaborowski <andrew.zaborowski(a)intel.com>
Allow watching for frames on interfaces that have no netdev in the
kernel and can only be referenced through the wdev_id instead of the
ifindex.
---
src/netdev.c | 86 +++++++++++++++++++++++++++++++++++++++++++++++-----
src/netdev.h | 6 ++++
2 files changed, 84 insertions(+), 8 deletions(-)
diff --git a/src/netdev.c b/src/netdev.c
index 350ade98..526480dd 100644
--- a/src/netdev.c
+++ b/src/netdev.c
@@ -167,6 +167,7 @@ struct netdev_frame_watch {
uint16_t frame_type;
uint8_t *prefix;
size_t prefix_len;
+ uint64_t wdev_id;
struct watchlist_item super;
};
@@ -174,6 +175,7 @@ static struct l_netlink *rtnl = NULL;
static struct l_genl_family *nl80211;
static struct l_queue *netdev_list;
static struct watchlist netdev_watches;
+static struct watchlist wdev_frame_watches;
static void do_debug(const char *str, void *user_data)
{
@@ -3482,6 +3484,7 @@ struct frame_prefix_info {
uint16_t frame_type;
const uint8_t *body;
size_t body_len;
+ uint64_t wdev_id;
};
static bool netdev_frame_watch_match_prefix(const void *a, const void *b)
@@ -3494,11 +3497,13 @@ static bool netdev_frame_watch_match_prefix(const void *a, const void *b)
return fw->frame_type == info->frame_type &&
fw->prefix_len <= info->body_len &&
(fw->prefix_len == 0 ||
- !memcmp(fw->prefix, info->body, fw->prefix_len));
+ !memcmp(fw->prefix, info->body, fw->prefix_len)) &&
+ (!info->wdev_id || info->wdev_id == fw->wdev_id);
}
static void netdev_mgmt_frame_event(struct l_genl_msg *msg,
- struct netdev *netdev)
+ struct netdev *netdev,
+ uint64_t wdev_id)
{
struct l_genl_attr attr;
uint16_t type, len, frame_len;
@@ -3530,7 +3535,7 @@ static void netdev_mgmt_frame_event(struct l_genl_msg *msg,
body = mmpdu_body(mpdu);
- if (memcmp(mpdu->address_1, netdev->addr, 6) &&
+ if (netdev && memcmp(mpdu->address_1, netdev->addr, 6) &&
!util_is_broadcast_address(mpdu->address_1))
return;
@@ -3539,11 +3544,18 @@ static void netdev_mgmt_frame_event(struct l_genl_msg *msg,
info.frame_type = l_get_le16(mpdu) & FC_FTYPE_STYPE_MASK;
info.body = (const uint8_t *) body;
info.body_len = (const uint8_t *) mpdu + frame_len - body;
+ info.wdev_id = netdev ? 0 : wdev_id;
- WATCHLIST_NOTIFY_MATCHES(&netdev->frame_watches,
+ if (netdev)
+ WATCHLIST_NOTIFY_MATCHES(&netdev->frame_watches,
netdev_frame_watch_match_prefix, &info,
netdev_frame_watch_func_t,
netdev, mpdu, body, info.body_len);
+ else
+ WATCHLIST_NOTIFY_MATCHES(&wdev_frame_watches,
+ netdev_frame_watch_match_prefix, &info,
+ netdev_frame_watch_func_t,
+ NULL, mpdu, body, info.body_len);
}
static void netdev_pae_destroy(void *user_data)
@@ -3735,6 +3747,7 @@ static int netdev_control_port_frame(uint32_t ifindex,
static void netdev_unicast_notify(struct l_genl_msg *msg, void *user_data)
{
struct netdev *netdev = NULL;
+ const uint64_t *wdev_id = NULL;
struct l_genl_attr attr;
uint16_t type, len;
const void *data;
@@ -3759,17 +3772,28 @@ static void netdev_unicast_notify(struct l_genl_msg *msg, void *user_data)
netdev = netdev_find(*((uint32_t *) data));
break;
+ case NL80211_ATTR_WDEV:
+ if (len != sizeof(uint64_t)) {
+ l_warn("Invalid wdev attribute");
+ return;
+ }
+
+ wdev_id = data;
+ break;
}
}
- if (!netdev)
- return;
-
switch (cmd) {
case NL80211_CMD_FRAME:
- netdev_mgmt_frame_event(msg, netdev);
+ if (!wdev_id)
+ break;
+
+ netdev_mgmt_frame_event(msg, netdev, *wdev_id);
break;
case NL80211_CMD_CONTROL_PORT_FRAME:
+ if (!netdev)
+ break;
+
netdev_control_port_frame_event(msg, netdev);
break;
}
@@ -4456,6 +4480,50 @@ bool netdev_frame_watch_remove(struct netdev *netdev, uint32_t id)
return watchlist_remove(&netdev->frame_watches, id);
}
+uint32_t netdev_wdev_frame_watch_add(uint64_t wdev_id, uint16_t frame_type,
+ const uint8_t *prefix, size_t prefix_len,
+ netdev_frame_watch_func_t handler,
+ void *user_data)
+{
+ struct netdev_frame_watch *fw;
+ struct l_genl_msg *msg;
+ struct frame_prefix_info info = { frame_type, prefix, prefix_len, wdev_id };
+ bool registered;
+ uint32_t id;
+
+ registered = l_queue_find(wdev_frame_watches.items,
+ netdev_frame_watch_match_prefix,
+ &info);
+
+ fw = l_new(struct netdev_frame_watch, 1);
+ fw->frame_type = frame_type;
+ fw->prefix = prefix_len ? l_memdup(prefix, prefix_len) : NULL;
+ fw->prefix_len = prefix_len;
+ fw->wdev_id = wdev_id;
+ id = watchlist_link(&wdev_frame_watches, &fw->super,
+ handler, user_data, NULL);
+
+ if (registered)
+ return id;
+
+ msg = l_genl_msg_new_sized(NL80211_CMD_REGISTER_FRAME, 32 + prefix_len);
+
+ l_genl_msg_append_attr(msg, NL80211_ATTR_WDEV, 8, &wdev_id);
+ l_genl_msg_append_attr(msg, NL80211_ATTR_FRAME_TYPE, 2, &frame_type);
+ l_genl_msg_append_attr(msg, NL80211_ATTR_FRAME_MATCH,
+ prefix_len, prefix);
+
+ l_genl_family_send(nl80211, msg, netdev_frame_cb,
+ L_UINT_TO_PTR(frame_type), NULL);
+
+ return id;
+}
+
+bool netdev_wdev_frame_watch_remove(uint32_t id)
+{
+ return watchlist_remove(&wdev_frame_watches, id);
+}
+
static struct l_io *pae_open(uint32_t ifindex)
{
/*
@@ -4796,6 +4864,8 @@ static int netdev_init(void)
watchlist_init(&netdev_watches, NULL);
netdev_list = l_queue_new();
+ watchlist_init(&wdev_frame_watches, &netdev_frame_watch_ops);
+
__handshake_set_install_tk_func(netdev_set_tk);
__handshake_set_install_gtk_func(netdev_set_gtk);
__handshake_set_install_igtk_func(netdev_set_igtk);
diff --git a/src/netdev.h b/src/netdev.h
index 114a6035..624811b2 100644
--- a/src/netdev.h
+++ b/src/netdev.h
@@ -197,6 +197,12 @@ uint32_t netdev_frame_watch_add(struct netdev *netdev, uint16_t frame_type,
void *user_data);
bool netdev_frame_watch_remove(struct netdev *netdev, uint32_t id);
+uint32_t netdev_wdev_frame_watch_add(uint64_t wdev_id, uint16_t frame_type,
+ const uint8_t *prefix, size_t prefix_len,
+ netdev_frame_watch_func_t handler,
+ void *user_data);
+bool netdev_wdev_frame_watch_remove(uint32_t id);
+
void netdev_handshake_failed(struct handshake_state *hs, uint16_t reason_code);
struct netdev *netdev_find(int ifindex);
--
2.20.1
1 year, 4 months