diff options
-rw-r--r-- | gtp/gtp.c | 68 | ||||
-rw-r--r-- | sgsnemu/sgsnemu.c | 10 |
2 files changed, 43 insertions, 35 deletions
@@ -1554,8 +1554,8 @@ int gtp_create_pdp_conf(struct gsn_t *gsn, int version, gtp_errpack(LOG_ERR, __FILE__, __LINE__, peer, pack, len, "Invalid message format"); if (gsn->cb_conf) gsn->cb_conf(type, EOF, pdp, cbp); - if (gsn->cb_delete_context) gsn->cb_delete_context(pdp); - pdp_freepdp(pdp); + /* if (gsn->cb_delete_context) gsn->cb_delete_context(pdp); + pdp_freepdp(pdp); */ return EOF; } @@ -1565,8 +1565,8 @@ int gtp_create_pdp_conf(struct gsn_t *gsn, int version, gtp_errpack(LOG_ERR, __FILE__, __LINE__, peer, pack, len, "Missing mandatory information field"); if (gsn->cb_conf) gsn->cb_conf(type, EOF, pdp, cbp); - if (gsn->cb_delete_context) gsn->cb_delete_context(pdp); - pdp_freepdp(pdp); + /* if (gsn->cb_delete_context) gsn->cb_delete_context(pdp); + pdp_freepdp(pdp); */ return EOF; } @@ -1590,8 +1590,8 @@ int gtp_create_pdp_conf(struct gsn_t *gsn, int version, gtp_errpack(LOG_ERR, __FILE__, __LINE__, peer, pack, len, "Missing conditional information field"); if (gsn->cb_conf) gsn->cb_conf(type, EOF, pdp, cbp); - if (gsn->cb_delete_context) gsn->cb_delete_context(pdp); - pdp_freepdp(pdp); + /* if (gsn->cb_delete_context) gsn->cb_delete_context(pdp); + pdp_freepdp(pdp); */ return EOF; } } @@ -1600,9 +1600,9 @@ int gtp_create_pdp_conf(struct gsn_t *gsn, int version, gsn->missing++; gtp_errpack(LOG_ERR, __FILE__, __LINE__, peer, pack, len, "Missing conditional information field"); - if (gsn->cb_delete_context) gsn->cb_delete_context(pdp); - pdp_freepdp(pdp); if (gsn->cb_conf) gsn->cb_conf(type, EOF, pdp, cbp); + /* if (gsn->cb_delete_context) gsn->cb_delete_context(pdp); + pdp_freepdp(pdp); */ return EOF; } @@ -1612,8 +1612,8 @@ int gtp_create_pdp_conf(struct gsn_t *gsn, int version, gtp_errpack(LOG_ERR, __FILE__, __LINE__, peer, pack, len, "Missing conditional information field"); if (gsn->cb_conf) gsn->cb_conf(type, EOF, pdp, cbp); - if (gsn->cb_delete_context) gsn->cb_delete_context(pdp); - pdp_freepdp(pdp); + /* if (gsn->cb_delete_context) gsn->cb_delete_context(pdp); + pdp_freepdp(pdp); */ return EOF; } @@ -1622,8 +1622,8 @@ int gtp_create_pdp_conf(struct gsn_t *gsn, int version, gtp_errpack(LOG_ERR, __FILE__, __LINE__, peer, pack, len, "Missing conditional information field"); if (gsn->cb_conf) gsn->cb_conf(type, EOF, pdp, cbp); - if (gsn->cb_delete_context) gsn->cb_delete_context(pdp); - pdp_freepdp(pdp); + /* if (gsn->cb_delete_context) gsn->cb_delete_context(pdp); + pdp_freepdp(pdp); */ return EOF; } } @@ -1634,8 +1634,8 @@ int gtp_create_pdp_conf(struct gsn_t *gsn, int version, gtp_errpack(LOG_ERR, __FILE__, __LINE__, peer, pack, len, "Missing conditional information field"); if (gsn->cb_conf) gsn->cb_conf(type, EOF, pdp, cbp); - if (gsn->cb_delete_context) gsn->cb_delete_context(pdp); - pdp_freepdp(pdp); + /* if (gsn->cb_delete_context) gsn->cb_delete_context(pdp); + pdp_freepdp(pdp); */ return EOF; } @@ -1644,8 +1644,8 @@ int gtp_create_pdp_conf(struct gsn_t *gsn, int version, gtp_errpack(LOG_ERR, __FILE__, __LINE__, peer, pack, len, "Missing conditional information field"); if (gsn->cb_conf) gsn->cb_conf(type, EOF, pdp, cbp); - if (gsn->cb_delete_context) gsn->cb_delete_context(pdp); - pdp_freepdp(pdp); + /* if (gsn->cb_delete_context) gsn->cb_delete_context(pdp); + pdp_freepdp(pdp); */ return EOF; } } @@ -1655,8 +1655,8 @@ int gtp_create_pdp_conf(struct gsn_t *gsn, int version, gtp_errpack(LOG_ERR, __FILE__, __LINE__, peer, pack, len, "Missing conditional information field"); if (gsn->cb_conf) gsn->cb_conf(type, EOF, pdp, cbp); - if (gsn->cb_delete_context) gsn->cb_delete_context(pdp); - pdp_freepdp(pdp); + /* if (gsn->cb_delete_context) gsn->cb_delete_context(pdp); + pdp_freepdp(pdp); */ } if (gtpie_gettlv(ie, GTPIE_EUA, 0, &pdp->eua.l, @@ -1665,8 +1665,8 @@ int gtp_create_pdp_conf(struct gsn_t *gsn, int version, gtp_errpack(LOG_ERR, __FILE__, __LINE__, peer, pack, len, "Missing conditional information field"); if (gsn->cb_conf) gsn->cb_conf(type, EOF, pdp, cbp); - if (gsn->cb_delete_context) gsn->cb_delete_context(pdp); - pdp_freepdp(pdp); + /* if (gsn->cb_delete_context) gsn->cb_delete_context(pdp); + pdp_freepdp(pdp); */ return EOF; } @@ -1676,8 +1676,8 @@ int gtp_create_pdp_conf(struct gsn_t *gsn, int version, gtp_errpack(LOG_ERR, __FILE__, __LINE__, peer, pack, len, "Missing conditional information field"); if (gsn->cb_conf) gsn->cb_conf(type, EOF, pdp, cbp); - if (gsn->cb_delete_context) gsn->cb_delete_context(pdp); - pdp_freepdp(pdp); + /* if (gsn->cb_delete_context) gsn->cb_delete_context(pdp); + pdp_freepdp(pdp); */ return EOF; } @@ -1687,8 +1687,8 @@ int gtp_create_pdp_conf(struct gsn_t *gsn, int version, gtp_errpack(LOG_ERR, __FILE__, __LINE__, peer, pack, len, "Missing conditional information field"); if (gsn->cb_conf) gsn->cb_conf(type, EOF, pdp, cbp); - if (gsn->cb_delete_context) gsn->cb_delete_context(pdp); - pdp_freepdp(pdp); + /* if (gsn->cb_delete_context) gsn->cb_delete_context(pdp); + pdp_freepdp(pdp); */ return EOF; } @@ -1699,8 +1699,8 @@ int gtp_create_pdp_conf(struct gsn_t *gsn, int version, gtp_errpack(LOG_ERR, __FILE__, __LINE__, peer, pack, len, "Missing conditional information field"); if (gsn->cb_conf) gsn->cb_conf(type, EOF, pdp, cbp); - if (gsn->cb_delete_context) gsn->cb_delete_context(pdp); - pdp_freepdp(pdp); + /* if (gsn->cb_delete_context) gsn->cb_delete_context(pdp); + pdp_freepdp(pdp); */ return EOF; } } @@ -2101,8 +2101,8 @@ int gtp_update_pdp_conf(struct gsn_t *gsn, int version, gtp_errpack(LOG_ERR, __FILE__, __LINE__, peer, pack, len, "Invalid message format"); if (gsn->cb_conf) gsn->cb_conf(type, EOF, pdp, cbp); - if (gsn->cb_delete_context) gsn->cb_delete_context(pdp); - pdp_freepdp(pdp); + /* if (gsn->cb_delete_context) gsn->cb_delete_context(pdp); + pdp_freepdp(pdp); */ return EOF; } @@ -2112,8 +2112,8 @@ int gtp_update_pdp_conf(struct gsn_t *gsn, int version, gtp_errpack(LOG_ERR, __FILE__, __LINE__, peer, pack, len, "Missing mandatory information field"); if (gsn->cb_conf) gsn->cb_conf(type, EOF, pdp, cbp); - if (gsn->cb_delete_context) gsn->cb_delete_context(pdp); - pdp_freepdp(pdp); + /* if (gsn->cb_delete_context) gsn->cb_delete_context(pdp); + pdp_freepdp(pdp); */ return EOF; } @@ -2125,8 +2125,8 @@ int gtp_update_pdp_conf(struct gsn_t *gsn, int version, /* Check all conditional information elements */ if (GTPCAUSE_ACC_REQ != cause) { if (gsn->cb_conf) gsn->cb_conf(type, cause, pdp, cbp); - if (gsn->cb_delete_context) gsn->cb_delete_context(pdp); - pdp_freepdp(pdp); + /* if (gsn->cb_delete_context) gsn->cb_delete_context(pdp); + pdp_freepdp(pdp); */ return 0; } else { @@ -2143,8 +2143,8 @@ int gtp_update_pdp_conf(struct gsn_t *gsn, int version, gtp_errpack(LOG_ERR, __FILE__, __LINE__, peer, pack, len, "Missing conditional information field"); if (gsn->cb_conf) gsn->cb_conf(type, EOF, pdp, cbp); - if (gsn->cb_delete_context) gsn->cb_delete_context(pdp); - pdp_freepdp(pdp); + /* if (gsn->cb_delete_context) gsn->cb_delete_context(pdp); + pdp_freepdp(pdp); */ return EOF; } diff --git a/sgsnemu/sgsnemu.c b/sgsnemu/sgsnemu.c index 9befbfb..e636f1b 100644 --- a/sgsnemu/sgsnemu.c +++ b/sgsnemu/sgsnemu.c @@ -791,6 +791,8 @@ int create_pdp_conf(struct pdp_t *pdp, void *cbp, int cause) { } else { state = 0; + pdp_freepdp(iph->pdp); + iph->pdp = NULL; return EOF; } } @@ -798,11 +800,15 @@ int create_pdp_conf(struct pdp_t *pdp, void *cbp, int cause) { if (cause != 128) { printf("Received create PDP context response. Cause value: %d\n", cause); state = 0; + pdp_freepdp(iph->pdp); + iph->pdp = NULL; return EOF; /* Not what we expected */ } if (pdp_euaton(&pdp->eua, &addr)) { printf("Received create PDP context response. Cause value: %d\n", cause); + pdp_freepdp(iph->pdp); + iph->pdp = NULL; state = 0; return EOF; /* Not a valid IP address */ } @@ -943,7 +949,9 @@ int main(int argc, char **argv) printf("Setting up PDP context #%d\n", n); iparr[n].inuse = 1; /* TODO */ - /* Allocated here. Cleaned up in gtp.c:*/ + /* Allocated here. */ + /* If create context failes we have to deallocate ourselves. */ + /* Otherwise it is deallocated gy gtplib */ pdp_newpdp(&pdp, options.imsi, n, NULL); pdp->peer = &iparr[n]; |