Merge branch 's1ap-brchiu' of https://github.com/acetcom/nextepc into s1ap-brchiu

This commit is contained in:
Sukchan Lee 2018-03-12 11:38:40 +00:00
commit 422d1c2f8f
21 changed files with 606 additions and 2864 deletions

View File

@ -424,7 +424,6 @@ AC_CONFIG_FILES([lib/core/test/Makefile])
AC_CONFIG_FILES([lib/core/Makefile])
AC_CONFIG_FILES([lib/s1ap/asn1c/Makefile])
AC_CONFIG_FILES([lib/s1ap/Makefile])
AC_CONFIG_FILES([lib/s1ap/test/Makefile])
AC_CONFIG_FILES([lib/nas/Makefile])
AC_CONFIG_FILES([lib/fd/Makefile])
AC_CONFIG_FILES([lib/gtp/Makefile])

View File

@ -1,27 +0,0 @@
## Process this file with automake to produce Makefile.in.
bin_PROGRAMS = tests1ap
tests1ap_SOURCES = \
abts.c abts.h abts_tests.h testutil.c testutil.h \
s1ap_conv.h s1ap_conv.c s1ap_build.h s1ap_build.c \
s1ap_message_test.c
tests1ap_LDADD = \
$(top_srcdir)/lib/s1ap/libs1ap.la
AM_CPPFLAGS = \
-I$(top_srcdir)/lib/core/include \
-I$(top_srcdir)/lib/s1ap/asn1c \
-I$(top_srcdir)/lib/s1ap \
$(NULL)
AM_CFLAGS = \
-Wall -Werror @OSCPPFLAGS@ \
-Wno-unused-function -Wno-unused-variable
TESTS = tests1ap
MAINTAINERCLEANFILES = Makefile.in
CLEANFILES = -R data
MOSTLYCLEANFILES = core *.stackdump

View File

@ -1,479 +0,0 @@
/* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "abts.h"
#include "abts_tests.h"
#include "testutil.h"
#include "core_pkbuf.h"
#define ABTS_STAT_SIZE 6
static char status[ABTS_STAT_SIZE] = {'|', '/', '-', '|', '\\', '-'};
static int curr_char;
static int verbose = 1;
static int exclude = 0;
static int quiet = 0;
static int list_tests = 0;
const char **testlist = NULL;
static int find_test_name(const char *testname) {
int i;
for (i = 0; testlist[i] != NULL; i++) {
if (!strcmp(testlist[i], testname)) {
return 1;
}
}
return 0;
}
/* Determine if the test should be run at all */
static int should_test_run(const char *testname) {
int found = 0;
if (list_tests == 1) {
return 0;
}
if (testlist == NULL) {
return 1;
}
found = find_test_name(testname);
if ((found && !exclude) || (!found && exclude)) {
return 1;
}
return 0;
}
static void reset_status(void)
{
curr_char = 0;
}
static void update_status(void)
{
if (!quiet) {
curr_char = (curr_char + 1) % ABTS_STAT_SIZE;
fprintf(stdout, "\b%c", status[curr_char]);
fflush(stdout);
}
}
static void end_suite(abts_suite *suite)
{
if (suite != NULL) {
sub_suite *last = suite->tail;
if (!quiet) {
fprintf(stdout, "\b");
fflush(stdout);
}
if (last->failed == 0) {
fprintf(stdout, "SUCCESS\n");
fflush(stdout);
}
else {
fprintf(stdout, "FAILED %d of %d\n", last->failed, last->num_test);
fflush(stdout);
}
}
}
abts_suite *abts_add_suite(abts_suite *suite, const char *suite_name_full)
{
sub_suite *subsuite;
char *p;
const char *suite_name;
curr_char = 0;
/* Only end the suite if we actually ran it */
if (suite && suite->tail &&!suite->tail->not_run) {
end_suite(suite);
}
subsuite = core_malloc(sizeof(*subsuite));
subsuite->num_test = 0;
subsuite->failed = 0;
subsuite->next = NULL;
/* suite_name_full may be an absolute path depending on __FILE__
* expansion */
suite_name = strrchr(suite_name_full, '/');
if (suite_name) {
suite_name++;
} else {
suite_name = suite_name_full;
}
p = strrchr(suite_name, '.');
if (p) {
subsuite->name = memcpy(core_calloc(p - suite_name + 1, 1),
suite_name, p - suite_name);
}
else {
subsuite->name = suite_name;
}
if (list_tests) {
fprintf(stdout, "%s\n", subsuite->name);
}
subsuite->not_run = 0;
if (suite == NULL) {
suite = core_malloc(sizeof(*suite));
suite->head = subsuite;
suite->tail = subsuite;
}
else {
suite->tail->next = subsuite;
suite->tail = subsuite;
}
if (!should_test_run(subsuite->name)) {
subsuite->not_run = 1;
return suite;
}
reset_status();
fprintf(stdout, "%-20s: ", subsuite->name);
update_status();
fflush(stdout);
return suite;
}
void abts_run_test(abts_suite *ts, test_func f, void *value)
{
abts_case tc;
sub_suite *ss;
if (!should_test_run(ts->tail->name)) {
return;
}
ss = ts->tail;
tc.failed = 0;
tc.suite = ss;
ss->num_test++;
update_status();
f(&tc, value);
if (tc.failed) {
ss->failed++;
}
}
static int report(abts_suite *suite)
{
int count = 0;
sub_suite *dptr;
if (suite && suite->tail &&!suite->tail->not_run) {
end_suite(suite);
}
for (dptr = suite->head; dptr; dptr = dptr->next) {
count += dptr->failed;
}
if (list_tests) {
return 0;
}
if (count == 0) {
printf("All tests passed.\n");
return 0;
}
dptr = suite->head;
fprintf(stdout, "%-15s\t\tTotal\tFail\tFailed %%\n", "Failed Tests");
fprintf(stdout, "===================================================\n");
while (dptr != NULL) {
if (dptr->failed != 0) {
float percent = ((float)dptr->failed / (float)dptr->num_test);
fprintf(stdout, "%-15s\t\t%5d\t%4d\t%6.2f%%\n", dptr->name,
dptr->num_test, dptr->failed, percent * 100);
}
dptr = dptr->next;
}
return 1;
}
static void abts_free(abts_suite *suite)
{
sub_suite *ptr = NULL, *next_ptr = NULL;
ptr = suite->head;
while (ptr != NULL) {
next_ptr = ptr->next;
CORE_FREE((void*)ptr->name);
CORE_FREE(ptr);
ptr = next_ptr;
}
CORE_FREE(suite);
}
void abts_log_message(const char *fmt, ...)
{
va_list args;
update_status();
if (verbose) {
va_start(args, fmt);
vfprintf(stderr, fmt, args);
va_end(args);
fprintf(stderr, "\n");
fflush(stderr);
}
}
void abts_int_equal(abts_case *tc, const int expected, const int actual, int lineno)
{
update_status();
if (tc->failed) return;
if (expected == actual) return;
tc->failed = TRUE;
if (verbose) {
fprintf(stderr, "Line %d: expected <%d>, but saw <%d>\n", lineno, expected, actual);
fflush(stderr);
}
}
void abts_int_nequal(abts_case *tc, const int expected, const int actual, int lineno)
{
update_status();
if (tc->failed) return;
if (expected != actual) return;
tc->failed = TRUE;
if (verbose) {
fprintf(stderr, "Line %d: expected <%d>, but saw <%d>\n", lineno, expected, actual);
fflush(stderr);
}
}
void abts_size_equal(abts_case *tc, size_t expected, size_t actual, int lineno)
{
update_status();
if (tc->failed) return;
if (expected == actual) return;
tc->failed = TRUE;
if (verbose) {
/* Note that the comparison is type-exact, reporting must be a best-fit */
fprintf(stderr, "Line %d: expected %lu, but saw %lu\n", lineno,
(unsigned long)expected, (unsigned long)actual);
fflush(stderr);
}
}
void abts_str_equal(abts_case *tc, const char *expected, const char *actual, int lineno)
{
update_status();
if (tc->failed) return;
if (!expected && !actual) return;
if (expected && actual)
if (!strcmp(expected, actual)) return;
tc->failed = TRUE;
if (verbose) {
fprintf(stderr, "Line %d: expected <%s>, but saw <%s>\n", lineno, expected, actual);
fflush(stderr);
}
}
void abts_str_nequal(abts_case *tc, const char *expected, const char *actual,
size_t n, int lineno)
{
update_status();
if (tc->failed) return;
if (!strncmp(expected, actual, n)) return;
tc->failed = TRUE;
if (verbose) {
fprintf(stderr, "Line %d: expected <%s>, but saw <%s>\n", lineno, expected, actual);
fflush(stderr);
}
}
void abts_ptr_null(abts_case *tc, const void *ptr, int lineno)
{
update_status();
if (tc->failed) return;
if (ptr == NULL) return;
tc->failed = TRUE;
if (verbose) {
fprintf(stderr, "Line %d: Expected NULL, but saw <%p>\n", lineno, ptr);
fflush(stderr);
}
}
void abts_ptr_notnull(abts_case *tc, const void *ptr, int lineno)
{
update_status();
if (tc->failed) return;
if (ptr != NULL) return;
tc->failed = TRUE;
if (verbose) {
fprintf(stderr, "Line %d: Expected not NULL, but saw <%p>\n", lineno, ptr);
fflush(stderr);
}
}
void abts_ptr_equal(abts_case *tc, const void *expected, const void *actual, int lineno)
{
update_status();
if (tc->failed) return;
if (expected == actual) return;
tc->failed = TRUE;
if (verbose) {
fprintf(stderr, "Line %d: expected <%p>, but saw <%p>\n", lineno, expected, actual);
fflush(stderr);
}
}
void abts_fail(abts_case *tc, const char *message, int lineno)
{
update_status();
if (tc->failed) return;
tc->failed = TRUE;
if (verbose) {
fprintf(stderr, "Line %d: %s\n", lineno, message);
fflush(stderr);
}
}
void abts_assert(abts_case *tc, const char *message, int condition, int lineno)
{
update_status();
if (tc->failed) return;
if (condition) return;
tc->failed = TRUE;
if (verbose) {
fprintf(stderr, "Line %d: %s\n", lineno, message);
fflush(stderr);
}
}
void abts_true(abts_case *tc, int condition, int lineno)
{
update_status();
if (tc->failed) return;
if (condition) return;
tc->failed = TRUE;
if (verbose) {
fprintf(stderr, "Line %d: Condition is false, but expected true\n", lineno);
fflush(stderr);
}
}
void abts_false(abts_case *tc, int condition, int lineno)
{
update_status();
if (tc->failed) return;
if (!condition) return;
tc->failed = TRUE;
if (verbose) {
fprintf(stderr, "Line %d: Condition is true, but expected false\n", lineno);
fflush(stderr);
}
}
void abts_not_impl(abts_case *tc, const char *message, int lineno)
{
update_status();
tc->suite->not_impl++;
if (verbose) {
fprintf(stderr, "Line %d: %s\n", lineno, message);
fflush(stderr);
}
}
int main(int argc, const char *const argv[]) {
int i;
int rv;
int list_provided = 0;
abts_suite *suite = NULL;
test_initialize();
quiet = !isatty(STDOUT_FILENO);
for (i = 1; i < argc; i++) {
if (!strcmp(argv[i], "-v")) {
verbose = 1;
continue;
}
if (!strcmp(argv[i], "-x")) {
exclude = 1;
continue;
}
if (!strcmp(argv[i], "-l")) {
list_tests = 1;
continue;
}
if (!strcmp(argv[i], "-q")) {
quiet = 1;
continue;
}
if (argv[i][0] == '-') {
fprintf(stderr, "Invalid option: `%s'\n", argv[i]);
exit(1);
}
list_provided = 1;
}
if (list_provided) {
/* Waste a little space here, because it is easier than counting the
* number of tests listed. Besides it is at most three char *.
*/
testlist = core_calloc(argc + 1, sizeof(char *));
for (i = 1; i < argc; i++) {
testlist[i - 1] = argv[i];
}
}
for (i = 0; i < (sizeof(alltests) / sizeof(struct testlist *)); i++) {
suite = alltests[i].func(suite);
}
rv = report(suite);
abts_free(suite);
CORE_FREE(testlist);
return rv;
}

View File

@ -1,112 +0,0 @@
/* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifdef __cplusplus
extern "C" {
#endif
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#ifdef WIN32
#include <io.h>
#else
#include <unistd.h>
#endif
#ifndef ABTS_H
#define ABTS_H
#ifndef FALSE
#define FALSE 0
#endif
#ifndef TRUE
#define TRUE 1
#endif
struct sub_suite {
const char *name;
int num_test;
int failed;
int not_run;
int not_impl;
struct sub_suite *next;
};
typedef struct sub_suite sub_suite;
struct abts_suite {
sub_suite *head;
sub_suite *tail;
};
typedef struct abts_suite abts_suite;
struct abts_case {
int failed;
sub_suite *suite;
};
typedef struct abts_case abts_case;
typedef void (*test_func)(abts_case *tc, void *data);
#define ADD_SUITE(suite) abts_add_suite(suite, __FILE__);
abts_suite *abts_add_suite(abts_suite *suite, const char *suite_name);
void abts_run_test(abts_suite *ts, test_func f, void *value);
void abts_log_message(const char *fmt, ...);
void abts_int_equal(abts_case *tc, const int expected, const int actual, int lineno);
void abts_int_nequal(abts_case *tc, const int expected, const int actual, int lineno);
void abts_str_equal(abts_case *tc, const char *expected, const char *actual, int lineno);
void abts_str_nequal(abts_case *tc, const char *expected, const char *actual,
size_t n, int lineno);
void abts_ptr_null(abts_case *tc, const void *ptr, int lineno);
void abts_ptr_notnull(abts_case *tc, const void *ptr, int lineno);
void abts_ptr_equal(abts_case *tc, const void *expected, const void *actual, int lineno);
void abts_true(abts_case *tc, int condition, int lineno);
void abts_false(abts_case *tc, int condition, int lineno);
void abts_fail(abts_case *tc, const char *message, int lineno);
void abts_not_impl(abts_case *tc, const char *message, int lineno);
void abts_assert(abts_case *tc, const char *message, int condition, int lineno);
void abts_size_equal(abts_case *tc, size_t expected, size_t actual, int lineno);
/* Convenience macros. Ryan hates these! */
#define ABTS_INT_EQUAL(a, b, c) abts_int_equal(a, b, c, __LINE__)
#define ABTS_INT_NEQUAL(a, b, c) abts_int_nequal(a, b, c, __LINE__)
#define ABTS_STR_EQUAL(a, b, c) abts_str_equal(a, b, c, __LINE__)
#define ABTS_STR_NEQUAL(a, b, c, d) abts_str_nequal(a, b, c, d, __LINE__)
#define ABTS_PTR_NULL(a, b) abts_ptr_null(a, b, __LINE__)
#define ABTS_PTR_NOTNULL(a, b) abts_ptr_notnull(a, b, __LINE__)
#define ABTS_PTR_EQUAL(a, b, c) abts_ptr_equal(a, b, c, __LINE__)
#define ABTS_TRUE(a, b) abts_true(a, b, __LINE__);
#define ABTS_FALSE(a, b) abts_false(a, b, __LINE__);
#define ABTS_FAIL(a, b) abts_fail(a, b, __LINE__);
#define ABTS_NOT_IMPL(a, b) abts_not_impl(a, b, __LINE__);
#define ABTS_ASSERT(a, b, c) abts_assert(a, b, c, __LINE__);
#define ABTS_SIZE_EQUAL(a, b, c) abts_size_equal(a, b, c, __LINE__)
abts_suite *run_tests(abts_suite *suite);
abts_suite *run_tests1(abts_suite *suite);
#endif
#ifdef __cplusplus
}
#endif

