On Fri, 17 Apr 2020 at 17:19, Denis Kenzior <denkenz(a)gmail.com> wrote:
On 4/3/20 11:14 AM, Andrew Zaborowski wrote:
> Add the functions to be called by manager.c and a minimal DBus API.
> ---
> Makefile.am | 1 +
> src/p2p.c | 354 ++++++++++++++++++++++++++++++++++++++++++++++++++++
> src/p2p.h | 31 +++++
> 3 files changed, 386 insertions(+)
> create mode 100644 src/p2p.c
> create mode 100644 src/p2p.h
>
<snip>
> +#include <stdlib.h>
> +#include <linux/rtnetlink.h>
> +#include <linux/if_ether.h>
> +#include <unistd.h>
> +#include <limits.h>
> +#include <stdio.h>
> +#include <time.h>
> +#include <errno.h>
So just for the future, it would be nice to introduce headers only as
you need them so it is a bit easier to track whether something is truly
required.
Ok, noted.
> +
> +#include <ell/ell.h>
> +
> +#include "linux/nl80211.h"
> +
> +#include "src/iwd.h"
> +#include "src/wiphy.h"
> +#include "src/scan.h"
> +#include "src/p2putil.h"
> +#include "src/ie.h"
> +#include "src/util.h"
> +#include "src/dbus.h"
> +#include "src/netdev.h"
> +#include "src/mpdu.h"
> +#include "src/common.h"
> +#include "src/wsc.h"
> +#include "src/handshake.h"
> +#include "src/crypto.h"
> +#include "src/module.h"
> +#include "src/frame-xchg.h"
> +#include "src/nl80211util.h"
> +#include "src/p2p.h"
Same for the internal ones...
<snip>
> +struct p2p_device *p2p_device_update_from_genl(struct l_genl_msg *msg,
> + bool create)
> +{
> + struct l_genl_attr attr;
> + uint16_t type, len;
> + const void *data;
> + const uint8_t *ifaddr = NULL;
> + const uint64_t *wdev_id = NULL;
> + struct wiphy *wiphy = NULL;
> + struct p2p_device *dev;
> +
> + if (!l_genl_attr_init(&attr, msg))
> + return NULL;
> +
> + while (l_genl_attr_next(&attr, &type, &len, &data)) {
> + switch (type) {
> + case NL80211_ATTR_WDEV:
> + if (len != sizeof(uint64_t)) {
> + l_warn("Invalid wdev index attribute");
> + return NULL;
> + }
> +
> + wdev_id = data;
> + break;
> +
> + case NL80211_ATTR_WIPHY:
> + if (len != sizeof(uint32_t)) {
> + l_warn("Invalid wiphy attribute");
> + return NULL;
> + }
> +
> + wiphy = wiphy_find(*((uint32_t *) data));
> + break;
> +
> + case NL80211_ATTR_IFTYPE:
> + if (len != sizeof(uint32_t)) {
> + l_warn("Invalid interface type attribute");
> + return NULL;
> + }
> +
> + if (*((uint32_t *) data) != NL80211_IFTYPE_P2P_DEVICE)
> + return NULL;
> +
> + break;
> +
> + case NL80211_ATTR_MAC:
> + if (len != ETH_ALEN) {
> + l_warn("Invalid interface address
attribute");
> + return NULL;
> + }
> +
> + ifaddr = data;
> + break;
> + }
> + }
I suspect you can change this to use nl80211util now...
I'll try to remember to do this afterwards.
Best regards