aboutsummaryrefslogtreecommitdiffstats
path: root/src/ipa_unit.c
blob: ccf88416d7b7e90982ed8484419ea2e4bba25c98 (plain)
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#include <osmocom/core/talloc.h>

#include <stdint.h>
#include <string.h>

struct ipaccess_unit {
	uint16_t	site_id;
	uint16_t	bts_id;
	uint16_t	trx_id;
	char		*name;
	char		*hwvers;
	char		*swvers;
	uint8_t		mac_addr[6];
	char		*location1;
	char		*location2;
	char		*serno;
};

struct ipaccess_unit *osmo_ipa_unit_alloc()
{
	struct ipaccess_unit *unit;

	unit = talloc_zero(NULL, struct ipaccess_unit);
	if (unit == NULL)
		return NULL;

	unit->name = strdup("");
	unit->hwvers = strdup("");
	unit->swvers = strdup("");
	unit->location1 = strdup("");
	unit->location2 = strdup("");
	unit->serno = strdup("");

	return unit;
}

void osmo_ipa_unit_free(struct ipaccess_unit *unit)
{
	if (unit->name)
		free(unit->name);
	if (unit->hwvers)
		free(unit->hwvers);
	if (unit->swvers)
		free(unit->swvers);
	if (unit->location1)
		free(unit->location1);
	if (unit->location2)
		free(unit->location2);
	if (unit->serno)
		free(unit->serno);

	talloc_free(unit);
}

void osmo_ipa_unit_set_site_id(struct ipaccess_unit *unit, uint16_t site_id)
{
	unit->site_id = site_id;
}

void osmo_ipa_unit_set_bts_id(struct ipaccess_unit *unit, uint16_t bts_id)
{
	unit->bts_id = bts_id;
}

void osmo_ipa_unit_set_trx_id(struct ipaccess_unit *unit, uint16_t trx_id)
{
	unit->trx_id = trx_id;
}

void osmo_ipa_unit_set_unit_name(struct ipaccess_unit *unit, const char *name)
{
	if (unit->name)
		free(unit->name);

	unit->name = strdup(name);
}

void osmo_ipa_unit_set_unit_hwvers(struct ipaccess_unit *unit, const char *vers)
{
	if (unit->hwvers)
		free(unit->hwvers);

	unit->hwvers = strdup(vers);
}

void osmo_ipa_unit_set_unit_swvers(struct ipaccess_unit *unit, const char *vers)
{
	if (unit->swvers)
		free(unit->swvers);

	unit->swvers = strdup(vers);
}

void osmo_ipa_unit_set_unit_mac_addr(struct ipaccess_unit *unit, uint8_t *addr)
{
	memcpy(unit->mac_addr, addr, sizeof(unit->mac_addr));
}

void osmo_ipa_unit_set_unit_loc1(struct ipaccess_unit *unit, const char *loc)
{
	if (unit->location1)
		free(unit->location1);

	unit->location1 = strdup(loc);
}

void osmo_ipa_unit_set_unit_loc2(struct ipaccess_unit *unit, const char *loc)
{
	if (unit->location2)
		free(unit->location2);

	unit->location2 = strdup(loc);
}

void osmo_ipa_unit_set_unit_serno(struct ipaccess_unit *unit, const char *serno)
{
	unit->serno = strdup(serno);
}