예제 #1
0
static void nl80211_cleanup(struct nl80211_state *state)
{
	genl_family_put(state->nl80211);

	nl_cache_free(state->nl_cache);
	nl_socket_free(state->nl_sock);
}
예제 #2
0
static bool nl80211_init()
{
	int err;

	sock = nl_socket_alloc();
	if (!sock) {
		fprintf(stderr, "failed to allocate netlink socket\n");
		goto out;
	}

	err = genl_connect(sock);
	if (err) {
		nl_perror(err, "failed to make generic netlink connection");
		goto out;
	}

	err = genl_ctrl_alloc_cache(sock, &cache);
	if (err) {
		nl_perror(err, "failed to allocate netlink controller cache");
		goto out;
	}

	family = genl_ctrl_search_by_name(cache, NL80211_GENL_NAME);
	if (!family) {
		fprintf(stderr, "failed to find nl80211\n");
		goto out;
	}

	return true;
out:
	genl_family_put(family);
	nl_cache_free(cache);
	nl_socket_free(sock);
	return false;
}
static void netlink_exit(void)
{
    g_io_channel_unref(channel);

    genl_family_put(family);
    nl_cache_free(cache);
    nl_handle_destroy(handle);
}
예제 #4
0
파일: cnl80211.cpp 프로젝트: stbuehler/nut
void CNL80211::close() {
	//don't check if not connected, check pointers
	if (m_nlSn) {
		m_nlSn->setEnabled(false);
		delete m_nlSn;
	}
	if (m_nlFamily)
		genl_family_put(m_nlFamily);
	if (m_nlCache)
		nl_cache_free(m_nlCache);
	if (m_nlSocket)
		nl_socket_free(m_nlSocket);
	m_nlFd = -1;
	m_connected = false;
}
static int netlink_init(void)
{
    info("Starting experimental netlink support");

    handle = nl_handle_alloc();
    if (!handle) {
        error("Failed to allocate netlink handle");
        return -ENOMEM;
    }

    if (genl_connect(handle) < 0) {
        error("Failed to connect to generic netlink");
        nl_handle_destroy(handle);
        return -ENOLINK;
    }

    cache = genl_ctrl_alloc_cache(handle);
    if (!cache) {
        error("Failed to allocate generic netlink cache");
        return -ENOMEM;
        nl_handle_destroy(handle);
    }

    family = genl_ctrl_search_by_name(cache, "bluetooth");
    if (!family) {
        error("Failed to find Bluetooth netlink family");
        nl_cache_free(cache);
        nl_handle_destroy(handle);
        return -ENOENT;
    }

    if (create_channel(nl_socket_get_fd(handle)) < 0)  {
        error("Failed to create netlink IO channel");
        genl_family_put(family);
        nl_cache_free(cache);
        nl_handle_destroy(handle);
        return -ENOMEM;
    }

    return 0;
}
예제 #6
0
static void deinit_nl()
{
    genl_family_put(nl80211);
    nl_cache_free(nl_cache);
    nl_socket_free(nl_soc);
}
예제 #7
0
void SoftapController::deinitNl() {
    genl_family_put(nl80211);
    nl_cache_free(nl_cache);
    nl_socket_free(nl_soc);
}
예제 #8
0
static void nl80211_finish() {
	nl_socket_free(sock);
	genl_family_put(family);
	nl_cache_free(cache);
}