/*
* (C) 2012 by Holger Hans Peter Freyther
* All Rights Reserved
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
*/
#include <osmocom/gsm/gsm0808.h>
#include <osmocom/gsm/gsm0808_utils.h>
#include <osmocom/gsm/protocol/gsm_08_08.h>
#include <osmocom/gsm/protocol/gsm_08_58.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <errno.h>
#define VERIFY(msg, data, len) \
if (msgb_l3len(msg) != len) { \
printf("%s:%d Length don't match: %d vs. %d. %s\n", \
__func__, __LINE__, msgb_l3len(msg), (int) len, \
osmo_hexdump(msg->l3h, msgb_l3len(msg))); \
abort(); \
} else if (memcmp(msg->l3h, data, len) != 0) { \
printf("%s:%d didn't match: got: %s\n", \
__func__, __LINE__, \
osmo_hexdump(msg->l3h, msgb_l3len(msg))); \
abort(); \
}
/* Setup a fake codec list for testing */
static void setup_codec_list(struct gsm0808_speech_codec_list *scl)
{
memset(scl, 0, sizeof(*scl));
scl->codec[0].pi = true;
scl->codec[0].tf = true;
scl->codec[0].type = GSM0808_SCT_FR3;
scl->codec[0].cfg = 0xcdef;
scl->codec[1].fi = true;
scl->codec[1].pt = true;
scl->codec[1].type = GSM0808_SCT_FR2;
scl->codec[2].fi = true;
scl->codec[2].tf = true;
scl->codec[2].type = GSM0808_SCT_CSD;
scl->codec[2].cfg = 0xc0;
scl->len = 3;
}
static void test_create_layer3(void)
{
static const uint8_t res[] = {
0x00, 0x0e, 0x57, 0x05, 0x08, 0x00, 0x77, 0x62,
0x83, 0x33, 0x66, 0x44, 0x88, 0x17, 0x01, 0x23 };
struct msgb *msg, *in_msg;
struct osmo_cell_global_id cgi = {
.lai = {
.plmn = {
.mcc = 0x2244,
.mnc = 0x1122,
},
.lac = 0x3366,
},
.cell_identity = 0x4488,
};
printf("Testing creating Layer3\n");
in_msg = msgb_alloc_headroom(512, 128, "foo");
in_msg->l3h = i
|