View File

@ -1,29 +0,0 @@
/* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef APR_TEST_INCLUDES
#define APR_TEST_INCLUDES
#include "abts.h"
#include "testutil.h"
const struct testlist {
abts_suite *(*func)(abts_suite *suite);
} alltests[] = {
{test_s1ap_message},
};
#endif /* APR_TEST_INCLUDES */

File diff suppressed because it is too large Load Diff

View File

@ -1,68 +0,0 @@
#ifndef __S1AP_BUILD_H__
#define __S1AP_BUILD_H__
#if 0
#include "s1ap/s1ap_message.h"
#else
#include "s1ap_message.h"
#endif
#if 0
#include "mme_context.h"
#endif
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
CORE_DECLARE(status_t) s1ap_build_setup_rsp(pkbuf_t **pkbuf);
CORE_DECLARE(status_t) s1ap_build_setup_failure(
pkbuf_t **pkbuf, S1AP_Cause_PR group, long cause, long time_to_wait);
CORE_DECLARE(status_t) s1ap_build_downlink_nas_transport(
pkbuf_t **s1apbuf, enb_ue_t *enb_ue, pkbuf_t *emmbuf);
#if 0
CORE_DECLARE(status_t) s1ap_build_initial_context_setup_request(
pkbuf_t **s1apbuf, mme_ue_t *mme_ue, pkbuf_t *emmbuf);
CORE_DECLARE(status_t) s1ap_build_e_rab_setup_request(
pkbuf_t **s1apbuf, mme_bearer_t *bearer, pkbuf_t *esmbuf);
CORE_DECLARE(status_t) s1ap_build_e_rab_modify_request(
pkbuf_t **s1apbuf, mme_bearer_t *bearer, pkbuf_t *esmbuf);
CORE_DECLARE(status_t) s1ap_build_e_rab_release_command(pkbuf_t **s1apbuf,
mme_bearer_t *bearer, pkbuf_t *esmbuf, S1ap_Cause_PR group, long cause);
CORE_DECLARE(status_t) s1ap_build_ue_context_release_command(
pkbuf_t **s1apbuf, enb_ue_t *enb_ue, S1ap_Cause_PR group, long cause);
CORE_DECLARE(status_t) s1ap_build_paging(pkbuf_t **s1apbuf, mme_ue_t *mme_ue);
CORE_DECLARE(status_t) s1ap_build_path_switch_ack(
pkbuf_t **s1apbuf, mme_ue_t *mme_ue);
CORE_DECLARE(status_t) s1ap_build_path_switch_failure(pkbuf_t **s1apbuf,
c_uint32_t enb_ue_s1ap_id, c_uint32_t mme_ue_s1ap_id,
S1ap_Cause_PR group, long cause);
CORE_DECLARE(status_t) s1ap_build_handover_command(
pkbuf_t **s1apbuf, enb_ue_t *source_ue);
CORE_DECLARE(status_t) s1ap_build_handover_preparation_failure(
pkbuf_t **s1apbuf, enb_ue_t *source_ue, S1ap_Cause_t *cause);
CORE_DECLARE(status_t) s1ap_build_handover_request(
pkbuf_t **s1apbuf, mme_ue_t *mme_ue, enb_ue_t *target_ue,
S1ap_HandoverRequiredIEs_t *required);
CORE_DECLARE(status_t) s1ap_build_handover_cancel_ack(
pkbuf_t **s1apbuf, enb_ue_t *source_ue);
CORE_DECLARE(status_t) s1ap_build_mme_status_transfer(pkbuf_t **s1apbuf,
enb_ue_t *target_ue, S1ap_ENBStatusTransferIEs_t *enb_ies);
CORE_DECLARE(status_t) s1ap_build_error_indication(
pkbuf_t **s1apbuf, c_uint16_t presenceMask,
c_uint32_t enb_ue_s1ap_id, c_uint32_t mme_ue_s1ap_id,
S1ap_Cause_PR group, long cause);
#endif
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __S1AP_BUILD_H__ */

View File

@ -1,201 +0,0 @@
#define TRACE_MODULE _s1ap_conv
#include "core_debug.h"
#include "core_network.h"
#include "3gpp_types.h"
#include "s1ap_conv.h"
void s1ap_uint8_to_OCTET_STRING(c_uint8_t uint8, OCTET_STRING_t *octet_string)
{
octet_string->size = 1;
octet_string->buf = core_calloc(octet_string->size, sizeof(c_uint8_t));
octet_string->buf[0] = uint8;
}
void s1ap_uint16_to_OCTET_STRING(c_uint16_t uint16, OCTET_STRING_t *octet_string)
{
octet_string->size = 2;
octet_string->buf = core_calloc(octet_string->size, sizeof(c_uint8_t));
octet_string->buf[0] = uint16 >> 8;
octet_string->buf[1] = uint16;
}
void s1ap_uint32_to_OCTET_STRING(c_uint32_t uint32, OCTET_STRING_t *octet_string)
{
octet_string->size = 4;
octet_string->buf = core_calloc(octet_string->size, sizeof(c_uint8_t));
octet_string->buf[0] = uint32 >> 24;
octet_string->buf[1] = uint32 >> 16;
octet_string->buf[2] = uint32 >> 8;
octet_string->buf[3] = uint32;
}
void s1ap_buffer_to_OCTET_STRING(
void *buf, int size, S1AP_TBCD_STRING_t *tbcd_string)
{
tbcd_string->size = size;
tbcd_string->buf = core_calloc(tbcd_string->size, sizeof(c_uint8_t));
memcpy(tbcd_string->buf, buf, size);
}
void s1ap_uint32_to_ENB_ID(
S1AP_ENB_ID_PR present, c_uint32_t enb_id, S1AP_ENB_ID_t *eNB_ID)
{
d_assert(eNB_ID, return, "Null param");
eNB_ID->present = present;
if (present == S1AP_ENB_ID_PR_macroENB_ID)
{
BIT_STRING_t *bit_string = &eNB_ID->choice.macroENB_ID;
d_assert(bit_string, return, "Null param");
bit_string->size = 3;
bit_string->buf = core_calloc(bit_string->size, sizeof(c_uint8_t));
bit_string->buf[0] = enb_id >> 12;
bit_string->buf[1] = enb_id >> 4;
bit_string->buf[2] = (enb_id & 0xf) << 4;
bit_string->bits_unused = 4;
}
else if (present == S1AP_ENB_ID_PR_homeENB_ID)
{
BIT_STRING_t *bit_string = &eNB_ID->choice.homeENB_ID;
d_assert(bit_string, return, "Null param");
bit_string->size = 4;
bit_string->buf = core_calloc(bit_string->size, sizeof(c_uint8_t));
bit_string->buf[0] = enb_id >> 20;
bit_string->buf[1] = enb_id >> 12;
bit_string->buf[2] = enb_id >> 4;
bit_string->buf[3] = (enb_id & 0xf) << 4;
bit_string->bits_unused = 4;
}
else
{
d_assert(0, return, "Invalid param");
}
}
void s1ap_ENB_ID_to_uint32(S1AP_ENB_ID_t *eNB_ID, c_uint32_t *uint32)
{
d_assert(uint32, return, "Null param");
d_assert(eNB_ID, return, "Null param");
if (eNB_ID->present == S1AP_ENB_ID_PR_homeENB_ID)
{
c_uint8_t *buf = eNB_ID->choice.homeENB_ID.buf;
d_assert(buf, return, "Null param");
*uint32 = (buf[0] << 20) + (buf[1] << 12) + (buf[2] << 4) +
((buf[3] & 0xf0) >> 4);
}
else if (eNB_ID->present == S1AP_ENB_ID_PR_macroENB_ID)
{
c_uint8_t *buf = eNB_ID->choice.macroENB_ID.buf;
d_assert(buf, return, "Null param");
*uint32 = (buf[0] << 12) + (buf[1] << 4) + ((buf[2] & 0xf0) >> 4);
}
else
{
d_assert(0, return, "Invalid param");
}
}
#if 0
status_t s1ap_BIT_STRING_to_ip(BIT_STRING_t *bit_string, ip_t *ip)
{
char buf[CORE_ADDRSTRLEN], buf2[CORE_ADDRSTRLEN];
d_assert(bit_string, return CORE_ERROR,);
d_assert(ip, return CORE_ERROR,);
if (bit_string->size == IPV4V6_LEN)
{
ip->ipv4 = 1;
ip->ipv6 = 1;
memcpy(&ip->both.addr, bit_string->buf, IPV4_LEN);
memcpy(&ip->both.addr6, bit_string->buf+IPV4_LEN, IPV6_LEN);
d_trace(5, " IPv4[%s] IPv6[%s]\n",
INET_NTOP(&ip->both.addr, buf), INET6_NTOP(&ip->both.addr6, buf2));
}
else if (bit_string->size == IPV4_LEN)
{
ip->ipv4 = 1;
memcpy(&ip->addr, bit_string->buf, IPV4_LEN);
d_trace(5, " IPv4[%s]\n", INET_NTOP(&ip->addr, buf));
}
else if (bit_string->size == IPV6_LEN)
{
ip->ipv6 = 1;
memcpy(&ip->addr6, bit_string->buf, IPV6_LEN);
d_trace(5, " IPv6[%s]\n", INET_NTOP(&ip->addr6, buf));
}
else
d_assert(0, return CORE_ERROR, "Invalid Length(%d)", bit_string->size);
ip->len = bit_string->size;
return CORE_OK;
}
status_t s1ap_ip_to_BIT_STRING(ip_t *ip, BIT_STRING_t *bit_string)
{
char buf[CORE_ADDRSTRLEN], buf2[CORE_ADDRSTRLEN];
d_assert(ip, return CORE_ERROR,);
d_assert(bit_string, return CORE_ERROR,);
if (ip->ipv4 && ip->ipv6)
{
bit_string->size = IPV4V6_LEN;
bit_string->buf = core_calloc(bit_string->size, sizeof(c_uint8_t));
memcpy(bit_string->buf, &ip->both.addr, IPV4_LEN);
memcpy(bit_string->buf+IPV4_LEN, &ip->both.addr6, IPV6_LEN);
d_trace(5, " IPv4[%s] IPv6[%s]\n",
INET_NTOP(&ip->both.addr, buf), INET6_NTOP(&ip->both.addr6, buf2));
}
else if (ip->ipv4)
{
bit_string->size = IPV4_LEN;
bit_string->buf = core_calloc(bit_string->size, sizeof(c_uint8_t));
memcpy(bit_string->buf, &ip->addr, IPV4_LEN);
d_trace(5, " IPv4[%s]\n", INET_NTOP(&ip->addr, buf));
}
else if (ip->ipv6)
{
bit_string->size = IPV6_LEN;
bit_string->buf = core_calloc(bit_string->size, sizeof(c_uint8_t));
memcpy(bit_string->buf, &ip->addr6, IPV6_LEN);
d_trace(5, " IPv6[%s]\n", INET_NTOP(&ip->addr6, buf));
}
else
d_assert(0, return CORE_ERROR,);
return CORE_OK;
}
S1ap_IE_t *s1ap_copy_ie(S1ap_IE_t *ie)
{
S1ap_IE_t *buff;
buff = core_malloc(sizeof (S1ap_IE_t));
d_assert(buff, return NULL,);
memset((void *)buff, 0, sizeof(S1ap_IE_t));
buff->id = ie->id;
buff->criticality = ie->criticality;
buff->value.size = ie->value.size;
buff->value.buf = core_calloc(1, buff->value.size);
memcpy(buff->value.buf, ie->value.buf, buff->value.size);
return buff;
}
#endif

View File

@ -1,38 +0,0 @@
#ifndef __S1AP_CONV_H__
#define __S1AP_CONV_H__
#include "s1ap_message.h"
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
CORE_DECLARE(void) s1ap_uint8_to_OCTET_STRING(
c_uint8_t uint8, OCTET_STRING_t *octet_string);
CORE_DECLARE(void) s1ap_uint16_to_OCTET_STRING(
c_uint16_t uint16, OCTET_STRING_t *octet_string);
CORE_DECLARE(void) s1ap_uint32_to_OCTET_STRING(
c_uint32_t uint32, OCTET_STRING_t *octet_string);
CORE_DECLARE(void) s1ap_buffer_to_OCTET_STRING(
void *buf, int size, S1AP_TBCD_STRING_t *tbcd_string);
CORE_DECLARE(void) s1ap_uint32_to_ENB_ID(
S1AP_ENB_ID_PR present, c_uint32_t enb_id, S1AP_ENB_ID_t *eNB_ID);
CORE_DECLARE(void) s1ap_ENB_ID_to_uint32(
S1AP_ENB_ID_t *eNB_ID, c_uint32_t *uint32);
#if 0
CORE_DECLARE(status_t) s1ap_BIT_STRING_to_ip(
BIT_STRING_t *bit_string, ip_t *ip);
CORE_DECLARE(status_t) s1ap_ip_to_BIT_STRING(
ip_t *ip, BIT_STRING_t *bit_string);
CORE_DECLARE(S1ap_IE_t *) s1ap_copy_ie(S1ap_IE_t *ie);
#endif
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __S1AP_CONV_H__ */

View File

@ -1,362 +0,0 @@
#define TRACE_MODULE __test__test
#include "core_debug.h"
#include "core_pkbuf.h"
#include "core_lib.h"
#include "3gpp_types.h"
#include "s1ap_message.h"
#include "s1ap_build.h"
#include "s1ap_conv.h"
#include "testutil.h"
#if 0
#include "testpacket.h"
#endif
static void s1ap_message_test1(abts_case *tc, void *data)
{
/* S1Reset */
char *payload =
"000e"
"0025000002000240 020000005c001840 02005b0004606400 04005b0004606300"
"03005b0002402c";
pkbuf_t *pkbuf;
s1ap_message_t message;
int result;
char hexbuf[MAX_SDU_LEN];
pkbuf = pkbuf_alloc(0, MAX_SDU_LEN);
ABTS_PTR_NOTNULL(tc, pkbuf);
pkbuf->len = 41;
memcpy(pkbuf->payload,
CORE_HEX(payload, strlen(payload), hexbuf), pkbuf->len);
result = s1ap_decode_pdu(&message, pkbuf);
ABTS_INT_EQUAL(tc, 0, result);
#if 0
asn_fprint(stdout, &asn_DEF_S1AP_S1AP_PDU, &message);
#endif
s1ap_free_pdu(&message);
pkbuf_free(pkbuf);
}
static void s1ap_message_test2(abts_case *tc, void *data)
{
/* InitialUE(Attach Request) */
char *payload =
"000c406f000006000800020001001a00"
"3c3b17df675aa8050741020bf600f110"
"000201030003e605f070000010000502"
"15d011d15200f11030395c0a003103e5"
"e0349011035758a65d0100e0c1004300"
"060000f1103039006440080000f1108c"
"3378200086400130004b00070000f110"
"000201";
s1ap_message_t message;
pkbuf_t *pkbuf;
int result;
char hexbuf[MAX_SDU_LEN];
pkbuf = pkbuf_alloc(0, MAX_SDU_LEN);
ABTS_PTR_NOTNULL(tc, pkbuf);
pkbuf->len = 115;
memcpy(pkbuf->payload,
CORE_HEX(payload, strlen(payload), hexbuf), pkbuf->len);
result = s1ap_decode_pdu(&message, pkbuf);
ABTS_INT_EQUAL(tc, 0, result);
#if 0
asn_fprint(stdout, &asn_DEF_S1AP_S1AP_PDU, &message);
#endif
s1ap_free_pdu(&message);
pkbuf_free(pkbuf);
}
static void s1ap_message_test3(abts_case *tc, void *data)
{
/* initial context setup response */
char *payload =
"2009002500000300004005c0020000bf"
"0008400200010033400f000032400a0a"
"1f0a0123c601000908";
s1ap_message_t message;
pkbuf_t *pkbuf;
int result;
char hexbuf[MAX_SDU_LEN];
pkbuf = pkbuf_alloc(0, MAX_SDU_LEN);
ABTS_PTR_NOTNULL(tc, pkbuf);
pkbuf->len = 41;
memcpy(pkbuf->payload,
CORE_HEX(payload, strlen(payload), hexbuf), pkbuf->len);
result = s1ap_decode_pdu(&message, pkbuf);
ABTS_INT_EQUAL(tc, 0, result);
#if 0
asn_fprint(stdout, &asn_DEF_S1AP_S1AP_PDU, &message);
#endif
s1ap_free_pdu(&message);
pkbuf_free(pkbuf);
}
#if 0
status_t s1ap_build_setup_failure(
pkbuf_t **pkbuf, S1AP_Cause_PR group, long cause, long time_to_wait)
{
int erval;
s1ap_message_t message;
struct S1AP_UnsuccessfulOutcome *unsuccessfulOutcome = NULL;
S1AP_S1SetupFailure_t *s1SetupFailure = NULL;
S1AP_S1SetupFailureIEs_t *ies = NULL;
memset(&message, 0, sizeof(s1ap_message_t));
unsuccessfulOutcome = message.choice.unsuccessfulOutcome;
s1SetupFailure = &unsuccessfulOutcome->value.choice.S1SetupFailure;
memset(&message, 0, sizeof(s1ap_message_t));
ies = core_calloc(1, sizeof(S1AP_S1SetupFailureIEs_t));
ies->value.choice.Cause.present = group;
ies->value.choice.Cause.choice.radioNetwork = cause;
d_trace(5, " Gruop[%d] Cause[%d] TimeToWait[%ld]\n",
group, cause, time_to_wait);
#if 0
if (time_to_wait > -1)
{
ies->presenceMask |= S1AP_S1SETUPFAILUREIES_TIMETOWAIT_PRESENT;
ies->timeToWait = time_to_wait;
}
#endif
printf("__LINE__ = %d\n", __LINE__);
ASN_SEQUENCE_ADD(&s1SetupFailure, ies);
printf("__LINE__ = %d\n", __LINE__);
message.choice.unsuccessfulOutcome->procedureCode =
S1AP_ProcedureCode_S1AP_id_S1Setup;
printf("__LINE__ = %d\n", __LINE__);
erval = s1ap_encode_pdu(pkbuf, &message);
printf("__LINE__ = %d\n", __LINE__);
s1ap_free_pdu(&message);
printf("__LINE__ = %d\n", __LINE__);
if (erval < 0)
{
d_error("s1ap_encode_error : (%d)", erval);
return CORE_ERROR;
}
return CORE_OK;
}
#define MAX_PLMN_ID 6
#define GRP_PER_MME 256 /* According to spec it is 65535 */
#define CODE_PER_MME 256 /* According to spec it is 256 */
typedef struct _served_gummei {
c_uint32_t num_of_plmn_id;
plmn_id_t plmn_id[MAX_PLMN_ID];
c_uint32_t num_of_mme_gid;
c_uint16_t mme_gid[GRP_PER_MME];
c_uint32_t num_of_mme_code;
c_uint8_t mme_code[CODE_PER_MME];
} served_gummei_t;
status_t s1ap_build_setup_rsp(pkbuf_t **pkbuf)
{
int erval;
int i, j;
s1ap_message_t message;
struct S1AP_SuccessfulOutcome *successfulOutcome = NULL;
S1AP_S1SetupResponse_t *s1setupResponse = NULL;
S1AP_S1SetupResponseIEs_t *ies = NULL;
S1AP_ServedGUMMEIsItem_t *servedGUMMEI;
S1AP_PLMNidentity_t *plmnIdentity;
S1AP_MME_Group_ID_t *mmeGroupId;
S1AP_MME_Code_t *mmeCode;
memset(&message, 0, sizeof(s1ap_message_t));
successfulOutcome = message.choice.successfulOutcome;
s1setupResponse = &successfulOutcome->value.choice.S1SetupResponse;
for (i = 0; i < 1; i++)
{
servedGUMMEI = (S1AP_ServedGUMMEIsItem_t *)
core_calloc(1, sizeof(S1AP_ServedGUMMEIsItem_t));
served_gummei_t *served_gummei = NULL, s;
served_gummei = &s;
memset(served_gummei, 0, sizeof(served_gummei_t));
served_gummei->num_of_plmn_id = 1;
plmn_id_build(&served_gummei->plmn_id[0], 1, 1, 2);
served_gummei->num_of_mme_gid = 1;
served_gummei->mme_gid[0] = 2;
served_gummei->num_of_mme_code = 1;
served_gummei->mme_code[0] = 1;
for (j = 0; j < served_gummei->num_of_plmn_id; j++)
{
plmnIdentity = (S1AP_PLMNidentity_t *)
core_calloc(1, sizeof(S1AP_PLMNidentity_t));
s1ap_buffer_to_OCTET_STRING(
&served_gummei->plmn_id[j], PLMN_ID_LEN, plmnIdentity);
ASN_SEQUENCE_ADD(&servedGUMMEI->servedPLMNs, plmnIdentity);
d_trace(5, " PLMN_ID[MCC:%d MNC:%d]\n",
plmn_id_mcc(&served_gummei->plmn_id[j]),
plmn_id_mnc(&served_gummei->plmn_id[j]));
}
for (j = 0; j < served_gummei->num_of_mme_gid; j++)
{
mmeGroupId = (S1AP_MME_Group_ID_t *)
core_calloc(1, sizeof(S1AP_MME_Group_ID_t));
s1ap_uint16_to_OCTET_STRING(
served_gummei->mme_gid[j], mmeGroupId);
ASN_SEQUENCE_ADD(&servedGUMMEI->servedGroupIDs, mmeGroupId);
d_trace(5, " MME Group[%d]\n", served_gummei->mme_gid[j]);
}
for (j = 0; j < served_gummei->num_of_mme_code; j++)
{
mmeCode = (S1AP_MME_Code_t *)
core_calloc(1, sizeof(S1AP_MME_Code_t));
s1ap_uint8_to_OCTET_STRING(
served_gummei->mme_code[j], mmeCode);
ASN_SEQUENCE_ADD(&servedGUMMEI->servedMMECs, mmeCode);
d_trace(5, " MME Code[%d]\n", served_gummei->mme_code[j]);
}
ASN_SEQUENCE_ADD(&s1setupResponse->protocolIEs.list, servedGUMMEI);
}
ies->relativeMMECapacity = 44;
message.procedureCode = S1ap_ProcedureCode_id_S1Setup;
message.direction = S1AP_PDU_PR_successfulOutcome;
erval = s1ap_encode_pdu(pkbuf, &message);
s1ap_free_pdu(&message);
if (erval < 0)
{
d_error("s1ap_encode_error : (%d)", erval);
return CORE_ERROR;
}
return CORE_OK;
}
#endif
static void s1ap_message_test4(abts_case *tc, void *data)
{
s1ap_message_t message;
status_t rv;
pkbuf_t *pkbuf;
int result;
rv = s1ap_build_setup_failure(&pkbuf, 2, 0, 0);
ABTS_INT_EQUAL(tc, CORE_OK, rv);
ABTS_PTR_NOTNULL(tc, pkbuf);
ABTS_PTR_NOTNULL(tc, pkbuf->payload);
#if 0
ABTS_INT_EQUAL(tc, 27, pkbuf->len);
#endif
result = s1ap_decode_pdu(&message, pkbuf);
ABTS_INT_EQUAL(tc, 0, result);
#if 1
asn_fprint(stdout, &asn_DEF_S1AP_S1AP_PDU, &message);
#endif
s1ap_free_pdu(&message);
pkbuf_free(pkbuf);
}
#if 0
static void s1ap_message_test5(abts_case *tc, void *data)
{
s1ap_message_t message;
status_t rv;
pkbuf_t *pkbuf;
int result;
rv = tests1ap_build_setup_req(&pkbuf, S1ap_ENB_ID_PR_macroENB_ID, 0x54f64);
ABTS_INT_EQUAL(tc, CORE_OK, rv);
ABTS_PTR_NOTNULL(tc, pkbuf);
ABTS_PTR_NOTNULL(tc, pkbuf->payload);
ABTS_INT_EQUAL(tc, 35, pkbuf->len);
result = s1ap_decode_pdu(&message, pkbuf);
ABTS_INT_EQUAL(tc, 0, result);
s1ap_free_pdu(&message);
pkbuf_free(pkbuf);
}
static void s1ap_message_test6(abts_case *tc, void *data)
{
pkbuf_t *s1apbuf = NULL;
int i;
s1ap_message_t message;
S1ap_DownlinkNASTransport_IEs_t *ies =
&message.s1ap_DownlinkNASTransport_IEs;
S1ap_NAS_PDU_t *nasPdu = &ies->nas_pdu;
char buffer[1024];
char *_result =
"000b4080 8c000003 00000002 00010008 00020001 001a0079 78efefef efefefef"
"efefefef efefefef efefefef efefefef efefefef efefefef efefefef efefefef"
"efefefef efefefef efefefef efefefef efefefef efefefef efefefef efefefef"
"efefefef efefefef efefefef efefefef efefefef efefefef efefefef efefefef"
"efefefef efefefef efefefef efefefef ef";
memset(&message, 0, sizeof(s1ap_message_t));
ies->mme_ue_s1ap_id = 1;
ies->eNB_UE_S1AP_ID = 1;
nasPdu->size = 120;
nasPdu->buf = core_calloc(nasPdu->size, sizeof(c_uint8_t));
for (i = 0; i < nasPdu->size; i++)
nasPdu->buf[i] = 0xef;
message.procedureCode = S1ap_ProcedureCode_id_downlinkNASTransport;
message.direction = S1AP_PDU_PR_initiatingMessage;
s1ap_encode_pdu(&s1apbuf, &message);
s1ap_free_pdu(&message);
ABTS_TRUE(tc, memcmp(CORE_HEX(_result, strlen(_result), buffer),
s1apbuf->payload, s1apbuf->len) == 0);
pkbuf_free(s1apbuf);
}
#endif
abts_suite *test_s1ap_message(abts_suite *suite)
{
suite = ADD_SUITE(suite)
abts_run_test(suite, s1ap_message_test1, NULL);
abts_run_test(suite, s1ap_message_test2, NULL);
abts_run_test(suite, s1ap_message_test3, NULL);
abts_run_test(suite, s1ap_message_test4, NULL);
#if 0
abts_run_test(suite, s1ap_message_test5, NULL);
abts_run_test(suite, s1ap_message_test6, NULL);
#endif
return suite;
}

View File

