blob: f58c8c84e7cb366cce46cdb48cf44b9e8cba48a0 [file] [log] [blame]
Harald Weltef8db61b2015-12-18 17:29:59 +01001/* (C) 2015 by Harald Welte <laforge@gnumonks.org>
2 * All Rights Reserved
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Affero General Public License as published by
6 * the Free Software Foundation; either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Affero General Public License for more details.
13 *
14 * You should have received a copy of the GNU Affero General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 *
17 */
18
19#include <osmocom/core/utils.h>
20#include <osmocom/core/msgb.h>
21#include <osmocom/core/logging.h>
22#include <osmocom/vty/logging.h>
Harald Welted328c1a2015-12-16 23:04:21 +010023
Harald Welte091039d2015-12-17 20:37:40 +010024#include "asn1helpers.h"
25#include "iu_helpers.h"
26
27#include "ranap_common.h"
28#include "ranap_ies_defs.h"
Harald Weltef8db61b2015-12-18 17:29:59 +010029#include "ranap_msg_factory.h"
Harald Welted328c1a2015-12-16 23:04:21 +010030
Harald Welte87ffeb92015-12-25 15:34:22 +010031#include "test_common.h"
32
Harald Weltef8db61b2015-12-18 17:29:59 +010033#include "hnbgw.h"
Harald Welted328c1a2015-12-16 23:04:21 +010034
Harald Weltef8db61b2015-12-18 17:29:59 +010035int asn1_xer_print = 1;
Harald Welted062df52015-12-17 23:18:40 +010036
Harald Weltef8db61b2015-12-18 17:29:59 +010037extern void *tall_msgb_ctx;
Harald Welted328c1a2015-12-16 23:04:21 +010038
Harald Weltef8db61b2015-12-18 17:29:59 +010039int main(int argc, char **argv)
Harald Welted328c1a2015-12-16 23:04:21 +010040{
Harald Weltef8db61b2015-12-18 17:29:59 +010041 uint8_t nas_buf[] = { 0xaa, 0xbb, 0xcc };
Harald Welted328c1a2015-12-16 23:04:21 +010042 struct msgb *msg;
Harald Weltef8db61b2015-12-18 17:29:59 +010043 const char *imsi = "901700123456789";
44 uint32_t tmsi = 0x01234567;
45 uint32_t rtp_ip = 0x0a0b0c0d;
46 uint16_t rtp_port = 2342;
47 uint32_t gtp_ip = 0x1a1b1c1d;
48 uint32_t gtp_tei = 0x11223344;
49 uint8_t ik[16] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 };
50 uint8_t ck[16] = { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 };
Harald Welte091039d2015-12-17 20:37:40 +010051 int i, rc;
Harald Welted328c1a2015-12-16 23:04:21 +010052
Harald Weltef8db61b2015-12-18 17:29:59 +010053 //asn_debug = 1;
Harald Welted328c1a2015-12-16 23:04:21 +010054
Harald Weltef8db61b2015-12-18 17:29:59 +010055 msgb_set_talloc_ctx(talloc_named_const(NULL, 1, "msgb"));
Harald Welted328c1a2015-12-16 23:04:21 +010056
Harald Welte87ffeb92015-12-25 15:34:22 +010057 test_common_init();
Harald Weltef8db61b2015-12-18 17:29:59 +010058
59 for (i = 0; i < 1; i++) {
60 printf("\n==> DIRECT TRANSFER\n");
61 msg = ranap_new_msg_dt(0, nas_buf, sizeof(nas_buf));
62 if (msg)
63 printf("%s\n", msgb_hexdump(msg));
64 msgb_free(msg);
65
66 printf("\n==> SECURITY MODE COMMAND\n");
67 msg = ranap_new_msg_sec_mod_cmd(ik, ck);
68 if (msg)
69 printf("%s\n", msgb_hexdump(msg));
70 msgb_free(msg);
71
72 printf("\n==> COMMON ID\n");
73 msg = ranap_new_msg_common_id(imsi);
74 if (msg)
75 printf("%s\n", msgb_hexdump(msg));
76 msgb_free(msg);
77
78 printf("\n==> IU RELEASE CMD\n");
79 RANAP_Cause_t cause = { .present = RANAP_Cause_PR_radioNetwork,
80 .choice.radioNetwork = RANAP_CauseRadioNetwork_radio_connection_with_UE_Lost };
81 msg = ranap_new_msg_iu_rel_cmd(&cause);
82 if (msg)
83 printf("%s\n", msgb_hexdump(msg));
84 msgb_free(msg);
85
86 printf("\n==> PAGING CMD\n");
87 msg = ranap_new_msg_paging_cmd(imsi, &tmsi, 0, RANAP_PagingCause_terminating_conversational_call);
88 if (msg)
89 printf("%s\n", msgb_hexdump(msg));
90 msgb_free(msg);
91
92 printf("\n==> RAB ASSIGNMENT COMMAND (VOICE)\n");
93 msg = ranap_new_msg_rab_assign_voice(1, rtp_ip, rtp_port);
94 if (msg)
95 printf("%s\n", msgb_hexdump(msg));
96 msgb_free(msg);
97
98 printf("\n==> RAB ASSIGNMENT COMMAND (DATA)\n");
99 msg = ranap_new_msg_rab_assign_data(2, gtp_ip, gtp_tei);
100 if (msg)
101 printf("%s\n", msgb_hexdump(msg));
102 msgb_free(msg);
Harald Welte091039d2015-12-17 20:37:40 +0100103 }
Harald Welted328c1a2015-12-16 23:04:21 +0100104
Harald Weltef8db61b2015-12-18 17:29:59 +0100105 printf("report\n");
106 talloc_report(talloc_asn1_ctx, stdout);
107 talloc_report(tall_msgb_ctx, stdout);
108 //talloc_report(NULL, stdout);
109 printf("exit\n");
110 exit(0);
Harald Welted328c1a2015-12-16 23:04:21 +0100111}