File: network.c

package info (click to toggle)
s3d 0.2.2.1-7
  • links: PTS, VCS
  • area: main
  • in suites: forky, trixie
  • size: 5,356 kB
  • sloc: ansic: 21,128; python: 488; perl: 98; makefile: 31; sh: 29
file content (82 lines) | stat: -rw-r--r-- 1,638 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
// SPDX-License-Identifier: GPL-2.0-or-later
/* SPDX-FileCopyrightText: 2006-2015  Marek Lindner <mareklindner@neomailbox.ch>
 */



#include "kism3d.h"
#include <string.h>   /* strncmp(), strncpy() */
#include <stdlib.h>   /* rand() */



struct wlan_network *get_wlan_network(char *bssid) {

	struct wlan_network *wlan_network;


	wlan_network = find_wlan_network(bssid);

	if (wlan_network != NULL)
		return wlan_network;


	/* we reached the end of the list and must create a new wlan_network */
	wlan_network = (struct wlan_network*)alloc_memory(sizeof(struct wlan_network));

	INIT_LIST_HEAD(&wlan_network->list);

	strncpy(wlan_network->bssid, bssid, sizeof(wlan_network->bssid));
	wlan_network->bssid[sizeof(wlan_network->bssid) - 1] = '\0';

	wlan_network->type = -1;
	wlan_network->chan = -1;

	wlan_network->ssid = NULL;

	wlan_network->num_wlan_clients = 0;

	wlan_network->visible = 1;

	wlan_network->pos_vec[0] = wlan_network->pos_vec[1] = wlan_network->pos_vec[2] = 0;

	wlan_network->obj_id = -1;
	wlan_network->bssid_id = -1;
	wlan_network->ssid_id = -1;
	wlan_network->misc_id = -1;

	wlan_network->rotation = 0;
	wlan_network->scale_fac = 0;

	wlan_network->props_changed = 1;

	list_add_tail(&wlan_network->list, &Network_list);

	Num_networks++;

	return wlan_network;

}



struct wlan_network *find_wlan_network(char *bssid) {

	struct list_head *network_pos;
	struct wlan_network *wlan_network;


	list_for_each(network_pos, &Network_list) {

		wlan_network = list_entry(network_pos, struct wlan_network, list);

		if (strncmp(wlan_network->bssid, bssid, 18) == 0)
			return wlan_network;

	}


	return NULL;

}