@ -1,41 +0,0 @@
/* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "core.h"
#include "abts.h"
#include "testutil.h"
void core_assert_ok(abts_case* tc, const char* context, status_t rv,
int lineno)
{
if (rv == CORE_ENOTIMPL)
{
abts_not_impl(tc, context, lineno);
} else if (rv != CORE_OK)
{
char buf[STRING_MAX], ebuf[128];
sprintf(buf, "%s (%d): %s\n", context, rv,
core_strerror(rv, ebuf, sizeof ebuf));
abts_fail(tc, buf, lineno);
}
}
void test_initialize(void)
{
core_initialize();
atexit(core_terminate);
}

View File

@ -1,62 +0,0 @@
/* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "core_general.h"
#include "abts.h"
#ifndef __APR_TEST_UTIL__
#define __APR_TEST_UTIL__
/* XXX: FIXME - these all should become much more utilitarian
* and part of core, itself
*/
#ifdef WIN32
#ifdef BINPATH
#define TESTBINPATH APR_STRINGIFY(BINPATH) "/"
#else
#define TESTBINPATH ""
#endif
#else
#define TESTBINPATH "./"
#endif
#ifdef WIN32
#define EXTENSION ".exe"
#elif NETWARE
#define EXTENSION ".nlm"
#else
#define EXTENSION
#endif
#define STRING_MAX 8096
/* Some simple functions to make the test apps easier to write and
* a bit more consistent...
*/
/* Assert that RV is an CORE_OK value; else fail giving strerror
* for RV and CONTEXT message. */
void core_assert_ok(abts_case* tc, const char *context,
status_t rv, int lineno);
#define CORE_ASSERT_OK(tc, ctxt, rv) \
core_assert_ok(tc, ctxt, rv, __LINE__)
void test_initialize(void);
abts_suite *test_s1ap_message(abts_suite *suite);
#endif /* CORE_TEST_INCLUDES */

View File

@ -423,7 +423,7 @@ void emm_state_authentication(fsm_t *s, event_t *e)
switch(authentication_failure->emm_cause)
{
case EMM_CAUSE_MAC_FAILURE:
d_error("Authentication failure(MAC failure)");
d_warn("Authentication failure(MAC failure)");
break;
case EMM_CAUSE_NON_EPS_AUTHENTICATION_UNACCEPTABLE:
d_error("Authentication failure"

View File

@ -199,8 +199,6 @@ status_t s1ap_build_downlink_nas_transport(
d_assert(enb_ue, return CORE_ERROR, "Null param");
d_trace(3, "[MME] Downlink NAS transport\n");
d_trace(5, " ENB_UE_S1AP_ID[%d] MME_UE_S1AP_ID[%d]\n",
enb_ue->enb_ue_s1ap_id, enb_ue->mme_ue_s1ap_id);
memset(&pdu, 0, sizeof (S1AP_S1AP_PDU_t));
pdu.present = S1AP_S1AP_PDU_PR_initiatingMessage;
@ -244,16 +242,19 @@ status_t s1ap_build_downlink_nas_transport(
NAS_PDU = &ie->value.choice.NAS_PDU;
d_trace(5, " ENB_UE_S1AP_ID[%d] MME_UE_S1AP_ID[%d]\n",
enb_ue->enb_ue_s1ap_id, enb_ue->mme_ue_s1ap_id);
*MME_UE_S1AP_ID = enb_ue->mme_ue_s1ap_id;
*ENB_UE_S1AP_ID = enb_ue->enb_ue_s1ap_id;
NAS_PDU->size = emmbuf->len;
NAS_PDU->buf = core_calloc(NAS_PDU->size, sizeof(c_uint8_t));
memcpy(NAS_PDU->buf, emmbuf->payload, NAS_PDU->size);
pkbuf_free(emmbuf);
rv = s1ap_encode_pdu(s1apbuf, &pdu);
s1ap_free_pdu(&pdu);
pkbuf_free(emmbuf);
if (rv != CORE_OK)
{
@ -457,6 +458,7 @@ status_t s1ap_build_initial_context_setup_request(
nasPdu->buf = core_calloc(nasPdu->size, sizeof(c_uint8_t));
memcpy(nasPdu->buf, emmbuf->payload, nasPdu->size);
e_rab->nAS_PDU = nasPdu;
pkbuf_free(emmbuf);
}
bearer = mme_bearer_next(bearer);
@ -511,7 +513,6 @@ status_t s1ap_build_initial_context_setup_request(
rv = s1ap_encode_pdu(s1apbuf, &pdu);
s1ap_free_pdu(&pdu);
pkbuf_free(emmbuf);
if (rv != CORE_OK)
{
@ -525,14 +526,22 @@ status_t s1ap_build_initial_context_setup_request(
status_t s1ap_build_e_rab_setup_request(
pkbuf_t **s1apbuf, mme_bearer_t *bearer, pkbuf_t *esmbuf)
{
#if 0
status_t rv;
int encoded;
s1ap_message_t message;
S1AP_E_RABSetupRequestIEs_t *ies = &message.s1ap_E_RABSetupRequestIEs;
S1AP_S1AP_PDU_t pdu;
S1AP_InitiatingMessage_t *initiatingMessage = NULL;
S1AP_E_RABSetupRequest_t *E_RABSetupRequest = NULL;
S1AP_E_RABSetupRequestIEs_t *ie = NULL;
S1AP_MME_UE_S1AP_ID_t *MME_UE_S1AP_ID = NULL;
S1AP_ENB_UE_S1AP_ID_t *ENB_UE_S1AP_ID = NULL;
S1AP_E_RABToBeSetupListBearerSUReq_t *E_RABToBeSetupListBearerSUReq = NULL;
S1AP_E_RABToBeSetupItemBearerSUReqIEs_t *item = NULL;
S1AP_E_RABToBeSetupItemBearerSUReq_t *e_rab = NULL;
struct S1AP_GBR_QosInformation *gbrQosInformation = NULL; /* OPTIONAL */
S1AP_GBR_QosInformation_t *gbrQosInformation = NULL;
S1AP_NAS_PDU_t *nasPdu = NULL;
mme_ue_t *mme_ue = NULL;
enb_ue_t *enb_ue = NULL;
@ -544,17 +553,64 @@ status_t s1ap_build_e_rab_setup_request(
enb_ue = mme_ue->enb_ue;
d_assert(enb_ue, return CORE_ERROR, "Null param");
d_trace(3, "[MME] E-RAB setup request\n");
memset(&pdu, 0, sizeof (S1AP_S1AP_PDU_t));
pdu.present = S1AP_S1AP_PDU_PR_initiatingMessage;
pdu.choice.initiatingMessage =
core_calloc(1, sizeof(S1AP_InitiatingMessage_t));
initiatingMessage = pdu.choice.initiatingMessage;
initiatingMessage->procedureCode = S1AP_ProcedureCode_id_E_RABSetup;
initiatingMessage->criticality = S1AP_Criticality_reject;
initiatingMessage->value.present =
S1AP_InitiatingMessage__value_PR_E_RABSetupRequest;
E_RABSetupRequest = &initiatingMessage->value.choice.E_RABSetupRequest;
ie = core_calloc(1, sizeof(S1AP_E_RABSetupRequestIEs_t));
ASN_SEQUENCE_ADD(&E_RABSetupRequest->protocolIEs, ie);
ie->id = S1AP_ProtocolIE_ID_id_MME_UE_S1AP_ID;
ie->criticality = S1AP_Criticality_reject;
ie->value.present = S1AP_E_RABSetupRequestIEs__value_PR_MME_UE_S1AP_ID;
MME_UE_S1AP_ID = &ie->value.choice.MME_UE_S1AP_ID;
ie = core_calloc(1, sizeof(S1AP_E_RABSetupRequestIEs_t));
ASN_SEQUENCE_ADD(&E_RABSetupRequest->protocolIEs, ie);
ie->id = S1AP_ProtocolIE_ID_id_eNB_UE_S1AP_ID;
ie->criticality = S1AP_Criticality_reject;
ie->value.present = S1AP_E_RABSetupRequestIEs__value_PR_ENB_UE_S1AP_ID;
ENB_UE_S1AP_ID = &ie->value.choice.ENB_UE_S1AP_ID;
ie = core_calloc(1, sizeof(S1AP_E_RABSetupRequestIEs_t));
ASN_SEQUENCE_ADD(&E_RABSetupRequest->protocolIEs, ie);
ie->id = S1AP_ProtocolIE_ID_id_E_RABToBeSetupListBearerSUReq;
ie->criticality = S1AP_Criticality_reject;
ie->value.present =
S1AP_E_RABSetupRequestIEs__value_PR_E_RABToBeSetupListBearerSUReq;
E_RABToBeSetupListBearerSUReq =
&ie->value.choice.E_RABToBeSetupListBearerSUReq;
d_trace(5, " ENB_UE_S1AP_ID[%d] MME_UE_S1AP_ID[%d]\n",
enb_ue->enb_ue_s1ap_id, enb_ue->mme_ue_s1ap_id);
memset(&message, 0, sizeof(s1ap_message_t));
*MME_UE_S1AP_ID = enb_ue->mme_ue_s1ap_id;
*ENB_UE_S1AP_ID = enb_ue->enb_ue_s1ap_id;
ies->mme_ue_s1ap_id = enb_ue->mme_ue_s1ap_id;
ies->eNB_UE_S1AP_ID = enb_ue->enb_ue_s1ap_id;
item = core_calloc(1, sizeof(S1AP_E_RABToBeSetupItemBearerSUReqIEs_t));
ASN_SEQUENCE_ADD(&E_RABToBeSetupListBearerSUReq->list, item);
item->id = S1AP_ProtocolIE_ID_id_E_RABToBeSetupItemBearerSUReq;
item->criticality = S1AP_Criticality_reject;
item->value.present =
S1AP_E_RABToBeSetupItemBearerSUReqIEs__value_PR_E_RABToBeSetupItemBearerSUReq;
e_rab = &item->value.choice.E_RABToBeSetupItemBearerSUReq;
e_rab = (S1AP_E_RABToBeSetupItemBearerSUReq_t *)
core_calloc(1, sizeof(S1AP_E_RABToBeSetupItemBearerSUReq_t));
e_rab->e_RAB_ID = bearer->ebi;
e_rab->e_RABlevelQoSParameters.qCI = bearer->qos.qci;
@ -579,8 +635,7 @@ status_t s1ap_build_e_rab_setup_request(
if (bearer->qos.gbr.uplink == 0)
bearer->qos.gbr.uplink = MAX_BIT_RATE;
gbrQosInformation =
core_calloc(1, sizeof(struct S1AP_GBR_QosInformation));
gbrQosInformation = core_calloc(1, sizeof(S1AP_GBR_QosInformation_t));
asn_uint642INTEGER(&gbrQosInformation->e_RAB_MaximumBitrateDL,
bearer->qos.mbr.downlink);
asn_uint642INTEGER(&gbrQosInformation->e_RAB_MaximumBitrateUL,
@ -602,19 +657,16 @@ status_t s1ap_build_e_rab_setup_request(
nasPdu->size = esmbuf->len;
nasPdu->buf = core_calloc(nasPdu->size, sizeof(c_uint8_t));
memcpy(nasPdu->buf, esmbuf->payload, nasPdu->size);
ASN_SEQUENCE_ADD(&ies->e_RABToBeSetupListBearerSUReq, e_rab);
message.procedureCode = S1AP_ProcedureCode_id_E_RABSetup;
message.direction = S1AP_PDU_PR_initiatingMessage;
encoded = s1ap_encode_pdu(s1apbuf, &message);
s1ap_free_pdu(&message);
d_assert(s1apbuf && encoded >= 0,return CORE_ERROR,);
pkbuf_free(esmbuf);
#endif
rv = s1ap_encode_pdu(s1apbuf, &pdu);
s1ap_free_pdu(&pdu);
if (rv != CORE_OK)
{
d_error("s1ap_encode_pdu() failed");
return CORE_ERROR;
}
return CORE_OK;
}
@ -713,12 +765,22 @@ status_t s1ap_build_e_rab_release_command(pkbuf_t **s1apbuf,
mme_bearer_t *bearer, pkbuf_t *esmbuf,
S1AP_Cause_PR group, long cause)
{
#if 0
int encoded;
s1ap_message_t message;
S1AP_E_RABReleaseCommandIEs_t *ies = &message.s1ap_E_RABReleaseCommandIEs;
S1AP_E_RABItem_t *e_rab = NULL;
status_t rv;
S1AP_S1AP_PDU_t pdu;
S1AP_InitiatingMessage_t *initiatingMessage = NULL;
S1AP_E_RABReleaseCommand_t *E_RABReleaseCommand = NULL;
S1AP_E_RABReleaseCommandIEs_t *ie = NULL;
S1AP_MME_UE_S1AP_ID_t *MME_UE_S1AP_ID = NULL;
S1AP_ENB_UE_S1AP_ID_t *ENB_UE_S1AP_ID = NULL;
S1AP_UEAggregateMaximumBitrate_t *UEAggregateMaximumBitrate = NULL;
S1AP_E_RABList_t *E_RABList = NULL;
S1AP_NAS_PDU_t *nasPdu = NULL;
S1AP_E_RABItemIEs_t *item = NULL;
S1AP_E_RABItem_t *e_rab = NULL;
mme_ue_t *mme_ue = NULL;
enb_ue_t *enb_ue = NULL;
s6a_subscription_data_t *subscription_data = NULL;
@ -734,48 +796,107 @@ status_t s1ap_build_e_rab_release_command(pkbuf_t **s1apbuf,
d_assert(subscription_data, return CORE_ERROR, "Null param");
d_trace(3, "[MME] E-RAB release command\n");
memset(&pdu, 0, sizeof (S1AP_S1AP_PDU_t));
pdu.present = S1AP_S1AP_PDU_PR_initiatingMessage;
pdu.choice.initiatingMessage =
core_calloc(1, sizeof(S1AP_InitiatingMessage_t));
initiatingMessage = pdu.choice.initiatingMessage;
initiatingMessage->procedureCode = S1AP_ProcedureCode_id_E_RABRelease;
initiatingMessage->criticality = S1AP_Criticality_reject;
initiatingMessage->value.present =
S1AP_InitiatingMessage__value_PR_E_RABReleaseCommand;
E_RABReleaseCommand = &initiatingMessage->value.choice.E_RABReleaseCommand;
ie = core_calloc(1, sizeof(S1AP_E_RABReleaseCommandIEs_t));
ASN_SEQUENCE_ADD(&E_RABReleaseCommand->protocolIEs, ie);
ie->id = S1AP_ProtocolIE_ID_id_MME_UE_S1AP_ID;
ie->criticality = S1AP_Criticality_reject;
ie->value.present = S1AP_E_RABReleaseCommandIEs__value_PR_MME_UE_S1AP_ID;
MME_UE_S1AP_ID = &ie->value.choice.MME_UE_S1AP_ID;
ie = core_calloc(1, sizeof(S1AP_E_RABReleaseCommandIEs_t));
ASN_SEQUENCE_ADD(&E_RABReleaseCommand->protocolIEs, ie);
ie->id = S1AP_ProtocolIE_ID_id_eNB_UE_S1AP_ID;
ie->criticality = S1AP_Criticality_reject;
ie->value.present = S1AP_E_RABReleaseCommandIEs__value_PR_ENB_UE_S1AP_ID;
ENB_UE_S1AP_ID = &ie->value.choice.ENB_UE_S1AP_ID;
ie = core_calloc(1, sizeof(S1AP_E_RABReleaseCommandIEs_t));
ASN_SEQUENCE_ADD(&E_RABReleaseCommand->protocolIEs, ie);
ie->id = S1AP_ProtocolIE_ID_id_uEaggregateMaximumBitrate;
ie->criticality = S1AP_Criticality_reject;
ie->value.present =
S1AP_E_RABReleaseCommandIEs__value_PR_UEAggregateMaximumBitrate;
UEAggregateMaximumBitrate = &ie->value.choice.UEAggregateMaximumBitrate;
ie = core_calloc(1, sizeof(S1AP_E_RABReleaseCommandIEs_t));
ASN_SEQUENCE_ADD(&E_RABReleaseCommand->protocolIEs, ie);
ie->id = S1AP_ProtocolIE_ID_id_E_RABToBeReleasedList;
ie->criticality = S1AP_Criticality_ignore;
ie->value.present = S1AP_E_RABReleaseCommandIEs__value_PR_E_RABList;
E_RABList = &ie->value.choice.E_RABList;
ie = core_calloc(1, sizeof(S1AP_E_RABReleaseCommandIEs_t));
ASN_SEQUENCE_ADD(&E_RABReleaseCommand->protocolIEs, ie);
ie->id = S1AP_ProtocolIE_ID_id_NAS_PDU;
ie->criticality = S1AP_Criticality_ignore;
ie->value.present = S1AP_E_RABReleaseCommandIEs__value_PR_NAS_PDU;
nasPdu = &ie->value.choice.NAS_PDU;
d_trace(5, " ENB_UE_S1AP_ID[%d] MME_UE_S1AP_ID[%d]\n",
enb_ue->enb_ue_s1ap_id, enb_ue->mme_ue_s1ap_id);
memset(&message, 0, sizeof(s1ap_message_t));
*MME_UE_S1AP_ID = enb_ue->mme_ue_s1ap_id;
*ENB_UE_S1AP_ID = enb_ue->enb_ue_s1ap_id;
ies->mme_ue_s1ap_id = enb_ue->mme_ue_s1ap_id;
ies->eNB_UE_S1AP_ID = enb_ue->enb_ue_s1ap_id;
ies->presenceMask |=
S1AP_E_RABRELEASECOMMANDIES_UEAGGREGATEMAXIMUMBITRATE_PRESENT;
asn_uint642INTEGER(
&ies->uEaggregateMaximumBitrate.uEaggregateMaximumBitRateUL,
&UEAggregateMaximumBitrate->uEaggregateMaximumBitRateUL,
subscription_data->ambr.uplink);
asn_uint642INTEGER(
&ies->uEaggregateMaximumBitrate.uEaggregateMaximumBitRateDL,
&UEAggregateMaximumBitrate->uEaggregateMaximumBitRateDL,
subscription_data->ambr.downlink);
e_rab = (S1AP_E_RABItem_t *)core_calloc(1, sizeof(S1AP_E_RABItem_t));
item = core_calloc(1, sizeof(S1AP_E_RABItemIEs_t));
ASN_SEQUENCE_ADD(&E_RABList->list, item);
item->id = S1AP_ProtocolIE_ID_id_E_RABItem;
item->criticality = S1AP_Criticality_ignore;
item->value.present = S1AP_E_RABItemIEs__value_PR_E_RABItem;
e_rab = &item->value.choice.E_RABItem;
e_rab->e_RAB_ID = bearer->ebi;
e_rab->cause.present = group;
e_rab->cause.choice.radioNetwork = cause;
d_trace(5, " EBI[%d] Gruop[%d] Cause[%d]\n", bearer->ebi, group, cause);
ies->presenceMask |= S1AP_E_RABRELEASECOMMANDIES_NAS_PDU_PRESENT;
nasPdu = &ies->nas_pdu;
nasPdu->size = esmbuf->len;
nasPdu->buf = core_calloc(nasPdu->size, sizeof(c_uint8_t));
memcpy(nasPdu->buf, esmbuf->payload, nasPdu->size);
ASN_SEQUENCE_ADD(&ies->e_RABToBeReleasedList, e_rab);
message.procedureCode = S1AP_ProcedureCode_id_E_RABRelease;
message.direction = S1AP_PDU_PR_initiatingMessage;
encoded = s1ap_encode_pdu(s1apbuf, &message);
s1ap_free_pdu(&message);
d_assert(s1apbuf && encoded >= 0,return CORE_ERROR,);
pkbuf_free(esmbuf);
#endif
rv = s1ap_encode_pdu(s1apbuf, &pdu);
s1ap_free_pdu(&pdu);
if (rv != CORE_OK)
{
d_error("s1ap_encode_pdu() failed");
return CORE_ERROR;
}
return CORE_OK;
}
@ -783,77 +904,171 @@ status_t s1ap_build_e_rab_release_command(pkbuf_t **s1apbuf,
status_t s1ap_build_ue_context_release_command(
pkbuf_t **s1apbuf, enb_ue_t *enb_ue, S1AP_Cause_PR group, long cause)
{
#if 0
int encoded;
s1ap_message_t message;
S1AP_UEContextReleaseCommand_IEs_t *ies =
&message.s1ap_UEContextReleaseCommand_IEs;
status_t rv;
S1AP_S1AP_PDU_t pdu;
S1AP_InitiatingMessage_t *initiatingMessage = NULL;
S1AP_UEContextReleaseCommand_t *UEContextReleaseCommand = NULL;
S1AP_UEContextReleaseCommand_IEs_t *ie = NULL;
S1AP_UE_S1AP_IDs_t *UE_S1AP_IDs = NULL;
S1AP_Cause_t *Cause = NULL;
d_assert(enb_ue, return CORE_ERROR, "Null param");
memset(&message, 0, sizeof(s1ap_message_t));
if (enb_ue->mme_ue_s1ap_id == 0)
{
d_error("invalid mme ue s1ap id (idx: %d)", enb_ue->index);
return CORE_ERROR;
}
memset(&pdu, 0, sizeof (S1AP_S1AP_PDU_t));
pdu.present = S1AP_S1AP_PDU_PR_initiatingMessage;
pdu.choice.initiatingMessage =
core_calloc(1, sizeof(S1AP_InitiatingMessage_t));
initiatingMessage = pdu.choice.initiatingMessage;
initiatingMessage->procedureCode = S1AP_ProcedureCode_id_UEContextRelease;
initiatingMessage->criticality = S1AP_Criticality_reject;
initiatingMessage->value.present =
S1AP_InitiatingMessage__value_PR_UEContextReleaseCommand;
UEContextReleaseCommand =
&initiatingMessage->value.choice.UEContextReleaseCommand;
ie = core_calloc(1, sizeof(S1AP_UEContextReleaseCommand_IEs_t));
ASN_SEQUENCE_ADD(&UEContextReleaseCommand->protocolIEs, ie);
ie->id = S1AP_ProtocolIE_ID_id_UE_S1AP_IDs;
ie->criticality = S1AP_Criticality_reject;
ie->value.present =
S1AP_UEContextReleaseCommand_IEs__value_PR_UE_S1AP_IDs;
UE_S1AP_IDs = &ie->value.choice.UE_S1AP_IDs;
ie = core_calloc(1, sizeof(S1AP_UEContextReleaseCommand_IEs_t));
ASN_SEQUENCE_ADD(&UEContextReleaseCommand->protocolIEs, ie);
ie->id = S1AP_ProtocolIE_ID_id_Cause;
ie->criticality = S1AP_Criticality_ignore;
ie->value.present =
S1AP_UEContextReleaseCommand_IEs__value_PR_Cause;
Cause = &ie->value.choice.Cause;
#if 0 /* ENB_UE_S1AP_ID could be allocated with 0 from eNodeB */
if (enb_ue->enb_ue_s1ap_id)
#endif
{
ies->uE_S1AP_IDs.present = S1AP_UE_S1AP_IDs_PR_uE_S1AP_ID_pair;
ies->uE_S1AP_IDs.choice.uE_S1AP_ID_pair.mME_UE_S1AP_ID =
UE_S1AP_IDs->present = S1AP_UE_S1AP_IDs_PR_uE_S1AP_ID_pair;
UE_S1AP_IDs->choice.uE_S1AP_ID_pair =
core_calloc(1, sizeof(S1AP_UE_S1AP_ID_pair_t));
UE_S1AP_IDs->choice.uE_S1AP_ID_pair->mME_UE_S1AP_ID =
enb_ue->mme_ue_s1ap_id;
ies->uE_S1AP_IDs.choice.uE_S1AP_ID_pair.eNB_UE_S1AP_ID =
UE_S1AP_IDs->choice.uE_S1AP_ID_pair->eNB_UE_S1AP_ID =
enb_ue->enb_ue_s1ap_id;
ies->uE_S1AP_IDs.choice.uE_S1AP_ID_pair.iE_Extensions = NULL;
}
#if 0
else
{
ies->uE_S1AP_IDs.present = S1AP_UE_S1AP_IDs_PR_mME_UE_S1AP_ID;
ies->uE_S1AP_IDs.choice.mME_UE_S1AP_ID = enb_ue->mme_ue_s1ap_id;
UE_S1AP_IDs->present = S1AP_UE_S1AP_IDs_PR_mME_UE_S1AP_ID;
UE_S1AP_IDs->choice.mME_UE_S1AP_ID = enb_ue->mme_ue_s1ap_id;
}
#endif
ies->cause.present = group;
ies->cause.choice.radioNetwork = cause;
Cause->present = group;
Cause->choice.radioNetwork = cause;
message.procedureCode = S1AP_ProcedureCode_id_UEContextRelease;
message.direction = S1AP_PDU_PR_initiatingMessage;
rv = s1ap_encode_pdu(s1apbuf, &pdu);
s1ap_free_pdu(&pdu);
encoded = s1ap_encode_pdu(s1apbuf, &message);
s1ap_free_pdu(&message);
d_assert(s1apbuf && encoded >= 0, return CORE_ERROR,);
#endif
if (rv != CORE_OK)
{
d_error("s1ap_encode_pdu() failed");
return CORE_ERROR;
}
return CORE_OK;
}
status_t s1ap_build_paging(pkbuf_t **s1apbuf, mme_ue_t *mme_ue)
{
#if 0
int encoded;
s1ap_message_t message;
S1AP_PagingIEs_t *ies = &message.s1ap_PagingIEs;
status_t rv;
S1AP_S1AP_PDU_t pdu;
S1AP_InitiatingMessage_t *initiatingMessage = NULL;
S1AP_Paging_t *Paging = NULL;
S1AP_PagingIEs_t *ie = NULL;
S1AP_UEIdentityIndexValue_t *UEIdentityIndexValue = NULL;
S1AP_UEPagingID_t *UEPagingID = NULL;
S1AP_CNDomain_t *CNDomain = NULL;
S1AP_TAIList_t *TAIList = NULL;
S1AP_TAIItemIEs_t *item = NULL;
S1AP_TAIItem_t *tai_item = NULL;
c_uint16_t index_value;
c_uint64_t ue_imsi_value = 0;
int i = 0;
d_assert(mme_ue, return CORE_ERROR, "Null param");
memset(&message, 0, sizeof(s1ap_message_t));
d_trace(3, "[MME] Paging\n");
memset(&pdu, 0, sizeof (S1AP_S1AP_PDU_t));
pdu.present = S1AP_S1AP_PDU_PR_initiatingMessage;
pdu.choice.initiatingMessage =
core_calloc(1, sizeof(S1AP_InitiatingMessage_t));
initiatingMessage = pdu.choice.initiatingMessage;
initiatingMessage->procedureCode = S1AP_ProcedureCode_id_Paging;
initiatingMessage->criticality = S1AP_Criticality_ignore;
initiatingMessage->value.present = S1AP_InitiatingMessage__value_PR_Paging;
Paging = &initiatingMessage->value.choice.Paging;
ie = core_calloc(1, sizeof(S1AP_PagingIEs_t));
ASN_SEQUENCE_ADD(&Paging->protocolIEs, ie);
ie->id = S1AP_ProtocolIE_ID_id_UEIdentityIndexValue;
ie->criticality = S1AP_Criticality_ignore;
ie->value.present = S1AP_PagingIEs__value_PR_UEIdentityIndexValue;
UEIdentityIndexValue = &ie->value.choice.UEIdentityIndexValue;
ie = core_calloc(1, sizeof(S1AP_PagingIEs_t));
ASN_SEQUENCE_ADD(&Paging->protocolIEs, ie);
ie->id = S1AP_ProtocolIE_ID_id_UEPagingID;
ie->criticality = S1AP_Criticality_ignore;
ie->value.present = S1AP_PagingIEs__value_PR_UEPagingID;
UEPagingID = &ie->value.choice.UEPagingID;
ie = core_calloc(1, sizeof(S1AP_PagingIEs_t));
ASN_SEQUENCE_ADD(&Paging->protocolIEs, ie);
ie->id = S1AP_ProtocolIE_ID_id_CNDomain;
ie->criticality = S1AP_Criticality_ignore;
ie->value.present = S1AP_PagingIEs__value_PR_CNDomain;
CNDomain = &ie->value.choice.CNDomain;
ie = core_calloc(1, sizeof(S1AP_PagingIEs_t));
ASN_SEQUENCE_ADD(&Paging->protocolIEs, ie);
ie->id = S1AP_ProtocolIE_ID_id_TAIList;
ie->criticality = S1AP_Criticality_ignore;
ie->value.present = S1AP_PagingIEs__value_PR_TAIList;
TAIList = &ie->value.choice.TAIList;
/* Set UE Identity Index value : IMSI mod 4096 */
ies->ueIdentityIndexValue.size = 2;
ies->ueIdentityIndexValue.buf =
core_calloc(ies->ueIdentityIndexValue.size, sizeof(c_uint8_t));
UEIdentityIndexValue->size = 2;
UEIdentityIndexValue->buf =
core_calloc(UEIdentityIndexValue->size, sizeof(c_uint8_t));
/* Conver string to value */
for (i = 0; i < strlen(mme_ue->imsi_bcd); i++)
@ -863,40 +1078,46 @@ status_t s1ap_build_paging(pkbuf_t **s1apbuf, mme_ue_t *mme_ue)
/* index(10bit) = ue_imsi_value mod 1024 */
index_value = ue_imsi_value % 1024;
ies->ueIdentityIndexValue.buf[0] = index_value >> 2;
ies->ueIdentityIndexValue.buf[1] = (index_value & 0x3f) << 6;
ies->ueIdentityIndexValue.bits_unused = 6;
UEIdentityIndexValue->buf[0] = index_value >> 2;
UEIdentityIndexValue->buf[1] = (index_value & 0x3f) << 6;
UEIdentityIndexValue->bits_unused = 6;
/* Set Paging Identity */
ies->uePagingID.present = S1AP_UEPagingID_PR_s_TMSI;
UEPagingID->present = S1AP_UEPagingID_PR_s_TMSI;
UEPagingID->choice.s_TMSI =
core_calloc(1, sizeof(S1AP_S_TMSI_t));
s1ap_uint8_to_OCTET_STRING(mme_ue->guti.mme_code,
&ies->uePagingID.choice.s_TMSI.mMEC);
&UEPagingID->choice.s_TMSI->mMEC);
s1ap_uint32_to_OCTET_STRING(mme_ue->guti.m_tmsi,
&ies->uePagingID.choice.s_TMSI.m_TMSI);
&UEPagingID->choice.s_TMSI->m_TMSI);
d_trace(5, " MME_CODE[%d] M_TMSI[0x%x]\n",
mme_ue->guti.mme_code, mme_ue->guti.m_tmsi);
/* FIXME : fixed to ps */
ies->cnDomain = S1AP_CNDomain_ps;
*CNDomain = S1AP_CNDomain_ps;
item = core_calloc(1, sizeof(S1AP_TAIItemIEs_t));
ASN_SEQUENCE_ADD(&TAIList->list, item);
item->id = S1AP_ProtocolIE_ID_id_TAIItem;
item->criticality = S1AP_Criticality_ignore;
item->value.present = S1AP_TAIItemIEs__value_PR_TAIItem;
tai_item = &item->value.choice.TAIItem;
tai_item = core_calloc(1, sizeof(S1AP_TAIItem_t));
s1ap_buffer_to_OCTET_STRING(&mme_ue->tai.plmn_id, sizeof(plmn_id_t),
&tai_item->tAI.pLMNidentity);
s1ap_uint16_to_OCTET_STRING(mme_ue->tai.tac, &tai_item->tAI.tAC);
ASN_SEQUENCE_ADD(&ies->taiList, tai_item);
rv = s1ap_encode_pdu(s1apbuf, &pdu);
s1ap_free_pdu(&pdu);
message.procedureCode = S1AP_ProcedureCode_id_Paging;
message.direction = S1AP_PDU_PR_initiatingMessage;
encoded = s1ap_encode_pdu(s1apbuf, &message);
s1ap_free_pdu(&message);
d_assert(s1apbuf && encoded >= 0, return CORE_ERROR,);
#endif
if (rv != CORE_OK)
{
d_error("s1ap_encode_pdu() failed");
return CORE_ERROR;
}
return CORE_OK;
}

View File

@ -349,6 +349,9 @@ void s1ap_handle_uplink_nas_transport(
enb_ue_t *enb_ue = NULL;
d_assert(enb, return,);
d_assert(enb->sock, return,);
d_assert(message, return,);
initiatingMessage = message->choice.initiatingMessage;
d_assert(initiatingMessage, return,);
@ -404,6 +407,9 @@ void s1ap_handle_ue_capability_info_indication(
enb_ue_t *enb_ue = NULL;
d_assert(enb, return,);
d_assert(enb->sock, return,);
d_assert(message, return,);
initiatingMessage = message->choice.initiatingMessage;
d_assert(initiatingMessage, return,);
@ -484,6 +490,9 @@ void s1ap_handle_initial_context_setup_response(
mme_ue_t *mme_ue = NULL;
enb_ue_t *enb_ue = NULL;
d_assert(enb, return,);
d_assert(enb->sock, return,);
d_assert(message, return,);
successfulOutcome = message->choice.successfulOutcome;
d_assert(successfulOutcome, return,);
@ -583,6 +592,9 @@ void s1ap_handle_initial_context_setup_failure(
mme_ue_t *mme_ue = NULL;
enb_ue_t *enb_ue = NULL;
d_assert(enb, return,);
d_assert(enb->sock, return,);
d_assert(message, return,);
unsuccessfulOutcome = message->choice.unsuccessfulOutcome;
d_assert(unsuccessfulOutcome, return,);
@ -684,7 +696,6 @@ void s1ap_handle_initial_context_setup_failure(
}
}
#if 0
void s1ap_handle_e_rab_setup_response(
mme_enb_t *enb, s1ap_message_t *message)
{
@ -692,36 +703,68 @@ void s1ap_handle_e_rab_setup_response(
char buf[CORE_ADDRSTRLEN];
int i;
S1AP_SuccessfulOutcome_t *successfulOutcome = NULL;
S1AP_E_RABSetupResponse_t *E_RABSetupResponse = NULL;
S1AP_E_RABSetupResponseIEs_t *ie = NULL;
S1AP_ENB_UE_S1AP_ID_t *ENB_UE_S1AP_ID = NULL;
S1AP_E_RABSetupListBearerSURes_t *E_RABSetupListBearerSURes = NULL;
enb_ue_t *enb_ue = NULL;
S1AP_E_RABSetupResponseIEs_t *ies = NULL;
mme_ue_t *mme_ue = NULL;
d_assert(enb, return, "Null param");
d_assert(message, return, "Null param");
d_assert(enb, return,);
d_assert(enb->sock, return,);
ies = &message->s1ap_E_RABSetupResponseIEs;
d_assert(ies, return, "Null param");
d_assert(message, return,);
successfulOutcome = message->choice.successfulOutcome;
d_assert(successfulOutcome, return,);
E_RABSetupResponse = &successfulOutcome->value.choice.E_RABSetupResponse;
d_assert(E_RABSetupResponse, return,);
d_trace(3, "[MME] E-RAB setup response\n");
for (i = 0; i < E_RABSetupResponse->protocolIEs.list.count; i++)
{
ie = E_RABSetupResponse->protocolIEs.list.array[i];
switch(ie->id)
{
case S1AP_ProtocolIE_ID_id_eNB_UE_S1AP_ID:
ENB_UE_S1AP_ID = &ie->value.choice.ENB_UE_S1AP_ID;
break;
case S1AP_ProtocolIE_ID_id_E_RABSetupListBearerSURes:
E_RABSetupListBearerSURes =
&ie->value.choice.E_RABSetupListBearerSURes;
break;
default:
break;
}
}
d_trace(5, " IP[%s] ENB_ID[%d]\n",
CORE_ADDR(enb->addr, buf), enb->enb_id);
enb_ue = enb_ue_find_by_enb_ue_s1ap_id(enb, ies->eNB_UE_S1AP_ID);
d_assert(enb_ue, return, "No UE Context[%d]", ies->eNB_UE_S1AP_ID);
d_assert(ENB_UE_S1AP_ID, return,);
enb_ue = enb_ue_find_by_enb_ue_s1ap_id(enb, *ENB_UE_S1AP_ID);
d_assert(enb_ue, return, "No UE Context[%d]", *ENB_UE_S1AP_ID);
mme_ue = enb_ue->mme_ue;
d_assert(mme_ue, return,);
d_trace(5, " ENB_UE_S1AP_ID[%d] MME_UE_S1AP_ID[%d]\n",
enb_ue->enb_ue_s1ap_id, enb_ue->mme_ue_s1ap_id);
for (i = 0; i < ies->e_RABSetupListBearerSURes.
s1ap_E_RABSetupItemBearerSURes.count; i++)
for (i = 0; i < E_RABSetupListBearerSURes->list.count; i++)
{
mme_bearer_t *bearer = NULL;
S1AP_E_RABSetupItemBearerSUResIEs_t *item = NULL;
S1AP_E_RABSetupItemBearerSURes_t *e_rab = NULL;
e_rab = (S1AP_E_RABSetupItemBearerSURes_t *)ies->
e_RABSetupListBearerSURes.s1ap_E_RABSetupItemBearerSURes.array[i];
mme_bearer_t *bearer = NULL;
item = (S1AP_E_RABSetupItemBearerSUResIEs_t *)
E_RABSetupListBearerSURes->list.array[i];
d_assert(item, return,);
e_rab = &item->value.choice.E_RABSetupItemBearerSURes;
d_assert(e_rab, return, "Null param");
bearer = mme_bearer_find_by_ue_ebi(mme_ue, e_rab->e_RAB_ID);
@ -763,44 +806,76 @@ void s1ap_handle_ue_context_release_request(
{
status_t rv;
char buf[CORE_ADDRSTRLEN];
int i;
S1AP_InitiatingMessage_t *initiatingMessage = NULL;
S1AP_UEContextReleaseRequest_t *UEContextReleaseRequest = NULL;
S1AP_UEContextReleaseRequest_IEs_t *ie = NULL;
S1AP_MME_UE_S1AP_ID_t *MME_UE_S1AP_ID = NULL;
S1AP_Cause_t *Cause = NULL;
enb_ue_t *enb_ue = NULL;
mme_ue_t *mme_ue = NULL;
S1AP_UEContextReleaseRequest_IEs_t *ies = NULL;
d_assert(enb, return,);
d_assert(message, return,);
d_assert(enb->sock, return,);
ies = &message->s1ap_UEContextReleaseRequest_IEs;
d_assert(ies, return,);
d_assert(message, return,);
initiatingMessage = message->choice.initiatingMessage;
d_assert(initiatingMessage, return,);
UEContextReleaseRequest =
&initiatingMessage->value.choice.UEContextReleaseRequest;
d_assert(UEContextReleaseRequest, return,);
d_trace(3, "[MME] UE Context release request\n");
for (i = 0; i < UEContextReleaseRequest->protocolIEs.list.count; i++)
{
ie = UEContextReleaseRequest->protocolIEs.list.array[i];
switch(ie->id)
{
case S1AP_ProtocolIE_ID_id_MME_UE_S1AP_ID:
MME_UE_S1AP_ID = &ie->value.choice.MME_UE_S1AP_ID;
break;
case S1AP_ProtocolIE_ID_id_Cause:
Cause = &ie->value.choice.Cause;
break;
default:
break;
}
}
d_trace(5, " IP[%s] ENB_ID[%d]\n",
CORE_ADDR(enb->addr, buf), enb->enb_id);
enb_ue = enb_ue_find_by_mme_ue_s1ap_id(ies->mme_ue_s1ap_id);
d_assert(MME_UE_S1AP_ID, return,);
enb_ue = enb_ue_find_by_mme_ue_s1ap_id(*MME_UE_S1AP_ID);
if (!enb_ue)
{
d_warn("No ENB UE Context : MME_UE_S1AP_ID[%d]", ies->mme_ue_s1ap_id);
d_warn("No ENB UE Context : MME_UE_S1AP_ID[%d]", *MME_UE_S1AP_ID);
#if 0
rv = s1ap_send_error_indication(enb,
S1AP_ERRORINDICATIONIES_MME_UE_S1AP_ID_PRESENT |
S1AP_ERRORINDICATIONIES_ENB_UE_S1AP_ID_PRESENT |
S1AP_ERRORINDICATIONIES_CAUSE_PRESENT,
ies->eNB_UE_S1AP_ID,
ies->mme_ue_s1ap_id,
enb_ue->enb_ue_s1ap_id,
enb_ue->mme_ue_s1ap_id,
S1AP_Cause_PR_radioNetwork,
S1AP_CauseRadioNetwork_unknown_mme_ue_s1ap_id);
d_assert(rv == CORE_OK, return, "s1ap send error");
#endif
return;
}
d_trace(5, " ENB_UE_S1AP_ID[%d] MME_UE_S1AP_ID[%d]\n",
enb_ue->enb_ue_s1ap_id, enb_ue->mme_ue_s1ap_id);
d_trace(5, " Cause[Group:%d Cause:%d]\n",
ies->cause.present, ies->cause.choice.radioNetwork);
switch(ies->cause.present)
d_assert(Cause, return,);
d_trace(5, " Cause[Group:%d Cause:%d]\n",
Cause->present, Cause->choice.radioNetwork);
switch(Cause->present)
{
case S1AP_Cause_PR_radioNetwork:
case S1AP_Cause_PR_transport:
@ -808,9 +883,9 @@ void s1ap_handle_ue_context_release_request(
case S1AP_Cause_PR_misc:
break;
case S1AP_Cause_PR_nas:
d_warn("NAS-Cause[%d]", ies->cause.choice.nas);
d_warn("NAS-Cause[%d]", Cause->choice.nas);
default:
d_warn("Invalid cause group[%d]", ies->cause.present);
d_warn("Invalid cause group[%d]", Cause->present);
break;
}
@ -848,20 +923,48 @@ void s1ap_handle_ue_context_release_complete(
{
status_t rv;
char buf[CORE_ADDRSTRLEN];
int i;
S1AP_SuccessfulOutcome_t *successfulOutcome = NULL;
S1AP_UEContextReleaseComplete_t *UEContextReleaseComplete = NULL;
S1AP_UEContextReleaseComplete_IEs_t *ie = NULL;
S1AP_MME_UE_S1AP_ID_t *MME_UE_S1AP_ID = NULL;
enb_ue_t *enb_ue = NULL;
mme_ue_t *mme_ue = NULL;
S1AP_UEContextReleaseComplete_IEs_t *ies = NULL;
enb_ue_t *enb_ue = NULL;
ies = &message->s1ap_UEContextReleaseComplete_IEs;
d_assert(ies, return, "Null param");
d_assert(enb, return,);
d_assert(enb->sock, return,);
d_assert(message, return,);
successfulOutcome = message->choice.successfulOutcome;
d_assert(successfulOutcome, return,);
UEContextReleaseComplete =
&successfulOutcome->value.choice.UEContextReleaseComplete;
d_assert(UEContextReleaseComplete, return,);
d_trace(3, "[MME] UE Context release complete\n");
for (i = 0; i < UEContextReleaseComplete->protocolIEs.list.count; i++)
{
ie = UEContextReleaseComplete->protocolIEs.list.array[i];
switch(ie->id)
{
case S1AP_ProtocolIE_ID_id_MME_UE_S1AP_ID:
MME_UE_S1AP_ID = &ie->value.choice.MME_UE_S1AP_ID;
break;
default:
break;
}
}
d_trace(5, " IP[%s] ENB_ID[%d]\n",
CORE_ADDR(enb->addr, buf), enb->enb_id);
enb_ue = enb_ue_find_by_mme_ue_s1ap_id(ies->mme_ue_s1ap_id);
d_assert(enb_ue, return, "No UE Context[%d]", ies->mme_ue_s1ap_id);
d_assert(MME_UE_S1AP_ID, return,);
enb_ue = enb_ue_find_by_mme_ue_s1ap_id(*MME_UE_S1AP_ID);
d_assert(enb_ue, return, "No UE Context[%d]", *MME_UE_S1AP_ID);
mme_ue = enb_ue->mme_ue;
d_trace(5, " ENB_UE_S1AP_ID[%d] MME_UE_S1AP_ID[%d]\n",
@ -934,11 +1037,9 @@ void s1ap_handle_ue_context_release_complete(
}
}
}
#endif
void s1ap_handle_paging(mme_ue_t *mme_ue)
{
#if 0
pkbuf_t *s1apbuf = NULL;
hash_index_t *hi = NULL;
mme_enb_t *enb = NULL;
@ -973,7 +1074,6 @@ void s1ap_handle_paging(mme_ue_t *mme_ue)
}
}
}
#endif
}
#if 0

View File

@ -85,13 +85,13 @@ void s1ap_state_operational(fsm_t *s, event_t *e)
enb, pdu);
break;
}
#if 0
case S1AP_ProcedureCode_id_UEContextReleaseRequest:
{
s1ap_handle_ue_context_release_request(
enb, pdu);
break;
}
#if 0
case S1AP_ProcedureCode_id_PathSwitchRequest:
{
s1ap_handle_path_switch_request(enb, pdu);
@ -143,7 +143,6 @@ void s1ap_state_operational(fsm_t *s, event_t *e)
enb, pdu);
break;
}
#if 0
case S1AP_ProcedureCode_id_E_RABSetup :
{
s1ap_handle_e_rab_setup_response(enb, pdu);
@ -163,6 +162,7 @@ void s1ap_state_operational(fsm_t *s, event_t *e)
enb, pdu);
break;
}
#if 0
case S1AP_ProcedureCode_id_HandoverResourceAllocation:
{
s1ap_handle_handover_request_ack(enb, pdu);
@ -187,13 +187,13 @@ void s1ap_state_operational(fsm_t *s, event_t *e)
switch(unsuccessfulOutcome->procedureCode)
{
#if 0
case S1AP_ProcedureCode_id_InitialContextSetup :
{
s1ap_handle_initial_context_setup_failure(
enb, pdu);
break;
}
#if 0
case S1AP_ProcedureCode_id_HandoverResourceAllocation :
{
s1ap_handle_handover_failure(enb, pdu);

View File

@ -11,7 +11,7 @@ testepc_SOURCES = \
common/testpacket.h common/testpacket.c common/testutil.h \
basic/testutil.c basic/s1ap_message_test.c basic/nas_message_test.c \
basic/gtp_message_test.c basic/security_test.c basic/s1setup_test.c \
basic/attach_test.c
basic/attach_test.c basic/volte_test.c
$(NULL)
# basic/attach_test.c basic/volte_test.c basic/handover_test.c

View File

@ -296,19 +296,15 @@ static void attach_test1(abts_case *tc, void *data)
* Send Initial-UE Message + Attach Request + PDN Connectivity */
core_sleep(time_from_msec(300));
#if 1
goto out;
#endif
rv = tests1ap_build_initial_ue_msg(&sendbuf, msgindex+1);
/* Update M-TMSI */
m_tmsi = htonl(m_tmsi);
memcpy(sendbuf->payload + 37, &m_tmsi, 4);
memcpy(sendbuf->payload + 36, &m_tmsi, 4);
/* Update NAS MAC */
void snow_3g_f9(c_uint8_t* key, c_uint32_t count, c_uint32_t fresh,
c_uint32_t dir, c_uint8_t *data, c_uint64_t length, c_uint8_t *out);
snow_3g_f9(mme_ue->knas_int, 7, 0, 0,
sendbuf->payload + 25, (109 << 3), sendbuf->payload+21);
sendbuf->payload + 24, (109 << 3), sendbuf->payload+20);
ABTS_INT_EQUAL(tc, CORE_OK, rv);
rv = tests1ap_enb_send(sock, sendbuf);
ABTS_INT_EQUAL(tc, CORE_OK, rv);
@ -483,7 +479,6 @@ out:
ABTS_INT_EQUAL(tc, CORE_OK, rv);
}
#if 0
/**************************************************************
* eNB : HOME
* UE : IMSI
@ -800,7 +795,6 @@ static void attach_test2(abts_case *tc, void *data)
ABTS_INT_EQUAL(tc, CORE_OK, rv);
pkbuf_free(recvbuf);
d_log_set_level(D_MSG_TO_STDOUT, D_LOG_LEVEL_FATAL);
/* Send Authentication Authentication Failure */
rv = tests1ap_build_authentication_failure(&sendbuf, msgindex+1);
ABTS_INT_EQUAL(tc, CORE_OK, rv);
@ -818,7 +812,6 @@ static void attach_test2(abts_case *tc, void *data)
rv = tests1ap_enb_read(sock, recvbuf);
ABTS_INT_EQUAL(tc, CORE_OK, rv);
pkbuf_free(recvbuf);
d_log_set_level(D_MSG_TO_STDOUT, D_LOG_LEVEL_ERROR);
/* Send UE Context Release Complete */
rv = tests1ap_build_ue_context_release_complete(&sendbuf, msgindex+2);
@ -1653,19 +1646,16 @@ out:
rv = tests1ap_enb_close(sock);
ABTS_INT_EQUAL(tc, CORE_OK, rv);
}
#endif
abts_suite *test_attach(abts_suite *suite)
{
suite = ADD_SUITE(suite)
abts_run_test(suite, attach_test1, NULL);
#if 0
abts_run_test(suite, attach_test2, NULL);
abts_run_test(suite, attach_test3, NULL);
abts_run_test(suite, attach_test4, NULL);
abts_run_test(suite, attach_test5, NULL);
#endif
return suite;
}

View File

@ -32,8 +32,8 @@ const struct testlist alltests[] = {
{test_security},
{test_s1setup},
{test_attach},
#if 0
{test_volte},
#if 0
{test_handover},
#endif
{NULL},

View File

@ -102,7 +102,7 @@ static void volte_test1(abts_case *tc, void *data)
/* Send S1-Setup Reqeust */
rv = tests1ap_build_setup_req(
&sendbuf, S1ap_ENB_ID_PR_macroENB_ID, 0x54f64);
&sendbuf, S1AP_ENB_ID_PR_macroENB_ID, 0x54f64);
ABTS_INT_EQUAL(tc, CORE_OK, rv);
rv = tests1ap_enb_send(sock, sendbuf);
ABTS_INT_EQUAL(tc, CORE_OK, rv);
@ -285,6 +285,8 @@ static void volte_test1(abts_case *tc, void *data)
rv = tests1ap_enb_send(sock, sendbuf);
ABTS_INT_EQUAL(tc, CORE_OK, rv);
core_sleep(time_from_msec(1000));
/* Deactivate EPS bearer context accept */
rv = tests1ap_build_deactivate_bearer_accept(&sendbuf, msgindex);
ABTS_INT_EQUAL(tc, CORE_OK, rv);
@ -412,7 +414,7 @@ static void volte_test2(abts_case *tc, void *data)
/* Send S1-Setup Reqeust */
rv = tests1ap_build_setup_req(
&sendbuf, S1ap_ENB_ID_PR_macroENB_ID, 0x54f64);
&sendbuf, S1AP_ENB_ID_PR_macroENB_ID, 0x54f64);
ABTS_INT_EQUAL(tc, CORE_OK, rv);
rv = tests1ap_enb_send(sock, sendbuf);
ABTS_INT_EQUAL(tc, CORE_OK, rv);

View File

@ -216,15 +216,14 @@ status_t tests1ap_build_initial_ue_msg(pkbuf_t **pkbuf, int i)
"3254869104e060c0 4000050221d031d1 5c0a003103e5e034 9011035758a65d01"
"00004300060000f1 1030390064400800 00f1101079baf000 86400130",
"000c40809c00"
"0005000800030002 00001a0073721711 a73a12070741020b f600f11000020100"
"00000105e060c040 0100210221d011d1 271a808021100100 0010810600000000"
"830600000000000d 00000a005255f501 10225c0a003103e5 c03e1355f501aaaa"
"11035758a6200b60 1404ef65233b8878 d290400804026004 00021f025d0107e0"
"004300060000f110 3039006440080055 f5010019d0100086 400130",
"000c40809b000005 000800020002001a 00737217400466af 070741020bf600f1"
"10000201fd001710 05e060c040010021 0221d011d1271a80 8021100100001081"
"0600000000830600 000000000d00000a 005255f50110225c 0a003103e5c03e13"
"55f501aaaa110357 58a6200b601404ef 65233b8878d29040 080402600400021f"
"025d0107e0004300 060000f110303900 6440080055f50100 19d0100086400130",
"000c40809c00"
"0005000800030003 00001a007372178c 3e3cff070741020b f600f11000020100"
"000c40809b00"
"0005000800020003 001a007372178c 3e3cff070741020b f600f11000020100"
"00000905e060c040 0100210204d011d1 271a808021100100 0010810600000000"
"830600000000000d 00000a005255f501 10225c0a003103e5 c03e1355f501aaaa"
"11035758a6200b60 1404ef65233b8878 d290400804026004 00021f025d0107e0"
@ -236,11 +235,11 @@ status_t tests1ap_build_initial_ue_msg(pkbuf_t **pkbuf, int i)
"00000a005c0a0090 11034f18a6f15d01 00004300060000f1 1030390064400800"
"00f110002343d000 86400130",
"000c405300000500 080003001100001a 002a2917acba67c4 8207410108091010"
"000c405200000500 0800020011001a 002a2917acba67c4 8207410108091010"
"103254866205f0f0 000000000e023cd0 11d1270780000a00 000d00c100430006"
"0000f11030390064 40080000f1109d67 aa500086400130",
"000c405300000500 080003002100001a 002a2917bcba67c4 8207410108091010"
"000c405200000500 0800020021001a 002a2917bcba67c4 8207410108091010"
"000000003005f0f0 000000000e023cd0 11d1270780000a00 000d00c100430006"
"0000f11030390064 40080000f1109d67 aa500086400130",
@ -284,12 +283,12 @@ status_t tests1ap_build_initial_ue_msg(pkbuf_t **pkbuf, int i)
};
c_uint16_t len[TESTS1AP_MAX_MESSAGE] = {
92,
161,
161,
160,
160,
108,
87,
87,
86,
86,
80,
0,
@ -322,7 +321,7 @@ status_t tests1ap_build_identity_response(pkbuf_t **pkbuf, int i)
"",
"",
"000d"
"403f000005000000 05c00100009f0008 0003000300001a00 121117d7e3248b57"
"403e000005000000 05c00100009f0008 00020003001a00 121117d7e3248b57"
"0756080910101032 5486510064400800 00f11054f6401000 4340060000f1105b"
"a0",
@ -343,7 +342,7 @@ status_t tests1ap_build_identity_response(pkbuf_t **pkbuf, int i)
c_uint16_t len[TESTS1AP_MAX_MESSAGE] = {
0,
0,
67,
66,
0,
0,
@ -453,7 +452,7 @@ status_t tests1ap_build_authentication_failure(pkbuf_t **pkbuf, int i)
"403d000005000000 0200030008000200 21001a001413075c 15300e61640edcfb"
"605d25911423ee1f 9e006440080000f1 100019b010004340 060000f1100001",
"000d"
"402e000005000000 0200030008000300 2100001a00040307 5c14006440080000"
"402d000005000000 0200030008000200 21001a00040307 5c14006440080000"
"f1101a2d10100043 40060000f1100001",
"",
@ -474,7 +473,7 @@ status_t tests1ap_build_authentication_failure(pkbuf_t **pkbuf, int i)
0,
65,
50,
49,
0,
0,
@ -956,10 +955,10 @@ status_t tests1ap_build_emm_status(pkbuf_t **pkbuf, int i)
status_t tests1ap_build_detach_request(pkbuf_t **pkbuf, int i)
{
char *payload[TESTS1AP_MAX_MESSAGE] = {
"000c404900000600 080003000200001a 001615172ba435db 040745090bf600f1"
"000c404800000600 0800020002001a 001615172ba435db 040745090bf600f1"
"10000201020003e6 004300060000f110 2b67006440080000 f1109d67aa500086"
"4001300060000600 40020003e6",
"000c404900000600 080003000100001a 00161517ba258500 040745090bf600f1"
"000c404800000600 0800020002001a 00161517ba258500 040745090bf600f1"
"10000201020003e6 004300060000f110 2b67006440080000 f1109d67aa500086"
"4001300060000600 40020003e6",
"",
@ -974,8 +973,8 @@ status_t tests1ap_build_detach_request(pkbuf_t **pkbuf, int i)
};
c_uint16_t len[TESTS1AP_MAX_MESSAGE] = {
77,
77,
76,
76,
0,
0,
@ -1105,22 +1104,28 @@ status_t tests1ap_build_ue_context_release_complete(pkbuf_t **pkbuf, int i)
return CORE_OK;
}
#if 0
status_t tests1ap_build_service_request(pkbuf_t **pkbuf,
c_uint32_t enb_ue_s1ap_id, c_uint8_t seq,
c_uint16_t mac, c_uint32_t m_tmsi)
{
char *payload[TESTS1AP_MAX_MESSAGE] = {
"000c"
"4037000006000800 020004001a0005 04c7049551004300 060000f110303900"
"6440080000f11007 87b8000086400140 0060000600400000 0001",
"000c"
"4038000006000800 03400700001a0005 04c7049551004300 060000f110303900"
"6440080000f11007 87b8000086400140 0060000600400000 0001",
};
c_uint16_t len[TESTS1AP_MAX_MESSAGE] = {
59,
60,
};
char hexbuf[MAX_SDU_LEN];
int i = 0;
if (enb_ue_s1ap_id & 0x400000) i = 1;
*pkbuf = pkbuf_alloc(0, MAX_SDU_LEN);
if (!(*pkbuf)) return CORE_ERROR;
@ -1130,16 +1135,15 @@ status_t tests1ap_build_service_request(pkbuf_t **pkbuf,
(*pkbuf)->len);
enb_ue_s1ap_id = htonl(enb_ue_s1ap_id << 8);
memcpy((*pkbuf)->payload + 11, &enb_ue_s1ap_id, 3);
memcpy((*pkbuf)->payload + 11, &enb_ue_s1ap_id, 2+i);
mac = htons(mac);
memcpy((*pkbuf)->payload + 20, &seq, 1);
memcpy((*pkbuf)->payload + 21, &mac, 2);
memcpy((*pkbuf)->payload + 19+i, &seq, 1);
memcpy((*pkbuf)->payload + 20+i, &mac, 2);
m_tmsi = htonl(m_tmsi);
memcpy((*pkbuf)->payload + 56, &m_tmsi, 4);
memcpy((*pkbuf)->payload + 55+i, &m_tmsi, 4);
return CORE_OK;
}
#endif
status_t tests1ap_build_tau_request(pkbuf_t **pkbuf, int i,
c_uint32_t mme_ue_s1ap_id, c_uint32_t enb_ue_s1ap_id, c_uint8_t active_flag,
@ -1218,13 +1222,13 @@ status_t tests1ap_build_pdn_connectivity_request(
pkbuf_t **pkbuf, int i)
{
char *payload[TESTS1AP_MAX_MESSAGE] = {
"000d40680000"
"0500000005c00000 0001000800030001 00001a003b3a277c 81dab50a0205d011"
"000d40640000"
"0500000002 0001000800020001 001a003b3a277c 81dab50a0205d011"
"281208696e746572 6e6574036e673204 6d6e6574271a8080 2110010000108106"
"0000000083060000 0000000d00000a00 006440080055f501 0019d01000434006"
"0055f5011022",
"000d40680000"
"0500000005c00000 0001000800030001 00001a003b3a2710 3fdafa0a0209d011"
"000d40640000"
"0500000002 0001000800020001 001a003b3a2710 3fdafa0a0209d011"
"281208706e746572 6e6574036e673204 6d6e6574271a8080 2110010000108106"
"0000000083060000 0000000d00000a00 006440080055f501 0019d01000434006"
"0055f5011022",
@ -1268,11 +1272,11 @@ status_t tests1ap_build_pdn_disconnectivity_request(
pkbuf_t **pkbuf, int i)
{
char *payload[TESTS1AP_MAX_MESSAGE] = {
"000d40380000"
"0500000005c08000 0108000800030001 00001a000b0a2732 423c53040206d206"
"000d40370000"
"0500000005c08000 0108000800020001 001a000b0a2732 423c53040206d206"
"006440080055f501 0019d01000434006 0055f5011022",
"000d40380000"
"0500000005c08000 0108000800030001 00001a000b0a2777 693066040206d206"
"000d40370000"
"0500000005c08000 0108000800020001 001a000b0a2777 693066040206d206"
"006440080055f501 0019d01000434006 0055f5011022",
"",
@ -1286,8 +1290,8 @@ status_t tests1ap_build_pdn_disconnectivity_request(
};
c_uint16_t len[TESTS1AP_MAX_MESSAGE] = {
60,
60,
59,
59,
0,
0,
@ -1310,35 +1314,82 @@ status_t tests1ap_build_pdn_disconnectivity_request(
return CORE_OK;
}
#if 0
status_t tests1ap_build_e_rab_setup_response(
pkbuf_t **pkbuf,
c_uint32_t mme_ue_s1ap_id, c_uint32_t enb_ue_s1ap_id,
c_uint8_t ebi, c_uint32_t teid)
{
int erval = -1;
status_t rv;
S1AP_S1AP_PDU_t pdu;
S1AP_SuccessfulOutcome_t *successfulOutcome = NULL;
S1AP_E_RABSetupResponse_t *E_RABSetupResponse = NULL;
S1AP_E_RABSetupResponseIEs_t *ie = NULL;
S1AP_MME_UE_S1AP_ID_t *MME_UE_S1AP_ID = NULL;
S1AP_ENB_UE_S1AP_ID_t *ENB_UE_S1AP_ID = NULL;
S1AP_E_RABSetupListBearerSURes_t *E_RABSetupListBearerSURes = NULL;
S1AP_E_RABSetupItemBearerSUResIEs_t *item = NULL;
S1AP_E_RABSetupItemBearerSURes_t *e_rab = NULL;
gtp_f_teid_t f_teid;
ip_t ip;
int len;
s1ap_message_t message;
S1AP_E_RABSetupResponseIEs_t *ies = NULL;
S1AP_E_RABSetupItemBearerSURes_t *e_rab = NULL;
memset(&pdu, 0, sizeof (S1AP_S1AP_PDU_t));
pdu.present = S1AP_S1AP_PDU_PR_successfulOutcome;
pdu.choice.successfulOutcome =
core_calloc(1, sizeof(S1AP_SuccessfulOutcome_t));
memset(&message, 0, sizeof(s1ap_message_t));
successfulOutcome = pdu.choice.successfulOutcome;
successfulOutcome->procedureCode = S1AP_ProcedureCode_id_E_RABSetup;
successfulOutcome->criticality = S1AP_Criticality_reject;
successfulOutcome->value.present =
S1AP_SuccessfulOutcome__value_PR_E_RABSetupResponse;
ies = &message.s1ap_E_RABSetupResponseIEs;
E_RABSetupResponse = &successfulOutcome->value.choice.E_RABSetupResponse;
message.direction = S1AP_PDU_PR_successfulOutcome;
message.procedureCode = S1AP_ProcedureCode_id_E_RABSetup;
ie = core_calloc(1, sizeof(S1AP_E_RABSetupResponseIEs_t));
ASN_SEQUENCE_ADD(&E_RABSetupResponse->protocolIEs, ie);
ies->mme_ue_s1ap_id = mme_ue_s1ap_id;
ies->eNB_UE_S1AP_ID = enb_ue_s1ap_id;
ie->id = S1AP_ProtocolIE_ID_id_MME_UE_S1AP_ID;
ie->criticality = S1AP_Criticality_ignore;
ie->value.present = S1AP_E_RABSetupResponseIEs__value_PR_MME_UE_S1AP_ID;
e_rab = (S1AP_E_RABSetupItemBearerSURes_t *)
core_calloc(1, sizeof(S1AP_E_RABSetupItemBearerSURes_t));
MME_UE_S1AP_ID = &ie->value.choice.MME_UE_S1AP_ID;
ie = core_calloc(1, sizeof(S1AP_E_RABSetupResponseIEs_t));
ASN_SEQUENCE_ADD(&E_RABSetupResponse->protocolIEs, ie);
ie->id = S1AP_ProtocolIE_ID_id_eNB_UE_S1AP_ID;
ie->criticality = S1AP_Criticality_ignore;
ie->value.present = S1AP_E_RABSetupResponseIEs__value_PR_ENB_UE_S1AP_ID;
ENB_UE_S1AP_ID = &ie->value.choice.ENB_UE_S1AP_ID;
ie = core_calloc(1, sizeof(S1AP_E_RABSetupResponseIEs_t));
ASN_SEQUENCE_ADD(&E_RABSetupResponse->protocolIEs, ie);
ie->id = S1AP_ProtocolIE_ID_id_E_RABSetupListBearerSURes;
ie->criticality = S1AP_Criticality_ignore;
ie->value.present =
S1AP_E_RABSetupResponseIEs__value_PR_E_RABSetupListBearerSURes;
E_RABSetupListBearerSURes = &ie->value.choice.E_RABSetupListBearerSURes;
*MME_UE_S1AP_ID = mme_ue_s1ap_id;
*ENB_UE_S1AP_ID = enb_ue_s1ap_id;
item = core_calloc(1, sizeof(S1AP_E_RABSetupItemBearerSUResIEs_t));
ASN_SEQUENCE_ADD(&E_RABSetupListBearerSURes->list, item);
item->id = S1AP_ProtocolIE_ID_id_E_RABSetupItemBearerSURes;
item->criticality = S1AP_Criticality_ignore;
item->value.present =
S1AP_E_RABSetupItemBearerSUResIEs__value_PR_E_RABSetupItemBearerSURes;
e_rab = &item->value.choice.E_RABSetupItemBearerSURes;
e_rab->e_RAB_ID = ebi;
rv = gtp_sockaddr_to_f_teid(test_enb1_addr, test_enb1_addr6, &f_teid, &len);
@ -1350,22 +1401,17 @@ status_t tests1ap_build_e_rab_setup_response(
d_assert(rv == CORE_OK, return CORE_ERROR,);
s1ap_uint32_to_OCTET_STRING(teid, &e_rab->gTP_TEID);
ies->presenceMask |=
S1AP_E_RABSETUPRESPONSEIES_E_RABSETUPLISTBEARERSURES_PRESENT;
ASN_SEQUENCE_ADD(&ies->e_RABSetupListBearerSURes, e_rab);
rv = s1ap_encode_pdu(pkbuf, &pdu);
s1ap_free_pdu(&pdu);
erval = s1ap_encode_pdu(pkbuf, &message);
s1ap_free_pdu(&message);
if (erval < 0)
if (rv != CORE_OK)
{
d_error("s1ap_encode_error : (%d)", erval);
d_error("s1ap_encode_pdu() failed");
return CORE_ERROR;
}
return CORE_OK;
}
#endif
status_t tests1ap_build_e_rab_modify_response(pkbuf_t **pkbuf, int i)
{
@ -1412,10 +1458,10 @@ status_t tests1ap_build_e_rab_modify_response(pkbuf_t **pkbuf, int i)
status_t tests1ap_build_e_rab_release_response(pkbuf_t **pkbuf, int i)
{
char *payload[TESTS1AP_MAX_MESSAGE] = {
"2007001d0000"
"0300004005c00000 0001000840030001 000045400600000f 40010c",
"2007001d0000"
"0300004005c00000 0001000840030001 000045400600000f 40010e",
"200700190000"
"0300004002 0001000840020001 0045400600000f 40010c",
"200700190000"
"0300004002 0001000840020001 0045400600000f 40010e",
"",
"",
@ -1428,8 +1474,8 @@ status_t tests1ap_build_e_rab_release_response(pkbuf_t **pkbuf, int i)
};
c_uint16_t len[TESTS1AP_MAX_MESSAGE] = {
33,
33,
29,
29,
0,
0,
@ -1456,8 +1502,8 @@ status_t tests1ap_build_activate_default_bearer_accept(
pkbuf_t **pkbuf, int i)
{
char *payload[TESTS1AP_MAX_MESSAGE] = {
"000d40370000"
"0500000005c08000 0107000800030001 00001a000a0927e7 f5bb400b6200c200"
"000d40360000"
"0500000005c08000 0107000800020001 001a000a0927e7 f5bb400b6200c200"
"6440080055f50100 19d0100043400600 55f5011022",
"",
"",
@ -1472,7 +1518,7 @@ status_t tests1ap_build_activate_default_bearer_accept(
};
c_uint16_t len[TESTS1AP_MAX_MESSAGE] = {
59,
58,
0,
0,
@ -1500,11 +1546,11 @@ status_t tests1ap_build_activate_dedicated_bearer_accept(
pkbuf_t **pkbuf, int i)
{
char *payload[TESTS1AP_MAX_MESSAGE] = {
"000d403700000500"
"000005c000000001 0008000300010000 1a000a0927078a5f 34037200c6006440"
"000d403600000500"
"000005c000000001 00080002000100 1a000a0927078a5f 34037200c6006440"
"080000f1109d67aa 50004340060000f1 102b67",
"000d403700000500"
"000005c000000001 0008000300010000 1a000a0927c035da 96036200c6006440"
"000d403600000500"
"000005c000000001 00080002000100 1a000a0927c035da 96036200c6006440"
"080000f1109d67aa 50004340060000f1 102b67",
"",
@ -1516,8 +1562,8 @@ status_t tests1ap_build_activate_dedicated_bearer_accept(
"",
"",
"000d403700000500"
"000005c00200003c 0008000300010000 1a000a0927a27f49 d6036200c6006440"
"000d403600000500"
"000005c00200003c 00080002000100 1a000a0927a27f49 d6036200c6006440"
"080000f1109d67aa 50004340060000f1 102b67",
"000d"
@ -1525,8 +1571,8 @@ status_t tests1ap_build_activate_dedicated_bearer_accept(
"00c6006440080000 f110001f20a00043 40060000f1103039",
};
c_uint16_t len[TESTS1AP_MAX_MESSAGE] = {
59,
59,
58,
58,
0,
0,
@ -1537,7 +1583,7 @@ status_t tests1ap_build_activate_dedicated_bearer_accept(
0,
0,
59,
58,
58,
};
char hexbuf[MAX_SDU_LEN];
@ -1607,14 +1653,14 @@ status_t tests1ap_build_deactivate_bearer_accept(
pkbuf_t **pkbuf, int i)
{
char *payload[TESTS1AP_MAX_MESSAGE] = {
"000d40370000"
"0500000005c00000 0001000800030001 00001a000a09274c b2ebbd056200ce00"
"000d40330000"
"0500000002 0001000800020001 001a000a09274c b2ebbd056200ce00"
"6440080055f50100 19d0100043400600 55f5011022",
"000d40370000"
"0500000005c00000 0001000800030001 00001a000a0927a9 a1b2bd057200ce00"
"000d40330000"
"0500000002 0001000800020001 001a000a0927a9 a1b2bd057200ce00"
"6440080055f50100 19d0100043400600 55f5011022",
"000d40370000"
"0500000005c00000 0001000800030001 00001a000a09277d 7f1f80056200ce00"
"000d40330000"
"0500000002 0001000800020001 001a000a09277d 7f1f80056200ce00"
"6440080055f50100 19d0100043400600 55f5011022",
"",