Mercurial > hg > freeDiameter
changeset 130:a16504d20ed1
Handle CEA with error result codes
author | Sebastien Decugis <sdecugis@nict.go.jp> |
---|---|
date | Thu, 10 Dec 2009 15:56:56 +0900 |
parents | b20b2aeeb160 |
children | 50d1dc19b221 |
files | freeDiameter/p_ce.c |
diffstat | 1 files changed, 23 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/freeDiameter/p_ce.c Thu Dec 10 15:46:06 2009 +0900 +++ b/freeDiameter/p_ce.c Thu Dec 10 15:56:56 2009 +0900 @@ -282,6 +282,23 @@ } switch (hdr->avp_code) { + case AC_RESULT_CODE: /* Result-Code */ + if (hdr->avp_value == NULL) { + /* This is a sanity check */ + TRACE_DEBUG(NONE, "Ignored an AVP with unset value in CER/CEA"); + fd_msg_dump_one(NONE, avp); + ASSERT(0); /* To check if this really happens, and understand why... */ + goto next; + } + + /* We check that the CEA Result-Code is Success, otherwise we disconnect */ + if (hdr->avp_value->u32 != ER_DIAMETER_SUCCESS) { + TRACE_DEBUG(INFO, "Received CEA with Result-Code %d (expected %d), disconnect", hdr->avp_value->u32, ER_DIAMETER_SUCCESS); + return EBADMSG; + } + + break; + case AC_ORIGIN_HOST: /* Origin-Host */ if (hdr->avp_value == NULL) { /* This is a sanity check */ @@ -625,7 +642,7 @@ TRACE_ENTRY("%p %p", msg, peer); CHECK_PARAMS( msg && *msg && CHECK_PEER(peer) ); - /* The only valid situation where we are called is in WAITCEA and we receive a CEA */ + /* The only valid situation where we are called is in WAITCEA and we receive a CEA (we may have won an election) */ /* Note : to implement Capabilities Update, we would need to change here */ @@ -695,6 +712,11 @@ return 0; cleanup: + if (*msg) { + CHECK_FCT_DO( fd_msg_free(*msg), /* continue */ ); + *msg = NULL; + } + fd_p_ce_clear_cnx(peer, NULL); /* Send the error to the peer */