fix the NAS encoding bug

This commit is contained in:
Sukchan Lee 2017-02-16 22:25:12 +09:00
parent d55ea75638
commit 2a6d570d69
4 changed files with 21 additions and 1 deletions

View File

@ -4,6 +4,18 @@
#include "core_lib.h"
#include "nas_ies.h"
c_int32_t nas_encode_iei(pkbuf_t *pkbuf, c_uint8_t iei)
{
c_uint16_t size = 0;
size = sizeof(c_uint8_t);
d_assert(pkbuf_header(pkbuf, -size) == CORE_OK,
return -1, "pkbuf_header error");
memcpy(pkbuf->payload - size, &iei, size);
return size;
}
/* 9.9.2.0A Device properties
* See subclause 10.5.7.8 in 3GPP TS 24.008 [13].
* O TV 1 */

View File

@ -7,6 +7,8 @@
extern "C" {
#endif /* __cplusplus */
CORE_DECLARE(c_int32_t) nas_encode_iei(pkbuf_t *pkbuf, c_uint8_t iei);
/* 9.9.2.0A Device properties
* See subclause 10.5.7.8 in 3GPP TS 24.008 [13].
* O TV 1 */

View File

@ -300,6 +300,10 @@ c_int32_t nas_encode_attach_accept(pkbuf_t *pkbuf, nas_message_t *message)
if (attach_accept->presencemask & NAS_ATTACH_ACCEPT_GUTI_PRESENT)
{
size = nas_encode_iei(pkbuf, NAS_ATTACH_ACCEPT_GUTI_IEI);
d_assert(size >= 0, return encoded, "decode failed");
encoded += size;
size = nas_encode_eps_mobile_identity(pkbuf, &attach_accept->guti);
d_assert(size >= 0, return encoded, "decode failed");
encoded += size;

View File

@ -83,6 +83,7 @@ static void nas_message_test2(abts_case *tc, void *data)
rv = nas_encode_pdu(&pkbuf, &message);
ABTS_INT_EQUAL(tc, CORE_OK, rv);
#if 0
{
int i = 0;
unsigned char *p = pkbuf->payload;
@ -90,7 +91,8 @@ static void nas_message_test2(abts_case *tc, void *data)
printf("0x%x, 0x%x\n", payload[0][i], p[i]);
}
ABTS_TRUE(tc, memcmp(pkbuf->payload, payload, pkbuf->len) == 0);
#endif
ABTS_TRUE(tc, memcmp(pkbuf->payload, payload[0], pkbuf->len) == 0);
pkbuf_free(pkbuf);
}