summaryrefslogtreecommitdiffstats
path: root/include/dect/identities.h
blob: 095687a66015325fa81e2100db0591c574a2358b (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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
/*
 * DECT Identities
 *
 * Copyright (c) 2009 Patrick McHardy <kaber@trash.net>
 */

#ifndef _LIBDECT_DECT_IDENTITIES_H
#define _LIBDECT_DECT_IDENTITIES_H

/*
 * Acess Rights Identity (ARI)
 */

/**
 * DECT ARI classes
 *
 * @DECT_ARC_A:	Residential and private (PBX) single- and small multiple cell systems
 * @DECT_ARC_B:	Private (PABXs) multiple cell
 * @DECT_ARC_C: Public single and multiple cell systems
 * @DECT_ARC_D: Public DECT access to a GSM network
 * @DECT_ARC_E: PP to PP direct communication (private)
 */
enum dect_ari_classes {
	DECT_ARC_A		= 0x0,
	DECT_ARC_B		= 0x1,
	DECT_ARC_C		= 0x2,
	DECT_ARC_D		= 0x3,
	DECT_ARC_E		= 0x4,
};

struct dect_ari {
	enum dect_ari_classes	arc;
	uint32_t		fpn;
	uint32_t		fps;
	union {
		uint16_t	emc;
		uint16_t	eic;
		uint16_t	poc;
		uint32_t	gop;
		uint16_t	fil;
	};
};

enum dect_ari_lengths {
	DECT_ARC_A_LEN		= 36,
	DECT_ARC_B_LEN		= 31,
	DECT_ARC_C_LEN		= 31,
	DECT_ARC_D_LEN		= 31,
	DECT_ARC_E_LEN		= 31,
};

extern bool dect_ari_cmp(const struct dect_ari *a1, const struct dect_ari *a2);
extern uint8_t dect_parse_ari(struct dect_ari *ari, uint64_t a);
extern uint64_t dect_build_ari(const struct dect_ari *ari);

/**
 * struct dect_park - Portable access rights key
 *
 * @park:	FP ARI
 * @pli:	FP ARI prefix length
 */
struct dect_park {
	struct dect_ari		park;
	uint8_t			pli;
};

/**
 * struct dect_ipei - International portable equipment ID
 *
 * @emc:	Equipment Manufacturer Code
 * @psn:	Portable Equipment Serial Number
 */
struct dect_ipei {
	uint16_t	emc;
	uint32_t	psn;
};

/* IPUI */

#define DECT_IPUI_PUT_MASK		0xf0
#define DECT_IPUI_PUT_SHIFT		4

/**
 * @DECT_IPUI_N:	Portable user identity type N (residential/default)
 * @DECT_IPUI_O:	Portable user identity type O (private)
 * @DECT_IPUI_P:	Portable user identity type P (public/public access service)
 * @DECT_IPUI_Q:	Portable user identity type Q (public/general)
 * @DECT_IPUI_R:	Portable user identity type R (public/IMSI)
 * @DECT_IPUI_S:	Portable user identity type S (PSTN/ISDN)
 * @DECT_IPUI_T:	Portable user identity type T (private extended)
 * @DECT_IPUI_U:	Portable user identity type U (public/general)
 */
enum dect_ipui_types {
	DECT_IPUI_N	= 0x0 << DECT_IPUI_PUT_SHIFT,
	DECT_IPUI_O	= 0x1 << DECT_IPUI_PUT_SHIFT,
	DECT_IPUI_P	= 0x2 << DECT_IPUI_PUT_SHIFT,
	DECT_IPUI_Q	= 0x3 << DECT_IPUI_PUT_SHIFT,
	DECT_IPUI_R	= 0x4 << DECT_IPUI_PUT_SHIFT,
	DECT_IPUI_S	= 0x5 << DECT_IPUI_PUT_SHIFT,
	DECT_IPUI_T	= 0x6 << DECT_IPUI_PUT_SHIFT,
	DECT_IPUI_U	= 0x7 << DECT_IPUI_PUT_SHIFT,
};

/**
 * @put:	Portable User Identity Type
 * @pun:	Type specific data
 */
struct dect_ipui {
	enum dect_ipui_types	put;
	union {
		struct {
			struct dect_ipei	ipei;
		} n;
		struct {
			uint64_t		number;
		} o;
		struct {
			uint16_t		poc;
			uint8_t			acc[10];
		} p;
		struct {
			uint8_t			bacn[10];
		} q;
		struct {
			uint64_t		imsi;
		} r;
		struct {
			uint64_t		number;
		} s;
		struct {
			uint16_t		eic;
			uint64_t		number;
		} t;
		struct {
			uint8_t			cacn[10];
		} u;
	} pun;
};

extern bool dect_ipui_cmp(const struct dect_ipui *u1,
			  const struct dect_ipui *u2);

/**
 *
 */
enum dect_tpui_types {
	DECT_TPUI_INDIVIDUAL_ASSIGNED,
	DECT_TPUI_CONNECTIONLESS_GROUP,
	DECT_TPUI_CALL_GROUP,
	DECT_TPUI_INDIVIDUAL_DEFAULT,
	DECT_TPUI_EMERGENCY,
};

/**
 * @type:	TPUI type
 * @tpui:	type specific value (20 bits)
 */
struct dect_tpui {
	enum dect_tpui_types	type;
	uint32_t		tpui;
};

extern void dect_default_individual_tpui(struct dect_tpui *tpui,
					 const struct dect_ipui *ipui);

/* Collective broadcast identifier */
#define DECT_TPUI_CBI		0xcfff

#endif /* _LIBDECT_DECT_IDENTITIES_H */