Exemple #1
0
/*
 * Check whether we've lost our association with the AP
 */
static void
ni_wireless_set_association_timer(ni_wireless_t *wlan, const ni_timer_t *new_timer)
{
	if (wlan->assoc.timer != NULL)
		ni_timer_cancel(wlan->assoc.timer);
	wlan->assoc.timer = new_timer;
}
Exemple #2
0
void
ni_wireless_scan_free(ni_wireless_scan_t *scan)
{
	if (scan->timer)
		ni_timer_cancel(scan->timer);
	scan->timer = NULL;

	ni_wireless_network_array_destroy(&scan->networks);
	free(scan);
}
Exemple #3
0
static void
ni_autoip_device_close(ni_autoip_device_t *dev)
{
	if (dev->arp_socket)
		ni_arp_socket_close(dev->arp_socket);
	dev->arp_socket = NULL;

	if (dev->fsm.timer) {
		ni_timer_cancel(dev->fsm.timer);
		dev->fsm.timer = NULL;
	}
}
Exemple #4
0
static void
ni_dhcp4_fsm_restart(ni_dhcp4_device_t *dev)
{
	dev->fsm.state = NI_DHCP4_STATE_INIT;

	ni_dhcp4_device_disarm_retransmit(dev);
	if (dev->fsm.timer) {
		ni_timer_cancel(dev->fsm.timer);
		dev->fsm.timer = NULL;
	}
	dev->dhcp4.xid = 0;

	ni_dhcp4_device_drop_lease(dev);
}
Exemple #5
0
static void
ni_dhcp4_device_close(ni_dhcp4_device_t *dev)
{
	ni_capture_free(dev->capture);
	dev->capture = NULL;

	if (dev->listen_fd >= 0)
		close(dev->listen_fd);
	dev->listen_fd = -1;

	if (dev->fsm.timer) {
		ni_warn("%s: timer active for %s", __func__, dev->ifname);
		ni_timer_cancel(dev->fsm.timer);
		dev->fsm.timer = NULL;
	}

	ni_dhcp4_device_arp_close(dev);
}
Exemple #6
0
static int
__do_arp_validate(struct arp_handle *handle)
{
	ni_capture_devinfo_t dev_info;
	int ret;

	if ((ret = __do_arp_validate_init(handle, &dev_info)) != 0)
		return ret;

	handle->sock = ni_arp_socket_open(&dev_info,
			__do_arp_validate_process, handle);
	if (!handle->sock || !handle->sock->user_data) {
		ni_error("%s: Cannot initialize arp socket", handle->ifname);
		__do_arp_handle_close(handle);
		return NI_LSB_RC_ERROR;
	}

	if (!__do_arp_validate_send(handle)) {
		__do_arp_handle_close(handle);
		ni_error("%s: Cannot send arp packet", handle->ifname);
		return NI_LSB_RC_ERROR;
	}

	ret = NI_WICKED_RC_ERROR;
	while (!ni_caught_terminal_signal()) {
		long timeout;

		ret = NI_LSB_RC_SUCCESS;
		timeout = ni_timer_next_timeout();
		if (ni_socket_wait(timeout) != 0)
			break;
		ret = NI_WICKED_RC_ERROR;
	}
	if (handle->timer) {
		ni_timer_cancel(handle->timer);
		handle->timer = NULL;
	}
	__do_arp_handle_close(handle);

	return handle->hwaddr.len ? NI_LSB_RC_NOT_ALLOWED : ret;
}