blob: 0c1f0afaca4f57bd5129c663921928750cbacd7d [file] [log] [blame]
Harald Welte318e4d52015-09-10 18:47:08 +02001#include <osmocom/core/msgb.h>
2#include <osmocom/core/utils.h>
3
4#include <unistd.h>
5#include <errno.h>
6#include <string.h>
7
8#include "asn1helpers.h"
9
10#include "hnbgw.h"
11#include "rua_common.h"
12#include "rua_ies_defs.h"
13
14static int hnbgw_rua_tx(struct hnb_context *ctx, struct msgb *msg)
15{
16 if (!msg)
17 return -EINVAL;
18
19 msgb_ppid(msg) = IUH_PPI_RUA;
20 return osmo_wqueue_enqueue(&ctx->wqueue, msg);
21}
22
23
24static int rua_rx_initiating_msg(struct hnb_context *hnb, RUA_InitiatingMessage_t *imsg)
25{
26 int rc;
27
28 switch (imsg->procedureCode) {
29 case RUA_ProcedureCode_id_Connect:
30 break;
31 case RUA_ProcedureCode_id_DirectTransfer:
32 break;
33 case RUA_ProcedureCode_id_Disconnect:
34 break;
35 case RUA_ProcedureCode_id_ConnectionlessTransfer:
36 break;
37 case RUA_ProcedureCode_id_ErrorIndication:
38 case RUA_ProcedureCode_id_privateMessage:
39 break;
40 default:
41 break;
42 }
43}
44
45static int rua_rx_successful_outcome_msg(struct hnb_context *hnb, RUA_SuccessfulOutcome_t *msg)
46{
47
48}
49
50static int rua_rx_unsuccessful_outcome_msg(struct hnb_context *hnb, RUA_UnsuccessfulOutcome_t *msg)
51{
52
53}
54
55
56static int _hnbgw_rua_rx(struct hnb_context *hnb, RUA_RUA_PDU_t *pdu)
57{
58 int rc;
59
60 /* it's a bit odd that we can't dispatch on procedure code, but
61 * that's not possible */
62 switch (pdu->present) {
63 case RUA_RUA_PDU_PR_initiatingMessage:
64 rc = rua_rx_initiating_msg(hnb, &pdu->choice.initiatingMessage);
65 break;
66 case RUA_RUA_PDU_PR_successfulOutcome:
67 rc = rua_rx_successful_outcome_msg(hnb, &pdu->choice.successfulOutcome);
68 break;
69 case RUA_RUA_PDU_PR_unsuccessfulOutcome:
70 rc = rua_rx_unsuccessful_outcome_msg(hnb, &pdu->choice.unsuccessfulOutcome);
71 break;
72 default:
73 return -1;
74 }
75}
76
77int hnbgw_rua_rx(struct hnb_context *hnb, struct msgb *msg)
78{
79 RUA_RUA_PDU_t _pdu, *pdu = &_pdu;
80 asn_dec_rval_t dec_ret;
81 int rc;
82
83 /* decode and handle to _hnbgw_hnbap_rx() */
84
85 memset(pdu, 0, sizeof(*pdu));
86 dec_ret = aper_decode(NULL, &asn_DEF_RUA_RUA_PDU, (void **) &pdu,
87 msg->data, msgb_length(msg), 0, 0);
88 if (dec_ret.code != RC_OK) {
89 LOGP(DMAIN, LOGL_ERROR, "Error in ASN.1 decode\n");
90 return rc;
91 }
92
93 rc = _hnbgw_rua_rx(hnb, pdu);
94
95 return rc;
96}
97
98
99int hnbgw_rua_init(void)
100{
101
102}