Mercurial > hg > freeDiameter
changeset 395:8e26b203e3cb
Fix issue for buggy RADIUS routeurs that use the same identifier again and again
author | Sebastien Decugis <sdecugis@nict.go.jp> |
---|---|
date | Wed, 07 Jul 2010 17:53:18 +0900 |
parents | fb9ed45f9217 |
children | 918fbb92eb8b |
files | extensions/app_radgw/rgw_clients.c |
diffstat | 1 files changed, 6 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/extensions/app_radgw/rgw_clients.c Wed Jul 07 16:52:17 2010 +0900 +++ b/extensions/app_radgw/rgw_clients.c Wed Jul 07 17:53:18 2010 +0900 @@ -80,6 +80,7 @@ struct { uint16_t port; uint8_t id; + uint8_t auth[16]; /* we also compare the request authenticator to avoid buggy NASes */ struct radius_msg * ans; /* to be able to resend a lost answer */ } last[2]; /*[0] for auth, [1] for acct. */ }; @@ -250,7 +251,9 @@ else idx = 1; - if ((cli->last[idx].id == (*msg)->radius.hdr->identifier) && (cli->last[idx].port == (*msg)->port)) { + if ((cli->last[idx].id == (*msg)->radius.hdr->identifier) + && (cli->last[idx].port == (*msg)->port) + && !memcmp(&cli->last[idx].auth[0], &(*msg)->radius.hdr->authenticator[0], 16)) { /* Duplicate! */ TRACE_DEBUG(INFO, "Received duplicated RADIUS message (id: %02hhx, port: %hu).", (*msg)->radius.hdr->identifier, ntohs((*msg)->port)); if (cli->last[idx].ans) { @@ -265,11 +268,13 @@ ASSERT(cli->last[idx].ans == NULL); cli->last[idx].id = (*msg)->radius.hdr->identifier; cli->last[idx].port = (*msg)->port; + memcpy(&cli->last[idx].auth[0], &(*msg)->radius.hdr->authenticator[0], 16); } else { /* We have got previous message(s), update the info only if answered already */ if (cli->last[idx].ans) { cli->last[idx].id = (*msg)->radius.hdr->identifier; cli->last[idx].port = (*msg)->port; + memcpy(&cli->last[idx].auth[0], &(*msg)->radius.hdr->authenticator[0], 16); /* Free the previous answer */ radius_msg_free(cli->last[idx].ans); free(cli->last[idx].ans);