blob: 9b674adf1ae2548384fea336efb0c2e91db3fa56 [file] [log] [blame]
Harald Welteba43de42015-08-29 20:33:16 +02001#include <osmocom/core/msgb.h>
2
3#include "hnbgw.h"
4#include "hnbap_const.h"
5
6static int hnbgw_hnbap_tx(struct HNBAP_PDU *pdu)
7{
8 /* FIXME */
9}
10
11static int hnbgw_tx_hnb_register_acc()
12{
13 /* FIXME */
14 /* Single required response IE: RNC-ID */
15}
16
17static int hnbgw_tx_ue_register_acc()
18{
19 /* FIXME */
20 /* Single required response IE: RNC-ID */
21}
22
23struct ProtocolIE_Field_1 *find_ie(const struct ProtocolIE_Container_1 *cont, ProtocolIE_ID id)
24{
25 for (i = 0; i < cont->count; i++) {
26 if (cont->tab[i].id == id)
27 return &cont->tab[i];
28 }
29 return NULL;
30}
31
32static int hnbgw_rx_hnb_register_req(struct HNBRegisterRequest *req)
33{
34 HNB_Identity *identity =
35 FIND_IE(req->protocolIEs, HNBAP_IEI_HNB_Identity);
36 HNB_Location_Information *loc =
37 FIND_IE(req->protocolIEs, HNBAP_IEI_HNB_Location_Information);
38 PLMNidentity *plmn_id =
39 FIND_IE(req->protocolIEs, HNBAP_IEI_PLMNidentity);
40 CellIdentity *cell_id =
41 FIND_IE(req->protocolIEs, HNBAP_IEI_CellIdentity);
42 LAC *lac = FIND_IE(req->protocolIEs, HNBAP_IEI_LAC);
43 RAC *rac = FIND_IE(req->protocolIEs, HNBAP_IEI_RAC);
44 SAC *sac = FIND_IE(req->protocolIEs, HNBAP_IEI_SAC);
45 /* Optional: CSG-ID */
46
47 if(!identity || !loc || !plmn_id || !cell_id || !lac || !rac || !sac)
48 return -1;
49
50 /* FIXME: Send HNBRegisterAccept */
51}
52
53static int hnbgw_rx_ue_register_req(struct UERegisterRequest *req)
54{
55 UE_Identity *id =
56 FIND_IE(req->protocolIEs, HNBAP_IEI_UE_Identity);
57 Registration_Cause *reg_cause =
58 FIND_IE(req->protocolIEs, HNBAP_IEI_RegistrationCause);
59 UE_Capabilities *ue_cap =
60 FIND_IE(req->protocolIEs, HNBAP_IEI_UE_Capabilities);
61
62 if (!id || !reg_cause || !ue_cap)
63 return -1;
64
65 /* FIXME: Send UERegisterAccept */
66}
67
68static int hnbgw_rx_initiating_msg(struct InitiatingMessage *msg)
69{
70 int rc;
71
72 switch (msg->procedureCode) {
73 case HNBAP_PC_HNBRegister: /* 8.2 */
74 if (msg->value.type != asn1_type_HNBRegisterRequest)
75 return -1;
76 rc = hnbgw_rx_hnb_register_req();
77 break;
78 case HNBAP_PC_HNBDe_Register: /* 8.3 */
79 break;
80 case HNBAP_PC_UERegister: /* 8.4 */
81 if (msg->value.type != asn1_type_UERegisterRequest)
82 return -1;
83 rc = hnbgw_rx_ue_register_req();
84 break;
85 case HNBAP_PC_UEDe_Register: /* 8.5 */
86 break;
87 case HNBAP_PC_ErrorIndication: /* 8.6 */
88 case HNBAP_PC_TNLUpdate: /* 8.9 */
89 case HNBAP_PC_HNBConfigTransfer: /* 8.10 */
90 case HNBAP_PC_RelocationComplete: /* 8.11 */
91 case HNBAP_PC_U_RNTIQuery: /* 8.12 */
92 case HNBAP_PC_privateMessage:
93 break;
94 default:
95 break;
96 }
97}
98
99static int hnbgw_rx_successful_outcome_msg(struct SuccessfulOutcome *msg)
100{
101
102}
103
104static int hnbgw_rx_unsuccessful_outcome_msg(struct UnsuccessfulOutcome *msg)
105{
106
107}
108
109
110static int _hnbgw_hnbap_rx(struct HNBAP_PDU *pdu)
111{
112 /* it's a bit odd that we can't dispatch on procedure code, but
113 * that's not possible */
114 switch (pdu->choice) {
115 case HNBAP_PDU_initiatingMessage:
116 rc = hnbgw_rx_initiating_msg(&pdu->u.initiatingMessage);
117 break;
118 case HNBAP_PDU_successfulOutcome:
119 rc = hnbgw_rx_successful_outcome_msg(&pdu->u.successfulOutcome);
120 break;
121 case HNBAP_PDU_unsuccessfulOutcome:
122 rc = hnbgw_rx_unsuccessful_outcome_msg(&pdu->u.unsuccessfulOutcome);
123 break;
124 default:
125 return -1;
126 }
127}
128
129int hnbgw_hnbap_rx(struct msgb *msg)
130{
131 /* FIXME: decode and handle to _hnbgw_hnbap_rx() */
132}
133
134
135int hnbgw_hnbap_init(void)
136{
137
138}