fix the bug for ping.

gtpv2c_header_t and gtp_header_t(v1) is merged to gtp_header_t.
In this case, sizeof(gtp_header_t) is 12 because the structure has an
attribute of gtpv2c header something like sequence number.

As such, we should not use sizeof(gtp_header_t) directly.
Use GTPV1U_HEADER_LEN and GTPV2C_HEADER_LEN.
This commit is contained in:
Sukchan Lee 2017-09-07 14:10:52 +09:00
parent 229d04c284
commit fb7ae93b07
4 changed files with 11 additions and 9 deletions

View File

@ -26,7 +26,7 @@
/*******************************************************************************
* This file had been created by gtp_tlv.py script v0.1.0
* Please do not modify this file but regenerate it via script.
* Created on: 2017-08-31 12:05:13.855408 by acetcom
* Created on: 2017-09-07 14:05:57.092990 by acetcom
* from 29274-d80.docx
******************************************************************************/
@ -2424,7 +2424,7 @@ status_t gtp_parse_msg(gtp_message_t *gtp_message, pkbuf_t *pkbuf)
if (h->teid_presence)
size = GTPV2C_HEADER_LEN;
else
size = GTPV2C_HEADER_LEN-GTPV2C_TEID_LEN;
size = GTPV2C_HEADER_LEN-GTP_TEID_LEN;
d_assert(pkbuf_header(pkbuf, -size) == CORE_OK,
return CORE_ERROR, "pkbuf_header error");

View File

@ -26,7 +26,7 @@
/*******************************************************************************
* This file had been created by gtp_tlv.py script v0.1.0
* Please do not modify this file but regenerate it via script.
* Created on: 2017-08-31 12:05:13.838521 by acetcom
* Created on: 2017-09-07 14:05:57.076773 by acetcom
* from 29274-d80.docx
******************************************************************************/
@ -40,8 +40,9 @@ extern "C" {
#endif /* __cplusplus */
/* 5.1 General format */
#define GTPV1U_HEADER_LEN 8
#define GTPV2C_HEADER_LEN 12
#define GTPV2C_TEID_LEN 4
#define GTP_TEID_LEN 4
typedef struct _gtp_header_t {
union {
struct {

View File

@ -395,8 +395,9 @@ extern "C" {
#endif /* __cplusplus */
/* 5.1 General format */
#define GTPV1U_HEADER_LEN 8
#define GTPV2C_HEADER_LEN 12
#define GTPV2C_TEID_LEN 4
#define GTP_TEID_LEN 4
typedef struct _gtp_header_t {
union {
struct {
@ -628,7 +629,7 @@ f.write("""status_t gtp_parse_msg(gtp_message_t *gtp_message, pkbuf_t *pkbuf)
if (h->teid_presence)
size = GTPV2C_HEADER_LEN;
else
size = GTPV2C_HEADER_LEN-GTPV2C_TEID_LEN;
size = GTPV2C_HEADER_LEN-GTP_TEID_LEN;
d_assert(pkbuf_header(pkbuf, -size) == CORE_OK,
return CORE_ERROR, "pkbuf_header error");

View File

@ -17,7 +17,7 @@ static int _gtpv1_tun_recv_cb(net_link_t *net_link, void *data)
status_t rv;
pgw_bearer_t *bearer = NULL;
recvbuf = pkbuf_alloc(sizeof(gtp_header_t), MAX_SDU_LEN);
recvbuf = pkbuf_alloc(GTPV1U_HEADER_LEN, MAX_SDU_LEN);
d_assert(recvbuf, return -1, "pkbuf_alloc error");
n = net_link_read(net_link, recvbuf->payload, recvbuf->len, 0);
@ -41,7 +41,7 @@ static int _gtpv1_tun_recv_cb(net_link_t *net_link, void *data)
char buf[INET_ADDRSTRLEN];
/* Add GTP-U header */
rv = pkbuf_header(recvbuf, sizeof(gtp_header_t));
rv = pkbuf_header(recvbuf, GTPV1U_HEADER_LEN);
if (rv != CORE_OK)
{
d_error("pkbuf_header error");
@ -135,7 +135,7 @@ static int _gtpv2_c_recv_cb(net_sock_t *sock, void *data)
static int _gtpv1_u_recv_cb(net_sock_t *sock, void *data)
{
pkbuf_t *pkbuf = NULL;
c_uint32_t size = sizeof(gtp_header_t);
c_uint32_t size = GTPV1U_HEADER_LEN;
d_assert(sock, return -1, "Null param");