aboutsummaryrefslogtreecommitdiffstats
path: root/src/tests/hnb-test.h
blob: 4af50a7286c136997b70544620d2a15d150bccff (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
#pragma once

#include <osmocom/core/select.h>
#include <osmocom/core/linuxlist.h>
#include <osmocom/core/write_queue.h>

#define DEBUG
#include <osmocom/core/logging.h>

enum {
	DMAIN,
	DHNBAP,
};


/* 25.467 Section 7.1 */
#define IUH_DEFAULT_SCTP_PORT	29169
#define RNA_DEFAULT_SCTP_PORT	25471

#define IUH_PPI_RUA		19
#define IUH_PPI_HNBAP		20
#define IUH_PPI_SABP		31
#define IUH_PPI_RNA		42
#define IUH_PPI_PUA		55

#define IUH_MSGB_SIZE	2048

struct umts_cell_id {
	uint16_t mcc;	/*!< Mobile Country Code */
	uint16_t mnc;	/*!< Mobile Network Code */
	uint16_t lac;	/*!< Locaton Area Code */
	uint16_t rac;	/*!< Routing Area Code */
	uint16_t sac;	/*!< Service Area Code */
	uint32_t cid;	/*!< Cell ID */
};

struct ue_context {
	/*! Entry in the HNB-global list of UE */
	struct llist_head list;
	/*! Unique Context ID for this UE */
	uint32_t context_id;
	char imsi[16+1];
};

struct hnbtest_chan {
	int is_ps;
	uint32_t conn_id;
	char *imsi;
};

struct hnb_test {
	const char *gw_addr;
	uint16_t gw_port;
	/*! SCTP listen socket for incoming connections */
	struct osmo_fd conn_fd;

	/*! SCTP socket + write queue for Iuh to this specific HNB */
	struct osmo_wqueue wqueue;
	/*! copied from HNB-Identity-Info IE */
	char identity_info[256];
	/*! copied from Cell Identity IE */
	struct umts_cell_id id;

	/*! SCTP stream ID for HNBAP */
	uint16_t hnbap_stream;
	/*! SCTP stream ID for RUA */
	uint16_t rua_stream;

	uint16_t rnc_id;

	uint32_t ctx_id;

	int ues;

	struct {
		struct hnbtest_chan *chan;
	} cs;
};

extern struct hnb_test g_hnb_test;