Example #1
0
int pppoe_disc_start(struct pppoe_serv_t *serv)
{
	struct disc_net *net = find_net(serv->net);
	struct rb_node **p, *parent = NULL;
	struct tree *t;
	int ifindex = serv->ifindex, i;
	struct pppoe_serv_t *n;

	if (!net) {
		pthread_mutex_lock(&nets_lock);

		net = find_net(serv->net);
		if (!net)
			net = init_net(serv->net);

		pthread_mutex_unlock(&nets_lock);

		if (!net)
			return -1;
	}

	t = &net->tree[ifindex & HASH_BITS];

	pthread_mutex_lock(&t->lock);

	p = &t->root.rb_node;

	while (*p) {
		parent = *p;
		n = rb_entry(parent, typeof(*n), node);
		i = n->ifindex;

		if (ifindex < i)
			p = &(*p)->rb_left;
		else if (ifindex > i)
			p = &(*p)->rb_right;
		else {
			pthread_mutex_unlock(&t->lock);
			log_error("pppoe: disc: attempt to add duplicate ifindex\n");
			return -1;
		}
	}

	rb_link_node(&serv->node, parent, p);
	rb_insert_color(&serv->node, &t->root);

	pthread_mutex_unlock(&t->lock);

	return net->hnd.fd;
}
Example #2
0
static void grab_hidden_ssid(const unsigned char *bssid,
							 struct ieee80211_frame *wh,
							 int len,
							 const int off)
{
	struct network *n;
	unsigned char *p = ((unsigned char *) (wh + 1)) + off;
	int l;

	n = find_net(bssid);
	if (n && n->n_ssid[0]) return;

	len -= sizeof(*wh) + off + 2;

	if (len < 0) goto __bad;

	if (*p++ != IEEE80211_ELEMID_SSID) goto __bad;

	l = *p++;
	if (l > len) goto __bad;

	if (l == 0) return;

	if (!n) n = net_add(bssid);

	memcpy(n->n_ssid, p, l);
	n->n_ssid[l] = 0;

	check_network(n);
	return;

__bad:
	printf("bad grab_hidden_ssid\n");
	return;
}
Example #3
0
void pppoe_disc_stop(struct pppoe_serv_t *serv)
{
	struct disc_net *n = find_net(serv->net);
	struct tree *t = &n->tree[serv->ifindex & HASH_BITS];

	pthread_mutex_lock(&t->lock);
	rb_erase(&serv->node, &t->root);
	pthread_mutex_unlock(&t->lock);
}
Example #4
0
static inline struct network * find_add_net(const unsigned char * bssid)
{
	struct network * n;

	n = find_net(bssid);
	if (n) return (n);

	return (net_add(bssid));
}
Example #5
0
static struct network *find_add_net(const unsigned char *bssid)
{
	struct network *n;

	n = find_net(bssid);
	if (n) return n;

	return net_add(bssid);
}