aboutsummaryrefslogtreecommitdiffstats
path: root/src/hnbgw_hnbap.c
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2015-08-30 12:20:09 +0200
committerHarald Welte <laforge@gnumonks.org>2015-08-30 12:20:09 +0200
commitb3dae30e5ee3d9109b07023327df1c6c00b06806 (patch)
treed9d6578116df79344bb6c3c4a7dd7436c355dc0c /src/hnbgw_hnbap.c
parentac0435b69129958e0ea5fbfda6561ddbe260bbcb (diff)
first compiling code (untested)
Diffstat (limited to 'src/hnbgw_hnbap.c')
-rw-r--r--src/hnbgw_hnbap.c71
1 files changed, 44 insertions, 27 deletions
diff --git a/src/hnbgw_hnbap.c b/src/hnbgw_hnbap.c
index ce41222..fd3a328 100644
--- a/src/hnbgw_hnbap.c
+++ b/src/hnbgw_hnbap.c
@@ -1,8 +1,14 @@
#include <osmocom/core/msgb.h>
+#include <osmocom/core/utils.h>
+#include <unistd.h>
+#include <string.h>
+
+#include "hnbap.h"
#include "hnbgw.h"
#include "hnbap_const.h"
+
static int hnbgw_hnbap_tx(struct HNBAP_PDU *pdu)
{
/* FIXME */
@@ -20,11 +26,19 @@ static int hnbgw_tx_ue_register_acc()
/* Single required response IE: RNC-ID */
}
-struct ProtocolIE_Field_1 *find_ie(const struct ProtocolIE_Container_1 *cont, ProtocolIE_ID id)
+#define FIND_IE(cont, id) find_ie((const struct ProtocolIE_Container_1 *)cont, id)
+
+static void *find_ie(const struct ProtocolIE_Container_1 *cont, ProtocolIE_ID id)
{
+ int i;
+
for (i = 0; i < cont->count; i++) {
- if (cont->tab[i].id == id)
- return &cont->tab[i];
+ ProtocolIE_Field_1 *field = &cont->tab[i];
+ if (field->id == id) {
+ OSMO_ASSERT(field->value.type);
+ /* FIXME: we shoudl check if it is the correct type, not just any type */
+ return field->value.u.data;
+ }
}
return NULL;
}
@@ -56,29 +70,30 @@ static inline uint8_t asn1bitstr_to_u32(ASN1BitString *as)
static int hnbgw_rx_hnb_register_req(struct hnb_context *ctx, struct HNBRegisterRequest *req)
{
HNB_Identity *identity =
- FIND_IE(req->protocolIEs, HNBAP_IEI_HNB_Identity);
+ FIND_IE(&req->protocolIEs, HNBAP_IEI_HNB_Identity);
HNB_Location_Information *loc =
- FIND_IE(req->protocolIEs, HNBAP_IEI_HNB_Location_Information);
+ FIND_IE(&req->protocolIEs, HNBAP_IEI_HNB_Location_Information);
PLMNidentity *plmn_id =
- FIND_IE(req->protocolIEs, HNBAP_IEI_PLMNidentity);
+ FIND_IE(&req->protocolIEs, HNBAP_IEI_PLMNidentity);
CellIdentity *cell_id =
- FIND_IE(req->protocolIEs, HNBAP_IEI_CellIdentity);
- LAC *lac = FIND_IE(req->protocolIEs, HNBAP_IEI_LAC);
- RAC *rac = FIND_IE(req->protocolIEs, HNBAP_IEI_RAC);
- SAC *sac = FIND_IE(req->protocolIEs, HNBAP_IEI_SAC);
+ FIND_IE(&req->protocolIEs, HNBAP_IEI_CellIdentity);
+ LAC *lac = FIND_IE(&req->protocolIEs, HNBAP_IEI_LAC);
+ RAC *rac = FIND_IE(&req->protocolIEs, HNBAP_IEI_RAC);
+ SAC *sac = FIND_IE(&req->protocolIEs, HNBAP_IEI_SAC);
/* Optional: CSG-ID */
if(!identity || !loc || !plmn_id || !cell_id || !lac || !rac || !sac)
return -1;
/* copy all identity parameters from the message to ctx */
- strncpy(ctx->identity_info, sizeof(ctx->identity_info, identity_info->buf);
+ strncpy(ctx->identity_info, (const char *) identity->hNB_Identity_Info.buf,
+ sizeof(ctx->identity_info));
ctx->id.lac = asn1str_to_u16(lac);
ctx->id.sac = asn1str_to_u16(sac);
ctx->id.rac = asn1str_to_u8(rac);
ctx->id.cid = asn1bitstr_to_u32(cell_id);
- ctx->id.mcc FIXME
- ctx->id.mnc FIXME
+ //ctx->id.mcc FIXME
+ //ctx->id.mnc FIXME
/* FIXME: Send HNBRegisterAccept */
}
@@ -86,11 +101,11 @@ static int hnbgw_rx_hnb_register_req(struct hnb_context *ctx, struct HNBRegister
static int hnbgw_rx_ue_register_req(struct hnb_context *ctx, struct UERegisterRequest *req)
{
UE_Identity *id =
- FIND_IE(req->protocolIEs, HNBAP_IEI_UE_Identity);
+ FIND_IE(&req->protocolIEs, HNBAP_IEI_UE_Identity);
Registration_Cause *reg_cause =
- FIND_IE(req->protocolIEs, HNBAP_IEI_RegistrationCause);
+ FIND_IE(&req->protocolIEs, HNBAP_IEI_RegistrationCause);
UE_Capabilities *ue_cap =
- FIND_IE(req->protocolIEs, HNBAP_IEI_UE_Capabilities);
+ FIND_IE(&req->protocolIEs, HNBAP_IEI_UE_Capabilities);
if (!id || !reg_cause || !ue_cap)
return -1;
@@ -98,22 +113,22 @@ static int hnbgw_rx_ue_register_req(struct hnb_context *ctx, struct UERegisterRe
/* FIXME: Send UERegisterAccept */
}
-static int hnbgw_rx_initiating_msg(struct hnb_context *hnb, struct InitiatingMessage *msg)
+static int hnbgw_rx_initiating_msg(struct hnb_context *hnb, struct InitiatingMessage *imsg)
{
int rc;
- switch (msg->procedureCode) {
+ switch (imsg->procedureCode) {
case HNBAP_PC_HNBRegister: /* 8.2 */
- if (msg->value.type != asn1_type_HNBRegisterRequest)
+ if (imsg->value.type != asn1_type_HNBRegisterRequest)
return -1;
- rc = hnbgw_rx_hnb_register_req(hnb, FIXME);
+ rc = hnbgw_rx_hnb_register_req(hnb, imsg->value.u.data);
break;
case HNBAP_PC_HNBDe_Register: /* 8.3 */
break;
case HNBAP_PC_UERegister: /* 8.4 */
- if (msg->value.type != asn1_type_UERegisterRequest)
+ if (imsg->value.type != asn1_type_UERegisterRequest)
return -1;
- rc = hnbgw_rx_ue_register_req(hnb, FIXME);
+ rc = hnbgw_rx_ue_register_req(hnb, imsg->value.u.data);
break;
case HNBAP_PC_UEDe_Register: /* 8.5 */
break;
@@ -129,12 +144,12 @@ static int hnbgw_rx_initiating_msg(struct hnb_context *hnb, struct InitiatingMes
}
}
-static int hnbgw_rx_successful_outcome_msg(struct SuccessfulOutcome *msg)
+static int hnbgw_rx_successful_outcome_msg(struct hnb_context *hnb, struct SuccessfulOutcome *msg)
{
}
-static int hnbgw_rx_unsuccessful_outcome_msg(struct UnsuccessfulOutcome *msg)
+static int hnbgw_rx_unsuccessful_outcome_msg(struct hnb_context *hnb, struct UnsuccessfulOutcome *msg)
{
}
@@ -142,17 +157,19 @@ static int hnbgw_rx_unsuccessful_outcome_msg(struct UnsuccessfulOutcome *msg)
static int _hnbgw_hnbap_rx(struct hnb_context *hnb, struct HNBAP_PDU *pdu)
{
+ int rc;
+
/* it's a bit odd that we can't dispatch on procedure code, but
* that's not possible */
switch (pdu->choice) {
case HNBAP_PDU_initiatingMessage:
- rc = hnbgw_rx_initiating_msg(&pdu->u.initiatingMessage);
+ rc = hnbgw_rx_initiating_msg(hnb, &pdu->u.initiatingMessage);
break;
case HNBAP_PDU_successfulOutcome:
- rc = hnbgw_rx_successful_outcome_msg(&pdu->u.successfulOutcome);
+ rc = hnbgw_rx_successful_outcome_msg(hnb, &pdu->u.successfulOutcome);
break;
case HNBAP_PDU_unsuccessfulOutcome:
- rc = hnbgw_rx_unsuccessful_outcome_msg(&pdu->u.unsuccessfulOutcome);
+ rc = hnbgw_rx_unsuccessful_outcome_msg(hnb, &pdu->u.unsuccessfulOutcome);
break;
default:
return -1;