summaryrefslogtreecommitdiffstats
path: root/include/dectmon.h
blob: 0b4f84c0b3d46b97e2227da65b9f66dd148a0f7d (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
#ifndef _DECTMON_H
#define _DECTMON_H

#include <stdio.h>
#include <stdbool.h>
#include <stdint.h>
#include <list.h>
#include <dect/libdect.h>
#include <dect/timer.h>
#include <dect/auth.h>
#include <phl.h>

enum {
	DECTMON_DUMP_MAC	= 0x1,
	DECTMON_DUMP_DLC	= 0x2,
	DECTMON_DUMP_NWK	= 0x4,
};

extern const char *auth_pin;
extern uint32_t dumpopts;
extern uint32_t debug_mask;

extern void dectmon_log(const char *fmt, ...);
extern void dect_hexdump(const char *prefix, const uint8_t *buf, size_t size);

extern struct list_head dect_handles;

struct dect_handle_priv {
	struct list_head			list;
	const char				*cluster;
	struct dect_handle			*dh;

	struct dect_timer			*lock_timer;
	bool					locked;
	struct dect_ari				pari;

	struct dect_fd				*rawsk;
	struct list_head			pt_list;
	struct dect_tbc				*slots[DECT_FRAME_SIZE];
};

extern struct dect_handle_priv *dect_handle_get_by_name(const char *name);

enum dect_mm_procedures {
	DECT_MM_NONE,
	DECT_MM_KEY_ALLOCATION,
	DECT_MM_AUTHENTICATION,
	DECT_MM_CIPHERING,
};

struct dect_pt {
	struct list_head			list;
	struct dect_ie_portable_identity	*portable_identity;
	struct dect_dl				*dl;

	uint8_t					uak[DECT_AUTH_KEY_LEN];
	uint8_t					dck[DECT_CIPHER_KEY_LEN];

	struct dect_audio_handle		*ah;

	enum dect_mm_procedures			procedure;
	uint8_t					last_msg;

	struct dect_ie_auth_type		*auth_type;
	struct dect_ie_auth_value		*rand_f;
	struct dect_ie_auth_value		*rs;
	struct dect_ie_auth_res			*res;
};

/* DLC */

struct dect_dl {
	struct dect_pt				*pt;
	struct dect_tbc				*tbc;
};

struct dect_msg_buf;
extern void dect_dl_data_ind(struct dect_handle *dh, struct dect_dl *dl,
			     struct dect_msg_buf *mb);

extern void dect_dl_u_data_ind(struct dect_handle *dh, struct dect_dl *dl,
			       bool dir, struct dect_msg_buf *mb);

struct dect_lc {
	uint16_t				lsig;
	struct dect_msg_buf			*rx_buf;
	uint8_t					rx_len;
};

struct dect_mac_con {
	struct dect_lc				*lc;
	struct dect_tbc				*tbc;
};

enum dect_data_channels;
extern void dect_mac_co_data_ind(struct dect_handle *dh,
				 struct dect_mac_con *mc,
				 enum dect_data_channels chan,
				 struct dect_msg_buf *mb);

extern void dect_mac_dis_ind(struct dect_handle *dh, struct dect_mac_con *mc);

/* MAC */

struct dect_mbc {
	bool					cs_seq;
	bool					cf_seq;
	struct dect_mac_con			mc;
};

struct dect_tbc {
	uint8_t					slot1;
	uint8_t					slot2;

	uint16_t				fmid;
	uint32_t				pmid;

	struct dect_timer			*timer;
	struct dect_mbc				mbc[2];

	bool					ciphered;
	uint8_t					ks[2 * 45];

	struct dect_dl				dl;
};

extern void dect_mac_rcv(struct dect_handle *dh, struct dect_msg_buf *mb);

#endif /* _DECTMON_H */