Last active
October 20, 2021 10:12
-
-
Save cbalint13/04888734c72c7deb8c6535363fa53f4b to your computer and use it in GitHub Desktop.
Testcase for open5gs issue #1201
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
COMPILE: | |
gcc testcase.c -g -O2 \ | |
-DOGS_GTP_INSIDE -DOGS_GTP_COMPILATION \ | |
-I/home/cbalint/rpmbuild/BUILD/open5gs/lib/gtp \ | |
-I/home/cbalint/rpmbuild/BUILD/open5gs/lib/core \ | |
-I/home/cbalint/rpmbuild/BUILD/open5gs/redhat-linux-build/lib \ | |
-I/home/cbalint/rpmbuild/BUILD/open5gs/lib \ | |
-I/home/cbalint/rpmbuild/BUILD/open5gs/lib/app/ \ | |
-I/home/cbalint/rpmbuild/BUILD/open5gs/lib/nas/common/ \ | |
-I/home/cbalint/rpmbuild/BUILD/open5gs/lib/crypt/ \ | |
-o test libogsgtp.so.2 libogscore.so.2 libogsapp.so.2 | |
RUN: | |
LD_LIBRARY_PATH=`pwd` ./test | |
*/ | |
// (gdb) print *recvbuf | |
// $105 = { | |
// lnode = { | |
// prev = 0x0, | |
// next = 0x0 | |
// }, | |
// param = {0, 0}, | |
// cluster = 0x7f97898269d0, | |
// len = 140, | |
// head = 0x7f9788078010 "H_", | |
// tail = 0x7f978807809c "", | |
// data = 0x7f9788078010 "H_", | |
// end = 0x7f978807a010 "", | |
// file_line = 0x5654884d539a "../src/sgwc/gtp-path.c:33", | |
// pool = 0x565488cdb150 | |
// } | |
// (gdb) print recvbuf.data | |
// $106 = 140 | |
// (gdb) x/140b 0x7f9788078010 | |
// 0x7f9788078010:, 0x48, 0x5f, 0x00, 0x88, 0x00, 0x00, 0x00, 0x02 | |
// 0x7f9788078018:, 0x12, 0x00, 0x01, 0x00, 0x49, 0x00, 0x01, 0x00 | |
// 0x7f9788078020:, 0x06, 0x5d, 0x00, 0x77, 0x00, 0x49, 0x00, 0x01 | |
// 0x7f9788078028:, 0x00, 0x00, 0x57, 0x00, 0x09, 0x01, 0x85, 0x66 | |
// 0x7f9788078030:, 0x8e, 0x15, 0x66, 0x52, 0x89, 0x24, 0x65, 0x5e | |
// 0x7f9788078038:, 0x00, 0x04, 0x00, 0x15, 0x65, 0x91, 0x3a, 0x54 | |
// 0x7f9788078040:, 0x00, 0x3f, 0x00, 0x24, 0x20, 0x04, 0x11, 0x10 | |
// 0x7f9788078048:, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 | |
// 0x7f9788078050:, 0x30, 0x11, 0x40, 0xc3, 0x82, 0x50, 0xff, 0xff | |
// 0x7f9788078058:, 0x11, 0x05, 0x08, 0x30, 0x11, 0x50, 0xff, 0xff | |
// 0x7f9788078060:, 0x40, 0xc3, 0x82, 0x22, 0x08, 0x11, 0x10, 0x00 | |
// 0x7f9788078068:, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30 | |
// 0x7f9788078070:, 0x11, 0x40, 0xc3, 0x83, 0x50, 0xff, 0xff, 0x13 | |
// 0x7f9788078078:, 0x09, 0x08, 0x30, 0x11, 0x50, 0xff, 0xff, 0x40 | |
// 0x7f9788078080:, 0xc3, 0x83, 0x50, 0x00, 0x16, 0x00, 0x09, 0x01 | |
// 0x7f9788078088:, 0x00, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x00, 0x00 | |
// 0x7f9788078090:, 0x00, 0x2c, 0x00, 0x00, 0x00, 0x00, 0x2c, 0x00 | |
// 0x7f9788078098:, 0x00, 0x00, 0x00, 0x2c | |
// 0x7f9788078004: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 | |
// 0x7f978807800c: 0x00 0x00 0x00 0x00 0x48 0x5f 0x00 0x88 | |
// 0x7f9788078014: 0x00 0x00 0x00 0x02 0x12 0x00 0x01 0x00 | |
// 0x7f978807801c: 0x49 0x00 0x01 0x00 0x06 0x5d 0x00 0x77 | |
// 0x7f9788078024: 0x00 0x49 0x00 0x01 0x00 0x00 0x57 0x00 | |
// 0x7f978807802c: 0x09 0x01 0x85 0x66 0x8e 0x15 0x66 0x52 | |
// 0x7f9788078034: 0x89 0x24 0x65 0x5e 0x00 0x04 0x00 0x15 | |
// 0x7f978807803c: 0x65 0x91 0x3a 0x54 0x00 0x3f 0x00 0x24 | |
// 0x7f9788078044: 0x20 0x04 0x11 0x10 0x00 0x00 0x00 0x00 | |
// 0x7f978807804c: 0x00 0x00 0x00 0x00 0x30 0x11 0x40 0xc3 | |
// 0x7f9788078054: 0x82 0x50 0xff 0xff 0x11 0x05 0x08 0x30 | |
// 0x7f978807805c: 0x11 0x50 0xff 0xff 0x40 0xc3 0x82 0x22 | |
// 0x7f9788078064: 0x08 0x11 0x10 0x00 0x00 0x00 0x00 0x00 | |
// 0x7f978807806c: 0x00 0x00 0x00 0x30 0x11 0x40 0xc3 0x83 | |
// 0x7f9788078074: 0x50 0xff 0xff 0x13 0x09 0x08 0x30 0x11 | |
// 0x7f978807807c: 0x50 0xff 0xff 0x40 0xc3 0x83 0x50 0x00 | |
// 0x7f9788078084: 0x16 0x00 0x09 0x01 0x00 0x00 0x00 0x00 | |
// 0x7f978807808c: 0x2c 0x00 0x00 0x00 0x00 0x2c 0x00 0x00 | |
// 0x7f9788078094: 0x00 0x00 0x2c 0x00 0x00 0x00 0x00 0x2c | |
#include <signal.h> | |
#include <stddef.h> | |
#include "ogs-gtp.h" | |
//unsigned char data[140] = "H_\000\210\000\000\000\002\022\000\001\000I\000\001\000\006]\000w\000I\000\001\000\000W\000\t\001\205f\216\025fR\211$e^\000\004\000\025e\221:T\000?\000$ \004\021\020\000\000\000\000\000\000\000\000\060\021@ÂP\377\377\021\005\b0\021P\377\377@Â\"\b\021\020\000\000\000\000\000\000\000\000\060\021@ÃP\377\377\023\t\b0\021P\377\377@ÃP\000\026\000\t\001\000\000\000\000,\000\000\000\000,\000\000\000\000,\000\000\000\000,"; | |
unsigned char data[140] = { 0x48, 0x5f, 0x00, 0x88, 0x00, 0x00, 0x00, 0x02, | |
0x12, 0x00, 0x01, 0x00, 0x49, 0x00, 0x01, 0x00, | |
0x06, 0x5d, 0x00, 0x77, 0x00, 0x49, 0x00, 0x01, | |
0x00, 0x00, 0x57, 0x00, 0x09, 0x01, 0x85, 0x66, | |
0x8e, 0x15, 0x66, 0x52, 0x89, 0x24, 0x65, 0x5e, | |
0x00, 0x04, 0x00, 0x15, 0x65, 0x91, 0x3a, 0x54, | |
0x00, 0x3f, 0x00, 0x24, 0x20, 0x04, 0x11, 0x10, | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
0x30, 0x11, 0x40, 0xc3, 0x82, 0x50, 0xff, 0xff, | |
0x11, 0x05, 0x08, 0x30, 0x11, 0x50, 0xff, 0xff, | |
0x40, 0xc3, 0x82, 0x22, 0x08, 0x11, 0x10, 0x00, | |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, | |
0x11, 0x40, 0xc3, 0x83, 0x50, 0xff, 0xff, 0x13, | |
0x09, 0x08, 0x30, 0x11, 0x50, 0xff, 0xff, 0x40, | |
0xc3, 0x83, 0x50, 0x00, 0x16, 0x00, 0x09, 0x01, | |
0x00, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x00, 0x00, | |
0x00, 0x2c, 0x00, 0x00, 0x00, 0x00, 0x2c, 0x00, | |
0x00, 0x00, 0x00, 0x2c }; | |
//OGS_POOL(pool, ogs_tlv_t); | |
int main(void *) | |
{ | |
ogs_tlv_init(); | |
ogs_gtp_message_t gtp_message; | |
ogs_pkbuf_t *recvbuf = NULL; | |
recvbuf = (ogs_pkbuf_t *) malloc(sizeof(ogs_pkbuf_t)); | |
recvbuf->len = sizeof(data); | |
recvbuf->data = (unsigned char *) malloc(sizeof(data)); | |
memcpy(recvbuf->data, data, sizeof(data)); | |
printf("data array base addr %p\n", recvbuf->data); | |
printf("data array[0] at base: 0x%02x\n", recvbuf->data[0]); | |
printf("data array len: %i\n", recvbuf->len); | |
printf("data array entry addr %p\n", recvbuf->data); | |
printf("data array[0] at entry: 0x%02x\n", recvbuf->data[0]); | |
int err = ogs_gtp_parse_msg(>p_message, recvbuf); | |
printf("gtp_message.create_bearer_request.bearer_contexts.s5_s8_u_sgw_f_teid.presence = %i\n", | |
gtp_message.create_bearer_request.bearer_contexts.s5_s8_u_sgw_f_teid.presence); | |
printf("gtp_message.create_bearer_request.bearer_contexts.s5_s8_u_sgw_f_teid.len = %i\n", | |
gtp_message.create_bearer_request.bearer_contexts.s5_s8_u_sgw_f_teid.len); | |
printf("gtp_message.create_bearer_request.bearer_contexts.s5_s8_u_sgw_f_teid.data = %p\n", | |
gtp_message.create_bearer_request.bearer_contexts.s5_s8_u_sgw_f_teid.data); | |
// https://github.com/open5gs/open5gs/blob/f05accc7f3928a40b38bc20b6a16863b7aefcc07/src/sgwc/s5c-handler.c#L406 | |
// (gdb) frame 3 | |
// #3 0x00005654884c91af in sgwc_s5c_handle_create_bearer_request (sess=0x7f977e44e260, s5c_xact=0x7f977dbb7ad8, gtpbuf=0x7f9789ae8fd0, message=0x7f977da1c990) at ../src/sgwc/s5c-handler.c:410 | |
// 410 in ../src/sgwc/s5c-handler.c | |
// (gdb) print message.create_bearer_request.bearer_contexts.s5_s8_u_sgw_f_teid | |
// $54 = { | |
// presence = 0, | |
// data = 0x0, | |
// len = 0 } | |
if (gtp_message.create_bearer_request.bearer_contexts.s5_s8_u_sgw_f_teid.presence == 0) { | |
ogs_error("No GTP TEID\n"); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment